diff mbox series

[12/12] qemu: Rename SupportsChardev to IsPlatformDevice

Message ID 3755681e5042a9d88cc5f63217d96333e580a97c.1498499392.git.crobinso@redhat.com
State Accepted
Commit 405c0f07f5c444c52bd6cc95476753c7c8b2ffe2
Headers show
Series qemu: support chardev for all machvirt config | expand

Commit Message

Cole Robinson June 26, 2017, 6:01 p.m. UTC
This is only used in qemu_command.c, so move it, and clarify that
it's really about identifying if the serial config is a platform
device or not.

Signed-off-by: Cole Robinson <crobinso@redhat.com>

---
 src/qemu/qemu_capabilities.c | 31 -------------------------------
 src/qemu/qemu_capabilities.h |  4 ----
 src/qemu/qemu_command.c      | 34 ++++++++++++++++++++++++++++++++--
 3 files changed, 32 insertions(+), 37 deletions(-)

-- 
2.13.0

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list

Comments

Andrea Bolognani July 7, 2017, 4:38 p.m. UTC | #1
On Mon, 2017-06-26 at 14:01 -0400, Cole Robinson wrote:
> This is only used in qemu_command.c, so move it, and clarify that
> it's really about identifying if the serial config is a platform
> device or not.

You're not only moving and renaming the function, you're
also entirely reversing its logic. Please mention that as
well in the commit message.

> +    if ((def->os.arch == VIR_ARCH_ARMV7L) ||
> +        (def->os.arch == VIR_ARCH_AARCH64)) {
> +        /* TARGET_TYPE_ISA here really means 'the default', which we
> +           treat as whatever the built in platform serial device is on.
> +           And for platform devices we can't use -chardev */

This comment definitely needs to be updated now that we're
using -chardev for everything, and this is the perfect time.


Reviewed-by: Andrea Bolognani <abologna@redhat.com>

-- 
Andrea Bolognani / Red Hat / Virtualization

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
diff mbox series

Patch

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index a20f405c2..db9f9b8b1 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -5550,37 +5550,6 @@  virQEMUCapsCacheFree(virQEMUCapsCachePtr cache)
 
 
 bool
-virQEMUCapsSupportsChardev(const virDomainDef *def,
-                           virQEMUCapsPtr qemuCaps ATTRIBUTE_UNUSED,
-                           virDomainChrDefPtr chr)
-{
-    if ((def->os.arch == VIR_ARCH_PPC) || ARCH_IS_PPC64(def->os.arch)) {
-        if (!qemuDomainIsPSeries(def))
-            return false;
-        /* only pseries need -device spapr-vty with -chardev */
-        if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
-            chr->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO)
-            return false;
-        return true;
-    }
-
-    if ((def->os.arch == VIR_ARCH_ARMV7L) ||
-        (def->os.arch == VIR_ARCH_AARCH64)) {
-        /* TARGET_TYPE_ISA here really means 'the default', which we
-           treat as whatever the built in platform serial device is on.
-           And for platform devices we can't use -chardev */
-        if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
-            chr->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA)
-            return false;
-
-        return true;
-    }
-
-    return true;
-}
-
-
-bool
 virQEMUCapsSupportsVmport(virQEMUCapsPtr qemuCaps,
                           const virDomainDef *def)
 {
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 829cbaadb..fb22815e9 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -525,10 +525,6 @@  int virQEMUCapsGetDefaultVersion(virCapsPtr caps,
 
 VIR_ENUM_DECL(virQEMUCaps);
 
-bool virQEMUCapsSupportsChardev(const virDomainDef *def,
-                                virQEMUCapsPtr qemuCaps,
-                                virDomainChrDefPtr chr);
-
 bool virQEMUCapsSupportsGICVersion(virQEMUCapsPtr qemuCaps,
                                    virDomainVirtType virtType,
                                    virGICVersion version);
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
index 3e82ca086..d6fd2f2b6 100644
--- a/src/qemu/qemu_command.c
+++ b/src/qemu/qemu_command.c
@@ -9101,6 +9101,36 @@  qemuBuildChrDeviceCommandLine(virCommandPtr cmd,
 }
 
 
+static bool
+qemuChrIsPlatformDevice(const virDomainDef *def,
+                        virDomainChrDefPtr chr)
+{
+    if ((def->os.arch == VIR_ARCH_PPC) || ARCH_IS_PPC64(def->os.arch)) {
+        if (!qemuDomainIsPSeries(def))
+            return true;
+        /* only pseries need -device spapr-vty with -chardev */
+        if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
+            chr->info.type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO)
+            return true;
+        return false;
+    }
+
+    if ((def->os.arch == VIR_ARCH_ARMV7L) ||
+        (def->os.arch == VIR_ARCH_AARCH64)) {
+        /* TARGET_TYPE_ISA here really means 'the default', which we
+           treat as whatever the built in platform serial device is on.
+           And for platform devices we can't use -chardev */
+        if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
+            chr->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA)
+            return true;
+
+        return false;
+    }
+
+    return false;
+}
+
+
 static int
 qemuBuildSerialCommandLine(virLogManagerPtr logManager,
                            virCommandPtr cmd,
@@ -9136,8 +9166,8 @@  qemuBuildSerialCommandLine(virLogManagerPtr logManager,
         virCommandAddArg(cmd, devstr);
         VIR_FREE(devstr);
 
-        /* Use -chardev with -device if they are available */
-        if (virQEMUCapsSupportsChardev(def, qemuCaps, serial)) {
+        /* If the device is not a platform device, build the devstr */
+        if (!qemuChrIsPlatformDevice(def, serial)) {
             if (qemuBuildChrDeviceCommandLine(cmd, def, serial, qemuCaps) < 0)
                 return -1;
         } else {