[PATCH 3/3] qemu: Build command line for object input-linux

Kristina Hanicova khanicov at redhat.com
Fri Apr 30 12:16:17 UTC 2021


Resolves: https://gitlab.com/libvirt/libvirt/-/issues/142

Signed-off-by: Kristina Hanicova <khanicov at redhat.com>
---
 src/qemu/qemu_command.c                       | 26 +++++++++++++-
 .../input-linux.x86_64-latest.args            | 34 +++++++++++++++++++
 2 files changed, 59 insertions(+), 1 deletion(-)
 create mode 100644 tests/qemuxml2argvdata/input-linux.x86_64-latest.args

diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 1ca330b840..a8ee94f212 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -4066,6 +4066,23 @@ qemuBuildUSBInputDevStr(const virDomainDef *def,
 }
 
 
+static char *
+qemuBuildObjectInputDevStr(virDomainInputDef *dev)
+{
+    g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
+
+    virBufferAsprintf(&buf, "input-linux,id=%s,evdev=", dev->info.alias);
+    virQEMUBuildBufferEscapeComma(&buf, dev->source.evdev);
+
+    if (dev->source.grab)
+        virBufferAddLit(&buf, ",grab_all=on");
+    if (dev->source.repeat)
+        virBufferAddLit(&buf, ",repeat=on");
+
+    return virBufferContentAndReset(&buf);
+}
+
+
 int
 qemuBuildInputDevStr(char **devstr,
                      const virDomainDef *def,
@@ -4082,6 +4099,10 @@ qemuBuildInputDevStr(char **devstr,
         if (!(*devstr = qemuBuildVirtioInputDevStr(def, input, qemuCaps)))
             return -1;
         break;
+    case VIR_DOMAIN_INPUT_BUS_NONE:
+        if (!(*devstr = qemuBuildObjectInputDevStr(input)))
+            return -1;
+        break;
     }
     return 0;
 }
@@ -4105,7 +4126,10 @@ qemuBuildInputCommandLine(virCommand *cmd,
             return -1;
 
         if (devstr) {
-            virCommandAddArg(cmd, "-device");
+            if (input->type == VIR_DOMAIN_INPUT_TYPE_LINUX)
+                virCommandAddArg(cmd, "-object");
+            else
+                virCommandAddArg(cmd, "-device");
             virCommandAddArg(cmd, devstr);
         }
     }
diff --git a/tests/qemuxml2argvdata/input-linux.x86_64-latest.args b/tests/qemuxml2argvdata/input-linux.x86_64-latest.args
new file mode 100644
index 0000000000..23c8eea7a4
--- /dev/null
+++ b/tests/qemuxml2argvdata/input-linux.x86_64-latest.args
@@ -0,0 +1,34 @@
+LC_ALL=C \
+PATH=/bin \
+HOME=/tmp/lib/domain--1-QEMUGuest1 \
+USER=test \
+LOGNAME=test \
+XDG_DATA_HOME=/tmp/lib/domain--1-QEMUGuest1/.local/share \
+XDG_CACHE_HOME=/tmp/lib/domain--1-QEMUGuest1/.cache \
+XDG_CONFIG_HOME=/tmp/lib/domain--1-QEMUGuest1/.config \
+/usr/bin/qemu-system-i386 \
+-name guest=QEMUGuest1,debug-threads=on \
+-S \
+-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tmp/lib/domain--1-QEMUGuest1/master-key.aes"}' \
+-machine pc,accel=tcg,usb=off,dump-guest-core=off,memory-backend=pc.ram \
+-cpu qemu64 \
+-m 214 \
+-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":224395264}' \
+-overcommit mem-lock=off \
+-smp 1,sockets=1,cores=1,threads=1 \
+-uuid c7a5fdbd-edaf-9455-926a-d65c16db1809 \
+-display none \
+-no-user-config \
+-nodefaults \
+-chardev socket,id=charmonitor,fd=1729,server=on,wait=off \
+-mon chardev=charmonitor,id=monitor,mode=control \
+-rtc base=utc \
+-no-shutdown \
+-no-acpi \
+-boot strict=on \
+-device piix3-usb-uhci,id=usb,bus=pci.0,addr=0x1.0x2 \
+-object input-linux,id=input0,evdev=/dev/input/event1234,grab_all=on,repeat=on \
+-audiodev id=audio1,driver=none \
+-device virtio-balloon-pci,id=balloon0,bus=pci.0,addr=0x2 \
+-sandbox on,obsolete=deny,elevateprivileges=deny,spawn=deny,resourcecontrol=deny \
+-msg timestamp=on
-- 
2.30.2




More information about the libvir-list mailing list