]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Implement VMware Tools for ESXi 6.0 guests.
authorVMware, Inc <>
Wed, 18 Sep 2013 03:39:48 +0000 (20:39 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Mon, 23 Sep 2013 05:26:43 +0000 (22:26 -0700)
This change provides limited VMware Tools support for ESXi 6.0
guests.  The powerOps and guestInfo plugins are supported.
Only IPv4 addresses are reported, since those are the only
ones we can get through the vmkuser library.

VMware Tools for ESXi 6.0 are packed as two VIBs on a single
ISO image.  One VIB contains the glib libraries that are
missing from the standard ESX distribution, and the other
VIB contains the tools themselves.

Signed-off-by: Dmitry Torokhov <dtor@vmware.com>
open-vm-tools/lib/procMgr/procMgrPosix.c
open-vm-tools/lib/rpcChannel/rpcChannel.c
open-vm-tools/lib/rpcIn/rpcin.c
open-vm-tools/lib/syncDriver/syncDriverPosix.c
open-vm-tools/lib/system/systemLinux.c
open-vm-tools/services/plugins/guestInfo/getlib/guestInfoPosix.c
open-vm-tools/services/plugins/guestInfo/guestInfoServer.c
open-vm-tools/services/plugins/vix/vixTools.c

index 495c306a5f78b5acff65d0b94142cf7e228e677f..a03dde32b4472a16cc70676f803a389b554684bb 100644 (file)
@@ -2077,7 +2077,9 @@ ProcMgr_ImpersonateUserStart(const char *user,  // IN: UTF-8 encoded user name
    }
 
    // first change group
-#if defined(__APPLE__)
+#if defined(USERWORLD)
+   ret = Id_SetREGid(ppw->pw_gid, ppw->pw_gid);
+#elif defined(__APPLE__)
    ret = setregid(ppw->pw_gid, ppw->pw_gid);
 #else
    ret = setresgid(ppw->pw_gid, ppw->pw_gid, root_gid);
@@ -2086,13 +2088,17 @@ ProcMgr_ImpersonateUserStart(const char *user,  // IN: UTF-8 encoded user name
       Warning("Failed to set gid for user %s\n", user);
       return FALSE;
    }
+#ifndef USERWORLD
    ret = initgroups(ppw->pw_name, ppw->pw_gid);
    if (ret < 0) {
       Warning("Failed to initgroups() for user %s\n", user);
       goto failure;
    }
+#endif
    // now user
-#if defined(__APPLE__)
+#if defined(USERWORLD)
+   ret = Id_SetREUid(ppw->pw_uid, ppw->pw_uid);
+#elif defined(__APPLE__)
    ret = setreuid(ppw->pw_uid, ppw->pw_uid);
 #else
    ret = setresuid(ppw->pw_uid, ppw->pw_uid, 0);
@@ -2152,7 +2158,9 @@ ProcMgr_ImpersonateUserStop(void)
    }
 
    // first change back user
-#if defined(__APPLE__)
+#if defined(USERWORLD)
+   ret = Id_SetREUid(ppw->pw_uid, ppw->pw_uid);
+#elif defined(__APPLE__)
    ret = setreuid(ppw->pw_uid, ppw->pw_uid);
 #else
    ret = setresuid(ppw->pw_uid, ppw->pw_uid, 0);
@@ -2163,7 +2171,9 @@ ProcMgr_ImpersonateUserStop(void)
    }
 
    // now group
-#if defined(__APPLE__)
+#if defined(USERWORLD)
+   ret = Id_SetREGid(ppw->pw_gid, ppw->pw_gid);
+#elif defined(__APPLE__)
    ret = setregid(ppw->pw_gid, ppw->pw_gid);
 #else
    ret = setresgid(ppw->pw_gid, ppw->pw_gid, ppw->pw_gid);
@@ -2172,11 +2182,13 @@ ProcMgr_ImpersonateUserStop(void)
       Warning("Failed to set gid for root\n");
       return FALSE;
    }
+#ifndef USERWORLD
    ret = initgroups(ppw->pw_name, ppw->pw_gid);
    if (ret < 0) {
       Warning("Failed to initgroups() for root\n");
       return FALSE;
    }
+#endif
 
    // set env
    setenv("USER", ppw->pw_name, 1);
