Skip to content

Commit ac275f4

Browse files
joaopeixoto13DavidMCerdeira
authored andcommitted
fix(core/vm): enabled the utilization of the vcpu active flag
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]>
1 parent c331298 commit ac275f4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/core/vm.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ static void vm_vcpu_init(struct vm* vm, const struct vm_config* vm_config)
4848
vcpu->id = vcpu_id;
4949
vcpu->phys_id = cpu()->id;
5050
vcpu->vm = vm;
51+
vcpu->active = true;
5152
cpu()->vcpu = vcpu;
5253

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

350351
void vcpu_run(struct vcpu* vcpu)
351352
{
352-
cpu()->vcpu->active = true;
353-
vcpu_arch_run(vcpu);
353+
if (vcpu->active == false) {
354+
cpu_idle();
355+
} else {
356+
vcpu_arch_run(vcpu);
357+
}
354358
}

0 commit comments

Comments
 (0)