On Thu, Mar 19, 2026 at 13:39:50 -0500, Jonathon Jongsma via Devel wrote: Please mention at least the limitations of the implementation in the commit message.
Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> --- 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, }
+static virDomainSnapshotPtr +hypervDomainSnapshotCreateXML(virDomainPtr domain, + const char *xmlDesc, + unsigned int flags) +{ + hypervPrivate *priv = domain->conn->privateData; + g_autoptr(Msvm_ComputerSystem) computerSystem = NULL; + g_autoptr(hypervInvokeParamsList) params = NULL; + g_autoptr(virDomainSnapshotDef) def = NULL; + g_autoptr(GHashTable) snapshotSettings = NULL; + g_auto(virBuffer) eprQuery = VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) query = VIR_BUFFER_INITIALIZER; + g_autoptr(Msvm_VirtualSystemSettingData) snapshot = NULL; + g_auto(WsXmlDocH) response = NULL; + char uuid_string[VIR_UUID_STRING_BUFLEN]; + + virCheckFlags(VIR_DOMAIN_SNAPSHOT_CREATE_QUIESCE, NULL); + + def = virDomainSnapshotDefParseString(xmlDesc, priv->xmlopt, NULL, NULL, 0); + if (!def) + return NULL; + + if (def->ndisks) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("disk snapshots not yet supported for hyperv"));
The message makes it sound like snapshotting disks is not supported, while what this check does is to prevent only configuring what to snapshot. If you don't want to allow configure what to snapshot, you also need to include rejection of the memory snapshot configuration because that doesn't seem to be configurable either.
+ return NULL; + } + + virUUIDFormat(domain->uuid, uuid_string); + + if (hypervMsvmComputerSystemFromDomain(domain, &computerSystem) < 0) + return NULL;
[...]
@@ -4493,6 +4574,7 @@ static virHypervisorDriver hypervHypervisorDriver = { .domainSnapshotCurrent = hypervDomainSnapshotCurrent, /* 12.2.0 */ .domainSnapshotGetParent = hypervDomainSnapshotGetParent, /* 12.2.0 */ .domainSnapshotDelete = hypervDomainSnapshotDelete, /* 12.2.0 */ + .domainSnapshotCreateXML = hypervDomainSnapshotCreateXML, /* 12.2.0 */ };
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; }
+static char* +hypervOutputParamReferenceId(WsXmlNodeH node) +{ + WsXmlNodeH selector_set = NULL; + WsXmlNodeH selector = NULL; + int i = 0; + + if (node) + selector_set = ws_xml_find_in_tree(node, XML_NS_WS_MAN, "SelectorSet", TRUE); + + if (selector_set) { + for (i = 0; (selector = ws_xml_get_child(selector_set, i, XML_NS_WS_MAN, "Selector")) != NULL; i++) { + if (STREQ_NULLABLE(ws_xml_find_attr_value(selector, NULL, "Name"), "InstanceID")) { + return ws_xml_get_node_text(selector); + } + } + } + return NULL; +} + + +/* + * hypervResponseGetOutputParam() + * + * Extracts an output parameter from a WMI method response and retrieves the + * referenced object. + * + * Handles both synchronous and asynchronous cases. When a method is + * synchronous, the parameter will be directly present in the response document. + * When the method returns asynchronously, we need to fetch the result parameter + * via its associations with the Msvm_ConcreteJob object referenced in the + * response document.
This doesn't seem to be entirely related to snapshots and even if yes it seems to be more of an infrastructure improvement rather than directly tied to the implemnetation. Thus it really looks like material for a separate patch.