404507
From 06cb6ae1254842377d0b17f9fdd52e0d2b6b23eb Mon Sep 17 00:00:00 2001
404507
Message-Id: <06cb6ae1254842377d0b17f9fdd52e0d2b6b23eb@dist-git>
404507
From: Andrea Bolognani <abologna@redhat.com>
404507
Date: Wed, 29 Nov 2017 16:22:56 +0100
404507
Subject: [PATCH] qemu: Introduce qemuDomainChrDefPostParse()
404507
404507
Having a separate function for char device handling is better than
404507
adding even more code to qemuDomainDeviceDefPostParse().
404507
404507
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
404507
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
404507
Reviewed-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
404507
(cherry picked from commit f4b50cc1b994e44c793f4dea59489ba51e2d1fe0)
404507
404507
https://bugzilla.redhat.com/show_bug.cgi?id=1449265
404507
https://bugzilla.redhat.com/show_bug.cgi?id=1511421
404507
https://bugzilla.redhat.com/show_bug.cgi?id=1512929
404507
https://bugzilla.redhat.com/show_bug.cgi?id=1512934
404507
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
404507
---
404507
 src/qemu/qemu_domain.c | 57 ++++++++++++++++++++++++++++++--------------------
404507
 1 file changed, 34 insertions(+), 23 deletions(-)
404507
404507
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
404507
index 138f773c22..b15d994774 100644
404507
--- a/src/qemu/qemu_domain.c
404507
+++ b/src/qemu/qemu_domain.c
404507
@@ -4082,6 +4082,35 @@ qemuDomainControllerDefPostParse(virDomainControllerDefPtr cont,
404507
     return 0;
404507
 }
404507
 
404507
+static int
404507
+qemuDomainChrDefPostParse(virDomainChrDefPtr chr,
404507
+                          const virDomainDef *def,
404507
+                          virQEMUDriverPtr driver,
404507
+                          unsigned int parseFlags)
404507
+{
404507
+    /* set the default console type for S390 arches */
404507
+    if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
404507
+        chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE &&
404507
+        ARCH_IS_S390(def->os.arch)) {
404507
+        chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO;
404507
+    }
404507
+
404507
+    /* clear auto generated unix socket path for inactive definitions */
404507
+    if (parseFlags & VIR_DOMAIN_DEF_PARSE_INACTIVE) {
404507
+        if (qemuDomainChrDefDropDefaultPath(chr, driver) < 0)
404507
+            return -1;
404507
+
404507
+        /* For UNIX chardev if no path is provided we generate one.
404507
+         * This also implies that the mode is 'bind'. */
404507
+        if (chr->source &&
404507
+            chr->source->type == VIR_DOMAIN_CHR_TYPE_UNIX &&
404507
+            !chr->source->data.nix.path) {
404507
+            chr->source->data.nix.listen = true;
404507
+        }
404507
+    }
404507
+
404507
+    return 0;
404507
+}
404507
 
404507
 static int
404507
 qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
404507
@@ -4142,29 +4171,6 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
404507
         }
404507
     }
404507
 
404507
-    /* set the default console type for S390 arches */
404507
-    if (dev->type == VIR_DOMAIN_DEVICE_CHR &&
404507
-        dev->data.chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
404507
-        dev->data.chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_NONE &&
404507
-        ARCH_IS_S390(def->os.arch))
404507
-        dev->data.chr->targetType = VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_VIRTIO;
404507
-
404507
-    /* clear auto generated unix socket path for inactive definitions */
404507
-    if ((parseFlags & VIR_DOMAIN_DEF_PARSE_INACTIVE) &&
404507
-        dev->type == VIR_DOMAIN_DEVICE_CHR) {
404507
-        virDomainChrDefPtr chr = dev->data.chr;
404507
-        if (qemuDomainChrDefDropDefaultPath(chr, driver) < 0)
404507
-            goto cleanup;
404507
-
404507
-        /* For UNIX chardev if no path is provided we generate one.
404507
-         * This also implies that the mode is 'bind'. */
404507
-        if (chr->source &&
404507
-            chr->source->type == VIR_DOMAIN_CHR_TYPE_UNIX &&
404507
-            !chr->source->data.nix.path) {
404507
-            chr->source->data.nix.listen = true;
404507
-        }
404507
-    }
404507
-
404507
     if (dev->type == VIR_DOMAIN_DEVICE_VIDEO) {
404507
         if (dev->data.video->type == VIR_DOMAIN_VIDEO_TYPE_DEFAULT) {
404507
             if ARCH_IS_PPC64(def->os.arch)
404507
@@ -4200,6 +4206,11 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr dev,
404507
         qemuDomainShmemDefPostParse(dev->data.shmem) < 0)
404507
         goto cleanup;
404507
 
404507
+    if (dev->type == VIR_DOMAIN_DEVICE_CHR &&
404507
+        qemuDomainChrDefPostParse(dev->data.chr, def, driver, parseFlags) < 0) {
404507
+        goto cleanup;
404507
+    }
404507
+
404507
     ret = 0;
404507
 
404507
  cleanup:
404507
-- 
404507
2.15.1
404507