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

Alexandre DERUMIER aderumier at odiso.com
Thu Apr 30 11:43:53 CEST 2015


Hi,

does it make sense to define

+my $snap_storage = {zfspool => 1, rbd => 1, zfs => 1, sheepdog => 1};
..
sub storage_support_snapshot()

in qemuserver ?


Couldn't we reuse volume_has_feature from storage plugins ?







----- Mail original -----
De: "Wolfgang Link" <w.link at proxmox.com>
À: "pve-devel" <pve-devel at pve.proxmox.com>
Envoyé: Jeudi 30 Avril 2015 09:47:03
Objet: [pve-devel] [PATCH] remove running from Storage and check it in	QemuServer

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 


_______________________________________________ 
pve-devel mailing list 
pve-devel at pve.proxmox.com 
http://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel 


More information about the pve-devel mailing list