mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2026-01-06 08:04:55 +00:00
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:
@@ -199,6 +199,9 @@ static inline bool is_vm0(struct vm *vm)
|
||||
return (vm->vm_id) == 0U;
|
||||
}
|
||||
|
||||
/*
|
||||
* @pre vcpu_id < CONFIG_MAX_VCPUS_PER_VM
|
||||
*/
|
||||
static inline struct vcpu *vcpu_from_vid(struct vm *vm, uint16_t vcpu_id)
|
||||
{
|
||||
uint16_t i;
|
||||
@@ -206,11 +209,10 @@ static inline struct vcpu *vcpu_from_vid(struct vm *vm, uint16_t vcpu_id)
|
||||
|
||||
foreach_vcpu(i, vm, vcpu) {
|
||||
if (vcpu->vcpu_id == vcpu_id) {
|
||||
return vcpu;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
return vcpu;
|
||||
}
|
||||
|
||||
static inline struct vcpu *vcpu_from_pid(struct vm *vm, uint16_t pcpu_id)
|
||||
|
||||
Reference in New Issue
Block a user