[libvirt] [PATCH 28/34] Convert USB input devices to -device
Daniel Veillard
veillard at redhat.com
Fri Jan 15 19:45:27 UTC 2010
On Fri, Jan 08, 2010 at 05:23:24PM +0000, Daniel P. Berrange wrote:
> ---
> src/qemu/qemu_conf.c | 34 ++++++++++++++++++++++++++++++++--
> 1 files changed, 32 insertions(+), 2 deletions(-)
>
> diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
> index 1ea61a9..3b39a91 100644
> --- a/src/qemu/qemu_conf.c
> +++ b/src/qemu/qemu_conf.c
> @@ -2268,6 +2268,28 @@ error:
> }
>
>
> +static char *qemuBuildUSBInputDevStr(virDomainInputDefPtr dev)
> +{
> + virBuffer buf = VIR_BUFFER_INITIALIZER;
> +
> + virBufferVSprintf(&buf, "%s",
> + dev->type == VIR_DOMAIN_INPUT_TYPE_MOUSE ?
> + "usb-mouse" : "usb-tablet");
> + virBufferVSprintf(&buf, ",id=%s", dev->info.alias);
> +
> + if (virBufferError(&buf)) {
> + virReportOOMError(NULL);
> + goto error;
> + }
> +
> + return virBufferContentAndReset(&buf);
> +
> +error:
> + virBufferFreeAndReset(&buf);
> + return NULL;
> +}
> +
> +
> static char *
> qemuBuildSoundDevStr(virDomainSoundDefPtr sound)
> {
> @@ -3273,8 +3295,16 @@ int qemudBuildCommandLine(virConnectPtr conn,
> virDomainInputDefPtr input = def->inputs[i];
>
> if (input->bus == VIR_DOMAIN_INPUT_BUS_USB) {
> - ADD_ARG_LIT("-usbdevice");
> - ADD_ARG_LIT(input->type == VIR_DOMAIN_INPUT_TYPE_MOUSE ? "mouse" : "tablet");
> + if (qemuCmdFlags & QEMUD_CMD_FLAG_DEVICE) {
> + char *optstr;
> + ADD_ARG_LIT("-device");
> + if (!(optstr = qemuBuildUSBInputDevStr(input)))
> + goto error;
> + ADD_ARG(optstr);
> + } else {
> + ADD_ARG_LIT("-usbdevice");
> + ADD_ARG_LIT(input->type == VIR_DOMAIN_INPUT_TYPE_MOUSE ? "mouse" : "tablet");
> + }
> }
> }
ACK,
Daniel
--
Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/
daniel at veillard.com | Rpmfind RPM search engine http://rpmfind.net/
http://veillard.com/ | virtualization library http://libvirt.org/
More information about the libvir-list
mailing list