]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Changes in shared code that don't affect open-vm-tools functionality.
authorVMware, Inc <>
Thu, 22 Dec 2011 00:16:48 +0000 (16:16 -0800)
committerMarcelo Vanzin <mvanzin@vmware.com>
Thu, 22 Dec 2011 00:16:48 +0000 (16:16 -0800)
Signed-off-by: Marcelo Vanzin <mvanzin@vmware.com>
open-vm-tools/lib/file/fileIO.c
open-vm-tools/lib/include/fileIO.h
open-vm-tools/lib/include/memaligned.h
open-vm-tools/lib/include/vm_version.h
open-vm-tools/modules/shared/vmxnet/eth_public.h
open-vm-tools/modules/shared/vmxnet/vmnet_def.h

index 5719566083b8ad6cfd7b365c16c2d4f6c825387c..a7c0fe9cd7b2ae13af5a1d993ca1145c6aaf9233 100644 (file)
@@ -464,6 +464,7 @@ FileIO_CloseAndUnlink(FileIODescriptor *fd)  // IN:
    Bool ret;
 
    ASSERT(fd);
+   ASSERT(FileIO_IsValid(fd));
 
    path = Unicode_Duplicate(fd->fileName);
    ret = FileIO_Close(fd) || File_Unlink(path);
@@ -728,18 +729,23 @@ bail:
    Unicode_Free(tempPath);
    return status;
 }
-   
+
 
 /*
  *-----------------------------------------------------------------------------
  *
- * FileIO_AtomicExchangeFiles --
+ * FileIO_AtomicUpdate --
+ *
+ *      On ESX when the target files reside on vmfs, exchanges the contents
+ *      of two files using code modeled from VmkfsLib_SwapFiles.  Both "curr"
+ *      and "new" are left open.
  *
- *      On ESX, exchanges the contents of two files using code modeled from
- *      VmkfsLib_SwapFiles.  Both "curr" and "new" are left open.
+ *      On ESX when the target files reside on NFS, and on hosted products,
+ *      uses rename to swap files, so "new" becomes "curr", and path to "new"
+ *      no longer exists on success.
  *
- *      On Hosted replaces "curr" with "new" using rename/link.
- *      Path to "new" no longer exists on success.
+ *      On success the caller must call FileIO_IsValid on newFD to verify it
+ *     is still open before using it again.
  *
  * Results:
  *      TRUE if successful, FALSE on failure.
@@ -752,8 +758,8 @@ bail:
 
 
 Bool
-FileIO_AtomicExchangeFiles(FileIODescriptor *newFD,   // IN/OUT: file IO descriptor
-                           FileIODescriptor *currFD)  // IN/OUT: file IO descriptor
+FileIO_AtomicUpdate(FileIODescriptor *newFD,   // IN/OUT: file IO descriptor
+                    FileIODescriptor *currFD)  // IN/OUT: file IO descriptor
 {
    char *currPath;
    char *newPath;
@@ -772,6 +778,7 @@ FileIO_AtomicExchangeFiles(FileIODescriptor *newFD,   // IN/OUT: file IO descrip
       char *fileName = NULL;
       char *dstDirName = NULL;
       char *dstFileName = NULL;
+      int savedErrno;
       int fd;
 
       currPath = File_FullPath(FileIO_Filename(currFD));
@@ -814,15 +821,46 @@ FileIO_AtomicExchangeFiles(FileIODescriptor *newFD,   // IN/OUT: file IO descrip
          goto swapdone;
       }
 
+      savedErrno = 0;
       if (ioctl(fd, IOCTLCMD_VMFS_SWAP_FILES, args) != 0) {
-         Log("%s: ioctl failed %d.\n", __FUNCTION__, errno);
-         ASSERT_BUG_DEBUGONLY(615124, errno != EBUSY);
+         savedErrno = errno;
+         if (errno != ENOSYS) {
+            Log("%s: ioctl failed %d.\n", __FUNCTION__, errno);
+            ASSERT_BUG_DEBUGONLY(615124, errno != EBUSY);
+         }
       } else {
          ret = TRUE;
       }
 
       close(fd);
 
+      /*
+       * Did we fail because we are on NFS?
+       */
+      if (savedErrno == ENOSYS) {
+         /*
+          * NFS allows renames of locked files, even if both files
+          * are locked.  The file lock follows the file handle, not
+          * the name, so after the rename we can swap the underlying
+          * file descriptors instead of closing and reopening the
+          * target file.
+          *
+          * This is different than the hosted path below because
+          * ESX uses native file locks and hosted does not.
+          */
+
+         if (File_Rename(newPath, currPath)) {
+            Log("%s: rename of '%s' to '%s' failed %d.\n",
+                newPath, currPath, __FUNCTION__, errno);
+            goto swapdone;
+         }
+         ret = TRUE;
+         fd = newFD->posix;
+         newFD->posix = currFD->posix;
+         currFD->posix = fd;
+         FileIO_Close(newFD);
+      }
+
 swapdone:
       free(args);
       free(dirName);
