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

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.
This commit is contained in:
Michal Privoznik 2013-01-02 15:36:33 +01:00
parent 83aca30f1e
commit b3f2b4ca5c
3 changed files with 26 additions and 2 deletions

View 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;
}

View File

@ -241,4 +241,5 @@ int qemuCapsParseDeviceStr(qemuCapsPtr caps, const char *str);
VIR_ENUM_DECL(qemuCaps);
bool qemuCapsUsedQMP(qemuCapsPtr caps);
#endif /* __QEMU_CAPABILITIES_H__*/

View 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 (qemuProcessLookupPTYs(vm->def->consoles, vm->def->nconsoles,
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 + 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;