From: John Wolfe Date: Thu, 4 Feb 2021 17:57:03 +0000 (-0800) Subject: Add a switch to the vm-support script to transfer the support bundle to the hypervisor X-Git-Tag: stable-11.3.0~157 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=c5b510fded54592eae1c5a4a61f8119f69666a3f;p=thirdparty%2Fopen-vm-tools.git Add a switch to the vm-support script to transfer the support bundle to the hypervisor 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. --- diff --git a/open-vm-tools/scripts/common/vm-support b/open-vm-tools/scripts/common/vm-support index 98be74c65..18786534e 100644 --- a/open-vm-tools/scripts/common/vm-support +++ b/open-vm-tools/scripts/common/vm-support @@ -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 @@ -20,10 +20,13 @@ # 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 diff --git a/open-vm-tools/services/plugins/guestInfo/guestInfoServer.c b/open-vm-tools/services/plugins/guestInfo/guestInfoServer.c index ab6725fe2..01d51ecae 100644 --- a/open-vm-tools/services/plugins/guestInfo/guestInfoServer.c +++ b/open-vm-tools/services/plugins/guestInfo/guestInfoServer.c @@ -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,