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

Re: [libvirt] [PATCH 13/25] qemu: Introduce qemuBuildChannelsCommandLine




On 02/18/2016 12:50 PM, John Ferlan wrote:
> Add new function to manage adding the channel device options to the
> command line removing that task from the mainline qemuBuildCommandLine.
> 
> Signed-off-by: John Ferlan <jferlan redhat com>
> ---
>  src/qemu/qemu_command.c | 159 ++++++++++++++++++++++++++----------------------
>  1 file changed, 87 insertions(+), 72 deletions(-)
> 

I've merged my local branch with the latest upstream taking into account
Martin's commit 'a89f05ba8d' with the following adjustment:

The rest of the changes merged fine. I can repost (in parts) if
desired...  To make it less onerous to review such a large pile.


> diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
> index f161c4f..07328b0 100644
> --- a/src/qemu/qemu_command.c
> +++ b/src/qemu/qemu_command.c
> @@ -7666,6 +7666,91 @@ qemuBuildParallelsCommandLine(virCommandPtr cmd,
>  
>  
>  static int
> +qemuBuildChannelsCommandLine(virCommandPtr cmd,
> +                             virQEMUDriverConfigPtr cfg,
> +                             const virDomainDef *def,
> +                             virQEMUCapsPtr qemuCaps)
> +{
> +    size_t i;
> +
> +    for (i = 0; i < def->nchannels; i++) {
> +        virDomainChrDefPtr channel = def->channels[i];
> +        char *devstr;
> +
> +        switch (channel->targetType) {
> +        case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD:
> +            if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV) ||
> +                !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
> +                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
> +                               "%s", _("guestfwd requires QEMU to support -chardev & -device"));
> +                return -1;
> +            }
> +
> +            virCommandAddArg(cmd, "-chardev");
> +            if (!(devstr = qemuBuildChrChardevStr(&channel->source,
> +                                                  channel->info.alias,
> +                                                  qemuCaps)))
> +                return -1;
> +            virCommandAddArg(cmd, devstr);
> +            VIR_FREE(devstr);
> +
> +            if (qemuBuildChrDeviceStr(&devstr, def, channel, qemuCaps) < 0)
> +                return -1;
> +            virCommandAddArgList(cmd, "-netdev", devstr, NULL);
> +            VIR_FREE(devstr);
> +            break;
> +
> +        case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO:
> +            if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
> +                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> +                               _("virtio channel requires QEMU to support -device"));
> +                return -1;
> +            }
> +
> +            /*
> +             * TODO: Refactor so that we generate this (and onther
> +             * things) somewhere else then where we are building the
> +             * command line.
> +             */
> +            if (channel->source.type == VIR_DOMAIN_CHR_TYPE_UNIX &&
> +                !channel->source.data.nix.path) {
> +                if (virAsprintf(&channel->source.data.nix.path,
> +                                "%s/domain-%s/%s",
> +                                cfg->channelTargetDir, def->name,

 -                                "%s/domain-%s/%s",
 -                                cfg->channelTargetDir, def->name,
++                                "%s/%s", domainChannelTargetDir,

> +                                channel->target.name ? channel->target.name
> +                                : "unknown.sock") < 0)
> +                    return -1;
> +
> +                channel->source.data.nix.listen = true;
> +            }
> +
> +            if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_SPICEVMC) &&
> +                channel->source.type == VIR_DOMAIN_CHR_TYPE_SPICEVMC) {
> +                /* spicevmc was originally introduced via a -device
> +                 * with a backend internal to qemu; although we prefer
> +                 * the newer -chardev interface.  */
> +                ;
> +            } else {
> +                virCommandAddArg(cmd, "-chardev");
> +                if (!(devstr = qemuBuildChrChardevStr(&channel->source,
> +                                                      channel->info.alias,
> +                                                      qemuCaps)))
> +                    return -1;
> +                virCommandAddArg(cmd, devstr);
> +                VIR_FREE(devstr);
> +            }
> +
> +            if (qemuBuildChrDeviceCommandLine(cmd, def, channel, qemuCaps) < 0)
> +                return -1;
> +            break;
> +        }
> +    }
> +
> +    return 0;
> +}
> +
> +
> +static int
>  qemuBuildDomainLoaderCommandLine(virCommandPtr cmd,
>                                   virDomainDefPtr def,
>                                   virQEMUCapsPtr qemuCaps)
> @@ -8221,78 +8306,8 @@ qemuBuildCommandLine(virConnectPtr conn,
>      if (qemuBuildParallelsCommandLine(cmd, def, qemuCaps) < 0)
>          goto error;
>  
> -    for (i = 0; i < def->nchannels; i++) {
> -        virDomainChrDefPtr channel = def->channels[i];
> -        char *devstr;
> -
> -        switch (channel->targetType) {
> -        case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_GUESTFWD:
> -            if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV) ||
> -                !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
> -                virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
> -                               "%s", _("guestfwd requires QEMU to support -chardev & -device"));
> -                goto error;
> -            }
> -
> -            virCommandAddArg(cmd, "-chardev");
> -            if (!(devstr = qemuBuildChrChardevStr(&channel->source,
> -                                                  channel->info.alias,
> -                                                  qemuCaps)))
> -                goto error;
> -            virCommandAddArg(cmd, devstr);
> -            VIR_FREE(devstr);
> -
> -            if (qemuBuildChrDeviceStr(&devstr, def, channel, qemuCaps) < 0)
> -                goto error;
> -            virCommandAddArgList(cmd, "-netdev", devstr, NULL);
> -            VIR_FREE(devstr);
> -            break;
> -
> -        case VIR_DOMAIN_CHR_CHANNEL_TARGET_TYPE_VIRTIO:
> -            if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
> -                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> -                               _("virtio channel requires QEMU to support -device"));
> -                goto error;
> -            }
> -
> -            /*
> -             * TODO: Refactor so that we generate this (and onther
> -             * things) somewhere else then where we are building the
> -             * command line.
> -             */
> -            if (channel->source.type == VIR_DOMAIN_CHR_TYPE_UNIX &&
> -                !channel->source.data.nix.path) {
> -                if (virAsprintf(&channel->source.data.nix.path,
> -                                "%s/domain-%s/%s",
> -                                cfg->channelTargetDir, def->name,
> -                                channel->target.name ? channel->target.name
> -                                : "unknown.sock") < 0)
> -                    goto error;
> -
> -                channel->source.data.nix.listen = true;
> -            }
> -
> -            if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_SPICEVMC) &&
> -                channel->source.type == VIR_DOMAIN_CHR_TYPE_SPICEVMC) {
> -                /* spicevmc was originally introduced via a -device
> -                 * with a backend internal to qemu; although we prefer
> -                 * the newer -chardev interface.  */
> -                ;
> -            } else {
> -                virCommandAddArg(cmd, "-chardev");
> -                if (!(devstr = qemuBuildChrChardevStr(&channel->source,
> -                                                      channel->info.alias,
> -                                                      qemuCaps)))
> -                    goto error;
> -                virCommandAddArg(cmd, devstr);
> -                VIR_FREE(devstr);
> -            }
> -
> -            if (qemuBuildChrDeviceCommandLine(cmd, def, channel, qemuCaps) < 0)
> -                goto error;
> -            break;
> -        }
> -    }
> +    if (qemuBuildChannelsCommandLine(cmd, cfg, def, qemuCaps) < 0)
> +        goto error;
>  
>      /* Explicit console devices */
>      for (i = 0; i < def->nconsoles; i++) {
> 


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