Re: [PATCH 07/12] qemu: command: Refactor creation of RNG device commandline

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

 



On Fri, Feb 06, 2015 at 04:32:21PM +0100, Peter Krempa wrote:
> As the RNG device is using an -object as backend refactor the code to
> use the JSON to commandline generator so that we can reuse the code
> later in hotplug.
> ---
>  src/qemu/qemu_command.c | 108 +++++++++++++++++++++++++++++++++++++-----------
>  1 file changed, 84 insertions(+), 24 deletions(-)
> 
> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index 6380621..9179c1f 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -6154,15 +6154,33 @@ qemuBuildSclpDevStr(virDomainChrDefPtr dev)
> 
> 
>  static int
> -qemuBuildRNGBackendArgs(virCommandPtr cmd,
> -                        virDomainRNGDefPtr dev,
> -                        virQEMUCapsPtr qemuCaps)
> +qemuBuildRNGBackendChrdevStr(virDomainRNGDefPtr rng,
> +                             virQEMUCapsPtr qemuCaps,
> +                             char **chr)
>  {
> -    virBuffer buf = VIR_BUFFER_INITIALIZER;
> -    char *backend = NULL;
> +    *chr = NULL;
> +
> +    if (rng->backend != VIR_DOMAIN_RNG_BACKEND_EGD)
> +        return 0;

Making this a switch ((virDomainRNGBackend)) would check if all the
enum values are handled.

> +
> +    if (!(*chr = qemuBuildChrChardevStr(rng->source.chardev,
> +                                        rng->info.alias, qemuCaps)))
> +        return -1;
> +

> @@ -10146,16 +10186,36 @@ qemuBuildCommandLine(virConnectPtr conn,
>      }
> 
>      for (i = 0; i < def->nrngs; i++) {
> -        char *devstr;
> +        virDomainRNGDefPtr rng = def->rngs[i];
> +        char *tmp;
> +
> +        if (!rng->info.alias) {
> +            virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
> +                           _("RNG device is missing alias"));
> +            goto error;
> +        }

Is it possible for the alias to be NULL at this point?
But it's still better to check twice than crash. :)

Jan

Attachment: signature.asc
Description: Digital signature

--
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]