[pve-devel] [PATCH] remove running from Storage and check it in QemuServer

Wolfgang Link w.link at proxmox.com
Thu Apr 30 09:47:03 CEST 2015


It is better to check if a VM is running in QemuServer then in Storage.
for the Storage there is no difference if it is running or not.

Signed-off-by: Wolfgang Link <w.link at proxmox.com>
---
 PVE/QemuServer.pm | 21 ++++++++++++++++++++-
 1 file changed, 20 insertions(+), 1 deletion(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 708b208..39aff42 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -31,6 +31,8 @@ use PVE::QMPClient;
 use PVE::RPCEnvironment;
 use Time::HiRes qw(gettimeofday);
 
+my $snap_storage = {zfspool => 1, rbd => 1, zfs => 1, sheepdog => 1};
+
 my $cpuinfo = PVE::ProcFSTools::read_cpuinfo();
 
 # Note about locking: we use flock on the config file protect
@@ -3777,7 +3779,7 @@ sub qemu_volume_snapshot {
 
     my $running = check_running($vmid);
 
-    return if !PVE::Storage::volume_snapshot($storecfg, $volid, $snap, $running);
+    PVE::Storage::volume_snapshot($storecfg, $volid, $snap) if storage_support_snapshop($volid, $storecfg);
 
     return if !$running;
 
@@ -5772,6 +5774,23 @@ my $savevm_wait = sub {
     }
 };
 
+sub storage_support_snapshot {
+    my ($volid, $storecfg) = @_;
+
+    my $storage_name = PVE::Storage::parse_volume_id($volid);
+
+    my $ret = undef;  
+    if ($snap_storage->{$storecfg->{ids}->{$storage_name}->{type}} ){
+	$ret = 1;
+    }
+
+    if ($volid =~ m/\.(qcow2|qed)$/){
+	$ret = 1;
+    }
+
+    return $ret;
+}
+
 sub snapshot_create {
     my ($vmid, $snapname, $save_vmstate, $comment) = @_;
 
-- 
2.1.4





More information about the pve-devel mailing list