Introduce vm_get_vcpu helper function.

Change-Id: I46aef6d240a74357b96b6677d1ec4c8386076f57
diff --git a/src/vm.c b/src/vm.c
index e136e84..c154eca 100644
--- a/src/vm.c
+++ b/src/vm.c
@@ -60,7 +60,7 @@
 
 	/* Do basic initialization of vcpus. */
 	for (i = 0; i < vcpu_count; i++) {
-		vcpu_init(&vm->vcpus[i], vm);
+		vcpu_init(vm_get_vcpu(vm, i), vm);
 	}
 
 	++vm_count;
@@ -107,3 +107,13 @@
 	sl_unlock(&locked->vm->lock);
 	locked->vm = NULL;
 }
+
+/**
+ * Get the vCPU with the given index from the given VM.
+ * This assumes the index is valid, i.e. less than vm->vcpu_count.
+ */
+struct vcpu *vm_get_vcpu(struct vm *vm, uint32_t vcpu_index)
+{
+	assert(vcpu_index < vm->vcpu_count);
+	return &vm->vcpus[vcpu_index];
+}