From nobody Wed Apr 15 07:02:36 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; 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 38.145.34.151 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=1775848935; cv=none; d=zohomail.com; s=zohoarc; b=nnTyju5MyNtqQCMteNu3UHp7VzXgSZvyz+U6+efrtrKmNHlHsk384o1UeWuMM+j12gLOM1dMu1vi7+6l6efq4kqZ9VdGBxMfMQJAgkyzCbLz6Q9XV45qsRE6siHzMWEbxciZdy2DJaBXSCdFw5mK6NuvHldu1WM3MKeLw53xUiE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775848935; 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=m9NyMJocq+B/nMi/ZUuw4W5NPZGby8l4ENgaaZ9WrSM=; b=Ylp8wg3MUB/COVVc1Dn14YlBJd5dL6B0W5j5ZKF7drmGhTLP3LmjthCmQtstVZSPcgjP0Lo8/DD4OvalYIpJ0EXFO1RMjQbryamzrVKZFSSqcB7EF1SmwGlWcCueU8PiGrxhAoMA3y4YcpC56kd4J7DfZZbxZH2leyzNtmg+sgc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 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 [38.145.34.151]) by mx.zohomail.com with SMTPS id 1775848935067670.538565833778; Fri, 10 Apr 2026 12:22:15 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 27EF641872; Fri, 10 Apr 2026 15:22:13 -0400 (EDT) Received: from [172.19.199.3] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id A080041840; Fri, 10 Apr 2026 15:20:24 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 1D62B3F2FA; Fri, 10 Apr 2026 15:20:08 -0400 (EDT) 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 7761F3F872 for ; Fri, 10 Apr 2026 15:20:06 -0400 (EDT) Received: from mx-prod-mc-06.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-615-iNvbiGQkPh21eujvySMy5g-1; Fri, 10 Apr 2026 15:20:04 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 09CAD1800650 for ; Fri, 10 Apr 2026 19:20:04 +0000 (UTC) Received: from himantopus.redhat.com (unknown [10.22.81.121]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 995D43000C16 for ; Fri, 10 Apr 2026 19:20:03 +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.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_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=1775848806; 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=m9NyMJocq+B/nMi/ZUuw4W5NPZGby8l4ENgaaZ9WrSM=; b=Hjxk8Zy/jXPjhVqwQIXVrSLUgS0IfXx5TJrKlNGbj1SUIBLFU4H2PIkeoF8j7cULvPffTP TgqXG5deFSDrXJr/K6wWYZOUwKYIi+KXLg2Qut2Vgvyq2gxW9TdIgrswUP/IGftr6l+Xae oEK7sRGZj9p0bgGYGj+7paVBxhqJcO0= X-MC-Unique: iNvbiGQkPh21eujvySMy5g-1 X-Mimecast-MFC-AGG-ID: iNvbiGQkPh21eujvySMy5g_1775848804 To: devel@lists.libvirt.org Subject: [PATCH v3 1/4] hyperv: Add snapshot related WMI class definitions Date: Fri, 10 Apr 2026 14:19:58 -0500 Message-ID: <20260410192001.1842210-2-jjongsma@redhat.com> In-Reply-To: <20260410192001.1842210-1-jjongsma@redhat.com> References: <20260410192001.1842210-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: vToUACNzL3tuSrccySPQdKSOibLwOBbL-bocvN0v8sw_1775848804 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: WIGCDVYWRDJPVWYHTJ6UCRGXQEZZ7ASJ X-Message-ID-Hash: WIGCDVYWRDJPVWYHTJ6UCRGXQEZZ7ASJ 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: 1775848935690158500 Content-Type: text/plain; charset="utf-8"; x-default="true" Msvm_VirtualSystemSnapshotService and Msvm_VirtualSystemSnapshotSettingData Reviewed-by: Peter Krempa --- src/hyperv/hyperv_wmi.h | 11 +++++++ src/hyperv/hyperv_wmi_generator.input | 42 +++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/src/hyperv/hyperv_wmi.h b/src/hyperv/hyperv_wmi.h index 977245bed5..0560f83e0d 100644 --- a/src/hyperv/hyperv_wmi.h +++ b/src/hyperv/hyperv_wmi.h @@ -41,6 +41,17 @@ #define MSVM_VIRTUALSYSTEMSETTINGDATA_VIRTUALTYPE_SNAPSHOT \ "Microsoft:Hyper-V:Snapshot:Realized" =20 +#define MSVM_VIRTUALSYSTEMSNAPSHOTSERVICE_SELECTOR \ + "CreationClassName=3DMsvm_VirtualSystemSnapshotService" + +/* Msvm_VirtualSystemSnapshotSettingData ConsistencyLevel values */ +#define HYPERV_SNAPSHOT_CONSISTENCY_APP_CONSISTENT "1" /* VSS (productio= n checkpoint) */ +#define HYPERV_SNAPSHOT_CONSISTENCY_CRASH_CONSISTENT "2" /* Standard check= point */ + +/* Msvm_VirtualSystemSnapshotService CreateSnapshot SnapshotType values */ +#define HYPERV_SNAPSHOT_TYPE_FULL "2" /* Full snapshot including memo= ry if running */ +#define HYPERV_SNAPSHOT_TYPE_DISK_ONLY "3" /* Disk-only, no memory state */ + int hypervVerifyResponse(WsManClient *client, WsXmlDocH response, const char *detail); =20 diff --git a/src/hyperv/hyperv_wmi_generator.input b/src/hyperv/hyperv_wmi_= generator.input index 1f8d4258e1..fccbe9009f 100644 --- a/src/hyperv/hyperv_wmi_generator.input +++ b/src/hyperv/hyperv_wmi_generator.input @@ -1304,3 +1304,45 @@ class Msvm_KvpExchangeComponent string GuestExchangeItems[] string GuestIntrinsicExchangeItems[] end + +class Msvm_VirtualSystemSnapshotService + string InstanceID + string Caption + string Description + string ElementName + datetime InstallDate + string Name + uint16 OperationalStatus[] + string StatusDescriptions[] + string Status + uint16 HealthState + uint16 CommunicationStatus + uint16 DetailedStatus + uint16 OperatingStatus + uint16 PrimaryStatus + uint16 EnabledState + string OtherEnabledState + uint16 RequestedState + uint16 EnabledDefault + datetime TimeOfLastStateChange + uint16 AvailableRequestedStates[] + uint16 TransitioningToState + string SystemCreationClassName + string SystemName + string CreationClassName + string PrimaryOwnerName + string PrimaryOwnerContact + string StartMode + boolean Started +end + + +class Msvm_VirtualSystemSnapshotSettingData + string InstanceID + string Caption + string Description + string ElementName + uint8 ConsistencyLevel + boolean IgnoreNonSnapshottableDisks + uint8 GuestBackupType +end --=20 2.53.0 From nobody Wed Apr 15 07:02:36 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; 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 38.145.34.151 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=1775849005; cv=none; d=zohomail.com; s=zohoarc; b=B+PK8WkSsPVtcsC1RPZg7nIFIs06aygWMDU0ud/636dvOFJSJ1DTSf9twPrqVKxq48THUbBoI2VTTXqWmOhEoYDmcUsJe4RMfbQMDAMDsEfAQYnG4QNLjA5lTSvjem/U6NqP5n2fpYrsrslJrpzgw7GRpgymD2ZOhEBalDnDFSk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775849005; 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=BX1ic0Is/3ywEbeM6L2zgcIJgU30+P28xkxjJlj6b34=; b=JYwJ8oPLHNmhc7902UTUdi9SXp72Yrlxo7Yjy248ZpnqGz8pZBEQJBsqhowiWMazHJ1fcfbe08+0SUSrqRwiv1aaM29ntzY7mncpd8YHaTRvA2dg1wSwoaUaSDIfrH8XWHx9xgp+wusNv++ysV5zuyBebS05Tn7wnhfdG8U7QAY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 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 [38.145.34.151]) by mx.zohomail.com with SMTPS id 1775849005210775.5692280655778; Fri, 10 Apr 2026 12:23:25 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 8BAAE417FB; Fri, 10 Apr 2026 15:23:24 -0400 (EDT) Received: from [172.19.199.3] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id 30F33419AA; Fri, 10 Apr 2026 15:20:31 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 6E33C3F2FA; Fri, 10 Apr 2026 15:20:08 -0400 (EDT) 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 2F5313F2F7 for ; Fri, 10 Apr 2026 15:20:07 -0400 (EDT) Received: from mx-prod-mc-06.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-215-iz1ZXwhYMCyfuT11P7Ymuw-1; Fri, 10 Apr 2026 15:20:05 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B47B11801304 for ; Fri, 10 Apr 2026 19:20:04 +0000 (UTC) Received: from himantopus.redhat.com (unknown [10.22.81.121]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 51F063000C16 for ; Fri, 10 Apr 2026 19:20:04 +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.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_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=1775848806; 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=BX1ic0Is/3ywEbeM6L2zgcIJgU30+P28xkxjJlj6b34=; b=S0CT9vGGUFrVG+b/e6plaxlnnklf6v9FcbeFP+isbZnXNV/aJgN1RtTc6SxhixSifhmk/r nZLPoXBbeJeiD43a0G7bqlgyu7yzHgizfP9YapbbNbiHbGsamJ9Ov1Bdy+fluNCIgqMwLP IK7yE+Hh9Cui3ZoCxZqHLYuCBAQCjug= X-MC-Unique: iz1ZXwhYMCyfuT11P7Ymuw-1 X-Mimecast-MFC-AGG-ID: iz1ZXwhYMCyfuT11P7Ymuw_1775848804 To: devel@lists.libvirt.org Subject: [PATCH v3 2/4] hyperv: Implement domainSnapshotDelete() Date: Fri, 10 Apr 2026 14:19:59 -0500 Message-ID: <20260410192001.1842210-3-jjongsma@redhat.com> In-Reply-To: <20260410192001.1842210-1-jjongsma@redhat.com> References: <20260410192001.1842210-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: ywPnIBFU1LHxHAMsIhhJD-KCcTFR7ctXW9cYXIDklzk_1775848804 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: QIMWJX7HOLC3FUDTJZYHTEVKSHE5EK4N X-Message-ID-Hash: QIMWJX7HOLC3FUDTJZYHTEVKSHE5EK4N 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: 1775849006567154100 Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: Jonathon Jongsma Reviewed-by: Peter Krempa --- src/hyperv/hyperv_driver.c | 41 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index 7ad80bc8ec..d28c285df5 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -4163,6 +4163,46 @@ hypervDomainSnapshotLookupByName(virDomainPtr domain, } =20 =20 +static int +hypervDomainSnapshotDelete(virDomainSnapshotPtr snapshot, + unsigned int flags) +{ + hypervPrivate *priv =3D snapshot->domain->conn->privateData; + g_autoptr(hypervInvokeParamsList) params =3D NULL; + g_auto(virBuffer) eprQuery =3D VIR_BUFFER_INITIALIZER; + g_autoptr(Msvm_VirtualSystemSettingData) snapshotVSSD =3D NULL; + + virCheckFlags(0, -1); + + snapshotVSSD =3D hypervDomainLookupSnapshotSD(snapshot->domain, snapsh= ot->name); + if (!snapshotVSSD) + return -1; + + /* Build EPR for the snapshot to destroy */ + virBufferEscapeSQL(&eprQuery, + MSVM_VIRTUALSYSTEMSETTINGDATA_WQL_SELECT "WHERE Inst= anceID =3D '%s'", + snapshotVSSD->data->InstanceID); + + /* Destroy snapshot via DestroySnapshot method */ + params =3D hypervCreateInvokeParamsList("DestroySnapshot", + MSVM_VIRTUALSYSTEMSNAPSHOTSERVIC= E_SELECTOR, + Msvm_VirtualSystemSnapshotServic= e_WmiInfo); + + if (!params) + return -1; + + if (hypervAddEprParam(params, "AffectedSnapshot", &eprQuery, + Msvm_VirtualSystemSettingData_WmiInfo) < 0) + return -1; + + /* Invoke the method */ + if (hypervInvokeMethod(priv, ¶ms, NULL) < 0) + return -1; + + return 0; +} + + static int hypervDomainListAllSnapshots(virDomainPtr domain, virDomainSnapshotPtr **snaps, @@ -4714,6 +4754,7 @@ static virHypervisorDriver hypervHypervisorDriver =3D= { .domainSnapshotCurrent =3D hypervDomainSnapshotCurrent, /* 12.2.0 */ .domainSnapshotGetParent =3D hypervDomainSnapshotGetParent, /* 12.2.0 = */ .domainGetGuestInfo =3D hypervDomainGetGuestInfo, /* 12.3.0 */ + .domainSnapshotDelete =3D hypervDomainSnapshotDelete, /* 12.3.0 */ }; =20 =20 --=20 2.53.0 From nobody Wed Apr 15 07:02:36 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; 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 38.145.34.151 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=1775849140; cv=none; d=zohomail.com; s=zohoarc; b=ArJS0KUrSPL0m//2QUCDXI0B2GvjEWNELxL3ptNevTUPr6WxWWzUBlgPc0NuUT4Sxehf4ZYZJskN78c4oR3WiMBA2FEcNuprypZnBdqxjfOmGcnAZyxBKxiACmHUL/+FqzAI8hZZMGUdYw4Jp2/IEJRs3PH8V+GdTOt+IKO/S+4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775849140; 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=1tomSzMOFEXZEcpOPGCUEpua1y6Qrre24bLde6X0kW8=; b=MSAa+swBVTgb8PmcfbJFile2uLkm2N2lzeD2o9TIDlYLxXyzvEFggyZaRDrhpnq56CQjaTj6JDCi3/KAkQrBjwtZKEfeNJSEIozSkt0QByc4AW4kNNjwRY8yy5LcfyfwA3DvXtiJggkQw5+Xa5nZ4viwFADIyxcsaOvqAd021uY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 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 [38.145.34.151]) by mx.zohomail.com with SMTPS id 1775849140208299.9881739154164; Fri, 10 Apr 2026 12:25:40 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 16D823F872; Fri, 10 Apr 2026 15:25:39 -0400 (EDT) Received: from [172.19.199.3] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id 5102E41815; Fri, 10 Apr 2026 15:20:44 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id B95623F87D; Fri, 10 Apr 2026 15:20:22 -0400 (EDT) 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 310113F87D for ; Fri, 10 Apr 2026 15:20:11 -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-679-6MfcJSXVN9K_I3PZGGHjxw-1; Fri, 10 Apr 2026 15:20:06 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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 6CF7818002C0 for ; Fri, 10 Apr 2026 19:20:05 +0000 (UTC) Received: from himantopus.redhat.com (unknown [10.22.81.121]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0A5703000C1E for ; Fri, 10 Apr 2026 19:20:04 +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.7 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_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=1775848810; 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=1tomSzMOFEXZEcpOPGCUEpua1y6Qrre24bLde6X0kW8=; b=PEOtw39h0Di1h+eoOA08L5OaPo6t5w1Ja7JjJ7U4OXZ0HxRoPuQRpaHKrqBrNhwOARevmk 4kN0DyIv8sQ5ugHhnoutvlbLHO8oY5sDx9phry76nk5hZbq072YfB0y0qmV2G7+g5MzzRx FcTBczE7Ay1zTXg7WdwYzIHpVz6cR4Y= X-MC-Unique: 6MfcJSXVN9K_I3PZGGHjxw-1 X-Mimecast-MFC-AGG-ID: 6MfcJSXVN9K_I3PZGGHjxw_1775848805 To: devel@lists.libvirt.org Subject: [PATCH v3 3/4] hyperv: Add a utility function for getting method output params Date: Fri, 10 Apr 2026 14:20:00 -0500 Message-ID: <20260410192001.1842210-4-jjongsma@redhat.com> In-Reply-To: <20260410192001.1842210-1-jjongsma@redhat.com> References: <20260410192001.1842210-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: tfG1Pu9eSequX6BEWL6TJ5HJIl7Hzwmacn8-BoEqpNw_1775848805 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: STMB7PDYCZTYRYA2ZQXS2FLWOYO545F4 X-Message-ID-Hash: STMB7PDYCZTYRYA2ZQXS2FLWOYO545F4 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: 1775849140686158500 Content-Type: text/plain; charset="utf-8"; x-default="true" When invoking a method in WMI, it can either return synchronously or asynchronously (with return value 4096). In the latter case, the output parameters of the method are not present in the method response xml document. We have to fetch the output parameters via associations with the Job object that is returned in the method response. the hypervInvokeMethod() function already partially handles the async case by polling the job until it fails, completes successfully, or times out. This patch adds a utility function to fetch a named output parameter from a given method response xml document. It handles both synchronous and asynchronous cases. Signed-off-by: Jonathon Jongsma Reviewed-by: Peter Krempa --- src/hyperv/hyperv_wmi.c | 139 ++++++++++++++++++++++++++++++++++++++++ src/hyperv/hyperv_wmi.h | 6 ++ 2 files changed, 145 insertions(+) diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c index 3e161429d5..1329d03262 100644 --- a/src/hyperv/hyperv_wmi.c +++ b/src/hyperv/hyperv_wmi.c @@ -866,6 +866,145 @@ hypervInvokeMethod(hypervPrivate *priv, return 0; } =20 +static char* +hypervOutputParamReferenceId(WsXmlNodeH node) +{ + WsXmlNodeH selector_set =3D NULL; + WsXmlNodeH selector =3D NULL; + int i =3D 0; + + if (node) + selector_set =3D ws_xml_find_in_tree(node, XML_NS_WS_MAN, "Selecto= rSet", TRUE); + + if (selector_set) { + for (i =3D 0; (selector =3D ws_xml_get_child(selector_set, i, XML_= NS_WS_MAN, "Selector")) !=3D NULL; i++) { + if (STREQ_NULLABLE(ws_xml_find_attr_value(selector, NULL, "Nam= e"), "InstanceID")) { + return ws_xml_get_node_text(selector); + } + } + } + return NULL; +} + + +/* + * hypervResponseGetOutputParam() + * + * Extracts an output parameter from a WMI method response and retrieves t= he + * referenced object. + * + * Handles both synchronous and asynchronous cases. When a method is + * synchronous, the parameter will be directly present in the response doc= ument. + * When the method returns asynchronously, we need to fetch the result par= ameter + * via its associations with the Msvm_ConcreteJob object referenced in the + * response document. + * + * Parameters: + * @priv: hypervPrivate object associated with the connection + * response: The WMI method response document + * paramName: The output parameter name (e.g., "ResultingSnapshot") + * paramClass: The WMI class info for the expected result type + * outParam: return location for the named output parameter + * + * Returns 0 on success, -1 on failure. + */ +int +hypervResponseGetOutputParam(hypervPrivate *priv, + WsXmlDocH response, + const char *paramName, + hypervWmiClassInfo *paramClassInfo, + hypervObject **outParam) +{ + g_auto(virBuffer) query =3D VIR_BUFFER_INITIALIZER; + WsXmlNodeH body =3D NULL; + WsXmlNodeH output_node =3D NULL; + char *output_name =3D NULL; + char *provider_ns =3D NULL; + const char *rv_str =3D NULL; + int return_code; + int i =3D 0; + + body =3D ws_xml_get_soap_body(response); + if (!body) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Could not find SOAP Body in response")); + return -1; + } + + /* Find the $(METHOD)_OUTPUT node in the SOAP Body */ + for (i =3D 0; (output_node =3D ws_xml_get_child(body, i, NULL, NULL)) = !=3D NULL; i++) { + output_name =3D ws_xml_get_node_local_name(output_node); + if (output_name && g_str_has_suffix(output_name, "_OUTPUT")) + break; + output_node =3D NULL; + } + + if (!output_node) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Could not find _OUTPUT node in method response")= ); + return -1; + } + + provider_ns =3D ws_xml_get_node_name_ns(output_node); + + rv_str =3D ws_xml_get_node_text(ws_xml_get_child(output_node, 0, provi= der_ns, "ReturnValue")); + if (!rv_str || virStrToLong_i(rv_str, NULL, 10, &return_code) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Could not get ReturnValue from method response")= ); + return -1; + } + + if (return_code =3D=3D CIM_RETURNCODE_COMPLETED_WITH_NO_ERROR) { + /* if this was a synchronous response, the output parameter should= contain + * the id of an object, so we can simply look it up by its instanc= e ID */ + WsXmlNodeH param_node =3D ws_xml_get_child(output_node, 0, provide= r_ns, paramName); + const char *out_param_id =3D NULL; + + if (param_node) + out_param_id =3D hypervOutputParamReferenceId(param_node); + + if (!out_param_id) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not find output parameter '%1$s' in re= sponse"), + paramName); + return -1; + } + VIR_DEBUG("Method response was synchronous: %1$s =3D %2$s", paramN= ame, out_param_id); + virBufferAsprintf(&query, "SELECT * FROM %s ", paramClassInfo->nam= e); + virBufferEscapeSQL(&query, "WHERE InstanceID=3D'%s'", out_param_id= ); + } else if (return_code =3D=3D CIM_RETURNCODE_TRANSITION_STARTED) { + /* if this was an asynchronous response, we have to get the output + * parameter from its association with the async job */ + WsXmlNodeH job_node =3D ws_xml_get_child(output_node, 0, provider_= ns, "Job"); + const char *job_id =3D NULL; + + if (job_node) + job_id =3D hypervOutputParamReferenceId(job_node); + + if (!job_id) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Could not find Job ID in async method respon= se")); + return -1; + } + VIR_DEBUG("Method response was asynchronous. Job ID =3D %1$s", job= _id); + virBufferEscapeSQL(&query, + "ASSOCIATORS OF {Msvm_ConcreteJob.InstanceID=3D'%s'} ", + job_id); + virBufferAsprintf(&query, + "WHERE AssocClass =3D Msvm_AffectedJobElement " + "ResultClass =3D %s", + paramClassInfo->name); + } else { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unexpected return code %1$d in method response"), + return_code); + return -1; + } + + hypervGetWmiClassList(priv, paramClassInfo, &query, outParam); + return 0; +} + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *= * * * Object */ diff --git a/src/hyperv/hyperv_wmi.h b/src/hyperv/hyperv_wmi.h index 0560f83e0d..36ca85a592 100644 --- a/src/hyperv/hyperv_wmi.h +++ b/src/hyperv/hyperv_wmi.h @@ -166,6 +166,12 @@ int hypervInvokeMethod(hypervPrivate *priv, hypervInvokeParamsList **paramsPtr, WsXmlDocH *res); =20 +int hypervResponseGetOutputParam(hypervPrivate *priv, + WsXmlDocH response, + const char *paramName, + hypervWmiClassInfo *paramClassInfo, + hypervObject **outParam); + /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *= * * * CIM/Msvm_ReturnCode */ --=20 2.53.0 From nobody Wed Apr 15 07:02:36 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 as permitted sender) client-ip=38.145.34.151; 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 38.145.34.151 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=1775849061; cv=none; d=zohomail.com; s=zohoarc; b=lZNbz7mZFOfp8jbyo0ZzOhYKJF6Cp5NBRkGigBbSJ5tslGSmSHYADMj2Y5EKlLHF+I9rwxC9vkBT3aJp0yAty+UvdzxUGVSN9hBM8xqjq5XoaDGkcsU7g0ecIKCRk2k4jYaObXrg0ZiD8QzcBpd6Xo5L9d7C3qdUK/kR8goicYU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1775849061; 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=Zp/zzZAPG3ErA3FGOBnclSkDd4Z8NKsAMS1EKMhWeaE=; b=AtgbTvR7zyYJSZqVx+YH/deVodeMpu6RC+7mTl/7arcmsx/Mo9ZXPlR0peP8ZFjCKRhXLIPZuOfSswQjLP4rkiynMjxD3SMRfGydScEp/BrPslcEGKgzRg3vOsBC1QAlMLWHqLmv62HL6g79CdQAjH6D/uR38HUE8oSADPa/fK8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 38.145.34.151 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 [38.145.34.151]) by mx.zohomail.com with SMTPS id 1775849061928161.0402427211942; Fri, 10 Apr 2026 12:24:21 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id B38C43F8AF; Fri, 10 Apr 2026 15:24:20 -0400 (EDT) Received: from [172.19.199.3] (unknown [10.16.107.18]) by lists.libvirt.org (Postfix) with ESMTP id 14240417FA; Fri, 10 Apr 2026 15:20:37 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 570863F872; Fri, 10 Apr 2026 15:20:09 -0400 (EDT) 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 AAAC13F2F7 for ; Fri, 10 Apr 2026 15:20:08 -0400 (EDT) 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-681-D1HzvgVQNGmM10qzptDxBw-1; Fri, 10 Apr 2026 15:20:06 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (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 166451955D9C for ; Fri, 10 Apr 2026 19:20:06 +0000 (UTC) Received: from himantopus.redhat.com (unknown [10.22.81.121]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id A6D6E3000C1D for ; Fri, 10 Apr 2026 19:20:05 +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=0.6 required=5.0 tests=BAYES_00,DKIM_INVALID, DKIM_SIGNED,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL,RCVD_IN_SBL_CSS,RCVD_IN_VALIDITY_CERTIFIED_BLOCKED, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_PASS autolearn=no autolearn_force=no version=4.0.1 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1775848808; 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=Zp/zzZAPG3ErA3FGOBnclSkDd4Z8NKsAMS1EKMhWeaE=; b=a/+1qx9pZ4uST3FxDz39ZW6VHTosw/qoTxxJw++D1Pgk4/tz5YAb/mNKtEhLutvLml+OaE CmzC14pHUd+Ld1p23V3+0ya5YMOCzA89knhwWxcYVoltAzftt6XwIzsMSGveWxBIDRkfkX ZlF4GsrnpN1dpbwhL7gMMu2eJm4rzkQ= X-MC-Unique: D1HzvgVQNGmM10qzptDxBw-1 X-Mimecast-MFC-AGG-ID: D1HzvgVQNGmM10qzptDxBw_1775848806 To: devel@lists.libvirt.org Subject: [PATCH v3 4/4] hyperv: Implement domainSnapshotCreateXML() Date: Fri, 10 Apr 2026 14:20:01 -0500 Message-ID: <20260410192001.1842210-5-jjongsma@redhat.com> In-Reply-To: <20260410192001.1842210-1-jjongsma@redhat.com> References: <20260410192001.1842210-1-jjongsma@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: 5OfcOG2YRAGWUyvpLFD_EAsg2rF25wv7bvFgeESCVMs_1775848806 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: HWXGWJONSI2T53FRPKEG3RWC6SVZEZ4Q X-Message-ID-Hash: HWXGWJONSI2T53FRPKEG3RWC6SVZEZ4Q 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: 1775849064261158500 Content-Type: text/plain; charset="utf-8"; x-default="true" The Hyper-V driver does not support specifying or in the snapshot xml and rejects those configurations. Signed-off-by: Jonathon Jongsma Reviewed-by: Peter Krempa --- src/hyperv/hyperv_driver.c | 88 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index d28c285df5..2d55743769 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -4163,6 +4163,93 @@ hypervDomainSnapshotLookupByName(virDomainPtr domain, } =20 =20 +static virDomainSnapshotPtr +hypervDomainSnapshotCreateXML(virDomainPtr domain, + const char *xmlDesc, + unsigned int flags) +{ + hypervPrivate *priv =3D domain->conn->privateData; + g_autoptr(Msvm_ComputerSystem) computerSystem =3D NULL; + g_autoptr(hypervInvokeParamsList) params =3D NULL; + g_autoptr(virDomainSnapshotDef) def =3D NULL; + g_autoptr(GHashTable) snapshotSettings =3D NULL; + g_auto(virBuffer) eprQuery =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) query =3D VIR_BUFFER_INITIALIZER; + g_autoptr(Msvm_VirtualSystemSettingData) snapshot =3D NULL; + g_auto(WsXmlDocH) response =3D NULL; + char uuid_string[VIR_UUID_STRING_BUFLEN]; + + virCheckFlags(VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE, NULL); + + def =3D virDomainSnapshotDefParseString(xmlDesc, priv->xmlopt, NULL, N= ULL, 0); + if (!def) + return NULL; + + if (def->ndisks) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("hyperv does not support per-disk snapshot config= uration")); + return NULL; + } + + if (def->memory =3D=3D VIR_DOMAIN_SNAPSHOT_LOCATION_EXTERNAL) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("hyperv does not support external memory snapshot= s")); + return NULL; + } + + virUUIDFormat(domain->uuid, uuid_string); + + if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) + return NULL; + + virBufferEscapeSQL(&eprQuery, + MSVM_COMPUTERSYSTEM_WQL_SELECT "WHERE Name =3D '%s'= ", + uuid_string); + + params =3D hypervCreateInvokeParamsList("CreateSnapshot", + MSVM_VIRTUALSYSTEMSNAPSHOTSERVIC= E_SELECTOR, + Msvm_VirtualSystemSnapshotServic= e_WmiInfo); + if (!params) + return NULL; + + if (hypervAddEprParam(params, "AffectedSystem", &eprQuery, + Msvm_ComputerSystem_WmiInfo) < 0) + return NULL; + + snapshotSettings =3D hypervCreateEmbeddedParam(Msvm_VirtualSystemSnaps= hotSettingData_WmiInfo); + if (!snapshotSettings) + return NULL; + + if (hypervSetEmbeddedProperty(snapshotSettings, "ConsistencyLevel", + (flags & VIR_DOMAIN_SNAPSHOT_CREATE_QUIE= SCE) ? + HYPERV_SNAPSHOT_CONSISTENCY_APP_CONSISTE= NT : + HYPERV_SNAPSHOT_CONSISTENCY_CRASH_CONSIS= TENT) < 0) + return NULL; + + if (hypervAddEmbeddedParam(params, "SnapshotSettings", &snapshotSettin= gs, + Msvm_VirtualSystemSnapshotSettingData_WmiIn= fo) < 0) + return NULL; + + hypervAddSimpleParam(params, "SnapshotType", HYPERV_SNAPSHOT_TYPE_FULL= ); + + if (hypervInvokeMethod(priv, ¶ms, &response) < 0) + return NULL; + + /* The CreateSnapshot method will generally return an async job rather + * than returning the 'ResultingSnapshot' output parameter directly + * in the response. Although hypervInvokeMethod() polls the async job = to + * completion when this occurs, the response will not include the outp= ut + * parameters. So we use this helper function to build a query to fetc= h the + * resulting object from the async job associations. */ + if (hypervResponseGetOutputParam(priv, response, "ResultingSnapshot", + Msvm_VirtualSystemSettingData_WmiInfo, + (hypervObject**) &snapshot) < 0) + return NULL; + + return virGetDomainSnapshot(domain, snapshot->data->InstanceID); +} + + static int hypervDomainSnapshotDelete(virDomainSnapshotPtr snapshot, unsigned int flags) @@ -4755,6 +4842,7 @@ static virHypervisorDriver hypervHypervisorDriver =3D= { .domainSnapshotGetParent =3D hypervDomainSnapshotGetParent, /* 12.2.0 = */ .domainGetGuestInfo =3D hypervDomainGetGuestInfo, /* 12.3.0 */ .domainSnapshotDelete =3D hypervDomainSnapshotDelete, /* 12.3.0 */ + .domainSnapshotCreateXML =3D hypervDomainSnapshotCreateXML, /* 12.3.0 = */ }; =20 =20 --=20 2.53.0