[pve-devel] [PATCH 8/9] implement virtio-scsi multiqueues
Alexandre Derumier
aderumier at odiso.com
Fri Jan 16 11:01:00 CET 2015
as for iothread, we can assign queues only on virtio-scsi-pci controller,
so we also use a dedicated virtio-scsi-pci controller by virtio-scsi disk
Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
PVE/QemuServer.pm | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index f9d6955..3d3f4fe 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -546,7 +546,7 @@ PVE::JSONSchema::register_standard_option("pve-qm-ide", $idedesc);
my $scsidesc = {
optional => 1,
type => 'string', format => 'pve-qm-drive',
- typetext => '[volume=]volume,] [,media=cdrom|disk] [,cyls=c,heads=h,secs=s[,trans=t]] [,snapshot=on|off] [,cache=none|writethrough|writeback|unsafe|directsync] [,format=f] [,backup=yes|no] [,rerror=ignore|report|stop] [,werror=enospc|ignore|report|stop] [,aio=native|threads] [,discard=ignore|on] [,iothread=yes]',
+ typetext => '[volume=]volume,] [,media=cdrom|disk] [,cyls=c,heads=h,secs=s[,trans=t]] [,snapshot=on|off] [,cache=none|writethrough|writeback|unsafe|directsync] [,format=f] [,backup=yes|no] [,rerror=ignore|report|stop] [,werror=enospc|ignore|report|stop] [,aio=native|threads] [,discard=ignore|on] [,iothread=yes] [,queues=<nbqueues>]',
description => "Use volume as SCSI hard disk or CD-ROM (n is 0 to " . ($MAX_SCSI_DISKS - 1) . ").",
};
PVE::JSONSchema::register_standard_option("pve-qm-scsi", $scsidesc);
@@ -922,7 +922,7 @@ sub parse_drive {
foreach my $p (split (/,/, $data)) {
next if $p =~ m/^\s*$/;
- if ($p =~ m/^(file|volume|cyls|heads|secs|trans|media|snapshot|cache|format|rerror|werror|backup|aio|bps|mbps|mbps_max|bps_rd|mbps_rd|mbps_rd_max|bps_wr|mbps_wr|mbps_wr_max|iops|iops_max|iops_rd|iops_rd_max|iops_wr|iops_wr_max|size|discard|iothread)=(.+)$/) {
+ if ($p =~ m/^(file|volume|cyls|heads|secs|trans|media|snapshot|cache|format|rerror|werror|backup|aio|bps|mbps|mbps_max|bps_rd|mbps_rd|mbps_rd_max|bps_wr|mbps_wr|mbps_wr_max|iops|iops_max|iops_rd|iops_rd_max|iops_wr|iops_wr_max|size|discard|iothread|queues)=(.+)$/) {
my ($k, $v) = ($1, $2);
$k = 'file' if $k eq 'volume';
@@ -965,6 +965,7 @@ sub parse_drive {
return undef if $res->{aio} && $res->{aio} !~ m/^(native|threads)$/;
return undef if $res->{discard} && $res->{discard} !~ m/^(ignore|on)$/;
return undef if $res->{iothread} && $res->{iothread} !~ m/^(yes)$/;
+ return undef if $res->{queues} && ($res->{queues} !~ m/^\d+$/ || $res->{queues} < 2);
return undef if $res->{mbps_rd} && $res->{mbps};
return undef if $res->{mbps_wr} && $res->{mbps};
@@ -1012,7 +1013,7 @@ sub print_drive {
my ($vmid, $drive) = @_;
my $opts = '';
- foreach my $o (@qemu_drive_options, 'mbps', 'mbps_rd', 'mbps_wr', 'mbps_max', 'mbps_rd_max', 'mbps_wr_max', 'backup', 'iothread') {
+ foreach my $o (@qemu_drive_options, 'mbps', 'mbps_rd', 'mbps_wr', 'mbps_max', 'mbps_rd_max', 'mbps_wr_max', 'backup', 'iothread', 'queues') {
$opts .= ",$o=$drive->{$o}" if $drive->{$o};
}
@@ -3026,8 +3027,13 @@ sub config_to_command {
push @$cmd, '-object', "iothread,id=iothread-scsihw$controller";
}
+ my $queues = '';
+ if($conf->{scsihw} && $conf->{scsihw} =~ m/^virtio-scsi-pci/ && $drive->{queues}) {
+ $queues = ",num_queues=$drive->{queues}";
+ }
+
$pciaddr = print_pci_addr("scsihw$controller", $bridges);
- push @$devices, '-device', "$scsihw,id=scsihw$controller$pciaddr$iothread" if !$scsicontroller->{$controller};
+ push @$devices, '-device', "$scsihw,id=scsihw$controller$pciaddr$iothread$queues" if !$scsicontroller->{$controller};
$scsicontroller->{$controller}=1;
}
@@ -3956,6 +3962,7 @@ sub vmconfig_update_disk {
# skip non hotpluggable value
if (&$safe_num_ne($drive->{discard}, $old_drive->{discard}) ||
&$safe_num_ne($drive->{iothread}, $old_drive->{iothread}) ||
+ &$safe_num_ne($drive->{queues}, $old_drive->{queues}) ||
&$safe_string_ne($drive->{cache}, $old_drive->{cache})) {
die "skip\n";
}
@@ -6048,7 +6055,7 @@ sub find_scsihw_controller {
my $maxdev = ($conf->{scsihw} && ($conf->{scsihw} !~ m/^lsi/)) ? 256 : 7;
my $controller = undef;
- if($conf->{scsihw} && $conf->{scsihw} =~ m/^virtio-scsi-pci/ && $drive->{iothread}){
+ if ($conf->{scsihw} && $conf->{scsihw} =~ m/^virtio-scsi-pci/ && ($drive->{iothread} || $drive->{queues})) {
$controller = "$drive->{interface}$drive->{index}";
} else {
$controller = int($drive->{index} / $maxdev);
--
1.7.10.4
More information about the pve-devel
mailing list