Resolves: https://gitlab.com/libvirt/libvirt/-/issues/142 Signed-off-by: Kristina Hanicova <khanicov@xxxxxxxxxx> --- src/qemu/qemu_command.c | 32 ++++++++++++++++- .../input-linux.x86_64-latest.args | 34 +++++++++++++++++++ tests/qemuxml2argvtest.c | 2 ++ 3 files changed, 67 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 9954bb0678..31a1ac0949 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -4065,6 +4065,29 @@ qemuBuildUSBInputDevStr(const virDomainDef *def, } +static char * +qemuBuildObjectInputDevStr(virDomainInputDef *dev, + virQEMUCaps *qemuCaps) +{ + g_autoptr(virJSONValue) props = NULL; + g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; + + if (qemuMonitorCreateObjectProps(&props, "input-linux", dev->info.alias, + "s:evdev", dev->source.evdev, + "T:repeat", dev->source.repeat, + NULL) < 0) + return NULL; + + if (dev->source.grab == VIR_DOMAIN_INPUT_SOURCE_GRAB_ALL) + virJSONValueObjectAdd(props, "b:grab_all", true, NULL); + + if (qemuBuildObjectCommandlineFromJSON(&buf, props, qemuCaps) < 0) + return NULL; + + return virBufferContentAndReset(&buf); +} + + int qemuBuildInputDevStr(char **devstr, const virDomainDef *def, @@ -4081,6 +4104,10 @@ qemuBuildInputDevStr(char **devstr, if (!(*devstr = qemuBuildVirtioInputDevStr(def, input, qemuCaps))) return -1; break; + case VIR_DOMAIN_INPUT_BUS_NONE: + if (!(*devstr = qemuBuildObjectInputDevStr(input, qemuCaps))) + return -1; + break; } return 0; } @@ -4104,7 +4131,10 @@ qemuBuildInputCommandLine(virCommand *cmd, return -1; if (devstr) { - virCommandAddArg(cmd, "-device"); + if (input->type == VIR_DOMAIN_INPUT_TYPE_EVDEV) + 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..688cf02873 --- /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 '{"qom-type":"input-linux","id":"input0","evdev":"/dev/input/event1234","repeat":true,"grab_all":true}' \ +-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 diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 25b0c81f21..b5cf2fcbbe 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -3264,6 +3264,8 @@ mymain(void) QEMU_CAPS_VIRTIO_MOUSE, QEMU_CAPS_VIRTIO_TABLET); DO_TEST("virtio-input-passthrough", QEMU_CAPS_VIRTIO_INPUT_HOST); + DO_TEST_CAPS_LATEST("input-linux"); + DO_TEST("ppc64-usb-controller", QEMU_CAPS_DEVICE_SPAPR_PCI_HOST_BRIDGE, QEMU_CAPS_PCI_OHCI); -- 2.31.1