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(a)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