Introducing hf_vcpu_count_t for vCPU count.
Return 0 rather than -1 on error.
Change-Id: I95cdde0744ef13e9bd748ce8ed32439d3d7f2010
diff --git a/src/api.c b/src/api.c
index 5506a04..bb954a6 100644
--- a/src/api.c
+++ b/src/api.c
@@ -224,20 +224,22 @@
}
/**
- * Returns the number of vcpus configured in the given VM.
+ * Returns the number of vCPUs configured in the given VM, or 0 if there is no
+ * such VM or the caller is not the primary VM.
*/
-int64_t api_vcpu_get_count(spci_vm_id_t vm_id, const struct vcpu *current)
+spci_vcpu_count_t api_vcpu_get_count(spci_vm_id_t vm_id,
+ const struct vcpu *current)
{
struct vm *vm;
/* Only the primary VM needs to know about vcpus for scheduling. */
if (current->vm->id != HF_PRIMARY_VM_ID) {
- return -1;
+ return 0;
}
vm = vm_find(vm_id);
if (vm == NULL) {
- return -1;
+ return 0;
}
return vm->vcpu_count;