vbox5: use with_libc when call-in into vbox code

required due to pthreads becoming/are an integral part of the libc now.
Commit avoids libc error:

Error: libc suspend() called from non-user context (0xaf5c784) - aborting

Issue #3550
This commit is contained in:
Alexander Boettcher 2019-11-15 11:51:10 +01:00 committed by Christian Helmuth
parent 4d7d208940
commit cb61a28362
4 changed files with 39 additions and 15 deletions

View File

@ -12,6 +12,7 @@
*/ */
#include <base/log.h> #include <base/log.h>
#include <libc/component.h>
#include <util/xml_node.h> #include <util/xml_node.h>
#include <VBox/settings.h> #include <VBox/settings.h>
@ -123,7 +124,7 @@ void GenodeConsole::update_video_mode()
32); 32);
} }
void GenodeConsole::handle_input() void GenodeConsole::_handle_input()
{ {
/* disable input processing if vm is powered down */ /* disable input processing if vm is powered down */
if (vm_down && (_vbox_mouse || _vbox_keyboard)) { if (vm_down && (_vbox_mouse || _vbox_keyboard)) {
@ -273,7 +274,7 @@ void GenodeConsole::handle_input()
RTTimeMilliTS()); RTTimeMilliTS());
} }
void GenodeConsole::handle_mode_change() void GenodeConsole::_handle_mode_change()
{ {
IFramebuffer *pFramebuffer = NULL; IFramebuffer *pFramebuffer = NULL;
HRESULT rc = i_getDisplay()->QueryFramebuffer(0, &pFramebuffer); HRESULT rc = i_getDisplay()->QueryFramebuffer(0, &pFramebuffer);
@ -312,7 +313,7 @@ void GenodeConsole::init_clipboard()
} }
} }
void GenodeConsole::handle_cb_rom_change() void GenodeConsole::_handle_cb_rom_change()
{ {
if (!_clipboard_rom) if (!_clipboard_rom)
return; return;
@ -332,7 +333,7 @@ void GenodeConsole::init_backends(IKeyboard * gKeyboard, IMouse * gMouse)
_nitpicker.mode_sigh(_mode_change_signal_dispatcher); _nitpicker.mode_sigh(_mode_change_signal_dispatcher);
handle_mode_change(); _handle_mode_change();
} }
void GenodeConsole::i_onMouseCapabilityChange(BOOL supportsAbsolute, void GenodeConsole::i_onMouseCapabilityChange(BOOL supportsAbsolute,
@ -518,7 +519,7 @@ void fireKeyboardLedsChangedEvent(IEventSource *, bool num_lock,
guest_caps_lock = caps_lock; guest_caps_lock = caps_lock;
} }
void GenodeConsole::handle_sticky_keys() void GenodeConsole::_handle_sticky_keys()
{ {
/* no keyboard - no sticky key handling */ /* no keyboard - no sticky key handling */
if (!_vbox_keyboard || !_caps_lock.constructed()) if (!_vbox_keyboard || !_caps_lock.constructed())
@ -553,3 +554,15 @@ void GenodeConsole::handle_sticky_keys()
_vbox_keyboard->PutScancode(Input::KEY_CAPSLOCK | 0x80); _vbox_keyboard->PutScancode(Input::KEY_CAPSLOCK | 0x80);
} }
} }
void GenodeConsole::handle_input() {
Libc::with_libc([&] () { _handle_input(); }); }
void GenodeConsole::handle_sticky_keys() {
Libc::with_libc([&] () { _handle_sticky_keys(); }); }
void GenodeConsole::handle_mode_change() {
Libc::with_libc([&] () { _handle_mode_change(); }); }
void GenodeConsole::handle_cb_rom_change() {
Libc::with_libc([&] () { _handle_cb_rom_change(); }); }

View File

@ -140,6 +140,11 @@ class GenodeConsole : public Console {
|| keycode == Input::BTN_MIDDLE; || keycode == Input::BTN_MIDDLE;
} }
void _handle_input();
void _handle_mode_change();
void _handle_cb_rom_change();
void _handle_sticky_keys();
public: public:
GenodeConsole() GenodeConsole()

View File

@ -1154,8 +1154,10 @@ class Periodic_gip
ASMAtomicIncU32(&cpu->u32TransactionId); ASMAtomicIncU32(&cpu->u32TransactionId);
/* call the timer function of the RTTimerCreate call */ /* call the timer function of the RTTimerCreate call */
if (rttimer_func) if (rttimer_func) {
rttimer_func(nullptr, rttimer_obj, 0); Libc::with_libc([&] () {
rttimer_func(nullptr, rttimer_obj, 0); });
}
for (Vcpu_handler *vcpu_handler = vcpu_handler_list().first(); for (Vcpu_handler *vcpu_handler = vcpu_handler_list().first();
vcpu_handler; vcpu_handler;

View File

@ -45,6 +45,7 @@
/* VBox Genode specific */ /* VBox Genode specific */
#include "vmm.h" #include "vmm.h"
#include <libc/component.h>
/******************************************************************************* /*******************************************************************************
* Structures and Typedefs * * Structures and Typedefs *
@ -121,12 +122,13 @@ class Nic_client
char *rx_content = _nic.rx()->packet_content(rx_packet); char *rx_content = _nic.rx()->packet_content(rx_packet);
int rc = _down_rx->pfnWaitReceiveAvail(_down_rx, RT_INDEFINITE_WAIT); Libc::with_libc([&] () {
if (RT_FAILURE(rc)) int rc = _down_rx->pfnWaitReceiveAvail(_down_rx, RT_INDEFINITE_WAIT);
continue; if (RT_FAILURE(rc)) return;
rc = _down_rx->pfnReceive(_down_rx, rx_content, rx_packet.size()); rc = _down_rx->pfnReceive(_down_rx, rx_content, rx_packet.size());
AssertRC(rc); AssertRC(rc);
});
_nic.rx()->acknowledge_packet(rx_packet); _nic.rx()->acknowledge_packet(rx_packet);
} }
@ -138,9 +140,11 @@ class Nic_client
{ {
_link_up = _nic.link_state(); _link_up = _nic.link_state();
_down_rx_config->pfnSetLinkState(_down_rx_config, Libc::with_libc([&] () {
_link_up ? PDMNETWORKLINKSTATE_UP _down_rx_config->pfnSetLinkState(_down_rx_config,
: PDMNETWORKLINKSTATE_DOWN); _link_up ? PDMNETWORKLINKSTATE_UP
: PDMNETWORKLINKSTATE_DOWN);
});
} }
void _handle_destruct() void _handle_destruct()