[libvirt] [PATCH v2 01/21] qemu: Introduce qemuDomainChrDefPostParse()
Marc Hartmayer
mhartmay at linux.vnet.ibm.com
Wed Nov 22 12:38:57 UTC 2017
On Tue, Nov 21, 2017 at 05:42 PM +0100, Andrea Bolognani <abologna at redhat.com> 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 | 57 ++++++++++++++++++++++++++++++--------------------
> 1 file changed, 34 insertions(+), 23 deletions(-)
>
> diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
> index cc7596bad..c6ba4079d 100644
> --- a/src/qemu/qemu_domain.c
> +++ b/src/qemu/qemu_domain.c
> @@ -4036,6 +4036,35 @@ qemuDomainControllerDefPostParse(virDomainControllerDefPtr cont,
> return 0;
> }
>
> +static int
> +qemuDomainChrDefPostParse(virDomainChrDefPtr chr,
> + const virDomainDef *def,
> + virQEMUDriverPtr driver,
> + unsigned int parseFlags)
> +{
> + /* 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;
> + }
> +
> + /* clear auto generated unix socket path for inactive definitions */
> + if (parseFlags & VIR_DOMAIN_DEF_PARSE_INACTIVE) {
> + if (qemuDomainChrDefDropDefaultPath(chr, driver) < 0)
> + return -1;
> +
> + /* For UNIX chardev if no path is provided we generate one.
> + * This also implies that the mode is 'bind'. */
> + if (chr->source &&
> + chr->source->type == VIR_DOMAIN_CHR_TYPE_UNIX &&
> + !chr->source->data.nix.path) {
> + chr->source->data.nix.listen = true;
> + }
> + }
> +
> + return 0;
> +}
>
> static int
> qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
> @@ -4096,29 +4125,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;
> -
> - /* clear auto generated unix socket path for inactive definitions */
> - if ((parseFlags & VIR_DOMAIN_DEF_PARSE_INACTIVE) &&
> - dev->type == VIR_DOMAIN_DEVICE_CHR) {
> - virDomainChrDefPtr chr = dev->data.chr;
> - if (qemuDomainChrDefDropDefaultPath(chr, driver) < 0)
> - goto cleanup;
> -
> - /* For UNIX chardev if no path is provided we generate one.
> - * This also implies that the mode is 'bind'. */
> - if (chr->source &&
> - chr->source->type == VIR_DOMAIN_CHR_TYPE_UNIX &&
> - !chr->source->data.nix.path) {
> - chr->source->data.nix.listen = true;
> - }
> - }
> -
> if (dev->type == VIR_DOMAIN_DEVICE_VIDEO) {
> if (dev->data.video->type == VIR_DOMAIN_VIDEO_TYPE_DEFAULT) {
> if ARCH_IS_PPC64(def->os.arch)
> @@ -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, driver, parseFlags) < 0) {
> + goto cleanup;
> + }
> +
> ret = 0;
>
> cleanup:
> --
> 2.14.3
>
> --
> libvir-list mailing list
> libvir-list at redhat.com
> https://www.redhat.com/mailman/listinfo/libvir-list
>
Reviewed-by: Marc Hartmayer <mhartmay at linux.vnet.ibm.com>
--
Beste Grüße / Kind regards
Marc Hartmayer
IBM Deutschland Research & Development GmbH
Vorsitzende des Aufsichtsrats: Martina Koederitz
Geschäftsführung: Dirk Wittkopp
Sitz der Gesellschaft: Böblingen
Registergericht: Amtsgericht Stuttgart, HRB 243294
More information about the libvir-list
mailing list