index 508bc3a23d463d59a77ba5616372c772ad8c12cb..bf281cbaa44a8636a198639dbe59c41c7390f088 100644 (file)
@@ -297,8 +297,8 @@ FileIOResult FileIO_Write(FileIODescriptor *file,
 FileIOResult FileIO_AtomicTempFile(FileIODescriptor *fileFD,
                                    FileIODescriptor *tempFD);
 
-Bool FileIO_AtomicExchangeFiles(FileIODescriptor *newFD,
-                                FileIODescriptor *currFD);
+Bool FileIO_AtomicUpdate(FileIODescriptor *newFD,
+                         FileIODescriptor *currFD);
 
 #if !defined(VMX86_TOOLS) || !defined(__FreeBSD__)
 
index 989ba6eac397d15e71c96c8e8c73c50a92ae2a9d..a784e56dffb5836e10ce461b70ff75e8e0f1e972 100644 (file)
@@ -106,14 +106,60 @@ AlignedMallocImpl(size_t size) // IN
    alignedResult = (void **)PAGE_ROUND_UP(buf + 1);
    *(alignedResult - 1) = buf;
 
-#undef PAGE_MASK
-#undef PAGE_ROUND_DOWN
-#undef PAGE_ROUND_UP
-
    return alignedResult;
 }
 
 
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * AlignedReallocImpl --
+ *
+ *      Internal implementation of page-aligned memory for operating systems
+ *      that lack a working page-aligned allocation function.
+ *
+ *      Resulting pointer needs to be freed with AlignedFreeImpl.
+ *
+ * Result:
+ *      A pointer.  NULL on out of memory condition.
+ *
+ * Side effects:
+ *      None
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static INLINE void *
+AlignedReallocImpl(void *oldbuf,    // IN
+                   size_t newsize)  // IN
+{
+   size_t paddedSize;
+   void **buf;
+   void **alignedResult;
+   void *oldptr = NULL;
+
+   if (oldbuf) {
+      oldptr = (*((void **)oldbuf - 1));
+   }
+
+   paddedSize = PAGE_SIZE + sizeof *buf + newsize;
+
+   // Check for overflow.
+   if (paddedSize < newsize) {
+      return NULL;
+   }
+
+   buf = (void **)realloc(oldptr, paddedSize);
+   if (!buf) {
+      return NULL;
+   }
+
+   alignedResult = (void **)PAGE_ROUND_UP(buf + 1);
+   *(alignedResult - 1) = buf;
+
+   return alignedResult;
+}
+
 /*
  *-----------------------------------------------------------------------------
  *
@@ -265,5 +311,72 @@ Aligned_Free(void *buf)  // IN
 #endif
 }
 
+
+/*
+ *---------------------------------------------------------------------------
+ *
+ * Aligned_UnsafeRealloc --
+ *
+ *      This function is not implemented because it cannot be done safely and
+ *      portably.  See https://reviewboard.eng.vmware.com/r/284303/ for
+ *      discussion.
+ *
+ *---------------------------------------------------------------------------
+ */
+
+
+/*
+ *---------------------------------------------------------------------------
+ *
+ * Aligned_Realloc --
+ *
+ *      Realloc a chunk of memory aligned on a page boundary, potentially
+ *      copying the previous data to a new buffer if necessary.  Resulting
+ *      pointer needs to be freed with Aligned_Free.  You should never use this
+ *      function.  Especially if size was derived from guest provided data.
+ *
+ * Result:
+ *      A pointer.
+ *
+ * Side effects:
+ *      Old buf may be freed.
+ *
+ *---------------------------------------------------------------------------
+ */
+
+static INLINE void*
+Aligned_Realloc(void *buf,   // IN
+                size_t size) // IN
+{
+#if defined MEMALIGNED_USE_INTERNAL_IMPL
+   return AlignedReallocImpl(buf, size);
+#elif defined _WIN32
+   return _aligned_realloc(buf, size, PAGE_SIZE);
+#else
+   /*
+    * Some valloc(3) manpages claim that realloc(3) on a buffer allocated by
+    * valloc() will return an aligned buffer.  If so, we have a fast path;
+    * simply realloc, validate the alignment, and return.  For realloc()s that
+    * do not maintain the alignment (such as glibc 2.13 x64 for allocations of
+    * 16 pages or less) then we fall back to a slowpath and copy the data.
+    * Note that we can't avoid the realloc overhead in this case: on entry to
+    * Aligned_Realloc we have no way to find out how big the source buffer is!
+    * Only after the realloc do we know a safe range to copy.  We may copy more
+    * data than necessary -- consider the case of resizing from one page to
+    * 100 pages -- but that is safe, just slow.
+    */
+   buf = realloc(buf, size);
+   if (((uintptr_t)buf % PAGE_SIZE) != 0) {
+      void *newbuf;
+
+      newbuf = Aligned_UnsafeMalloc(size);
+      ASSERT_MEM_ALLOC(newbuf);
+      memcpy(newbuf, buf, size);
+      free(buf);
+      return newbuf;
+   }
+   return buf;
 #endif
+}
 
