All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] udev: add rules for qemu guests
@ 2011-01-25 10:44 Gerd Hoffmann
  2011-01-25 12:01 ` Kay Sievers
                   ` (5 more replies)
  0 siblings, 6 replies; 7+ messages in thread
From: Gerd Hoffmann @ 2011-01-25 10:44 UTC (permalink / raw)
  To: linux-hotplug

These patches enable usb autosuspend for the qemu emulated HID devices.
This reduces the cpu load for idle guests with a hid device attached
because the linux kernel will suspend the usb bus then and qemu can stop
running a 1000 Hz to emulate the (active) UHCI controller.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
 Makefile.am                      |    6 ++++++
 extras/qemu/99-qemu-usb.rules    |   12 ++++++++++++
 extras/qemu/qemu-usb-autosuspend |    7 +++++++
 3 files changed, 25 insertions(+), 0 deletions(-)
 create mode 100644 extras/qemu/99-qemu-usb.rules
 create mode 100755 extras/qemu/qemu-usb-autosuspend

diff --git a/Makefile.am b/Makefile.am
index 2e3fe39..c09b2a0 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -317,6 +317,12 @@ extras_v4l_id_v4l_id_LDADD = libudev/libudev-private.la
 libexec_PROGRAMS += extras/v4l_id/v4l_id
 dist_udevrules_DATA += extras/v4l_id/60-persistent-v4l.rules
 
+# ------------------------------------------------------------------------------
+# qemu -- qemu/kvm guest tweaks
+# ------------------------------------------------------------------------------
+dist_udevrules_DATA += extras/qemu/99-qemu-usb.rules
+dist_libexec_SCRIPTS += extras/qemu/qemu-usb-autosuspend
+
 if ENABLE_EXTRAS
 # ------------------------------------------------------------------------------
 # conditional extras (need glib, libusb, libacl, ...)
diff --git a/extras/qemu/99-qemu-usb.rules b/extras/qemu/99-qemu-usb.rules
new file mode 100644
index 0000000..35f33e1
--- /dev/null
+++ b/extras/qemu/99-qemu-usb.rules
@@ -0,0 +1,12 @@
+#
+# Enable autosuspend for qemu emulated usb hid devices.
+#
+# Note that there are buggy qemu versions which advertise remote
+# wakeup support but don't actually implement it correctly.  This
+# is the reason why we need a match for the serial number here.
+# The serial number "42" is used to tag the implementations where
+# remote wakeup is working.
+#
+ACTION="add", SUBSYSTEM="usb", ATTR{product}="QEMU USB Mouse", ATTR{serial}="42", RUN+="qemu-usb-autosuspend %p"
+ACTION="add", SUBSYSTEM="usb", ATTR{product}="QEMU USB Tablet", ATTR{serial}="42", RUN+="qemu-usb-autosuspend %p"
+ACTION="add", SUBSYSTEM="usb", ATTR{product}="QEMU USB Keyboard", ATTR{serial}="42", RUN+="qemu-usb-autosuspend %p"
diff --git a/extras/qemu/qemu-usb-autosuspend b/extras/qemu/qemu-usb-autosuspend
new file mode 100755
index 0000000..48761de
--- /dev/null
+++ b/extras/qemu/qemu-usb-autosuspend
@@ -0,0 +1,7 @@
+#!/bin/sh
+path="$1"
+if test -f "/sys${path}/power/control"; then
+	echo "auto" > "/sys${path}/power/control"
+elif test -f "/sys${path}/power/level"; then
+	echo "auto" > "/sys${path}/power/level"
+fi
-- 
1.7.1


^ permalink raw reply related	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2011-01-25 14:45 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-01-25 10:44 [PATCH] udev: add rules for qemu guests Gerd Hoffmann
2011-01-25 12:01 ` Kay Sievers
2011-01-25 12:20 ` Gerd Hoffmann
2011-01-25 13:39 ` Kay Sievers
2011-01-25 14:07 ` Gerd Hoffmann
2011-01-25 14:21 ` Kay Sievers
2011-01-25 14:45 ` Gerd Hoffmann

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.