[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

Re: [libvirt] [PATCH] Make QEMU driver use -chardev everywhere when it's available



On Fri, Nov 13, 2009 at 04:01:44PM +0000, Matthew Booth wrote:
> Change -monitor, -serial and -parallel output to use -chardev if it is
> available.
> 
> * src/qemu/qemu_conf.c: Update qemudBuildCommandLine to use -chardev where
>   available.
> * tests/qemuxml2argvtest.c tests/qemuxml2argvdata/: Add -chardev equivalents for
>   all current serial and parallel tests.

> diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c
> index c807688..4f4b3db 100644
> --- a/src/qemu/qemu_conf.c
> +++ b/src/qemu/qemu_conf.c
> @@ -1844,12 +1844,36 @@ int qemudBuildCommandLine(virConnectPtr conn,
>      if (monitor_chr) {
>          virBuffer buf = VIR_BUFFER_INITIALIZER;
>  
> -        qemudBuildCommandLineChrDevStr(monitor_chr, &buf);
> -        if (virBufferError(&buf))
> -            goto error;
> +        /* Use -chardev if it's available */
> +        if (qemuCmdFlags & QEMUD_CMD_FLAG_CHARDEV) {
> +            char id[16];
> +
> +            if (snprintf(id, sizeof(id), "monitor%i", i) > sizeof(id))
> +                goto error;

This is using 'i' uninitialized I believe. Its a little overkill to do
a printf here at all since there's only ever a single monitor called
'monitor0'

>  
> -        ADD_ARG_LIT("-monitor");
> -        ADD_ARG(virBufferContentAndReset(&buf));
> +            qemudBuildCommandLineChrDevChardevStr(monitor_chr, id, &buf);
> +            if (virBufferError(&buf))
> +                goto error;
> +
> +            ADD_ARG_LIT("-chardev");
> +            ADD_ARG(virBufferContentAndReset(&buf));
> +
> +            virBufferVSprintf(&buf, "chardev:%s", id);
> +            if (virBufferError(&buf))
> +                goto error;
> +
> +            ADD_ARG_LIT("-monitor");
> +            ADD_ARG(virBufferContentAndReset(&buf));
> +        }
> +
> +        else {
> +            qemudBuildCommandLineChrDevStr(monitor_chr, &buf);
> +            if (virBufferError(&buf))
> +                goto error;
> +
> +            ADD_ARG_LIT("-monitor");
> +            ADD_ARG(virBufferContentAndReset(&buf));
> +        }
>      }


Regards,
Daniel
-- 
|: Red Hat, Engineering, London   -o-   http://people.redhat.com/berrange/ :|
|: http://libvirt.org  -o-  http://virt-manager.org  -o-  http://ovirt.org :|
|: http://autobuild.org       -o-         http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505  -o-  F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]