From 106653ffe4047765b06e354f2759c0f8d06244f8 Mon Sep 17 00:00:00 2001 From: Rom Walton Date: Wed, 5 Feb 2014 16:23:46 -0500 Subject: [PATCH] VBOX: If vboxmanage returns a CO_E_SERVER_EXEC_FAILURE error, go again and retry the command anyway. Vboxsvc may be running and working but some other oddity prevented vboxmanage from communicating with vboxsvc. Evidence suggests future attempts may not fail. Trace logs indicates that the clean-up routines did not fail when we attempted to cleanup the environment before reporting a failure. --- samples/vboxwrapper/vbox.cpp | 27 ++++++++++++++++++++++++++- samples/vboxwrapper/vbox.h | 3 +++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/samples/vboxwrapper/vbox.cpp b/samples/vboxwrapper/vbox.cpp index 63ad51ac22..65b6815071 100644 --- a/samples/vboxwrapper/vbox.cpp +++ b/samples/vboxwrapper/vbox.cpp @@ -2681,9 +2681,34 @@ int VBOX_VM::vbm_popen(string& command, string& output, const char* item, bool l sleep_interval *= 2; } } + + // VboxManage has to be able to communicate with vboxsvc in order to actually issue a + // command. In cases where we detect CO_E_SERVER_EXEC_FAILURE, we should just automatically + // try the command again. Vboxmanage wasn't even able to issue the desired command + // anyway. + // + // Experiments performed by jujube suggest changing the sleep interval to an exponential + // style backoff would increase our chances of success. + // + // Error Code: CO_E_SERVER_EXEC_FAILURE (0x80080005) + // + if (CO_E_SERVER_EXEC_FAILURE == retval) { + if (retry_notes.find("Unable to communicate with VirtualBox") == string::npos) { + retry_notes += "Unable to communicate with VirtualBox. VirtualBox may need to\n"; + retry_notes += "be reinstalled.\n\n"; + } + if (retry_count) { + sleep_interval *= 2; + } + } // Retry? - if (!retry_failures) break; + if (!retry_failures && + (VBOX_E_INVALID_OBJECT_STATE != retval) && + (CO_E_SERVER_EXEC_FAILURE != retval) + ) { + break; + } // Timeout? if (retry_count >= 5) break; diff --git a/samples/vboxwrapper/vbox.h b/samples/vboxwrapper/vbox.h index 92ee9da112..321fe7cae1 100644 --- a/samples/vboxwrapper/vbox.h +++ b/samples/vboxwrapper/vbox.h @@ -23,6 +23,9 @@ // Known VirtualBox/COM error codes // +#ifndef CO_E_SERVER_EXEC_FAILURE +#define CO_E_SERVER_EXEC_FAILURE 0x80080005 +#endif #ifndef RPC_S_SERVER_UNAVAILABLE #define RPC_S_SERVER_UNAVAILABLE 0x800706ba #endif