From: VMware, Inc <> Date: Mon, 15 Oct 2012 04:48:59 +0000 (-0700) Subject: Guestinfo: return an empty nicinfo if an error occurs. X-Git-Tag: 2012.10.14-874563~41 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=d70b102d4dcbda2af82d6084f124cac87288c8ac;p=thirdparty%2Fopen-vm-tools.git Guestinfo: return an empty nicinfo if an error occurs. If an error occurs while retrieving the network information then, instead of ignoring error, guestinfon should return an empty nicinfo so that all corresponding entries in the MOB, VMDB, will be set to blank values and VI client will not show any stale data. This change also fixes another issue. If any error occurs while retrieving the primary 'ipaddress', guestinfo plugin now returns a blank string so that VI client and other clients show the blank value instead of stale data. Signed-off-by: Dmitry Torokhov --- diff --git a/open-vm-tools/services/plugins/guestInfo/guestInfoServer.c b/open-vm-tools/services/plugins/guestInfo/guestInfoServer.c index 494d7e7e5..68b6e052d 100644 --- a/open-vm-tools/services/plugins/guestInfo/guestInfoServer.c +++ b/open-vm-tools/services/plugins/guestInfo/guestInfoServer.c @@ -299,7 +299,13 @@ GuestInfoGather(gpointer data) /* Get NIC information. */ if (!GuestInfo_GetNicInfo(&nicInfo)) { g_warning("Failed to get nic info.\n"); - } else if (GuestInfo_IsEqual_NicInfoV3(nicInfo, gInfoCache.nicInfo)) { + /* + * Return an empty nic info. + */ + nicInfo = Util_SafeCalloc(1, sizeof (struct NicInfoV3)); + } + + if (GuestInfo_IsEqual_NicInfoV3(nicInfo, gInfoCache.nicInfo)) { g_debug("Nic info not changed.\n"); GuestInfo_FreeNicInfo(nicInfo); } else if (GuestInfoUpdateVmdb(ctx, INFO_IPADDRESS, nicInfo)) { @@ -1234,6 +1240,7 @@ GuestInfoServerSetOption(gpointer src, { char *ip; Bool ret = FALSE; + gchar *msg; if (strcmp(option, TOOLSOPTION_BROADCASTIP) != 0) { goto exit; @@ -1249,15 +1256,18 @@ GuestInfoServerSetOption(gpointer src, } ip = NetUtil_GetPrimaryIP(); - - if (ip != NULL) { - gchar *msg; - msg = g_strdup_printf("info-set guestinfo.ip %s", ip); - ret = RpcChannel_Send(ctx->rpc, msg, strlen(msg) + 1, NULL, NULL); - vm_free(ip); - g_free(msg); + if (ip == NULL) { + /* + * If there is any error, then return a blank string. + */ + ip = Util_SafeStrdup(""); } + msg = g_strdup_printf("info-set guestinfo.ip %s", ip); + ret = RpcChannel_Send(ctx->rpc, msg, strlen(msg) + 1, NULL, NULL); + vm_free(ip); + g_free(msg); + exit: return (gboolean) ret; }