+#endif
index e20e994e13004834f06afa12c85a190a044f6fd1..c7252646f3c0ab485a0980a6de28ce1557b9609d 100644 (file)
 #define VDM_VERSION "e.x.p"
 #define VMSAFE_VERSION        "1.2.0"
 #define VMSAFE_FILE_VERSION    1,2,0,PRODUCT_BUILD_NUMBER_NUMERIC
-#define NETDUMP_VERSION        "1.1.0"
-#define NETDUMP_FILE_VERSION    1,1,0,PRODUCT_BUILD_NUMBER_NUMERIC
+#define NETDUMP_VERSION        "5.1.0"
+#define NETDUMP_FILE_VERSION    5,1,0,PRODUCT_BUILD_NUMBER_NUMERIC
 #define VDDK_VERSION          "5.1.0"
 #define VDDK_FILE_VERSION      5,1,0,PRODUCT_BUILD_NUMBER_NUMERIC
 #define OVFTOOL_VERSION "e.x.p"
 #define PCOIP_VERSION "e.x.p"
 #define VIEW_VERSION "0.0.0"
 #define HOSTD_VERSION "e.x.p"
+#define RECOVERYLIBS_VERSION "2.0.0"
 
 
 #ifndef MAKESTR
  */
 #define TOOLS_VERSION TOOLS_VERSION_CURRENT_STR
 
-#define USB_ARBITRATOR_VERSION_MAJOR 9
+#define USB_ARBITRATOR_VERSION_MAJOR 10
 #define USB_ARBITRATOR_VERSION_MINOR 0
-#define USB_ARBITRATOR_VERSION_Z     44
+#define USB_ARBITRATOR_VERSION_Z     9
 
 #define USB_ARBITRATOR_VERSION_BASE  USB_ARBITRATOR_VERSION_MAJOR.\
                                      USB_ARBITRATOR_VERSION_MINOR
  * USB Arbitrator Component version. This version is used by the linux
  * installer. See USB_ARBITRATOR_COMPONENT_VERSION_NUMBER in mk/defs-onetime.mk
  */
-#define USB_ARBITRATOR_COMPONENT_VERSION_NUMBER "9.0.44"
+#define USB_ARBITRATOR_COMPONENT_VERSION_NUMBER "10.0.9"
 
 #ifdef VMX86_VPX
 #define VIM_API_TYPE "VirtualCenter"
 #define PRODUCT_VERSION_WORKSTATION_65 PRODUCT_WORKSTATION_BRIEF_NAME " 6.5"
 #define PRODUCT_VERSION_WORKSTATION_7 PRODUCT_WORKSTATION_BRIEF_NAME " 7.x"
 #define PRODUCT_VERSION_WORKSTATION_80 PRODUCT_WORKSTATION_BRIEF_NAME " 8.0"
