mirror of
https://github.com/genodelabs/genode.git
synced 2024-12-23 23:42:32 +00:00
vbox: Factor out memory config check
Move Genode/vbox memory configuration check to separate genode_check_memory_config() function and call it in platform-specific setup machine hook of accloff/nova. The rationale for this change is to omit the check on Muen since the guest memory is separate and not allocated from base-hw memory. Issue #2016
This commit is contained in:
parent
68bab6a411
commit
63591160df
@ -123,7 +123,10 @@ void genode_update_tsc(void (*update_func)(void), unsigned long update_us)
|
||||
}
|
||||
|
||||
|
||||
HRESULT genode_setup_machine(ComObjPtr<Machine> machine) { return S_OK; }
|
||||
HRESULT genode_setup_machine(ComObjPtr<Machine> machine)
|
||||
{
|
||||
return genode_check_memory_config(machine);
|
||||
}
|
||||
|
||||
|
||||
bool Vmm_memory::revoke_from_vm(Mem_region *r)
|
||||
|
@ -125,27 +125,6 @@ HRESULT setupmachine()
|
||||
if (FAILED(rc))
|
||||
return rc;
|
||||
|
||||
/* Validate configured memory of vbox file and Genode config */
|
||||
ULONG memory_vbox;
|
||||
rc = machine->COMGETTER(MemorySize)(&memory_vbox);
|
||||
if (FAILED(rc))
|
||||
return rc;
|
||||
|
||||
/* request max available memory */
|
||||
size_t memory_genode = Genode::env()->ram_session()->avail() >> 20;
|
||||
size_t memory_vmm = 28;
|
||||
|
||||
if (memory_vbox + memory_vmm > memory_genode) {
|
||||
PERR("Configured memory %u MB (vbox file) is insufficient.",
|
||||
memory_vbox);
|
||||
PERR("%zu MB (1) - %zu MB (2) = %zu MB (3)",
|
||||
memory_genode, memory_vmm, memory_genode - memory_vmm);
|
||||
PERR("(1) available memory based defined by Genode config");
|
||||
PERR("(2) minimum memory required for VBox VMM");
|
||||
PERR("(3) maximal available memory to VM");
|
||||
return E_FAIL;
|
||||
}
|
||||
|
||||
/* Console object */
|
||||
ComPtr<IConsole> gConsole;
|
||||
rc = session->COMGETTER(Console)(gConsole.asOutParam());
|
||||
|
@ -216,7 +216,10 @@ void genode_update_tsc(void (*update_func)(void), unsigned long update_us)
|
||||
}
|
||||
|
||||
|
||||
HRESULT genode_setup_machine(ComObjPtr<Machine> machine) { return S_OK; }
|
||||
HRESULT genode_setup_machine(ComObjPtr<Machine> machine)
|
||||
{
|
||||
return genode_check_memory_config(machine);
|
||||
};
|
||||
|
||||
|
||||
bool Vmm_memory::revoke_from_vm(Mem_region *r)
|
||||
|
@ -328,3 +328,31 @@ void genode_VMMR0_DO_GVMM_REGISTER_VMCPU(PVMR0 pVMR0, VMCPUID idCpu)
|
||||
PVM pVM = reinterpret_cast<PVM>(pVMR0);
|
||||
pVM->aCpus[idCpu].hNativeThreadR0 = RTThreadNativeSelf();
|
||||
}
|
||||
|
||||
|
||||
HRESULT genode_check_memory_config(ComObjPtr<Machine> machine)
|
||||
{
|
||||
HRESULT rc;
|
||||
|
||||
/* Validate configured memory of vbox file and Genode config */
|
||||
ULONG memory_vbox;
|
||||
rc = machine->COMGETTER(MemorySize)(&memory_vbox);
|
||||
if (FAILED(rc))
|
||||
return rc;
|
||||
|
||||
/* Request max available memory */
|
||||
size_t memory_genode = Genode::env()->ram_session()->avail() >> 20;
|
||||
size_t memory_vmm = 28;
|
||||
|
||||
if (memory_vbox + memory_vmm > memory_genode) {
|
||||
PERR("Configured memory %u MB (vbox file) is insufficient.",
|
||||
memory_vbox);
|
||||
PERR("%zu MB (1) - %zu MB (2) = %zu MB (3)",
|
||||
memory_genode, memory_vmm, memory_genode - memory_vmm);
|
||||
PERR("(1) available memory based defined by Genode config");
|
||||
PERR("(2) minimum memory required for VBox VMM");
|
||||
PERR("(3) maximal available memory to VM");
|
||||
return E_FAIL;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
@ -47,4 +47,6 @@ void genode_VMMR0_DO_GVMM_REGISTER_VMCPU(PVMR0 pVMR0, VMCPUID idCpu);
|
||||
|
||||
HRESULT genode_setup_machine(ComObjPtr<Machine> machine);
|
||||
|
||||
HRESULT genode_check_memory_config(ComObjPtr<Machine> machine);
|
||||
|
||||
#endif /* _SUP_H_ */
|
||||
|
Loading…
Reference in New Issue
Block a user