mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-11 07:17:44 +00:00
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: Chris Venteicher <cventeic@redhat.com> Reviewed-by: Jiri Denemark <jdenemar@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com>
This commit is contained in:
parent
bfff747313
commit
0e12707680
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user