[pve-devel] [PATCH 3/3] don't use usb2 as default and always plug table on usb1

Alexandre Derumier aderumier at odiso.com
Thu Feb 21 18:44:18 CET 2013


- Only use ehci if usb-passthrough is needed
- always plug tablet on uhci

Also convert old -usb controller syntax to new qdev -device piix3-usb-uhci

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

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index 4dce525..27f1e70 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -2194,15 +2194,26 @@ sub config_to_command {
 
     push @$cmd, '-daemonize';
 
-    $pciaddr = print_pci_addr("ehci", $bridges);
-    push @$devices, '-device', "ich9-usb-ehci1,id=ehci,multifunction=on$pciaddr.0x7";
-    push @$devices, '-device', "ich9-usb-uhci1,id=uhci1,masterbus=ehci.0,firstport=0,multifunction=on$pciaddr.0x0";
-    push @$devices, '-device', "ich9-usb-uhci2,id=uhci2,masterbus=ehci.0,firstport=2,multifunction=on$pciaddr.0x1";
-    push @$devices, '-device', "ich9-usb-uhci3,id=uchi3,masterbus=ehci.0,firstport=4,multifunction=on$pciaddr.0x2";
+    my $use_usb2 = 0;
+    for (my $i = 0; $i < $MAX_USB_DEVICES; $i++)  {
+	next if !$conf->{"usb$i"};
+	$use_usb2 = 1;
+    }
+
+    if($use_usb2){
+	$pciaddr = print_pci_addr("ehci", $bridges);
+	push @$devices, '-device', "ich9-usb-ehci1,id=ehci,multifunction=on$pciaddr.0x7";
+	push @$devices, '-device', "ich9-usb-uhci1,id=uhci1,masterbus=ehci.0,firstport=0,multifunction=on$pciaddr.0x0";	
+	push @$devices, '-device', "ich9-usb-uhci2,id=uhci2,masterbus=ehci.0,firstport=2,multifunction=on$pciaddr.0x1";
+	push @$devices, '-device', "ich9-usb-uhci3,id=uchi3,masterbus=ehci.0,firstport=4,multifunction=on$pciaddr.0x2";
+    }
+
+    $pciaddr = print_pci_addr("piix3", $bridges);
+    push @$devices, '-device', "piix3-usb-uhci,id=uhci0$pciaddr.0x2";
 
     # enable absolute mouse coordinates (needed by vnc)
     my $tablet = defined($conf->{tablet}) ? $conf->{tablet} : $defaults->{tablet};
-    push @$devices, '-device', 'usb-tablet,id=tablet,bus=ehci.0,port=6' if $tablet;
+    push @$devices, '-device', 'usb-tablet,id=tablet,bus=uhci0.0,port=2' if $tablet;
 
     # host pci devices
     for (my $i = 0; $i < $MAX_HOSTPCI_DEVICES; $i++)  {
@@ -2520,7 +2531,7 @@ sub vm_deviceplug {
     return 1 if !check_running($vmid);
 
     if ($deviceid eq 'tablet') {
-	my $devicefull = "usb-tablet,id=tablet,bus=ehci.0,port=6";
+	my $devicefull = "usb-tablet,id=tablet,bus=uhci0.0,port=2";
 	qemu_deviceadd($vmid, $devicefull);
 	return 1;
     }
@@ -3352,7 +3363,7 @@ sub print_pci_addr {
 
     my $res = '';
     my $devices = {
-	#addr1 : ide,parallel,serial (motherboard)
+	piix3 => { bus => 0, addr => 1 },
 	#addr2 : first videocard
 	balloon0 => { bus => 0, addr => 3 },
 	watchdog => { bus => 0, addr => 4 },
@@ -3375,7 +3386,6 @@ sub print_pci_addr {
 	net4 => { bus => 0, addr => 22 },
 	net5 => { bus => 0, addr => 23 },
 	ehci => { bus => 0, addr => 29 },
-	#addr29 : usb-host (pve-usb.cfg)
 	'pci.1' => { bus => 0, addr => 30 },
 	'pci.2' => { bus => 0, addr => 31 },
 	'net6' => { bus => 1, addr => 1 },
-- 
1.7.10.4




More information about the pve-devel mailing list