[PATCH] qemu: Don't parse log output when starting up a domain

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Despite our great effort we still parsed qemu log output.
We wouldn't notice unless qemu changed the format of the
logs slightly. Anyway, now we should gather all interesting
knobs like pty paths from monitor. Moreover, since for
historical reasons the first console can be just an alias to
the first serial port, we need to check this and copy the
pty path if that's the case to the first console.
---
 src/qemu/qemu_capabilities.c |  7 +++++++
 src/qemu/qemu_capabilities.h |  1 +
 src/qemu/qemu_process.c      | 20 ++++++++++++++++++--
 3 files changed, 26 insertions(+), 2 deletions(-)

diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c
index 17e6679..f49a31c 100644
--- a/src/qemu/qemu_capabilities.c
+++ b/src/qemu/qemu_capabilities.c
@@ -1695,6 +1695,7 @@ qemuCapsPtr qemuCapsNewCopy(qemuCapsPtr caps)
 
     virBitmapCopy(ret->flags, caps->flags);
 
+    ret->usedQMP = caps->usedQMP;
     ret->version = caps->version;
     ret->kvmVersion = caps->kvmVersion;
     ret->arch = caps->arch;
@@ -2633,3 +2634,9 @@ qemuCapsCacheFree(qemuCapsCachePtr cache)
     virMutexDestroy(&cache->lock);
     VIR_FREE(cache);
 }
+
+bool
+qemuCapsUsedQMP(qemuCapsPtr caps)
+{
+    return caps->usedQMP;
+}
diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h
index 3457852..1417d7f 100644
--- a/src/qemu/qemu_capabilities.h
+++ b/src/qemu/qemu_capabilities.h
@@ -241,4 +241,5 @@ int qemuCapsParseDeviceStr(qemuCapsPtr caps, const char *str);
 
 VIR_ENUM_DECL(qemuCaps);
 
+bool qemuCapsUsedQMP(qemuCapsPtr caps);
 #endif /* __QEMU_CAPABILITIES_H__*/
diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
index eac6553..ff88192 100644
--- a/src/qemu/qemu_process.c
+++ b/src/qemu/qemu_process.c
@@ -1532,6 +1532,7 @@ qemuProcessFindCharDevicePTYsMonitor(virDomainObjPtr vm,
                                      virHashTablePtr paths)
 {
     bool chardevfmt = qemuCapsGet(caps, QEMU_CAPS_CHARDEV);
+    int i = 0;
 
     if (qemuProcessLookupPTYs(vm->def->serials, vm->def->nserials,
                               paths, chardevfmt) < 0)
@@ -1544,8 +1545,23 @@ qemuProcessFindCharDevicePTYsMonitor(virDomainObjPtr vm,
     if (qemuProcessLookupPTYs(vm->def->channels, vm->def->nchannels,
                               paths, chardevfmt) < 0)
         return -1;
+    /* For historical reasons, console[0] can be just an alias
+     * for serial[0]; That's why we need to update it as well */
+    if (vm->def->nconsoles) {
+        virDomainChrDefPtr chr = vm->def->consoles[0];
+
+        if (vm->def->nserials &&
+            chr->deviceType == VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE &&
+            chr->targetType == VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL) {
+            /* yes, the first console is just an alias for serials[0] */
+            i = 1;
+            if (virDomainChrSourceDefCopy(&chr->source,
+                                          &((vm->def->serials[0])->source)) < 0)
+                return -1;
+        }
+    }
 
-    if (qemuProcessLookupPTYs(vm->def->consoles, vm->def->nconsoles,
+    if (qemuProcessLookupPTYs(vm->def->consoles + i, vm->def->nconsoles - i,
                               paths, chardevfmt) < 0)
         return -1;
 
@@ -1650,7 +1666,7 @@ qemuProcessWaitForMonitor(virQEMUDriverPtr driver,
     virHashTablePtr paths = NULL;
     qemuDomainObjPrivatePtr priv;
 
-    if (pos != -1) {
+    if (!qemuCapsUsedQMP(caps) && pos != -1) {
         if ((logfd = qemuDomainOpenLog(driver, vm, pos)) < 0)
             return -1;
 
-- 
1.8.0.2

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


[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]