From 852d21db14ba639506b5782d9c6346b9f8231ffb Mon Sep 17 00:00:00 2001
From: Sebastian Sumpf <sebastian.sumpf@genode-labs.com>
Date: Thu, 10 Nov 2022 09:56:42 +0100
Subject: [PATCH] vbox6: print error in case machine powerup fails

Retrieve error message (best effort and might fail) from progress
information.

issue #4666
---
 repos/ports/src/virtualbox6/main.cc | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/repos/ports/src/virtualbox6/main.cc b/repos/ports/src/virtualbox6/main.cc
index 1dd498ad2e..1e64ce59b1 100644
--- a/repos/ports/src/virtualbox6/main.cc
+++ b/repos/ports/src/virtualbox6/main.cc
@@ -335,6 +335,15 @@ struct Main : Event_handler
 
 		if (state != MachineState_Running) {
 			error("machine could not enter running state");
+
+			/* retrieve and print error information */
+			IVirtualBoxErrorInfo *info;
+			progress->COMGETTER(ErrorInfo)(&info);
+
+			PRUnichar *text = (PRUnichar *)malloc(4096);
+			info->GetText((PRUnichar **)&text);
+			Genode::log("Error: ", Utf8Str(text).c_str());
+
 			throw Fatal();
 		}
 	}