Skip to contentSkip to conversation

udev: add rules for qemu guests

PATCH Applied Gerd Hoffmann 4 participants 5 messages Jan 25, 2011 – Jan 26, 2011 Kbuild

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 udev: add rules for qemu guests

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.

---
 Makefile.am                       |    5 +++++
 extras/qemu/42-qemu-usb.rules     |   13 +++++++++++++
 rules/misc/30-kernel-compat.rules |    5 +++++
 3 files changed, 23 insertions(+), 0 deletions(-)
 create mode 100644 extras/qemu/42-qemu-usb.rules
Makefile.am +5 -0
index 2e3fe39..b2300ce 100644
@@ -317,6 +317,11 @@ 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
+
 if ENABLE_EXTRAS
 # ------------------------------------------------------------------------------
 # conditional extras (need glib, libusb, libacl, ...)
extras/qemu/42-qemu-usb.rules new file +13 -0
new file mode 100644
index 0000000..4fd53c7
@@ -0,0 +1,13 @@
+#
+# 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", TEST="power/control", ATTR{power/control}="auto"
+ACTION="add", SUBSYSTEM="usb", ATTR{product}="QEMU USB Tablet", ATTR{serial}="42", TEST="power/control", ATTR{power/control}="auto"
+CTION="add", SUBSYSTEM="usb", ATTR{product}="QEMU USB Keyboard", ATTR{serial}="42", TEST="power/control", ATTR{power/control}="auto"
rules/misc/30-kernel-compat.rules +5 -0
index 2c545dc..2a6a97c 100644
@@ -97,4 +97,9 @@ SUBSYSTEM="mmc", RUN+="/sbin/modprobe -b mmc_block"
 SUBSYSTEM="pnp", DRIVER!="?*", \
   RUN{ignore_error}+="/bin/sh -c '/sbin/modprobe -a $$(while read id; do echo pnp:d$$id; done < /sys$devpath/id)'"
 
+# see extras/qemu/42-qemu-usb.rules, version for 2.6.32 + older.
+ACTION="add", SUBSYSTEM="usb", ATTR{product}="QEMU USB Mouse", ATTR{serial}="42", TEST="power/level", ATTR{power/level}="auto"
+ACTION="add", SUBSYSTEM="usb", ATTR{product}="QEMU USB Tablet", ATTR{serial}="42", TEST="power/level", ATTR{power/level}="auto"
+ACTION="add", SUBSYSTEM="usb", ATTR{product}="QEMU USB Keyboard", ATTR{serial}="42", TEST="power/level", ATTR{power/level}="auto"
+
 LABEL="kernel_compat_end"
Signature · 1 line
1.7.1
Applied
#1 lore raw
Quoted 4 lines · Gerd Hoffmann

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.

Applied.

Thanks,
Kay

#2 lore raw
In reply to Gerd Hoffmann

extras/qemu/42-qemu-usb.rules line 13

Quoted 3 lines · Gerd Hoffmann
extras/qemu/42-qemu-usb.rules new file +3 -0
+ACTION="add", SUBSYSTEM="usb", ATTR{product}="QEMU USB Mouse", ATTR{serial}="42", TEST="power/control", ATTR{power/control}="auto"
+ACTION="add", SUBSYSTEM="usb", ATTR{product}="QEMU USB Tablet", ATTR{serial}="42", TEST="power/control", ATTR{power/control}="auto"
+CTION="add", SUBSYSTEM="usb", ATTR{product}="QEMU USB Keyboard", ATTR{serial}="42", TEST="power/control", ATTR{power/control}="auto"

There's a typo in here.

Signature · 2 lines
Pardus Linux
http://www.pardus.org.tr/eng
#3 lore raw
In reply to Gerd Hoffmann
Quoted 10 lines · Ozan Çağlayan
Quoted 6 lines · Gerd Hoffmann

+ACTION="add", SUBSYSTEM="usb", ATTR{product}="QEMU USB Mouse", ATTR{serial}="42", TEST="power/control", ATTR{power/control}="auto" +ACTION="add", SUBSYSTEM="usb", ATTR{product}="QEMU USB Tablet", ATTR{serial}="42", TEST="power/control", ATTR{power/control}="auto" +CTION="add", SUBSYSTEM="usb", ATTR{product}="QEMU USB Keyboard", ATTR{serial}="42", TEST="power/control", ATTR{power/control}="auto"

There's a typo in here.

Fixed.

Thanks,
Kay

#4 lore raw
In reply to Gerd Hoffmann
Quoted 18 lines · Gerd Hoffmann

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.

---
 Makefile.am                       |    5 +++++
 extras/qemu/42-qemu-usb.rules     |   13 +++++++++++++
 rules/misc/30-kernel-compat.rules |    5 +++++
 3 files changed, 23 insertions(+), 0 deletions(-)
 create mode 100644 extras/qemu/42-qemu-usb.rules
Makefile.am +0 -0
index 2e3fe39..b2300ce 100644

Makefile.am extras_v4l_id_v4l_id_LDADD = libudev/libudev-private.la · line 323

Quoted 7 lines
Makefile.am +4 -0
@@ -317,6 +317,11 @@ 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

That should be 42-qemu-usb.rules

-jim

Quoted 44 lines
Makefile.am +1 -0
+
 if ENABLE_EXTRAS
 # ------------------------------------------------------------------------------
 # conditional extras (need glib, libusb, libacl, ...)
extras/qemu/42-qemu-usb.rules new file +13 -0
new file mode 100644
index 0000000..4fd53c7
@@ -0,0 +1,13 @@
+#
+# 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", TEST="power/control", ATTR{power/control}="auto"
+ACTION="add", SUBSYSTEM="usb", ATTR{product}="QEMU USB Tablet", ATTR{serial}="42", TEST="power/control", ATTR{power/control}="auto"
+CTION="add", SUBSYSTEM="usb", ATTR{product}="QEMU USB Keyboard", ATTR{serial}="42", TEST="power/control", ATTR{power/control}="auto"
rules/misc/30-kernel-compat.rules +5 -0
index 2c545dc..2a6a97c 100644
@@ -97,4 +97,9 @@ SUBSYSTEM="mmc", RUN+="/sbin/modprobe -b mmc_block"
 SUBSYSTEM="pnp", DRIVER!="?*", \
   RUN{ignore_error}+="/bin/sh -c '/sbin/modprobe -a $$(while read id; do echo pnp:d$$id; done < /sys$devpath/id)'"
 
+# see extras/qemu/42-qemu-usb.rules, version for 2.6.32 + older.
+ACTION="add", SUBSYSTEM="usb", ATTR{product}="QEMU USB Mouse", ATTR{serial}="42", TEST="power/level", ATTR{power/level}="auto"
+ACTION="add", SUBSYSTEM="usb", ATTR{product}="QEMU USB Tablet", ATTR{serial}="42", TEST="power/level", ATTR{power/level}="auto"
+ACTION="add", SUBSYSTEM="usb", ATTR{product}="QEMU USB Keyboard", ATTR{serial}="42", TEST="power/level", ATTR{power/level}="auto"
+
 LABEL="kernel_compat_end"
Signature · 6 lines
1.7.1

--
To unsubscribe from this list: send the line "unsubscribe linux-hotplug" in
the body of a message to [email protected]
More majordomo info at  http://vger.kernel.org/majordomo-info.html