index b775813c68bf974a5f997e779a6e96be60278053..bfa5e23a81691122f130690b56bed1a19fcaa213 100644 (file)
@@ -638,7 +638,7 @@ RpcChannel *
 RpcChannel_New(void)
 {
    RpcChannel *chan;
-#if defined(linux) || defined(_WIN32)
+#if (defined(__linux__) && !defined(USERWORLD)) || defined(_WIN32)
    chan = VSockChannel_New();
 #else
    chan = BackdoorChannel_New();
index 1b05f9eb238b59efb4633a17c763cc4e32e0756f..c90e36288f07e1d11fc4d4bc93a72f6623f7ce09 100644 (file)
@@ -46,7 +46,8 @@
 
 #include "vm_basic_types.h"
 
-#if (defined(_WIN32) || defined(linux)) && defined(VMTOOLS_USE_GLIB)
+#if ((defined(__linux__) && !defined(USERWORLD)) || defined(_WIN32)) && \
+    defined(VMTOOLS_USE_GLIB)
 #define VMTOOLS_USE_VSOCKET
 #else
 #undef  VMTOOLS_USE_VSOCKET
index 402421abba3f992b829092adb24aefc1765f5a9e..b82f4fa02a5da8d9b71a936cda4d46df7d0f5cdf 100644 (file)
@@ -34,7 +34,7 @@
 #include "mntinfo.h"
 
 static SyncFreezeFn gBackends[] = {
-#if defined(linux)
+#if defined(__linux__) && !defined(USERWORLD)
    LinuxDriver_Freeze,
    VmSync_Freeze,
    NullDriver_Freeze,
index d1c28d96588cd57c27b2c0156a57eb8f57c458e5..f579c1fd8ec5f6d9c39033c8b5d772b11bc7c5cc 100644 (file)
 #include "ifaddrs.h"
 #endif
 
+#ifdef USERWORLD
+#include <vm_basic_types.h>
+#include <vmkuserstatus.h>
+#include <vmkuseruptime.h>
+#endif
+
 #include "vm_assert.h"
 #include "system.h"
 #include "debug.h"
@@ -183,7 +189,16 @@ System_Uptime(void)
 {
    uint64 uptime = -1;
 
-#ifdef __linux__
+#ifdef USERWORLD
+   {
+      VmkuserStatus_Code status;
+      uint64 sysUptime;
+      status = VmkuserUptime_GetUptime(&sysUptime);
+      if (VmkuserStatus_IsOK(status)) {
+         uptime = sysUptime / 10000;
+      }
+   }
+#elif defined(__linux__)
    {
       FILE *procStream;
       char *buf = NULL;
@@ -345,6 +360,8 @@ System_Shutdown(Bool reboot)  // IN: "reboot or shutdown" flag
    if (reboot) {
 #if defined(sun)
       cmd = "/usr/sbin/shutdown -g 0 -i 6 -y";
+#elif defined(USERWORLD)
+      cmd = "/bin/reboot";
 #else
       cmd = "/sbin/shutdown -r now";
 #endif
@@ -353,6 +370,8 @@ System_Shutdown(Bool reboot)  // IN: "reboot or shutdown" flag
       cmd = "/sbin/shutdown -p now";
 #elif defined(sun)
       cmd = "/usr/sbin/shutdown -g 0 -i 5 -y";
+#elif defined(USERWORLD)
+      cmd = "/bin/halt";
 #else
       cmd = "/sbin/shutdown -h now";
 #endif
index f09908a29c3b0aafb29ee7656de907c393213c69..c1ff739e5b48c9c5d96f5b225b982d4641329a6c 100644 (file)
 # endif
 #endif
 
+#ifdef USERWORLD
+#include <vm_basic_types.h>
+#include <vmkuserstatus.h>
+#include <vmkusertcpip.h>
+#endif
+
 #include <netinet/in.h>
 #include <arpa/nameser.h>
 #include <resolv.h>
@@ -187,6 +193,43 @@ GuestInfoGetNicInfo(NicInfoV3 *nicInfo) // OUT
       return FALSE;
    }
 
+   return TRUE;
+#elif defined(USERWORLD)
+   unsigned count;
+   VmkuserTcpip_Interface ifList[NICINFO_MAX_NICS];
+   VmkuserStatus_Code status;
+
+   status = VmkuserTcpip_GetInterfaces(ifList, NICINFO_MAX_NICS, &count);
+   if (VmkuserStatus_IsOK(status)) {
+      unsigned ix;
+      for (ix = 0; ix < count && ix < ARRAYSIZE(ifList); ix++) {
+         GuestNicV3 *nic;
+         char macAddress[NICINFO_MAC_LEN];
+         struct sockaddr_in sin = {
+            .sin_family = AF_INET,
+            .sin_addr = { .s_addr = ifList[ix].ipaddr }
+         };
+         struct sockaddr sa;
+         Str_Sprintf(macAddress, sizeof macAddress,
+                     "%02x:%02x:%02x:%02x:%02x:%02x",
+                     (unsigned)ifList[ix].macaddr[0],
+                     (unsigned)ifList[ix].macaddr[1],
+                     (unsigned)ifList[ix].macaddr[2],
+                     (unsigned)ifList[ix].macaddr[3],
+                     (unsigned)ifList[ix].macaddr[4],
+                     (unsigned)ifList[ix].macaddr[5]);
+         nic = GuestInfoAddNicEntry(nicInfo, macAddress, NULL, NULL);
+         if (NULL == nic) {
+            /*
+             * We reached maximum number of NICs we can report to the host.
+             */
+            break;
+         }
+         memset(&sa, 0, sizeof sa);
+         memcpy(&sa, &sin, sizeof sin);
+         GuestInfoAddIpAddress(nic, &sa, 0, NULL, NULL);
+      }
+   }
    return TRUE;
 #else
    return FALSE;
index 7d2c1165928359ddef959821e07e8f2b22065938..28c657fbfb6f22d7eac2ba4d884e1d6307d39c58 100644 (file)
@@ -232,10 +232,12 @@ GuestInfoGather(gpointer data)
    char name[256];  // Size is derived from the SUS2 specification
                     // "Host names are limited to 255 bytes"
    char *osString = NULL;
+#if !defined(USERWORLD)
    gboolean disableQueryDiskInfo;
-   NicInfoV3 *nicInfo = NULL;
    GuestDiskInfo *diskInfo = NULL;
-#if defined(_WIN32) || defined(linux)
+#endif
+   NicInfoV3 *nicInfo = NULL;
+#if (defined(__linux__) && !defined(USERWORLD)) || defined(_WIN32)
    GuestMemInfo vmStats = {0};
    gboolean perfmonEnabled;
 #endif
@@ -274,6 +276,7 @@ GuestInfoGather(gpointer data)
    }
    free(osString);
 
+#if !defined(USERWORLD)
    disableQueryDiskInfo =
       g_key_file_get_boolean(ctx->config, CONFGROUPNAME_GUESTINFO,
                              CONFNAME_GUESTINFO_DISABLEQUERYDISKINFO, NULL);
@@ -290,6 +293,7 @@ GuestInfoGather(gpointer data)
          }
       }
    }
