]> xenbits.xensource.com Git - libvirt.git/commitdiff
vbox: Introduce IVirtualBoxErrorInfo interface
authorMichal Privoznik <mprivozn@redhat.com>
Fri, 20 Jan 2023 07:59:40 +0000 (08:59 +0100)
committerMichal Privoznik <mprivozn@redhat.com>
Tue, 24 Jan 2023 09:45:30 +0000 (10:45 +0100)
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 <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
src/vbox/vbox_common.h
src/vbox/vbox_tmpl.c
src/vbox/vbox_uniformed_api.h

index a2d0903c45156a3c8b53e75511c4804211ba08f0..1893c280bd9aaab9ad547461841df0dfc1072d9f 100644 (file)
@@ -361,6 +361,7 @@ typedef nsISupports IHost;
 typedef nsISupports IHostNetworkInterface;
 typedef nsISupports IDHCPServer;
 typedef nsISupports IKeyboard;
+typedef nsISupports IVirtualBoxErrorInfo;
 
 /* Macros for all vbox drivers. */
 
index 32bfbecabc3a910dda189f498b8c8e0c63039ab3..9800b8fcebd86942f7dcf8c6c1894f076e1abbbc 100644 (file)
@@ -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;
index ba655feb95fed6a527c244475085bcfce2b57a81..5fbc1bf77d50dbcb41d9dfa945dfdeac21dfaf51 100644 (file)
@@ -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;