Commit Graph

179 Commits

Author SHA1 Message Date
Matt Coleman
7795712ddc hyperv: call openwsman's ws_serializer_free_mem
This should have been included with the upgrade to openwsman 2.6.3.

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-03 11:30:11 +01:00
Matt Coleman
3b52bcfa43 hyperv: minor formatting fix in hyperv_wmi.h
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-03 11:29:38 +01:00
Matt Coleman
d2ab8a530c hyperv: consistent names for SettingData functions
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-03 11:29:14 +01:00
Matt Coleman
87e062415f hyperv: move hypervGetProcSDByVSSDInstanceId to hyperv_wmi.c
This places it next to existing related functions.

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-03 11:28:57 +01:00
Matt Coleman
add5cd8a3c hyperv: move hypervGetWmiClass to hyperv_wmi.h
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-03 11:28:25 +01:00
Matt Coleman
58ae6be649 hyperv: WMI class list function general cleanup
* use the same section comment in the header and code
* place the items in the same relative location within the .h and .c
* one parameter per line for multiline function definitions

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-03 11:27:37 +01:00
Matt Coleman
db294a7eec hyperv: remove spaces after hypervObject* casts
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-03 11:26:15 +01:00
Matt Coleman
f5dadf9a71 hyperv: g_autofree username and password in hypervConnectOpen()
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-03 11:24:47 +01:00
Matt Coleman
b1a06feed7 hyperv: do not overwrite errors from hypervInvokeMethod()
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-02 18:44:21 +01:00
Matt Coleman
f1c406a9aa hyperv: reduce duplicate code for Msvm_ComputerSystem lookups
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-02 18:44:21 +01:00
Matt Coleman
855af506d3 hyperv: remove unneeded braces in hypervDomainGetInfo() and hypervDomainGetXMLDesc()
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-02 18:44:21 +01:00
Matt Coleman
a7fc186fd2 hyperv: remove duplicate function hypervGetMemSDByVSSDInstanceId()
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-02 18:44:21 +01:00
Matt Coleman
e08393e339 hyperv: remove duplicate function hypervGetVSSDFromUUID()
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-02 18:44:21 +01:00
Matt Coleman
a3f6592e1e hyperv: reformat WQL query strings
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-11-02 18:44:21 +01:00
Michal Privoznik
c383dc948e hyperv: Reformat
This is mostly opening hyperv driver sources in vim, selecting
everything, hitting reformat and then fixing a very few places.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Matt Coleman <matt@datto.com>
2020-10-22 16:11:56 +02:00
Michal Privoznik
e8fd9c91c2 hyperv: Use two empty lines between functions
In some places we separate functions with only one line, in
others with three lines and the rest uses two lines.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Matt Coleman <matt@datto.com>
2020-10-22 16:11:56 +02:00
Michal Privoznik
864d79e452 hyperv: Use hypervRequestStateChange() in hypervDomainSuspend()
A few commits ago, hypervRequestStateChange() helper was
introduced which has exactly the same code as a part of
hypervDomainSuspend(). Deduplicate by calling the helper.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Matt Coleman <matt@datto.com>
2020-10-22 16:11:56 +02:00
Michal Privoznik
458e2d6fc5 hyperv: Don't overwrite errors from hypervCreateInvokeParamsList()
The hypervCreateInvokeParamsList() function sets an error on a
failure, therefore there is no need to report another error in
callers.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Matt Coleman <matt@datto.com>
2020-10-22 16:11:56 +02:00
Peter Krempa
b82dfe3ba7 Replace all instances of 'virHashCreate' with 'virHashNew'
It doesn't make much sense to configure the bucket count in the hash
table for each case specifically. Replace all calls of virHashCreate
with virHashNew which has a pre-set size and remove virHashCreate
completely.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
2020-10-22 15:02:46 +02:00
Matt Coleman
747e0888a0 hyperv: fix domainManagedSave on Hyper-V V2
Signed-off-by: Matt Coleman <matt@datto.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-21 14:20:52 +02:00
Matt Coleman
a9f1a798fd hyperv: fix domainSuspend and domainResume on Hyper-V V2
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-21 14:20:50 +02:00
Matt Coleman
d4f09baa6b hyperv: implement domainShutdown and domainShutdownFlags
Co-authored-by: Sri Ramanujam <sramanujam@datto.com>
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-21 14:20:47 +02:00
Matt Coleman
8943b14838 hyperv: implement domainReboot and domainReset
Co-authored-by: Sri Ramanujam <sramanujam@datto.com>
Signed-off-by: Matt Coleman <matt@datto.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-21 14:20:44 +02:00
Matt Coleman
7bf302fb63 hyperv: implement nodeGetFreeMemory
Co-authored-by: Sri Ramanujam <sramanujam@datto.com>
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-21 14:20:41 +02:00
Matt Coleman
cc9248cc6c hyperv: implement domainSetAutostart
Co-authored-by: Sri Ramanujam <sramanujam@datto.com>
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-21 14:20:39 +02:00
Matt Coleman
26f5609e70 hyperv: avoid overwriting errors from hypervGetWmiClass()
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-21 14:20:37 +02:00
Matt Coleman
5140f97bcc hyperv: enable usage of g_autoptr for hypervInvokeParamsList
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-21 14:20:33 +02:00
Michal Privoznik
d8960bff71 hyverv: hypervCreateEmbeddedParam: Rework items counting
It's not necessarily clear, why we need to create the hash table
as big as number of fields we want to store, but nevertheless,
the code can be written a bit better. The @count should be type
of size_t and could be used directly in the loop that counts the
fields.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Matt Coleman <matt@datto.com>
2020-10-20 12:12:21 +02:00
Michal Privoznik
7f238274bb hyperv: Drop needless error label in hypervCreateEmbeddedParam()
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Matt Coleman <matt@datto.com>
2020-10-20 12:09:57 +02:00
Michal Privoznik
28065881f7 hyperv: Use g_auto() for virHashTable in hypervCreateEmbeddedParam
This will allow us to drop 'error' label later.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-20 12:09:12 +02:00
Michal Privoznik
b54b229e74 hyperv: Accept const @value in hypervSetEmbeddedProperty()
The hypervSetEmbeddedProperty() function is used to update a
value for given property in a list of properties created by
hypervCreateEmbeddedParam(). The list is nothing fancy - it's a
virHashTable that has NULL as dataFree callback => the table does
not own the value. This is not that obvious since
hypervSetEmbeddedProperty() accepts a non-const pointer. This
fact makes it unnecessary hard to consume, e.g. if we wanted to
pass a stack allocated string.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Matt Coleman <matt@datto.com>
2020-10-20 12:05:50 +02:00
Michal Privoznik
07cec18a51 hyperv: Simplify @memResource freeing in hypervDomainSetMemoryFlags()
Now, that ownership transfer of hypervSetEmbeddedProperty() is
clear, we can use automatic freeing of the hash table.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Matt Coleman <matt@datto.com>
2020-10-19 11:13:10 +02:00
Michal Privoznik
e0a09c243c hyperv: Make it obvious that hypervAddEmbeddedParam() consumes an argument
Upon successful return hypervAddEmbeddedParam() transfers
ownership of @table argument to @params. But because it takes
only simple pointer (which hides this ownership transfer) it
doesn't clear the @table pointer.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Matt Coleman <matt@datto.com>
2020-10-19 11:13:10 +02:00
Michal Privoznik
49562e92e8 hyperv: Drop needless label in hypervDomainSetMemoryFlags()
Now, that hypervInvokeMethod() clears the passed pointer we don't
need a special cleanup label ('params_cleanup') that handles
non-obvious ownership transfer.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Matt Coleman <matt@datto.com>
2020-10-19 11:13:10 +02:00
Michal Privoznik
0dbfb9c5a6 hyperv: Reindent hypervInvokeMethod() body
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Matt Coleman <matt@datto.com>
2020-10-19 11:13:10 +02:00
Michal Privoznik
f978e2e6ef hyperv: Make it obvious that hypervInvokeMethod() consumes an argument
Upon invocation, hypervInvokeMethod() consumes passed @params
(the second argument) regardless whether success or failure is
released. However, it takes only simple pointer (which hides this
ownership transfer) and because of that it doesn't clear it.

