]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Guestinfo: return an empty nicinfo if an error occurs.
authorVMware, Inc <>
Mon, 15 Oct 2012 04:48:59 +0000 (21:48 -0700)
committerDmitry Torokhov <dtor@vmware.com>
Fri, 19 Oct 2012 18:32:39 +0000 (11:32 -0700)
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 <dtor@vmware.com>
open-vm-tools/services/plugins/guestInfo/guestInfoServer.c

index 494d7e7e5cc8553bc39e158592a132022d943cd1..68b6e052d8bb468680fa24d7425d30d1b54fc9ed 100644 (file)
@@ -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;
 }