From 4de1bb2523101e1197a8e2619badb2262b19ae78 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Thu, 12 Feb 2015 08:00:14 +0100 Subject: [PATCH] fix CDROM hotplug --- PVE/QemuServer.pm | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm index e5c79e3b..ee8ee8b2 100644 --- a/PVE/QemuServer.pm +++ b/PVE/QemuServer.pm @@ -4062,25 +4062,23 @@ sub vmconfig_update_disk { return 1; } + + } else { # cdrom + + if ($drive->{file} eq 'none') { + vm_mon_cmd($vmid, "eject",force => JSON::true,device => "drive-$opt"); + } else { + my $path = get_iso_path($storecfg, $vmid, $drive->{file}); + vm_mon_cmd($vmid, "eject", force => JSON::true,device => "drive-$opt"); # force eject if locked + vm_mon_cmd($vmid, "change", device => "drive-$opt",target => "$path") if $path; + } } } } - if (drive_is_cdrom($drive)) { # cdrom - - if ($drive->{file} eq 'none') { - vm_mon_cmd($vmid, "eject",force => JSON::true,device => "drive-$opt"); - } else { - my $path = get_iso_path($storecfg, $vmid, $drive->{file}); - vm_mon_cmd($vmid, "eject", force => JSON::true,device => "drive-$opt"); # force eject if locked - vm_mon_cmd($vmid, "change", device => "drive-$opt",target => "$path") if $path; - } - - } else { - die "skip\n" if !$hotplug || $opt =~ m/(ide|sata)(\d+)/; - # hotplug new disks - vm_deviceplug($storecfg, $conf, $vmid, $opt, $drive); - } + die "skip\n" if !$hotplug || $opt =~ m/(ide|sata)(\d+)/; + # hotplug new disks + vm_deviceplug($storecfg, $conf, $vmid, $opt, $drive); } sub vm_start { -- 2.39.5