hv: dm: Use new VM management ioctls

IC_CREATE_VM		->	ACRN_IOCTL_CREATE_VM
IC_DESTROY_VM		->	ACRN_IOCTL_DESTROY_VM
IC_START_VM		->	ACRN_IOCTL_START_VM
IC_PAUSE_VM		->	ACRN_IOCTL_PAUSE_VM
IC_RESET_VM		->	ACRN_IOCTL_RESET_VM

struct acrn_create_vm	->	struct acrn_vm_creation

Tracked-On: #6282
Signed-off-by: Shuo A Liu <shuo.a.liu@intel.com>
This commit is contained in:
Shuo A Liu 2021-07-07 13:13:17 +08:00 committed by wenlingz
parent 7efe18a84b
commit f476ca55ab
6 changed files with 25 additions and 23 deletions

View File

@ -165,12 +165,12 @@ struct vmctx *
vm_create(const char *name, uint64_t req_buf, int *vcpu_num) vm_create(const char *name, uint64_t req_buf, int *vcpu_num)
{ {
struct vmctx *ctx; struct vmctx *ctx;
struct acrn_create_vm create_vm; struct acrn_vm_creation create_vm;
int error, retry = 10; int error, retry = 10;
uuid_t vm_uuid; uuid_t vm_uuid;
struct stat tmp_st; struct stat tmp_st;
memset(&create_vm, 0, sizeof(struct acrn_create_vm)); memset(&create_vm, 0, sizeof(struct acrn_vm_creation));
ctx = calloc(1, sizeof(struct vmctx) + strnlen(name, PATH_MAX) + 1); ctx = calloc(1, sizeof(struct vmctx) + strnlen(name, PATH_MAX) + 1);
if ((ctx == NULL) || (devfd != -1)) if ((ctx == NULL) || (devfd != -1))
goto err; goto err;
@ -230,9 +230,9 @@ vm_create(const char *name, uint64_t req_buf, int *vcpu_num)
create_vm.vm_flag |= GUEST_FLAG_IO_COMPLETION_POLLING; create_vm.vm_flag |= GUEST_FLAG_IO_COMPLETION_POLLING;
} }
create_vm.req_buf = req_buf; create_vm.ioreq_buf = req_buf;
while (retry > 0) { while (retry > 0) {
error = ioctl(ctx->fd, IC_CREATE_VM, &create_vm); error = ioctl(ctx->fd, ACRN_IOCTL_CREATE_VM, &create_vm);
if (error == 0) if (error == 0)
break; break;
usleep(500000); usleep(500000);
@ -311,7 +311,7 @@ vm_destroy(struct vmctx *ctx)
if (!ctx) if (!ctx)
return; return;
ioctl(ctx->fd, IC_DESTROY_VM, NULL); ioctl(ctx->fd, ACRN_IOCTL_DESTROY_VM, NULL);
close(ctx->fd); close(ctx->fd);
free(ctx); free(ctx);
devfd = -1; devfd = -1;
@ -468,7 +468,7 @@ vm_run(struct vmctx *ctx)
{ {
int error; int error;
error = ioctl(ctx->fd, IC_START_VM, &ctx->vmid); error = ioctl(ctx->fd, ACRN_IOCTL_START_VM, &ctx->vmid);
return error; return error;
} }
@ -476,13 +476,13 @@ vm_run(struct vmctx *ctx)
void void
vm_pause(struct vmctx *ctx) vm_pause(struct vmctx *ctx)
{ {
ioctl(ctx->fd, IC_PAUSE_VM, &ctx->vmid); ioctl(ctx->fd, ACRN_IOCTL_PAUSE_VM, &ctx->vmid);
} }
void void
vm_reset(struct vmctx *ctx) vm_reset(struct vmctx *ctx)
{ {
ioctl(ctx->fd, IC_RESET_VM, &ctx->vmid); ioctl(ctx->fd, ACRN_IOCTL_RESET_VM, &ctx->vmid);
} }
void void

View File

@ -72,13 +72,18 @@
#define ACRN_IOCTL_GET_PLATFORM_INFO \ #define ACRN_IOCTL_GET_PLATFORM_INFO \
_IOR(ACRN_IOCTL_TYPE, 0x03, struct acrn_platform_info) _IOR(ACRN_IOCTL_TYPE, 0x03, struct acrn_platform_info)
/* VM management */
#define IC_ID_VM_BASE 0x10UL #define IC_ID_VM_BASE 0x10UL
#define IC_CREATE_VM _IC_ID(IC_ID, IC_ID_VM_BASE + 0x00) #define ACRN_IOCTL_CREATE_VM \
#define IC_DESTROY_VM _IC_ID(IC_ID, IC_ID_VM_BASE + 0x01) _IOWR(ACRN_IOCTL_TYPE, 0x10, struct acrn_vm_creation)
#define IC_START_VM _IC_ID(IC_ID, IC_ID_VM_BASE + 0x02) #define ACRN_IOCTL_DESTROY_VM \
#define IC_PAUSE_VM _IC_ID(IC_ID, IC_ID_VM_BASE + 0x03) _IO(ACRN_IOCTL_TYPE, 0x11)
#define IC_RESET_VM _IC_ID(IC_ID, IC_ID_VM_BASE + 0x05) #define ACRN_IOCTL_START_VM \
_IO(ACRN_IOCTL_TYPE, 0x12)
#define ACRN_IOCTL_PAUSE_VM \
_IO(ACRN_IOCTL_TYPE, 0x13)
#define ACRN_IOCTL_RESET_VM \
_IO(ACRN_IOCTL_TYPE, 0x15)
#define IC_SET_VCPU_REGS _IC_ID(IC_ID, IC_ID_VM_BASE + 0x06) #define IC_SET_VCPU_REGS _IC_ID(IC_ID, IC_ID_VM_BASE + 0x06)
/* IRQ and Interrupts */ /* IRQ and Interrupts */

View File

@ -110,7 +110,7 @@ struct acrn_vm *parse_target_vm(struct acrn_vm *sos_vm, uint64_t hcall_id, uint6
{ {
struct acrn_vm *target_vm = NULL; struct acrn_vm *target_vm = NULL;
uint16_t vm_id = ACRN_INVALID_VMID; uint16_t vm_id = ACRN_INVALID_VMID;
struct acrn_create_vm cv; struct acrn_vm_creation cv;
struct set_regions regions; struct set_regions regions;
uint16_t relative_vm_id; uint16_t relative_vm_id;

View File

@ -241,7 +241,7 @@ int32_t hcall_get_platform_info(struct acrn_vcpu *vcpu, __unused struct acrn_vm
* @param vcpu Pointer to vCPU that initiates the hypercall * @param vcpu Pointer to vCPU that initiates the hypercall
* @param target_vm Pointer to target VM data structure * @param target_vm Pointer to target VM data structure
* @param param1 guest physical memory address. This gpa points to * @param param1 guest physical memory address. This gpa points to
* struct acrn_create_vm * struct acrn_vm_creation
* *
* @pre is_sos_vm(vcpu->vm) * @pre is_sos_vm(vcpu->vm)
* @pre get_vm_config(target_vm->vm_id) != NULL * @pre get_vm_config(target_vm->vm_id) != NULL
@ -253,7 +253,7 @@ int32_t hcall_create_vm(struct acrn_vcpu *vcpu, struct acrn_vm *target_vm, uint6
uint16_t vmid = target_vm->vm_id; uint16_t vmid = target_vm->vm_id;
int32_t ret = -1; int32_t ret = -1;
struct acrn_vm *tgt_vm = NULL; struct acrn_vm *tgt_vm = NULL;
struct acrn_create_vm cv; struct acrn_vm_creation cv;
struct acrn_vm_config* vm_config = NULL; struct acrn_vm_config* vm_config = NULL;
if (copy_from_gpa(vm, &cv, param1, sizeof(cv)) == 0) { if (copy_from_gpa(vm, &cv, param1, sizeof(cv)) == 0) {

View File

@ -79,7 +79,7 @@ int32_t hcall_get_platform_info(struct acrn_vcpu *vcpu, struct acrn_vm *target_v
* @param vcpu Pointer to vCPU that initiates the hypercall * @param vcpu Pointer to vCPU that initiates the hypercall
* @param target_vm Pointer to target VM data structure * @param target_vm Pointer to target VM data structure
* @param param1 guest physical memory address. This gpa points to * @param param1 guest physical memory address. This gpa points to
* struct acrn_create_vm * struct acrn_vm_creation
* @param param2 not used * @param param2 not used
* *
* @pre is_sos_vm(vcpu->vm) * @pre is_sos_vm(vcpu->vm)

View File

@ -339,7 +339,7 @@ union vhm_request_buffer {
/** /**
* @brief Info to create a VM, the parameter for HC_CREATE_VM hypercall * @brief Info to create a VM, the parameter for HC_CREATE_VM hypercall
*/ */
struct acrn_create_vm { struct acrn_vm_creation {
/** created vmid return to VHM. Keep it first field */ /** created vmid return to VHM. Keep it first field */
uint16_t vmid; uint16_t vmid;
@ -360,7 +360,7 @@ struct acrn_create_vm {
*/ */
uint64_t vm_flag; uint64_t vm_flag;
uint64_t req_buf; uint64_t ioreq_buf;
/** /**
* The least significant set bit is the PCPU # the VCPU 0 maps to; * The least significant set bit is the PCPU # the VCPU 0 maps to;
@ -368,9 +368,6 @@ struct acrn_create_vm {
* and so on... * and so on...
*/ */
uint64_t cpu_affinity; uint64_t cpu_affinity;
/** Reserved for future use*/
uint8_t reserved2[8];
} __aligned(8); } __aligned(8);
/** /**