Re: [PATCH 4/9] qemuBuildVhostuserCommandLine: Reuse qemuBuildChrChardevStr

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

 




On 08/16/2016 11:41 AM, Michal Privoznik wrote:
> There's no need to reinvent the wheel here. We already have a
> function to format virDomainChrSourceDefPtr. It's called
> qemuBuildChrChardevStr(). Use that instead of some dummy
> virBufferAsprintf().
> 
> Signed-off-by: Michal Privoznik <mprivozn@xxxxxxxxxx>
> ---
>  src/qemu/qemu_command.c | 16 +++++++++-------
>  1 file changed, 9 insertions(+), 7 deletions(-)
> 
> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index c419ecf..59fcb4c 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -7848,7 +7848,7 @@ qemuBuildVhostuserCommandLine(virCommandPtr cmd,
>                                virQEMUCapsPtr qemuCaps,
>                                unsigned int bootindex)
>  {
> -    virBuffer chardev_buf = VIR_BUFFER_INITIALIZER;
> +    char *chardev = NULL;
>      virBuffer netdev_buf = VIR_BUFFER_INITIALIZER;
>      unsigned int queues = net->driver.virtio.queues;
>      char *nic = NULL;
> @@ -7861,9 +7861,10 @@ qemuBuildVhostuserCommandLine(virCommandPtr cmd,
>  
>      switch ((virDomainChrType) net->data.vhostuser->type) {
>      case VIR_DOMAIN_CHR_TYPE_UNIX:
> -        virBufferAsprintf(&chardev_buf, "socket,id=char%s,path=%s%s",
> -                          net->info.alias, net->data.vhostuser->data.nix.path,
> -                          net->data.vhostuser->data.nix.listen ? ",server" : "");
> +        if (!(chardev = qemuBuildChrChardevStr(NULL, NULL, NULL, def,

logManager == NULL?
cmd == NULL?
cfg == NULL?

if (dev->logfile) code will surely have problems (as will the TLS code)

While true your narrow usage could avoid the TLS code that's going to
dereference cfg without doing the obligatory "cfg &&", I'm still not
clear how it would avoid the dev->logfile code.

Shouldn't this support that logManager anyway? If not, then perhaps it
needs to be more explicit.  IOW: Extra checks.

John

> +                                               net->data.vhostuser,
> +                                               net->info.alias, qemuCaps, false)))
> +            goto error;
>          break;
>  
>      case VIR_DOMAIN_CHR_TYPE_NULL:
> @@ -7881,7 +7882,7 @@ qemuBuildVhostuserCommandLine(virCommandPtr cmd,
>      case VIR_DOMAIN_CHR_TYPE_LAST:
>          virReportError(VIR_ERR_INTERNAL_ERROR,
>                         _("vhost-user type '%s' not supported"),
> -                        virDomainChrTypeToString(net->data.vhostuser->type));
> +                       virDomainChrTypeToString(net->data.vhostuser->type));
>          goto error;
>      }
>  
> @@ -7899,7 +7900,8 @@ qemuBuildVhostuserCommandLine(virCommandPtr cmd,
>      }
>  
>      virCommandAddArg(cmd, "-chardev");
> -    virCommandAddArgBuffer(cmd, &chardev_buf);
> +    virCommandAddArg(cmd, chardev);
> +    VIR_FREE(chardev);
>  
>      virCommandAddArg(cmd, "-netdev");
>      virCommandAddArgBuffer(cmd, &netdev_buf);
> @@ -7917,7 +7919,7 @@ qemuBuildVhostuserCommandLine(virCommandPtr cmd,
>      return 0;
>  
>   error:
> -    virBufferFreeAndReset(&chardev_buf);
> +    VIR_FREE(chardev);
>      virBufferFreeAndReset(&netdev_buf);
>      VIR_FREE(nic);
>  
> 

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]