+#endif
 
    if (!System_GetNodeName(sizeof name, name)) {
       g_warning("Failed to get netbios name.\n");
@@ -324,7 +328,7 @@ GuestInfoGather(gpointer data)
    /* Send the uptime to VMX so that it can detect soft resets. */
    SendUptime(ctx);
 
-#if defined(_WIN32) || defined(linux)
+#if (defined(__linux__) && !defined(USERWORLD)) || defined(_WIN32)
    /* Send the vmstats to the VMX. */
    perfmonEnabled = !g_key_file_get_boolean(ctx->config,
                                             CONFGROUPNAME_GUESTINFO,
index 9f02047fd804503f3271374b6f885c52ed24f330..70fa9b30e06cd6185bb23660dc47542f4c8e7ecf 100644 (file)
 /*
  * No support for open-vm-tools.
  */
-#if (defined(_WIN32) ||  defined(linux)) && !defined(OPEN_VM_TOOLS)
+#if ((defined(__linux__) && !defined(USERWORLD)) || defined(_WIN32)) && \
+    !defined(OPEN_VM_TOOLS)
 #define SUPPORT_VGAUTH 1
 #else
 #define SUPPORT_VGAUTH 0
@@ -5167,7 +5168,7 @@ VixToolsListProcessesEx(VixCommandRequestHeader *requestMsg, // IN
                         char **result)                       // OUT
 {
    VixError err = VIX_OK;
-   char *fullResultBuffer;
+   char *fullResultBuffer = NULL;
    char *finalResultBuffer = NULL;
    size_t fullResultSize = 0;
    size_t curPacketLen = 0;