[pve-devel] [PATCH] iothreads : create 1 iothread by virtio device
Alexandre Derumier
aderumier at odiso.com
Mon Jan 12 10:56:04 CET 2015
for better performance, we create 1 iothread "iothread-deviceid" by virtio device.
we can hot-add|del iothread with object_add|del qmp command
Benched with rbd : I can reach around 40000iops by iothreads
Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
PVE/QemuServer.pm | 47 ++++++++++++++++++++++++++++++++++++++++++++---
1 file changed, 44 insertions(+), 3 deletions(-)
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 0e25148..087c508 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -1115,7 +1115,7 @@ sub print_drivedevice_full {
if ($drive->{interface} eq 'virtio') {
my $pciaddr = print_pci_addr("$drive->{interface}$drive->{index}", $bridges);
$device = "virtio-blk-pci,drive=drive-$drive->{interface}$drive->{index},id=$drive->{interface}$drive->{index}$pciaddr";
- $device .= ",iothread=iothread0" if $conf->{iothread};
+ $device .= ",iothread=iothread-$drive->{interface}$drive->{index}" if $conf->{iothread};
} elsif ($drive->{interface} eq 'scsi') {
$maxdev = ($conf->{scsihw} && ($conf->{scsihw} !~ m/^lsi/)) ? 256 : 7;
my $controller = int($drive->{index} / $maxdev);
@@ -2616,8 +2616,6 @@ sub config_to_command {
push @$cmd, '-smbios', "type=1,$conf->{smbios1}";
}
- push @$cmd, '-object', "iothread,id=iothread0" if $conf->{iothread};
-
if ($q35) {
# the q35 chipset support native usb2, so we enable usb controller
# by default for this machine type
@@ -3015,6 +3013,10 @@ sub config_to_command {
}
}
+ if($ds =~ m/^virtio/){
+ push @$cmd, '-object', "iothread,id=iothread-$ds" if $conf->{iothread};
+ }
+
if ($drive->{interface} eq 'scsi') {
my $maxdev = ($scsihw !~ m/^lsi/) ? 256 : 7;
@@ -3165,6 +3167,11 @@ sub vm_deviceplug {
} elsif ($deviceid =~ m/^(virtio)(\d+)$/) {
+ if($conf->{iothread}) {
+ my $iothreads = vm_iothreads_list($vmid);
+ qemu_objectadd($vmid, "iothread-$deviceid", "iothread") if !$iothreads->{"iothread-$deviceid"};
+ }
+
qemu_driveadd($storecfg, $vmid, $device);
my $devicefull = print_drivedevice_full($storecfg, $conf, $vmid, $device);
@@ -3246,6 +3253,11 @@ sub vm_deviceunplug {
qemu_devicedel($vmid, $deviceid);
qemu_devicedelverify($vmid, $deviceid);
qemu_drivedel($vmid, $deviceid);
+
+ if($conf->{iothread}) {
+ my $iothreads = vm_iothreads_list($vmid);
+ qemu_objectdel($vmid, "iothread-$deviceid") if $iothreads->{"iothread-$deviceid"};
+ }
} elsif ($deviceid =~ m/^(lsi)(\d+)$/) {
@@ -3269,6 +3281,35 @@ sub vm_deviceunplug {
return 1;
}
+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;
+}
+
+sub qemu_objectadd {
+ my($vmid, $objectid, $qomtype) = @_;
+
+ vm_mon_cmd($vmid, "object-add", id => $objectid, "qom-type" => $qomtype);
+
+ return 1;
+}
+
+sub qemu_objectdel {
+ my($vmid, $objectid) = @_;
+
+ vm_mon_cmd($vmid, "object-del", id => $objectid);
+
+ return 1;
+}
+
sub qemu_deviceadd {
my ($vmid, $devicefull) = @_;
--
1.7.10.4
More information about the pve-devel
mailing list