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