Switch to double pointer and tweak the documentation.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Matt Coleman <matt@datto.com>
2020-10-19 11:13:10 +02:00
Matt Coleman
6930138225 hyperv: remove openwsman.h
This header's main purpose was to work around bugs in older versions of
openwsman. Most of the files using it only needed wsman-api.h, which
they now include directly.

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-09 10:13:38 +02:00
Matt Coleman
6fa53f02df hyperv: bump minimum openwsman version to 2.6.3
Bug fixes and comments specific to older versions have been removed.

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-09 10:13:38 +02:00
Matt Coleman
1fe7aa3ccc hyperv: implement domainGetAutostart
Co-authored-by: Sri Ramanujam <sramanujam@datto.com>
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-09 09:27:48 +02:00
Matt Coleman
c0939b4e56 hyperv: implement connectGetVersion
Hyper-V version numbers are not compatible with the encoding in
virParseVersionString():
https://gitlab.com/libvirt/libvirt/-/blob/master/src/util/virutil.c#L246

For example, the Windows Server 2016 Hyper-V version is 10.0.14393: its
micro is over 14 times larger than the encoding allows.

This commit repacks the Hyper-V version number in order to preserve all
of the digits. The major and minor are concatenated (with minor zero-
padded to two digits) to form the repacked major value. This works
because Microsoft's major and minor versions numbers are unlikely to
exceed 99. The repacked minor value is derived from the digits in the
thousands, ten-thousands, and hundred-thousands places of Hyper-V's
micro. The repacked micro is derived from the digits in the ones, tens,
and hundreds places of Hyper-V's micro.

