mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 13:45:38 +00:00
qemu: Build command line for object input-linux
Resolves: https://gitlab.com/libvirt/libvirt/-/issues/142 Signed-off-by: Kristina Hanicova <khanicov@redhat.com>
This commit is contained in:
parent
cff0444e51
commit
483e943884
@ -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);
|
||||
}
|
||||
}
|
||||
|
34
tests/qemuxml2argvdata/input-linux.x86_64-latest.args
Normal file
34
tests/qemuxml2argvdata/input-linux.x86_64-latest.args
Normal file
@ -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
|
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user