[libvirt] [PATCH 03/14] qemu: Introduce qemuDomainChrDefPostParse()

Pavel Hrdina phrdina at redhat.com
Thu Nov 16 10:30:59 UTC 2017


On Wed, Nov 15, 2017 at 12:50:06PM +0100, Andrea Bolognani wrote:
> Having a separate function for char device handling is better than
> adding even more code to qemuDomainDeviceDefPostParse().
> 
> Signed-off-by: Andrea Bolognani <abologna at redhat.com>
> ---
>  src/qemu/qemu_domain.c | 25 ++++++++++++++++++-------
>  1 file changed, 18 insertions(+), 7 deletions(-)
> 
> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index cc7596bad..2d5eee01e 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c
> @@ -4036,6 +4036,19 @@ qemuDomainControllerDefPostParse(virDomainControllerDefPtr cont,
>      return 0;
>  }
>  
> +static int
> +qemuDomainChrDefPostParse(virDomainChrDefPtr chr,
> +                          const virDomainDef *def)
> +{
> +    /* set the default console type for S390 arches */
> +    if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
> +        chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE &&
> +        ARCH_IS_S390(def->os.arch)) {
> +        chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO;
> +    }
> +
> +    return 0;
> +}
>  
>  static int
>  qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
> @@ -4096,13 +4109,6 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
>          }
>      }
>  
> -    /* set the default console type for S390 arches */
> -    if (dev->type == VIR_DOMAIN_DEVICE_CHR &&
> -        dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
> -        dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE &&
> -        ARCH_IS_S390(def->os.arch))
> -        dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO;
> -

You've missed the following condition that clears auto generated unix
socket path, it is also for char devices.

>      /* clear auto generated unix socket path for inactive definitions */
>      if ((parseFlags & VIR_DOMAIN_DEF_PARSE_INACTIVE) &&
>          dev->type == VIR_DOMAIN_DEVICE_CHR) {
> @@ -4154,6 +4160,11 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
>          qemuDomainShmemDefPostParse(dev->data.shmem) < 0)
>          goto cleanup;
>  
> +    if (dev->type == VIR_DOMAIN_DEVICE_CHR &&
> +        qemuDomainChrDefPostParse(dev->data.chr, def) < 0) {
> +        goto cleanup;
> +    }
> +

Is there any specific reason why did you move it to a different place?

Pavel
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: not available
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20171116/d88f366d/attachment-0001.sig>


More information about the libvir-list mailing list