diff options
Diffstat (limited to 'open-vm-tools/libguestlib/vmGuestLib.c')
-rw-r--r-- | open-vm-tools/libguestlib/vmGuestLib.c | 86 |
1 files changed, 83 insertions, 3 deletions
diff --git a/open-vm-tools/libguestlib/vmGuestLib.c b/open-vm-tools/libguestlib/vmGuestLib.c index 4328ea73..487826c3 100644 --- a/open-vm-tools/libguestlib/vmGuestLib.c +++ b/open-vm-tools/libguestlib/vmGuestLib.c @@ -1,5 +1,5 @@ /********************************************************* - * Copyright (C) 2005 VMware, Inc. All rights reserved. + * Copyright (C) 2005-2015 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 @@ -259,8 +259,6 @@ VMGuestLib_OpenHandle(VMGuestLibHandle *handle) // OUT { VMGuestLibHandleType *data; - VMTools_SetGuestSDKMode(); - if (!VmCheck_IsVirtualWorld()) { Debug("VMGuestLib_OpenHandle: Not in a VM.\n"); return VMGUESTLIB_ERROR_NOT_RUNNING_IN_VM; @@ -1839,3 +1837,85 @@ VMGuestLib_AtomicUpdateCookie(const char *src, // IN param.GuestLibIoctlParam_u.atomicUpdateCookie.dst = (char *)dst; return VMGuestLibIoctl(¶m, reply, replySize); } + + +/* + *----------------------------------------------------------------------------- + * + * VMGuestLib_StatGet -- + * + * Fetches semi-structured stat information from the hypervisor. + * Pass to VMGuestLib_StatFree() to release. + * + * Encodings: 'json', 'text', 'xml', 'yaml' + * Stats: pass NULL or "" to receive a list of available stats + * Some stats are two words, e.g. "vscsi scsi0:0" + * + * NOTE: stats, their meaning and availability may change from release + * to release as the underlying implementation evolves. + * This information is intended for troubleshooting only! + * + * Results: + * VMGuestLibError + * + * Side effects: + * None + * + *----------------------------------------------------------------------------- + */ + +VMGuestLibError +VMGuestLib_StatGet(const char *encoding, // IN + const char *stat, // IN + char **reply, // OUT + size_t *replySize) // OUT +{ + char commandBuf[256]; + int bufRet; + Bool ret; + + if (encoding == NULL) { + return VMGUESTLIB_ERROR_INVALID_ARG; + } + if (stat == NULL) { + stat = ""; // Dummy value + } + + /* + * Construct command string with the command name and the name + * of the stat that we want. + */ + bufRet = Str_Snprintf(commandBuf, sizeof commandBuf, "%s %s %s", + VMGUESTLIB_STATDATA_COMMAND_STRING, encoding, stat); + if (bufRet == -1 || bufRet >= sizeof commandBuf) { + return VMGUESTLIB_ERROR_BUFFER_TOO_SMALL; + } + + ret = RpcChannel_SendOneRaw(commandBuf, strlen(commandBuf), + reply, replySize); + + return ret ? VMGUESTLIB_ERROR_SUCCESS : VMGUESTLIB_ERROR_NOT_AVAILABLE; +} + +/* + *----------------------------------------------------------------------------- + * + * VMGuestLib_StatFree -- + * + * Frees a stat fetched by VMGuestLib_StatGet() + * + * Results: + * None + * + * Side effects: + * None + * + *----------------------------------------------------------------------------- + */ + +void +VMGuestLib_StatFree(char *reply, // IN + size_t replySize) // IN +{ + free(reply); +} |