Co-authored-by: Sri Ramanujam <sramanujam@datto.com>
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-09 09:27:20 +02:00
Matt Coleman
4852a79a50 hyperv: fix Win32_OperatingSystem WMI queries
CurrentTimeZone's type is a signed integer, not unsigned.

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-09 09:27:03 +02:00
Matt Coleman
5aab9a2eac hyperv: implement connectGetMaxVcpus
Co-authored-by: Sri Ramanujam <sramanujam@datto.com>
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-09 09:26:49 +02:00
Matt Coleman
ab75d6b17c hyperv: implement connectGetCapabilities
Co-authored-by: Sri Ramanujam <sramanujam@datto.com>
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-09 09:26:44 +02:00
Matt Coleman
110e649f8a hyperv: replace generic WMI class list helpers with a macro
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-09 09:24:00 +02:00
Matt Coleman
7c3ff13987 hyperv: break out common lookups into separate functions
This eliminates some duplicate code and simplifies the driver functions.

Co-authored-by: Sri Ramanujam <sramanujam@datto.com>
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-09 09:23:29 +02:00
Matt Coleman
2a59362feb hyperv: fix nodeGetInfo failures caused by long CPU names
Some CPU model names were too long for _virNodeInfo.model.
For example: Intel Xeon CPU E5-2620 v2 @ 2.10GHz
This commit removes the clock frequency suffix.

Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-09 09:22:48 +02:00
Matt Coleman
c1cfbaab25 hyperv: make Msvm_ComputerSystem WQL queries locale agnostic
There are two specific WQL queries we're using to get either a list of
virtual machines or the hypervisor host itself from Msvm_ComputerSystem.
Those queries rely on filtering results based on the "Description"
field. Since the "Description" field is locale sensitive, the queries
will fail if the Windows host is using a language pack. While the WSMAN
spec allows the client to set the requested locale (and it is supported
since openwsman 2.6.x), the Windows WinRM service does not respect this
setting: it returns non-English strings despite the WSMAN request
properly setting the locale to 'en-US'. Therefore, this patch changes
the WQL query to make use of the "__SERVER" field to stop relying on
English strings in queries and side step the issue.

Co-authored-by: Dawid Zamirski <dzamirski@datto.com>
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-10-09 09:19:19 +02:00
Ján Tomko
535d78630f hyperv: use g_new0 instead of VIR_ALLOC*
Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Peter Krempa <pkrempa@redhat.com>
2020-10-01 12:34:13 +02:00
Matt Coleman
1e18d3b833 hyperv: fix the number of threads per core
The operands were reversed, producing an incorrect result.

Co-authored-by: Sri Ramanujam <sramanujam@datto.com>
Signed-off-by: Matt Coleman <matt@datto.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
2020-09-16 10:14:42 +02:00
Ján Tomko
6fab37da59 Prefer https: everywhere where possible
Use https: links for websites that support them.

The URIs which are used as namespace identifiers
are left alone.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Neal Gompa <ngompa13@gmail.com>
2020-09-01 21:58:46 +02:00