From eb739ebd0c7b9d56576eecedc8a30b918e153091 Mon Sep 17 00:00:00 2001 From: Martin Date: Fri, 6 May 2016 03:32:56 +0200 Subject: [PATCH] List provider after provider error --- urbackupclient/client.cpp | 41 +++++++++++++++++++++++++++++++++------ urbackupclient/client.h | 1 + 2 files changed, 36 insertions(+), 6 deletions(-) diff --git a/urbackupclient/client.cpp b/urbackupclient/client.cpp index 8283f64b..3c33730b 100644 --- a/urbackupclient/client.cpp +++ b/urbackupclient/client.cpp @@ -97,12 +97,12 @@ const int64 file_buffer_commit_interval=120*1000; #define ENABLE_VSS #endif -#define CHECK_COM_RESULT_RELEASE(x) { HRESULT r; if( (r=(x))!=S_OK ){ VSSLog(#x+(std::string)" failed: EC="+GetErrorHResErrStr(r), LL_ERROR); if(backupcom!=NULL){backupcom->AbortBackup();backupcom->Release();} return false; }} -#define CHECK_COM_RESULT_RETURN(x) { HRESULT r; if( (r=(x))!=S_OK ){ VSSLog( #x+(std::string)" failed: EC="+GetErrorHResErrStr(r), LL_ERROR); return false; }} -#define CHECK_COM_RESULT_RELEASE_S(x) { HRESULT r; if( (r=(x))!=S_OK ){ VSSLog( #x+(std::string)" failed: EC="+GetErrorHResErrStr(r), LL_ERROR); if(backupcom!=NULL){backupcom->AbortBackup();backupcom->Release();} return ""; }} -#define CHECK_COM_RESULT(x) { HRESULT r; if( (r=(x))!=S_OK ){ VSSLog( #x+(std::string)" failed: EC="+GetErrorHResErrStr(r), LL_ERROR); }} -#define CHECK_COM_RESULT_OK(x, ok) { HRESULT r; if( (r=(x))!=S_OK ){ ok=false; VSSLog( #x+(std::string)" failed: EC="+GetErrorHResErrStr(r), LL_ERROR); }} -#define CHECK_COM_RESULT_OK_HR(x, ok, r) { if( (r=(x))!=S_OK ){ ok=false; VSSLog( #x+(std::string)" failed: EC="+GetErrorHResErrStr(r), LL_ERROR); }} +#define CHECK_COM_RESULT_RELEASE(x) { HRESULT r; if( (r=(x))!=S_OK ){ VSSLog(#x+(std::string)" failed. VSS error code "+GetErrorHResErrStr(r), LL_ERROR); printProviderInfo(r); if(backupcom!=NULL){backupcom->AbortBackup();backupcom->Release();} return false; }} +#define CHECK_COM_RESULT_RETURN(x) { HRESULT r; if( (r=(x))!=S_OK ){ VSSLog( #x+(std::string)" failed. VSS error code"+GetErrorHResErrStr(r), LL_ERROR); printProviderInfo(r); return false; }} +#define CHECK_COM_RESULT_RELEASE_S(x) { HRESULT r; if( (r=(x))!=S_OK ){ VSSLog( #x+(std::string)" failed. VSS error code "+GetErrorHResErrStr(r), LL_ERROR); printProviderInfo(r); if(backupcom!=NULL){backupcom->AbortBackup();backupcom->Release();} return ""; }} +#define CHECK_COM_RESULT(x) { HRESULT r; if( (r=(x))!=S_OK ){ VSSLog( #x+(std::string)" failed. VSS error code "+GetErrorHResErrStr(r), LL_ERROR); printProviderInfo(r); }} +#define CHECK_COM_RESULT_OK(x, ok) { HRESULT r; if( (r=(x))!=S_OK ){ ok=false; VSSLog( #x+(std::string)" failed .VSS error code "+GetErrorHResErrStr(r), LL_ERROR); printProviderInfo(r); }} +#define CHECK_COM_RESULT_OK_HR(x, ok, r) { if( (r=(x))!=S_OK ){ ok=false; VSSLog( #x+(std::string)" failed. VSS error code "+GetErrorHResErrStr(r), LL_ERROR); printProviderInfo(r); }} void IdleCheckerThread::operator()(void) { @@ -2917,6 +2917,35 @@ std::string IndexThread::GetErrorHResErrStr(HRESULT res) return "VSS_E_VOLUME_NOT_SUPPORTED_BY_PROVIDER"; }; return "UNDEF"; +} + +void IndexThread::printProviderInfo(HRESULT res) +{ + if (res != VSS_E_UNEXPECTED_PROVIDER_ERROR) + { + return; + } + + std::string data; + if (os_popen("vssadmin list providers", data) == 0) + { + std::vector lines; + TokenizeMail(data, lines, "\n"); + + if (lines.size() > 3) + { + VSSLog("VSS provider information:", LL_ERROR); + + for (size_t i = 3; i < lines.size(); ++i) + { + std::string cl = trim(lines[i]); + if (!cl.empty()) + { + VSSLog(cl, LL_ERROR); + } + } + } + } } #endif diff --git a/urbackupclient/client.h b/urbackupclient/client.h index d6509800..41149717 100644 --- a/urbackupclient/client.h +++ b/urbackupclient/client.h @@ -263,6 +263,7 @@ private: bool start_shadowcopy_win( SCDirs * dir, std::string &wpath, bool for_imagebackup, bool * &onlyref ); bool wait_for(IVssAsync *vsasync); std::string GetErrorHResErrStr(HRESULT res); + void printProviderInfo(HRESULT res); bool check_writer_status(IVssBackupComponents *backupcom, std::string& errmsg, int loglevel, bool* retryable_error); bool checkErrorAndLog(BSTR pbstrWriter, VSS_WRITER_STATE pState, HRESULT pHrResultFailure, std::string& errmsg, int loglevel, bool* retryable_error); #else