Differentiate a preempted and yielding vCPU.
If it was preempted, it wants to run again right away. If it yielded, it
wants to take a scheduling decision to give another thread the chance to
use the cycles.
Change-Id: I598bc4b4db7dea5d42a66616d8ca936e352d3583
diff --git a/main.c b/main.c
index 505ca6c..a49a4e2 100644
--- a/main.c
+++ b/main.c
@@ -274,8 +274,16 @@
ret = hf_vcpu_run(vcpu->vm->id, vcpu->vcpu_index);
switch (ret.code) {
- /* Yield (forcibly or voluntarily). */
+ /* Preempted. */
+ case HF_VCPU_RUN_PREEMPTED:
+ if (need_resched())
+ schedule();
+ break;
+
+ /* Yield. */
case HF_VCPU_RUN_YIELD:
+ if (!kthread_should_stop())
+ schedule();
break;
/* WFI. */