From ce9fce7985bfbc595dc08ab29db618e0db6f5ac6 Mon Sep 17 00:00:00 2001 From: Stefan Reiter Date: Thu, 6 Feb 2020 10:53:52 +0100 Subject: [PATCH] qmp: use 'blockdev-change-medium' instead of generic 'change' ...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 --- PVE/QemuServer.pm | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index 2762dde..12e6398 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.39.2