From: VMware, Inc <> Date: Mon, 20 Sep 2010 18:15:59 +0000 (-0700) Subject: vmbackup: provide better errors to the host. X-Git-Tag: 2010.09.19-301124~14 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=604b3ce0926c567e9d8df176c15ff2b698f9eeaf;p=thirdparty%2Fopen-vm-tools.git vmbackup: provide better errors to the host. Allow providers to set an error message in the backup state object, which is then used to construct the full error message. The "errorMsg" field could probably have been done in a cleaner way, but right now that would require too much churn in the plugin's internal API (which needs some more thorough cleanup at some point). Signed-off-by: Marcelo Vanzin --- diff --git a/open-vm-tools/services/plugins/vmbackup/stateMachine.c b/open-vm-tools/services/plugins/vmbackup/stateMachine.c index ee966378f..b704603dc 100644 --- a/open-vm-tools/services/plugins/vmbackup/stateMachine.c +++ b/open-vm-tools/services/plugins/vmbackup/stateMachine.c @@ -213,6 +213,7 @@ VmBackupFinalize(void) g_free(gBackupState->scriptArg); g_free(gBackupState->volumes); g_free(gBackupState->snapshots); + g_free(gBackupState->errorMsg); g_free(gBackupState); gBackupState = NULL; } @@ -404,20 +405,19 @@ VmBackupAsyncCallback(void *clientData) default: { - Bool freeMsg = TRUE; - char *errMsg = Str_Asprintf(NULL, - "Asynchronous operation failed: %s", - gBackupState->currentOpName); - if (errMsg == NULL) { - freeMsg = FALSE; - errMsg = "Asynchronous operation failed."; + gchar *msg; + if (gBackupState->errorMsg != NULL) { + msg = g_strdup_printf("'%s' operation failed: %s", + gBackupState->currentOpName, + gBackupState->errorMsg); + } else { + msg = g_strdup_printf("'%s' operation failed.", + gBackupState->currentOpName); } VmBackup_SendEvent(VMBACKUP_EVENT_REQUESTOR_ERROR, VMBACKUP_UNEXPECTED_ERROR, - errMsg); - if (freeMsg) { - vm_free(errMsg); - } + msg); + g_free(msg); VmBackup_Release(gBackupState->currentOp); gBackupState->currentOp = NULL; diff --git a/open-vm-tools/services/plugins/vmbackup/vmBackupInt.h b/open-vm-tools/services/plugins/vmbackup/vmBackupInt.h index d6382a642..6c0e79cf2 100644 --- a/open-vm-tools/services/plugins/vmbackup/vmBackupInt.h +++ b/open-vm-tools/services/plugins/vmbackup/vmBackupInt.h @@ -100,6 +100,7 @@ typedef struct VmBackupState { void *scripts; const char *configDir; ssize_t currentScript; + gchar *errorMsg; VmBackupMState machineState; struct VmBackupSyncProvider *provider; } VmBackupState;