]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Add a switch to the vm-support script to transfer the support bundle to the hypervisor
authorJohn Wolfe <jwolfe@vmware.com>
Thu, 4 Feb 2021 17:57:03 +0000 (09:57 -0800)
committerJohn Wolfe <jwolfe@vmware.com>
Thu, 4 Feb 2021 17:57:03 +0000 (09:57 -0800)
The vm-support script unconditionally transferred the support bundle to
to the VMware hypervisor, thereby filling vmware.log.
This fix changes the default behavior of the Linux and Windows scripts
to *not* transfer the logs to the host.

Added an option '-x' to both scripts to let the user elect to
transfer the guest support bundle to the host.

open-vm-tools/scripts/common/vm-support
open-vm-tools/services/plugins/guestInfo/guestInfoServer.c

index 98be74c65adb33960b616d28fb347d25a4ada85d..18786534e31c29ff1508027da4aff1a849f144d5 100644 (file)
@@ -1,6 +1,6 @@
 #!/bin/sh
 ##########################################################
-# Copyright (C) 2006-2019 VMware, Inc. All rights reserved.
+# Copyright (C) 2006-2021 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
 # usage(): prints how to use this script
 usage()
 {
-       echo ""
-       echo "Usage: $0 [-h]"
-       echo "  -h prints this usage statement"
-       exit 1
+        echo ""
+        echo "Usage: $0 [-hux]"
+        echo "  -h prints this usage statement"
+        echo "  -u updates the host with the state of support data" \
+             "collection process"
+        echo "  -x transfers support data to the host"
+        exit 1
 }
 
 
@@ -59,6 +62,9 @@ VMSUPPORT_UNKNOWN=100
 #internal state machine state for update
 update=0
 
+#internal state machine state for transfering logs to host
+transfer=0
+
 # UpdateState($state): Updates the VM with the given state.
 UpdateState()
 {
@@ -204,9 +210,12 @@ stageLinux()
    runcmd "/tmp/modules.txt" /sbin/lsmod
    runcmd "/tmp/uname.txt" uname -a
    runcmd "/tmp/issue.txt" cat /etc/issue
-   if which rpm &> /dev/null; then
+   if which rpm > /dev/null; then
       runcmd "/tmp/rpm-qa.txt" rpm -qa
    fi
+   if which apt > /dev/null; then
+      runcmd "/tmp/apt-list.txt" apt list
+   fi
    runcmd "/tmp/netstat-lan.txt" netstat -lan
    runcmd "/tmp/route.txt" route
    runcmd "/tmp/free.txt" free
@@ -257,7 +266,7 @@ cleanup()
 export PATH=/bin:/sbin:/usr/bin:/usr/sbin
 
 TARFILE=vm-`date +%Y-%m-%d`.$$.tar.gz
-VER=0.92
+VER=0.93
 
 # Parse args
 for option in $@
@@ -269,6 +278,9 @@ do
    "-u")
       update=1
       ;;
+   "-x")
+      transfer=1
+      ;;
    *)
       usage
       ;;
@@ -377,12 +389,17 @@ fi
 # Clean up temporary files
 trap - HUP INT QUIT TERM ABRT; cleanup
 
-banner "Uploading archive to host..."
-vmware-xferlogs enc $TARFILE 2>/dev/null
+if [ $transfer -eq 1 ]; then
+   banner "Transferring support data to the host..."
+   vmware-xferlogs enc $TARFILE 2>/dev/null
 
-if [ $? != 0 ]; then
-   banner "Could not transmit logs successfully: either the vmware-xferlogs " \
-          "binary is not in the path, or you are not in a virtual machine."
+   if [ $? != 0 ]; then
+      banner "Could not transfer the support data  successfully: either " \
+             "vmware-xferlogs binary is not in the path, or you are not " \
+             "in a virtual machine."
+   fi
+else
+   banner "Skipping support data transfer to the host."
 fi
 
 UpdateState $VMSUPPORT_ENDING
index ab6725fe2439eec7047a7a1c688a423f90414d74..01d51ecae3bd0314bfab049a9d51cf88a618cf17 100644 (file)
@@ -1,5 +1,5 @@
 /*********************************************************
- * Copyright (C) 1998-2020 VMware, Inc. All rights reserved.
+ * Copyright (C) 1998-2021 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
@@ -231,7 +231,7 @@ GuestInfoVMSupport(RpcInData *data)
     }
 
     /* Put together absolute vm-support filename. */
-    vmSupport = g_strdup_printf("cscript \"%s%s%s\" -u",
+    vmSupport = g_strdup_printf("cscript \"%s%s%s\" -u -x",
                                 vmSupportPath, DIRSEPS, vmSupportCmd);
     vm_free(vmSupportPath);
 
@@ -259,7 +259,7 @@ GuestInfoVMSupport(RpcInData *data)
 
 #else
 
-     gchar *vmSupportCmdArgv[] = {"vm-support", "-u", NULL};
+     gchar *vmSupportCmdArgv[] = {"vm-support", "-u", "-x", NULL};
 
      g_message("Starting vm-support script - %s\n", vmSupportCmdArgv[0]);
      if (!g_spawn_async(NULL, vmSupportCmdArgv, NULL,