render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
6d3351
From 76122cda79a4864f632ef1e5ea4bb5364cde4595 Mon Sep 17 00:00:00 2001
6d3351
Message-Id: <76122cda79a4864f632ef1e5ea4bb5364cde4595@dist-git>
6d3351
From: Cole Robinson <crobinso@redhat.com>
6d3351
Date: Tue, 11 Jul 2017 10:57:49 +0200
6d3351
Subject: [PATCH] qemu: Rename SupportsChardev to IsPlatformDevice
6d3351
6d3351
This is only used in qemu_command.c, so move it, and clarify that
6d3351
it's really about identifying if the serial config is a platform
6d3351
device or not.
6d3351
6d3351
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6d3351
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6d3351
(cherry picked from commit 405c0f07f5c444c52bd6cc95476753c7c8b2ffe2)
6d3351
6d3351
Bug: https://bugzilla.redhat.com/show_bug.cgi?id=1435681
6d3351
6d3351
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6d3351
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
6d3351
---
6d3351
 src/qemu/qemu_capabilities.c | 27 ---------------------------
6d3351
 src/qemu/qemu_capabilities.h |  4 ----
6d3351
 src/qemu/qemu_command.c      | 28 ++++++++++++++++++++++++++--
6d3351
 3 files changed, 26 insertions(+), 33 deletions(-)
6d3351
6d3351
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
6d3351
index 0e611c343c..60281373f0 100644
6d3351
--- a/src/qemu/qemu_capabilities.c
6d3351
+++ b/src/qemu/qemu_capabilities.c
6d3351
@@ -5502,33 +5502,6 @@ virQEMUCapsCacheFree(virQEMUCapsCachePtr cache)
6d3351
 
6d3351
 
6d3351
 bool
6d3351
-virQEMUCapsSupportsChardev(const virDomainDef *def,
6d3351
-                           virQEMUCapsPtr qemuCaps ATTRIBUTE_UNUSED,
6d3351
-                           virDomainChrDefPtr chr)
6d3351
-{
6d3351
-    if ((def->os.arch == VIR_ARCH_PPC) || ARCH_IS_PPC64(def->os.arch)) {
6d3351
-        if (!qemuDomainIsPSeries(def))
6d3351
-            return false;
6d3351
-        /* only pseries need -device spapr-vty with -chardev */
6d3351
-        if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
6d3351
-            chr->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO)
6d3351
-            return false;
6d3351
-    }
6d3351
-
6d3351
-    if (def->os.arch == VIR_ARCH_ARMV7L || def->os.arch == VIR_ARCH_AARCH64) {
6d3351
-        /* TARGET_TYPE_ISA here really means 'the default', which we
6d3351
-           treat as whatever the built in platform serial device is on.
6d3351
-           And for platform devices we can't use -chardev */
6d3351
-        if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
6d3351
-            chr->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA)
6d3351
-            return false;
6d3351
-    }
6d3351
-
6d3351
-    return true;
6d3351
-}
6d3351
-
6d3351
-
6d3351
-bool
6d3351
 virQEMUCapsSupportsVmport(virQEMUCapsPtr qemuCaps,
6d3351
                           const virDomainDef *def)
6d3351
 {
6d3351
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
6d3351
index 433aa7f90b..5b8e654d10 100644
6d3351
--- a/src/qemu/qemu_capabilities.h
6d3351
+++ b/src/qemu/qemu_capabilities.h
6d3351
@@ -543,10 +543,6 @@ void virQEMUCapsInitQMPBasicArch(virQEMUCapsPtr qemuCaps);
6d3351
 
6d3351
 VIR_ENUM_DECL(virQEMUCaps);
6d3351
 
6d3351
-bool virQEMUCapsSupportsChardev(const virDomainDef *def,
6d3351
-                                virQEMUCapsPtr qemuCaps,
6d3351
-                                virDomainChrDefPtr chr);
6d3351
-
6d3351
 bool virQEMUCapsSupportsGICVersion(virQEMUCapsPtr qemuCaps,
6d3351
                                    virDomainVirtType virtType,
6d3351
                                    virGICVersion version);
6d3351
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
6d3351
index 69f4323a3b..7ad3d16ea8 100644
6d3351
--- a/src/qemu/qemu_command.c
6d3351
+++ b/src/qemu/qemu_command.c
6d3351
@@ -9063,6 +9063,30 @@ qemuBuildChrDeviceCommandLine(virCommandPtr cmd,
6d3351
 }
6d3351
 
6d3351
 
6d3351
+static bool
6d3351
+qemuChrIsPlatformDevice(const virDomainDef *def,
6d3351
+                        virDomainChrDefPtr chr)
6d3351
+{
6d3351
+    if ((def->os.arch == VIR_ARCH_PPC) || ARCH_IS_PPC64(def->os.arch)) {
6d3351
+        if (!qemuDomainIsPSeries(def))
6d3351
+            return true;
6d3351
+        /* only pseries need -device spapr-vty with -chardev */
6d3351
+        if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
6d3351
+            chr->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO)
6d3351
+            return true;
6d3351
+    }
6d3351
+
6d3351
+    if (def->os.arch == VIR_ARCH_ARMV7L || def->os.arch == VIR_ARCH_AARCH64) {
6d3351
+        /* TARGET_TYPE_ISA here really means 'the default platform device' */
6d3351
+        if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
6d3351
+            chr->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA)
6d3351
+            return true;
6d3351
+    }
6d3351
+
6d3351
+    return false;
6d3351
+}
6d3351
+
6d3351
+
6d3351
 static int
6d3351
 qemuBuildSerialCommandLine(virLogManagerPtr logManager,
6d3351
                            virCommandPtr cmd,
6d3351
@@ -9096,8 +9120,8 @@ qemuBuildSerialCommandLine(virLogManagerPtr logManager,
6d3351
         virCommandAddArg(cmd, devstr);
6d3351
         VIR_FREE(devstr);
6d3351
 
6d3351
-        /* Use -chardev with -device if they are available */
6d3351
-        if (virQEMUCapsSupportsChardev(def, qemuCaps, serial)) {
6d3351
+        /* If the device is not a platform device, build the devstr */
6d3351
+        if (!qemuChrIsPlatformDevice(def, serial)) {
6d3351
             if (qemuBuildChrDeviceCommandLine(cmd, def, serial, qemuCaps) < 0)
6d3351
                 return -1;
6d3351
         } else {
6d3351
-- 
6d3351
2.13.3
6d3351