From 2a690fc1729242a749c50b29ad804b51f5ffa5a3 Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Fri, 20 Jan 2023 08:59:40 +0100 Subject: [PATCH] vbox: Introduce IVirtualBoxErrorInfo interface 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 by 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 Reviewed-by: Martin Kletzander --- 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 a2d0903c45..1893c280bd 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 32bfbecabc..9800b8fceb 100644 --- a/src/vbox/vbox_tmpl.c +++ b/src/vbox/vbox_tmpl.c @@ -2150,6 +2150,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) && @@ -2505,6 +2531,13 @@ static vboxUniformedIKeyboard _UIKeyboard = { .PutScancodes = _keyboardPutScancodes, }; +static vboxUniformedIVirtualBoxErrorInfo _UIVirtualBoxErrorInfo = { + .GetIID = _virtualBoxErrorInfoGetIID, + .GetComponent = _virtualBoxErrorInfoGetComponent, + .GetNext = _virtualBoxErrorInfoGetNext, + .GetText = _virtualBoxErrorInfoGetText, +}; + static uniformedMachineStateChecker _machineStateChecker = { .Online = _machineStateOnline, .Inactive = _machineStateInactive, @@ -2550,6 +2583,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 ba655feb95..5fbc1bf77d 100644 --- a/src/vbox/vbox_uniformed_api.h +++ b/src/vbox/vbox_uniformed_api.h @@ -494,6 +494,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); @@ -541,6 +548,7 @@ typedef struct { vboxUniformedIHNInterface UIHNInterface; vboxUniformedIDHCPServer UIDHCPServer; vboxUniformedIKeyboard UIKeyboard; + vboxUniformedIVirtualBoxErrorInfo UIVirtualBoxErrorInfo; uniformedMachineStateChecker machineStateChecker; /* vbox API features */ bool chipsetType;