@@ -362,3 +362,21 @@ This command is always allowed.
* -KVM_PERM - the event specified by ``id`` is disallowed
* -KVM_EINVAL - padding is not zero
+
+5. KVMI_GET_GUEST_INFO
+----------------------
+
+:Architectures: all
+:Versions: >= 1
+:Parameters:: none
+:Returns:
+
+::
+
+ struct kvmi_error_code;
+ struct kvmi_get_guest_info_reply {
+ __u32 vcpu_count;
+ __u32 padding[3];
+ };
+
+Returns the number of online vCPUs.
@@ -102,4 +102,9 @@ struct kvmi_check_event {
__u32 padding2;
};
+struct kvmi_get_guest_info_reply {
+ __u32 vcpu_count;
+ __u32 padding[3];
+};
+
#endif /* _UAPI__LINUX_KVMI_H */
@@ -12,6 +12,7 @@ static const char *const msg_IDs[] = {
[KVMI_CHECK_COMMAND] = "KVMI_CHECK_COMMAND",
[KVMI_CHECK_EVENT] = "KVMI_CHECK_EVENT",
[KVMI_CONTROL_CMD_RESPONSE] = "KVMI_CONTROL_CMD_RESPONSE",
+ [KVMI_GET_GUEST_INFO] = "KVMI_GET_GUEST_INFO",
[KVMI_GET_VERSION] = "KVMI_GET_VERSION",
};
@@ -213,6 +214,18 @@ static int handle_check_event(struct kvmi *ikvm,
return kvmi_msg_vm_maybe_reply(ikvm, msg, ec, NULL, 0);
}
+static int handle_get_guest_info(struct kvmi *ikvm,
+ const struct kvmi_msg_hdr *msg,
+ const void *req)
+{
+ struct kvmi_get_guest_info_reply rpl;
+
+ memset(&rpl, 0, sizeof(rpl));
+ rpl.vcpu_count = atomic_read(&ikvm->kvm->online_vcpus);
+
+ return kvmi_msg_vm_maybe_reply(ikvm, msg, 0, &rpl, sizeof(rpl));
+}
+
static int handle_control_cmd_response(struct kvmi *ikvm,
const struct kvmi_msg_hdr *msg,
const void *_req)
@@ -246,6 +259,7 @@ static int(*const msg_vm[])(struct kvmi *, const struct kvmi_msg_hdr *,
[KVMI_CHECK_COMMAND] = handle_check_command,
[KVMI_CHECK_EVENT] = handle_check_event,
[KVMI_CONTROL_CMD_RESPONSE] = handle_control_cmd_response,
+ [KVMI_GET_GUEST_INFO] = handle_get_guest_info,
[KVMI_GET_VERSION] = handle_get_version,
};