mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-23 21:34:54 +03:00
qemu: format qemu command line for USB keyboard
Format qemu command line for USB keyboard and add test cases for it. Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com> Signed-off-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
f5ffd45f4c
commit
78730478aa
@ -5306,9 +5306,19 @@ qemuBuildUSBInputDevStr(virDomainDefPtr def,
|
||||
{
|
||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
||||
|
||||
virBufferAsprintf(&buf, "%s,id=%s",
|
||||
dev->type == VIR_DOMAIN_INPUT_TYPE_MOUSE ?
|
||||
"usb-mouse" : "usb-tablet", dev->info.alias);
|
||||
switch (dev->type) {
|
||||
case VIR_DOMAIN_INPUT_TYPE_MOUSE:
|
||||
virBufferAsprintf(&buf, "usb-mouse,id=%s", dev->info.alias);
|
||||
break;
|
||||
case VIR_DOMAIN_INPUT_TYPE_TABLET:
|
||||
virBufferAsprintf(&buf, "usb-tablet,id=%s", dev->info.alias);
|
||||
break;
|
||||
case VIR_DOMAIN_INPUT_TYPE_KBD:
|
||||
if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_USB_KBD))
|
||||
goto error;
|
||||
virBufferAsprintf(&buf, "usb-kbd,id=%s", dev->info.alias);
|
||||
break;
|
||||
}
|
||||
|
||||
if (qemuBuildDeviceAddressStr(&buf, def, &dev->info, qemuCaps) < 0)
|
||||
goto error;
|
||||
@ -9044,9 +9054,17 @@ qemuBuildCommandLine(virConnectPtr conn,
|
||||
virCommandAddArg(cmd, optstr);
|
||||
VIR_FREE(optstr);
|
||||
} else {
|
||||
virCommandAddArgList(cmd, "-usbdevice",
|
||||
input->type == VIR_DOMAIN_INPUT_TYPE_MOUSE
|
||||
? "mouse" : "tablet", NULL);
|
||||
switch (input->type) {
|
||||
case VIR_DOMAIN_INPUT_TYPE_MOUSE:
|
||||
virCommandAddArgList(cmd, "-usbdevice", "mouse", NULL);
|
||||
break;
|
||||
case VIR_DOMAIN_INPUT_TYPE_TABLET:
|
||||
virCommandAddArgList(cmd, "-usbdevice", "tablet", NULL);
|
||||
break;
|
||||
case VIR_DOMAIN_INPUT_TYPE_KBD:
|
||||
virCommandAddArgList(cmd, "-usbdevice", "keyboard", NULL);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -11720,20 +11738,23 @@ qemuParseCommandLine(virCapsPtr qemuCaps,
|
||||
} else if (STREQ(arg, "-usbdevice")) {
|
||||
WANT_VALUE();
|
||||
if (STREQ(val, "tablet") ||
|
||||
STREQ(val, "mouse")) {
|
||||
STREQ(val, "mouse") ||
|
||||
STREQ(val, "keyboard")) {
|
||||
virDomainInputDefPtr input;
|
||||
if (VIR_ALLOC(input) < 0)
|
||||
goto error;
|
||||
input->bus = VIR_DOMAIN_INPUT_BUS_USB;
|
||||
if (STREQ(val, "tablet"))
|
||||
input->type = VIR_DOMAIN_INPUT_TYPE_TABLET;
|
||||
else
|
||||
else if (STREQ(val, "mouse"))
|
||||
input->type = VIR_DOMAIN_INPUT_TYPE_MOUSE;
|
||||
if (VIR_REALLOC_N(def->inputs, def->ninputs+1) < 0) {
|
||||
else
|
||||
input->type = VIR_DOMAIN_INPUT_TYPE_KBD;
|
||||
|
||||
if (VIR_APPEND_ELEMENT(def->inputs, def->ninputs, input) < 0) {
|
||||
virDomainInputDefFree(input);
|
||||
goto error;
|
||||
}
|
||||
def->inputs[def->ninputs++] = input;
|
||||
} else if (STRPREFIX(val, "disk:")) {
|
||||
if (VIR_ALLOC(disk) < 0)
|
||||
goto error;
|
||||
|
9
tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.args
Normal file
9
tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.args
Normal file
@ -0,0 +1,9 @@
|
||||
LC_ALL=C PATH=/bin HOME=/home/test USER=test LOGNAME=test QEMU_AUDIO_DRV=none \
|
||||
/usr/bin/qemu-system-ppc64 -S -M pseries -m 512 -smp 1 \
|
||||
-nographic -nodefconfig -nodefaults \
|
||||
-chardev socket,id=charmonitor,path=/tmp/test-monitor,server,nowait \
|
||||
-mon chardev=charmonitor,id=monitor,mode=readline -no-acpi -boot c \
|
||||
-device pci-ohci,id=usb,bus=pci,addr=0x1 \
|
||||
-chardev pty,id=charserial0 \
|
||||
-device spapr-vty,chardev=charserial0,reg=0x30000000 \
|
||||
-device usb-kbd,id=input0
|
19
tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.xml
Normal file
19
tests/qemuxml2argvdata/qemuxml2argv-pseries-usb-kbd.xml
Normal file
@ -0,0 +1,19 @@
|
||||
<domain type='qemu'>
|
||||
<name>QEMUGuest1</name>
|
||||
<uuid>1ccfd97d-5eb4-478a-bbe6-88d254c16db7</uuid>
|
||||
<memory unit='KiB'>524288</memory>
|
||||
<vcpu placement='static'>1</vcpu>
|
||||
<os>
|
||||
<type arch='ppc64' machine='pseries'>hvm</type>
|
||||
</os>
|
||||
<clock offset='utc'/>
|
||||
<devices>
|
||||
<emulator>/usr/bin/qemu-system-ppc64</emulator>
|
||||
<console type='pty'>
|
||||
<address type="spapr-vio"/>
|
||||
</console>
|
||||
<memballoon model="none"/>
|
||||
<controller type='usb' index='0' model='pci-ohci'/>
|
||||
<input type='keyboard' bus='usb'/>
|
||||
</devices>
|
||||
</domain>
|
@ -1206,6 +1206,9 @@ mymain(void)
|
||||
DO_TEST_ERROR("pseries-vio-address-clash", QEMU_CAPS_DRIVE,
|
||||
QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
|
||||
DO_TEST("pseries-nvram", QEMU_CAPS_DEVICE_NVRAM);
|
||||
DO_TEST("pseries-usb-kbd", QEMU_CAPS_PCI_OHCI,
|
||||
QEMU_CAPS_DEVICE_USB_KBD, QEMU_CAPS_CHARDEV,
|
||||
QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
|
||||
DO_TEST_FAILURE("pseries-cpu-exact", QEMU_CAPS_CHARDEV, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG);
|
||||
DO_TEST("disk-ide-drive-split",
|
||||
QEMU_CAPS_DRIVE, QEMU_CAPS_DEVICE, QEMU_CAPS_NODEFCONFIG,
|
||||
|
Loading…
Reference in New Issue
Block a user