From nobody Sun Feb 8 17:47:05 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1676887272; cv=none; d=zohomail.com; s=zohoarc; b=MBQsyLam8PH5BvWtaJTbEVwyx3Gz5h47+riILBqRWTsdJsc8CZacQbkTUfpGnhUrU4UiS7iTokktkJyK3I/zPfhp76hO4rxAyUUeHQyjkqRVA6FPH16OR+vBLtmyYLF3/OuFRd0SxyUjI2B0n//Bm+TYFKGuBSuPMx9hOdX6eIo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676887272; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=mohsTRlP5fU0Wkoy+7spWovusFdb+LLaQRzs41mHXMM=; b=V8RFzpyPfDI3Io5L6OFAGZts9SbUk8zY3Slm5dtGzK06C0lGTDZ8D004R+P6WQ+axIDYCeec3heVEREz6kzugrBwPCfwDaQZNadaT1YJ3kiAnpEfPbSskmubS4Ov3IRoV8mI4qtRltP9W+h/fbj2gHm2yx663QTo0OyS6ZZUEpA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1676887272456967.7374097991454; Mon, 20 Feb 2023 02:01:12 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-297-UgY2nmIcOny7NTr_sNNhzA-1; Mon, 20 Feb 2023 05:01:09 -0500 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 3F28B802D32; Mon, 20 Feb 2023 10:01:04 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2B054492B00; Mon, 20 Feb 2023 10:01:04 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 112101946588; Mon, 20 Feb 2023 10:01:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8D2931946588 for ; Mon, 20 Feb 2023 10:01:02 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 71C7F1415113; Mon, 20 Feb 2023 10:01:02 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 18A33140EBF6 for ; Mon, 20 Feb 2023 10:01:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676887271; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=mohsTRlP5fU0Wkoy+7spWovusFdb+LLaQRzs41mHXMM=; b=ePpLzw62Qxs7VY14cGNAEJgBXb1c6sXZsWUYGvuhaxQg9cPNpd5tdy/FBESLPPSKCF1y5f 9SixblFnsgjJGyGGMUqqRlDfrPo906dsOP/CUAI+4/AIhDufJhsMIZIPPgk7yQ1SH8b4pV gfC3C/SFoM4QqJtte+uFz0T5C7hHHlw= X-MC-Unique: UgY2nmIcOny7NTr_sNNhzA-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 4/4] qemu: Let virCommand module translate exitstatus Date: Mon, 20 Feb 2023 11:00:58 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.10 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1676887273841100007 Content-Type: text/plain; charset="utf-8"; x-default="true" When starting (some) external helpers, callers of qemuSecurityCommandRun() pass &exitstatus variable, to learn the exit code of helper process (with qemuTPMEmulatorStart() being the only exception). Then, if the status wasn't zero they produce a generic error message, like: "Starting of helper process failed. exitstatus=3D%d" or, in case of qemuPasstStart(): "Could not start 'passt': %s" This is needless as virCommandRun() (that's called under the hood), can do both for us, if NULL was passed instead of @exitstatus. Not only it appends exit status, it also reads stderr of failed command producing comprehensive error message: Child process (${args}) unexpected exit status ${exitstatus}: ${stderr} Therefore, pass NULL everywhere. But in contrast with one of previous commits which removed @cmdret argument, there could be a sensible caller which might want to process exit code. So keep the argument for now and just pass NULL. Signed-off-by: Michal Privoznik --- src/qemu/qemu_dbus.c | 9 +-------- src/qemu/qemu_passt.c | 11 +---------- src/qemu/qemu_security.c | 2 +- src/qemu/qemu_slirp.c | 9 +-------- src/qemu/qemu_vhost_user_gpu.c | 9 +-------- 5 files changed, 5 insertions(+), 35 deletions(-) diff --git a/src/qemu/qemu_dbus.c b/src/qemu/qemu_dbus.c index 74cb5457ea..a6dc802637 100644 --- a/src/qemu/qemu_dbus.c +++ b/src/qemu/qemu_dbus.c @@ -182,7 +182,6 @@ qemuDBusStart(virQEMUDriver *driver, virTimeBackOffVar timebackoff; const unsigned long long timeout =3D 500 * 1000; /* ms */ VIR_AUTOCLOSE errfd =3D -1; - int exitstatus =3D 0; pid_t cpid =3D -1; int ret =3D -1; =20 @@ -218,15 +217,9 @@ qemuDBusStart(virQEMUDriver *driver, virCommandDaemonize(cmd); virCommandAddArgFormat(cmd, "--config-file=3D%s", configfile); =20 - if (qemuSecurityCommandRun(driver, vm, cmd, -1, -1, &exitstatus) < 0) + if (qemuSecurityCommandRun(driver, vm, cmd, -1, -1, NULL) < 0) goto cleanup; =20 - if (exitstatus !=3D 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not start dbus-daemon. exitstatus: %d"), e= xitstatus); - goto cleanup; - } - if (virPidFileReadPath(pidfile, &cpid) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("dbus-daemon %s didn't show up"), diff --git a/src/qemu/qemu_passt.c b/src/qemu/qemu_passt.c index 81b7917026..9eb8cb9834 100644 --- a/src/qemu/qemu_passt.c +++ b/src/qemu/qemu_passt.c @@ -155,15 +155,12 @@ qemuPasstStart(virDomainObj *vm, g_autofree char *passtSocketName =3D qemuPasstCreateSocketPath(vm, net= ); g_autoptr(virCommand) cmd =3D NULL; g_autofree char *pidfile =3D qemuPasstCreatePidFilename(vm, net); - g_autofree char *errbuf =3D NULL; char macaddr[VIR_MAC_STRING_BUFLEN]; size_t i; - int exitstatus =3D 0; =20 cmd =3D virCommandNew(PASST); =20 virCommandClearCaps(cmd); - virCommandSetErrorBuffer(cmd, &errbuf); =20 virCommandAddArgList(cmd, "--one-off", @@ -270,15 +267,9 @@ qemuPasstStart(virDomainObj *vm, if (qemuExtDeviceLogCommand(driver, vm, cmd, "passt") < 0) return -1; =20 - if (qemuSecurityCommandRun(driver, vm, cmd, -1, -1, &exitstatus) < 0) + if (qemuSecurityCommandRun(driver, vm, cmd, -1, -1, NULL) < 0) goto error; =20 - if (exitstatus !=3D 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not start 'passt': %s"), NULLSTR(errbuf)); - goto error; - } - return 0; =20 error: diff --git a/src/qemu/qemu_security.c b/src/qemu/qemu_security.c index 07fcffb288..ee03e2225e 100644 --- a/src/qemu/qemu_security.c +++ b/src/qemu/qemu_security.c @@ -622,7 +622,7 @@ qemuSecurityDomainRestorePathLabel(virQEMUDriver *drive= r, * @cmd: the command to run * @uid: the uid to force * @gid: the gid to force - * @existstatus: pointer to int returning exit status of process + * @existstatus: optional pointer to int returning exit status of process * * Run @cmd with seclabels set on it. If @uid and/or @gid are not * -1 then their value is enforced. diff --git a/src/qemu/qemu_slirp.c b/src/qemu/qemu_slirp.c index bbe919f37a..9697542cd3 100644 --- a/src/qemu/qemu_slirp.c +++ b/src/qemu/qemu_slirp.c @@ -247,7 +247,6 @@ qemuSlirpStart(virDomainObj *vm, size_t i; pid_t pid =3D (pid_t) -1; int rc; - int exitstatus =3D 0; bool killDBusDaemon =3D false; g_autofree char *fdname =3D g_strdup_printf("slirpfd-%s", net->info.al= ias); =20 @@ -326,15 +325,9 @@ qemuSlirpStart(virDomainObj *vm, if (qemuExtDeviceLogCommand(driver, vm, cmd, "slirp") < 0) goto error; =20 - if (qemuSecurityCommandRun(driver, vm, cmd, -1, -1, &exitstatus) < 0) + if (qemuSecurityCommandRun(driver, vm, cmd, -1, -1, NULL) < 0) goto error; =20 - if (exitstatus !=3D 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not start 'slirp'. exitstatus: %d"), exits= tatus); - goto error; - } - rc =3D virPidFileReadPath(pidfile, &pid); if (rc < 0) { virReportSystemError(-rc, diff --git a/src/qemu/qemu_vhost_user_gpu.c b/src/qemu/qemu_vhost_user_gpu.c index 196ebc7dff..5b49ef4e28 100644 --- a/src/qemu/qemu_vhost_user_gpu.c +++ b/src/qemu/qemu_vhost_user_gpu.c @@ -106,7 +106,6 @@ int qemuExtVhostUserGPUStart(virQEMUDriver *driver, g_autoptr(virCommand) cmd =3D NULL; int pair[2] =3D { -1, -1 }; int rc; - int exitstatus =3D 0; pid_t pid; int ret =3D -1; =20 @@ -153,15 +152,9 @@ int qemuExtVhostUserGPUStart(virQEMUDriver *driver, virCommandAddArgFormat(cmd, "--render-node=3D%s", video->accel= ->rendernode); } =20 - if (qemuSecurityCommandRun(driver, vm, cmd, -1, -1, &exitstatus) < 0) + if (qemuSecurityCommandRun(driver, vm, cmd, -1, -1, NULL) < 0) goto error; =20 - if (exitstatus !=3D 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not start 'vhost-user-gpu'. exitstatus: %d= "), exitstatus); - goto cleanup; - } - rc =3D virPidFileReadPath(pidfile, &pid); if (rc < 0) { virReportSystemError(-rc, --=20 2.39.2