From nobody Mon Feb 9 03:48:24 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1550567158889410.25740701252903; Tue, 19 Feb 2019 01:05:58 -0800 (PST) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3619460B2; Tue, 19 Feb 2019 09:05:56 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6CC46600C8; Tue, 19 Feb 2019 09:05:55 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 260BC3FA4D; Tue, 19 Feb 2019 09:05:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x1J95GkC016199 for ; Tue, 19 Feb 2019 04:05:16 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7888C61080; Tue, 19 Feb 2019 09:05:16 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 260DB60BE8 for ; Tue, 19 Feb 2019 09:05:10 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 555D8100104; Tue, 19 Feb 2019 10:05:09 +0100 (CET) From: Jiri Denemark To: libvir-list@redhat.com Date: Tue, 19 Feb 2019 10:04:47 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 04/20] qemu_process: Refer to proc not cmd in process code X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Tue, 19 Feb 2019 09:05:57 +0000 (UTC) Content-Type: text/plain; charset="utf-8" From: Chris Venteicher s/cmd/proc/ in process code imported from qemu_capabilities. Signed-off-by: Chris Venteicher Reviewed-by: Jiri Denemark Signed-off-by: Jiri Denemark Reviewed-by: J=C3=A1n Tomko --- Notes: Version 7: - s/cmd/proc/ in qemuProcessQMPRun prototype src/qemu/qemu_capabilities.c | 18 ++--- src/qemu/qemu_process.c | 140 +++++++++++++++++------------------ src/qemu/qemu_process.h | 6 +- 3 files changed, 82 insertions(+), 82 deletions(-) diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index e7442ac010..aa6571457e 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -4361,39 +4361,39 @@ virQEMUCapsInitQMP(virQEMUCapsPtr qemuCaps, gid_t runGid, char **qmperr) { - qemuProcessQMPPtr cmd =3D NULL; + qemuProcessQMPPtr proc =3D NULL; int ret =3D -1; int rc; =20 - if (!(cmd =3D qemuProcessQMPNew(qemuCaps->binary, libDir, - runUid, runGid, qmperr))) + if (!(proc =3D qemuProcessQMPNew(qemuCaps->binary, libDir, + runUid, runGid, qmperr))) goto cleanup; =20 - if ((rc =3D qemuProcessQMPRun(cmd, false)) !=3D 0) { + if ((rc =3D qemuProcessQMPRun(proc, false)) !=3D 0) { if (rc =3D=3D 1) ret =3D 0; goto cleanup; } =20 - if (virQEMUCapsInitQMPMonitor(qemuCaps, cmd->mon) < 0) + if (virQEMUCapsInitQMPMonitor(qemuCaps, proc->mon) < 0) goto cleanup; =20 if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_KVM)) { - qemuProcessQMPAbort(cmd); - if ((rc =3D qemuProcessQMPRun(cmd, true)) !=3D 0) { + qemuProcessQMPAbort(proc); + if ((rc =3D qemuProcessQMPRun(proc, true)) !=3D 0) { if (rc =3D=3D 1) ret =3D 0; goto cleanup; } =20 - if (virQEMUCapsInitQMPMonitorTCG(qemuCaps, cmd->mon) < 0) + if (virQEMUCapsInitQMPMonitorTCG(qemuCaps, proc->mon) < 0) goto cleanup; } =20 ret =3D 0; =20 cleanup: - qemuProcessQMPFree(cmd); + qemuProcessQMPFree(proc); return ret; } =20 diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 6b698c0622..8e45dbc0ce 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8325,17 +8325,17 @@ static qemuMonitorCallbacks callbacks =3D { =20 =20 void -qemuProcessQMPFree(qemuProcessQMPPtr cmd) +qemuProcessQMPFree(qemuProcessQMPPtr proc) { - if (!cmd) + if (!proc) return; =20 - 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); } =20 =20 @@ -8346,25 +8346,25 @@ qemuProcessQMPNew(const char *binary, gid_t runGid, char **qmperr) { - qemuProcessQMPPtr cmd =3D NULL; + qemuProcessQMPPtr proc =3D NULL; =20 - if (VIR_ALLOC(cmd) < 0) + if (VIR_ALLOC(proc) < 0) goto error; =20 - if (VIR_STRDUP(cmd->binary, binary) < 0) + if (VIR_STRDUP(proc->binary, binary) < 0) goto error; =20 - cmd->runUid =3D runUid; - cmd->runGid =3D runGid; - cmd->qmperr =3D qmperr; + proc->runUid =3D runUid; + proc->runGid =3D runGid; + proc->qmperr =3D qmperr; =20 /* 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; =20 /* ".pidfile" suffix is used rather than ".pid" to avoid a possible cl= ash @@ -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; =20 - virPidFileForceCleanupPath(cmd->pidfile); + virPidFileForceCleanupPath(proc->pidfile); =20 - cmd->config.type =3D VIR_DOMAIN_CHR_TYPE_UNIX; - cmd->config.data.nix.path =3D cmd->monpath; - cmd->config.data.nix.listen =3D false; + proc->config.type =3D VIR_DOMAIN_CHR_TYPE_UNIX; + proc->config.data.nix.path =3D proc->monpath; + proc->config.data.nix.listen =3D false; =20 - return cmd; + return proc; =20 error: - qemuProcessQMPFree(cmd); + qemuProcessQMPFree(proc); return NULL; } =20 @@ -8395,7 +8395,7 @@ qemuProcessQMPNew(const char *binary, * 1 when probing QEMU failed */ int -qemuProcessQMPRun(qemuProcessQMPPtr cmd, +qemuProcessQMPRun(qemuProcessQMPPtr proc, bool forceTCG) { virDomainXMLOptionPtr xmlopt =3D NULL; @@ -8409,7 +8409,7 @@ qemuProcessQMPRun(qemuProcessQMPPtr cmd, machine =3D "none,accel=3Dkvm:tcg"; =20 VIR_DEBUG("Try to probe capabilities of '%s' via QMP, machine %s", - cmd->binary, machine); + proc->binary, machine); =20 /* * 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 =3D virCommandNewArgList(cmd->binary, - "-S", - "-no-user-config", - "-nodefaults", - "-nographic", - "-machine", machine, - "-qmp", cmd->monarg, - "-pidfile", cmd->pidfile, - "-daemonize", + proc->cmd =3D 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); =20 #if WITH_CAPNG /* QEMU might run into permission issues, e.g. /dev/sev (0600), overri= de * them just for the purpose of probing */ if (geteuid() =3D=3D 0) - virCommandAllowCap(cmd->cmd, CAP_DAC_OVERRIDE); + virCommandAllowCap(proc->cmd, CAP_DAC_OVERRIDE); #endif =20 - virCommandSetGID(cmd->cmd, cmd->runGid); - virCommandSetUID(cmd->cmd, cmd->runUid); + virCommandSetGID(proc->cmd, proc->runGid); + virCommandSetUID(proc->cmd, proc->runUid); =20 - virCommandSetErrorBuffer(cmd->cmd, cmd->qmperr); + virCommandSetErrorBuffer(proc->cmd, proc->qmperr); =20 /* Log, but otherwise ignore, non-zero status. */ - if (virCommandRun(cmd->cmd, &status) < 0) + if (virCommandRun(proc->cmd, &status) < 0) goto cleanup; =20 if (status !=3D 0) { VIR_DEBUG("QEMU %s exited with status %d: %s", - cmd->binary, status, *cmd->qmperr); + proc->binary, status, *proc->qmperr); goto ignore; } =20 - 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; } =20 if (!(xmlopt =3D virDomainXMLOptionNew(NULL, NULL, NULL, NULL, NULL)) = || - !(cmd->vm =3D virDomainObjNew(xmlopt))) + !(proc->vm =3D virDomainObjNew(xmlopt))) goto cleanup; =20 - cmd->vm->pid =3D cmd->pid; + proc->vm->pid =3D proc->pid; =20 - if (!(cmd->mon =3D qemuMonitorOpen(cmd->vm, &cmd->config, true, true, - 0, &callbacks, NULL))) + if (!(proc->mon =3D qemuMonitorOpen(proc->vm, &proc->config, true, tru= e, + 0, &callbacks, NULL))) goto ignore; =20 - virObjectLock(cmd->mon); + virObjectLock(proc->mon); =20 ret =3D 0; =20 cleanup: - if (!cmd->mon) - qemuProcessQMPAbort(cmd); + if (!proc->mon) + qemuProcessQMPAbort(proc); virObjectUnref(xmlopt); =20 return ret; @@ -8486,34 +8486,34 @@ qemuProcessQMPRun(qemuProcessQMPPtr cmd, =20 =20 void -qemuProcessQMPAbort(qemuProcessQMPPtr cmd) +qemuProcessQMPAbort(qemuProcessQMPPtr proc) { - if (cmd->mon) - virObjectUnlock(cmd->mon); - qemuMonitorClose(cmd->mon); - cmd->mon =3D NULL; + if (proc->mon) + virObjectUnlock(proc->mon); + qemuMonitorClose(proc->mon); + proc->mon =3D NULL; =20 - virCommandAbort(cmd->cmd); - virCommandFree(cmd->cmd); - cmd->cmd =3D NULL; + virCommandAbort(proc->cmd); + virCommandFree(proc->cmd); + proc->cmd =3D NULL; =20 - if (cmd->monpath) - unlink(cmd->monpath); + if (proc->monpath) + unlink(proc->monpath); =20 - virDomainObjEndAPI(&cmd->vm); + virDomainObjEndAPI(&proc->vm); =20 - if (cmd->pid !=3D 0) { + if (proc->pid !=3D 0) { char ebuf[1024]; =20 - VIR_DEBUG("Killing QMP caps process %lld", (long long)cmd->pid); - if (virProcessKill(cmd->pid, SIGKILL) < 0 && errno !=3D ESRCH) + VIR_DEBUG("Killing QMP caps process %lld", (long long)proc->pid); + if (virProcessKill(proc->pid, SIGKILL) < 0 && errno !=3D ESRCH) VIR_ERROR(_("Failed to kill process %lld: %s"), - (long long)cmd->pid, + (long long)proc->pid, virStrerror(errno, ebuf, sizeof(ebuf))); =20 - VIR_FREE(*cmd->qmperr); + VIR_FREE(*proc->qmperr); } - if (cmd->pidfile) - unlink(cmd->pidfile); - cmd->pid =3D 0; + if (proc->pidfile) + unlink(proc->pidfile); + proc->pid =3D 0; } diff --git a/src/qemu/qemu_process.h b/src/qemu/qemu_process.h index fe79873967..a480d006f9 100644 --- a/src/qemu/qemu_process.h +++ b/src/qemu/qemu_process.h @@ -237,11 +237,11 @@ qemuProcessQMPPtr qemuProcessQMPNew(const char *binar= y, gid_t runGid, char **qmperr); =20 -void qemuProcessQMPFree(qemuProcessQMPPtr cmd); +void qemuProcessQMPFree(qemuProcessQMPPtr proc); =20 -int qemuProcessQMPRun(qemuProcessQMPPtr cmd, +int qemuProcessQMPRun(qemuProcessQMPPtr proc, bool forceTCG); =20 -void qemuProcessQMPAbort(qemuProcessQMPPtr cmd); +void qemuProcessQMPAbort(qemuProcessQMPPtr proc); =20 #endif /* LIBVIRT_QEMU_PROCESS_H */ --=20 2.20.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list