char **qmperr)
{
qemuProcessQMPPtr proc = NULL;
+ qemuProcessQMPPtr procTCG = NULL;
int ret = -1;
int rc;
if (!(proc = qemuProcessQMPNew(qemuCaps->binary, libDir,
- runUid, runGid, qmperr)))
+ runUid, runGid, qmperr, false)))
goto cleanup;
- if ((rc = qemuProcessQMPRun(proc, false)) != 0) {
+ if ((rc = qemuProcessQMPRun(proc)) != 0) {
if (rc == 1)
ret = 0;
goto cleanup;
goto cleanup;
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) {
+ /* The second QEMU process probes for TCG capabilities
+ * in case the first process reported KVM as enabled
+ * (otherwise the first one already reported TCG capabilities). */
+
qemuProcessQMPStop(proc);
- if ((rc = qemuProcessQMPRun(proc, true)) != 0) {
+
+ procTCG = qemuProcessQMPNew(qemuCaps->binary, libDir,
+ runUid, runGid, NULL, true);
+
+ if ((rc = qemuProcessQMPRun(procTCG)) != 0) {
if (rc == 1)
ret = 0;
goto cleanup;
}
- if (virQEMUCapsInitQMPMonitorTCG(qemuCaps, proc->mon) < 0)
+ if (virQEMUCapsInitQMPMonitorTCG(qemuCaps, procTCG->mon) < 0)
goto cleanup;
}
cleanup:
qemuProcessQMPStop(proc);
+ qemuProcessQMPStop(procTCG);
qemuProcessQMPFree(proc);
+ qemuProcessQMPFree(procTCG);
return ret;
}
const char *libDir,
uid_t runUid,
gid_t runGid,
- char **qmperr)
+ char **qmperr,
+ bool forceTCG)
{
qemuProcessQMPPtr proc = NULL;
proc->runUid = runUid;
proc->runGid = runGid;
proc->qmperr = qmperr;
+ proc->forceTCG = forceTCG;
/* the ".sock" sufix is important to avoid a possible clash with a qemu
* domain called "capabilities"
* 1 when probing QEMU failed
*/
int
-qemuProcessQMPRun(qemuProcessQMPPtr proc,
- bool forceTCG)
+qemuProcessQMPRun(qemuProcessQMPPtr proc)
{
virDomainXMLOptionPtr xmlopt = NULL;
const char *machine;
int status = 0;
int ret = -1;
- if (forceTCG)
+ if (proc->forceTCG)
machine = "none,accel=tcg";
else
machine = "none,accel=kvm:tcg";
virDomainChrSourceDef config;
pid_t pid;
virDomainObjPtr vm;
+ bool forceTCG;
};
qemuProcessQMPPtr qemuProcessQMPNew(const char *binary,
const char *libDir,
uid_t runUid,
gid_t runGid,
- char **qmperr);
+ char **qmperr,
+ bool forceTCG);
void qemuProcessQMPFree(qemuProcessQMPPtr proc);
-int qemuProcessQMPRun(qemuProcessQMPPtr proc,
- bool forceTCG);
+int qemuProcessQMPRun(qemuProcessQMPPtr proc);
void qemuProcessQMPStop(qemuProcessQMPPtr proc);