+#define PRODUCT_VERSION_WORKSTATION_85 PRODUCT_WORKSTATION_BRIEF_NAME " 8.5"
 #define PRODUCT_VERSION_WORKSTATION_ENTERPRISE_1 "ACE 1.x"
 #define PRODUCT_VERSION_WORKSTATION_ENTERPRISE_2 "ACE 2.0"
 #define PRODUCT_VERSION_WORKSTATION_ENTERPRISE_25 "ACE 2.5"
 #define PRODUCT_VERSION_MAC_DESKTOP_2 PRODUCT_MAC_DESKTOP_BRIEF_NAME " 2.x"
 #define PRODUCT_VERSION_MAC_DESKTOP_3 PRODUCT_MAC_DESKTOP_BRIEF_NAME " 3.x"
 #define PRODUCT_VERSION_MAC_DESKTOP_40 PRODUCT_MAC_DESKTOP_BRIEF_NAME " 4.0"
+#define PRODUCT_VERSION_MAC_DESKTOP_45 PRODUCT_MAC_DESKTOP_BRIEF_NAME " 4.5"
 
 
 /*
index d4f60c5bef67c3d436d25019664580140aa77197..032bd5d79dcbbadc29f407d087dd10686ba8c9e4 100644 (file)
@@ -56,6 +56,29 @@ typedef uint8 Eth_Address[ETH_ADDR_LENGTH];
 #define ETH_ADDR_FMT_STR     "%02x:%02x:%02x:%02x:%02x:%02x"
 #define ETH_ADDR_FMT_ARGS(a) ((uint8 *)a)[0], ((uint8 *)a)[1], ((uint8 *)a)[2], \
                              ((uint8 *)a)[3], ((uint8 *)a)[4], ((uint8 *)a)[5]
+
+#define ETH_MAX_EXACT_MULTICAST_ADDRS 32
+
+typedef enum Eth_RxMode {
+   ETH_FILTER_UNICAST   = 0x0001,   // pass unicast (directed) frames
+   ETH_FILTER_MULTICAST = 0x0002,   // pass some multicast frames
+   ETH_FILTER_ALLMULTI  = 0x0004,   // pass *all* multicast frames
+   ETH_FILTER_BROADCAST = 0x0008,   // pass broadcast frames
+   ETH_FILTER_PROMISC   = 0x0010,   // pass all frames (ie no filter)
+   ETH_FILTER_USE_LADRF = 0x0020,   // use the LADRF for multicast filtering
+   ETH_FILTER_SINK      = 0x10000   // pass not-matched unicast frames
+} Eth_RxMode;
+
+// filter flags printf helpers
+#define ETH_FILTER_FLAG_FMT_STR     "%s%s%s%s%s%s%s"
+#define ETH_FILTER_FLAG_FMT_ARGS(f) (f) & ETH_FILTER_UNICAST   ? "  UNICAST"   : "", \
+                                    (f) & ETH_FILTER_MULTICAST ? "  MULTICAST" : "", \
+                                    (f) & ETH_FILTER_ALLMULTI  ? "  ALLMULTI"  : "", \
+                                    (f) & ETH_FILTER_BROADCAST ? "  BROADCAST" : "", \
+                                    (f) & ETH_FILTER_PROMISC   ? "  PROMISC"   : "", \
+                                    (f) & ETH_FILTER_USE_LADRF ? "  USE_LADRF" : "", \
+                                    (f) & ETH_FILTER_SINK      ? "  SINK"      : ""
+
 // Ethernet header type
 typedef enum {
    ETH_HEADER_TYPE_DIX,
index 6e44aea2bb5cf2bdc370b1f8e9a60cecbdd8a2ae..8d5b7ce6d1a615ba922d3950b192559879bb0334 100644 (file)
@@ -88,4 +88,5 @@
 #define VMNET_CAP_IP6_CSUM_EXT_HDRS 0x10000000 /* support csum of ip6 ext hdrs */
 #define VMNET_CAP_TSO6_EXT_HDRS 0x20000000 /* support TSO for ip6 ext hdrs */
 #define VMNET_CAP_SCHED       0x40000000 /* compliant with network scheduling */
+#define VMNET_CAP_SRIOV       0x80000000 /* Supports SR-IOV */
 #endif // _VMNET_DEF_H_