[PATCH 0/8] vbox: Report VirtualBox exceptions too
See 5/8 for motivation. Michal Prívozník (8): vbox: Introduce VBOX_QUERY_INTERFACE() vbox: Introduce IVirtualBoxErrorInfo interface vbox: Introduce vboxUniformedPFN::GetException() vbox: Introduce vboxUniformedPFN::ClearException() vbox: Introduce vboxReportError() vbox: Replace virReportError() with vboxReportError() vbox: Move error messages onto a single line vbox: Stop reporting RC in error messages src/vbox/vbox_common.c | 1223 +++++++++++++++++---------------- src/vbox/vbox_common.h | 6 + src/vbox/vbox_tmpl.c | 52 ++ src/vbox/vbox_uniformed_api.h | 11 + 4 files changed, 712 insertions(+), 580 deletions(-) -- 2.39.1
So far we haven't needed to use a different interface for objects we are working with. We were happy with calling their respective vtbl callbacks. Well, this will change soon as we will query an exception (type of nsIException) but will need to promote it to IVirtualBoxErrorInfo class. This promoting is done by QueryInterface() callback which accepts 3 arguments: the original object, ID of the new interface and address where to store the promoted object. As this is very basic operation, available to every object, it is part of the ISupports interface among with other goodies like AddRef() and Release(). Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/vbox/vbox_common.h | 3 +++ src/vbox/vbox_tmpl.c | 6 ++++++ src/vbox/vbox_uniformed_api.h | 1 + 3 files changed, 10 insertions(+) diff --git a/src/vbox/vbox_common.h b/src/vbox/vbox_common.h index 1fb922aaf0..38afdfddfa 100644 --- a/src/vbox/vbox_common.h +++ b/src/vbox/vbox_common.h @@ -405,6 +405,9 @@ typedef nsISupports IKeyboard; abort(); \ } while (0) +#define VBOX_QUERY_INTERFACE(nsi, iid, resultp) \ + gVBoxAPI.nsUISupports.QueryInterface((void*)(nsi), iid, resultp) + #define VBOX_ADDREF(arg) gVBoxAPI.nsUISupports.AddRef((void *)(arg)) #define VBOX_RELEASE(arg) \ diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index 52b1c93b6d..f01f8bd487 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -563,6 +563,11 @@ static void* _handleHostGetNetworkInterfaces(IHost *host) return host->vtbl->GetNetworkInterfaces; } +static nsresult _nsisupportsQueryInterface(nsISupports *nsi, const nsID *iid, void **resultp) +{ + return nsi->vtbl->QueryInterface(nsi, iid, resultp); +} + static nsresult _nsisupportsRelease(nsISupports *nsi) { return nsi->vtbl->Release(nsi); @@ -2238,6 +2243,7 @@ static vboxUniformedArray _UArray = { }; static vboxUniformednsISupports _nsUISupports = { + .QueryInterface = _nsisupportsQueryInterface, .Release = _nsisupportsRelease, .AddRef = _nsisupportsAddRef, }; diff --git a/src/vbox/vbox_uniformed_api.h b/src/vbox/vbox_uniformed_api.h index 18f352d98e..3ac6ba92a6 100644 --- a/src/vbox/vbox_uniformed_api.h +++ b/src/vbox/vbox_uniformed_api.h @@ -145,6 +145,7 @@ typedef struct { /* Functions for nsISupports */ typedef struct { + nsresult (*QueryInterface)(nsISupports *nsi, const nsID *iid, void **resultp); nsresult (*Release)(nsISupports *nsi); nsresult (*AddRef)(nsISupports *nsi); } vboxUniformednsISupports; -- 2.39.1
The IVirtualBoxErrorInfo interface allows us to query error messages from VirtualBox. Since VirtualBox has stacked errors we need the GetNext() method too. The odd one, that sticks out is GetIID() as it is not part of the interface as defined bu VirtualBox header files. BUT, we need to get the interface UUID (which MAY change across each release) so that it can be passed to VBOX_QUERY_INTERFACE() introduced earlier. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/vbox/vbox_common.h | 1 + src/vbox/vbox_tmpl.c | 34 ++++++++++++++++++++++++++++++++++ src/vbox/vbox_uniformed_api.h | 8 ++++++++ 3 files changed, 43 insertions(+) diff --git a/src/vbox/vbox_common.h b/src/vbox/vbox_common.h index 38afdfddfa..78c36dcb19 100644 --- a/src/vbox/vbox_common.h +++ b/src/vbox/vbox_common.h @@ -361,6 +361,7 @@ typedef nsISupports IHost; typedef nsISupports IHostNetworkInterface; typedef nsISupports IDHCPServer; typedef nsISupports IKeyboard; +typedef nsISupports IVirtualBoxErrorInfo; /* Macros for all vbox drivers. */ diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index f01f8bd487..06cdd82e12 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -2169,6 +2169,32 @@ _keyboardPutScancodes(IKeyboard *keyboard, PRUint32 scancodesSize, codesStored); } +static const nsID * +_virtualBoxErrorInfoGetIID(void) +{ + static const nsID ret = IVIRTUALBOXERRORINFO_IID; + + return &ret; +} + +static nsresult +_virtualBoxErrorInfoGetComponent(IVirtualBoxErrorInfo *errInfo, PRUnichar **component) +{ + return errInfo->vtbl->GetComponent(errInfo, component); +} + +static nsresult +_virtualBoxErrorInfoGetNext(IVirtualBoxErrorInfo *errInfo, IVirtualBoxErrorInfo **next) +{ + return errInfo->vtbl->GetNext(errInfo, next); +} + +static nsresult +_virtualBoxErrorInfoGetText(IVirtualBoxErrorInfo *errInfo, PRUnichar **text) +{ + return errInfo->vtbl->GetText(errInfo, text); +} + static bool _machineStateOnline(PRUint32 state) { return ((state >= MachineState_FirstOnline) && @@ -2526,6 +2552,13 @@ static vboxUniformedIKeyboard _UIKeyboard = { .PutScancodes = _keyboardPutScancodes, }; +static vboxUniformedIVirtualBoxErrorInfo _UIVirtualBoxErrorInfo = { + .GetIID = _virtualBoxErrorInfoGetIID, + .GetComponent = _virtualBoxErrorInfoGetComponent, + .GetNext = _virtualBoxErrorInfoGetNext, + .GetText = _virtualBoxErrorInfoGetText, +}; + static uniformedMachineStateChecker _machineStateChecker = { .Online = _machineStateOnline, .Inactive = _machineStateInactive, @@ -2571,6 +2604,7 @@ void NAME(InstallUniformedAPI)(vboxUniformedAPI *pVBoxAPI) pVBoxAPI->UIHNInterface = _UIHNInterface; pVBoxAPI->UIDHCPServer = _UIDHCPServer; pVBoxAPI->UIKeyboard = _UIKeyboard; + pVBoxAPI->UIVirtualBoxErrorInfo = _UIVirtualBoxErrorInfo; pVBoxAPI->machineStateChecker = _machineStateChecker; pVBoxAPI->chipsetType = 1; diff --git a/src/vbox/vbox_uniformed_api.h b/src/vbox/vbox_uniformed_api.h index 3ac6ba92a6..b0674b4815 100644 --- a/src/vbox/vbox_uniformed_api.h +++ b/src/vbox/vbox_uniformed_api.h @@ -498,6 +498,13 @@ typedef struct { PRInt32 *scanCodes, PRUint32 *codesStored); } vboxUniformedIKeyboard; +typedef struct { + const nsID * (*GetIID)(void); + nsresult (*GetComponent)(IVirtualBoxErrorInfo *errInfo, PRUnichar **component); + nsresult (*GetNext)(IVirtualBoxErrorInfo *errInfo, IVirtualBoxErrorInfo **next); + nsresult (*GetText)(IVirtualBoxErrorInfo *errInfo, PRUnichar **text); +} vboxUniformedIVirtualBoxErrorInfo; + typedef struct { bool (*Online)(PRUint32 state); bool (*Inactive)(PRUint32 state); @@ -545,6 +552,7 @@ typedef struct { vboxUniformedIHNInterface UIHNInterface; vboxUniformedIDHCPServer UIDHCPServer; vboxUniformedIKeyboard UIKeyboard; + vboxUniformedIVirtualBoxErrorInfo UIVirtualBoxErrorInfo; uniformedMachineStateChecker machineStateChecker; /* vbox API features */ bool chipsetType; -- 2.39.1
On Mon, Jan 23, 2023 at 10:35:49AM +0100, Michal Privoznik wrote:
The IVirtualBoxErrorInfo interface allows us to query error messages from VirtualBox. Since VirtualBox has stacked errors we need the GetNext() method too.
The odd one, that sticks out is GetIID() as it is not part of the interface as defined bu VirtualBox header files. BUT, we need to
s/bu/by/ or s/bu/in/
get the interface UUID (which MAY change across each release) so that it can be passed to VBOX_QUERY_INTERFACE() introduced earlier.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
The GetException() method can be used to obtain the latest exception that occurred in VirtualBox. Calling the method does not reset the exception though. For that we'll need to call another method (introduced in following commit). Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/vbox/vbox_common.h | 2 ++ src/vbox/vbox_tmpl.c | 6 ++++++ src/vbox/vbox_uniformed_api.h | 1 + 3 files changed, 9 insertions(+) diff --git a/src/vbox/vbox_common.h b/src/vbox/vbox_common.h index 78c36dcb19..08da0845a6 100644 --- a/src/vbox/vbox_common.h +++ b/src/vbox/vbox_common.h @@ -109,6 +109,7 @@ typedef unsigned long PRUword; #define nsnull 0 typedef PRUint32 nsresult; +#define HRESULT nsresult #if defined(__GNUC__) && (__GNUC__ > 2) # define NS_LIKELY(x) (__builtin_expect((x), 1)) @@ -362,6 +363,7 @@ typedef nsISupports IHostNetworkInterface; typedef nsISupports IDHCPServer; typedef nsISupports IKeyboard; typedef nsISupports IVirtualBoxErrorInfo; +typedef struct nsIException nsIException; /* Macros for all vbox drivers. */ diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index 06cdd82e12..ba7dc34a6b 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -483,6 +483,11 @@ static int _pfnUtf8ToUtf16(PCVBOXXPCOM pFuncs, const char *pszString, PRUnichar return pFuncs->pfnUtf8ToUtf16(pszString, ppwszString); } +static HRESULT _pfnGetException(PCVBOXXPCOM pFuncs, IErrorInfo **ppException) +{ + return pFuncs->pfnGetException(ppException); +} + static void _vboxIIDInitialize(vboxIID *iid) { memset(iid, 0, sizeof(vboxIID)); @@ -2237,6 +2242,7 @@ static vboxUniformedPFN _UPFN = { .Utf8Free = _pfnUtf8Free, .Utf16ToUtf8 = _pfnUtf16ToUtf8, .Utf8ToUtf16 = _pfnUtf8ToUtf16, + .GetException = _pfnGetException, }; static vboxUniformedIID _UIID = { diff --git a/src/vbox/vbox_uniformed_api.h b/src/vbox/vbox_uniformed_api.h index b0674b4815..465a7877d9 100644 --- a/src/vbox/vbox_uniformed_api.h +++ b/src/vbox/vbox_uniformed_api.h @@ -109,6 +109,7 @@ typedef struct { void (*Utf8Free)(PCVBOXXPCOM pFuncs, char *pszString); int (*Utf16ToUtf8)(PCVBOXXPCOM pFuncs, const PRUnichar *pwszString, char **ppszString); int (*Utf8ToUtf16)(PCVBOXXPCOM pFuncs, const char *pszString, PRUnichar **ppwszString); + HRESULT (*GetException)(PCVBOXXPCOM pFuncs, nsIException **ppException); } vboxUniformedPFN; /* Functions for vboxIID */ -- 2.39.1
The ClearException() method clears the latest exception inside of VirtualBox. This needed because obtaining an exception via GetException() does not clear it. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/vbox/vbox_tmpl.c | 6 ++++++ src/vbox/vbox_uniformed_api.h | 1 + 2 files changed, 7 insertions(+) diff --git a/src/vbox/vbox_tmpl.c b/src/vbox/vbox_tmpl.c index ba7dc34a6b..a0c6a8f287 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -488,6 +488,11 @@ static HRESULT _pfnGetException(PCVBOXXPCOM pFuncs, IErrorInfo **ppException) return pFuncs->pfnGetException(ppException); } +static HRESULT _pfnClearException(PCVBOXXPCOM pFuncs) +{ + return pFuncs->pfnClearException(); +} + static void _vboxIIDInitialize(vboxIID *iid) { memset(iid, 0, sizeof(vboxIID)); @@ -2243,6 +2248,7 @@ static vboxUniformedPFN _UPFN = { .Utf16ToUtf8 = _pfnUtf16ToUtf8, .Utf8ToUtf16 = _pfnUtf8ToUtf16, .GetException = _pfnGetException, + .ClearException = _pfnClearException, }; static vboxUniformedIID _UIID = { diff --git a/src/vbox/vbox_uniformed_api.h b/src/vbox/vbox_uniformed_api.h index 465a7877d9..2d61ed97fa 100644 --- a/src/vbox/vbox_uniformed_api.h +++ b/src/vbox/vbox_uniformed_api.h @@ -110,6 +110,7 @@ typedef struct { int (*Utf16ToUtf8)(PCVBOXXPCOM pFuncs, const PRUnichar *pwszString, char **ppszString); int (*Utf8ToUtf16)(PCVBOXXPCOM pFuncs, const char *pszString, PRUnichar **ppwszString); HRESULT (*GetException)(PCVBOXXPCOM pFuncs, nsIException **ppException); + HRESULT (*ClearException)(PCVBOXXPCOM pFuncs); } vboxUniformedPFN; /* Functions for vboxIID */ -- 2.39.1
When a VirtualBox API fails it produced an exception. Until now, we did not have correct APIs wired up to get the exception and its error message. Thus, we were left with plain: virReportError("virtualbox API failed, rc=%08x", rc); This is not very user friendly because those rc values are hard to parse (e.g. some values are defined as a sum of a base value and some other value) and also it expects users to know where to look. But now that we have all machinery needed for querying exceptions, vboxReportError() can be introduced. The aim is to query VirtualBox exceptions and append them after the error message we intent to report. If the exception can't be queried successfully, this behaves exactly like virReportError(). Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/vbox/vbox_common.c | 113 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index bd77641d39..2a913e5975 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -63,6 +63,119 @@ static struct _vboxDriver *vbox_driver; static struct _vboxDriver *vboxDriverObjNew(void); static __thread bool vboxDriverDisposed; +#define vboxReportError(errcode, ...) \ + vboxReportErrorHelper(data, errcode, __FILE__, \ + __FUNCTION__, __LINE__, __VA_ARGS__) + +static void G_GNUC_PRINTF(6, 7) G_GNUC_UNUSED +vboxReportErrorHelper(struct _vboxDriver *data, + int errcode, + const char *filename, + const char *funcname, + size_t linenr, + const char *fmt, ...) +{ + int save_errno = errno; + g_auto(virBuffer) errBuf = VIR_BUFFER_INITIALIZER; + nsIException *ex = NULL; + IVirtualBoxErrorInfo *ei = NULL; + const nsID *vboxErrorInfoIID = NULL; + bool multipleLines = false; + nsresult rc; + g_autofree char *detail = NULL; + + if (fmt) { + va_list args; + + va_start(args, fmt); + detail = g_strdup_vprintf(fmt, args); + va_end(args); + } + + rc = gVBoxAPI.UPFN.GetException(data->pFuncs, &ex); + if (NS_FAILED(rc) || !ex) { + VIR_WARN("failed to get exception object"); + goto report; + } + + vboxErrorInfoIID = gVBoxAPI.UIVirtualBoxErrorInfo.GetIID(); + rc = VBOX_QUERY_INTERFACE(ex, vboxErrorInfoIID, (void **)&ei); + if (NS_FAILED(rc) || !ei) { + VIR_WARN("unable to typecast exception object"); + goto report; + } + + while (ei) { + IVirtualBoxErrorInfo *ei_next = NULL; + PRUnichar *componentUtf16 = NULL; + char *componentUtf8 = NULL; + PRUnichar *textUtf16 = NULL; + char *textUtf8 = NULL; + + rc = gVBoxAPI.UIVirtualBoxErrorInfo.GetComponent(ei, &componentUtf16); + if (NS_FAILED(rc)) { + VIR_WARN("failed to get error text"); + goto report; + } + + rc = gVBoxAPI.UIVirtualBoxErrorInfo.GetText(ei, &textUtf16); + if (NS_FAILED(rc)) { + VBOX_UTF16_FREE(componentUtf16); + VIR_WARN("failed to get error text"); + goto report; + } + + VBOX_UTF16_TO_UTF8(componentUtf16, &componentUtf8); + VBOX_UTF16_FREE(componentUtf16); + + VBOX_UTF16_TO_UTF8(textUtf16, &textUtf8); + VBOX_UTF16_FREE(textUtf16); + + virBufferAsprintf(&errBuf, "%s: %s", componentUtf8, textUtf8); + VBOX_UTF8_FREE(componentUtf8); + VBOX_UTF8_FREE(textUtf8); + + if (multipleLines) + virBufferAddChar(&errBuf, '\n'); + else + multipleLines = true; + + rc = gVBoxAPI.UIVirtualBoxErrorInfo.GetNext(ei, &ei_next); + if (NS_FAILED(rc)) { + break; + } + + VBOX_RELEASE(ei); + ei = ei_next; + } + + report: + if (virBufferUse(&errBuf)) { + const char *vboxErr = virBufferCurrentContent(&errBuf); + g_autofree char *newDetail = NULL; + + if (!detail || STREQ(detail, "")) { + newDetail = g_strdup(vboxErr); + } else { + newDetail = g_strdup_printf("%s: %s", detail, vboxErr); + } + + VIR_FREE(detail); + detail = g_steal_pointer(&newDetail); + } + + virReportErrorHelper(VIR_FROM_THIS, errcode, filename, funcname, linenr, "%s", detail); + + rc = gVBoxAPI.UPFN.ClearException(data->pFuncs); + if (NS_FAILED(rc)) { + VIR_WARN("failed to clear exception"); + } + + VBOX_RELEASE(ei); + VBOX_RELEASE(ex); + errno = save_errno; +} + static int vboxDomainDevicesDefPostParse(virDomainDeviceDef *dev G_GNUC_UNUSED, const virDomainDef *def G_GNUC_UNUSED, -- 2.39.1
On Mon, Jan 23, 2023 at 10:35:52AM +0100, Michal Privoznik wrote:
When a VirtualBox API fails it produced an exception. Until now, we did not have correct APIs wired up to get the exception and its error message. Thus, we were left with plain:
virReportError("virtualbox API failed, rc=%08x", rc);
This is not very user friendly because those rc values are hard to parse (e.g. some values are defined as a sum of a base value and some other value) and also it expects users to know where to look.
But now that we have all machinery needed for querying exceptions, vboxReportError() can be introduced. The aim is to query VirtualBox exceptions and append them after the error message we intent to report. If the exception can't be queried successfully, this behaves exactly like virReportError().
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/vbox/vbox_common.c | 113 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 113 insertions(+)
diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index bd77641d39..2a913e5975 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -63,6 +63,119 @@ static struct _vboxDriver *vbox_driver; static struct _vboxDriver *vboxDriverObjNew(void); static __thread bool vboxDriverDisposed;
+#define vboxReportError(errcode, ...) \ + vboxReportErrorHelper(data, errcode, __FILE__, \ + __FUNCTION__, __LINE__, __VA_ARGS__) + +static void G_GNUC_PRINTF(6, 7) G_GNUC_UNUSED +vboxReportErrorHelper(struct _vboxDriver *data, + int errcode, + const char *filename, + const char *funcname, + size_t linenr, + const char *fmt, ...) +{ + int save_errno = errno; + g_auto(virBuffer) errBuf = VIR_BUFFER_INITIALIZER; + nsIException *ex = NULL; + IVirtualBoxErrorInfo *ei = NULL; + const nsID *vboxErrorInfoIID = NULL; + bool multipleLines = false; + nsresult rc; + g_autofree char *detail = NULL; + + if (fmt) { + va_list args; + + va_start(args, fmt); + detail = g_strdup_vprintf(fmt, args); + va_end(args); + } + + rc = gVBoxAPI.UPFN.GetException(data->pFuncs, &ex); + if (NS_FAILED(rc) || !ex) { + VIR_WARN("failed to get exception object"); + goto report; + } + + vboxErrorInfoIID = gVBoxAPI.UIVirtualBoxErrorInfo.GetIID(); + rc = VBOX_QUERY_INTERFACE(ex, vboxErrorInfoIID, (void **)&ei); + if (NS_FAILED(rc) || !ei) { + VIR_WARN("unable to typecast exception object"); + goto report; + } + + while (ei) { + IVirtualBoxErrorInfo *ei_next = NULL; + PRUnichar *componentUtf16 = NULL; + char *componentUtf8 = NULL; + PRUnichar *textUtf16 = NULL; + char *textUtf8 = NULL; + + rc = gVBoxAPI.UIVirtualBoxErrorInfo.GetComponent(ei, &componentUtf16); + if (NS_FAILED(rc)) { + VIR_WARN("failed to get error text");
Maybe s/text/component/ so that we know where to look if more things go wrong. But wow on the complexity of getting a sensible error message from vbox. I guess it'd be easier in C++.
+ goto report; + } + + rc = gVBoxAPI.UIVirtualBoxErrorInfo.GetText(ei, &textUtf16); + if (NS_FAILED(rc)) { + VBOX_UTF16_FREE(componentUtf16); + VIR_WARN("failed to get error text"); + goto report; + } + + VBOX_UTF16_TO_UTF8(componentUtf16, &componentUtf8); + VBOX_UTF16_FREE(componentUtf16); + + VBOX_UTF16_TO_UTF8(textUtf16, &textUtf8); + VBOX_UTF16_FREE(textUtf16); + + virBufferAsprintf(&errBuf, "%s: %s", componentUtf8, textUtf8); + VBOX_UTF8_FREE(componentUtf8); + VBOX_UTF8_FREE(textUtf8); + + if (multipleLines) + virBufferAddChar(&errBuf, '\n'); + else + multipleLines = true; + + rc = gVBoxAPI.UIVirtualBoxErrorInfo.GetNext(ei, &ei_next); + if (NS_FAILED(rc)) { + break; + } + + VBOX_RELEASE(ei); + ei = ei_next; + } + + report: + if (virBufferUse(&errBuf)) { + const char *vboxErr = virBufferCurrentContent(&errBuf); + g_autofree char *newDetail = NULL; + + if (!detail || STREQ(detail, "")) { + newDetail = g_strdup(vboxErr); + } else { + newDetail = g_strdup_printf("%s: %s", detail, vboxErr); + } + + VIR_FREE(detail); + detail = g_steal_pointer(&newDetail); + } + + virReportErrorHelper(VIR_FROM_THIS, errcode, filename, funcname, linenr, "%s", detail); + + rc = gVBoxAPI.UPFN.ClearException(data->pFuncs); + if (NS_FAILED(rc)) { + VIR_WARN("failed to clear exception"); + } + + VBOX_RELEASE(ei); + VBOX_RELEASE(ex); + errno = save_errno; +} + static int vboxDomainDevicesDefPostParse(virDomainDeviceDef *dev G_GNUC_UNUSED, const virDomainDef *def G_GNUC_UNUSED, -- 2.39.1
Now that we have vboxReportError() which reports VirtualBox errors too, we can switch the code to use the former. And since the vboxReportError() is designed to behave exactly like virReportError() we can do that almost everywhere, regardless of the source of the error. There are a few exceptions though, for instance, when initializing VirtualBox SDK (we don't have all the objects needed for querying exceptions yet), or when invalid combination of arguments was passed to an API of ours, or when a function from other module (e.g. src/conf/) failed. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/vbox/vbox_common.c | 1157 ++++++++++++++++++++-------------------- 1 file changed, 579 insertions(+), 578 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 2a913e5975..b7b61df080 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -391,8 +391,8 @@ static int openSessionForMachine(struct _vboxDriver *data, const unsigned char * /* Get machine for the call to VBOX_SESSION_OPEN_EXISTING */ if (NS_FAILED(gVBoxAPI.UIVirtualBox.GetMachine(data->vboxObj, iid, machine))) { - virReportError(VIR_ERR_NO_DOMAIN, "%s", - _("no domain with matching uuid")); + vboxReportError(VIR_ERR_NO_DOMAIN, "%s", + _("no domain with matching uuid")); return -1; } @@ -492,9 +492,9 @@ vboxSetStorageController(virDomainControllerDef *controller, case VIR_DOMAIN_CONTROLLER_TYPE_XENBUS: case VIR_DOMAIN_CONTROLLER_TYPE_ISA: case VIR_DOMAIN_CONTROLLER_TYPE_LAST: - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("The vbox driver does not support %s controller type"), - virDomainControllerTypeToString(controller->type)); + vboxReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("The vbox driver does not support %s controller type"), + virDomainControllerTypeToString(controller->type)); return -1; } @@ -526,16 +526,16 @@ vboxSetStorageController(virDomainControllerDef *controller, case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_NCR53C90: case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_DC390: case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_AM53C974: - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("The vbox driver does not support %s SCSI " - "controller model"), - virDomainControllerModelSCSITypeToString(controller->model)); + vboxReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("The vbox driver does not support %s SCSI " + "controller model"), + virDomainControllerModelSCSITypeToString(controller->model)); goto cleanup; case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_DEFAULT: case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LAST: - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unexpected SCSI controller model %d"), - controller->model); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Unexpected SCSI controller model %d"), + controller->model); goto cleanup; } /* libvirt ide model => vbox ide model */ @@ -555,9 +555,9 @@ vboxSetStorageController(virDomainControllerDef *controller, break; case VIR_DOMAIN_CONTROLLER_MODEL_IDE_LAST: case VIR_DOMAIN_CONTROLLER_MODEL_IDE_DEFAULT: - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Unexpected IDE controller model %d"), - controller->model); + vboxReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Unexpected IDE controller model %d"), + controller->model); goto cleanup; } } @@ -570,10 +570,10 @@ vboxSetStorageController(virDomainControllerDef *controller, vboxBusType, &vboxController); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to add storage controller " - "(name: %s, busType: %d), rc=%08x"), - debugName, vboxBusType, rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to add storage controller " + "(name: %s, busType: %d), rc=%08x"), + debugName, vboxBusType, rc); goto cleanup; } @@ -582,7 +582,7 @@ vboxSetStorageController(virDomainControllerDef *controller, rc = gVBoxAPI.UIStorageController.SetControllerType(vboxController, vboxModel); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, + vboxReportError(VIR_ERR_INTERNAL_ERROR, _("Failed to change storage controller model, " "rc=%08x"), rc); goto cleanup; @@ -798,9 +798,9 @@ static int vboxConnectListDomains(virConnectPtr conn, int *ids, int nids) rc = gVBoxAPI.UArray.vboxArrayGet(&machines, data->vboxObj, ARRAY_GET_MACHINES); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get list of Domains, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not get list of Domains, rc=%08x"), + (unsigned)rc); goto cleanup; } @@ -840,8 +840,8 @@ static int vboxConnectNumOfDomains(virConnectPtr conn) rc = gVBoxAPI.UArray.vboxArrayGet(&machines, data->vboxObj, ARRAY_GET_MACHINES); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get number of Domains, rc=%08x"), (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not get number of Domains, rc=%08x"), (unsigned)rc); goto cleanup; } @@ -886,16 +886,16 @@ static virDomainPtr vboxDomainLookupByID(virConnectPtr conn, int id) /* Internal vbox IDs start from 0, the public libvirt ID * starts from 1, so refuse id == 0, and adjust the rest */ if (id == 0) { - virReportError(VIR_ERR_NO_DOMAIN, - _("no domain with matching id %d"), id); + vboxReportError(VIR_ERR_NO_DOMAIN, + _("no domain with matching id %d"), id); return NULL; } id = id - 1; rc = gVBoxAPI.UArray.vboxArrayGet(&machines, data->vboxObj, ARRAY_GET_MACHINES); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get list of machines, rc=%08x"), (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not get list of machines, rc=%08x"), (unsigned)rc); return NULL; } @@ -960,8 +960,8 @@ virDomainPtr vboxDomainLookupByUUID(virConnectPtr conn, VBOX_IID_INITIALIZE(&iid); rc = gVBoxAPI.UArray.vboxArrayGet(&machines, data->vboxObj, ARRAY_GET_MACHINES); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get list of machines, rc=%08x"), (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not get list of machines, rc=%08x"), (unsigned)rc); return NULL; } @@ -1032,8 +1032,8 @@ vboxDomainLookupByName(virConnectPtr conn, const char *name) VBOX_IID_INITIALIZE(&iid); rc = gVBoxAPI.UArray.vboxArrayGet(&machines, data->vboxObj, ARRAY_GET_MACHINES); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get list of machines, rc=%08x"), (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not get list of machines, rc=%08x"), (unsigned)rc); return NULL; } @@ -1166,11 +1166,11 @@ vboxAttachDrives(virDomainDef *def, struct _vboxDriver *data, IMachine *machine) deviceSlot = disk->info.addr.drive.bus; if (type != VIR_STORAGE_TYPE_FILE) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Unsupported storage type %s, the only supported " - "type is %s"), - virStorageTypeToString(type), - virStorageTypeToString(VIR_STORAGE_TYPE_FILE)); + vboxReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Unsupported storage type %s, the only supported " + "type is %s"), + virStorageTypeToString(type), + virStorageTypeToString(VIR_STORAGE_TYPE_FILE)); ret = -1; goto cleanup; } @@ -1178,8 +1178,8 @@ vboxAttachDrives(virDomainDef *def, struct _vboxDriver *data, IMachine *machine) switch ((virDomainDiskDevice) disk->device) { case VIR_DOMAIN_DISK_DEVICE_DISK: if (!src) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Missing disk source file path")); + vboxReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Missing disk source file path")); ret = -1; goto cleanup; } @@ -1201,9 +1201,9 @@ vboxAttachDrives(virDomainDef *def, struct _vboxDriver *data, IMachine *machine) break; case VIR_DOMAIN_DISK_DEVICE_LUN: case VIR_DOMAIN_DISK_DEVICE_LAST: - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("The vbox driver does not support %s disk device"), - virDomainDiskDeviceTypeToString(disk->device)); + vboxReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("The vbox driver does not support %s disk device"), + virDomainDiskDeviceTypeToString(disk->device)); ret = -1; goto cleanup; } @@ -1242,9 +1242,9 @@ vboxAttachDrives(virDomainDef *def, struct _vboxDriver *data, IMachine *machine) case VIR_DOMAIN_DISK_BUS_SD: case VIR_DOMAIN_DISK_BUS_NONE: case VIR_DOMAIN_DISK_BUS_LAST: - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("The vbox driver does not support %s bus type"), - virDomainDiskBusTypeToString(disk->bus)); + vboxReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("The vbox driver does not support %s bus type"), + virDomainDiskBusTypeToString(disk->bus)); ret = -1; goto cleanup; } @@ -1273,19 +1273,19 @@ vboxAttachDrives(virDomainDef *def, struct _vboxDriver *data, IMachine *machine) } if (!medium) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to open the following disk/dvd/floppy " - "to the machine: %s, rc=%08x"), src, rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to open the following disk/dvd/floppy " + "to the machine: %s, rc=%08x"), src, rc); ret = -1; goto cleanup; } rc = gVBoxAPI.UIMedium.GetId(medium, &mediumUUID); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Can't get the UUID of the file to be attached " - "as harddisk/dvd/floppy: %s, rc=%08x"), - src, rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Can't get the UUID of the file to be attached " + "as harddisk/dvd/floppy: %s, rc=%08x"), + src, rc); ret = -1; goto cleanup; } @@ -1318,9 +1318,9 @@ vboxAttachDrives(virDomainDef *def, struct _vboxDriver *data, IMachine *machine) medium); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not attach the file as " - "harddisk/dvd/floppy: %s, rc=%08x"), src, rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not attach the file as " + "harddisk/dvd/floppy: %s, rc=%08x"), src, rc); ret = -1; goto cleanup; } else { @@ -1429,8 +1429,8 @@ vboxAttachNetwork(virDomainDef *def, struct _vboxDriver *data, IMachine *machine VIR_DEBUG("NIC(%zu): ipaddr: %s", i, ipStr); VIR_FREE(ipStr); } else if (def->nets[i]->guestIP.nips > 1) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Driver does not support setting multiple IP addresses")); + vboxReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Driver does not support setting multiple IP addresses")); return -1; } } @@ -1981,39 +1981,39 @@ vboxDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags rc = gVBoxAPI.UIVirtualBox.CreateMachine(data, def, &machine, uuidstr); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("could not define a domain, rc=%08x"), (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("could not define a domain, rc=%08x"), (unsigned)rc); goto cleanup; } rc = gVBoxAPI.UIMachine.SetMemorySize(machine, VIR_DIV_UP(def->mem.cur_balloon, 1024)); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("could not set the memory size of the domain to: %llu Kb, " - "rc=%08x"), - def->mem.cur_balloon, (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("could not set the memory size of the domain to: %llu Kb, " + "rc=%08x"), + def->mem.cur_balloon, (unsigned)rc); } if (virDomainDefHasVcpusOffline(def)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("current vcpu count must equal maximum")); + vboxReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("current vcpu count must equal maximum")); } rc = gVBoxAPI.UIMachine.SetCPUCount(machine, virDomainDefGetVcpusMax(def)); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("could not set the number of virtual CPUs to: %u, rc=%08x"), - virDomainDefGetVcpusMax(def), (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("could not set the number of virtual CPUs to: %u, rc=%08x"), + virDomainDefGetVcpusMax(def), (unsigned)rc); } rc = gVBoxAPI.UIMachine.SetCPUProperty(machine, CPUPropertyType_PAE, def->features[VIR_DOMAIN_FEATURE_PAE] == VIR_TRISTATE_SWITCH_ON); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("could not change PAE status to: %s, rc=%08x"), - (def->features[VIR_DOMAIN_FEATURE_PAE] == VIR_TRISTATE_SWITCH_ON) - ? _("Enabled") : _("Disabled"), (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("could not change PAE status to: %s, rc=%08x"), + (def->features[VIR_DOMAIN_FEATURE_PAE] == VIR_TRISTATE_SWITCH_ON) + ? _("Enabled") : _("Disabled"), (unsigned)rc); } gVBoxAPI.UIMachine.GetBIOSSettings(machine, &bios); @@ -2022,19 +2022,19 @@ vboxDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags def->features[VIR_DOMAIN_FEATURE_ACPI] == VIR_TRISTATE_SWITCH_ON); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("could not change ACPI status to: %s, rc=%08x"), - (def->features[VIR_DOMAIN_FEATURE_ACPI] == VIR_TRISTATE_SWITCH_ON) - ? _("Enabled") : _("Disabled"), (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("could not change ACPI status to: %s, rc=%08x"), + (def->features[VIR_DOMAIN_FEATURE_ACPI] == VIR_TRISTATE_SWITCH_ON) + ? _("Enabled") : _("Disabled"), (unsigned)rc); } rc = gVBoxAPI.UIBIOSSettings.SetIOAPICEnabled(bios, def->features[VIR_DOMAIN_FEATURE_APIC] == VIR_TRISTATE_SWITCH_ON); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("could not change APIC status to: %s, rc=%08x"), - (def->features[VIR_DOMAIN_FEATURE_APIC] == VIR_TRISTATE_SWITCH_ON) - ? _("Enabled") : _("Disabled"), (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("could not change APIC status to: %s, rc=%08x"), + (def->features[VIR_DOMAIN_FEATURE_APIC] == VIR_TRISTATE_SWITCH_ON) + ? _("Enabled") : _("Disabled"), (unsigned)rc); } VBOX_RELEASE(bios); } @@ -2042,8 +2042,8 @@ vboxDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags /* Register the machine before attaching other devices to it */ rc = gVBoxAPI.UIVirtualBox.RegisterMachine(data->vboxObj, machine); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("could not define a domain, rc=%08x"), (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("could not define a domain, rc=%08x"), (unsigned)rc); goto cleanup; } @@ -2086,8 +2086,8 @@ vboxDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags */ rc = gVBoxAPI.UIMachine.SaveSettings(machine); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to save VM settings, rc=%08x"), rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to save VM settings, rc=%08x"), rc); machineReady = false; } @@ -2143,8 +2143,8 @@ static int vboxDomainUndefineFlags(virDomainPtr dom, unsigned int flags) gVBoxAPI.deleteConfig(machine); ret = 0; } else { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("could not delete the domain, rc=%08x"), (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("could not delete the domain, rc=%08x"), (unsigned)rc); } vboxIIDUnalloc(&iid); @@ -2265,8 +2265,8 @@ vboxStartMachine(virDomainPtr dom, int maxDomID, IMachine *machine, vboxIID *iid &progress); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_OPERATION_FAILED, "%s", - _("OpenRemoteSession/LaunchVMProcess failed, domain can't be started")); + vboxReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("OpenRemoteSession/LaunchVMProcess failed, domain can't be started")); goto cleanup; } else { PRBool completed = 0; @@ -2316,15 +2316,15 @@ static int vboxDomainCreateWithFlags(virDomainPtr dom, unsigned int flags) virCheckFlags(0, -1); if (!dom->name) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Error while reading the domain name")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Error while reading the domain name")); return -1; } rc = gVBoxAPI.UArray.vboxArrayGet(&machines, data->vboxObj, ARRAY_GET_MACHINES); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get list of machines, rc=%08x"), (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not get list of machines, rc=%08x"), (unsigned)rc); return -1; } @@ -2353,10 +2353,10 @@ static int vboxDomainCreateWithFlags(virDomainPtr dom, unsigned int flags) if (gVBoxAPI.machineStateChecker.NotStart(state)) { ret = vboxStartMachine(dom, i, machine, &iid); } else { - virReportError(VIR_ERR_OPERATION_FAILED, "%s", - _("machine is not in " - "poweroff|saved|aborted state, so " - "couldn't start it")); + vboxReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("machine is not in " + "poweroff|saved|aborted state, so " + "couldn't start it")); ret = -1; } } @@ -2424,8 +2424,8 @@ static int vboxDomainIsActive(virDomainPtr dom) VBOX_IID_INITIALIZE(&iid); rc = gVBoxAPI.UArray.vboxArrayGet(&machines, data->vboxObj, ARRAY_GET_MACHINES); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get list of machines, rc=%08x"), (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not get list of machines, rc=%08x"), (unsigned)rc); return ret; } @@ -2555,14 +2555,14 @@ static int vboxDomainSuspend(virDomainPtr dom) VBOX_RELEASE(console); ret = 0; } else { - virReportError(VIR_ERR_OPERATION_FAILED, "%s", - _("error while suspending the domain")); + vboxReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("error while suspending the domain")); goto cleanup; } gVBoxAPI.UISession.Close(data->vboxSession); } else { - virReportError(VIR_ERR_OPERATION_FAILED, "%s", - _("machine not in running state to suspend it")); + vboxReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("machine not in running state to suspend it")); goto cleanup; } @@ -2606,14 +2606,14 @@ static int vboxDomainResume(virDomainPtr dom) VBOX_RELEASE(console); ret = 0; } else { - virReportError(VIR_ERR_OPERATION_FAILED, "%s", - _("error while resuming the domain")); + vboxReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("error while resuming the domain")); goto cleanup; } gVBoxAPI.UISession.Close(data->vboxSession); } else { - virReportError(VIR_ERR_OPERATION_FAILED, "%s", - _("machine not paused, so can't resume it")); + vboxReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("machine not paused, so can't resume it")); goto cleanup; } @@ -2651,12 +2651,12 @@ static int vboxDomainShutdownFlags(virDomainPtr dom, unsigned int flags) gVBoxAPI.UIMachine.GetState(machine, &state); if (gVBoxAPI.machineStateChecker.Paused(state)) { - virReportError(VIR_ERR_OPERATION_FAILED, "%s", - _("machine paused, so can't power it down")); + vboxReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("machine paused, so can't power it down")); goto cleanup; } else if (gVBoxAPI.machineStateChecker.PoweredOff(state)) { - virReportError(VIR_ERR_OPERATION_FAILED, "%s", - _("machine already powered down")); + vboxReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("machine already powered down")); goto cleanup; } @@ -2717,8 +2717,8 @@ static int vboxDomainReboot(virDomainPtr dom, unsigned int flags) } gVBoxAPI.UISession.Close(data->vboxSession); } else { - virReportError(VIR_ERR_OPERATION_FAILED, "%s", - _("machine not running, so can't reboot it")); + vboxReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("machine not running, so can't reboot it")); goto cleanup; } @@ -2756,8 +2756,8 @@ static int vboxDomainDestroyFlags(virDomainPtr dom, unsigned int flags) gVBoxAPI.UIMachine.GetState(machine, &state); if (gVBoxAPI.machineStateChecker.PoweredOff(state)) { - virReportError(VIR_ERR_OPERATION_FAILED, "%s", - _("machine already powered down")); + vboxReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("machine already powered down")); goto cleanup; } @@ -2819,8 +2819,8 @@ static int vboxDomainSetMemory(virDomainPtr dom, unsigned long memory) gVBoxAPI.UIMachine.GetState(machine, &state); if (!gVBoxAPI.machineStateChecker.PoweredOff(state)) { - virReportError(VIR_ERR_OPERATION_FAILED, "%s", - _("memory size can't be changed unless domain is powered down")); + vboxReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("memory size can't be changed unless domain is powered down")); goto cleanup; } @@ -2837,10 +2837,10 @@ static int vboxDomainSetMemory(virDomainPtr dom, unsigned long memory) gVBoxAPI.UIMachine.SaveSettings(machine); ret = 0; } else { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("could not set the memory size of the " - "domain to: %lu Kb, rc=%08x"), - memory, (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("could not set the memory size of the " + "domain to: %lu Kb, rc=%08x"), + memory, (unsigned)rc); } } gVBoxAPI.UISession.Close(data->vboxSession); @@ -2866,8 +2866,8 @@ static int vboxDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info) rc = gVBoxAPI.UArray.vboxArrayGet(&machines, data->vboxObj, ARRAY_GET_MACHINES); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get list of machines, rc=%08x"), (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not get list of machines, rc=%08x"), (unsigned)rc); return -1; } @@ -2977,7 +2977,7 @@ static int vboxDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus, return ret; if (flags != VIR_DOMAIN_AFFECT_LIVE) { - virReportError(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"), flags); + vboxReportError(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"), flags); return -1; } @@ -2993,19 +2993,19 @@ static int vboxDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus, gVBoxAPI.UIMachine.SaveSettings(machine); ret = 0; } else { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("could not set the number of cpus of the domain " - "to: %u, rc=%08x"), - CPUCount, (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("could not set the number of cpus of the domain " + "to: %u, rc=%08x"), + CPUCount, (unsigned)rc); } VBOX_RELEASE(machine); } else { - virReportError(VIR_ERR_NO_DOMAIN, - _("no domain with matching id %d"), dom->id); + vboxReportError(VIR_ERR_NO_DOMAIN, + _("no domain with matching id %d"), dom->id); } } else { - virReportError(VIR_ERR_NO_DOMAIN, - _("can't open session to the domain with id %d"), dom->id); + vboxReportError(VIR_ERR_NO_DOMAIN, + _("can't open session to the domain with id %d"), dom->id); } gVBoxAPI.UISession.Close(data->vboxSession); @@ -3029,7 +3029,7 @@ static int vboxDomainGetVcpusFlags(virDomainPtr dom, unsigned int flags) return ret; if (flags != (VIR_DOMAIN_AFFECT_LIVE | VIR_DOMAIN_VCPU_MAXIMUM)) { - virReportError(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"), flags); + vboxReportError(VIR_ERR_INVALID_ARG, _("unsupported flags: (0x%x)"), flags); return -1; } @@ -3296,8 +3296,8 @@ vboxDumpDisks(virDomainDef *def, struct _vboxDriver *data, IMachine *machine) rc = gVBoxAPI.UIMediumAttachment.GetMedium(mediumAttachment, &medium); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get IMedium, rc=%08x"), rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not get IMedium, rc=%08x"), rc); goto cleanup; } @@ -3336,17 +3336,17 @@ vboxDumpDisks(virDomainDef *def, struct _vboxDriver *data, IMachine *machine) rc = gVBoxAPI.UIMediumAttachment.GetMedium(mediumAttachment, &medium); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get IMedium, rc=%08x"), rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not get IMedium, rc=%08x"), rc); goto cleanup; } rc = gVBoxAPI.UIMediumAttachment.GetController(mediumAttachment, &controllerName); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to get storage controller name, rc=%08x"), - rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Failed to get storage controller name, rc=%08x"), + rc); goto cleanup; } @@ -3354,44 +3354,44 @@ vboxDumpDisks(virDomainDef *def, struct _vboxDriver *data, IMachine *machine) controllerName, &controller); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get storage controller by name, rc=%08x"), - rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not get storage controller by name, rc=%08x"), + rc); goto cleanup; } rc = gVBoxAPI.UIMediumAttachment.GetType(mediumAttachment, &deviceType); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get device type, rc=%08x"), rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not get device type, rc=%08x"), rc); goto cleanup; } rc = gVBoxAPI.UIMediumAttachment.GetPort(mediumAttachment, &devicePort); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get device port, rc=%08x"), rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not get device port, rc=%08x"), rc); goto cleanup; } rc = gVBoxAPI.UIMediumAttachment.GetDevice(mediumAttachment, &deviceSlot); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get device slot, rc=%08x"), rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not get device slot, rc=%08x"), rc); goto cleanup; } rc = gVBoxAPI.UIStorageController.GetBus(controller, &storageBus); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get storage controller bus, rc=%08x"), - rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not get storage controller bus, rc=%08x"), + rc); goto cleanup; } if (medium) { rc = gVBoxAPI.UIMedium.GetLocation(medium, &mediumLocUtf16); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get medium storage location, rc=%08x"), - rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not get medium storage location, rc=%08x"), + rc); goto cleanup; } @@ -3401,8 +3401,8 @@ vboxDumpDisks(virDomainDef *def, struct _vboxDriver *data, IMachine *machine) rc = gVBoxAPI.UIMedium.GetReadOnly(medium, &readOnly); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get read only state, rc=%08x"), rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not get read only state, rc=%08x"), rc); goto cleanup; } } @@ -3411,9 +3411,9 @@ vboxDumpDisks(virDomainDef *def, struct _vboxDriver *data, IMachine *machine) sdCount); if (!disk->dst) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not generate medium name for the disk " - "at: port:%d, slot:%d"), devicePort, deviceSlot); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not generate medium name for the disk " + "at: port:%d, slot:%d"), devicePort, deviceSlot); goto cleanup; } @@ -3467,8 +3467,8 @@ vboxDumpDisks(virDomainDef *def, struct _vboxDriver *data, IMachine *machine) break; case StorageBus_Null: - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unsupported null storage bus")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unsupported null storage bus")); goto cleanup; } @@ -3489,8 +3489,8 @@ vboxDumpDisks(virDomainDef *def, struct _vboxDriver *data, IMachine *machine) case DeviceType_USB: case DeviceType_SharedFolder: case DeviceType_Null: - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unsupported vbox device type: %d"), deviceType); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Unsupported vbox device type: %d"), deviceType); goto cleanup; } @@ -4228,9 +4228,9 @@ static int vboxConnectListDefinedDomains(virConnectPtr conn, rc = gVBoxAPI.UArray.vboxArrayGet(&machines, data->vboxObj, ARRAY_GET_MACHINES); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get list of Defined Domains, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not get list of Defined Domains, rc=%08x"), + (unsigned)rc); goto cleanup; } @@ -4281,9 +4281,9 @@ static int vboxConnectNumOfDefinedDomains(virConnectPtr conn) rc = gVBoxAPI.UArray.vboxArrayGet(&machines, data->vboxObj, ARRAY_GET_MACHINES); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get number of Defined Domains, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not get number of Defined Domains, rc=%08x"), + (unsigned)rc); goto cleanup; } @@ -4373,9 +4373,9 @@ static int vboxDomainAttachDeviceImpl(virDomainPtr dom, writable, PR_FALSE); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("could not attach shared folder '%s', rc=%08x"), - dev->data.fs->dst, (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("could not attach shared folder '%s', rc=%08x"), + dev->data.fs->dst, (unsigned)rc); ret = -1; } else { ret = 0; @@ -4388,7 +4388,7 @@ static int vboxDomainAttachDeviceImpl(virDomainPtr dom, VBOX_RELEASE(machine); if (ret == -VIR_ERR_ARGUMENT_UNSUPPORTED) { - virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, _("Unsupported device type %d"), dev->type); + vboxReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, _("Unsupported device type %d"), dev->type); ret = -1; } } @@ -4491,9 +4491,9 @@ static int vboxDomainDetachDevice(virDomainPtr dom, const char *xml) rc = gVBoxAPI.UIMachine.RemoveSharedFolder(machine, nameUtf16); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("could not detach shared folder '%s', rc=%08x"), - dev->data.fs->dst, (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("could not detach shared folder '%s', rc=%08x"), + dev->data.fs->dst, (unsigned)rc); } else { ret = 0; } @@ -4504,7 +4504,7 @@ static int vboxDomainDetachDevice(virDomainPtr dom, const char *xml) VBOX_RELEASE(machine); if (ret == -VIR_ERR_ARGUMENT_UNSUPPORTED) { - virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, _("Unsupported device type %d"), dev->type); + vboxReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, _("Unsupported device type %d"), dev->type); ret = -1; } } @@ -4548,15 +4548,15 @@ static int vboxCloseDisksRecursively(virDomainPtr dom, char *location) AccessMode_ReadWrite, &medium); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to open HardDisk, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to open HardDisk, rc=%08x"), + (unsigned)rc); goto cleanup; } rc = gVBoxAPI.UIMedium.GetChildren(medium, &childrenSize, &children); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to get disk children")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to get disk children")); goto cleanup; } for (i = 0; i < childrenSize; i++) { @@ -4566,15 +4566,15 @@ static int vboxCloseDisksRecursively(virDomainPtr dom, char *location) char *childLocation = NULL; rc = gVBoxAPI.UIMedium.GetLocation(childMedium, &childLocationUtf); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to get childMedium location")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to get childMedium location")); goto cleanup; } VBOX_UTF16_TO_UTF8(childLocationUtf, &childLocation); VBOX_UTF16_FREE(childLocationUtf); if (vboxCloseDisksRecursively(dom, childLocation) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to close disk children")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to close disk children")); goto cleanup; } VIR_FREE(childLocation); @@ -4582,9 +4582,9 @@ static int vboxCloseDisksRecursively(virDomainPtr dom, char *location) } rc = gVBoxAPI.UIMedium.Close(medium); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to close HardDisk, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to close HardDisk, rc=%08x"), + (unsigned)rc); goto cleanup; } @@ -4672,8 +4672,8 @@ vboxSnapshotRedefine(virDomainPtr dom, /* It may failed when the machine is not mutable. */ rc = gVBoxAPI.UIMachine.GetSettingsFilePath(machine, &settingsFilePath); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("cannot get settings file path")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cannot get settings file path")); goto cleanup; } VBOX_UTF16_TO_UTF8(settingsFilePath, &settingsFilePath_Utf8); @@ -4681,8 +4681,8 @@ vboxSnapshotRedefine(virDomainPtr dom, /* Getting the machine name to retrieve the machine location path. */ rc = gVBoxAPI.UIMachine.GetName(machine, &machineNameUtf16); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("cannot get machine name")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cannot get machine name")); goto cleanup; } VBOX_UTF16_TO_UTF8(machineNameUtf16, &machineName); @@ -4690,16 +4690,16 @@ vboxSnapshotRedefine(virDomainPtr dom, nameTmpUse = g_strdup_printf("%s.vbox", machineName); machineLocationPath = virStringReplace(settingsFilePath_Utf8, nameTmpUse, ""); if (machineLocationPath == NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to get the machine location path")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to get the machine location path")); goto cleanup; } /* We create the xml struct with the settings file path. */ snapshotMachineDesc = virVBoxSnapshotConfLoadVboxFile(settingsFilePath_Utf8, machineLocationPath); if (snapshotMachineDesc == NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("cannot create a vboxSnapshotXmlPtr")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cannot create a vboxSnapshotXmlPtr")); goto cleanup; } if (snapshotMachineDesc->currentSnapshot != NULL) { @@ -4715,8 +4715,8 @@ vboxSnapshotRedefine(virDomainPtr dom, * the machine unregistration. */ if (virVBoxSnapshotConfRemoveFakeDisks(snapshotMachineDesc) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to remove Fake Disks")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to remove Fake Disks")); goto cleanup; } realReadWriteDisksPathSize = virVBoxSnapshotConfGetRWDisksPathsFromLibvirtXML(currentSnapshotXmlFilePath, @@ -4726,9 +4726,9 @@ vboxSnapshotRedefine(virDomainPtr dom, /* The read-only disk number is necessarily greater or equal to the * read-write disk number */ if (realReadOnlyDisksPathSize < realReadWriteDisksPathSize) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("The read only disk number must be greater or equal to the " - " read write disk number")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("The read only disk number must be greater or equal to the " + " read write disk number")); goto cleanup; } for (it = 0; it < realReadWriteDisksPathSize; it++) { @@ -4749,9 +4749,9 @@ vboxSnapshotRedefine(virDomainPtr dom, AccessMode_ReadWrite, &readWriteMedium); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to open HardDisk, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to open HardDisk, rc=%08x"), + (unsigned)rc); VBOX_UTF16_FREE(locationUtf); goto cleanup; } @@ -4759,8 +4759,8 @@ vboxSnapshotRedefine(virDomainPtr dom, rc = gVBoxAPI.UIMedium.GetId(readWriteMedium, &iid); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to get the read write medium id")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to get the read write medium id")); goto cleanup; } gVBoxAPI.UIID.vboxIIDToUtf8(data, &iid, &uuid); @@ -4768,8 +4768,8 @@ vboxSnapshotRedefine(virDomainPtr dom, rc = gVBoxAPI.UIMedium.GetFormat(readWriteMedium, &formatUtf); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to get the read write medium format")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to get the read write medium format")); goto cleanup; } VBOX_UTF16_TO_UTF8(formatUtf, &format); @@ -4795,16 +4795,16 @@ vboxSnapshotRedefine(virDomainPtr dom, if (virVBoxSnapshotConfAddHardDiskToMediaRegistry(readWriteDisk, snapshotMachineDesc->mediaRegistry, parentUuid) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to add hard disk to media Registry")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to add hard disk to media Registry")); VIR_FREE(readWriteDisk); goto cleanup; } rc = gVBoxAPI.UIMedium.Close(readWriteMedium); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to close HardDisk, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to close HardDisk, rc=%08x"), + (unsigned)rc); goto cleanup; } } @@ -4840,8 +4840,8 @@ vboxSnapshotRedefine(virDomainPtr dom, diskInMediaRegistry = virVBoxSnapshotConfDiskIsInMediaRegistry(snapshotMachineDesc, def->parent.dom->disks[it]->src->path); if (diskInMediaRegistry == -1) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to know if disk is in media registry")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to know if disk is in media registry")); goto cleanup; } if (diskInMediaRegistry == 1) /* Nothing to do. */ @@ -4855,9 +4855,9 @@ vboxSnapshotRedefine(virDomainPtr dom, AccessMode_ReadWrite, &readOnlyMedium); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to open HardDisk, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to open HardDisk, rc=%08x"), + (unsigned)rc); VBOX_UTF16_FREE(locationUtf); goto cleanup; } @@ -4865,8 +4865,8 @@ vboxSnapshotRedefine(virDomainPtr dom, rc = gVBoxAPI.UIMedium.GetId(readOnlyMedium, &iid); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to get hard disk id")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to get hard disk id")); goto cleanup; } gVBoxAPI.UIID.vboxIIDToUtf8(data, &iid, &uuid); @@ -4874,8 +4874,8 @@ vboxSnapshotRedefine(virDomainPtr dom, rc = gVBoxAPI.UIMedium.GetFormat(readOnlyMedium, &formatUtf); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to get hard disk format")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to get hard disk format")); VIR_FREE(uuid); goto cleanup; } @@ -4885,17 +4885,17 @@ vboxSnapshotRedefine(virDomainPtr dom, /* This disk is already in the media registry */ rc = gVBoxAPI.UIMedium.GetParent(readOnlyMedium, &parentReadOnlyMedium); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to get parent hard disk")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to get parent hard disk")); VIR_FREE(uuid); goto cleanup; } rc = gVBoxAPI.UIMedium.GetId(parentReadOnlyMedium, &parentiid); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to get hard disk id, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to get hard disk id, rc=%08x"), + (unsigned)rc); VIR_FREE(uuid); goto cleanup; } @@ -4904,9 +4904,9 @@ vboxSnapshotRedefine(virDomainPtr dom, rc = gVBoxAPI.UIMedium.Close(readOnlyMedium); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to close HardDisk, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to close HardDisk, rc=%08x"), + (unsigned)rc); VIR_FREE(uuid); VIR_FREE(parentUuid); goto cleanup; @@ -4919,9 +4919,9 @@ vboxSnapshotRedefine(virDomainPtr dom, readOnlyDisk->location = g_strdup(def->parent.dom->disks[it]->src->path); if (virVBoxSnapshotConfAddHardDiskToMediaRegistry(readOnlyDisk, snapshotMachineDesc->mediaRegistry, - parentUuid) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to add hard disk to media registry")); + parentUuid) < 0) { + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to add hard disk to media registry")); VIR_FREE(readOnlyDisk); goto cleanup; } @@ -4933,9 +4933,9 @@ vboxSnapshotRedefine(virDomainPtr dom, &aMediaSize, &aMedia); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to unregister machine, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to unregister machine, rc=%08x"), + (unsigned)rc); goto cleanup; } VBOX_RELEASE(machine); @@ -4953,8 +4953,8 @@ vboxSnapshotRedefine(virDomainPtr dom, char *locationUtf8 = NULL; rc = gVBoxAPI.UIMedium.GetLocation(medium, &locationUtf16); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to get medium location")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to get medium location")); goto cleanup; } VBOX_UTF16_TO_UTF8(locationUtf16, &locationUtf8); @@ -4965,18 +4965,18 @@ vboxSnapshotRedefine(virDomainPtr dom, resultCodeUnion resultCode; rc = gVBoxAPI.UIMedium.DeleteStorage(medium, &progress); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to delete medium, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to delete medium, rc=%08x"), + (unsigned)rc); VIR_FREE(locationUtf8); goto cleanup; } gVBoxAPI.UIProgress.WaitForCompletion(progress, -1); gVBoxAPI.UIProgress.GetResultCode(progress, &resultCode); if (RC_FAILED(resultCode)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Error while closing medium, rc=%08x"), - resultCode.uResultCode); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Error while closing medium, rc=%08x"), + resultCode.uResultCode); VIR_FREE(locationUtf8); goto cleanup; } @@ -4998,8 +4998,8 @@ vboxSnapshotRedefine(virDomainPtr dom, /* Close all disks that failed to close normally. */ for (it = 0; it < snapshotMachineDesc->mediaRegistry->ndisks; it++) { if (vboxCloseDisksRecursively(dom, snapshotMachineDesc->mediaRegistry->disks[it]->location) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to close recursively all disks")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to close recursively all disks")); goto cleanup; } } @@ -5059,8 +5059,8 @@ vboxSnapshotRedefine(virDomainPtr dom, VIR_FREE(tmp); } if (virVBoxSnapshotConfAddSnapshotToXmlMachine(newSnapshotPtr, snapshotMachineDesc, def->parent.parent_name) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to add the snapshot to the machine description")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to add the snapshot to the machine description")); goto cleanup; } /* @@ -5099,9 +5099,9 @@ vboxSnapshotRedefine(virDomainPtr dom, &medium); VBOX_UTF16_FREE(locationUtf16); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to open HardDisk, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to open HardDisk, rc=%08x"), + (unsigned)rc); goto cleanup; } } @@ -5132,9 +5132,9 @@ vboxSnapshotRedefine(virDomainPtr dom, AccessMode_ReadWrite, &medium); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to open HardDisk, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to open HardDisk, rc=%08x"), + (unsigned)rc); goto cleanup; } VBOX_UTF16_FREE(locationUtf16); @@ -5143,8 +5143,8 @@ vboxSnapshotRedefine(virDomainPtr dom, rc = gVBoxAPI.UIMedium.GetFormat(medium, &formatUtf16); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to get disk format")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to get disk format")); VIR_FREE(disk); goto cleanup; } @@ -5157,8 +5157,8 @@ vboxSnapshotRedefine(virDomainPtr dom, rc = gVBoxAPI.UIMedium.GetId(medium, &iid); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to get disk uuid")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to get disk uuid")); VIR_FREE(disk); goto cleanup; } @@ -5168,8 +5168,8 @@ vboxSnapshotRedefine(virDomainPtr dom, rc = gVBoxAPI.UIMedium.GetParent(medium, &parentDisk); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to get disk parent")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to get disk parent")); VIR_FREE(disk); goto cleanup; } @@ -5180,8 +5180,8 @@ vboxSnapshotRedefine(virDomainPtr dom, if (virVBoxSnapshotConfAddHardDiskToMediaRegistry(disk, snapshotMachineDesc->mediaRegistry, parentUuid) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to add hard disk to the media registry")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to add hard disk to the media registry")); VIR_FREE(disk); goto cleanup; } @@ -5194,8 +5194,8 @@ vboxSnapshotRedefine(virDomainPtr dom, it + 1, &searchResultTab); if (resultSize != it + 1) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to find UUID %s"), searchResultTab[it]); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to find UUID %s"), searchResultTab[it]); goto cleanup; } @@ -5212,9 +5212,9 @@ vboxSnapshotRedefine(virDomainPtr dom, /* Close disk */ rc = gVBoxAPI.UIMedium.Close(medium); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to close HardDisk, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to close HardDisk, rc=%08x"), + (unsigned)rc); goto cleanup; } } @@ -5246,9 +5246,9 @@ vboxSnapshotRedefine(virDomainPtr dom, AccessMode_ReadWrite, &medium); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to open HardDisk, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to open HardDisk, rc=%08x"), + (unsigned)rc); VBOX_UTF16_FREE(locationUtf16); goto cleanup; } @@ -5256,9 +5256,9 @@ vboxSnapshotRedefine(virDomainPtr dom, rc = gVBoxAPI.UIMedium.GetId(medium, &parentiid); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to get hardDisk Id, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to get hardDisk Id, rc=%08x"), + (unsigned)rc); goto cleanup; } gVBoxAPI.UIID.vboxIIDToUtf8(data, &parentiid, &parentUuid); @@ -5275,9 +5275,9 @@ vboxSnapshotRedefine(virDomainPtr dom, VBOX_UTF16_FREE(newLocation); VBOX_UTF16_FREE(formatUtf16); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to create HardDisk, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to create HardDisk, rc=%08x"), + (unsigned)rc); goto cleanup; } @@ -5287,9 +5287,9 @@ vboxSnapshotRedefine(virDomainPtr dom, gVBoxAPI.UIProgress.WaitForCompletion(progress, -1); gVBoxAPI.UIProgress.GetResultCode(progress, &resultCode); if (RC_FAILED(resultCode)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Error while creating diff storage, rc=%08x"), - resultCode.uResultCode); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Error while creating diff storage, rc=%08x"), + resultCode.uResultCode); goto cleanup; } VBOX_RELEASE(progress); @@ -5302,9 +5302,9 @@ vboxSnapshotRedefine(virDomainPtr dom, rc = gVBoxAPI.UIMedium.GetId(newMedium, &iid); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to get medium uuid, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to get medium uuid, rc=%08x"), + (unsigned)rc); goto cleanup; } gVBoxAPI.UIID.vboxIIDToUtf8(data, &iid, &uuid); @@ -5321,8 +5321,8 @@ vboxSnapshotRedefine(virDomainPtr dom, if (virVBoxSnapshotConfAddHardDiskToMediaRegistry(newHardDisk, snapshotMachineDesc->mediaRegistry, parentUuid) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to add hard disk to the media registry")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to add hard disk to the media registry")); goto cleanup; } newHardDisk = NULL; /* Consumed by above */ @@ -5333,8 +5333,8 @@ vboxSnapshotRedefine(virDomainPtr dom, it + 1, &searchResultTab); if (resultSize != it + 1) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to find UUID %s"), searchResultTab[it]); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to find UUID %s"), searchResultTab[it]); goto cleanup; } @@ -5350,9 +5350,9 @@ vboxSnapshotRedefine(virDomainPtr dom, /* Closing the "fake" disk */ rc = gVBoxAPI.UIMedium.Close(newMedium); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to close the new medium, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to close the new medium, rc=%08x"), + (unsigned)rc); goto cleanup; } } @@ -5367,8 +5367,8 @@ vboxSnapshotRedefine(virDomainPtr dom, data->xmlopt, VIR_DOMAIN_SNAPSHOT_FORMAT_SECURE); if (snapshotContent == NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to get snapshot content")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to get snapshot content")); goto cleanup; } if (virFileWriteStr(currentSnapshotXmlFilePath, snapshotContent, 0644) < 0) { @@ -5399,16 +5399,16 @@ vboxSnapshotRedefine(virDomainPtr dom, AccessMode_ReadWrite, &medium); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to open HardDisk, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to open HardDisk, rc=%08x"), + (unsigned)rc); goto cleanup; } rc = gVBoxAPI.UIMedium.Close(medium); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to close HardDisk, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to close HardDisk, rc=%08x"), + (unsigned)rc); goto cleanup; } VBOX_UTF16_FREE(locationUtf16); @@ -5417,25 +5417,25 @@ vboxSnapshotRedefine(virDomainPtr dom, /* Now, we rewrite the 'machineName'.vbox file to redefine the machine. */ if (virVBoxSnapshotConfSaveVboxFile(snapshotMachineDesc, settingsFilePath_Utf8) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to serialize the machine description")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to serialize the machine description")); goto cleanup; } rc = gVBoxAPI.UIVirtualBox.OpenMachine(data->vboxObj, settingsFilePath, &machine); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to open Machine, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to open Machine, rc=%08x"), + (unsigned)rc); goto cleanup; } rc = gVBoxAPI.UIVirtualBox.RegisterMachine(data->vboxObj, machine); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to register Machine, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to register Machine, rc=%08x"), + (unsigned)rc); goto cleanup; } @@ -5510,8 +5510,8 @@ vboxDomainSnapshotCreateXML(virDomainPtr dom, rc = gVBoxAPI.UIMachine.GetState(machine, &state); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("could not get domain state")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("could not get domain state")); goto cleanup; } @@ -5524,9 +5524,9 @@ vboxDomainSnapshotCreateXML(virDomainPtr dom, if (NS_SUCCEEDED(rc)) rc = gVBoxAPI.UISession.GetConsole(data->vboxSession, &console); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("could not open VirtualBox session with domain %s"), - dom->name); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("could not open VirtualBox session with domain %s"), + dom->name); goto cleanup; } @@ -5538,24 +5538,24 @@ vboxDomainSnapshotCreateXML(virDomainPtr dom, rc = gVBoxAPI.UIConsole.TakeSnapshot(console, name, description, &progress); if (NS_FAILED(rc) || !progress) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("could not take snapshot of domain %s"), dom->name); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("could not take snapshot of domain %s"), dom->name); goto cleanup; } gVBoxAPI.UIProgress.WaitForCompletion(progress, -1); gVBoxAPI.UIProgress.GetResultCode(progress, &result); if (RC_FAILED(result)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("could not take snapshot of domain %s"), dom->name); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("could not take snapshot of domain %s"), dom->name); goto cleanup; } rc = gVBoxAPI.UIMachine.GetCurrentSnapshot(machine, &snapshot); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("could not get current snapshot of domain %s"), - dom->name); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("could not get current snapshot of domain %s"), + dom->name); goto cleanup; } @@ -5577,6 +5577,7 @@ vboxDomainSnapshotGetAll(virDomainPtr dom, IMachine *machine, ISnapshot ***snapshots) { + struct _vboxDriver *data = dom->conn->privateData; vboxIID empty; ISnapshot **list = NULL; PRUint32 count; @@ -5587,9 +5588,9 @@ vboxDomainSnapshotGetAll(virDomainPtr dom, VBOX_IID_INITIALIZE(&empty); rc = gVBoxAPI.UIMachine.GetSnapshotCount(machine, &count); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("could not get snapshot count for domain %s"), - dom->name); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("could not get snapshot count for domain %s"), + dom->name); goto error; } @@ -5600,9 +5601,9 @@ vboxDomainSnapshotGetAll(virDomainPtr dom, rc = gVBoxAPI.UIMachine.FindSnapshot(machine, &empty, list); if (NS_FAILED(rc) || !list[0]) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("could not get root snapshot for domain %s"), - dom->name); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("could not get root snapshot for domain %s"), + dom->name); goto error; } @@ -5613,16 +5614,16 @@ vboxDomainSnapshotGetAll(virDomainPtr dom, size_t i; if (!list[next]) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected number of snapshots < %u"), count); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected number of snapshots < %u"), count); goto error; } rc = gVBoxAPI.UArray.vboxArrayGet(&children, list[next], gVBoxAPI.UArray.handleSnapshotGetChildren(list[next])); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("could not get children snapshots")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("could not get children snapshots")); goto error; } for (i = 0; i < children.count; i++) { @@ -5630,8 +5631,8 @@ vboxDomainSnapshotGetAll(virDomainPtr dom, if (!child) continue; if (top == count) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unexpected number of snapshots > %u"), count); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("unexpected number of snapshots > %u"), count); gVBoxAPI.UArray.vboxArrayRelease(&children); goto error; } @@ -5675,8 +5676,8 @@ vboxDomainSnapshotGet(struct _vboxDriver *data, rc = gVBoxAPI.UISnapshot.GetName(snapshots[i], &nameUtf16); if (NS_FAILED(rc) || !nameUtf16) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("could not get snapshot name")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("could not get snapshot name")); goto cleanup; } VBOX_UTF16_TO_UTF8(nameUtf16, &nameUtf8); @@ -5690,9 +5691,9 @@ vboxDomainSnapshotGet(struct _vboxDriver *data, } if (!snapshot) { - virReportError(VIR_ERR_OPERATION_INVALID, - _("domain %s has no snapshots with name %s"), - dom->name, name); + vboxReportError(VIR_ERR_OPERATION_INVALID, + _("domain %s has no snapshots with name %s"), + dom->name, name); goto cleanup; } @@ -5738,8 +5739,8 @@ vboxSnapshotGetReadWriteDisks(virDomainSnapshotDef *def, rc = gVBoxAPI.UISnapshot.GetId(snap, &snapIid); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Could not get snapshot id")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Could not get snapshot id")); goto cleanup; } @@ -5747,16 +5748,16 @@ vboxSnapshotGetReadWriteDisks(virDomainSnapshotDef *def, vboxIIDUnalloc(&snapIid); rc = gVBoxAPI.UISnapshot.GetMachine(snap, &snapMachine); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("could not get machine")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("could not get machine")); goto cleanup; } def->ndisks = 0; rc = gVBoxAPI.UArray.vboxArrayGet(&mediumAttachments, snapMachine, gVBoxAPI.UArray.handleMachineGetMediumAttachments(snapMachine)); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("no medium attachments")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("no medium attachments")); goto cleanup; } /* get the number of attachments */ @@ -5767,8 +5768,8 @@ vboxSnapshotGetReadWriteDisks(virDomainSnapshotDef *def, rc = gVBoxAPI.UIMediumAttachment.GetMedium(imediumattach, &medium); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("cannot get medium")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cannot get medium")); goto cleanup; } if (medium) { @@ -5807,8 +5808,8 @@ vboxSnapshotGetReadWriteDisks(virDomainSnapshotDef *def, rc = gVBoxAPI.UIMediumAttachment.GetController(imediumattach, &storageControllerName); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot get storage controller name")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Cannot get storage controller name")); goto cleanup; } @@ -5817,45 +5818,45 @@ vboxSnapshotGetReadWriteDisks(virDomainSnapshotDef *def, &storageController); VBOX_UTF16_FREE(storageControllerName); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot get storage controller by name")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Cannot get storage controller by name")); goto cleanup; } rc = gVBoxAPI.UIStorageController.GetBus(storageController, &storageBus); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot get storage controller bus")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Cannot get storage controller bus")); VBOX_RELEASE(storageController); goto cleanup; } rc = gVBoxAPI.UIMediumAttachment.GetType(imediumattach, &deviceType); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot get medium attachment type")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Cannot get medium attachment type")); VBOX_RELEASE(storageController); goto cleanup; } rc = gVBoxAPI.UIMediumAttachment.GetPort(imediumattach, &devicePort); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot get medium attachment port")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Cannot get medium attachment port")); VBOX_RELEASE(storageController); goto cleanup; } rc = gVBoxAPI.UIMediumAttachment.GetDevice(imediumattach, &deviceSlot); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot get medium attachment slot")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Cannot get medium attachment slot")); VBOX_RELEASE(storageController); goto cleanup; } rc = gVBoxAPI.UIMediumAttachment.GetMedium(imediumattach, &disk); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot get medium")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Cannot get medium")); VBOX_RELEASE(storageController); goto cleanup; } @@ -5877,16 +5878,16 @@ vboxSnapshotGetReadWriteDisks(virDomainSnapshotDef *def, handle = gVBoxAPI.UArray.handleMediumGetChildren(disk); rc = gVBoxAPI.UArray.vboxArrayGet(&children, disk, handle); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("cannot get children disk")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cannot get children disk")); goto cleanup; } handle = gVBoxAPI.UArray.handleMediumGetSnapshotIds(disk); rc = gVBoxAPI.UArray.vboxArrayGetWithIIDArg(&snapshotIids, disk, handle, &domiid); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("cannot get snapshot ids")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cannot get snapshot ids")); goto cleanup; } for (j = 0; j < children.count; ++j) { @@ -5898,8 +5899,8 @@ vboxSnapshotGetReadWriteDisks(virDomainSnapshotDef *def, if (STREQ(diskSnapIdStr, snapshotUuidStr)) { rc = gVBoxAPI.UIMedium.GetLocation(child, &childLocUtf16); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("cannot get disk location")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cannot get disk location")); VBOX_RELEASE(storageController); VBOX_RELEASE(disk); VBOX_RELEASE(child); @@ -5970,8 +5971,8 @@ vboxSnapshotGetReadOnlyDisks(virDomainSnapshotDef *def, rc = gVBoxAPI.UISnapshot.GetMachine(snap, &snapMachine); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("cannot get machine")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cannot get machine")); goto cleanup; } /* @@ -5981,8 +5982,8 @@ vboxSnapshotGetReadOnlyDisks(virDomainSnapshotDef *def, rc = gVBoxAPI.UArray.vboxArrayGet(&mediumAttachments, snapMachine, gVBoxAPI.UArray.handleMachineGetMediumAttachments(snapMachine)); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("cannot get medium attachments")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cannot get medium attachments")); goto cleanup; } /* get the number of attachments */ @@ -5993,8 +5994,8 @@ vboxSnapshotGetReadOnlyDisks(virDomainSnapshotDef *def, rc = gVBoxAPI.UIMediumAttachment.GetMedium(imediumattach, &medium); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("cannot get medium")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cannot get medium")); goto cleanup; } if (medium) { @@ -6029,8 +6030,8 @@ vboxSnapshotGetReadOnlyDisks(virDomainSnapshotDef *def, continue; rc = gVBoxAPI.UIMediumAttachment.GetController(imediumattach, &storageControllerName); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot get storage controller name")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Cannot get storage controller name")); goto cleanup; } if (!storageControllerName) @@ -6040,35 +6041,35 @@ vboxSnapshotGetReadOnlyDisks(virDomainSnapshotDef *def, &storageController); VBOX_UTF16_FREE(storageControllerName); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot get storage controller")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Cannot get storage controller")); goto cleanup; } if (!storageController) continue; rc = gVBoxAPI.UIStorageController.GetBus(storageController, &storageBus); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot get storage controller bus")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Cannot get storage controller bus")); goto cleanup; } rc = gVBoxAPI.UIMediumAttachment.GetPort(imediumattach, &devicePort); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot get medium attachment port")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Cannot get medium attachment port")); goto cleanup; } rc = gVBoxAPI.UIMediumAttachment.GetDevice(imediumattach, &deviceSlot); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot get device slot")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Cannot get device slot")); goto cleanup; } rc = gVBoxAPI.UIMediumAttachment.GetMedium(imediumattach, &disk); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot get medium")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Cannot get medium")); goto cleanup; } @@ -6088,8 +6089,8 @@ vboxSnapshotGetReadOnlyDisks(virDomainSnapshotDef *def, rc = gVBoxAPI.UIMedium.GetLocation(disk, &mediumLocUtf16); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot get disk location")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Cannot get disk location")); goto cleanup; } VBOX_UTF16_TO_UTF8(mediumLocUtf16, &mediumLocUtf8); @@ -6099,8 +6100,8 @@ vboxSnapshotGetReadOnlyDisks(virDomainSnapshotDef *def, VBOX_UTF8_FREE(mediumLocUtf8); rc = gVBoxAPI.UIMedium.GetReadOnly(disk, &readOnly); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot get read only attribute")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Cannot get read only attribute")); goto cleanup; } @@ -6109,9 +6110,9 @@ vboxSnapshotGetReadOnlyDisks(virDomainSnapshotDef *def, deviceSlot, sdCount); if (!defdom->disks[diskCount]->dst) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not generate medium name for the disk " - "at: port:%d, slot:%d"), devicePort, deviceSlot); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not generate medium name for the disk " + "at: port:%d, slot:%d"), devicePort, deviceSlot); ret = -1; goto cleanup; } @@ -6131,8 +6132,8 @@ vboxSnapshotGetReadOnlyDisks(virDomainSnapshotDef *def, rc = gVBoxAPI.UIMediumAttachment.GetType(imediumattach, &deviceType); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("cannot get medium attachment type")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cannot get medium attachment type")); goto cleanup; } if (deviceType == DeviceType_HardDisk) @@ -6232,9 +6233,9 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot, rc = gVBoxAPI.UISnapshot.GetDescription(snap, &str16); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("could not get description of snapshot %s"), - snapshot->name); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("could not get description of snapshot %s"), + snapshot->name); goto cleanup; } if (str16) { @@ -6246,9 +6247,9 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot, rc = gVBoxAPI.UISnapshot.GetTimeStamp(snap, ×tamp); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("could not get creation time of snapshot %s"), - snapshot->name); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("could not get creation time of snapshot %s"), + snapshot->name); goto cleanup; } /* timestamp is in milliseconds while creationTime in seconds */ @@ -6256,17 +6257,17 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot, rc = gVBoxAPI.UISnapshot.GetParent(snap, &parent); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("could not get parent of snapshot %s"), - snapshot->name); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("could not get parent of snapshot %s"), + snapshot->name); goto cleanup; } if (parent) { rc = gVBoxAPI.UISnapshot.GetName(parent, &str16); if (NS_FAILED(rc) || !str16) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("could not get name of parent of snapshot %s"), - snapshot->name); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("could not get name of parent of snapshot %s"), + snapshot->name); goto cleanup; } VBOX_UTF16_TO_UTF8(str16, &str8); @@ -6277,9 +6278,9 @@ static char *vboxDomainSnapshotGetXMLDesc(virDomainSnapshotPtr snapshot, rc = gVBoxAPI.UISnapshot.GetOnline(snap, &online); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("could not get online state of snapshot %s"), - snapshot->name); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("could not get online state of snapshot %s"), + snapshot->name); goto cleanup; } if (online) @@ -6325,9 +6326,9 @@ static int vboxDomainSnapshotNum(virDomainPtr dom, unsigned int flags) rc = gVBoxAPI.UIMachine.GetSnapshotCount(machine, &snapshotCount); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("could not get snapshot count for domain %s"), - dom->name); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("could not get snapshot count for domain %s"), + dom->name); goto cleanup; } @@ -6375,9 +6376,9 @@ static int vboxDomainSnapshotListNames(virDomainPtr dom, char **names, snapshots = g_new0(ISnapshot *, 1); rc = gVBoxAPI.UIMachine.FindSnapshot(machine, &empty, snapshots); if (NS_FAILED(rc) || !snapshots[0]) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("could not get root snapshot for domain %s"), - dom->name); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("could not get root snapshot for domain %s"), + dom->name); goto cleanup; } count = 1; @@ -6395,8 +6396,8 @@ static int vboxDomainSnapshotListNames(virDomainPtr dom, char **names, rc = gVBoxAPI.UISnapshot.GetName(snapshots[i], &nameUtf16); if (NS_FAILED(rc) || !nameUtf16) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("could not get snapshot name")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("could not get snapshot name")); goto cleanup; } VBOX_UTF16_TO_UTF8(nameUtf16, &name); @@ -6469,8 +6470,8 @@ static int vboxDomainHasCurrentSnapshot(virDomainPtr dom, rc = gVBoxAPI.UIMachine.GetCurrentSnapshot(machine, &snapshot); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("could not get current snapshot")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("could not get current snapshot")); goto cleanup; } @@ -6513,23 +6514,23 @@ vboxDomainSnapshotGetParent(virDomainSnapshotPtr snapshot, rc = gVBoxAPI.UISnapshot.GetParent(snap, &parent); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("could not get parent of snapshot %s"), - snapshot->name); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("could not get parent of snapshot %s"), + snapshot->name); goto cleanup; } if (!parent) { - virReportError(VIR_ERR_NO_DOMAIN_SNAPSHOT, - _("snapshot '%s' does not have a parent"), - snapshot->name); + vboxReportError(VIR_ERR_NO_DOMAIN_SNAPSHOT, + _("snapshot '%s' does not have a parent"), + snapshot->name); goto cleanup; } rc = gVBoxAPI.UISnapshot.GetName(parent, &nameUtf16); if (NS_FAILED(rc) || !nameUtf16) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("could not get name of parent of snapshot %s"), - snapshot->name); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("could not get name of parent of snapshot %s"), + snapshot->name); goto cleanup; } VBOX_UTF16_TO_UTF8(nameUtf16, &name); @@ -6568,21 +6569,21 @@ vboxDomainSnapshotCurrent(virDomainPtr dom, unsigned int flags) rc = gVBoxAPI.UIMachine.GetCurrentSnapshot(machine, &snapshot); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("could not get current snapshot")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("could not get current snapshot")); goto cleanup; } if (!snapshot) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("domain has no snapshots")); + vboxReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("domain has no snapshots")); goto cleanup; } rc = gVBoxAPI.UISnapshot.GetName(snapshot, &nameUtf16); if (NS_FAILED(rc) || !nameUtf16) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("could not get current snapshot name")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("could not get current snapshot name")); goto cleanup; } @@ -6626,8 +6627,8 @@ static int vboxDomainSnapshotIsCurrent(virDomainSnapshotPtr snapshot, rc = gVBoxAPI.UIMachine.GetCurrentSnapshot(machine, ¤t); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("could not get current snapshot")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("could not get current snapshot")); goto cleanup; } if (!current) { @@ -6637,8 +6638,8 @@ static int vboxDomainSnapshotIsCurrent(virDomainSnapshotPtr snapshot, rc = gVBoxAPI.UISnapshot.GetName(current, &nameUtf16); if (NS_FAILED(rc) || !nameUtf16) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("could not get current snapshot name")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("could not get current snapshot name")); goto cleanup; } @@ -6715,30 +6716,30 @@ static int vboxDomainRevertToSnapshot(virDomainSnapshotPtr snapshot, rc = gVBoxAPI.UISnapshot.GetOnline(newSnapshot, &online); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("could not get online state of snapshot %s"), - snapshot->name); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("could not get online state of snapshot %s"), + snapshot->name); goto cleanup; } rc = gVBoxAPI.UIMachine.GetCurrentSnapshot(machine, &prevSnapshot); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("could not get current snapshot of domain %s"), - dom->name); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("could not get current snapshot of domain %s"), + dom->name); goto cleanup; } rc = gVBoxAPI.UIMachine.GetState(machine, &state); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("could not get domain state")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("could not get domain state")); goto cleanup; } if (gVBoxAPI.machineStateChecker.Online(state)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("cannot revert snapshot of running domain")); + vboxReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("cannot revert snapshot of running domain")); goto cleanup; } @@ -6774,19 +6775,19 @@ vboxDomainSnapshotDeleteSingle(struct _vboxDriver *data, VBOX_IID_INITIALIZE(&iid); rc = gVBoxAPI.UISnapshot.GetId(snapshot, &iid); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("could not get snapshot UUID")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("could not get snapshot UUID")); goto cleanup; } rc = gVBoxAPI.UIConsole.DeleteSnapshot(console, &iid, &progress); if (NS_FAILED(rc) || !progress) { if (rc == VBOX_E_INVALID_VM_STATE) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("cannot delete domain snapshot for running domain")); + vboxReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("cannot delete domain snapshot for running domain")); } else { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("could not delete snapshot")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("could not delete snapshot")); } goto cleanup; } @@ -6794,8 +6795,8 @@ vboxDomainSnapshotDeleteSingle(struct _vboxDriver *data, gVBoxAPI.UIProgress.WaitForCompletion(progress, -1); gVBoxAPI.UIProgress.GetResultCode(progress, &result); if (RC_FAILED(result)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("could not delete snapshot")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("could not delete snapshot")); goto cleanup; } @@ -6820,8 +6821,8 @@ vboxDomainSnapshotDeleteTree(struct _vboxDriver *data, rc = gVBoxAPI.UArray.vboxArrayGet(&children, snapshot, gVBoxAPI.UArray.handleSnapshotGetChildren(snapshot)); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("could not get children snapshots")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("could not get children snapshots")); goto cleanup; } @@ -6885,16 +6886,16 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot) defXml = vboxDomainSnapshotGetXMLDesc(snapshot, 0); if (!defXml) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to get XML Desc of snapshot")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to get XML Desc of snapshot")); goto cleanup; } def = virDomainSnapshotDefParseString(defXml, data->xmlopt, NULL, NULL, VIR_DOMAIN_SNAPSHOT_PARSE_REDEFINE); if (!def) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to get a virDomainSnapshotDef *")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to get a virDomainSnapshotDef *")); goto cleanup; } @@ -6902,8 +6903,8 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot) goto cleanup; rc = gVBoxAPI.UIMachine.GetSettingsFilePath(machine, &settingsFilePathUtf16); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("cannot get settings file path")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cannot get settings file path")); goto cleanup; } VBOX_UTF16_TO_UTF8(settingsFilePathUtf16, &settingsFilepath); @@ -6911,29 +6912,29 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot) /* Getting the machine name to retrieve the machine location path. */ rc = gVBoxAPI.UIMachine.GetName(machine, &machineNameUtf16); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("cannot get machine name")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cannot get machine name")); goto cleanup; } VBOX_UTF16_TO_UTF8(machineNameUtf16, &machineName); nameTmpUse = g_strdup_printf("%s.vbox", machineName); machineLocationPath = virStringReplace(settingsFilepath, nameTmpUse, ""); if (machineLocationPath == NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to get the machine location path")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to get the machine location path")); goto cleanup; } snapshotMachineDesc = virVBoxSnapshotConfLoadVboxFile(settingsFilepath, machineLocationPath); if (!snapshotMachineDesc) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("cannot create a vboxSnapshotXmlPtr")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cannot create a vboxSnapshotXmlPtr")); goto cleanup; } isCurrent = virVBoxSnapshotConfIsCurrentSnapshot(snapshotMachineDesc, def->parent.name); if (isCurrent < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to know if the snapshot is the current snapshot")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to know if the snapshot is the current snapshot")); goto cleanup; } if (isCurrent) { @@ -6966,13 +6967,13 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot) readOnly = virVBoxSnapshotConfHardDiskPtrByLocation(snapshotMachineDesc, def->parent.dom->disks[it]->src->path); if (!readOnly) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Cannot get hard disk by location")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Cannot get hard disk by location")); goto cleanup; } if (readOnly->parent == NULL) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("The read only disk has no parent")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("The read only disk has no parent")); goto cleanup; } @@ -6983,17 +6984,17 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot) AccessMode_ReadWrite, &medium); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to open HardDisk, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to open HardDisk, rc=%08x"), + (unsigned)rc); goto cleanup; } rc = gVBoxAPI.UIMedium.GetId(medium, &parentiid); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to get hardDisk Id, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to get hardDisk Id, rc=%08x"), + (unsigned)rc); goto cleanup; } gVBoxAPI.UIID.vboxIIDToUtf8(data, &parentiid, &parentUuid); @@ -7009,9 +7010,9 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot) newLocation, &newMedium); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to create HardDisk, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to create HardDisk, rc=%08x"), + (unsigned)rc); goto cleanup; } VBOX_UTF16_FREE(formatUtf16); @@ -7023,9 +7024,9 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot) gVBoxAPI.UIProgress.WaitForCompletion(progress, -1); gVBoxAPI.UIProgress.GetResultCode(progress, &resultCode); if (RC_FAILED(resultCode)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Error while creating diff storage, rc=%08x"), - resultCode.uResultCode); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Error while creating diff storage, rc=%08x"), + resultCode.uResultCode); goto cleanup; } VBOX_RELEASE(progress); @@ -7038,9 +7039,9 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot) rc = gVBoxAPI.UIMedium.GetId(newMedium, &iid); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to get medium uuid, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to get medium uuid, rc=%08x"), + (unsigned)rc); VIR_FREE(disk); goto cleanup; } @@ -7058,8 +7059,8 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot) if (virVBoxSnapshotConfAddHardDiskToMediaRegistry(disk, snapshotMachineDesc->mediaRegistry, parentUuid) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to add hard disk to the media registry")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to add hard disk to the media registry")); goto cleanup; } /* Adding fake disks to the machine storage controllers */ @@ -7069,8 +7070,8 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot) it + 1, &searchResultTab); if (resultSize != it + 1) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to find UUID %s"), searchResultTab[it]); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to find UUID %s"), searchResultTab[it]); goto cleanup; } @@ -7086,9 +7087,9 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot) /* Closing the "fake" disk */ rc = gVBoxAPI.UIMedium.Close(newMedium); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to close the new medium, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to close the new medium, rc=%08x"), + (unsigned)rc); goto cleanup; } } @@ -7099,9 +7100,9 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot) uuidRO = virVBoxSnapshotConfHardDiskUuidByLocation(snapshotMachineDesc, def->parent.dom->disks[it]->src->path); if (!uuidRO) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("No such disk in media registry %s"), - def->parent.dom->disks[it]->src->path); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("No such disk in media registry %s"), + def->parent.dom->disks[it]->src->path); goto cleanup; } @@ -7110,9 +7111,9 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot) it + 1, &searchResultTab); if (resultSize != it + 1) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to find UUID %s"), - searchResultTab[it]); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to find UUID %s"), + searchResultTab[it]); goto cleanup; } @@ -7134,13 +7135,13 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot) virVBoxSnapshotConfHardDiskUuidByLocation(snapshotMachineDesc, def->disks[it].src->path); if (!uuidRW) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to find UUID for location %s"), def->disks[it].src->path); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to find UUID for location %s"), def->disks[it].src->path); goto cleanup; } if (virVBoxSnapshotConfRemoveHardDisk(snapshotMachineDesc->mediaRegistry, uuidRW) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to remove disk from media registry. uuid = %s"), uuidRW); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to remove disk from media registry. uuid = %s"), uuidRW); goto cleanup; } } @@ -7151,13 +7152,13 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot) virVBoxSnapshotConfHardDiskUuidByLocation(snapshotMachineDesc, def->parent.dom->disks[it]->src->path); if (!uuidRO) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to find UUID for location %s"), def->parent.dom->disks[it]->src->path); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to find UUID for location %s"), def->parent.dom->disks[it]->src->path); goto cleanup; } if (virVBoxSnapshotConfRemoveHardDisk(snapshotMachineDesc->mediaRegistry, uuidRO) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to remove disk from media registry. uuid = %s"), uuidRO); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to remove disk from media registry. uuid = %s"), uuidRO); goto cleanup; } } @@ -7167,9 +7168,9 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot) &aMediaSize, &aMedia); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to unregister machine, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to unregister machine, rc=%08x"), + (unsigned)rc); goto cleanup; } VBOX_RELEASE(machine); @@ -7189,17 +7190,17 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot) resultCodeUnion resultCode; rc = gVBoxAPI.UIMedium.DeleteStorage(medium, &progress); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to delete medium, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to delete medium, rc=%08x"), + (unsigned)rc); goto cleanup; } gVBoxAPI.UIProgress.WaitForCompletion(progress, -1); gVBoxAPI.UIProgress.GetResultCode(progress, &resultCode); if (RC_FAILED(resultCode)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Error while closing medium, rc=%08x"), - resultCode.uResultCode); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Error while closing medium, rc=%08x"), + resultCode.uResultCode); goto cleanup; } VBOX_RELEASE(progress); @@ -7218,8 +7219,8 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot) /* removing the snapshot */ if (virVBoxSnapshotConfRemoveSnapshot(snapshotMachineDesc, def->parent.name) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to remove snapshot %s"), def->parent.name); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to remove snapshot %s"), def->parent.name); goto cleanup; } @@ -7228,8 +7229,8 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot) if (def->parent.parent_name != NULL) { virVBoxSnapshotConfSnapshot *snap = virVBoxSnapshotConfSnapshotByName(snapshotMachineDesc->snapshot, def->parent.parent_name); if (!snap) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to get the snapshot to remove")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to get the snapshot to remove")); goto cleanup; } snapshotMachineDesc->currentSnapshot = g_strdup(snap->uuid); @@ -7238,25 +7239,25 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot) /* Registering the machine */ if (virVBoxSnapshotConfSaveVboxFile(snapshotMachineDesc, settingsFilepath) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Unable to serialize the machine description")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to serialize the machine description")); goto cleanup; } rc = gVBoxAPI.UIVirtualBox.OpenMachine(data->vboxObj, settingsFilePathUtf16, &machine); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to open Machine, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to open Machine, rc=%08x"), + (unsigned)rc); goto cleanup; } rc = gVBoxAPI.UIVirtualBox.RegisterMachine(data->vboxObj, machine); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to register Machine, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Unable to register Machine, rc=%08x"), + (unsigned)rc); goto cleanup; } @@ -7305,8 +7306,8 @@ static int vboxDomainSnapshotDelete(virDomainSnapshotPtr snapshot, rc = gVBoxAPI.UIMachine.GetState(machine, &state); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("could not get domain state")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("could not get domain state")); goto cleanup; } @@ -7317,13 +7318,13 @@ static int vboxDomainSnapshotDelete(virDomainSnapshotPtr snapshot, rc = gVBoxAPI.UArray.vboxArrayGet(&snapChildren, snap, gVBoxAPI.UArray.handleSnapshotGetChildren(snap)); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("could not get snapshot children")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("could not get snapshot children")); goto cleanup; } if (snapChildren.count != 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("cannot delete metadata of a snapshot with children")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cannot delete metadata of a snapshot with children")); goto cleanup; } else if (gVBoxAPI.vboxSnapshotRedefine) { ret = vboxDomainSnapshotDeleteMetadataOnly(snapshot); @@ -7332,8 +7333,8 @@ static int vboxDomainSnapshotDelete(virDomainSnapshotPtr snapshot, } if (gVBoxAPI.machineStateChecker.Online(state)) { - virReportError(VIR_ERR_OPERATION_INVALID, "%s", - _("cannot delete snapshots of running domain")); + vboxReportError(VIR_ERR_OPERATION_INVALID, "%s", + _("cannot delete snapshots of running domain")); goto cleanup; } @@ -7341,9 +7342,9 @@ static int vboxDomainSnapshotDelete(virDomainSnapshotPtr snapshot, if (NS_SUCCEEDED(rc)) rc = gVBoxAPI.UISession.GetConsole(data->vboxSession, &console); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("could not open VirtualBox session with domain %s"), - dom->name); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("could not open VirtualBox session with domain %s"), + dom->name); goto cleanup; } @@ -7388,16 +7389,16 @@ vboxDomainScreenshot(virDomainPtr dom, rc = gVBoxAPI.UIMachine.GetMonitorCount(machine, &max_screen); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_OPERATION_FAILED, "%s", - _("unable to get monitor count")); + vboxReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("unable to get monitor count")); VBOX_RELEASE(machine); return NULL; } if (screen >= max_screen) { - virReportError(VIR_ERR_INVALID_ARG, - _("screen ID higher than monitor " - "count (%d)"), max_screen); + vboxReportError(VIR_ERR_INVALID_ARG, + _("screen ID higher than monitor " + "count (%d)"), max_screen); VBOX_RELEASE(machine); return NULL; } @@ -7437,8 +7438,8 @@ vboxDomainScreenshot(virDomainPtr dom, &xOrigin, &yOrigin); if (NS_FAILED(rc) || !width || !height) { - virReportError(VIR_ERR_OPERATION_FAILED, "%s", - _("unable to get screen resolution")); + vboxReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("unable to get screen resolution")); goto endjob; } @@ -7447,8 +7448,8 @@ vboxDomainScreenshot(virDomainPtr dom, &screenDataSize, &screenData); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_OPERATION_FAILED, "%s", - _("failed to take screenshot")); + vboxReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("failed to take screenshot")); goto endjob; } @@ -7467,8 +7468,8 @@ vboxDomainScreenshot(virDomainPtr dom, ret = g_strdup("image/png"); if (virFDStreamOpenFile(st, tmp, 0, 0, O_RDONLY) < 0) { - virReportError(VIR_ERR_OPERATION_FAILED, "%s", - _("unable to open stream")); + vboxReportError(VIR_ERR_OPERATION_FAILED, "%s", + _("unable to open stream")); VIR_FREE(ret); } endjob: @@ -7534,8 +7535,8 @@ vboxConnectListAllDomains(virConnectPtr conn, rc = gVBoxAPI.UArray.vboxArrayGet(&machines, data->vboxObj, ARRAY_GET_MACHINES); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get list of domains, rc=%08x"), (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not get list of domains, rc=%08x"), (unsigned)rc); goto cleanup; } @@ -7572,8 +7573,8 @@ vboxConnectListAllDomains(virConnectPtr conn, if (MATCH(VIR_CONNECT_LIST_DOMAINS_FILTERS_SNAPSHOT)) { rc = gVBoxAPI.UIMachine.GetSnapshotCount(machine, &snapshotCount); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("could not get snapshot count for listed domains")); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("could not get snapshot count for listed domains")); goto cleanup; } if (!((MATCH(VIR_CONNECT_LIST_DOMAINS_HAS_SNAPSHOT) && @@ -7734,8 +7735,8 @@ vboxDomainHasManagedSaveImage(virDomainPtr dom, unsigned int flags) VBOX_IID_INITIALIZE(&iid); rc = gVBoxAPI.UArray.vboxArrayGet(&machines, data->vboxObj, ARRAY_GET_MACHINES); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get list of machines, rc=%08x"), (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("Could not get list of machines, rc=%08x"), (unsigned)rc); return ret; } @@ -7818,11 +7819,11 @@ vboxDomainSendKey(virDomainPtr dom, keycode = virKeycodeValueTranslate(codeset, VIR_KEYCODE_SET_XT, keyDownCodes[i]); if (keycode < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot translate keycode %u of %s codeset to" - " xt keycode"), - keyDownCodes[i], - virKeycodeSetTypeToString(codeset)); + vboxReportError(VIR_ERR_INTERNAL_ERROR, + _("cannot translate keycode %u of %s codeset to" + " xt keycode"), + keyDownCodes[i], + virKeycodeSetTypeToString(codeset)); goto cleanup; } keyDownCodes[i] = keycode; @@ -7837,27 +7838,27 @@ vboxDomainSendKey(virDomainPtr dom, rc = gVBoxAPI.UISession.OpenExisting(data, &iid, machine); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_OPERATION_FAILED, - _("Unable to open VirtualBox session with domain %s"), - dom->name); + vboxReportError(VIR_ERR_OPERATION_FAILED, + _("Unable to open VirtualBox session with domain %s"), + dom->name); goto cleanup; } rc = gVBoxAPI.UISession.GetConsole(data->vboxSession, &console); if (NS_FAILED(rc) || !console) { - virReportError(VIR_ERR_OPERATION_FAILED, - _("Unable to get Console object for domain %s"), - dom->name); + vboxReportError(VIR_ERR_OPERATION_FAILED, + _("Unable to get Console object for domain %s"), + dom->name); goto cleanup; } rc = gVBoxAPI.UIConsole.GetKeyboard(console, &keyboard); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_OPERATION_FAILED, - _("Unable to get Keyboard object for domain %s"), - dom->name); + vboxReportError(VIR_ERR_OPERATION_FAILED, + _("Unable to get Keyboard object for domain %s"), + dom->name); goto cleanup; } @@ -7865,9 +7866,9 @@ vboxDomainSendKey(virDomainPtr dom, &codesStored); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_OPERATION_FAILED, - _("Unable to send keyboard scancodes for domain %s"), - dom->name); + vboxReportError(VIR_ERR_OPERATION_FAILED, + _("Unable to send keyboard scancodes for domain %s"), + dom->name); goto cleanup; } @@ -7880,9 +7881,9 @@ vboxDomainSendKey(virDomainPtr dom, &codesStored); if (NS_FAILED(rc)) { - virReportError(VIR_ERR_OPERATION_FAILED, - _("Unable to send keyboard scan codes to domain %s"), - dom->name); + vboxReportError(VIR_ERR_OPERATION_FAILED, + _("Unable to send keyboard scan codes to domain %s"), + dom->name); goto cleanup; } -- 2.39.1
Our coding style suggests error messages to be on a single line for easier git grep. Since I'm touching them anyways, let's make them follow our own suggestion. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/vbox/vbox_common.c | 52 +++++++++++++++--------------------------- 1 file changed, 19 insertions(+), 33 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index b7b61df080..cf404ea9d7 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -527,8 +527,7 @@ vboxSetStorageController(virDomainControllerDef *controller, case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_DC390: case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_AM53C974: vboxReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("The vbox driver does not support %s SCSI " - "controller model"), + _("The vbox driver does not support %s SCSI controller model"), virDomainControllerModelSCSITypeToString(controller->model)); goto cleanup; case VIR_DOMAIN_CONTROLLER_MODEL_SCSI_DEFAULT: @@ -571,8 +570,7 @@ vboxSetStorageController(virDomainControllerDef *controller, if (NS_FAILED(rc)) { vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to add storage controller " - "(name: %s, busType: %d), rc=%08x"), + _("Failed to add storage controller (name: %s, busType: %d), rc=%08x"), debugName, vboxBusType, rc); goto cleanup; } @@ -583,8 +581,7 @@ vboxSetStorageController(virDomainControllerDef *controller, vboxModel); if (NS_FAILED(rc)) { vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to change storage controller model, " - "rc=%08x"), rc); + _("Failed to change storage controller model, rc=%08x"), rc); goto cleanup; } } @@ -1167,8 +1164,7 @@ vboxAttachDrives(virDomainDef *def, struct _vboxDriver *data, IMachine *machine) if (type != VIR_STORAGE_TYPE_FILE) { vboxReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Unsupported storage type %s, the only supported " - "type is %s"), + _("Unsupported storage type %s, the only supported type is %s"), virStorageTypeToString(type), virStorageTypeToString(VIR_STORAGE_TYPE_FILE)); ret = -1; @@ -1274,8 +1270,8 @@ vboxAttachDrives(virDomainDef *def, struct _vboxDriver *data, IMachine *machine) if (!medium) { vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to open the following disk/dvd/floppy " - "to the machine: %s, rc=%08x"), src, rc); + _("Failed to open the following disk/dvd/floppy to the machine: %s, rc=%08x"), + src, rc); ret = -1; goto cleanup; } @@ -1283,8 +1279,7 @@ vboxAttachDrives(virDomainDef *def, struct _vboxDriver *data, IMachine *machine) rc = gVBoxAPI.UIMedium.GetId(medium, &mediumUUID); if (NS_FAILED(rc)) { vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Can't get the UUID of the file to be attached " - "as harddisk/dvd/floppy: %s, rc=%08x"), + _("Can't get the UUID of the file to be attached as harddisk/dvd/floppy: %s, rc=%08x"), src, rc); ret = -1; goto cleanup; @@ -1319,8 +1314,8 @@ vboxAttachDrives(virDomainDef *def, struct _vboxDriver *data, IMachine *machine) if (NS_FAILED(rc)) { vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not attach the file as " - "harddisk/dvd/floppy: %s, rc=%08x"), src, rc); + _("Could not attach the file as harddisk/dvd/floppy: %s, rc=%08x"), + src, rc); ret = -1; goto cleanup; } else { @@ -1990,8 +1985,7 @@ vboxDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags VIR_DIV_UP(def->mem.cur_balloon, 1024)); if (NS_FAILED(rc)) { vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("could not set the memory size of the domain to: %llu Kb, " - "rc=%08x"), + _("could not set the memory size of the domain to: %llu Kb, rc=%08x"), def->mem.cur_balloon, (unsigned)rc); } @@ -2354,9 +2348,7 @@ static int vboxDomainCreateWithFlags(virDomainPtr dom, unsigned int flags) ret = vboxStartMachine(dom, i, machine, &iid); } else { vboxReportError(VIR_ERR_OPERATION_FAILED, "%s", - _("machine is not in " - "poweroff|saved|aborted state, so " - "couldn't start it")); + _("machine is not in poweroff|saved|aborted state, so couldn't start it")); ret = -1; } } @@ -2838,8 +2830,7 @@ static int vboxDomainSetMemory(virDomainPtr dom, unsigned long memory) ret = 0; } else { vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("could not set the memory size of the " - "domain to: %lu Kb, rc=%08x"), + _("could not set the memory size of the domain to: %lu Kb, rc=%08x"), memory, (unsigned)rc); } } @@ -2994,8 +2985,7 @@ static int vboxDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus, ret = 0; } else { vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("could not set the number of cpus of the domain " - "to: %u, rc=%08x"), + _("could not set the number of cpus of the domain to: %u, rc=%08x"), CPUCount, (unsigned)rc); } VBOX_RELEASE(machine); @@ -3412,8 +3402,8 @@ vboxDumpDisks(virDomainDef *def, struct _vboxDriver *data, IMachine *machine) if (!disk->dst) { vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not generate medium name for the disk " - "at: port:%d, slot:%d"), devicePort, deviceSlot); + _("Could not generate medium name for the disk at: port:%d, slot:%d"), + devicePort, deviceSlot); goto cleanup; } @@ -4727,8 +4717,7 @@ vboxSnapshotRedefine(virDomainPtr dom, * read-write disk number */ if (realReadOnlyDisksPathSize < realReadWriteDisksPathSize) { vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("The read only disk number must be greater or equal to the " - " read write disk number")); + _("The read only disk number must be greater or equal to the read write disk number")); goto cleanup; } for (it = 0; it < realReadWriteDisksPathSize; it++) { @@ -6111,8 +6100,7 @@ vboxSnapshotGetReadOnlyDisks(virDomainSnapshotDef *def, sdCount); if (!defdom->disks[diskCount]->dst) { vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not generate medium name for the disk " - "at: port:%d, slot:%d"), devicePort, deviceSlot); + _("Could not generate medium name for the disk at: port:%d, slot:%d"), devicePort, deviceSlot); ret = -1; goto cleanup; } @@ -7397,8 +7385,7 @@ vboxDomainScreenshot(virDomainPtr dom, if (screen >= max_screen) { vboxReportError(VIR_ERR_INVALID_ARG, - _("screen ID higher than monitor " - "count (%d)"), max_screen); + _("screen ID higher than monitor count (%d)"), max_screen); VBOX_RELEASE(machine); return NULL; } @@ -7820,8 +7807,7 @@ vboxDomainSendKey(virDomainPtr dom, keyDownCodes[i]); if (keycode < 0) { vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("cannot translate keycode %u of %s codeset to" - " xt keycode"), + _("cannot translate keycode %u of %s codeset to xt keycode"), keyDownCodes[i], virKeycodeSetTypeToString(codeset)); goto cleanup; -- 2.39.1
As shown in the commit that introduced vboxReportError(), we are appending the retval of a failed VirtualBox API onto our error messages. Well, this is no longer needed because vboxReportError() already appends the VirtualBox error in plain text. Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/vbox/vbox_common.c | 301 ++++++++++++++++++----------------------- 1 file changed, 132 insertions(+), 169 deletions(-) diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index cf404ea9d7..0a83cc5a61 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -570,8 +570,8 @@ vboxSetStorageController(virDomainControllerDef *controller, if (NS_FAILED(rc)) { vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to add storage controller (name: %s, busType: %d), rc=%08x"), - debugName, vboxBusType, rc); + _("Failed to add storage controller (name: %s, busType: %d)"), + debugName, vboxBusType); goto cleanup; } @@ -581,7 +581,7 @@ vboxSetStorageController(virDomainControllerDef *controller, vboxModel); if (NS_FAILED(rc)) { vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to change storage controller model, rc=%08x"), rc); + _("Failed to change storage controller model")); goto cleanup; } } @@ -795,9 +795,8 @@ static int vboxConnectListDomains(virConnectPtr conn, int *ids, int nids) rc = gVBoxAPI.UArray.vboxArrayGet(&machines, data->vboxObj, ARRAY_GET_MACHINES); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get list of Domains, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Could not get list of Domains")); goto cleanup; } @@ -837,8 +836,8 @@ static int vboxConnectNumOfDomains(virConnectPtr conn) rc = gVBoxAPI.UArray.vboxArrayGet(&machines, data->vboxObj, ARRAY_GET_MACHINES); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get number of Domains, rc=%08x"), (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Could not get number of Domains")); goto cleanup; } @@ -891,8 +890,8 @@ static virDomainPtr vboxDomainLookupByID(virConnectPtr conn, int id) rc = gVBoxAPI.UArray.vboxArrayGet(&machines, data->vboxObj, ARRAY_GET_MACHINES); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get list of machines, rc=%08x"), (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Could not get list of machines")); return NULL; } @@ -958,7 +957,7 @@ virDomainPtr vboxDomainLookupByUUID(virConnectPtr conn, rc = gVBoxAPI.UArray.vboxArrayGet(&machines, data->vboxObj, ARRAY_GET_MACHINES); if (NS_FAILED(rc)) { vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get list of machines, rc=%08x"), (unsigned)rc); + _("Could not get list of machines")); return NULL; } @@ -1030,7 +1029,7 @@ vboxDomainLookupByName(virConnectPtr conn, const char *name) rc = gVBoxAPI.UArray.vboxArrayGet(&machines, data->vboxObj, ARRAY_GET_MACHINES); if (NS_FAILED(rc)) { vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get list of machines, rc=%08x"), (unsigned)rc); + _("Could not get list of machines")); return NULL; } @@ -1270,8 +1269,8 @@ vboxAttachDrives(virDomainDef *def, struct _vboxDriver *data, IMachine *machine) if (!medium) { vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to open the following disk/dvd/floppy to the machine: %s, rc=%08x"), - src, rc); + _("Failed to open the following disk/dvd/floppy to the machine: %s"), + src); ret = -1; goto cleanup; } @@ -1279,8 +1278,8 @@ vboxAttachDrives(virDomainDef *def, struct _vboxDriver *data, IMachine *machine) rc = gVBoxAPI.UIMedium.GetId(medium, &mediumUUID); if (NS_FAILED(rc)) { vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Can't get the UUID of the file to be attached as harddisk/dvd/floppy: %s, rc=%08x"), - src, rc); + _("Can't get the UUID of the file to be attached as harddisk/dvd/floppy: %s"), + src); ret = -1; goto cleanup; } @@ -1314,8 +1313,8 @@ vboxAttachDrives(virDomainDef *def, struct _vboxDriver *data, IMachine *machine) if (NS_FAILED(rc)) { vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not attach the file as harddisk/dvd/floppy: %s, rc=%08x"), - src, rc); + _("Could not attach the file as harddisk/dvd/floppy: %s"), + src); ret = -1; goto cleanup; } else { @@ -1977,7 +1976,7 @@ vboxDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags if (NS_FAILED(rc)) { vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("could not define a domain, rc=%08x"), (unsigned)rc); + _("could not define a domain")); goto cleanup; } @@ -1985,8 +1984,8 @@ vboxDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags VIR_DIV_UP(def->mem.cur_balloon, 1024)); if (NS_FAILED(rc)) { vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("could not set the memory size of the domain to: %llu Kb, rc=%08x"), - def->mem.cur_balloon, (unsigned)rc); + _("could not set the memory size of the domain to: %llu Kb"), + def->mem.cur_balloon); } if (virDomainDefHasVcpusOffline(def)) { @@ -1996,8 +1995,8 @@ vboxDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags rc = gVBoxAPI.UIMachine.SetCPUCount(machine, virDomainDefGetVcpusMax(def)); if (NS_FAILED(rc)) { vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("could not set the number of virtual CPUs to: %u, rc=%08x"), - virDomainDefGetVcpusMax(def), (unsigned)rc); + _("could not set the number of virtual CPUs to: %u"), + virDomainDefGetVcpusMax(def)); } rc = gVBoxAPI.UIMachine.SetCPUProperty(machine, CPUPropertyType_PAE, @@ -2005,9 +2004,9 @@ vboxDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags VIR_TRISTATE_SWITCH_ON); if (NS_FAILED(rc)) { vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("could not change PAE status to: %s, rc=%08x"), + _("could not change PAE status to: %s"), (def->features[VIR_DOMAIN_FEATURE_PAE] == VIR_TRISTATE_SWITCH_ON) - ? _("Enabled") : _("Disabled"), (unsigned)rc); + ? _("Enabled") : _("Disabled")); } gVBoxAPI.UIMachine.GetBIOSSettings(machine, &bios); @@ -2017,18 +2016,18 @@ vboxDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags VIR_TRISTATE_SWITCH_ON); if (NS_FAILED(rc)) { vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("could not change ACPI status to: %s, rc=%08x"), + _("could not change ACPI status to: %s"), (def->features[VIR_DOMAIN_FEATURE_ACPI] == VIR_TRISTATE_SWITCH_ON) - ? _("Enabled") : _("Disabled"), (unsigned)rc); + ? _("Enabled") : _("Disabled")); } rc = gVBoxAPI.UIBIOSSettings.SetIOAPICEnabled(bios, def->features[VIR_DOMAIN_FEATURE_APIC] == VIR_TRISTATE_SWITCH_ON); if (NS_FAILED(rc)) { vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("could not change APIC status to: %s, rc=%08x"), + _("could not change APIC status to: %s"), (def->features[VIR_DOMAIN_FEATURE_APIC] == VIR_TRISTATE_SWITCH_ON) - ? _("Enabled") : _("Disabled"), (unsigned)rc); + ? _("Enabled") : _("Disabled")); } VBOX_RELEASE(bios); } @@ -2036,8 +2035,8 @@ vboxDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags /* Register the machine before attaching other devices to it */ rc = gVBoxAPI.UIVirtualBox.RegisterMachine(data->vboxObj, machine); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("could not define a domain, rc=%08x"), (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("could not define a domain")); goto cleanup; } @@ -2081,7 +2080,7 @@ vboxDomainDefineXMLFlags(virConnectPtr conn, const char *xml, unsigned int flags rc = gVBoxAPI.UIMachine.SaveSettings(machine); if (NS_FAILED(rc)) { vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to save VM settings, rc=%08x"), rc); + _("Failed to save VM settings")); machineReady = false; } @@ -2137,8 +2136,8 @@ static int vboxDomainUndefineFlags(virDomainPtr dom, unsigned int flags) gVBoxAPI.deleteConfig(machine); ret = 0; } else { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("could not delete the domain, rc=%08x"), (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("could not delete the domain")); } vboxIIDUnalloc(&iid); @@ -2317,8 +2316,8 @@ static int vboxDomainCreateWithFlags(virDomainPtr dom, unsigned int flags) rc = gVBoxAPI.UArray.vboxArrayGet(&machines, data->vboxObj, ARRAY_GET_MACHINES); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get list of machines, rc=%08x"), (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Could not get list of machines")); return -1; } @@ -2417,7 +2416,7 @@ static int vboxDomainIsActive(virDomainPtr dom) rc = gVBoxAPI.UArray.vboxArrayGet(&machines, data->vboxObj, ARRAY_GET_MACHINES); if (NS_FAILED(rc)) { vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get list of machines, rc=%08x"), (unsigned)rc); + _("Could not get list of machines")); return ret; } @@ -2830,8 +2829,8 @@ static int vboxDomainSetMemory(virDomainPtr dom, unsigned long memory) ret = 0; } else { vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("could not set the memory size of the domain to: %lu Kb, rc=%08x"), - memory, (unsigned)rc); + _("could not set the memory size of the domain to: %lu Kb"), + memory); } } gVBoxAPI.UISession.Close(data->vboxSession); @@ -2857,8 +2856,8 @@ static int vboxDomainGetInfo(virDomainPtr dom, virDomainInfoPtr info) rc = gVBoxAPI.UArray.vboxArrayGet(&machines, data->vboxObj, ARRAY_GET_MACHINES); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get list of machines, rc=%08x"), (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Could not get list of machines")); return -1; } @@ -2985,8 +2984,8 @@ static int vboxDomainSetVcpusFlags(virDomainPtr dom, unsigned int nvcpus, ret = 0; } else { vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("could not set the number of cpus of the domain to: %u, rc=%08x"), - CPUCount, (unsigned)rc); + _("could not set the number of cpus of the domain to: %u"), + CPUCount); } VBOX_RELEASE(machine); } else { @@ -3286,8 +3285,8 @@ vboxDumpDisks(virDomainDef *def, struct _vboxDriver *data, IMachine *machine) rc = gVBoxAPI.UIMediumAttachment.GetMedium(mediumAttachment, &medium); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get IMedium, rc=%08x"), rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Could not get IMedium")); goto cleanup; } @@ -3327,16 +3326,15 @@ vboxDumpDisks(virDomainDef *def, struct _vboxDriver *data, IMachine *machine) rc = gVBoxAPI.UIMediumAttachment.GetMedium(mediumAttachment, &medium); if (NS_FAILED(rc)) { vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get IMedium, rc=%08x"), rc); + _("Could not get IMedium")); goto cleanup; } rc = gVBoxAPI.UIMediumAttachment.GetController(mediumAttachment, &controllerName); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to get storage controller name, rc=%08x"), - rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Failed to get storage controller name")); goto cleanup; } @@ -3344,44 +3342,41 @@ vboxDumpDisks(virDomainDef *def, struct _vboxDriver *data, IMachine *machine) controllerName, &controller); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get storage controller by name, rc=%08x"), - rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Could not get storage controller by name")); goto cleanup; } rc = gVBoxAPI.UIMediumAttachment.GetType(mediumAttachment, &deviceType); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get device type, rc=%08x"), rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Could not get device type")); goto cleanup; } rc = gVBoxAPI.UIMediumAttachment.GetPort(mediumAttachment, &devicePort); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get device port, rc=%08x"), rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Could not get device port")); goto cleanup; } rc = gVBoxAPI.UIMediumAttachment.GetDevice(mediumAttachment, &deviceSlot); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get device slot, rc=%08x"), rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Could not get device slot")); goto cleanup; } rc = gVBoxAPI.UIStorageController.GetBus(controller, &storageBus); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get storage controller bus, rc=%08x"), - rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Could not get storage controller bus")); goto cleanup; } if (medium) { rc = gVBoxAPI.UIMedium.GetLocation(medium, &mediumLocUtf16); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get medium storage location, rc=%08x"), - rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Could not get medium storage location")); goto cleanup; } @@ -3391,8 +3386,8 @@ vboxDumpDisks(virDomainDef *def, struct _vboxDriver *data, IMachine *machine) rc = gVBoxAPI.UIMedium.GetReadOnly(medium, &readOnly); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get read only state, rc=%08x"), rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Could not get read only state")); goto cleanup; } } @@ -4218,9 +4213,8 @@ static int vboxConnectListDefinedDomains(virConnectPtr conn, rc = gVBoxAPI.UArray.vboxArrayGet(&machines, data->vboxObj, ARRAY_GET_MACHINES); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get list of Defined Domains, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Could not get list of Defined Domains")); goto cleanup; } @@ -4271,9 +4265,8 @@ static int vboxConnectNumOfDefinedDomains(virConnectPtr conn) rc = gVBoxAPI.UArray.vboxArrayGet(&machines, data->vboxObj, ARRAY_GET_MACHINES); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get number of Defined Domains, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Could not get number of Defined Domains")); goto cleanup; } @@ -4364,8 +4357,8 @@ static int vboxDomainAttachDeviceImpl(virDomainPtr dom, if (NS_FAILED(rc)) { vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("could not attach shared folder '%s', rc=%08x"), - dev->data.fs->dst, (unsigned)rc); + _("could not attach shared folder '%s'"), + dev->data.fs->dst); ret = -1; } else { ret = 0; @@ -4482,8 +4475,8 @@ static int vboxDomainDetachDevice(virDomainPtr dom, const char *xml) if (NS_FAILED(rc)) { vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("could not detach shared folder '%s', rc=%08x"), - dev->data.fs->dst, (unsigned)rc); + _("could not detach shared folder '%s'"), + dev->data.fs->dst); } else { ret = 0; } @@ -4538,9 +4531,8 @@ static int vboxCloseDisksRecursively(virDomainPtr dom, char *location) AccessMode_ReadWrite, &medium); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to open HardDisk, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to open HardDisk")); goto cleanup; } rc = gVBoxAPI.UIMedium.GetChildren(medium, &childrenSize, &children); @@ -4572,9 +4564,8 @@ static int vboxCloseDisksRecursively(virDomainPtr dom, char *location) } rc = gVBoxAPI.UIMedium.Close(medium); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to close HardDisk, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to close HardDisk")); goto cleanup; } @@ -4738,9 +4729,8 @@ vboxSnapshotRedefine(virDomainPtr dom, AccessMode_ReadWrite, &readWriteMedium); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to open HardDisk, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to open HardDisk")); VBOX_UTF16_FREE(locationUtf); goto cleanup; } @@ -4791,9 +4781,8 @@ vboxSnapshotRedefine(virDomainPtr dom, } rc = gVBoxAPI.UIMedium.Close(readWriteMedium); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to close HardDisk, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to close HardDisk")); goto cleanup; } } @@ -4845,8 +4834,7 @@ vboxSnapshotRedefine(virDomainPtr dom, &readOnlyMedium); if (NS_FAILED(rc)) { vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to open HardDisk, rc=%08x"), - (unsigned)rc); + _("Unable to open HardDisk")); VBOX_UTF16_FREE(locationUtf); goto cleanup; } @@ -4882,9 +4870,8 @@ vboxSnapshotRedefine(virDomainPtr dom, rc = gVBoxAPI.UIMedium.GetId(parentReadOnlyMedium, &parentiid); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to get hard disk id, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to get hard disk id")); VIR_FREE(uuid); goto cleanup; } @@ -4893,9 +4880,8 @@ vboxSnapshotRedefine(virDomainPtr dom, rc = gVBoxAPI.UIMedium.Close(readOnlyMedium); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to close HardDisk, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to close HardDisk")); VIR_FREE(uuid); VIR_FREE(parentUuid); goto cleanup; @@ -4922,9 +4908,8 @@ vboxSnapshotRedefine(virDomainPtr dom, &aMediaSize, &aMedia); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to unregister machine, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to unregister machine")); goto cleanup; } VBOX_RELEASE(machine); @@ -4954,9 +4939,8 @@ vboxSnapshotRedefine(virDomainPtr dom, resultCodeUnion resultCode; rc = gVBoxAPI.UIMedium.DeleteStorage(medium, &progress); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to delete medium, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to delete medium")); VIR_FREE(locationUtf8); goto cleanup; } @@ -5088,9 +5072,8 @@ vboxSnapshotRedefine(virDomainPtr dom, &medium); VBOX_UTF16_FREE(locationUtf16); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to open HardDisk, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to open HardDisk")); goto cleanup; } } @@ -5121,9 +5104,8 @@ vboxSnapshotRedefine(virDomainPtr dom, AccessMode_ReadWrite, &medium); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to open HardDisk, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to open HardDisk")); goto cleanup; } VBOX_UTF16_FREE(locationUtf16); @@ -5201,9 +5183,8 @@ vboxSnapshotRedefine(virDomainPtr dom, /* Close disk */ rc = gVBoxAPI.UIMedium.Close(medium); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to close HardDisk, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to close HardDisk")); goto cleanup; } } @@ -5235,9 +5216,8 @@ vboxSnapshotRedefine(virDomainPtr dom, AccessMode_ReadWrite, &medium); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to open HardDisk, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to open HardDisk")); VBOX_UTF16_FREE(locationUtf16); goto cleanup; } @@ -5245,9 +5225,8 @@ vboxSnapshotRedefine(virDomainPtr dom, rc = gVBoxAPI.UIMedium.GetId(medium, &parentiid); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to get hardDisk Id, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to get hardDisk Id")); goto cleanup; } gVBoxAPI.UIID.vboxIIDToUtf8(data, &parentiid, &parentUuid); @@ -5264,9 +5243,8 @@ vboxSnapshotRedefine(virDomainPtr dom, VBOX_UTF16_FREE(newLocation); VBOX_UTF16_FREE(formatUtf16); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to create HardDisk, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to create HardDisk")); goto cleanup; } @@ -5291,9 +5269,8 @@ vboxSnapshotRedefine(virDomainPtr dom, rc = gVBoxAPI.UIMedium.GetId(newMedium, &iid); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to get medium uuid, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to get medium uuid")); goto cleanup; } gVBoxAPI.UIID.vboxIIDToUtf8(data, &iid, &uuid); @@ -5339,9 +5316,8 @@ vboxSnapshotRedefine(virDomainPtr dom, /* Closing the "fake" disk */ rc = gVBoxAPI.UIMedium.Close(newMedium); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to close the new medium, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to close the new medium")); goto cleanup; } } @@ -5388,16 +5364,14 @@ vboxSnapshotRedefine(virDomainPtr dom, AccessMode_ReadWrite, &medium); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to open HardDisk, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to open HardDisk")); goto cleanup; } rc = gVBoxAPI.UIMedium.Close(medium); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to close HardDisk, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to close HardDisk")); goto cleanup; } VBOX_UTF16_FREE(locationUtf16); @@ -5414,17 +5388,15 @@ vboxSnapshotRedefine(virDomainPtr dom, settingsFilePath, &machine); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to open Machine, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to open Machine")); goto cleanup; } rc = gVBoxAPI.UIVirtualBox.RegisterMachine(data->vboxObj, machine); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to register Machine, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to register Machine")); goto cleanup; } @@ -6972,17 +6944,15 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot) AccessMode_ReadWrite, &medium); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to open HardDisk, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to open HardDisk")); goto cleanup; } rc = gVBoxAPI.UIMedium.GetId(medium, &parentiid); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to get hardDisk Id, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to get hardDisk Id")); goto cleanup; } gVBoxAPI.UIID.vboxIIDToUtf8(data, &parentiid, &parentUuid); @@ -6998,9 +6968,8 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot) newLocation, &newMedium); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to create HardDisk, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to create HardDisk")); goto cleanup; } VBOX_UTF16_FREE(formatUtf16); @@ -7027,9 +6996,8 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot) rc = gVBoxAPI.UIMedium.GetId(newMedium, &iid); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to get medium uuid, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to get medium uuid")); VIR_FREE(disk); goto cleanup; } @@ -7075,9 +7043,8 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot) /* Closing the "fake" disk */ rc = gVBoxAPI.UIMedium.Close(newMedium); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to close the new medium, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to close the new medium")); goto cleanup; } } @@ -7156,9 +7123,8 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot) &aMediaSize, &aMedia); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to unregister machine, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to unregister machine")); goto cleanup; } VBOX_RELEASE(machine); @@ -7178,9 +7144,8 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot) resultCodeUnion resultCode; rc = gVBoxAPI.UIMedium.DeleteStorage(medium, &progress); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to delete medium, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to delete medium")); goto cleanup; } gVBoxAPI.UIProgress.WaitForCompletion(progress, -1); @@ -7235,17 +7200,15 @@ vboxDomainSnapshotDeleteMetadataOnly(virDomainSnapshotPtr snapshot) settingsFilePathUtf16, &machine); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to open Machine, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to open Machine")); goto cleanup; } rc = gVBoxAPI.UIVirtualBox.RegisterMachine(data->vboxObj, machine); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to register Machine, rc=%08x"), - (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Unable to register Machine")); goto cleanup; } @@ -7522,8 +7485,8 @@ vboxConnectListAllDomains(virConnectPtr conn, rc = gVBoxAPI.UArray.vboxArrayGet(&machines, data->vboxObj, ARRAY_GET_MACHINES); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get list of domains, rc=%08x"), (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Could not get list of domains")); goto cleanup; } @@ -7722,8 +7685,8 @@ vboxDomainHasManagedSaveImage(virDomainPtr dom, unsigned int flags) VBOX_IID_INITIALIZE(&iid); rc = gVBoxAPI.UArray.vboxArrayGet(&machines, data->vboxObj, ARRAY_GET_MACHINES); if (NS_FAILED(rc)) { - vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Could not get list of machines, rc=%08x"), (unsigned)rc); + vboxReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Could not get list of machines")); return ret; } -- 2.39.1
On Mon, Jan 23, 2023 at 10:35:55AM +0100, Michal Privoznik wrote:
As shown in the commit that introduced vboxReportError(), we are appending the retval of a failed VirtualBox API onto our error messages. Well, this is no longer needed because vboxReportError() already appends the VirtualBox error in plain text.
Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/vbox/vbox_common.c | 301 ++++++++++++++++++----------------------- 1 file changed, 132 insertions(+), 169 deletions(-)
diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index cf404ea9d7..0a83cc5a61 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -570,8 +570,8 @@ vboxSetStorageController(virDomainControllerDef *controller,
if (NS_FAILED(rc)) { vboxReportError(VIR_ERR_INTERNAL_ERROR, - _("Failed to add storage controller (name: %s, busType: %d), rc=%08x"), - debugName, vboxBusType, rc); + _("Failed to add storage controller (name: %s, busType: %d)"), + debugName, vboxBusType); goto cleanup; }
@@ -581,7 +581,7 @@ vboxSetStorageController(virDomainControllerDef *controller, vboxModel); if (NS_FAILED(rc)) { vboxReportError(VIR_ERR_INTERNAL_ERROR,
"%s" should be here and without it the build should fail. I guess vboxReportError should be added to msg_gen_function in build-aux/syntax-check.mk. There are more occurrences of this in the rest of the patch.
On Mon, Jan 23, 2023 at 10:35:47AM +0100, Michal Privoznik wrote:
See 5/8 for motivation.
Michal Prívozník (8): vbox: Introduce VBOX_QUERY_INTERFACE() vbox: Introduce IVirtualBoxErrorInfo interface vbox: Introduce vboxUniformedPFN::GetException() vbox: Introduce vboxUniformedPFN::ClearException() vbox: Introduce vboxReportError() vbox: Replace virReportError() with vboxReportError() vbox: Move error messages onto a single line vbox: Stop reporting RC in error messages
With the few things fixed this is Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
src/vbox/vbox_common.c | 1223 +++++++++++++++++---------------- src/vbox/vbox_common.h | 6 + src/vbox/vbox_tmpl.c | 52 ++ src/vbox/vbox_uniformed_api.h | 11 + 4 files changed, 712 insertions(+), 580 deletions(-)
-- 2.39.1
participants (2)
-
Martin Kletzander -
Michal Privoznik