[pve-devel] [PATCH] don't try to hotplug/unplug is device exist/don't exist

Derumier Alexandre aderumier at odiso.com
Sun Feb 5 14:19:06 CET 2012


Signed-off-by: Derumier Alexandre <aderumier at odiso.com>
---
 PVE/QemuServer.pm |    6 ++++++
 1 files changed, 6 insertions(+), 0 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 942432b..e1a4cfd 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -2228,6 +2228,9 @@ sub vm_deviceplug {
 
     return 1 if !check_running($vmid) || !$conf->{hotplug};
 
+    my $devices_list = vm_devices_list($vmid);
+    return 1 if defined($devices_list->{$deviceid});
+
     if ($deviceid =~ m/^(virtio)(\d+)$/) {
         return undef if !qemu_driveadd($storecfg, $vmid, $device);
         my $devicefull = print_drivedevice_full($storecfg, $vmid, $device);
@@ -2273,6 +2276,9 @@ sub vm_deviceunplug {
 
     return 1 if !check_running ($vmid) || !$conf->{hotplug};
 
+    my $devices_list = vm_devices_list($vmid);
+    return 1 if !defined($devices_list->{$deviceid});
+
     die "can't unplug bootdisk" if $conf->{bootdisk} && $conf->{bootdisk} eq $deviceid;
 
     if ($deviceid =~ m/^(virtio)(\d+)$/) {
-- 
1.7.2.5



More information about the pve-devel mailing list