qemu_process: Refer to proc not cmd in process code

s/cmd/proc/ in process code imported from qemu_capabilities.

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:
Chris Venteicher 2019-01-12 18:50:03 -06:00 committed by Jiri Denemark
parent 1aa4257569
commit 3dcdd18b6b
3 changed files with 82 additions and 82 deletions

View File

@ -4361,39 +4361,39 @@ virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps,
gid_t runGid,
char **qmperr)
{
qemuProcessQMPPtr cmd = NULL;
qemuProcessQMPPtr proc = NULL;
int ret = -1;
int rc;
if (!(cmd = qemuProcessQMPNew(qemuCaps->binary, libDir,
runUid, runGid, qmperr)))
if (!(proc = qemuProcessQMPNew(qemuCaps->binary, libDir,
runUid, runGid, qmperr)))
goto cleanup;
if ((rc = qemuProcessQMPRun(cmd, false)) != 0) {
if ((rc = qemuProcessQMPRun(proc, false)) != 0) {
if (rc == 1)
ret = 0;
goto cleanup;
}
if (virQEMUCapsInitQMPMonitor(qemuCaps, cmd->mon) < 0)
if (virQEMUCapsInitQMPMonitor(qemuCaps, proc->mon) < 0)
goto cleanup;
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) {
qemuProcessQMPAbort(cmd);
if ((rc = qemuProcessQMPRun(cmd, true)) != 0) {
qemuProcessQMPAbort(proc);
if ((rc = qemuProcessQMPRun(proc, true)) != 0) {
if (rc == 1)
ret = 0;
goto cleanup;
}
if (virQEMUCapsInitQMPMonitorTCG(qemuCaps, cmd->mon) < 0)
if (virQEMUCapsInitQMPMonitorTCG(qemuCaps, proc->mon) < 0)
goto cleanup;
}
ret = 0;
cleanup:
qemuProcessQMPFree(cmd);
qemuProcessQMPFree(proc);
return ret;
}

View File

@ -8325,17 +8325,17 @@ static qemuMonitorCallbacks callbacks = {
void
qemuProcessQMPFree(qemuProcessQMPPtr cmd)
qemuProcessQMPFree(qemuProcessQMPPtr proc)
{
if (!cmd)
if (!proc)
return;
qemuProcessQMPAbort(cmd);
VIR_FREE(cmd->binary);
VIR_FREE(cmd->monpath);
VIR_FREE(cmd->monarg);
VIR_FREE(cmd->pidfile);
VIR_FREE(cmd);
qemuProcessQMPAbort(proc);
VIR_FREE(proc->binary);
VIR_FREE(proc->monpath);
VIR_FREE(proc->monarg);
VIR_FREE(proc->pidfile);
VIR_FREE(proc);
}
@ -8346,25 +8346,25 @@ qemuProcessQMPNew(const char *binary,
gid_t runGid,
char **qmperr)
{
qemuProcessQMPPtr cmd = NULL;
qemuProcessQMPPtr proc = NULL;
if (VIR_ALLOC(cmd) < 0)
if (VIR_ALLOC(proc) < 0)
goto error;
if (VIR_STRDUP(cmd->binary, binary) < 0)
if (VIR_STRDUP(proc->binary, binary) < 0)
goto error;
cmd->runUid = runUid;
cmd->runGid = runGid;
cmd->qmperr = qmperr;
proc->runUid = runUid;
proc->runGid = runGid;
proc->qmperr = qmperr;
/* the ".sock" sufix is important to avoid a possible clash with a qemu
* domain called "capabilities"
*/
if (virAsprintf(&cmd->monpath, "%s/%s", libDir,
if (virAsprintf(&proc->monpath, "%s/%s", libDir,
"capabilities.monitor.sock") < 0)
goto error;
if (virAsprintf(&cmd->monarg, "unix:%s,server,nowait", cmd->monpath) < 0)
if (virAsprintf(&proc->monarg, "unix:%s,server,nowait", proc->monpath) < 0)
goto error;
/* ".pidfile" suffix is used rather than ".pid" to avoid a possible clash
@ -8373,19 +8373,19 @@ qemuProcessQMPNew(const char *binary,
* -daemonize we need QEMU to be allowed to create them, rather
* than libvirtd. So we're using libDir which QEMU can write to
*/
if (virAsprintf(&cmd->pidfile, "%s/%s", libDir, "capabilities.pidfile") < 0)
if (virAsprintf(&proc->pidfile, "%s/%s", libDir, "capabilities.pidfile") < 0)
goto error;
virPidFileForceCleanupPath(cmd->pidfile);
virPidFileForceCleanupPath(proc->pidfile);
cmd->config.type = VIR_DOMAIN_CHR_TYPE_UNIX;
cmd->config.data.nix.path = cmd->monpath;
cmd->config.data.nix.listen = false;
proc->config.type = VIR_DOMAIN_CHR_TYPE_UNIX;
proc->config.data.nix.path = proc->monpath;
proc->config.data.nix.listen = false;
return cmd;
return proc;
error:
qemuProcessQMPFree(cmd);
qemuProcessQMPFree(proc);
return NULL;
}
@ -8395,7 +8395,7 @@ qemuProcessQMPNew(const char *binary,
* 1 when probing QEMU failed
*/
int
qemuProcessQMPRun(qemuProcessQMPPtr cmd,
qemuProcessQMPRun(qemuProcessQMPPtr proc,
bool forceTCG)
{
virDomainXMLOptionPtr xmlopt = NULL;
@ -8409,7 +8409,7 @@ qemuProcessQMPRun(qemuProcessQMPPtr cmd,
machine = "none,accel=kvm:tcg";
VIR_DEBUG("Try to probe capabilities of '%s' via QMP, machine %s",
cmd->binary, machine);
proc->binary, machine);
/*
* We explicitly need to use -daemonize here, rather than
@ -8418,63 +8418,63 @@ qemuProcessQMPRun(qemuProcessQMPPtr cmd,
* daemonize guarantees control won't return to libvirt
* until the socket is present.
*/
cmd->cmd = virCommandNewArgList(cmd->binary,
"-S",
"-no-user-config",
"-nodefaults",
"-nographic",
"-machine", machine,
"-qmp", cmd->monarg,
"-pidfile", cmd->pidfile,
"-daemonize",
proc->cmd = virCommandNewArgList(proc->binary,
"-S",
"-no-user-config",
"-nodefaults",
"-nographic",
"-machine", machine,
"-qmp", proc->monarg,
"-pidfile", proc->pidfile,
"-daemonize",
NULL);
virCommandAddEnvPassCommon(cmd->cmd);
virCommandClearCaps(cmd->cmd);
virCommandAddEnvPassCommon(proc->cmd);
virCommandClearCaps(proc->cmd);
#if WITH_CAPNG
/* QEMU might run into permission issues, e.g. /dev/sev (0600), override
* them just for the purpose of probing */
if (geteuid() == 0)
virCommandAllowCap(cmd->cmd, CAP_DAC_OVERRIDE);
virCommandAllowCap(proc->cmd, CAP_DAC_OVERRIDE);
#endif
virCommandSetGID(cmd->cmd, cmd->runGid);
virCommandSetUID(cmd->cmd, cmd->runUid);
virCommandSetGID(proc->cmd, proc->runGid);
virCommandSetUID(proc->cmd, proc->runUid);
virCommandSetErrorBuffer(cmd->cmd, cmd->qmperr);
virCommandSetErrorBuffer(proc->cmd, proc->qmperr);
/* Log, but otherwise ignore, non-zero status. */
if (virCommandRun(cmd->cmd, &status) < 0)
if (virCommandRun(proc->cmd, &status) < 0)
goto cleanup;
if (status != 0) {
VIR_DEBUG("QEMU %s exited with status %d: %s",
cmd->binary, status, *cmd->qmperr);
proc->binary, status, *proc->qmperr);
goto ignore;
}
if (virPidFileReadPath(cmd->pidfile, &cmd->pid) < 0) {
VIR_DEBUG("Failed to read pidfile %s", cmd->pidfile);
if (virPidFileReadPath(proc->pidfile, &proc->pid) < 0) {
VIR_DEBUG("Failed to read pidfile %s", proc->pidfile);
goto ignore;
}
if (!(xmlopt = virDomainXMLOptionNew(NULL, NULL, NULL, NULL, NULL)) ||
!(cmd->vm = virDomainObjNew(xmlopt)))
!(proc->vm = virDomainObjNew(xmlopt)))
goto cleanup;
cmd->vm->pid = cmd->pid;
proc->vm->pid = proc->pid;
if (!(cmd->mon = qemuMonitorOpen(cmd->vm, &cmd->config, true, true,
0, &callbacks, NULL)))
if (!(proc->mon = qemuMonitorOpen(proc->vm, &proc->config, true, true,
0, &callbacks, NULL)))
goto ignore;
virObjectLock(cmd->mon);
virObjectLock(proc->mon);
ret = 0;
cleanup:
if (!cmd->mon)
qemuProcessQMPAbort(cmd);
if (!proc->mon)
qemuProcessQMPAbort(proc);
virObjectUnref(xmlopt);
return ret;
@ -8486,34 +8486,34 @@ qemuProcessQMPRun(qemuProcessQMPPtr cmd,
void
qemuProcessQMPAbort(qemuProcessQMPPtr cmd)
qemuProcessQMPAbort(qemuProcessQMPPtr proc)
{
if (cmd->mon)
virObjectUnlock(cmd->mon);
qemuMonitorClose(cmd->mon);
cmd->mon = NULL;
if (proc->mon)
virObjectUnlock(proc->mon);
qemuMonitorClose(proc->mon);
proc->mon = NULL;
virCommandAbort(cmd->cmd);
virCommandFree(cmd->cmd);
cmd->cmd = NULL;
virCommandAbort(proc->cmd);
virCommandFree(proc->cmd);
proc->cmd = NULL;
if (cmd->monpath)
unlink(cmd->monpath);
if (proc->monpath)
unlink(proc->monpath);
virDomainObjEndAPI(&cmd->vm);
virDomainObjEndAPI(&proc->vm);
if (cmd->pid != 0) {
if (proc->pid != 0) {
char ebuf[1024];
VIR_DEBUG("Killing QMP caps process %lld", (long long)cmd->pid);
if (virProcessKill(cmd->pid, SIGKILL) < 0 && errno != ESRCH)
VIR_DEBUG("Killing QMP caps process %lld", (long long)proc->pid);
if (virProcessKill(proc->pid, SIGKILL) < 0 && errno != ESRCH)
VIR_ERROR(_("Failed to kill process %lld: %s"),
(long long)cmd->pid,
(long long)proc->pid,
virStrerror(errno, ebuf, sizeof(ebuf)));
VIR_FREE(*cmd->qmperr);
VIR_FREE(*proc->qmperr);
}
if (cmd->pidfile)
unlink(cmd->pidfile);
cmd->pid = 0;
if (proc->pidfile)
unlink(proc->pidfile);
proc->pid = 0;
}

View File

@ -237,11 +237,11 @@ qemuProcessQMPPtr qemuProcessQMPNew(const char *binary,
gid_t runGid,
char **qmperr);
void qemuProcessQMPFree(qemuProcessQMPPtr cmd);
void qemuProcessQMPFree(qemuProcessQMPPtr proc);
int qemuProcessQMPRun(qemuProcessQMPPtr cmd,
int qemuProcessQMPRun(qemuProcessQMPPtr proc,
bool forceTCG);
void qemuProcessQMPAbort(qemuProcessQMPPtr cmd);
void qemuProcessQMPAbort(qemuProcessQMPPtr proc);
#endif /* LIBVIRT_QEMU_PROCESS_H */