]> git.ipfire.org Git - thirdparty/open-vm-tools.git/commitdiff
vmbackup: provide better errors to the host.
authorVMware, Inc <>
Mon, 20 Sep 2010 18:15:59 +0000 (11:15 -0700)
committerMarcelo Vanzin <mvanzin@vmware.com>
Mon, 20 Sep 2010 18:15:59 +0000 (11:15 -0700)
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 <mvanzin@vmware.com>
open-vm-tools/services/plugins/vmbackup/stateMachine.c
open-vm-tools/services/plugins/vmbackup/vmBackupInt.h

index ee966378f6274f9d4023260d01bcfd88bf807ad5..b704603dce8a69e3a6cd32cbd1fca77604000d4b 100644 (file)
@@ -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;
index d6382a642ae00414b77920a41a8fbc07f519caed..6c0e79cf2aec4618bfc7d3e30bdfdfa19882a421 100644 (file)
@@ -100,6 +100,7 @@ typedef struct VmBackupState {
    void          *scripts;
    const char    *configDir;
    ssize_t        currentScript;
+   gchar         *errorMsg;
    VmBackupMState machineState;
    struct VmBackupSyncProvider *provider;
 } VmBackupState;