[libvirt] [PATCH 06/16] hyperv: implement nodeGetFreeMemory
John Ferlan
jferlan at redhat.com
Thu Sep 15 11:03:01 UTC 2016
All these commits need a bit a information w/r/t how the task is being
accomplished. It doesn't need to be a lot of words, but at least something.
On 08/09/2016 08:39 AM, Jason Miesionczek wrote:
> ---
> src/hyperv/hyperv_driver.c | 32 ++++++++++++++++++++++++++++++++
> 1 file changed, 32 insertions(+)
>
> diff --git a/src/hyperv/hyperv_driver.c b/src/hyperv/hyperv_driver.c
> index 7d956d3..861d5ab 100644
> --- a/src/hyperv/hyperv_driver.c
> +++ b/src/hyperv/hyperv_driver.c
> @@ -1573,6 +1573,37 @@ hypervDomainGetVcpus(virDomainPtr domain, virVcpuInfoPtr info, int maxinfo,
> return count;
> }
>
> +static unsigned long long
> +hypervNodeGetFreeMemory(virConnectPtr conn)
> +{
> + unsigned long long res = 0;
> + hypervPrivate *priv = conn->privateData;
> + virBuffer query = VIR_BUFFER_INITIALIZER;
> + Win32_OperatingSystem *operatingSystem = NULL;
> +
> + /* Get Win32_OperatingSystem */
> + virBufferAddLit(&query, WIN32_OPERATINGSYSTEM_WQL_SELECT);
Aha! this is what I was referring to in a previous patch - see how the
string constant is 'hidden' behind some #define. That's what you really
should be doing for all these patches.
See MSVM_COMPUTERSYSTEM_CLASSNAME and MSVM_COMPUTERSYSTEM_WQL_SELECT for
an example as well as hypervConnectOpen which makes 3 virBufferAddLit
calls in order to formulate a string to make the call to
hypervGetMsvmComputerSystemList
> +
> + if (hypervGetWin32OperatingSystemList(priv, &query, &operatingSystem) < 0) {
> + goto cleanup;
> + }
Brackets/syntax-check
> +
> + if (operatingSystem == NULL) {
> + virReportError(VIR_ERR_INTERNAL_ERROR,
Need "%s", /syntax-check
> + _("Could not get Win32_OperatingSystem"));
> + goto cleanup;
> + }
> +
> + /* Return free memory in bytes */
> + res = operatingSystem->data->FreePhysicalMemory * 1024;
> +
> + cleanup:
> + hypervFreeObject(priv, (hypervObject *) operatingSystem);
> + virBufferFreeAndReset(&query);
> +
> + return res;
> +}
> +
> static virHypervisorDriver hypervHypervisorDriver = {
> .name = "Hyper-V",
> .connectOpen = hypervConnectOpen, /* 0.9.5 */
> @@ -1580,6 +1611,7 @@ static virHypervisorDriver hypervHypervisorDriver = {
> .connectGetType = hypervConnectGetType, /* 0.9.5 */
> .connectGetHostname = hypervConnectGetHostname, /* 0.9.5 */
> .nodeGetInfo = hypervNodeGetInfo, /* 0.9.5 */
> + .nodeGetFreeMemory = hypervNodeGetFreeMemory, /* 1.2.10 */
2.3.0 at the earliest
John
> .connectListDomains = hypervConnectListDomains, /* 0.9.5 */
> .connectNumOfDomains = hypervConnectNumOfDomains, /* 0.9.5 */
> .connectListAllDomains = hypervConnectListAllDomains, /* 0.10.2 */
>
More information about the libvir-list
mailing list