vbox: Add platform-specific setup machine hook

Add call to genode_setup_machine prior to machine registration in
frontend machine setup code. This enables platform-specific adjustments
to the machine instance.

The new function is used on hw_x86_64_muen to clamp the processor count
to 1 as multiple virtual CPUs are not supported on this platform.

Issue #2016
This commit is contained in:
Adrian-Ken Rueegsegger 2016-05-04 18:40:30 +02:00 committed by Norman Feske
parent e3fbeeb25e
commit 6d28ea1c5c
9 changed files with 51 additions and 0 deletions

View File

@ -1,11 +1,16 @@
include $(REP_DIR)/lib/mk/virtualbox-common.inc
LIBS += stdcxx
SRC_CC = pgm.cc sup.cc
INC_DIR += $(call select_from_repositories,src/lib/libc)
INC_DIR += $(VBOX_DIR)/Main/xml
INC_DIR += $(VBOX_DIR)/Main/include
INC_DIR += $(VBOX_DIR)/VMM/include
INC_DIR += $(REP_DIR)/src/virtualbox
INC_DIR += $(REP_DIR)/src/virtualbox/frontend
INC_DIR += $(REP_DIR)/src/virtualbox/spec/muen
vpath pgm.cc $(REP_DIR)/src/virtualbox/

View File

@ -1,12 +1,17 @@
include $(REP_DIR)/lib/mk/virtualbox-common.inc
LIBS += stdcxx
SRC_CC = sup.cc pgm.cc
INC_DIR += $(call select_from_repositories,src/lib/libc)
INC_DIR += $(call select_from_repositories,src/lib/pthread)
INC_DIR += $(VBOX_DIR)/Main/xml
INC_DIR += $(VBOX_DIR)/Main/include
INC_DIR += $(VBOX_DIR)/VMM/include
INC_DIR += $(REP_DIR)/src/virtualbox
INC_DIR += $(REP_DIR)/src/virtualbox/frontend
INC_DIR += $(REP_DIR)/src/virtualbox/spec/nova
vpath pgm.cc $(REP_DIR)/src/virtualbox/

View File

@ -1,10 +1,15 @@
include $(REP_DIR)/lib/mk/virtualbox-common.inc
LIBS += stdcxx
SRC_CC = pgm.cc sup.cc
INC_DIR += $(call select_from_repositories,src/lib/libc)
INC_DIR += $(VBOX_DIR)/Main/xml
INC_DIR += $(VBOX_DIR)/Main/include
INC_DIR += $(VBOX_DIR)/VMM/include
INC_DIR += $(REP_DIR)/src/virtualbox
INC_DIR += $(REP_DIR)/src/virtualbox/frontend
INC_DIR += $(REP_DIR)/src/virtualbox/accloff
vpath pgm.cc $(REP_DIR)/src/virtualbox/

View File

@ -67,6 +67,7 @@ SRC_CC += Main/glue/xpcom/helpers.cpp
INC_DIR += $(VBOX_DIR)/Main/xml
INC_DIR += $(VBOX_DIR)/Main/include
INC_DIR += $(REP_DIR)/src/virtualbox
INC_DIR += $(REP_DIR)/src/virtualbox/frontend
INC_DIR += $(REP_DIR)/src/virtualbox/frontend/VBoxAPIWrap

View File

@ -123,6 +123,9 @@ void genode_update_tsc(void (*update_func)(void), unsigned long update_us)
}
HRESULT genode_setup_machine(ComObjPtr<Machine> machine) { return S_OK; }
bool Vmm_memory::revoke_from_vm(Mem_region *r)
{
PWRN("%s unimplemented", __func__);

View File

@ -34,6 +34,7 @@
/* Genode port specific includes */
#include "console.h"
#include "fb.h"
#include "../sup.h"
static char c_vbox_file[128];
static char c_vbox_vmname[128];
@ -106,6 +107,10 @@ HRESULT setupmachine()
if (FAILED(rc))
return rc;
rc = genode_setup_machine(machine);
if (FAILED(rc))
return rc;
rc = virtualbox->RegisterMachine(machine);
if (FAILED(rc))
return rc;

View File

@ -747,6 +747,25 @@ uint64_t genode_cpu_hz()
}
HRESULT genode_setup_machine(ComObjPtr<Machine> machine)
{
HRESULT rc;
ULONG cCpus;
rc = machine->COMGETTER(CPUCount)(&cCpus);
if (FAILED(rc))
return rc;
if (cCpus != 1) {
PWRN("Configured CPUs %u not supported, reducing to 1.", cCpus);
rc = machine->COMSETTER(CPUCount)(1);
if (FAILED(rc))
return rc;
}
return S_OK;
}
/**
* Dummies and unimplemented stuff.
*/

View File

@ -216,6 +216,9 @@ void genode_update_tsc(void (*update_func)(void), unsigned long update_us)
}
HRESULT genode_setup_machine(ComObjPtr<Machine> machine) { return S_OK; }
bool Vmm_memory::revoke_from_vm(Mem_region *r)
{
Assert(r);

View File

@ -20,8 +20,11 @@
/* VirtualBox includes */
#include <VBox/vmm/vm.h>
#include <VBox/vmm/gvmm.h>
#include <VBox/com/ptr.h>
#include <iprt/param.h>
#include "MachineImpl.h"
/**
* Returns true if a vCPU could be started. If false we run without
* hardware acceleration support.
@ -42,4 +45,6 @@ Genode::Cpu_session * get_vcpu_cpu_session();
void genode_VMMR0_DO_GVMM_CREATE_VM(PSUPVMMR0REQHDR pReqHdr);
void genode_VMMR0_DO_GVMM_REGISTER_VMCPU(PVMR0 pVMR0, VMCPUID idCpu);
HRESULT genode_setup_machine(ComObjPtr<Machine> machine);
#endif /* _SUP_H_ */