From nobody Sun Feb 8 21:48: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=1642011108; cv=none; d=zohomail.com; s=zohoarc; b=QCAFIhhsJLG6xdmGzrMV+tSGrQZH7sh/6PkU/uI0RtX9ED7AqFOFO8842mduEPhai40zWo+gDxgBcmhFYvw/kgzzNnooeb+V8F+e1NTEfPMuomfqS1iacUMZKhEXYEz7XZ7mUZEa/YRmYkzgExqot0NcMSGTk+naW99HzEtpv0E= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1642011108; 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=PGrFiuWjlOM9VY6u2b0t3fdn8Lkb4g0/lHmNVtNNKVE=; b=CJlMOgZY0/3M/CzhuBIcPodU3NHAl0EAAfcyw+nyie0zJQw91SrVFQhijYhtROCswaXLYal+GXLIJP3UYb1q7mxVZp6NCdePhZjXMcr2WjfVkb/caVXy+9AC9aWnvjYwijx2uMWyauWXnZtoxm00Q4/j0+CM7RUIKRjSf6YLRWc= 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 1642011108710275.32734254604316; Wed, 12 Jan 2022 10:11:48 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-467-3jyPfQX1OiKQaxUw7hM29g-1; Wed, 12 Jan 2022 13:11:44 -0500 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 566A8100C66A; Wed, 12 Jan 2022 18:11:37 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 383EB105C89D; Wed, 12 Jan 2022 18:11:37 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 0725E1806D2D; Wed, 12 Jan 2022 18:11:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 20CIAgmD003124 for ; Wed, 12 Jan 2022 13:10:42 -0500 Received: by smtp.corp.redhat.com (Postfix) id 179E18AD18; Wed, 12 Jan 2022 18:10:42 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.34]) by smtp.corp.redhat.com (Postfix) with ESMTP id 579EA8CB25 for ; Wed, 12 Jan 2022 18:10:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1642011107; 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=PGrFiuWjlOM9VY6u2b0t3fdn8Lkb4g0/lHmNVtNNKVE=; b=R+13P8ALcp9U7lcO2PcsRNG/DRwlYwEtO43igeHJrI+D8u5YKeN7IvZX9NkF/Kwtmcz6YK xrIABpDO7DEyWybV/EyaPzXrabRePvAyVn4VVqBGfqh4tjdH+WPP+vWcS9GDIO85Taod9W Frh44kvfDJMRjaOQ+3PDQqHw/M5vNGw= X-MC-Unique: 3jyPfQX1OiKQaxUw7hM29g-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 12/17] testDomainSnapshotCreateXML: Extract snapshot redefinition code Date: Wed, 12 Jan 2022 19:10:12 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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: 1642011110984100001 Content-Type: text/plain; charset="utf-8" The test driver code was copied from qemu but wasn't refactored recently. Split out the redefinition code similarly to what qemu driver did. Signed-off-by: Peter Krempa --- src/test/test_driver.c | 76 +++++++++++++++++++++++++++--------------- 1 file changed, 49 insertions(+), 27 deletions(-) diff --git a/src/test/test_driver.c b/src/test/test_driver.c index dde7bf1b8e..e772b2be2b 100644 --- a/src/test/test_driver.c +++ b/src/test/test_driver.c @@ -8739,6 +8739,33 @@ testDomainSnapshotAlignDisks(virDomainObj *vm, return virDomainSnapshotAlignDisks(def, NULL, align_location, true); } + +static virDomainSnapshotPtr +testDomainSnapshotRedefine(virDomainObj *vm, + virDomainPtr domain, + virDomainSnapshotDef *snapdeftmp, + virDomainMomentObj **snapout, + virDomainXMLOption *xmlopt, + unsigned int flags) +{ + virDomainMomentObj *snap =3D NULL; + g_autoptr(virDomainSnapshotDef) snapdef =3D virObjectRef(snapdeftmp); + + if (virDomainSnapshotRedefinePrep(vm, &snapdef, &snap, xmlopt, flags) = < 0) + return NULL; + + if (!snap) { + if (!(snap =3D virDomainSnapshotAssignDef(vm->snapshots, snapdef))) + return NULL; + snapdef =3D NULL; + } + + *snapout =3D snap; + + return virGetDomainSnapshot(domain, snap->def->name); +} + + static virDomainSnapshotPtr testDomainSnapshotCreateXML(virDomainPtr domain, const char *xmlDesc, @@ -8805,37 +8832,32 @@ testDomainSnapshotCreateXML(virDomainPtr domain, goto cleanup; if (redefine) { - if (virDomainSnapshotRedefinePrep(vm, &def, &snap, - privconn->xmlopt, - flags) < 0) - goto cleanup; - } else { - if (!(def->parent.dom =3D virDomainDefCopy(vm->def, - privconn->xmlopt, - NULL, - true))) - goto cleanup; - - if (testDomainSnapshotAlignDisks(vm, def, flags) < 0) - goto cleanup; + snapshot =3D testDomainSnapshotRedefine(vm, domain, def, &snap, + privconn->xmlopt, flags); + goto cleanup; } - if (!snap) { - if (!(snap =3D virDomainSnapshotAssignDef(vm->snapshots, def))) - goto cleanup; - def =3D NULL; - } + if (!(def->parent.dom =3D virDomainDefCopy(vm->def, + privconn->xmlopt, + NULL, + true))) + goto cleanup; - if (!redefine) { - snap->def->parent_name =3D g_strdup(virDomainSnapshotGetCurrentNam= e(vm->snapshots)); + if (testDomainSnapshotAlignDisks(vm, def, flags) < 0) + goto cleanup; - if ((flags & VIR_DOMAIN_SNAPSHOT_CREATE_HALT) && - virDomainObjIsActive(vm)) { - testDomainShutdownState(domain, vm, - VIR_DOMAIN_SHUTOFF_FROM_SNAPSHOT); - event =3D virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVE= NT_STOPPED, - VIR_DOMAIN_EVENT_STOPPED_FROM_SNAPSHOT= ); - } + if (!(snap =3D virDomainSnapshotAssignDef(vm->snapshots, def))) + goto cleanup; + def =3D NULL; + + snap->def->parent_name =3D g_strdup(virDomainSnapshotGetCurrentName(vm= ->snapshots)); + + if ((flags & VIR_DOMAIN_SNAPSHOT_CREATE_HALT) && + virDomainObjIsActive(vm)) { + testDomainShutdownState(domain, vm, + VIR_DOMAIN_SHUTOFF_FROM_SNAPSHOT); + event =3D virDomainEventLifecycleNewFromObj(vm, VIR_DOMAIN_EVENT_S= TOPPED, + VIR_DOMAIN_EVENT_STOPPED= _FROM_SNAPSHOT); } snapshot =3D virGetDomainSnapshot(domain, snap->def->name); --=20 2.31.1