[libvirt] [PATCH 2/2] qemu: Allow creating ppc64 guests with graphics and no USB mouse

Andrea Bolognani abologna at redhat.com
Wed Feb 27 18:08:01 UTC 2019


The existing behavior for ppc64 guests is to always add a USB
keyboard and mouse combo if graphics are present; unfortunately,
this means any attempt to use a USB tablet will cause both pointing
devices to show up in the guest, which in turn will result in poor
user experience.

We can't just stop adding the USB mouse or start adding a USB tablet
instead, because existing applications and user might rely on the
current behavior; however, we can avoid adding the USB mouse if a USB
tablet is already present, thus allowing users and applications to
create guests that contain a single pointing device.

https://bugzilla.redhat.com/show_bug.cgi?id=1683681

Signed-off-by: Andrea Bolognani <abologna at redhat.com>
---
 src/qemu/qemu_domain.c                        | 20 +++++++++++++++++++
 .../ppc64-pseries-graphics.ppc64-latest.args  |  1 -
 2 files changed, 20 insertions(+), 1 deletion(-)

diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index 59fe1eb401..915795ab84 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -3476,6 +3476,26 @@ qemuDomainDefAddDefaultDevices(virDomainDefPtr def,
         virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_S390) && def->memballoon)
         def->memballoon->model = VIR_DOMAIN_MEMBALLOON_MODEL_NONE;
 
+    if (addDefaultUSBMouse) {
+        bool hasUSBTablet = false;
+        size_t j;
+
+        for (j = 0; j < def->ninputs; j++) {
+            if (def->inputs[j]->type == VIR_DOMAIN_INPUT_TYPE_TABLET &&
+                def->inputs[j]->bus == VIR_DOMAIN_INPUT_BUS_USB) {
+                hasUSBTablet = true;
+                break;
+            }
+        }
+
+        /* Historically, we have automatically added USB keyboard and
+         * mouse to some guests. While the former device is generally
+         * safe to have, adding the latter is undesiderable if a USB
+         * tablet is already present in the guest */
+        if (hasUSBTablet)
+            addDefaultUSBMouse = false;
+    }
+
     if (addDefaultUSBKBD &&
         def->ngraphics > 0 &&
         virDomainDefMaybeAddInput(def,
diff --git a/tests/qemuxml2argvdata/ppc64-pseries-graphics.ppc64-latest.args b/tests/qemuxml2argvdata/ppc64-pseries-graphics.ppc64-latest.args
index 1c6c25ed24..b81648f078 100644
--- a/tests/qemuxml2argvdata/ppc64-pseries-graphics.ppc64-latest.args
+++ b/tests/qemuxml2argvdata/ppc64-pseries-graphics.ppc64-latest.args
@@ -37,7 +37,6 @@ addr=0x1 \
 id=channel0,name=org.qemu.guest_agent.0 \
 -device usb-tablet,id=input0,bus=usb.0,port=1 \
 -device usb-kbd,id=input1,bus=usb.0,port=2 \
--device usb-mouse,id=input2,bus=usb.0,port=3 \
 -vnc 127.0.0.1:0 \
 -device VGA,id=video0,vgamem_mb=16,bus=pci.0,addr=0x7 \
 -device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x5 \
-- 
2.20.1




More information about the libvir-list mailing list