hv:refine prepare_vm0 api

-- fix MISRA-C violation "procedure has more than one exit point"
   for this api
-- change start_vm to void type since it is always return 0

Tracked-On: #861
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Mingqiang Chi 2018-12-18 15:44:17 +08:00 committed by wenlingz
parent b5e0efca82
commit 64a463000f
3 changed files with 27 additions and 27 deletions

View File

@ -242,7 +242,7 @@ int32_t shutdown_vm(struct acrn_vm *vm)
/**
* * @pre vm != NULL
*/
int32_t start_vm(struct acrn_vm *vm)
void start_vm(struct acrn_vm *vm)
{
struct acrn_vcpu *vcpu = NULL;
@ -251,8 +251,6 @@ int32_t start_vm(struct acrn_vm *vm)
/* Only start BSP (vid = 0) and let BSP start other APs */
vcpu = vcpu_from_vid(vm, 0U);
schedule_vcpu(vcpu);
return 0;
}
/**
@ -402,31 +400,33 @@ static int32_t prepare_vm0(void)
vm0_desc.vm_hw_num_cores = phys_cpu_num;
err = create_vm(&vm0_desc, &vm);
if (err != 0) {
return err;
}
/* Allocate all cpus to vm0 at the beginning */
for (i = 0U; i < vm0_desc.vm_hw_num_cores; i++) {
err = prepare_vcpu(vm, i);
if (err != 0) {
return err;
if (err == 0) {
/* Allocate all cpus to vm0 at the beginning */
for (i = 0U; i < vm0_desc.vm_hw_num_cores; i++) {
err = prepare_vcpu(vm, i);
if (err != 0) {
break;
}
}
if (err == 0) {
if (vm_sw_loader == NULL) {
vm_sw_loader = general_sw_loader;
}
if (is_vm0(vm)) {
(void)vm_sw_loader(vm);
}
/* start vm0 BSP automatically */
start_vm(vm);
pr_acrnlog("Start VM0");
}
}
if (vm_sw_loader == NULL) {
vm_sw_loader = general_sw_loader;
}
if (is_vm0(vm)) {
(void )vm_sw_loader(vm);
}
/* start vm0 BSP automatically */
err = start_vm(vm);
pr_acrnlog("Start VM0");
return err;
}

View File

@ -177,7 +177,7 @@ int32_t hcall_destroy_vm(uint16_t vmid)
*/
int32_t hcall_start_vm(uint16_t vmid)
{
int32_t ret;
int32_t ret = 0;
struct acrn_vm *target_vm = get_vm_from_vmid(vmid);
if (target_vm == NULL) {
@ -185,7 +185,7 @@ int32_t hcall_start_vm(uint16_t vmid)
} else if (target_vm->sw.io_shared_page == NULL) {
ret = -1;
} else {
ret = start_vm(target_vm);
start_vm(target_vm);
}
return ret;

View File

@ -263,7 +263,7 @@ int32_t shutdown_vm(struct acrn_vm *vm);
void pause_vm(struct acrn_vm *vm);
void resume_vm(struct acrn_vm *vm);
void resume_vm_from_s3(struct acrn_vm *vm, uint32_t wakeup_vec);
int32_t start_vm(struct acrn_vm *vm);
void start_vm(struct acrn_vm *vm);
int32_t reset_vm(struct acrn_vm *vm);
int32_t create_vm(struct vm_description *vm_desc, struct acrn_vm **rtn_vm);
int32_t prepare_vm(uint16_t pcpu_id);