render / rpms / libvirt

Forked from rpms/libvirt 9 months ago
Clone
adeaf8
From c72361536b151a2b9bd839bd528671bafbd5dee2 Mon Sep 17 00:00:00 2001
2daa92
From: Cole Robinson <crobinso@redhat.com>
Daniel P. Berrange 11755d
Date: Fri, 30 Aug 2013 12:41:32 -0400
adeaf8
Subject: [PATCH] qemu: Fix specifying char devs for ARM
2daa92
2daa92
QEMU ARM boards don't give us any way to explicitly wire in
2daa92
a -chardev, so use the old style -serial options.
2daa92
2daa92
Unfortunately this isn't as simple as just turning off the CHARDEV flag
2daa92
for qemu-system-arm, as upcoming virtio support _will_ use device/chardev.
2daa92
---
2daa92
 src/qemu/qemu_capabilities.c | 18 ++++++++++++++++++
2daa92
 src/qemu/qemu_capabilities.h |  4 ++++
2daa92
 src/qemu/qemu_command.c      |  3 +--
2daa92
 src/qemu/qemu_process.c      | 37 ++++++++++++++++++++++---------------
2daa92
 4 files changed, 45 insertions(+), 17 deletions(-)
2daa92
2daa92
diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
Daniel P. Berrange 11755d
index 7888e2d..72df793 100644
2daa92
--- a/src/qemu/qemu_capabilities.c
2daa92
+++ b/src/qemu/qemu_capabilities.c
Daniel P. Berrange 11755d
@@ -2827,3 +2827,21 @@ virQEMUCapsUsedQMP(virQEMUCapsPtr qemuCaps)
2daa92
 {
2daa92
     return qemuCaps->usedQMP;
2daa92
 }
2daa92
+
2daa92
+bool
2daa92
+virQEMUCapsSupportsChardev(virDomainDefPtr def,
2daa92
+                           virQEMUCapsPtr qemuCaps,
2daa92
+                           virDomainChrDefPtr chr ATTRIBUTE_UNUSED)
2daa92
+{
2daa92
+    if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV) ||
2daa92
+        !virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE))
2daa92
+        return false;
2daa92
+
2daa92
+    /* This may not be true for all ARM machine types, but at least
2daa92
+     * the only supported serial devices of vexpress and versatile
2daa92
+     * don't have the -chardev property wired up. */
2daa92
+    if (def->os.arch != VIR_ARCH_ARMV7L)
2daa92
+        return false;
2daa92
+
2daa92
+    return true;
2daa92
+}
2daa92
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
Daniel P. Berrange 11755d
index 69f3395..5180ee9 100644
2daa92
--- a/src/qemu/qemu_capabilities.h
2daa92
+++ b/src/qemu/qemu_capabilities.h
Daniel P. Berrange 11755d
@@ -275,4 +275,8 @@ int virQEMUCapsParseDeviceStr(virQEMUCapsPtr qemuCaps, const char *str);
2daa92
 VIR_ENUM_DECL(virQEMUCaps);
2daa92
 
2daa92
 bool virQEMUCapsUsedQMP(virQEMUCapsPtr qemuCaps);
2daa92
+bool virQEMUCapsSupportsChardev(virDomainDefPtr def,
2daa92
+                                virQEMUCapsPtr qemuCaps,
2daa92
+                                virDomainChrDefPtr chr);
2daa92
+
2daa92
 #endif /* __QEMU_CAPABILITIES_H__*/
