File 405c0f07-qemu-rename-chardev-func.patch of Package libvirt.9596

commit 405c0f07f5c444c52bd6cc95476753c7c8b2ffe2
Author: Cole Robinson <crobinso@redhat.com>
Date:   Mon Jun 26 14:01:53 2017 -0400

    qemu: Rename SupportsChardev to IsPlatformDevice
    
    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.
    
    Reviewed-by: Andrea Bolognani <abologna@redhat.com>
    Signed-off-by: Cole Robinson <crobinso@redhat.com>

Index: libvirt-3.3.0/src/qemu/qemu_capabilities.c
===================================================================
--- libvirt-3.3.0.orig/src/qemu/qemu_capabilities.c
+++ libvirt-3.3.0/src/qemu/qemu_capabilities.c
@@ -5479,33 +5479,6 @@ virQEMUCapsCacheFree(virQEMUCapsCachePtr
 
 
 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;
-    }
-
-    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;
-}
-
-
-bool
 virQEMUCapsSupportsVmport(virQEMUCapsPtr qemuCaps,
                           const virDomainDef *def)
 {
Index: libvirt-3.3.0/src/qemu/qemu_capabilities.h
===================================================================
--- libvirt-3.3.0.orig/src/qemu/qemu_capabilities.h
+++ libvirt-3.3.0/src/qemu/qemu_capabilities.h
@@ -518,10 +518,6 @@ int virQEMUCapsGetDefaultVersion(virCaps
 
 VIR_ENUM_DECL(virQEMUCaps);
 
-bool virQEMUCapsSupportsChardev(const virDomainDef *def,
-                                virQEMUCapsPtr qemuCaps,
-                                virDomainChrDefPtr chr);
-
 bool virQEMUCapsSupportsGICVersion(virQEMUCapsPtr qemuCaps,
                                    virDomainVirtType virtType,
                                    virGICVersion version);
Index: libvirt-3.3.0/src/qemu/qemu_command.c
===================================================================
--- libvirt-3.3.0.orig/src/qemu/qemu_command.c
+++ libvirt-3.3.0/src/qemu/qemu_command.c
@@ -8976,6 +8976,30 @@ qemuBuildChrDeviceCommandLine(virCommand
 }
 
 
+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;
+    }
+
+    if (def->os.arch == VIR_ARCH_ARMV7L || def->os.arch == VIR_ARCH_AARCH64) {
+        /* TARGET_TYPE_ISA here really means 'the default platform device' */
+        if (chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_SERIAL &&
+            chr->targetType == VIR_DOMAIN_CHR_SERIAL_TARGET_TYPE_ISA)
+            return true;
+    }
+
+    return false;
+}
+
+
 static int
 qemuBuildSerialCommandLine(virLogManagerPtr logManager,
                            virCommandPtr cmd,
@@ -9009,8 +9033,8 @@ qemuBuildSerialCommandLine(virLogManager
         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 {
openSUSE Build Service is sponsored by