Skip to content

Commit

Permalink
fix(core/vm): enabled the utilization of the vcpu active flag
Browse files Browse the repository at this point in the history
This commit relocates the vCPU active flag assignment from the
run method to the vCPU initialization method.
Additionally, it introduces a logic check within the run method
to verify whether the vCPU should be executed.

Signed-off-by: joaopeixoto13 <[email protected]>
  • Loading branch information
joaopeixoto13 authored and DavidMCerdeira committed Sep 17, 2024
1 parent c331298 commit ac275f4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/core/vm.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ static void vm_vcpu_init(struct vm* vm, const struct vm_config* vm_config)
vcpu->id = vcpu_id;
vcpu->phys_id = cpu()->id;
vcpu->vm = vm;
vcpu->active = true;
cpu()->vcpu = vcpu;

vcpu_arch_init(vcpu, vm);
Expand Down Expand Up @@ -349,6 +350,9 @@ __attribute__((weak)) cpumap_t vm_translate_to_vcpu_mask(struct vm* vm, cpumap_t

void vcpu_run(struct vcpu* vcpu)
{
cpu()->vcpu->active = true;
vcpu_arch_run(vcpu);
if (vcpu->active == false) {
cpu_idle();
} else {
vcpu_arch_run(vcpu);
}
}

0 comments on commit ac275f4

Please sign in to comment.