From nobody Tue Sep 9 19:25:39 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1752754786; cv=none; d=zohomail.com; s=zohoarc; b=GFUZzMLJ2fN63AghEbVOd3T4He7NTKD52Ysxy6RxkPb5ZKPgBqIHSIJz10Mak+50OaR6U8wA+EYXYydeckOFAXV1/FIwlXZqy3wV29WfDgSCi6rH+Kmqs9m9D2ulBwdYgciqxdIS0lq9XzgQQUHkSwvbc7qv8S1fDfOF/atMCsU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1752754786; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id:Cc; bh=PbaC0SOwlb70IE1e0SenrvzrxFzxkUt7UfrkXVzcwMw=; b=RhiOYMH11lpqHp+F6mXZCZyR6VGBP4CI4wIYyRu0d6fTzrxVHcGU+mG9fB9doajSDpHPaFo9N2CV6wUa3k1alKF6mtF+yDkH9jyF2b++k5vHP0fawbuZsxpV4lhHGYHps28adEDNN5fKOpAfBTPqVtoE6FtqUMIO8fwY6KBpie4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1752754785892433.4721952623321; Thu, 17 Jul 2025 05:19:45 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id C81EF14B8; Thu, 17 Jul 2025 08:19:44 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 6AF0D146A; Thu, 17 Jul 2025 08:19:07 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id B2B9111BC; Thu, 17 Jul 2025 08:19:02 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id DEA7711E3 for ; Thu, 17 Jul 2025 08:19:01 -0400 (EDT) Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-435-6oGTKDtBOxmSR8lUiZ5UmQ-1; Thu, 17 Jul 2025 08:19:00 -0400 Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A541D195FD2B for ; Thu, 17 Jul 2025 12:18:59 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.3.236]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id F1BEB19560A0 for ; Thu, 17 Jul 2025 12:18:58 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_PASS autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1752754741; h=from:from: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; bh=RWjzpyWqn23P++0UBsNI6Nvz8ih7ne5GnLsyA1JonWw=; b=GmjkRI5S9Yztz3Bw6L2HfTTNANvwJWNJCNU6Zvikp5wD6+wRkvWDhlyjrBxW6DFvYtELr5 9DDnUKBTIinamBzGQV/DaR8YlcF2dqMi8mkf+ocvB18gvETz8tKH9kI94Psf2n+IsDliw7 qzw/CQSqkJZoOoxyKfWzEaYf1RZrjlA= X-MC-Unique: 6oGTKDtBOxmSR8lUiZ5UmQ-1 X-Mimecast-MFC-AGG-ID: 6oGTKDtBOxmSR8lUiZ5UmQ_1752754739 To: devel@lists.libvirt.org Subject: [PATCH 1/2] qemu: Report system error on failed open() Date: Thu, 17 Jul 2025 14:18:54 +0200 Message-ID: <045cb8a9cf366c0fcc383390a02c993e0ce5c547.1752754566.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: MxCdH3tsQdKa8JSpBoDjamXAISZ4e0vW9hwaaxQoAgQ_1752754739 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: UXLNMQ2KWZ455M7AY7FZVHXD355BR77Y X-Message-ID-Hash: UXLNMQ2KWZ455M7AY7FZVHXD355BR77Y X-MailFrom: mprivozn@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: From: Michal Privoznik via Devel Reply-To: Michal Privoznik X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1752754788905116600 Content-Type: text/plain; charset="utf-8"; x-default="true" From: Michal Privoznik With a help from coccinelle three places were identified that call virReportError() after failed open() (in qemuDomainWriteMasterKeyFile(), qemuDomainMasterKeyReadFile() and qemuProcessOpenVhostVsock()). The open() syscall does set errno on failure so switch them to virReportSystemError() which may shed more light into the reasons for failure. Signed-off-by: Michal Privoznik --- src/qemu/qemu_domain.c | 8 ++++---- src/qemu/qemu_process.c | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 4420940745..963dbd3973 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -515,8 +515,8 @@ qemuDomainWriteMasterKeyFile(virQEMUDriver *driver, return -1; =20 if ((fd =3D open(path, O_WRONLY|O_TRUNC|O_CREAT, 0600)) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("failed to open domain master key file for write"= )); + virReportSystemError(errno, "%s", + _("failed to open domain master key file for = write")); return -1; } =20 @@ -580,8 +580,8 @@ qemuDomainMasterKeyReadFile(qemuDomainObjPrivate *priv) } =20 if ((fd =3D open(path, O_RDONLY)) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("failed to open domain master key file for read")= ); + virReportSystemError(errno, "%s", + _("failed to open domain master key file for = read")); goto error; } =20 diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 82cab3f76e..a2872602e8 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -7137,8 +7137,8 @@ qemuProcessOpenVhostVsock(virDomainVsockDef *vsock) int fd; =20 if ((fd =3D open(vsock_path, O_RDWR)) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - "%s", _("unable to open vhost-vsock device")); + virReportSystemError(errno, "%s", + _("unable to open vhost-vsock device")); return -1; } =20 --=20 2.49.1