]> git.proxmox.com Git - qemu-server.git/commitdiff
qmp: use 'blockdev-change-medium' instead of generic 'change'
authorStefan Reiter <s.reiter@proxmox.com>
Thu, 6 Feb 2020 09:53:52 +0000 (10:53 +0100)
committerThomas Lamprecht <t.lamprecht@proxmox.com>
Thu, 6 Feb 2020 12:50:33 +0000 (13:50 +0100)
...and cleanup surrounding code a bit.

'change' is deprecated, and according to the qapi definition in QEMU it
is 'strongly recommended' to avoid using it.

Signed-off-by: Stefan Reiter <s.reiter@proxmox.com>
PVE/QemuServer.pm

index 2762dde93b95ba8f7b9f73c7f376ee09255accc2..12e63980e137baf9d27ad8206d128bf29cc28d3c 100644 (file)
@@ -5131,14 +5131,20 @@ sub vmconfig_update_disk {
            } else { # cdrom
 
                if ($drive->{file} eq 'none') {
-                   mon_cmd($vmid, "eject",force => JSON::true,device => "drive-$opt");
+                   mon_cmd($vmid, "eject", force => JSON::true, device => "drive-$opt");
                    if (drive_is_cloudinit($old_drive)) {
                        vmconfig_register_unused_drive($storecfg, $vmid, $conf, $old_drive);
                    }
                } else {
                    my $path = get_iso_path($storecfg, $vmid, $drive->{file});
-                   mon_cmd($vmid, "eject", force => JSON::true,device => "drive-$opt"); # force eject if locked
-                   mon_cmd($vmid, "change", device => "drive-$opt",target => "$path") if $path;
+
+                   # force eject if locked
+                   mon_cmd($vmid, "eject", force => JSON::true, device => "drive-$opt");
+
+                   if ($path) {
+                       mon_cmd($vmid, "blockdev-change-medium",
+                           device => "drive-$opt", filename => "$path");
+                   }
                }
 
                return 1;