From nobody Tue Mar 24 01:12:21 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=1772835369; cv=none; d=zohomail.com; s=zohoarc; b=SPzfvC/y1n7P7RoXgBD1UESYx147CJESjOTjkKXqQxNxOF1+PE9X0hES5DAFI1f+Ns0v/MaK9++cg72hV+9n04t4YsxFRiH85MgxGSBV/0BN03HUtAbJ29tXHdiGVDHAWt4KayCjnsiDRUeIUm9NXoPwaGrSsqTlOiiKCzhFTcI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772835369; 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=MqF5xiVmcgdehgTRHV+Xng8Ofmc/xobqPk2qqq6pppE=; b=ZO7hq5ahCJY25LvQDlS/cDSqQ/qDIL1FUPNlJEKI4fNcYRW48PCxfqV9AlXzxwPzizUMvj0NKPicwSJULfESVBpKDvFFw2d46VoEXuI87Svicct5Yhu1nYTVTASZi+880XVLNTUqtlbxXg6O2M3CDJi/NGfm7x1kZ2WfN+otI+4= 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 1772835369224753.746957422856; Fri, 6 Mar 2026 14:16:09 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 53E294196A; Fri, 6 Mar 2026 17:16:08 -0500 (EST) Received: from [172.19.199.12] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 6F75141C99; Fri, 6 Mar 2026 17:13:10 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id BF995418E1; Fri, 6 Mar 2026 17:12:58 -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 4B7A6418DB for ; Fri, 6 Mar 2026 17:12:58 -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-473-02UF7rPEO1uoJ92XYeM8XQ-1; Fri, 06 Mar 2026 17:12:56 -0500 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.12]) (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 A26EA1956050 for ; Fri, 6 Mar 2026 22:12:55 +0000 (UTC) Received: from himantopus.redhat.com (unknown [10.22.81.168]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 40EC31958DC5 for ; Fri, 6 Mar 2026 22:12:55 +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=-2.6 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,HELO_MISC_IP,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=1772835178; 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=MqF5xiVmcgdehgTRHV+Xng8Ofmc/xobqPk2qqq6pppE=; b=WqxDYE6SVGmrE+pm/G9EXBswGk5xlEB+x7dcAyj96TDu+eyWmPNFe6wGEk1gcE8OHmLiGp J2IibOJE1IeA3/5aL/BGah9QGZk0F1LzeMe0Tjiu6A6Q2oBWH4+IOAreuZMKvoWxp8mkkA V96F5iwDUlKJSOT9laJTegRzIZrlSX8= X-MC-Unique: 02UF7rPEO1uoJ92XYeM8XQ-1 X-Mimecast-MFC-AGG-ID: 02UF7rPEO1uoJ92XYeM8XQ_1772835175 To: devel@lists.libvirt.org Subject: [PATCH 3/5] hyperv: implement virDomainSnapshotGetXMLDesc() Date: Fri, 6 Mar 2026 16:12:49 -0600 Message-ID: <20260306221251.929040-4-jjongsma@redhat.com> In-Reply-To: <20260306221251.929040-1-jjongsma@redhat.com> References: <20260306221251.929040-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: aDhLTYPgOmMV01FjlMUletUvURLaaIr6i-XWieLtZqA_1772835175 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: QVBI3QZTS26ZPG5H2QDWAYJ6MI4YB4AC X-Message-ID-Hash: QVBI3QZTS26ZPG5H2QDWAYJ6MI4YB4AC X-MailFrom: jjongsma@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: Jonathon Jongsma via Devel Reply-To: Jonathon Jongsma X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1772835371587158500 Content-Type: text/plain; charset="utf-8"; x-default="true" This function is required for `virsh snapshot-list` to work. Signed-off-by: Jonathon Jongsma --- src/hyperv/hyperv_driver.c | 67 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 67 insertions(+) diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index 8a1cc4b453..4a4db0e76b 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -41,6 +41,7 @@ #include "virstring.h" #include "virkeycode.h" #include "domain_conf.h" +#include "snapshot_conf.h" #include "virfdstream.h" #include "virfile.h" =20 @@ -4209,6 +4210,71 @@ hypervDomainSnapshotNum(virDomainPtr domain, } =20 =20 +/* A snapshot's parent is specified as an object path like 'InstanceID=3D"= $ID"'. + * This function extracts the id portion. */ +static char * +hypervParseInstanceIdFromParentPath(const char *obj_path) +{ + const char *const instance_prefix =3D "InstanceID=3D\""; + const char *id_start =3D NULL; + if (!obj_path) + return NULL; + + id_start =3D strstr(obj_path, instance_prefix); + if (id_start) { + const char *id_end; + id_start +=3D strlen(instance_prefix); + id_end =3D strchr(id_start, '"'); + if (id_end) { + g_autofree char* parent_id_escaped =3D g_strndup(id_start, id_= end - id_start); + char* parent_id =3D virStringReplace(parent_id_escaped, "\\\\"= , "\\"); + return parent_id; + } + } + return NULL; +} + + +static char * +hypervDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot, + unsigned int flags) +{ + hypervPrivate *priv =3D snapshot->domain->conn->privateData; + g_autoptr(Msvm_VirtualSystemSettingData) vssd =3D NULL; + g_autoptr(virDomainSnapshotDef) def =3D NULL; + char uuidstr[VIR_UUID_STRING_BUFLEN]; + + virCheckFlags(VIR_DOMAIN_SNAPSHOT_XML_SECURE, NULL); + + vssd =3D hypervDomainLookupSnapshotSD(snapshot->domain, snapshot->name= ); + if (!vssd) + return NULL; + + if (!(def =3D virDomainSnapshotDefNew())) + return NULL; + + def->parent.name =3D g_strdup(vssd->data->InstanceID); + def->parent.description =3D g_strdup(vssd->data->ElementName); + def->parent.parent_name =3D hypervParseInstanceIdFromParentPath(vssd->= data->Parent); + /* IsSaved indicates the snapshot configuration references a saved mem= ory + * state file, meaning the snapshot was taken from a running VM and in= cludes + * full machine state. Otherwise it's either a 'production' checkpoint= or an + * offline snapshot, which are both disk-only. */ + def->state =3D vssd->data->IsSaved ? VIR_DOMAIN_SNAPSHOT_RUNNING : VIR= _DOMAIN_SNAPSHOT_DISK_SNAPSHOT; + + if (vssd->data->CreationTime) { + g_autoptr(GDateTime) dt =3D g_date_time_new_from_iso8601(vssd->dat= a->CreationTime, NULL); + if (dt) + def->parent.creationTime =3D g_date_time_to_unix(dt); + } + + virUUIDFormat(snapshot->domain->uuid, uuidstr); + + return virDomainSnapshotDefFormat(uuidstr, def, priv->xmlopt, + virDomainSnapshotFormatConvertXMLFla= gs(flags)); +} + + static virHypervisorDriver hypervHypervisorDriver =3D { .name =3D "Hyper-V", .connectOpen =3D hypervConnectOpen, /* 0.9.5 */ @@ -4278,6 +4344,7 @@ static virHypervisorDriver hypervHypervisorDriver =3D= { .domainSnapshotLookupByName =3D hypervDomainSnapshotLookupByName, /* 1= 2.2.0 */ .domainListAllSnapshots =3D hypervDomainListAllSnapshots, /* 12.2.0 */ .domainSnapshotNum =3D hypervDomainSnapshotNum, /* 12.2.0 */ + .domainSnapshotGetXMLDesc =3D hypervDomainSnapshotGetXMLDesc, /* 12.2.= 0 */ }; =20 =20 --=20 2.53.0