提交 0e127076 编写于 作者: C Chris Venteicher 提交者: Jiri Denemark

qemu_process: Use qemuProcessQMP struct for a single process

In new process code, move from model where qemuProcessQMP struct can be
used to activate a series of Qemu processes to model where one
qemuProcessQMP struct is used for one and only one Qemu process.

By allowing only one process activation per qemuProcessQMP struct, the
struct can safely store process outputs like status and stderr, without
being overwritten, until qemuProcessQMPFree is called.

By doing this, process outputs like status and stderr can remain stored
in the qemuProcessQMP struct without being overwritten by subsequent
process activations.

The forceTCG parameter (use / don't use KVM) will be passed when the
qemuProcessQMP struct is initialized since the qemuProcessQMP struct
won't be reused.
Signed-off-by: NChris Venteicher <cventeic@redhat.com>
Reviewed-by: NJiri Denemark <jdenemar@redhat.com>
Reviewed-by: NJán Tomko <jtomko@redhat.com>
上级 bfff7473
......@@ -4362,14 +4362,15 @@ virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps,
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;
......@@ -4379,14 +4380,22 @@ virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps,
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;
}
......@@ -4394,7 +4403,9 @@ virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps,
cleanup:
qemuProcessQMPStop(proc);
qemuProcessQMPStop(procTCG);
qemuProcessQMPFree(proc);
qemuProcessQMPFree(procTCG);
return ret;
}
......
......@@ -8344,7 +8344,8 @@ qemuProcessQMPNew(const char *binary,
const char *libDir,
uid_t runUid,
gid_t runGid,
char **qmperr)
char **qmperr,
bool forceTCG)
{
qemuProcessQMPPtr proc = NULL;
......@@ -8357,6 +8358,7 @@ qemuProcessQMPNew(const char *binary,
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"
......@@ -8395,15 +8397,14 @@ qemuProcessQMPNew(const char *binary,
* 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";
......
......@@ -229,18 +229,19 @@ struct _qemuProcessQMP {
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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册