2daa92
diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c
Daniel P. Berrange 11755d
index 9dfdb73..a8e532c 100644
2daa92
--- a/src/qemu/qemu_command.c
2daa92
+++ b/src/qemu/qemu_command.c
Daniel P. Berrange 11755d
@@ -8493,8 +8493,7 @@ qemuBuildCommandLine(virConnectPtr conn,
2daa92
             char *devstr;
2daa92
 
2daa92
             /* Use -chardev with -device if they are available */
2daa92
-            if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV) &&
2daa92
-                virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE)) {
2daa92
+            if (virQEMUCapsSupportsChardev(def, qemuCaps, serial)) {
2daa92
                 virCommandAddArg(cmd, "-chardev");
2daa92
                 if (!(devstr = qemuBuildChrChardevStr(&serial->source,
2daa92
                                                       serial->info.alias,
2daa92
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
Daniel P. Berrange 11755d
index dfe8142..abe0060 100644
2daa92
--- a/src/qemu/qemu_process.c
2daa92
+++ b/src/qemu/qemu_process.c
Daniel P. Berrange 11755d
@@ -1604,22 +1604,25 @@ qemuProcessExtractTTYPath(const char *haystack,
2daa92
 }
2daa92
 
2daa92
 static int
2daa92
-qemuProcessLookupPTYs(virDomainChrDefPtr *devices,
2daa92
+qemuProcessLookupPTYs(virDomainDefPtr def,
2daa92
+                      virQEMUCapsPtr qemuCaps,
2daa92
+                      virDomainChrDefPtr *devices,
2daa92
                       int count,
2daa92
-                      virHashTablePtr paths,
2daa92
-                      bool chardevfmt)
2daa92
+                      virHashTablePtr paths)
2daa92
 {
2daa92
     size_t i;
2daa92
-    const char *prefix = chardevfmt ? "char" : "";
2daa92
 
2daa92
     for (i = 0; i < count; i++) {
2daa92
         virDomainChrDefPtr chr = devices[i];
2daa92
+        bool chardevfmt = virQEMUCapsSupportsChardev(def, qemuCaps, chr);
2daa92
+
2daa92
         if (chr->source.type == VIR_DOMAIN_CHR_TYPE_PTY) {
2daa92
             char id[32];
2daa92
             const char *path;
2daa92
 
2daa92
             if (snprintf(id, sizeof(id), "%s%s",
2daa92
-                         prefix, chr->info.alias) >= sizeof(id))
2daa92
+                         chardevfmt ? "char" : "",
2daa92
+                         chr->info.alias) >= sizeof(id))
2daa92
                 return -1;
2daa92
 
2daa92
             path = (const char *) virHashLookup(paths, id);
Daniel P. Berrange 11755d
@@ -1653,19 +1656,21 @@ qemuProcessFindCharDevicePTYsMonitor(virDomainObjPtr vm,
2daa92
                                      virQEMUCapsPtr qemuCaps,
2daa92
                                      virHashTablePtr paths)
2daa92
 {
2daa92
-    bool chardevfmt = virQEMUCapsGet(qemuCaps, QEMU_CAPS_CHARDEV);
2daa92
     size_t i = 0;
2daa92
 
2daa92
-    if (qemuProcessLookupPTYs(vm->def->serials, vm->def->nserials,
2daa92
-                              paths, chardevfmt) < 0)
2daa92
+    if (qemuProcessLookupPTYs(vm->def, qemuCaps,
2daa92
+                              vm->def->serials, vm->def->nserials,
2daa92
+                              paths) < 0)
2daa92
         return -1;
2daa92
 
2daa92
-    if (qemuProcessLookupPTYs(vm->def->parallels, vm->def->nparallels,
2daa92
-                              paths, chardevfmt) < 0)
2daa92
+    if (qemuProcessLookupPTYs(vm->def, qemuCaps,
2daa92
+                              vm->def->parallels, vm->def->nparallels,
2daa92
+                              paths) < 0)
2daa92
         return -1;
2daa92
 
2daa92
-    if (qemuProcessLookupPTYs(vm->def->channels, vm->def->nchannels,
2daa92
-                              paths, chardevfmt) < 0)
2daa92
+    if (qemuProcessLookupPTYs(vm->def, qemuCaps,
2daa92
+                              vm->def->channels, vm->def->nchannels,
2daa92
+                              paths) < 0)
2daa92
         return -1;
2daa92
     /* For historical reasons, console[0] can be just an alias
2daa92
      * for serial[0]. That's why we need to update it as well. */
Daniel P. Berrange 11755d
@@ -1683,8 +1688,9 @@ qemuProcessFindCharDevicePTYsMonitor(virDomainObjPtr vm,
2daa92
         }
2daa92
     }
2daa92
 
2daa92
-    if (qemuProcessLookupPTYs(vm->def->consoles + i, vm->def->nconsoles - i,
2daa92
-                              paths, chardevfmt) < 0)
2daa92
+    if (qemuProcessLookupPTYs(vm->def, qemuCaps,
2daa92
+                              vm->def->consoles + i, vm->def->nconsoles - i,
2daa92
+                              paths) < 0)
2daa92
         return -1;
2daa92
 
2daa92
     return 0;
Daniel P. Berrange 11755d
@@ -1774,7 +1780,8 @@ qemuProcessWaitForMonitor(virQEMUDriverPtr driver,
2daa92
     virHashTablePtr paths = NULL;
2daa92
     qemuDomainObjPrivatePtr priv;
2daa92
 
2daa92
-    if (!virQEMUCapsUsedQMP(qemuCaps) && pos != -1) {
2daa92
+    if (!virQEMUCapsUsedQMP(qemuCaps)
2daa92
+        && pos != -1) {
2daa92
         if ((logfd = qemuDomainOpenLog(driver, vm, pos)) < 0)
2daa92
             return -1;
2daa92