From nobody Mon Feb 9 00:07:30 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=1676887270; cv=none; d=zohomail.com; s=zohoarc; b=bzORhuQkee+BA/lS41Yi0SEKRZrBaGDIcQ0ggLJ/Je+GcueR6Z1Fq8GgYPUI5hPjLqZyXBZHGbUO5YCOwv6WLkjhErdG7AZAy/qjfSmXoqu2IQ0RqbYCCZLL9rTpvsPmbA3ZK4QMF4blpUtlOCvRrNnTPN1aRnHzXZwdpuiBj74= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1676887270; 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=Jwic3gzySQktDGrW/cYZKSOXGo9CqCG5Vl2GCzj5K2M=; b=X4E656GF3S18dRbbfoeyNtnfmrwAA+VBaBfP86+IcuzxcuD42Yj0soaLTkec/JOGi45Uw2jby/iSQyQmXL4EvBlxpC7Kd80BgT8Nud4ha9uywUoVp7fR+PHwes3lie4TMc6KNyEJfPDQZjsInaiC8nRrKciKunOkNbLfGGfsBgY= 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 1676887270641407.587393948568; Mon, 20 Feb 2023 02:01:10 -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-267-oPmfhgu0OLiTRD_Z60Kopg-1; Mon, 20 Feb 2023 05:01:06 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 14E1181172B; Mon, 20 Feb 2023 10:01:03 +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 00C05C15BA0; Mon, 20 Feb 2023 10:01:03 +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 E4CE11946588; Mon, 20 Feb 2023 10:01:02 +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 543401946587 for ; Mon, 20 Feb 2023 10:01:01 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 45C681415113; Mon, 20 Feb 2023 10:01:01 +0000 (UTC) Received: from maggie.redhat.com (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id E02EE140EBF6 for ; Mon, 20 Feb 2023 10:01:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1676887269; 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=Jwic3gzySQktDGrW/cYZKSOXGo9CqCG5Vl2GCzj5K2M=; b=cMddEep0zs7HUksATda3xoRg2sP5B3ueSVCHmjZ/kmYJrbhZM6bL3NLppr4GAiCMnX2sPp qxqt5oFfaDKOW3MsAJQgrCkWKTadXUFaA2LzSwxjotUWIKdnmQRCkcqbsl2b3SnXyCZikH YkTRow1HULi01ggNEK4yKQkhwudk2Mw= X-MC-Unique: oPmfhgu0OLiTRD_Z60Kopg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH 2/4] qemu: Don't overwrite error from qemuSecurityCommandRun() Date: Mon, 20 Feb 2023 11:00:56 +0100 Message-Id: <4e7b5d5cf9351d74048f41d63c0f6c6b2a764bf7.1676887078.git.mprivozn@redhat.com> 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.8 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: 1676887271869100003 Content-Type: text/plain; charset="utf-8"; x-default="true" The usual pattern when starting a helper daemon is: if (qemuSecurityCommandRun(..., &exitstatus, &cmdret) < 0) goto cleanup; if (cmdret < 0 || exitstatus !=3D 0) { virReportError(); goto cleanup; } The only problem with this pattern is that if virCommandRun() fails (i.e. cmdret < 0), then proper error was already reported. But in this pattern we overwrite it (usually with less specific) error. Signed-off-by: Michal Privoznik --- src/qemu/qemu_dbus.c | 6 ++++-- src/qemu/qemu_passt.c | 6 ++++-- src/qemu/qemu_security.c | 5 +++-- src/qemu/qemu_slirp.c | 6 ++++-- src/qemu/qemu_vhost_user_gpu.c | 6 ++++-- 5 files changed, 19 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_dbus.c b/src/qemu/qemu_dbus.c index cb2694795e..a5807527a6 100644 --- a/src/qemu/qemu_dbus.c +++ b/src/qemu/qemu_dbus.c @@ -224,8 +224,10 @@ qemuDBusStart(virQEMUDriver *driver, goto cleanup; =20 if (cmdret < 0 || exitstatus !=3D 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not start dbus-daemon. exitstatus: %d"), e= xitstatus); + if (cmdret >=3D 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not start dbus-daemon. exitstatus: %d"= ), exitstatus); + } goto cleanup; } =20 diff --git a/src/qemu/qemu_passt.c b/src/qemu/qemu_passt.c index 1217a6a087..53a7cc9605 100644 --- a/src/qemu/qemu_passt.c +++ b/src/qemu/qemu_passt.c @@ -275,8 +275,10 @@ qemuPasstStart(virDomainObj *vm, goto error; =20 if (cmdret < 0 || exitstatus !=3D 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not start 'passt': %s"), NULLSTR(errbuf)); + if (cmdret >=3D 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not start 'passt': %s"), NULLSTR(errbu= f)); + } goto error; } =20 diff --git a/src/qemu/qemu_security.c b/src/qemu/qemu_security.c index beada669f7..2548fc0ecd 100644 --- a/src/qemu/qemu_security.c +++ b/src/qemu/qemu_security.c @@ -626,10 +626,11 @@ qemuSecurityDomainRestorePathLabel(virQEMUDriver *dri= ver, * @cmdret: pointer to int returning result of virCommandRun * * Run @cmd with seclabels set on it. If @uid and/or @gid are not - * -1 then their value is enforced. + * -1 then their value is enforced. If @cmdret is negative upon + * return, then appropriate error was already reported. * * Returns: 0 on success, - * -1 otherwise. + * -1 otherwise (with error reported). */ int qemuSecurityCommandRun(virQEMUDriver *driver, diff --git a/src/qemu/qemu_slirp.c b/src/qemu/qemu_slirp.c index faf58b0394..1bd45cb06c 100644 --- a/src/qemu/qemu_slirp.c +++ b/src/qemu/qemu_slirp.c @@ -331,8 +331,10 @@ qemuSlirpStart(virDomainObj *vm, goto error; =20 if (cmdret < 0 || exitstatus !=3D 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not start 'slirp'. exitstatus: %d"), exits= tatus); + if (cmdret >=3D 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not start 'slirp'. exitstatus: %d"), e= xitstatus); + } goto error; } =20 diff --git a/src/qemu/qemu_vhost_user_gpu.c b/src/qemu/qemu_vhost_user_gpu.c index bc5a1dc3ec..a9a5fe3a3e 100644 --- a/src/qemu/qemu_vhost_user_gpu.c +++ b/src/qemu/qemu_vhost_user_gpu.c @@ -157,8 +157,10 @@ int qemuExtVhostUserGPUStart(virQEMUDriver *driver, goto error; =20 if (cmdret < 0 || exitstatus !=3D 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not start 'vhost-user-gpu'. exitstatus: %d= "), exitstatus); + if (cmdret >=3D 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not start 'vhost-user-gpu'. exitstatus= : %d"), exitstatus); + } goto cleanup; } =20 --=20 2.39.2