diff options
author | VMware, Inc <> | 2013-09-17 20:39:48 -0700 |
---|---|---|
committer | Dmitry Torokhov <dmitry.torokhov@gmail.com> | 2013-09-22 22:26:43 -0700 |
commit | a9635c0923caeef61b51afc5580b51ccb65fd7f5 (patch) | |
tree | fd15d386bc5cbbd32fe4d28a43f1f8460d4eb31a | |
parent | 3a9f2297a82b9c109e894b5f8ea17753e68830ac (diff) |
Implement VMware Tools for ESXi 6.0 guests.
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>
-rw-r--r-- | open-vm-tools/lib/procMgr/procMgrPosix.c | 20 | ||||
-rw-r--r-- | open-vm-tools/lib/rpcChannel/rpcChannel.c | 2 | ||||
-rw-r--r-- | open-vm-tools/lib/rpcIn/rpcin.c | 3 | ||||
-rw-r--r-- | open-vm-tools/lib/syncDriver/syncDriverPosix.c | 2 | ||||
-rw-r--r-- | open-vm-tools/lib/system/systemLinux.c | 21 | ||||
-rw-r--r-- | open-vm-tools/services/plugins/guestInfo/getlib/guestInfoPosix.c | 43 | ||||
-rw-r--r-- | open-vm-tools/services/plugins/guestInfo/guestInfoServer.c | 10 | ||||
-rw-r--r-- | open-vm-tools/services/plugins/vix/vixTools.c | 5 |
8 files changed, 93 insertions, 13 deletions
diff --git a/open-vm-tools/lib/procMgr/procMgrPosix.c b/open-vm-tools/lib/procMgr/procMgrPosix.c index 495c306a..a03dde32 100644 --- a/open-vm-tools/lib/procMgr/procMgrPosix.c +++ b/open-vm-tools/lib/procMgr/procMgrPosix.c @@ -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); diff --git a/open-vm-tools/lib/rpcChannel/rpcChannel.c b/open-vm-tools/lib/rpcChannel/rpcChannel.c index b775813c..bfa5e23a 100644 --- a/open-vm-tools/lib/rpcChannel/rpcChannel.c +++ b/open-vm-tools/lib/rpcChannel/rpcChannel.c @@ -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(); diff --git a/open-vm-tools/lib/rpcIn/rpcin.c b/open-vm-tools/lib/rpcIn/rpcin.c index 1b05f9eb..c90e3628 100644 --- a/open-vm-tools/lib/rpcIn/rpcin.c +++ b/open-vm-tools/lib/rpcIn/rpcin.c @@ -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 diff --git a/open-vm-tools/lib/syncDriver/syncDriverPosix.c b/open-vm-tools/lib/syncDriver/syncDriverPosix.c index 402421ab..b82f4fa0 100644 --- a/open-vm-tools/lib/syncDriver/syncDriverPosix.c +++ b/open-vm-tools/lib/syncDriver/syncDriverPosix.c @@ -34,7 +34,7 @@ #include "mntinfo.h" static SyncFreezeFn gBackends[] = { -#if defined(linux) +#if defined(__linux__) && !defined(USERWORLD) LinuxDriver_Freeze, VmSync_Freeze, NullDriver_Freeze, diff --git a/open-vm-tools/lib/system/systemLinux.c b/open-vm-tools/lib/system/systemLinux.c index d1c28d96..f579c1fd 100644 --- a/open-vm-tools/lib/system/systemLinux.c +++ b/open-vm-tools/lib/system/systemLinux.c @@ -63,6 +63,12 @@ #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 diff --git a/open-vm-tools/services/plugins/guestInfo/getlib/guestInfoPosix.c b/open-vm-tools/services/plugins/guestInfo/getlib/guestInfoPosix.c index f09908a2..c1ff739e 100644 --- a/open-vm-tools/services/plugins/guestInfo/getlib/guestInfoPosix.c +++ b/open-vm-tools/services/plugins/guestInfo/getlib/guestInfoPosix.c @@ -45,6 +45,12 @@ # 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> @@ -188,6 +194,43 @@ GuestInfoGetNicInfo(NicInfoV3 *nicInfo) // OUT } 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; #endif diff --git a/open-vm-tools/services/plugins/guestInfo/guestInfoServer.c b/open-vm-tools/services/plugins/guestInfo/guestInfoServer.c index 7d2c1165..28c657fb 100644 --- a/open-vm-tools/services/plugins/guestInfo/guestInfoServer.c +++ b/open-vm-tools/services/plugins/guestInfo/guestInfoServer.c @@ -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, diff --git a/open-vm-tools/services/plugins/vix/vixTools.c b/open-vm-tools/services/plugins/vix/vixTools.c index 9f02047f..70fa9b30 100644 --- a/open-vm-tools/services/plugins/vix/vixTools.c +++ b/open-vm-tools/services/plugins/vix/vixTools.c @@ -122,7 +122,8 @@ /* * 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; |