[pve-devel] [PATCH 1/2] implement iothread for virtio-scsi

Alexandre Derumier aderumier at odiso.com
Mon Mar 23 06:29:33 CET 2015


iothread can only be enabled by virtio-scsi-pci,

currently we use 1 controller for all virtio-scsi.

This patch create 1 virtio-scsi-pci controller for each virtio-scsi drive with iothread enable

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/QemuServer.pm |   37 +++++++++++++++++++++++++++++++++----
 1 file changed, 33 insertions(+), 4 deletions(-)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 39ca21b..9d5ff20 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -549,7 +549,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]',
+    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=on]',
     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);
@@ -1146,7 +1146,12 @@ sub print_drivedevice_full {
 	$device .= ",iothread=iothread-$drive->{interface}$drive->{index}" if $drive->{iothread};
     } elsif ($drive->{interface} eq 'scsi') {
 	$maxdev = ($conf->{scsihw} && ($conf->{scsihw} !~ m/^lsi/)) ? 256 : 7;
-	my $controller = int($drive->{index} / $maxdev);
+	my $controller = undef;
+	if($conf->{scsihw} && $conf->{scsihw} =~ m/^virtio-scsi-pci/ && $drive->{iothread}){
+	    $controller = "$drive->{interface}$drive->{index}";
+	} else {
+	    $controller = int($drive->{index} / $maxdev);
+	}
 	my $unit = $drive->{index} % $maxdev;
 	my $devicetype = 'hd';
         my $path = '';
@@ -3111,9 +3116,17 @@ sub config_to_command {
         if ($drive->{interface} eq 'scsi') {
 
 	    my $maxdev = ($scsihw !~ m/^lsi/) ? 256 : 7;
-	    my $controller = int($drive->{index} / $maxdev);
+	    my $controller = undef;
+	    my $iothread = '';
+	    if($conf->{scsihw} && $conf->{scsihw} =~ m/^virtio-scsi-pci/ && $drive->{iothread}){
+		$controller = "$drive->{interface}$drive->{index}";
+		$iothread .= ",iothread=iothread-scsihw$controller";
+		push @$cmd, '-object', "iothread,id=iothread-scsihw$controller";
+	    } else {
+		$controller = int($drive->{index} / $maxdev);
+	    }
 	    $pciaddr = print_pci_addr("scsihw$controller", $bridges);
-	    push @$devices, '-device', "$scsihw,id=scsihw$controller$pciaddr" if !$scsicontroller->{$controller};
+	    push @$devices, '-device', "$scsihw,id=scsihw$controller$pciaddr$iothread" if !$scsicontroller->{$controller};
 	    $scsicontroller->{$controller}=1;
         }
 
@@ -4761,6 +4774,22 @@ sub print_pci_addr {
 	'virtio13' => { bus => 2, addr => 8 },
 	'virtio14' => { bus => 2, addr => 9 },
 	'virtio15' => { bus => 2, addr => 10 },
+	'scsihwscsi0' => { bus => 2, addr => 11 },
+	'scsihwscsi1' => { bus => 2, addr => 12 },
+	'scsihwscsi2' => { bus => 2, addr => 13 },
+	'scsihwscsi3' => { bus => 2, addr => 14 },
+	'scsihwscsi4' => { bus => 2, addr => 15 },
+	'scsihwscsi5' => { bus => 2, addr => 16 },
+	'scsihwscsi6' => { bus => 2, addr => 17 },
+	'scsihwscsi7' => { bus => 2, addr => 18 },
+	'scsihwscsi8' => { bus => 2, addr => 19 },
+	'scsihwscsi9' => { bus => 2, addr => 20 },
+	'scsihwscsi10' => { bus => 2, addr => 21 },
+	'scsihwscsi11' => { bus => 2, addr => 22 },
+	'scsihwscsi12' => { bus => 2, addr => 23 },
+	'scsihwscsi13' => { bus => 2, addr => 24 },
+	'scsihwscsi14' => { bus => 2, addr => 25 },
+
     };
 
     if (defined($devices->{$id}->{bus}) && defined($devices->{$id}->{addr})) {
-- 
1.7.10.4




More information about the pve-devel mailing list