[pve-devel] [PATCH] usb2.0 as default + usb-tablet hotplug/unplug

Alexandre Derumier aderumier at odiso.com
Mon Feb 18 05:53:13 CET 2013


- This add ehci as default usb controller. (always activated)
- Full usb2 withtout usb1 compagnon (Don't need anymore the external usb.cfg) as we don't need usb1 anymore

- hotplug/unplug usb-tablet on console task start/stop.

tablet config:
 tablet:0  no tablet
 tablet:1  always tablet
 no config : auto hotplug/unplug at console task

On my old xeon, tablet on usb2 give me 2% less cpu.
Unplugging the tablet give me 6% less cpu.

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/API2/Qemu.pm  |    5 +++++
 PVE/QemuServer.pm |   19 +++++--------------
 2 files changed, 10 insertions(+), 14 deletions(-)

diff --git a/PVE/API2/Qemu.pm b/PVE/API2/Qemu.pm
index cabe2cf..eacda07 100644
--- a/PVE/API2/Qemu.pm
+++ b/PVE/API2/Qemu.pm
@@ -1100,8 +1100,13 @@ __PACKAGE__->register_method({
 	    # also redirect stderr (else we get RFB protocol errors)
 	    my $cmd = ['/bin/nc', '-l', '-p', $port, '-w', $timeout, '-c', "$qmstr 2>/dev/null"];
 
+	    my $conf = PVE::QemuServer::load_config($vmid);
+	    PVE::QemuServer::qemu_deviceadd($vmid, "usb-tablet,id=usb-tablet,bus=ehci.0,port=6") if !defined($conf->{tablet});
+
 	    PVE::Tools::run_command($cmd);
 
+	    PVE::QemuServer::qemu_devicedel($vmid, "usb-tablet") if !defined($conf->{tablet});
+
 	    return;
 	};
 
diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index ebd7a83..176b068 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -2192,23 +2192,13 @@ sub config_to_command {
 
     push @$cmd, '-daemonize';
 
-    my $use_usb2 = 0;
-    for (my $i = 0; $i < $MAX_USB_DEVICES; $i++)  {
-	next if !$conf->{"usb$i"};
-	$use_usb2 = 1;
-    }
     # include usb device config
-    push @$devices, '-readconfig', '/usr/share/qemu-server/pve-usb.cfg' if $use_usb2;
+    $pciaddr = print_pci_addr("ehci", $bridges);
+    push @$devices, '-device', "usb-ehci,id=ehci$pciaddr";
 
     # enable absolute mouse coordinates (needed by vnc)
-    my $tablet = defined($conf->{tablet}) ? $conf->{tablet} : $defaults->{tablet};
-    if ($tablet) {
-	if ($use_usb2) {
-	    push @$devices, '-device', 'usb-tablet,bus=ehci.0,port=6';
-	} else {
-	    push @$devices, '-usbdevice', 'tablet';
-	}
-    }
+    my $tablet = $conf->{tablet} if defined($conf->{tablet});
+    push @$devices, '-device', 'usb-tablet,id=usb-tablet,bus=ehci.0,port=6' if $tablet;
 
     # host pci devices
     for (my $i = 0; $i < $MAX_HOSTPCI_DEVICES; $i++)  {
@@ -3376,6 +3366,7 @@ sub print_pci_addr {
 	net3 => { bus => 0, addr => 21 },
 	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 },
-- 
1.7.10.4




More information about the pve-devel mailing list