]> git.ipfire.org Git - thirdparty/libvirt.git/commitdiff
qemu: Don't parse log output when starting up a domain
authorMichal Privoznik <mprivozn@redhat.com>
Wed, 2 Jan 2013 14:36:33 +0000 (15:36 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Thu, 3 Jan 2013 08:56:51 +0000 (09:56 +0100)
Despite our great effort we still parsed qemu log output.
We wouldn't notice unless upcoming qemu 1.4 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
src/qemu/qemu_capabilities.h
src/qemu/qemu_process.c

index 17e667981d2b9cd89ee6433fbd275f7f2cdf8951..f49a31c8e7d60d26f46c2691e8d140046fb8c5fd 100644 (file)
@@ -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;
+}
index 3457852ddcd3dabaf358ccb1ca5cab81385cb5a4..1417d7fe83b6b0512d1c30b763cac79a88ed03bf 100644 (file)
@@ -241,4 +241,5 @@ int qemuCapsParseDeviceStr(qemuCapsPtr caps, const char *str);
 
 VIR_ENUM_DECL(qemuCaps);
 
+bool qemuCapsUsedQMP(qemuCapsPtr caps);
 #endif /* __QEMU_CAPABILITIES_H__*/
index eac6553bc872d14b90c149cc269092aaeb1865a5..358757b3b86a6d635cca87bbda675c4c3a7df3f8 100644 (file)
@@ -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;