]> git.proxmox.com Git - qemu-server.git/commitdiff
Fix #1717: delete snapshot when vm running and drive not attached
authorAlexandre Derumier <aderumier@odiso.com>
Wed, 11 Jul 2018 11:55:53 +0000 (13:55 +0200)
committerWolfgang Bumiller <w.bumiller@proxmox.com>
Thu, 19 Jul 2018 08:42:03 +0000 (10:42 +0200)
changelog v2:
 - remove hash
 - remove check if cdrom

if we try to delete a snapshot, and that is disk from the snapshot
is not attached anymore (unused), we can't delete the snapshot
with qemu snapshot delete command (for storage which use it (qcow2,rbd,...))

example:

...
unused0: rbd:vm-107-disk-3

[snap1]
...
scsi2: rbd:vm-107-disk-3,size=1G

-> die
 qmp command 'delete-drive-snapshot' failed - Device 'drive-scsi2' not found

If drive is not attached, we need to use the storage snapshot delete command

PVE/QemuServer.pm

index 7357e3892abd9d7f41e4d67ff7dfb6fc61b4202a..a4ab11e2ec9d78349986c9e45230b9e7c4e74405 100644 (file)
@@ -4197,6 +4197,16 @@ sub qemu_volume_snapshot_delete {
 
     my $running = check_running($vmid);
 
+    if($running) {
+
+       $running = undef;
+       my $conf = PVE::QemuConfig->load_config($vmid);
+       foreach_drive($conf, sub {
+           my ($ds, $drive) = @_;
+           $running = 1 if $drive->{file} eq $volid;
+       });
+    }
+
     if ($running && do_snapshots_with_qemu($storecfg, $volid)){
        vm_mon_cmd($vmid, "delete-drive-snapshot", device => $deviceid, name => $snap);
     } else {