From nobody Sun Feb 8 23:30:38 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=1747323090; cv=none; d=zohomail.com; s=zohoarc; b=kvVzKlX8C8rKHRtCDuKGryXTKfabNetpqHaD16xmRTr3LqgZ0zhK11wIaexjkhxND7NyAJoJHyZFdnAx2cSmYz5bSU6oADXP42ABJkEaYcYOZNL3AK5++Rv73xFjr2Dk7zpexCLnQo9YKdCnifjz0kze3un0VNCVq6jC6yJn80o= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1747323090; h=Content-Type:Content-Transfer-Encoding:Cc:Cc: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; bh=GMIW5bqslJgk7q+H9cHcCOZETlpn3U0+4IWJ2FN0xKg=; b=Wawx1eGFOAOUxN+yF7LsyyQDngkriWS5et0sXZfGhzhnwmunoq33lL6KeosPn23VLYriSwSV4yRWPKY9BOqZjXrgfQvZpnJx4XGWy2rolM5idGTyzur1e0caeC0bNnuUcwuDh8UMsNt/O3zoDgrfgjGJsgUEsLk7PFolUFpEsaU= 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 17473230902759.142075995054824; Thu, 15 May 2025 08:31:30 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 4298713E7; Thu, 15 May 2025 11:31:29 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 2F4D31373; Thu, 15 May 2025 11:29:33 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 7CEE41402; Thu, 15 May 2025 11:29:28 -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 C94D81339 for ; Thu, 15 May 2025 11:29:20 -0400 (EDT) Received: from mx-prod-mc-08.mail-002.prod.us-west-2.aws.redhat.com (ec2-35-165-154-97.us-west-2.compute.amazonaws.com [35.165.154.97]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-241-mGXyLEhBOnSvAWGTKAa1rw-1; Thu, 15 May 2025 11:29:19 -0400 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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3AF5B180036E for ; Thu, 15 May 2025 15:29:18 +0000 (UTC) Received: from speedmetal.lan (unknown [10.44.22.37]) by mx-prod-int-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 3BAB918003FC; Thu, 15 May 2025 15:29:17 +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_NONE 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=1747322960; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=5rEfqKw1dX8fx621EIsk+fQGDLWppBY5pqZvW5CCxW8=; b=TGNYgfj9sbtYpCAi2nCeGoWhZxtZAFB0SS8n767hw15Yj+hC64hfSEOtI6Asbsa+Ix9Ld5 FJJCOHyJwh7RMzYPFjZ74B3VjqZ5SCrwqJPKQxnQGDbjCkKds/n8/PXPQriyzy+o2BmcUb I7vvWQ4H8NlilGJ3EpNpqcTvUJY1Nt4= X-MC-Unique: mGXyLEhBOnSvAWGTKAa1rw-1 X-Mimecast-MFC-AGG-ID: mGXyLEhBOnSvAWGTKAa1rw_1747322958 To: devel@lists.libvirt.org Subject: [PATCH 04/17] qemuSnapshotRevertInactive: Ensure all error paths handle transient domains properly Date: Thu, 15 May 2025 17:28:49 +0200 Message-ID: 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: koZX6gLC4JsfxDFVgyVSOqp74iiYdWfRGsGdCexN25U_1747322958 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: WS346BE2HBFHXSVH7R4HIYBC5E4DHRA7 X-Message-ID-Hash: WS346BE2HBFHXSVH7R4HIYBC5E4DHRA7 X-MailFrom: pkrempa@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 CC: Peter Krempa 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: Peter Krempa via Devel Reply-To: Peter Krempa X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1747323092032116600 Content-Type: text/plain; charset="utf-8" From: Peter Krempa Only the internal snapshot code paths were able to handle transient domains properly in case when startup of the process failed. Unify the error paths on an 'error' label with proper handling. Signed-off-by: Peter Krempa --- src/qemu/qemu_snapshot.c | 31 ++++++++++++++++--------------- 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_snapshot.c b/src/qemu/qemu_snapshot.c index 6926d1a0e4..b66b83e230 100644 --- a/src/qemu/qemu_snapshot.c +++ b/src/qemu/qemu_snapshot.c @@ -2773,24 +2773,20 @@ qemuSnapshotRevertInactive(virDomainObj *vm, if (virDomainSnapshotIsExternal(snap)) { if (!(tmpsnapdef =3D virDomainSnapshotDefNew())) - return -1; + goto error; if (qemuSnapshotRevertExternalPrepare(vm, tmpsnapdef, snap, - NULL, *inactiveConfig, NULL)= < 0) { - return -1; - } + NULL, *inactiveConfig, NULL)= < 0) + goto error; if (qemuSnapshotRevertExternalInactive(tmpsnapdef, - *inactiveConfig) < 0) { - return -1; - } + *inactiveConfig) < 0) + goto error; qemuSnapshotRevertExternalFinish(vm, tmpsnapdef, snap); } else { - if (qemuSnapshotInternalRevertInactive(vm, snap) < 0) { - qemuDomainRemoveInactive(driver, vm, 0, false); - return -1; - } + if (qemuSnapshotInternalRevertInactive(vm, snap) < 0) + goto error; } if (*inactiveConfig) { @@ -2810,10 +2806,9 @@ qemuSnapshotRevertInactive(virDomainObj *vm, NULL, VIR_NETDEV_VPORT_PROFILE_OP_CREATE, start_flags); virDomainAuditStart(vm, "from-snapshot", rc >=3D 0); - if (rc < 0) { - qemuDomainRemoveInactive(driver, vm, 0, false); - return -1; - } + if (rc < 0) + goto error; + detail =3D VIR_DOMAIN_EVENT_STARTED_FROM_SNAPSHOT; event =3D virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_STARTED, @@ -2829,6 +2824,12 @@ qemuSnapshotRevertInactive(virDomainObj *vm, } return qemuSnapshotRevertWriteMetadata(vm, snap, driver, cfg, defined); + + error: + if (!virDomainObjIsActive(vm)) + qemuDomainRemoveInactive(driver, vm, 0, false); + + return -1; } --=20 2.49.0