...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.rei...@proxmox.com>
---
 PVE/QemuServer.pm | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 9e00c8a..ff2e3ee 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -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;
-- 
2.20.1


_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to