[pve-devel] [PATCH 1/3] hot-unplug : don't unplug disks if hotplug config option < 2.

Alexandre Derumier aderumier at odiso.com
Thu Feb 21 18:44:16 CET 2013


Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/QemuServer.pm |   18 +++++++++++-------
 1 file changed, 11 insertions(+), 7 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index fb672eb..5e02734 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -165,8 +165,10 @@ my $confdesc = {
     },
     hotplug => {
         optional => 1,
-        type => 'boolean',
+        type => 'integer',
         description => "Allow hotplug for disk and network device",
+        minimum => 0,
+        maximum => 2,
         default => 1,
     },
     reboot => {
@@ -2591,6 +2593,14 @@ sub vm_deviceunplug {
     my $devices_list = vm_devices_list($vmid);
     return 1 if !defined($devices_list->{$deviceid});
 
+    if ($deviceid =~ m/^(net)(\d+)$/) {
+        return undef if !qemu_netdevdel($vmid, $deviceid);
+        qemu_devicedel($vmid, $deviceid);
+        return undef if !qemu_devicedelverify($vmid, $deviceid);
+    }
+    
+    return 1 if (!$conf->{hotplug} || (defined($conf->{hotplug}) && $conf->{hotplug} < 2));
+
     die "can't unplug bootdisk" if $conf->{bootdisk} && $conf->{bootdisk} eq $deviceid;
 
     if ($deviceid =~ m/^(virtio)(\d+)$/) {
@@ -2608,12 +2618,6 @@ sub vm_deviceunplug {
         return undef if !qemu_drivedel($vmid, $deviceid);
     }
 
-    if ($deviceid =~ m/^(net)(\d+)$/) {
-        return undef if !qemu_netdevdel($vmid, $deviceid);
-        qemu_devicedel($vmid, $deviceid);
-        return undef if !qemu_devicedelverify($vmid, $deviceid);
-    }
-
     return 1;
 }
 
-- 
1.7.10.4




More information about the pve-devel mailing list