]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
[Part 2] GuestLib support for 64bit memory shares.
authorOliver Kurth <okurth@vmware.com>
Tue, 19 Feb 2019 20:51:30 +0000 (12:51 -0800)
committerOliver Kurth <okurth@vmware.com>
Tue, 19 Feb 2019 20:51:30 +0000 (12:51 -0800)
MEMSCHED_SHARES_MAX is currently set to MAX_PPN and will not fit in
32-bit soon. 'memshares' property which is currently available in GuestSDK
is an unsigned 32bit value.  Starting from ESX 7.0, this value is available
only if it can be fit in an unsigned 32-bit data type.

'memShares64' is the new unsigned 64-bit property added in GuestSDK for the
memory shares.

Added necessary APIs to retrieve the memshares64 value.  The new API
VMGuestLib_GetMemShares64 will first try to retrieve the memShares64 property.
If the underlying host is an older one, then the API will return the memShares
property.

Updated the vmGuestLibTest code to retrieve and print the new memShares64 value.

open-vm-tools/lib/include/vmGuestLib.h
open-vm-tools/libguestlib/vmGuestLib.c

index b83f43cda64f8f3e0c4844559f7cf968d477d643..80061084f7a864e93556e4b7c16e5e2bf7302f76 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2003-2016 VMware, Inc. All rights reserved.
+ * Copyright (C) 2003-2016,2019 VMware, Inc. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published
@@ -267,10 +267,19 @@ VMGuestLibError VMGuestLib_GetMemLimitMB(VMGuestLibHandle handle, // IN
 
 /*
  * Retrieves the number of memory shares allocated to the virtual machine.
+ * This API returns an error if the memory shares exceeds the maximum
+ * value of 32-bit unsigned integer (0xFFFFFFFF). Therefore,
+ * VMGuestLib_GetMemShares64 API should be used instead of this API.
  */
 VMGuestLibError VMGuestLib_GetMemShares(VMGuestLibHandle handle, // IN
                                         uint32 *memShares);      // OUT
 
+/*
+ * Retrieves the number of memory shares allocated to the virtual machine.
+ */
+VMGuestLibError VMGuestLib_GetMemShares64(VMGuestLibHandle handle, // IN
+                                          uint64 *memShares64);    // OUT
+
 /*
  * Retrieves the mapped memory size of this virtual machine. This
  * is the current total amount of guest memory that is backed by
index 544e0fa4bb5748ee0d3e6ec20a3ce2a4f545d593..f3d48521668b07203282b3594f0f03bc34748d37 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 2005-2016 VMware, Inc. All rights reserved.
+ * Copyright (C) 2005-2016,2019 VMware, Inc. All rights reserved.
  *
  * This program is free software; you can redistribute it and/or modify it
  * under the terms of the GNU Lesser General Public License as published
@@ -1761,6 +1761,48 @@ VMGuestLib_GetMemBalloonMaxMB(VMGuestLibHandle handle,    // IN
 }
 
 
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * VMGuestLib_GetMemShares64 --
+ *
+ *      Retrieve memory shares.
+ *
+ * Results:
+ *      VMGuestLibError
+ *
+ * Side effects:
+ *      None
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+VMGuestLibError
+VMGuestLib_GetMemShares64(VMGuestLibHandle handle, // IN
+                          uint64 *memShares64)     // OUT
+{
+   VMGuestLibError error = VMGUESTLIB_ERROR_OTHER;
+   VMGUESTLIB_GETSTAT_V3(handle, error,
+                         memShares64, memShares64,
+                         GUESTLIB_MEM_SHARES_64);
+   if (VMGUESTLIB_ERROR_UNSUPPORTED_VERSION == error) {
+      /*
+       * GUESTLIB_MEM_SHARES_64 is available only from ESX 7.0.
+       * If the host is older, then return the value of GUESTLIB_MEM_SHARES.
+       */
+      uint32 memShares = 0;
+      if (VMGUESTLIB_ERROR_SUCCESS !=
+         VMGuestLib_GetMemShares(handle, &memShares)) {
+         return error;
+      } else {
+         *memShares64 = memShares;
+         return VMGUESTLIB_ERROR_SUCCESS;
+      }
+   }
+   return error;
+}
+
+
 /*
  *-----------------------------------------------------------------------------
  *