]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
Internal branch sync. Included in this change:
authorVMware, Inc <>
Wed, 18 Sep 2013 03:38:49 +0000 (20:38 -0700)
committerDmitry Torokhov <dmitry.torokhov@gmail.com>
Mon, 23 Sep 2013 05:26:42 +0000 (22:26 -0700)
. Support Linux Quiescing for vSphere Replication
. changes in shared code that don't affect open-vm-tools functionality

Signed-off-by: Dmitry Torokhov <dtor@vmware.com>
open-vm-tools/lib/file/file.c
open-vm-tools/lib/include/file.h
open-vm-tools/lib/include/vm_basic_defs.h
open-vm-tools/lib/include/vm_product_versions.h
open-vm-tools/services/plugins/vmbackup/Makefile.am
open-vm-tools/services/plugins/vmbackup/guestQuiesce.x [new file with mode: 0644]
open-vm-tools/services/plugins/vmbackup/stateMachine.c

index 3b9412ce7475fa333719dbdbdef8cdbbf54420b5..569e231f4c04ddcd7b52b8efff6cb0447477e7a1 100644 (file)
@@ -688,6 +688,55 @@ File_IsEmptyDirectory(ConstUnicode pathName)  // IN:
 }
 
 
+/*
+ *----------------------------------------------------------------------------
+ *
+ * File_IsOsfsVolumeEmpty --
+ *
+ *      Check if specified OSFS volume contains no files.
+ *      This method ignore hidden .sf files. *.sf files are VMFS
+ *      metadata files.
+ *
+ *      OSFS based volumes are considered empty even if they
+ *      contain vmfs metadata files. This emptiness can not be
+ *      checked by File_IsEmptyDirectory API (PR 1050328).
+ *
+ * Results:
+ *      Bool - TRUE -> is vmfs empty directory, FALSE -> not an vmfs
+ *      empty directory
+ *
+ * Side effects:
+ *      None
+ *
+ *----------------------------------------------------------------------------
+ */
+
+Bool
+File_IsOsfsVolumeEmpty(ConstUnicode pathName)  // IN:
+{
+   int i, numFiles;
+   Unicode *fileList = NULL;
+   static const char vmfsSystemFilesuffix[] = ".sf";
+   Bool onlyVmfsSystemFilesFound = TRUE;
+
+   numFiles = File_ListDirectory(pathName, &fileList);
+   if (numFiles == -1) {
+      return FALSE;
+   }
+
+   for (i = 0; i < numFiles; i++) {
+      if (!Unicode_EndsWith(fileList[i], vmfsSystemFilesuffix)) {
+         onlyVmfsSystemFilesFound = FALSE;
+         break;
+      }
+   }
+
+   Unicode_FreeList(fileList, numFiles);
+
+   return onlyVmfsSystemFilesFound;
+}
+
+
 /*
  *----------------------------------------------------------------------
  *
index 19eb04c22e1b018d34fdaa9f97985e2cdd9d5da4..caa6cfcfbe8cb216edb88a7838a252dc539f12f3 100644 (file)
@@ -183,6 +183,8 @@ Bool File_DeleteDirectoryTree(ConstUnicode pathName);
 int File_ListDirectory(ConstUnicode pathName,
                        Unicode **ids);
 
+Bool File_IsOsfsVolumeEmpty(ConstUnicode pathName);
+
 /*
  * Simple file-system walk.
  */
index 84f4e33d805c8130a93a359eda75d83e9b2b4ed0..6f21f033aca9f19532720b71860c7a0d686cde99 100644 (file)
@@ -297,9 +297,17 @@ Max(int a, int b)
 #define MBYTES_2_BYTES(_nbytes) ((uint64)(_nbytes) << 20)
 #endif
 
+#ifndef BYTES_2_GBYTES
+#define BYTES_2_GBYTES(_nbytes) ((_nbytes) >> 30)
+#endif
+
+#ifndef GBYTES_2_BYTES
+#define GBYTES_2_BYTES(_nbytes) ((uint64)(_nbytes) << 30)
+#endif
+
 #ifndef VM_PAE_LARGE_PAGE_SHIFT
 #define VM_PAE_LARGE_PAGE_SHIFT 21
-#endif 
+#endif
 
 #ifndef VM_PAE_LARGE_PAGE_SIZE
 #define VM_PAE_LARGE_PAGE_SIZE (1 << VM_PAE_LARGE_PAGE_SHIFT)
