Introduce spci_vm_count_t for count of VMs.
Change-Id: I4eae492136019c6a39b2d06b59793f021b4e07bb
diff --git a/inc/hf/api.h b/inc/hf/api.h
index 21bed0c..7d6b7c0 100644
--- a/inc/hf/api.h
+++ b/inc/hf/api.h
@@ -24,7 +24,7 @@
void api_init(struct mpool *ppool);
spci_vm_id_t api_vm_get_id(const struct vcpu *current);
-int64_t api_vm_get_count(void);
+spci_vm_count_t api_vm_get_count(void);
int64_t api_vcpu_get_count(spci_vm_id_t vm_id, const struct vcpu *current);
void api_regs_state_saved(struct vcpu *vcpu);
struct hf_vcpu_run_return api_vcpu_run(spci_vm_id_t vm_id, uint32_t vcpu_idx,
diff --git a/inc/hf/vm.h b/inc/hf/vm.h
index 6a8f8b1..4bebc20 100644
--- a/inc/hf/vm.h
+++ b/inc/hf/vm.h
@@ -98,7 +98,7 @@
};
bool vm_init(uint32_t vcpu_count, struct mpool *ppool, struct vm **new_vm);
-uint32_t vm_get_count(void);
+spci_vm_count_t vm_get_count(void);
struct vm *vm_find(spci_vm_id_t id);
struct vm_locked vm_lock(struct vm *vm);
void vm_unlock(struct vm_locked *locked);
diff --git a/inc/vmapi/hf/call.h b/inc/vmapi/hf/call.h
index 239244f..01be71f 100644
--- a/inc/vmapi/hf/call.h
+++ b/inc/vmapi/hf/call.h
@@ -56,7 +56,7 @@
/**
* Returns the number of secondary VMs.
*/
-static inline int64_t hf_vm_get_count(void)
+static inline spci_vm_count_t hf_vm_get_count(void)
{
return hf_call(HF_VM_GET_COUNT, 0, 0, 0);
}
diff --git a/inc/vmapi/hf/spci.h b/inc/vmapi/hf/spci.h
index 523c4ae..c387e62 100644
--- a/inc/vmapi/hf/spci.h
+++ b/inc/vmapi/hf/spci.h
@@ -60,8 +60,15 @@
/* clang-format on */
+/** The ID of a VM. These are assigned sequentially. */
typedef uint16_t spci_vm_id_t;
+/**
+ * A count of VMs. This has the same range as the VM IDs but we give it a
+ * different name to make the different semantics clear.
+ */
+typedef spci_vm_id_t spci_vm_count_t;
+
/** SPCI common message header. */
struct spci_message {
/*
diff --git a/src/api.c b/src/api.c
index 698e788..ccbeeda 100644
--- a/src/api.c
+++ b/src/api.c
@@ -216,7 +216,7 @@
/**
* Returns the number of VMs configured to run.
*/
-int64_t api_vm_get_count(void)
+spci_vm_count_t api_vm_get_count(void)
{
return vm_get_count();
}
diff --git a/src/vm.c b/src/vm.c
index e9919d8..8532144 100644
--- a/src/vm.c
+++ b/src/vm.c
@@ -23,7 +23,7 @@
#include "vmapi/hf/call.h"
static struct vm vms[MAX_VMS];
-static uint32_t vm_count;
+static spci_vm_count_t vm_count;
bool vm_init(uint32_t vcpu_count, struct mpool *ppool, struct vm **new_vm)
{
@@ -69,7 +69,7 @@
return true;
}
-uint32_t vm_get_count(void)
+spci_vm_count_t vm_get_count(void)
{
return vm_count;
}