hv:Simplify for-loop when walk through the vcpu

-- Not return NULL for vcpu_from_vid
  We have replaced dynamic memory with static memory for vcpu,
  then if vcpu_id is valid, this API should not return NULL.
-- Simplify the for-loop when walk through the vcpu

Tracked-On: #861
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
Reviewed-by: Li, Fei1 <fei1.li@intel.com>
Reviewed-by: Anthony Xu <anthony.xu@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Mingqiang Chi
2018-10-17 13:56:37 +08:00
committed by wenlingz
parent 813e3abccc
commit 85ececd2d7
5 changed files with 127 additions and 132 deletions

View File

@@ -319,12 +319,12 @@ int32_t hcall_set_vcpu_regs(struct vm *vm, uint16_t vmid, uint64_t param)
return -1;
}
vcpu = vcpu_from_vid(target_vm, vcpu_regs.vcpu_id);
if (vcpu == NULL) {
if (vcpu_regs.vcpu_id >= CONFIG_MAX_VCPUS_PER_VM) {
pr_err("%s: invalid vcpu_id for set_vcpu_regs\n", __func__);
return -1;
}
vcpu = vcpu_from_vid(target_vm, vcpu_regs.vcpu_id);
set_vcpu_regs(vcpu, &(vcpu_regs.vcpu_regs));
return 0;
@@ -437,13 +437,13 @@ int32_t hcall_notify_ioreq_finish(uint16_t vmid, uint16_t vcpu_id)
dev_dbg(ACRN_DBG_HYCALL, "[%d] NOTIFY_FINISH for vcpu %d",
vmid, vcpu_id);
vcpu = vcpu_from_vid(target_vm, vcpu_id);
if (vcpu == NULL) {
if (vcpu_id >= CONFIG_MAX_VCPUS_PER_VM) {
pr_err("%s, failed to get VCPU %d context from VM %d\n",
__func__, vcpu_id, target_vm->vm_id);
return -EINVAL;
}
vcpu = vcpu_from_vid(target_vm, vcpu_id);
emulate_io_post(vcpu);
return 0;