index a010c223de0f4c51de441446ec88d7f5c73a4963..d14b999833592d58390acaac23d27c153c9b381d 100644 (file)
 #  define PRODUCT_LICENSE_VERSION "0.0"
 #else
 #  if defined(VMX86_SERVER)
-#    define PRODUCT_LICENSE_VERSION "5.0"
+#    define PRODUCT_LICENSE_VERSION "6.0"
 #  elif defined(VMX86_WGS_MIGRATION)
 #    define PRODUCT_LICENSE_VERSION "1.0"
 #  elif defined(VMX86_WGS)
 #      define PRODUCT_LICENSE_VERSION "10.0"
 #    endif
 #  elif defined(VMX86_VPX)
-#    define PRODUCT_LICENSE_VERSION "5.0"
-#    define PRODUCT_LICENSE_FILE_VERSION "5.5.0.1"
+#    define PRODUCT_LICENSE_VERSION "6.0"
+#    define PRODUCT_LICENSE_FILE_VERSION "6.0.0.0"
 #  elif defined(VMX86_WBC)
 #    define PRODUCT_LICENSE_VERSION "1.0"
 #  elif defined(VMX86_SDK)
index d78eda6e7af638a5e388082bb8f613d60101409f..2babc4ce8b23e7f8d381d17387f289348dcdfa97 100644 (file)
@@ -38,14 +38,26 @@ libvmbackup_la_SOURCES += vmBackupSignals.c
 BUILT_SOURCES =
 BUILT_SOURCES += vmBackupSignals.c
 BUILT_SOURCES += vmBackupSignals.h
+BUILT_SOURCES += guestQuiesce.h
+BUILT_SOURCES += guestQuiesce_xdr.c
 
 CLEANFILES =
 CLEANFILES += vmBackupSignals.c
 CLEANFILES += vmBackupSignals.h
+CLEANFILES += guestQuiesce.h
+CLEANFILES += guestQuiesce_xdr.c
 
 EXTRA_DIST =
 EXTRA_DIST += vmBackupSignals.gm
 
+libvmbackup_la_SOURCES += guestQuiesce_xdr.c
+
+guestQuiesce.h: guestQuiesce.x
+               @RPCGEN_WRAPPER@ services/plugins/vmbackup/guestQuiesce.x $@
+
+guestQuiesce_xdr.c: guestQuiesce.x guestQuiesce.h
+               @RPCGEN_WRAPPER@ services/plugins/vmbackup/guestQuiesce.x $@
+
 vmBackupSignals.c: $(top_srcdir)/services/plugins/vmbackup/vmBackupSignals.gm
        glib-genmarshal --body $(top_srcdir)/services/plugins/vmbackup/vmBackupSignals.gm > \
           $@ || (rm -f $@ && exit 1)
diff --git a/open-vm-tools/services/plugins/vmbackup/guestQuiesce.x b/open-vm-tools/services/plugins/vmbackup/guestQuiesce.x
new file mode 100644 (file)
index 0000000..3aefef8
--- /dev/null
@@ -0,0 +1,48 @@
+/*********************************************************
+ * Copyright (C) 2010 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
+ * by the Free Software Foundation version 2.1 and no later version.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
+ * or FITNESS FOR A PARTICULAR PURPOSE.  See the Lesser GNU General Public
+ * License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public License
+ * along with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA.
+ *
+ *********************************************************/
+
+/*
+ * guestQuiesce.x --
+ *
+ *    Definition of the data structures used in the GuestRpc commands to
+ *    provide information about guest quiescing settings.
+ */
+
+enum GuestQuiesceParamsVersion {
+   GUESTQUIESCEPARAMS_V1 = 1
+};
+
+const GUESTQUIESCE_SCRIPTARG_MAX_LEN = 256;
+const GUESTQUIESCE_DISKUUID_MAX_LEN = 3200;   /* (UUID_MAXLEN + 1) * 64 disks */
+
+/*  Guest Quiescing parameters. */
+struct GuestQuiesceParamsV1 {
+   Bool createManifest;     /* Create manifest describing the operations */
+   Bool quiesceApps;        /* Allow application quiescing */
+   Bool quiesceFS;          /* Allow file system quiescing */
+   Bool writableSnapshot;   /* Assume writable snapshot is allowed */
+   Bool execScripts;        /* Run custom scripts created by the users */
+   string scriptArg<GUESTQUIESCE_SCRIPTARG_MAX_LEN>;  /* Argument to  scripts */
+   uint32 timeout;          /* Time out for the quiesce operation*/
+   string diskUuids<GUESTQUIESCE_DISKUUID_MAX_LEN>;   /* disk Uuids */
+};
+
+union GuestQuiesceParams switch (GuestQuiesceParamsVersion ver) {
+case GUESTQUIESCEPARAMS_V1:
+   struct GuestQuiesceParamsV1 *guestQuiesceParamsV1;
+};
index a17fda086b81478af056458ebce7e1b2de834bb1..bbd6b778d8fac6e0ad8922038d60a30e67541bb4 100644 (file)
@@ -43,9 +43,7 @@
 #include "strutil.h"
 #include "util.h"
 #include "vmBackupSignals.h"
