Implement MSHV-specific hooks for vCPU creation and teardown in the i386 target.
Signed-off-by: Magnus Kulke <magnusku...@linux.microsoft.com> --- target/i386/mshv/mshv-cpu.c | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/target/i386/mshv/mshv-cpu.c b/target/i386/mshv/mshv-cpu.c index 2fe5319201..7a6965d7fb 100644 --- a/target/i386/mshv/mshv-cpu.c +++ b/target/i386/mshv/mshv-cpu.c @@ -28,6 +28,8 @@ #include "trace-accel_mshv.h" #include "trace.h" +#include <sys/ioctl.h> + int mshv_store_regs(CPUState *cpu) { error_report("unimplemented"); @@ -60,20 +62,29 @@ int mshv_run_vcpu(int vm_fd, CPUState *cpu, hv_message *msg, MshvVmExit *exit) void mshv_remove_vcpu(int vm_fd, int cpu_fd) { - error_report("unimplemented"); - abort(); + close(cpu_fd); } + int mshv_create_vcpu(int vm_fd, uint8_t vp_index, int *cpu_fd) { - error_report("unimplemented"); - abort(); + int ret; + struct mshv_create_vp vp_arg = { + .vp_index = vp_index, + }; + ret = ioctl(vm_fd, MSHV_CREATE_VP, &vp_arg); + if (ret < 0) { + error_report("failed to create mshv vcpu: %s", strerror(errno)); + return -1; + } + + *cpu_fd = ret; + + return 0; } void mshv_init_cpu_logic(void) { - error_report("unimplemented"); - abort(); } void mshv_arch_init_vcpu(CPUState *cpu) -- 2.34.1