mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-04-30 19:31:54 +00:00
use 'boolean' for hotplug option
cleanup coding style
This commit is contained in:
parent
2bbed6c09a
commit
e8b9c17cac
@ -155,7 +155,7 @@ my $confdesc = {
|
||||
},
|
||||
hotplug => {
|
||||
optional => 1,
|
||||
type => 'integer',
|
||||
type => 'boolean',
|
||||
description => "Activate hotplug for disk and network device",
|
||||
default => 0,
|
||||
},
|
||||
@ -2277,20 +2277,20 @@ sub vm_deviceadd {
|
||||
my $cfspath = cfs_config_path($vmid);
|
||||
my $conf = PVE::Cluster::cfs_read_file($cfspath) || {};
|
||||
|
||||
return if !check_running ($vmid) || $conf->{hotplug} != 1 ; # do nothing if vm is running or hotplug option not set to 1
|
||||
return if !check_running($vmid) || !$conf->{hotplug};
|
||||
|
||||
if($deviceid =~ m/^(virtio)(\d+)$/) {
|
||||
|
||||
my $drive = print_drive_full ($storecfg,$vmid, $device);
|
||||
vm_monitor_command ($vmid, "drive_add auto $drive", 1);
|
||||
my $devicefull = print_drivedevice_full ($storecfg,$vmid, $device);
|
||||
vm_monitor_command ($vmid, "device_add $devicefull", 1);
|
||||
my $drive = print_drive_full($storecfg,$vmid, $device);
|
||||
vm_monitor_command($vmid, "drive_add auto $drive", 1);
|
||||
my $devicefull = print_drivedevice_full($storecfg,$vmid, $device);
|
||||
vm_monitor_command($vmid, "device_add $devicefull", 1);
|
||||
}
|
||||
|
||||
#verification
|
||||
sleep 2; #give a litlle time to os to add the device
|
||||
my $devices_list = vm_devices_list($vmid);
|
||||
die "error on hotplug device" if(! defined($devices_list->{$deviceid}));
|
||||
die "error on hotplug device" if !defined($devices_list->{$deviceid});
|
||||
|
||||
}
|
||||
|
||||
@ -2300,18 +2300,18 @@ sub vm_devicedel {
|
||||
my $cfspath = cfs_config_path($vmid);
|
||||
my $conf = PVE::Cluster::cfs_read_file($cfspath) || {};
|
||||
|
||||
return if !check_running ($vmid) || $conf->{hotplug} != 1 ;
|
||||
return if !check_running ($vmid) || !$conf->{hotplug};
|
||||
|
||||
if($deviceid =~ m/^(virtio)(\d+)$/){
|
||||
|
||||
vm_monitor_command ($vmid, "drive_del drive-$deviceid",1);
|
||||
vm_monitor_command ($vmid, "device_del $deviceid",1);
|
||||
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});
|
||||
my $devices_list = vm_devices_list($vmid);
|
||||
die "error on hot-unplugging device " if defined($devices_list->{$deviceid});
|
||||
}
|
||||
|
||||
sub vm_start {
|
||||
|
Loading…
Reference in New Issue
Block a user