[pve-devel] [PATCH] usb2.0 as default + usb-tablet hotplug/unplug V2
Alexandre Derumier
aderumier at odiso.com
Mon Feb 18 09:32:42 CET 2013
- This add ehci as default usb controller. (always activated)
- 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 | 17 +++--------------
2 files changed, 8 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..884c138 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -2192,23 +2192,12 @@ 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;
+ push @$devices, '-readconfig', '/usr/share/qemu-server/pve-usb.cfg';
# 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++) {
--
1.7.10.4
More information about the pve-devel
mailing list