From nobody Mon Feb 2 07:31:49 2026 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=1769443850; cv=none; d=zohomail.com; s=zohoarc; b=ImFwjEvzDrvKQ8s/TWZMVqoxCd257utf7mW1kuvOiHj/sMqG/Rjp5TcEcAxybilR4DJOC8lZk9KHQ9BB6cmu0Yim6BINWkjQ78aUdBizkLS1BI81CXQOoz4/QgalJpkwo644q8KgiWWAnw/TU9e6rYEjc9iXMTtQFdudzCvnOsI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1769443850; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Owner: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=H4E4EYR3HyBM/aQvZj+eFU/m9lp8BdNOPD/vGDtRQiM=; b=MX/GPT4q2xh8DgLN5cBKiyM0j84egBIhr7+CZlUbDOt/UrZiqPkLfvxpboaGP52fARkaEPp9pKPHM6BPwBAbUlqROHGDHdflFrqYewf6R8cqRfLx2vNoSI2VtRn+8yPNPf++SKhxsFYFtH5jOZSo53KD+PxRiON0r4AqGvdChEU= 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 1769443850804666.839815337147; Mon, 26 Jan 2026 08:10:50 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 0121341B0D; Mon, 26 Jan 2026 11:10:49 -0500 (EST) Received: from [172.19.199.3] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 07CB543EA3; Mon, 26 Jan 2026 11:07:55 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id A0EB841A40; Mon, 26 Jan 2026 11:07:50 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (3072 bits) server-digest SHA256) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id A1D9541B39 for ; Mon, 26 Jan 2026 11:07:04 -0500 (EST) Received: from mx-prod-mc-03.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-451-KJ_mRQPyOU6lrzKtg4NmkQ-1; Mon, 26 Jan 2026 11:07:02 -0500 Received: from mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.111]) (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-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 24DE71955D95 for ; Mon, 26 Jan 2026 16:07:02 +0000 (UTC) Received: from speedmetal.lan (unknown [10.45.242.3]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 595DD180049F for ; Mon, 26 Jan 2026 16:07:01 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 4.0.1 (2024-03-26) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-5.0 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED, RCVD_IN_VALIDITY_CERTIFIED_BLOCKED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_PASS autolearn=unavailable autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1769443624; 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=H4E4EYR3HyBM/aQvZj+eFU/m9lp8BdNOPD/vGDtRQiM=; b=E2hXWmyqzDOhNZBFMqckDnLrfDqRdBZJ0zUmJaMH9IWzzvFqWr8oJufzN6hwEMtvuzPuPb VDAXa+JuHI/TepXQGW0iQ7irEhHrTFwg4BdWlL94NhhXXSqqgwLa1UbHt7QuSV+j3ktDoB uz2nZhMcn8byoA3VBb8js3enzXixUhQ= X-MC-Unique: KJ_mRQPyOU6lrzKtg4NmkQ-1 X-Mimecast-MFC-AGG-ID: KJ_mRQPyOU6lrzKtg4NmkQ_1769443622 To: devel@lists.libvirt.org Subject: [PATCH v2 5/5] qemuSnapshotUpdateBackingStore: Retry as curent user if qemu-img fails Date: Mon, 26 Jan 2026 17:06:53 +0100 Message-ID: <37ca0662a40201ed08ac3a4095c680ab83077b66.1769443445.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.111 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: cK_PADSz7EmymLITgGKKbY3-bJ8DWSMYPwLHB2kW-Ss_1769443622 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 7RVLJFNB7WAB3SRH5K7NPHZJSBLZZYIA X-Message-ID-Hash: 7RVLJFNB7WAB3SRH5K7NPHZJSBLZZYIA X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; loop; banned-address; header-match-devel.lists.libvirt.org-0; emergency; member-moderation; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; digests; suspicious-header X-Mailman-Version: 3.3.10 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Owner: List-Post: List-Subscribe: List-Unsubscribe: From: Peter Krempa via Devel Reply-To: Peter Krempa X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1769443853119158500 Content-Type: text/plain; charset="utf-8" From: Peter Krempa The code calls 'qemu-img rebase' to fix the backing store references. The 'qemu-img' process here is run as the 'qemu' user or whatever the defaults and domain XML resolve to. Since this, in certain cases, works also on images which are not part of the backing chain and in privileged deployments thus can be owned by 'root:root' the update may fail (silently). To preserver root-squash deployments but fix also the above case, retry the operation on failure as current user. Signed-off-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 53 ++++++++++++++++++++++++++++------------ 1 file changed, 38 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 1628c33865..70e4c37144 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -3710,25 +3710,48 @@ qemuSnapshotUpdateBackingStore(qemuSnapshotDeleteEx= ternalData *data) for (cur =3D data->disksWithBacking; cur; cur =3D g_slist_next(cur)) { struct _qemuSnapshotDisksWithBackingStoreData *backingData =3D cur= ->data; - g_autoptr(virCommand) cmd =3D NULL; + /* Try to run the command first as the appropriate user based on t= he + * domain definition and config. If error is returned retry as cur= rent + * (possibly privileged) user for cases where seclabels were reset + * to the default */ + g_autoptr(virCommand) cmd_user_qemu =3D NULL; + g_autoptr(virCommand) cmd_user_curr =3D NULL; + + if (!(cmd_user_qemu =3D virCommandNewArgList("qemu-img", + "rebase", + "-u", + "-F", + virStorageFileFormatTyp= eToString(data->parentDiskSrc->format), + "-f", + virStorageFileFormatTyp= eToString(backingData->diskSrc->format), + "-b", + data->parentDiskSrc->pa= th, + backingData->diskSrc->p= ath, + NULL))) + continue; - if (!(cmd =3D virCommandNewArgList("qemu-img", - "rebase", - "-u", - "-F", - virStorageFileFormatTypeToString(= data->parentDiskSrc->format), - "-f", - virStorageFileFormatTypeToString(= backingData->diskSrc->format), - "-b", - data->parentDiskSrc->path, - backingData->diskSrc->path, - NULL))) + virCommandSetUID(cmd_user_qemu, backingData->uid); + virCommandSetGID(cmd_user_qemu, backingData->gid); + + /* done on success */ + if (virCommandRun(cmd_user_qemu, NULL) =3D=3D 0) continue; - virCommandSetUID(cmd, backingData->uid); - virCommandSetGID(cmd, backingData->gid); + /* retry as current user */ + if (!(cmd_user_curr =3D virCommandNewArgList("qemu-img", + "rebase", + "-u", + "-F", + virStorageFileFormatTyp= eToString(data->parentDiskSrc->format), + "-f", + virStorageFileFormatTyp= eToString(backingData->diskSrc->format), + "-b", + data->parentDiskSrc->pa= th, + backingData->diskSrc->p= ath, + NULL))) + continue; - ignore_value(virCommandRun(cmd, NULL)); + ignore_value(virCommandRun(cmd_user_curr, NULL)); } } --=20 2.52.0