5
0
mirror of git://git.proxmox.com/git/qemu-server.git synced 2025-03-08 04:58:26 +03:00

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 <s.reiter@proxmox.com>
This commit is contained in:
Stefan Reiter 2020-02-06 10:53:52 +01:00 committed by Thomas Lamprecht
parent 9e7bce2c88
commit ce9fce7985

View 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;