From nobody Mon Mar 23 23:26:15 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=1773945683; cv=none; d=zohomail.com; s=zohoarc; b=dfwvAAx4bK++qYIKVsVuymU89A+Etlwi05elH6XSM5TcJKqJ/mf9dh6Y9bc03HukWBDz9OxU46moHqqwVJoKQ9/imC57oR+pshT+vFs/OEEZW4L+5v5g26i+DMakIs72VJ5AcK1sBqnt1NriZbmuArjdMTYvKk391WOrg06Wxc4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773945683; 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=zVS6nU5avUyzouQojb6rmrkl5R1E2OoiUGmqA7IrzSY=; b=WYhLwWSRizBFNnWDfBxZ8X2ci8xX/udy5A7WkXB4xMNdwNHgbebUFFV21l+XLgCno+pUYszUHPklTR567Ln2OiX+69e2G5YGoTlRj3eMYnLWLuaMVEBoszOzVyDBg1rm9ypKswqRvlQXAoXYQQLM+klJOmjjiH4GZ3IfUJvY0DY= 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 1773945683893252.46918290724977; Thu, 19 Mar 2026 11:41:23 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id A916F418C8; Thu, 19 Mar 2026 14:41:22 -0400 (EDT) Received: from [172.19.199.12] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id F047F41B29; Thu, 19 Mar 2026 14:40:02 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 65B5E3F84A; Thu, 19 Mar 2026 14:39:56 -0400 (EDT) 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 E8B043F2BF for ; Thu, 19 Mar 2026 14:39:55 -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-456-C7O0cZHCMYqgP5LGf7vrzA-1; Thu, 19 Mar 2026 14:39:54 -0400 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 5A39F180044D for ; Thu, 19 Mar 2026 18:39:53 +0000 (UTC) Received: from himantopus.redhat.com (unknown [10.22.66.78]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D23151955F21 for ; Thu, 19 Mar 2026 18:39:52 +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=1773945595; 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=zVS6nU5avUyzouQojb6rmrkl5R1E2OoiUGmqA7IrzSY=; b=TVyZVCvuJl3RK4sACarcyxb32wKc0p8cvPWBHvMgCmN+89Lw3ZFhj6IVvbN0TZkk2TlJm7 buGZJ2rjjR9BCMq1Vy0OfROU+5QwmAe9g+EkMk7grTm8w+W1A6UViNOZPGADqWlOXhmMRP S7fDoR+un7Jm2psXu4pFyoxBN+xNRDE= X-MC-Unique: C7O0cZHCMYqgP5LGf7vrzA-1 X-Mimecast-MFC-AGG-ID: C7O0cZHCMYqgP5LGf7vrzA_1773945593 To: devel@lists.libvirt.org Subject: [PATCH 1/3] hyperv: Add snapshot related WMI class definitions Date: Thu, 19 Mar 2026 13:39:48 -0500 Message-ID: <20260319183950.2100933-2-jjongsma@redhat.com> In-Reply-To: <20260319183950.2100933-1-jjongsma@redhat.com> References: <20260319183950.2100933-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: nuD4YT3sGq9berhaplFJNjb_3xGOMPDkkvu7fW-gH8w_1773945593 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: RUZWEESUA4SQRFCFVUA2GFRGFHQBKCO2 X-Message-ID-Hash: RUZWEESUA4SQRFCFVUA2GFRGFHQBKCO2 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: 1773945686162154100 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 b3cd9d19fb..4ba69aa77a 100644 --- a/src/hyperv/hyperv_wmi_generator.input +++ b/src/hyperv/hyperv_wmi_generator.input @@ -1261,3 +1261,45 @@ class Msvm_SecuritySettingData boolean EncryptStateAndVmMigrationTraffic boolean VirtualizationBasedSecurityOptOut 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 Mon Mar 23 23:26:15 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=1773945718; cv=none; d=zohomail.com; s=zohoarc; b=GWS5xQMRzo0kupwo5rJqVdlF7dmc7IZQFH5ZPfsZQQ+ggtl6CYdUnwn7U9bK470rpk3IA0QCI1WH0dpqpFZbErLyZbqYJ1bwlAc2/jC1uZOJR+OEiB0ahb7z+ZozfTKlN2TQuflNV6BohzkyixcHdYoRN0MJQmPBqrh3foZsOMM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773945718; 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=vwZUaPqkc8K00cP1Z1z3s7o+gPFnJuQ/q0JOinHNaso=; b=F0FyW+t8/t1gja8PUvAYL16Ss6j7xUE95wvpWlK8bRjR/1Pn8/1KUv1FuxoLLfo5SmZAXGFDgcanBDRkj4Nu1FVZ8SYTpoaAjC/M15Iu36lVckalOeEM2pklJGZZke1EJ/v4KHMcEw298TNmY+Jyif1tqGeI5qeFjIwVHddBI/M= 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 1773945718116586.1440242440738; Thu, 19 Mar 2026 11:41:58 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 4D9BB418AA; Thu, 19 Mar 2026 14:41:57 -0400 (EDT) Received: from [172.19.199.12] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 1EABA41B79; Thu, 19 Mar 2026 14:40:04 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id E12D73F86D; Thu, 19 Mar 2026 14:39:56 -0400 (EDT) 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 A7CE13F2BF for ; Thu, 19 Mar 2026 14:39:56 -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-342--yNJOUgmOk69b_J1aiMyHw-1; Thu, 19 Mar 2026 14:39:54 -0400 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-06.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id F37EE1800283 for ; Thu, 19 Mar 2026 18:39:53 +0000 (UTC) Received: from himantopus.redhat.com (unknown [10.22.66.78]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 7CCD81955F21 for ; Thu, 19 Mar 2026 18:39: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=1773945596; 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=vwZUaPqkc8K00cP1Z1z3s7o+gPFnJuQ/q0JOinHNaso=; b=FEY76RkR8/fUZHjIZfAJ0bHeY963lN8vk6isM9ADPm+lQjIB2BfPt6qHPbjPhFHK6W1PKs EJzad+4FNQannda7uRWaJGSMRhLMLo/kJ3dGqXccVk66tLG4go599MjAqSGTmSaEqlKIOa Ml86TliQgLvmhRtZ3lEqDH3052H4Eio= X-MC-Unique: -yNJOUgmOk69b_J1aiMyHw-1 X-Mimecast-MFC-AGG-ID: -yNJOUgmOk69b_J1aiMyHw_1773945594 To: devel@lists.libvirt.org Subject: [PATCH 2/3] hyperv: Implement domainSnapshotDelete() Date: Thu, 19 Mar 2026 13:39:49 -0500 Message-ID: <20260319183950.2100933-3-jjongsma@redhat.com> In-Reply-To: <20260319183950.2100933-1-jjongsma@redhat.com> References: <20260319183950.2100933-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: -PsMeTttxKnRZuOvs9XBQkQRH78m9aVK8T5rsGjWkR8_1773945594 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: ELODVKIM6FMVCICO6Y7MXZLYYNFWCOC2 X-Message-ID-Hash: ELODVKIM6FMVCICO6Y7MXZLYYNFWCOC2 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: 1773945719669158500 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 18e06f0e2a..841d9ccaa5 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, @@ -4452,6 +4492,7 @@ static virHypervisorDriver hypervHypervisorDriver =3D= { .domainHasCurrentSnapshot =3D hypervDomainHasCurrentSnapshot, /* 12.2.= 0 */ .domainSnapshotCurrent =3D hypervDomainSnapshotCurrent, /* 12.2.0 */ .domainSnapshotGetParent =3D hypervDomainSnapshotGetParent, /* 12.2.0 = */ + .domainSnapshotDelete =3D hypervDomainSnapshotDelete, /* 12.2.0 */ }; =20 =20 --=20 2.53.0 From nobody Mon Mar 23 23:26:15 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=1773945774; cv=none; d=zohomail.com; s=zohoarc; b=RoTX09WIuv3b4ZknVO0A7yTvWMY5d3wR1U6i82pU6KjNqaEJ8mBWKKMuD56xEHK/cdOFrcTgWIgI1ZpF4Vryd5yjrPKGZ4JEq05d7HIEHNMXMsa/35BRyd+f3JIw2WxEaz7uSKFSg1aFdzcRPRfgqH9hJu0GYPg1pbtV1Ae6vac= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1773945774; 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=mZg8bxZqTBff4BnDwVbIqKW1Xu2nC+ba31iMBRTE6uE=; b=YTiVJC2nmDvrIiMyxH/0TrLk0m/ntienTeQXBPG6ne44dGwir7JaFSqmyWAdIdB8XQxL7OwdVlKCPcG/+PVRzYEoQ8G6865QhzQMOwi9tfj6yC9tefvxo9lbSca0hGLK/jTiQb3t6Jo9oU449L90bfJMqA7a/eQ42ZaxgBecgY0= 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 1773945774792857.7781306057805; Thu, 19 Mar 2026 11:42:54 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 331B041829; Thu, 19 Mar 2026 14:42:54 -0400 (EDT) Received: from [172.19.199.12] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 6482941BC8; Thu, 19 Mar 2026 14:40:07 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id EB1B93F836; Thu, 19 Mar 2026 14:39:57 -0400 (EDT) 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 7925A3F2BF for ; Thu, 19 Mar 2026 14:39:57 -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-404-yKgrE5T5NrKOpAkG2PTQYQ-1; Thu, 19 Mar 2026 14:39:56 -0400 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 2F31C180044D for ; Thu, 19 Mar 2026 18:39:55 +0000 (UTC) Received: from himantopus.redhat.com (unknown [10.22.66.78]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 99AD71955F21 for ; Thu, 19 Mar 2026 18:39: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=1773945597; 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=mZg8bxZqTBff4BnDwVbIqKW1Xu2nC+ba31iMBRTE6uE=; b=AqV778wXFf5qxP6JOJnXGiSrfosRXKYy0swHE03BDFdt7Z0VO6q+ObbMlWC+CI/x2i8xFz o1KDn25etbFzf7HubA5eNs9+9+DEYNrRCt4aTZ2QzHy/KvGROnSj27sikXpw8vPfMNBhkV SQ69Xlzn1dYSEE1hzKm7loHGSWBV1WY= X-MC-Unique: yKgrE5T5NrKOpAkG2PTQYQ-1 X-Mimecast-MFC-AGG-ID: yKgrE5T5NrKOpAkG2PTQYQ_1773945595 To: devel@lists.libvirt.org Subject: [PATCH 3/3] hyperv: Implement domainSnapshotCreateXML() Date: Thu, 19 Mar 2026 13:39:50 -0500 Message-ID: <20260319183950.2100933-4-jjongsma@redhat.com> In-Reply-To: <20260319183950.2100933-1-jjongsma@redhat.com> References: <20260319183950.2100933-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: o5RQecHlHoSWPDu9hV5U_yQ6dShzRJeGiV54D2Bve40_1773945595 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: JPHAF567KMC7GCGCZ7S4463ML56IKSFS X-Message-ID-Hash: JPHAF567KMC7GCGCZ7S4463ML56IKSFS 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: 1773945776505154100 Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: Jonathon Jongsma Reviewed-by: Peter Krempa --- src/hyperv/hyperv_driver.c | 82 ++++++++++++++++++++++ src/hyperv/hyperv_wmi.c | 139 +++++++++++++++++++++++++++++++++++++ src/hyperv/hyperv_wmi.h | 6 ++ 3 files changed, 227 insertions(+) diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c index 841d9ccaa5..12af6bd337 100644 --- a/src/hyperv/hyperv_driver.c +++ b/src/hyperv/hyperv_driver.c @@ -4163,6 +4163,87 @@ 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", + _("disk snapshots not yet supported for hyperv")); + 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) @@ -4493,6 +4574,7 @@ static virHypervisorDriver hypervHypervisorDriver =3D= { .domainSnapshotCurrent =3D hypervDomainSnapshotCurrent, /* 12.2.0 */ .domainSnapshotGetParent =3D hypervDomainSnapshotGetParent, /* 12.2.0 = */ .domainSnapshotDelete =3D hypervDomainSnapshotDelete, /* 12.2.0 */ + .domainSnapshotCreateXML =3D hypervDomainSnapshotCreateXML, /* 12.2.0 = */ }; =20 =20 diff --git a/src/hyperv/hyperv_wmi.c b/src/hyperv/hyperv_wmi.c index dab7abe8cf..9809eac1e5 100644 --- a/src/hyperv/hyperv_wmi.c +++ b/src/hyperv/hyperv_wmi.c @@ -867,6 +867,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