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

Wolfgang Link w.link at proxmox.com
Wed May 6 12:07:47 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/Storage.pm                   | 4 ++--
 PVE/Storage/ISCSIDirectPlugin.pm | 2 +-
 PVE/Storage/LVMPlugin.pm         | 2 +-
 PVE/Storage/Plugin.pm            | 4 +---
 PVE/Storage/RBDPlugin.pm         | 8 ++------
 PVE/Storage/SheepdogPlugin.pm    | 8 ++------
 PVE/Storage/ZFSPlugin.pm         | 4 +---
 PVE/Storage/ZFSPoolPlugin.pm     | 6 ++----
 8 files changed, 12 insertions(+), 26 deletions(-)

diff --git a/PVE/Storage.pm b/PVE/Storage.pm
index b542ee6..92c7d14 100755
--- a/PVE/Storage.pm
+++ b/PVE/Storage.pm
@@ -162,13 +162,13 @@ sub volume_rollback_is_possible {
 }
 
 sub volume_snapshot {
-    my ($cfg, $volid, $snap, $running) = @_;
+    my ($cfg, $volid, $snap) = @_;
 
     my ($storeid, $volname) = parse_volume_id($volid, 1);
     if ($storeid) {
         my $scfg = storage_config($cfg, $storeid);
         my $plugin = PVE::Storage::Plugin->lookup($scfg->{type});
-        return $plugin->volume_snapshot($scfg, $storeid, $volname, $snap, $running);
+        return $plugin->volume_snapshot($scfg, $storeid, $volname, $snap);
     } elsif ($volid =~ m|^(/.+)$| && -e $volid) {
         die "snapshot file/device '$volid' is not possible\n";
     } else {
diff --git a/PVE/Storage/ISCSIDirectPlugin.pm b/PVE/Storage/ISCSIDirectPlugin.pm
index c957ade..763c482 100644
--- a/PVE/Storage/ISCSIDirectPlugin.pm
+++ b/PVE/Storage/ISCSIDirectPlugin.pm
@@ -205,7 +205,7 @@ sub volume_resize {
 }
 
 sub volume_snapshot {
-    my ($class, $scfg, $storeid, $volname, $snap, $running) = @_;
+    my ($class, $scfg, $storeid, $volname, $snap) = @_;
     die "volume snapshot is not possible on iscsi device";
 }
 
diff --git a/PVE/Storage/LVMPlugin.pm b/PVE/Storage/LVMPlugin.pm
index 1688bb5..19eb78c 100644
--- a/PVE/Storage/LVMPlugin.pm
+++ b/PVE/Storage/LVMPlugin.pm
@@ -456,7 +456,7 @@ sub volume_resize {
 }
 
 sub volume_snapshot {
-    my ($class, $scfg, $storeid, $volname, $snap, $running) = @_;
+    my ($class, $scfg, $storeid, $volname, $snap) = @_;
 
     die "lvm snapshot is not implemented";
 }
diff --git a/PVE/Storage/Plugin.pm b/PVE/Storage/Plugin.pm
index 5b72b07..f119068 100644
--- a/PVE/Storage/Plugin.pm
+++ b/PVE/Storage/Plugin.pm
@@ -641,12 +641,10 @@ sub volume_resize {
 }
 
 sub volume_snapshot {
-    my ($class, $scfg, $storeid, $volname, $snap, $running) = @_;
+    my ($class, $scfg, $storeid, $volname, $snap) = @_;
 
     die "can't snapshot this image format\n" if $volname !~ m/\.(qcow2|qed)$/;
 
-    return 1 if $running;
-
     my $path = $class->filesystem_path($scfg, $volname);
 
     my $cmd = ['/usr/bin/qemu-img', 'snapshot','-c', $snap, $path];
diff --git a/PVE/Storage/RBDPlugin.pm b/PVE/Storage/RBDPlugin.pm
index 2c45a68..7aaa1f0 100644
--- a/PVE/Storage/RBDPlugin.pm
+++ b/PVE/Storage/RBDPlugin.pm
@@ -319,9 +319,7 @@ sub create_base {
     my $cmd = &$rbd_cmd($scfg, $storeid, 'rename', &$add_pool_to_disk($scfg, $name), &$add_pool_to_disk($scfg, $newname));
     run_rbd_command($cmd, errmsg => "rbd rename '$name' error");
 
-    my $running  = undef; #fixme : is create_base always offline ?
-
-    $class->volume_snapshot($scfg, $storeid, $newname, $snap, $running);
+    $class->volume_snapshot($scfg, $storeid, $newname, $snap);
 
     my (undef, undef, undef, $protected) = rbd_volume_info($scfg, $storeid, $newname, $snap);
 
@@ -510,9 +508,7 @@ sub volume_resize {
 }
 
 sub volume_snapshot {
-    my ($class, $scfg, $storeid, $volname, $snap, $running) = @_;
-
-    return 1 if $running;
+    my ($class, $scfg, $storeid, $volname, $snap) = @_;
 
     my ($vtype, $name, $vmid) = $class->parse_volname($volname);
 
diff --git a/PVE/Storage/SheepdogPlugin.pm b/PVE/Storage/SheepdogPlugin.pm
index 3e2c126..50bd1a8 100644
--- a/PVE/Storage/SheepdogPlugin.pm
+++ b/PVE/Storage/SheepdogPlugin.pm
@@ -207,9 +207,7 @@ sub create_base {
     run_command($cmd, errmsg => "sheepdog delete $volname' error");
 
     #create the base snapshot
-    my $running  = undef; #fixme : is create_base always offline ?
-
-    $class->volume_snapshot($scfg, $storeid, $newname, $snap, $running);
+    $class->volume_snapshot($scfg, $storeid, $newname, $snap);
 
     return $newvolname;
 }
@@ -389,9 +387,7 @@ sub volume_resize {
 }
 
 sub volume_snapshot {
-    my ($class, $scfg, $storeid, $volname, $snap, $running) = @_;
-
-    return 1 if $running;
+    my ($class, $scfg, $storeid, $volname, $snap) = @_;
 
     my ($vtype, $name, $vmid, $basename, $basevmid, $isBase) =
 	$class->parse_volname($volname);
diff --git a/PVE/Storage/ZFSPlugin.pm b/PVE/Storage/ZFSPlugin.pm
index e7acfb8..07afd1a 100644
--- a/PVE/Storage/ZFSPlugin.pm
+++ b/PVE/Storage/ZFSPlugin.pm
@@ -244,9 +244,7 @@ sub create_base {
     my $guid = $class->zfs_create_lu($scfg, $newname);
     $class->zfs_add_lun_mapping_entry($scfg, $newname, $guid);
 
-    my $running  = undef; #fixme : is create_base always offline ?
-
-    $class->volume_snapshot($scfg, $storeid, $newname, $snap, $running);
+    $class->volume_snapshot($scfg, $storeid, $newname, $snap);
 
     return $newvolname;
 }
diff --git a/PVE/Storage/ZFSPoolPlugin.pm b/PVE/Storage/ZFSPoolPlugin.pm
index 39fc348..62d35f4 100644
--- a/PVE/Storage/ZFSPoolPlugin.pm
+++ b/PVE/Storage/ZFSPoolPlugin.pm
@@ -415,7 +415,7 @@ sub volume_size_info {
 }
 
 sub volume_snapshot {
-    my ($class, $scfg, $storeid, $volname, $snap, $running) = @_;
+    my ($class, $scfg, $storeid, $volname, $snap) = @_;
 
     $class->zfs_request($scfg, undef, 'snapshot', "$scfg->{pool}/$volname\@$snap");
 }
@@ -505,9 +505,7 @@ sub create_base {
 
     $class->zfs_request($scfg, undef, 'rename', "$scfg->{pool}/$name", "$scfg->{pool}/$newname");
 
-    my $running  = undef; #fixme : is create_base always offline ?
-
-    $class->volume_snapshot($scfg, $storeid, $newname, $snap, $running);
+    $class->volume_snapshot($scfg, $storeid, $newname, $snap);
 
     return $newvolname;
 }
-- 
2.1.4





More information about the pve-devel mailing list