#include <process.h>
#endif
+/*
+ * Define an enumeration type VmBackupOpType and a corresponding array
+ * VmBackupOpName whose entries provide the printable names of the
+ * enumeration ids in VmBackupOpType.
+ *
+ * VmBackupOpType and VmBackupOpName are each defined as an invocation
+ * of a macro VMBACKUP_OPLIST. VMBACKUP_OPLIST specifies a list of
+ * enumeration ids using a macro VMBACKUP_OP that must be defined before
+ * invoking VMBACKUP_OPLIST. VMBACKUP_OP takes a single argument, which
+ * should be an enumeration id, and is defined to generate from the id
+ * either the id itself or a string to be used as its printable name. The
+ * result is that an invocation of VMBACKUP_OPLIST generates either the
+ * list of enumeration ids or the list of their printable names.
+ */
+#define VMBACKUP_OPLIST \
+ VMBACKUP_OP(OP_FREEZE), \
+ VMBACKUP_OP(OP_THAW), \
+ VMBACKUP_OP(OP_UNDO),
+
+#define VMBACKUP_OPID(id) id
+#define VMBACKUP_OPNAME(id) #id
+
+#undef VMBACKUP_OP
+#define VMBACKUP_OP(id) VMBACKUP_OPID(id)
+
+typedef enum {
+ VMBACKUP_OPLIST
+} VmBackupOpType;
+
+#undef VMBACKUP_OP
+#define VMBACKUP_OP(id) VMBACKUP_OPNAME(id)
+
+static const char *VmBackupOpName[] = {
+ VMBACKUP_OPLIST
+};
+
+#undef VMBACKUP_OP
+
typedef struct VmBackupDriverOp {
VmBackupOp callbacks;
const char *volumes;
- Bool freeze;
+ VmBackupOpType opType;
Bool canceled;
SyncDriverHandle *syncHandle;
SyncManifest *manifest;
} VmBackupDriverOp;
-
/*
*-----------------------------------------------------------------------------
*
VmBackupDriverOp *op = (VmBackupDriverOp *) _op;
VmBackupOpStatus ret;
- if (op->freeze) {
+ if (op->opType == OP_FREEZE) {
SyncDriverStatus st = SyncDriver_QueryStatus(*op->syncHandle, 0);
g_debug("SyncDriver status: %d\n", st);
static VmBackupDriverOp *
VmBackupNewDriverOp(VmBackupState *state, // IN
- Bool freeze, // IN
+ VmBackupOpType opType, // IN
SyncDriverHandle *handle, // IN
const char *volumes, // IN
Bool useNullDriverPrefs) // IN
Bool success;
VmBackupDriverOp *op = NULL;
- g_return_val_if_fail((handle == NULL || *handle == SYNCDRIVER_INVALID_HANDLE) ||
- !freeze,
+ g_return_val_if_fail((handle == NULL ||
+ *handle == SYNCDRIVER_INVALID_HANDLE) ||
+ opType != OP_FREEZE,
NULL);
op = Util_SafeMalloc(sizeof *op);
op->callbacks.queryFn = VmBackupDriverOpQuery;
op->callbacks.cancelFn = VmBackupDriverOpCancel;
op->callbacks.releaseFn = VmBackupDriverOpRelease;
- op->freeze = freeze;
+ op->opType = opType;
op->volumes = volumes;
op->syncHandle = g_new0(SyncDriverHandle, 1);
*op->syncHandle = (handle != NULL) ? *handle : SYNCDRIVER_INVALID_HANDLE;
- if (freeze) {
- success = SyncDriver_Freeze(op->volumes,
- useNullDriverPrefs ?
- state->enableNullDriver : FALSE,
- op->syncHandle,
- state->excludedFileSystems);
- } else {
- op->manifest = SyncNewManifest(state, *op->syncHandle);
- success = VmBackupDriverThaw(op->syncHandle);
+ switch (opType) {
+ case OP_FREEZE:
+ success = SyncDriver_Freeze(op->volumes,
+ useNullDriverPrefs ?
+ state->enableNullDriver : FALSE,
+ op->syncHandle,
+ state->excludedFileSystems);
+ break;
+ case OP_THAW:
+ op->manifest = SyncNewManifest(state, *op->syncHandle);
+ success = VmBackupDriverThaw(op->syncHandle);
+ break;
+ default:
+ ASSERT(opType == OP_UNDO);
+ success = VmBackupDriverThaw(op->syncHandle);
+ break;
}
if (!success) {
- g_warning("Error %s filesystems.", freeze ? "freezing" : "thawing");
+ g_warning("Error trying to perform %s on filesystems.",
+ VmBackupOpName[opType]);
g_free(op->syncHandle);
SyncManifestRelease(op->manifest);
free(op);
VmBackupDriverOp *op;
g_debug("*** %s\n", __FUNCTION__);
- op = VmBackupNewDriverOp(state, TRUE, NULL, state->volumes, TRUE);
+ op = VmBackupNewDriverOp(state, OP_FREEZE, NULL, state->volumes, TRUE);
if (op != NULL) {
state->clientData = op->syncHandle;
VmBackupDriverOp *op;
g_debug("*** %s\n", __FUNCTION__);
- op = VmBackupNewDriverOp(state, TRUE, NULL, state->volumes, FALSE);
+ op = VmBackupNewDriverOp(state, OP_FREEZE, NULL, state->volumes, FALSE);
if (op != NULL) {
state->clientData = op->syncHandle;
VmBackupState *state = (VmBackupState*) clientData;
g_debug("*** %s\n", __FUNCTION__);
- op = VmBackupNewDriverOp(state, TRUE, NULL, state->volumes, TRUE);
+ op = VmBackupNewDriverOp(state, OP_FREEZE, NULL, state->volumes, TRUE);
if (op != NULL) {
state->clientData = op->syncHandle;
VmBackupState *state = (VmBackupState*) clientData;
g_debug("*** %s\n", __FUNCTION__);
- op = VmBackupNewDriverOp(state, TRUE, NULL, state->volumes, FALSE);
+ op = VmBackupNewDriverOp(state, OP_FREEZE, NULL, state->volumes, FALSE);
if (op != NULL) {
state->clientData = op->syncHandle;
g_debug("*** %s\n", __FUNCTION__);
- op = VmBackupNewDriverOp(state, FALSE, state->clientData, NULL, TRUE);
+ op = VmBackupNewDriverOp(state, OP_THAW, state->clientData, NULL, TRUE);
g_free(state->clientData);
state->clientData = NULL;
g_debug("*** %s\n", __FUNCTION__);
- op = VmBackupNewDriverOp(state, FALSE, state->clientData, NULL, FALSE);
+ op = VmBackupNewDriverOp(state, OP_THAW, state->clientData, NULL, FALSE);
+ g_free(state->clientData);
+ state->clientData = NULL;
+
+ return VmBackup_SetCurrentOp(state, (VmBackupOp *) op, NULL, __FUNCTION__);
+}
+
+
+#if defined(__linux__)
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * VmBackupSyncDriverUndo --
+ *
+ * Undo a completed quiescing operation.
+ *
+ * Result
+ * TRUE, unless an error occurs.
+ *
+ * Side effects:
+ * None.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static Bool
+VmBackupSyncDriverUndo(VmBackupState *state,
+ void *clientData)
+{
+ VmBackupDriverOp *op;
+
+ g_debug("*** %s\n", __FUNCTION__);
+
+ op = VmBackupNewDriverOp(state, OP_UNDO, state->clientData, NULL, TRUE);
+ g_free(state->clientData);
+ state->clientData = NULL;
+
+ return VmBackup_SetCurrentOp(state, (VmBackupOp *) op, NULL, __FUNCTION__);
+}
+
+
+/*
+ *-----------------------------------------------------------------------------
+ *
+ * VmBackupSyncDriverOnlyUndo --
+ *
+ * Undo a completed quiescing operation.
+ *
+ * Result
+ * TRUE, unless an error occurs.
+ *
+ * Side effects:
+ * None.
+ *
+ *-----------------------------------------------------------------------------
+ */
+
+static Bool
+VmBackupSyncDriverOnlyUndo(VmBackupState *state,
+ void *clientData)
+{
+ VmBackupDriverOp *op;
+
+ g_debug("*** %s\n", __FUNCTION__);
+
+ op = VmBackupNewDriverOp(state, OP_UNDO, state->clientData, NULL, FALSE);
g_free(state->clientData);
state->clientData = NULL;
return VmBackup_SetCurrentOp(state, (VmBackupOp *) op, NULL, __FUNCTION__);
}
+#endif
/*
if (useNullDriverPrefs) {
provider->start = VmBackupSyncDriverStart;
provider->snapshotDone = VmBackupSyncDriverSnapshotDone;
+#if defined(__linux__)
+ provider->undo = VmBackupSyncDriverUndo;
+#endif
} else {
provider->start = VmBackupSyncDriverOnlyStart;
provider->snapshotDone = VmBackupSyncDriverOnlySnapshotDone;
+#if defined(__linux__)
+ provider->undo = VmBackupSyncDriverOnlyUndo;
+#endif
}
+
provider->release = VmBackupSyncDriverRelease;
provider->clientData = NULL;