-#if defined(_WIN32)
-#include "vmware/guestrpc/guestQuiesce.h"
-#endif
+#include "guestQuiesce.h"
 #include "vmware/tools/utils.h"
 #include "vmware/tools/vmbackup.h"
 #include "xdrutil.h"
@@ -572,15 +570,17 @@ VmBackupConfigGetBoolean(GKeyFile *config,
  * Starts the quiesce operation according to the supplied specification unless
  * some unexpected error occurs.
  *
- * @param[in]  data      RPC data.
- * @param[in]  forceVss  Only allow Vss quiescing or no quiescing.
+ * @param[in]  data          RPC data.
+ * @param[in]  forceQuiesce  Only allow Vss quiescing on Windows platform or
+ *                           SyncDriver quiescing on Linux platform ( only file
+ *                           system quiescing )
  *
  * @return TRUE on success.
  */
 
 static gboolean
 VmBackupStartCommon(RpcInData *data,
-                    gboolean forceVss)
+                    gboolean forceQuiesce)
 {
    GError *err = NULL;
    ToolsAppCtx *ctx = data->appCtx;
@@ -600,12 +600,24 @@ VmBackupStartCommon(RpcInData *data,
       { VmBackup_NewNullProvider, NULL },
    };
 
-   if (forceVss) {
+   if (forceQuiesce) {
       if (gBackupState->quiesceApps || gBackupState->quiesceFS) {
-          /* If quiescing is requested, only allow VSS provider */
+         /*
+          * If quiescing is requested on windows platform,
+          * only allow VSS provider
+          */
 #if defined(_WIN32)
-          if (VmBackupConfigGetBoolean(ctx->config, "enableVSS", TRUE)) {
-             provider = VmBackup_NewVssProvider();
+         if (VmBackupConfigGetBoolean(ctx->config, "enableVSS", TRUE)) {
+            provider = VmBackup_NewVssProvider();
+         }
+#elif defined(_LINUX) || defined(__linux__)
+         /*
+          * If quiescing is requested on linux platform,
+          * only allow SyncDriver provider
+          */
+         if (gBackupState->quiesceFS &&
+             VmBackupConfigGetBoolean(ctx->config, "enableSyncDriver", TRUE)) {
+            provider = VmBackup_NewSyncDriverProvider();
           }
 #endif
       } else {
@@ -760,7 +772,6 @@ VmBackupStart(RpcInData *data)
    return VmBackupStartCommon(data, FALSE);
 }
 
-#if defined(_WIN32)
 
 /**
  * Handler for the "vmbackup.startWithOpts" message. Starts processing the
@@ -827,7 +838,6 @@ VmBackupStartWithOpts(RpcInData *data)
    return retval;
 }
 
-#endif
 
 /**
  * Aborts the current operation if one is active, and stops the backup
@@ -973,11 +983,9 @@ ToolsOnLoad(ToolsAppCtx *ctx)
 
    RpcChannelCallback rpcs[] = {
       { VMBACKUP_PROTOCOL_START, VmBackupStart, NULL, NULL, NULL, 0 },
-#if defined(_WIN32)
       /* START_WITH_OPTS command supported only on Windows for now */
       { VMBACKUP_PROTOCOL_START_WITH_OPTS, VmBackupStartWithOpts, NULL,
                     xdr_GuestQuiesceParams, NULL, sizeof (GuestQuiesceParams) },
-#endif
       { VMBACKUP_PROTOCOL_ABORT, VmBackupAbort, NULL, NULL, NULL, 0 },
       { VMBACKUP_PROTOCOL_SNAPSHOT_DONE, VmBackupSnapshotDone, NULL, NULL, NULL, 0 }
    };