mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-06-28 17:27:06 +00:00
hotplug/unplug tablet on config update
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
This commit is contained in:
parent
42869ac07d
commit
cd6ecb89eb
@ -649,6 +649,8 @@ my $vmconfig_delete_option = sub {
|
||||
|
||||
die "error hot-unplug $opt" if !PVE::QemuServer::vm_deviceunplug($vmid, $conf, $opt);
|
||||
|
||||
PVE::QemuServer::vm_deviceplug(undef, $conf, $vmid, $opt) if $opt eq 'tablet';
|
||||
|
||||
if ($isDisk) {
|
||||
my $drive = PVE::QemuServer::parse_drive($opt, $conf->{$opt});
|
||||
&$delete_drive($conf, $storecfg, $vmid, $opt, $drive, $force);
|
||||
@ -910,6 +912,12 @@ __PACKAGE__->register_method({
|
||||
|
||||
} else {
|
||||
|
||||
if($opt eq 'tablet' && $param->{$opt} == 1){
|
||||
PVE::QemuServer::vm_deviceplug(undef, $conf, $vmid, $opt);
|
||||
}elsif($opt eq 'tablet' && $param->{$opt} == 0){
|
||||
PVE::QemuServer::vm_deviceunplug($vmid, $conf, $opt);
|
||||
}
|
||||
|
||||
$conf->{$opt} = $param->{$opt};
|
||||
PVE::QemuServer::update_config_nolock($vmid, $conf, 1);
|
||||
}
|
||||
|
@ -2511,7 +2511,15 @@ sub vm_devices_list {
|
||||
sub vm_deviceplug {
|
||||
my ($storecfg, $conf, $vmid, $deviceid, $device) = @_;
|
||||
|
||||
return 1 if !check_running($vmid) || !$conf->{hotplug};
|
||||
return 1 if !check_running($vmid);
|
||||
|
||||
if ($deviceid eq 'tablet') {
|
||||
my $devicefull = "usb-tablet,id=tablet,bus=ehci.0,port=6";
|
||||
qemu_deviceadd($vmid, $devicefull);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 1 if !$conf->{hotplug};
|
||||
|
||||
my $devices_list = vm_devices_list($vmid);
|
||||
return 1 if defined($devices_list->{$deviceid});
|
||||
@ -2571,7 +2579,14 @@ sub vm_deviceplug {
|
||||
sub vm_deviceunplug {
|
||||
my ($vmid, $conf, $deviceid) = @_;
|
||||
|
||||
return 1 if !check_running ($vmid) || !$conf->{hotplug};
|
||||
return 1 if !check_running ($vmid);
|
||||
|
||||
if ($deviceid eq 'tablet') {
|
||||
qemu_devicedel($vmid, $deviceid);
|
||||
return 1;
|
||||
}
|
||||
|
||||
return 1 if!$conf->{hotplug};
|
||||
|
||||
my $devices_list = vm_devices_list($vmid);
|
||||
return 1 if !defined($devices_list->{$deviceid});
|
||||
|
Loading…
Reference in New Issue
Block a user