From nobody Mon Mar 23 23:29:32 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=1772835276; cv=none; d=zohomail.com; s=zohoarc; b=M87PuoxcYXOuAktIGU/8Ksc0HmjeHaqxU4E0PkQub3m+uxBpfYivfkz+YdFA9GuHM/KgDTMgWh1oMcOLAIs3+YYCtB5Iknw4B7vDrtOgSwkDFNklr9H4ONkRAY/SftYXsH6lMpRWkG1QD36teU814LKxXn/14SSHZUKCnPdziYg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772835276; 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=3eGxc+ypaxjNrveRdiqgRe1dRnbKwF+T9giqV6E/DP4=; b=idC4covJnOgk/R2pxDMK+6FpKhWtSee5fzYgJwok6hxLi2N9kBg4TrnyhwPP87o9ZCIBFpHo4nPwhDf86Mr9bFFenEjznpHLXhT8mYzDyX3DT7i2DV3+zzDD4XUUEa37wOoT6nbLKHNNd44G5iMPZUTsCGca5l9NnbWyA4RVhDM= 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 1772835276051864.1785343666974; Fri, 6 Mar 2026 14:14:36 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 85C3A419A3; Fri, 6 Mar 2026 17:14:34 -0500 (EST) Received: from [172.19.199.12] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id A5EEE41919; Fri, 6 Mar 2026 17:13:05 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id 4644E418DB; Fri, 6 Mar 2026 17:12:57 -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 C41A6418DF for ; Fri, 6 Mar 2026 17:12:56 -0500 (EST) 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-513-ePRipvZHN92fD1lAiZBsTQ-1; Fri, 06 Mar 2026 17:12:55 -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-08.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 52EE118002CA for ; Fri, 6 Mar 2026 22:12:54 +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 E59BB1958DC5 for ; Fri, 6 Mar 2026 22:12:53 +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=1772835176; 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=3eGxc+ypaxjNrveRdiqgRe1dRnbKwF+T9giqV6E/DP4=; b=KW/a1/Glm0EVqv8p7lZOFR9kugtDxXQkq13RtO9rKcLWv3E8me4DaHqMxD1MX2lI0Phv5u o31/QJFGyIROfKpbxb9OuE3f6ebU8kACnQbMy0hKS2GN0tnNiWZWj17twHMAhnCNSFmbev 2m9LDb0hjzcf8ieUV15qO0V8X2ah+6Q= X-MC-Unique: ePRipvZHN92fD1lAiZBsTQ-1 X-Mimecast-MFC-AGG-ID: ePRipvZHN92fD1lAiZBsTQ_1772835174 To: devel@lists.libvirt.org Subject: [PATCH 1/5] hyperv: Implement domainSnapshotLookupByName() Date: Fri, 6 Mar 2026 16:12:47 -0600 Message-ID: <20260306221251.929040-2-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: FONEFll9SxyWmTW7Xsf1Xb_NV5lCI3m_OTI0A3dtRdY_1772835174 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: RPVVVGRPHONK25K5TZLZIOPXQLTB2XWR X-Message-ID-Hash: RPVVVGRPHONK25K5TZLZIOPXQLTB2XWR 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: 1772835278650154100 Content-Type: text/plain; charset="utf-8"; x-default="true" Unfortunately Hyper-V does not enforce any uniqueness constraints on snapshot names (called ElementName in Hyper-V). So it's possible for multiple snapshots of the same domain to have identical ElementNames. Since libvirt uses the domain and snapshot name as a unique key to reference a snapshot, we can't use the hyperv ElementName as the snapshot name in libvirt. So instead I've decided to use the InstanceId of the snapshot as the snapshot name and use the ElementName as the snapshot description. This results in a worse user experience (since the snapshot names end up being something like "Microsoft:$(UUID)"), but guarantees that we will be able to uniquely reference every snapshot. Signed-off-by: Jonathon Jongsma Reviewed-by: Michal Privoznik --- src/hyperv/hyperv_driver.c | 53 ++++++++++++++++++++++++++++++++++++++ src/hyperv/hyperv_wmi.h | 3 +++ 2 files changed, 56 insertions(+) diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index 906f6e5d19..44b671b45e 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -4077,6 +4077,58 @@ hypervDomainGetBlockInfo(virDomainPtr domain, } =20 =20 +static Msvm_VirtualSystemSettingData* +hypervDomainLookupSnapshotSD(virDomainPtr domain, const char *snapshot) +{ + hypervPrivate *priv =3D domain->conn->privateData; + g_autoptr(Msvm_VirtualSystemSettingData) vssd =3D NULL; + char domain_uuid_string[VIR_UUID_STRING_BUFLEN]; + g_auto(virBuffer) query =3D VIR_BUFFER_INITIALIZER; + + virUUIDFormat(domain->uuid, domain_uuid_string); + + /* Hyper-V does not enforce unique snapshot names per domain, so we do= n't + * use the Hyper-V snapshot's ElementName field as the libvirt snapsho= t name. + * Instead we use the unique InstanceID as the name, even though it is= not as + * user-friendly */ + virBufferEscapeSQL(&query, + MSVM_VIRTUALSYSTEMSETTINGDATA_WQL_SELECT + "WHERE InstanceID=3D'%s'", + snapshot); + virBufferEscapeSQL(&query, "AND VirtualSystemIdentifier=3D'%s'", domai= n_uuid_string); + virBufferAddLit(&query, "AND VirtualSystemType=3D'" + MSVM_VIRTUALSYSTEMSETTINGDATA_VIRTUALTYPE_SNAPSHOT "'"= ); + + if (hypervGetWmiClass(Msvm_VirtualSystemSettingData, &vssd) < 0) + return NULL; + + if (!vssd) { + virReportError(VIR_ERR_NO_DOMAIN_SNAPSHOT, + _("no domain snapshot with matching name '%1$s'"), = snapshot); + return NULL; + } + + return g_steal_pointer(&vssd); +} + + +static virDomainSnapshotPtr +hypervDomainSnapshotLookupByName(virDomainPtr domain, + const char *name, + unsigned int flags) +{ + g_autoptr(Msvm_VirtualSystemSettingData) vssd =3D NULL; + + virCheckFlags(0, NULL); + + vssd =3D hypervDomainLookupSnapshotSD(domain, name); + if (vssd =3D=3D NULL) + return NULL; + + return virGetDomainSnapshot(domain, name); +} + + static virHypervisorDriver hypervHypervisorDriver =3D { .name =3D "Hyper-V", .connectOpen =3D hypervConnectOpen, /* 0.9.5 */ @@ -4143,6 +4195,7 @@ static virHypervisorDriver hypervHypervisorDriver =3D= { .connectIsAlive =3D hypervConnectIsAlive, /* 0.9.8 */ .domainInterfaceAddresses =3D hypervDomainInterfaceAddresses, /* 12.1.= 0 */ .domainGetBlockInfo =3D hypervDomainGetBlockInfo, /* 12.1.0 */ + .domainSnapshotLookupByName =3D hypervDomainSnapshotLookupByName, /* 1= 2.2.0 */ }; =20 =20 diff --git a/src/hyperv/hyperv_wmi.h b/src/hyperv/hyperv_wmi.h index 65b1211b89..d577dbcecb 100644 --- a/src/hyperv/hyperv_wmi.h +++ b/src/hyperv/hyperv_wmi.h @@ -38,6 +38,9 @@ #define MSVM_IMAGEMANAGEMENTSERVICE_SELECTOR \ "CreationClassName=3DMsvm_ImageManagementService" =20 +#define MSVM_VIRTUALSYSTEMSETTINGDATA_VIRTUALTYPE_SNAPSHOT \ + "Microsoft:Hyper-V:Snapshot:Realized" + int hypervVerifyResponse(WsManClient *client, WsXmlDocH response, const char *detail); =20 --=20 2.53.0 From nobody Mon Mar 23 23:29:32 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=1772835318; cv=none; d=zohomail.com; s=zohoarc; b=J8JQWCy8TwijC19+vav3ztiNHgBZaBm0Oqb7pfdZATnl6vlJNOVAv39pPmcdG4DYJnVzWx0MkRfpa2Y3M43nDDI6OVZRGD+Pcqdsc5UFkQPoqF+siTaFNbzhmPjrySPw72GdTemICYGy/n8nJrRiH+z7gbKE4GZ6QxpLZZA5g1A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772835318; 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=2ZlEqp6H2qubAliwzUAH3S4/GJtQA6BiqkZxw4geFM0=; b=I/Dg0gdKmVT31STcHJo/BVxxdZcdd6QJdcaEqtip8mm19RA35VKvxAEt9IW9DG9raQPLcIxYjbAvecNC7nhY+MAj1HZDMJb3NXyqPqvSspVneBx7SBWo5h6fusjwP024Mc0AyDcSMf12m78oL5wwd2TIN7cp8Uxq/oolva3AbBQ= 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 1772835318329329.7543745686769; Fri, 6 Mar 2026 14:15:18 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id C2C4D4193C; Fri, 6 Mar 2026 17:15:17 -0500 (EST) Received: from [172.19.199.12] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 14E4741BB6; Fri, 6 Mar 2026 17:13:08 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id B20B6418DB; Fri, 6 Mar 2026 17:12:57 -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 632863F8A5 for ; Fri, 6 Mar 2026 17:12:57 -0500 (EST) Received: from mx-prod-mc-05.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-237-tHOegUiROS6WsSbv4D0AQg-1; Fri, 06 Mar 2026 17:12:55 -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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 013BB1956089 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 936161958DC5 for ; Fri, 6 Mar 2026 22:12:54 +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=1772835177; 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=2ZlEqp6H2qubAliwzUAH3S4/GJtQA6BiqkZxw4geFM0=; b=MK+X8zT3uixu7eOgdTiVoUGfuBAWjGX1jj57Ox9h9/7c9bJ1B06WGrdKnr456Y1vB7Y68q tKhgqWprZbm+GdbarkAAzOwp1IYZm3iY4dyYAErs/9zIsO4Q/PsSO08zJUKs5Gfp2/ERCf Lh+741WKi7GZM19XXPAcjLzBzsnA3nc= X-MC-Unique: tHOegUiROS6WsSbv4D0AQg-1 X-Mimecast-MFC-AGG-ID: tHOegUiROS6WsSbv4D0AQg_1772835175 To: devel@lists.libvirt.org Subject: [PATCH 2/5] hyperv: implement virDomainListAllSnapshots()/virDomainSnapshotNum() Date: Fri, 6 Mar 2026 16:12:48 -0600 Message-ID: <20260306221251.929040-3-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: rax7U9YAKjaldGdIgOAVIFHpNWpF6MFIF5Akl4GqVOA_1772835175 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: E6BVLVY62HC3KDJUK6MHGNOLLQEBPYTZ X-Message-ID-Hash: E6BVLVY62HC3KDJUK6MHGNOLLQEBPYTZ 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: 1772835320604154100 Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: Jonathon Jongsma Reviewed-by: Michal Privoznik --- src/hyperv/hyperv_driver.c | 82 ++++++++++++++++++++++++++++++++++++++ src/hyperv/hyperv_wmi.c | 20 ++++++++++ src/hyperv/hyperv_wmi.h | 4 ++ 3 files changed, 106 insertions(+) diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index 44b671b45e..8a1cc4b453 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -4129,6 +4129,86 @@ hypervDomainSnapshotLookupByName(virDomainPtr domain, } =20 =20 +static int +hypervDomainListAllSnapshots(virDomainPtr domain, + virDomainSnapshotPtr **snaps, + unsigned int flags) +{ + hypervPrivate *priv =3D domain->conn->privateData; + g_autoptr(Msvm_VirtualSystemSettingData) snapshots =3D NULL; + Msvm_VirtualSystemSettingData *snapshot =3D NULL; + g_autoptr(GList) filtered =3D NULL; + virDomainSnapshotPtr *snapshotsRet =3D NULL; + char uuid_string[VIR_UUID_STRING_BUFLEN]; + int count =3D 0; + int ret =3D -1; + + virCheckFlags(VIR_DOMAIN_SNAPSHOT_LIST_ROOTS | + VIR_DOMAIN_SNAPSHOT_LIST_METADATA | + VIR_DOMAIN_SNAPSHOT_LIST_NO_METADATA, -1); + + /* libvirt does not maintain any metadata for hyper-v snapshots */ + if (flags & VIR_DOMAIN_SNAPSHOT_LIST_METADATA) + return 0; + + virUUIDFormat(domain->uuid, uuid_string); + + if (hypervGetDomainSnapshotsSD(priv, uuid_string, &snapshots) < 0) + return -1; + + /* filter snapshots */ + for (snapshot =3D snapshots; snapshot; snapshot =3D snapshot->next) { + if ((flags & VIR_DOMAIN_SNAPSHOT_LIST_ROOTS) && snapshot->data->Pa= rent) + continue; + + filtered =3D g_list_append(filtered, snapshot); + } + + count =3D g_list_length(filtered); + + if (!snaps) + return count; + + if (count > 0) { + GList *l =3D NULL; + int idx =3D 0; + + snapshotsRet =3D g_new0(virDomainSnapshotPtr, count); + + for (l =3D filtered; l; l =3D l->next) { + Msvm_VirtualSystemSettingData *vssd =3D l->data; + snapshotsRet[idx] =3D virGetDomainSnapshot(domain, vssd->data-= >InstanceID); + if (!snapshotsRet[idx]) + goto cleanup; + idx++; + } + } + + *snaps =3D snapshotsRet; + ret =3D count; + + cleanup: + if (ret < 0) { + size_t i; + for (i =3D 0; i < count; i++) { + if (snapshotsRet[i]) + virObjectUnref(snapshotsRet[i]); + } + VIR_FREE(snapshotsRet); + } + + return ret; +} + + +static int +hypervDomainSnapshotNum(virDomainPtr domain, + unsigned int flags) +{ + return hypervDomainListAllSnapshots(domain, NULL, flags); +} + + static virHypervisorDriver hypervHypervisorDriver =3D { .name =3D "Hyper-V", .connectOpen =3D hypervConnectOpen, /* 0.9.5 */ @@ -4196,6 +4276,8 @@ static virHypervisorDriver hypervHypervisorDriver =3D= { .domainInterfaceAddresses =3D hypervDomainInterfaceAddresses, /* 12.1.= 0 */ .domainGetBlockInfo =3D hypervDomainGetBlockInfo, /* 12.1.0 */ .domainSnapshotLookupByName =3D hypervDomainSnapshotLookupByName, /* 1= 2.2.0 */ + .domainListAllSnapshots =3D hypervDomainListAllSnapshots, /* 12.2.0 */ + .domainSnapshotNum =3D hypervDomainSnapshotNum, /* 12.2.0 */ }; =20 =20 diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c index 7ae3afc40a..94a4789913 100644 --- a/src/hyperv/hyperv_wmi.c +++ b/src/hyperv/hyperv_wmi.c @@ -1406,6 +1406,26 @@ hypervGetMsvmVirtualSystemSettingDataFromUUID(hyperv= Private *priv, } =20 =20 +int +hypervGetDomainSnapshotsSD(hypervPrivate *priv, + const char *domain_uuid_string, + Msvm_VirtualSystemSettingData **list) +{ + g_auto(virBuffer) query =3D VIR_BUFFER_INITIALIZER; + + virBufferAsprintf(&query, + "ASSOCIATORS OF {Msvm_ComputerSystem.CreationClassNa= me=3D'Msvm_ComputerSystem',Name=3D'%s'} " + "WHERE AssocClass =3D Msvm_SnapshotOfVirtualSystem " + "ResultClass =3D Msvm_VirtualSystemSettingData", + domain_uuid_string); + + if (hypervGetWmiClass(Msvm_VirtualSystemSettingData, list) < 0) + return -1; + + return 0; +} + + #define hypervGetSettingData(type, id, out) \ g_auto(virBuffer) query =3D VIR_BUFFER_INITIALIZER; \ virBufferEscapeSQL(&query, \ diff --git a/src/hyperv/hyperv_wmi.h b/src/hyperv/hyperv_wmi.h index d577dbcecb..134d8894e6 100644 --- a/src/hyperv/hyperv_wmi.h +++ b/src/hyperv/hyperv_wmi.h @@ -240,6 +240,10 @@ int hypervGetMsvmVirtualSystemSettingDataFromUUID(hype= rvPrivate *priv, const char *uuid_string, Msvm_VirtualSystemSettin= gData **list); =20 +int hypervGetDomainSnapshotsSD(hypervPrivate *priv, + const char *domain_uuid_string, + Msvm_VirtualSystemSettingData **list); + int hypervGetResourceAllocationSD(hypervPrivate *priv, const char *id, Msvm_ResourceAllocationSettingData **dat= a); --=20 2.53.0 From nobody Mon Mar 23 23:29:32 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 Reviewed-by: Michal Privoznik --- 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 From nobody Mon Mar 23 23:29:32 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=1772835407; cv=none; d=zohomail.com; s=zohoarc; b=Il3HFB3MSjRjQOCGkXMAHH7CYU8+6N8mRM4GlXDjap88opDtCatNmWOXwoEf0ZwghyLvZsV5agnMC5HdQXt063Kc5VTTb9hz/ZK2VbKJbd1PMeg0Y3mo0I8AGIiU0hqwSc2M6Vb9NbtlIhjlSojo8uDjdXUf9TEeAqzuiHHAKwY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772835407; 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=rJWljYIWKp1su7+DjaEQpDn8u9DyL518YkUkiFoZ1Gk=; b=OLislPnrqDzW7EL8hR32GgXHwOcAUTMQl2TWTNl/20XNI97MzrPIOtPs3dFu35Ep2i7NAmkQNtF25+UquoXO1AhogS+UirFhW1kOwicuoXk5DfI9TxlEkKoo46TxF29gu+Nku+hRUM1zegHiZvJK24Pe+qkGZ3eFrO/S3Y03jnc= 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 1772835406981717.4378795323433; Fri, 6 Mar 2026 14:16:46 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id 14A93418DF; Fri, 6 Mar 2026 17:16:46 -0500 (EST) Received: from [172.19.199.12] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id BCF6441CF0; Fri, 6 Mar 2026 17:13:12 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id 095FE3F8A5; Fri, 6 Mar 2026 17:12:59 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.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 8C8CF418DE 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-124-vB22fsz4N1uNQ8idg4ukNQ-1; Fri, 06 Mar 2026 17:12:57 -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 478961956052 for ; Fri, 6 Mar 2026 22:12:56 +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 DA2C71958DD2 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=rJWljYIWKp1su7+DjaEQpDn8u9DyL518YkUkiFoZ1Gk=; b=HFOWPmRexzEVL090PaRGIH4DIE6R2fd7lyKy8UosSNZjKTx21skHuOMsVOKyr1A1/3beOf qeO9A1M7S3Y3cb7irMb4FEZKQnxT7+3OjKi5rOpHayHMaIHgNZ6iV3iZN7wuBmE9w+FcKS DGhoPySX03ygZGA9jx+dLo9Ma+2FMFg= X-MC-Unique: vB22fsz4N1uNQ8idg4ukNQ-1 X-Mimecast-MFC-AGG-ID: vB22fsz4N1uNQ8idg4ukNQ_1772835176 To: devel@lists.libvirt.org Subject: [PATCH 4/5] hyperv: Implement virDomainSnapshotCurrent()/virDomainHasCurrentSnapshot() Date: Fri, 6 Mar 2026 16:12:50 -0600 Message-ID: <20260306221251.929040-5-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: ayED7JknpwBeeAC4szYXrbi1d1yhu5VGI9XncGrtKCI_1772835176 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: MC2SYLU3XX6S6KG3EOP7BCLAL6M2Y7RY X-Message-ID-Hash: MC2SYLU3XX6S6KG3EOP7BCLAL6M2Y7RY 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: 1772835409587158500 Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: Jonathon Jongsma Reviewed-by: Michal Privoznik --- src/hyperv/hyperv_driver.c | 48 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index 4a4db0e76b..dd1248ced1 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -4235,6 +4235,52 @@ hypervParseInstanceIdFromParentPath(const char *obj_= path) } =20 =20 +static int +hypervDomainHasCurrentSnapshot(virDomainPtr domain, + unsigned int flags) +{ + g_autoptr(Msvm_VirtualSystemSettingData) vssd =3D NULL; + hypervPrivate *priv =3D domain->conn->privateData; + char uuid_string[VIR_UUID_STRING_BUFLEN]; + + virCheckFlags(0, -1); + + virUUIDFormat(domain->uuid, uuid_string); + + if (hypervGetMsvmVirtualSystemSettingDataFromUUID(priv, uuid_string, &= vssd) < 0) + return -1; + + return (vssd->data->Parent !=3D NULL); +} + + +static virDomainSnapshotPtr +hypervDomainSnapshotCurrent(virDomainPtr domain, + unsigned int flags) +{ + hypervPrivate *priv =3D domain->conn->privateData; + char uuid_string[VIR_UUID_STRING_BUFLEN]; + g_autoptr(Msvm_VirtualSystemSettingData) vssd =3D NULL; + g_autofree char* current_snapshot =3D NULL; + + virCheckFlags(0, NULL); + + virUUIDFormat(domain->uuid, uuid_string); + + if (hypervGetMsvmVirtualSystemSettingDataFromUUID(priv, uuid_string, &= vssd) < 0) + return NULL; + + current_snapshot =3D hypervParseInstanceIdFromParentPath(vssd->data->P= arent); + if (!current_snapshot) { + virReportError(VIR_ERR_NO_DOMAIN_SNAPSHOT, "%s", + _("the domain does not have a current snapshot")); + return NULL; + } + + return virGetDomainSnapshot(domain, current_snapshot); +} + + static char * hypervDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot, unsigned int flags) @@ -4345,6 +4391,8 @@ static virHypervisorDriver hypervHypervisorDriver =3D= { .domainListAllSnapshots =3D hypervDomainListAllSnapshots, /* 12.2.0 */ .domainSnapshotNum =3D hypervDomainSnapshotNum, /* 12.2.0 */ .domainSnapshotGetXMLDesc =3D hypervDomainSnapshotGetXMLDesc, /* 12.2.= 0 */ + .domainHasCurrentSnapshot =3D hypervDomainHasCurrentSnapshot, /* 12.2.= 0 */ + .domainSnapshotCurrent =3D hypervDomainSnapshotCurrent, /* 12.2.0 */ }; =20 =20 --=20 2.53.0 From nobody Mon Mar 23 23:29:32 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=1772835439; cv=none; d=zohomail.com; s=zohoarc; b=Rq8YbRj/gooCfiCtuEISzKsMh9aJFgWKqwtjNcXzUiHk1Hu7pmpSKRKORb0H8k2wBcDM7H3DeET/+28It/v4xgttSLqjvsns2q+oU8bZW3uEpibPbZ+B5mNVVsbnJSWOrYK0eyWtDsMqtRO5fwLYicWbILCXJTjI1G5QMbnXass= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1772835439; 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=eUb8OBRdF0sEFAu9cki+HJ5cVMJuWDKWiuNyYRAYRhM=; b=L5Pkth8PqSVOgg9HlPu0DXl0EN9xqP0rbzVN7WN0xkHoO0QCy1/3lnSKLZbVpQ5Cy2romCGVpGIc9GGGhmtenZCsVczsZ7kdJnp1wQResOcPB0irrivTk6IiI3DLH31OBeZZiVY4PtMo07ev5OTXMdj1xQAzzwRjbhJXBoQohnk= 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 1772835439553299.4417735859802; Fri, 6 Mar 2026 14:17:19 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 993) id EF2153FA60; Fri, 6 Mar 2026 17:17:18 -0500 (EST) Received: from [172.19.199.12] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 3CF3341A03; Fri, 6 Mar 2026 17:13:14 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 993) id B597D418DE; Fri, 6 Mar 2026 17:12:59 -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 41FB93F8A5 for ; Fri, 6 Mar 2026 17:12:59 -0500 (EST) Received: from mx-prod-mc-05.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-117-_78jj58DNjWON_HaJU3ALA-1; Fri, 06 Mar 2026 17:12:57 -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-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id E2DDF1956089 for ; Fri, 6 Mar 2026 22:12:56 +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 7F40D1958DC5 for ; Fri, 6 Mar 2026 22:12:56 +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=eUb8OBRdF0sEFAu9cki+HJ5cVMJuWDKWiuNyYRAYRhM=; b=aAf9cOMimSYEZd84uWYOjtP7b9oai5uL8fIBVT3ICzU3i2hYkQrVqVSIu1BMG4k/o9yZvL xgyRpJumdotREkL7pAQBFAKBd7QYG4y5F4o5/PpBMqkdwrJeRl7oBnFwGZmx3kNZCz8qfY hs4UK4nIliyVnX33djcf+CVcwh22y2Q= X-MC-Unique: _78jj58DNjWON_HaJU3ALA-1 X-Mimecast-MFC-AGG-ID: _78jj58DNjWON_HaJU3ALA_1772835177 To: devel@lists.libvirt.org Subject: [PATCH 5/5] hyperv: Implement virDomainSnapshotGetParent() Date: Fri, 6 Mar 2026 16:12:51 -0600 Message-ID: <20260306221251.929040-6-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: TzbFfpFLcg29iYO3jC9YkZAAbJyWpuHBDWWDMbcHlRw_1772835177 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: H7YIJT7F5JOOJID7SLXMPTARP74NOCCI X-Message-ID-Hash: H7YIJT7F5JOOJID7SLXMPTARP74NOCCI 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: 1772835442374154100 Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: Jonathon Jongsma Reviewed-by: Michal Privoznik --- src/hyperv/hyperv_driver.c | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index dd1248ced1..d3e17d7a16 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -4321,6 +4321,31 @@ hypervDomainSnapshotGetXMLDesc(virDomainSnapshotPtr = snapshot, } =20 =20 +static virDomainSnapshotPtr +hypervDomainSnapshotGetParent(virDomainSnapshotPtr snapshot, + unsigned int flags) +{ + g_autoptr(Msvm_VirtualSystemSettingData) vssd =3D NULL; + g_autofree char* parent_id =3D NULL; + + virCheckFlags(0, NULL); + + vssd =3D hypervDomainLookupSnapshotSD(snapshot->domain, snapshot->name= ); + if (!vssd) + return NULL; + + parent_id =3D hypervParseInstanceIdFromParentPath(vssd->data->Parent); + if (!parent_id) { + virReportError(VIR_ERR_NO_DOMAIN_SNAPSHOT, + _("snapshot '%1$s' does not have a parent"), + snapshot->name); + return NULL; + } + + return virGetDomainSnapshot(snapshot->domain, parent_id); +} + + static virHypervisorDriver hypervHypervisorDriver =3D { .name =3D "Hyper-V", .connectOpen =3D hypervConnectOpen, /* 0.9.5 */ @@ -4393,6 +4418,7 @@ static virHypervisorDriver hypervHypervisorDriver =3D= { .domainSnapshotGetXMLDesc =3D hypervDomainSnapshotGetXMLDesc, /* 12.2.= 0 */ .domainHasCurrentSnapshot =3D hypervDomainHasCurrentSnapshot, /* 12.2.= 0 */ .domainSnapshotCurrent =3D hypervDomainSnapshotCurrent, /* 12.2.0 */ + .domainSnapshotGetParent =3D hypervDomainSnapshotGetParent, /* 12.2.0 = */ }; =20 =20 --=20 2.53.0