From nobody Sun Apr 5 18:03: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=1774380068; cv=none; d=zohomail.com; s=zohoarc; b=ad7FxBSea/RWszRIg14a4iDyHQuM0IXBudqIOjpTbD/lWy0LLIZ4w3CR4lhxJAwPgyAjLyCEbHD4j6R0pF2NdvJa9LZPAEC7j6xfMwLyzU0IcLtHnMY6r8neVXKUD+2+4jQgi1sVNEHvz4rza93vllbpJ1lJKDIwXLxpcrbKNnA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1774380068; 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=i0gnaw7yzaxkVs8oy26km4TVfEhYRUDI9Vx/Ouc2+Fg=; b=fnvEPQ2wJY/etKYsW4zaRJIcO0a9s3TzRrevWycyr0zeIF1cxU+CS1Dvo1JGjRxanG2khvdngFOAyMkKwsAVvsaEWw5aDGMXQP1miciBK7dYqTsb82Lzwqo0jw0O19b54ARV7wQWZ/wzWVKaxe3lFa5bqq+ZNEf38WQwIpdIUQM= 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 1774380068971643.6203123678259; Tue, 24 Mar 2026 12:21:08 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 150553F328; Tue, 24 Mar 2026 15:21:08 -0400 (EDT) Received: from [172.19.199.12] (lists.libvirt.org [8.43.85.245]) by lists.libvirt.org (Postfix) with ESMTP id 680FA41A4F; Tue, 24 Mar 2026 15:17:57 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 993) id 69CEF417D6; Tue, 24 Mar 2026 15:17:48 -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 1B4823F287 for ; Tue, 24 Mar 2026 15:17:33 -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-340-yd_R2pq1Mq2c3m8V3f3fOg-1; Tue, 24 Mar 2026 15:17:30 -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 EE5EA1800371 for ; Tue, 24 Mar 2026 19:17:28 +0000 (UTC) Received: from himantopus.redhat.com (unknown [10.22.89.231]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8A15C19560B1 for ; Tue, 24 Mar 2026 19:17:28 +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=-4.7 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=1774379852; 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=i0gnaw7yzaxkVs8oy26km4TVfEhYRUDI9Vx/Ouc2+Fg=; b=Wpf4b6nTP/20r3ghQQ/DpnMkVcVKUzGdytOXygeLt5fe43xpUwcO4v8w9O1BcbV80gzZRw rLkCw22QumnPs5FYeim+Gowe5Tajqi+d070VWTmCEZspMBAVzK0A/R0x0FGaOhGAvP2gqG JTyr8Yd1skaW/o6yAAetPk3CoRmPVEY= X-MC-Unique: yd_R2pq1Mq2c3m8V3f3fOg-1 X-Mimecast-MFC-AGG-ID: yd_R2pq1Mq2c3m8V3f3fOg_1774379849 To: devel@lists.libvirt.org Subject: [PATCH v2 4/4] hyperv: Implement domainSnapshotCreateXML() Date: Tue, 24 Mar 2026 14:17:24 -0500 Message-ID: <20260324191724.2628460-5-jjongsma@redhat.com> In-Reply-To: <20260324191724.2628460-1-jjongsma@redhat.com> References: <20260324191724.2628460-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: 1nMF6wacIIZkF2T_cU-SPImBm5eJ9AyRwoWaXVTiFg8_1774379849 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: WPA5UECEUDQ5TGUTPEB4KXQBSJ5X2ZGF X-Message-ID-Hash: WPA5UECEUDQ5TGUTPEB4KXQBSJ5X2ZGF 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: 1774380070826158500 Content-Type: text/plain; charset="utf-8"; x-default="true" Signed-off-by: Jonathon Jongsma --- 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 841d9ccaa5..5417c8593f 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", + _("configuring specific disks is not yet supported = for hyperv")); + return NULL; + } + + if (def->memory) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("configuring snapshot memory is 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 +4580,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 --=20 2.53.0