[pve-devel] [PATCH 4/6] add vm_devicedel sub
Derumier Alexandre
aderumier at odiso.com
Mon Oct 10 16:46:56 CEST 2011
use qm monitor to hot-unplug device.
Currently only virtio disk
Signed-off-by: Derumier Alexandre <aderumier at odiso.com>
---
PVE/QemuServer.pm | 20 ++++++++++++++++++++
1 files changed, 20 insertions(+), 0 deletions(-)
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 4e41e2a..80ab7c7 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -2293,6 +2293,26 @@ sub vm_deviceadd {
}
+sub vm_devicedel {
+ my ($vmid,$deviceid) = @_;
+
+ my $cfspath = cfs_config_path($vmid);
+ my $conf = PVE::Cluster::cfs_read_file($cfspath) || {};
+
+ return if !check_running ($vmid) || $conf->{hotplug} != 1 ;
+
+ if($deviceid =~ m/^(virtio)(\d+)$/){
+
+ vm_monitor_command ($vmid, "drive_del drive-$deviceid",1);
+ vm_monitor_command ($vmid, "device_del $deviceid",1);
+
+ }
+
+ sleep 2;
+ my $devices_list=vm_devices_list($vmid);
+ die "error on hot-unplugging device " if(defined $devices_list->{$deviceid});
+}
+
sub vm_start {
my ($storecfg, $vmid, $statefile, $skiplock) = @_;
--
1.7.2.5
More information about the pve-devel
mailing list