add vm_devicedel sub

use qm monitor to hot-unplug device.

Currently only virtio disk

Signed-off-by: Derumier Alexandre <aderumier@odiso.com>
This commit is contained in:
Derumier Alexandre 2011-10-10 16:46:56 +02:00 committed by Dietmar Maurer
parent a4dea33125
commit 873c2d698f

View File

@ -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) = @_;