mirror of
https://git.proxmox.com/git/qemu-server
synced 2025-05-03 01:29:13 +00:00
implement virtio iothread hotplug
Signed-off-by: Alexandre Derumier <aderumier@odiso.com>
This commit is contained in:
parent
51f492cd6d
commit
22de899a80
@ -3270,6 +3270,8 @@ sub vm_deviceplug {
|
|||||||
|
|
||||||
} elsif ($deviceid =~ m/^(virtio)(\d+)$/) {
|
} elsif ($deviceid =~ m/^(virtio)(\d+)$/) {
|
||||||
|
|
||||||
|
qemu_iothread_add($vmid, $deviceid, $device);
|
||||||
|
|
||||||
qemu_driveadd($storecfg, $vmid, $device);
|
qemu_driveadd($storecfg, $vmid, $device);
|
||||||
my $devicefull = print_drivedevice_full($storecfg, $conf, $vmid, $device);
|
my $devicefull = print_drivedevice_full($storecfg, $conf, $vmid, $device);
|
||||||
|
|
||||||
@ -3349,6 +3351,7 @@ sub vm_deviceunplug {
|
|||||||
qemu_devicedel($vmid, $deviceid);
|
qemu_devicedel($vmid, $deviceid);
|
||||||
qemu_devicedelverify($vmid, $deviceid);
|
qemu_devicedelverify($vmid, $deviceid);
|
||||||
qemu_drivedel($vmid, $deviceid);
|
qemu_drivedel($vmid, $deviceid);
|
||||||
|
qemu_iothread_del($conf, $vmid, $deviceid);
|
||||||
|
|
||||||
} elsif ($deviceid =~ m/^(scsihw)(\d+)$/) {
|
} elsif ($deviceid =~ m/^(scsihw)(\d+)$/) {
|
||||||
|
|
||||||
@ -3389,6 +3392,25 @@ sub qemu_devicedel {
|
|||||||
my $ret = vm_mon_cmd($vmid, "device_del", id => $deviceid);
|
my $ret = vm_mon_cmd($vmid, "device_del", id => $deviceid);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub qemu_iothread_add {
|
||||||
|
my($vmid, $deviceid, $device) = @_;
|
||||||
|
|
||||||
|
if ($device->{iothread}) {
|
||||||
|
my $iothreads = vm_iothreads_list($vmid);
|
||||||
|
qemu_objectadd($vmid, "iothread-$deviceid", "iothread") if !$iothreads->{"iothread-$deviceid"};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
sub qemu_iothread_del {
|
||||||
|
my($conf, $vmid, $deviceid) = @_;
|
||||||
|
|
||||||
|
my $device = parse_drive($deviceid, $conf->{$deviceid});
|
||||||
|
if ($device->{iothread}) {
|
||||||
|
my $iothreads = vm_iothreads_list($vmid);
|
||||||
|
qemu_objectdel($vmid, "iothread-$deviceid") if $iothreads->{"iothread-$deviceid"};
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
sub qemu_objectadd {
|
sub qemu_objectadd {
|
||||||
my($vmid, $objectid, $qomtype) = @_;
|
my($vmid, $objectid, $qomtype) = @_;
|
||||||
|
|
||||||
@ -4078,6 +4100,7 @@ sub vmconfig_update_disk {
|
|||||||
|
|
||||||
# skip non hotpluggable value
|
# skip non hotpluggable value
|
||||||
if (&$safe_num_ne($drive->{discard}, $old_drive->{discard}) ||
|
if (&$safe_num_ne($drive->{discard}, $old_drive->{discard}) ||
|
||||||
|
&$safe_string_ne($drive->{iothread}, $old_drive->{iothread}) ||
|
||||||
&$safe_string_ne($drive->{cache}, $old_drive->{cache})) {
|
&$safe_string_ne($drive->{cache}, $old_drive->{cache})) {
|
||||||
die "skip\n";
|
die "skip\n";
|
||||||
}
|
}
|
||||||
@ -6191,4 +6214,17 @@ sub lspci {
|
|||||||
return $devices;
|
return $devices;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
sub vm_iothreads_list {
|
||||||
|
my ($vmid) = @_;
|
||||||
|
|
||||||
|
my $res = vm_mon_cmd($vmid, 'query-iothreads');
|
||||||
|
|
||||||
|
my $iothreads = {};
|
||||||
|
foreach my $iothread (@$res) {
|
||||||
|
$iothreads->{ $iothread->{id} } = $iothread->{"thread-id"};
|
||||||
|
}
|
||||||
|
|
||||||
|
return $iothreads;
|
||||||
|
}
|
||||||
|
|
||||||
1;
|
1;
|
||||||
|
Loading…
Reference in New Issue
Block a user