hv: create all VCPUs for guest when create VM

To enable static configuration of different scenarios, we configure VMs
in HV code and prepare all nesserary resources for this VM in create VM
hypercall. It means when we create one VM through hypercall, HV will
read all its configuration and run it automatically.

Tracked-On: #3663
Signed-off-by: Jason Chen CJ <jason.cj.chen@intel.com>
Signed-off-by: Yu Wang <yu1.wang@intel.com>
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Shuo A Liu 2019-05-22 15:09:34 +08:00 committed by ACRN System Integration
parent 9a23ec6b5a
commit 2096c43e5c
1 changed files with 17 additions and 11 deletions

View File

@ -421,6 +421,8 @@ int32_t create_vm(uint16_t vm_id, struct acrn_vm_config *vm_config, struct acrn_
struct acrn_vm *vm = NULL;
int32_t status = 0;
bool need_cleanup = false;
uint32_t i;
uint16_t pcpu_id;
/* Allocate memory for virtual machine */
vm = &vm_array[vm_id];
@ -536,6 +538,21 @@ int32_t create_vm(uint16_t vm_id, struct acrn_vm_config *vm_config, struct acrn_
(void)memset(vm->arch_vm.nworld_eptp, 0U, PAGE_SIZE);
}
}
if (status == 0) {
/* We have assumptions:
* 1) vcpus used by SOS has been offlined by DM before UOS re-use it.
* 2) vcpu_affinity[] passed sanitization is OK for vcpu creating.
*/
for (i = 0U; i < vm_config->vcpu_num; i++) {
pcpu_id = ffs64(vm_config->vcpu_affinity[i]);
status = prepare_vcpu(vm, pcpu_id);
if (status != 0) {
break;
}
}
}
return status;
}
@ -724,21 +741,10 @@ void resume_vm_from_s3(struct acrn_vm *vm, uint32_t wakeup_vec)
void prepare_vm(uint16_t vm_id, struct acrn_vm_config *vm_config)
{
int32_t err = 0;
uint16_t i, pcpu_id;
struct acrn_vm *vm = NULL;
err = create_vm(vm_id, vm_config, &vm);
if (err == 0) {
for (i = 0U; i < vm_config->vcpu_num; i++) {
pcpu_id = ffs64(vm_config->vcpu_affinity[i]);
err = prepare_vcpu(vm, pcpu_id);
if (err != 0) {
break;
}
}
}
if (err == 0) {
if (is_prelaunched_vm(vm)) {
build_vacpi(vm);