hv: remove UUID

With current arch design the UUID is used to identify ACRN VMs,
all VM configurations must be deployed with given UUIDs at build time.
For post-launched VMs, end user must use UUID as acrn-dm parameter
to launch specified user VM. This is not friendly for end users
that they have to look up the pre-configured UUID before launching VM,
and then can only launch the VM which its UUID in the pre-configured UUID
list,otherwise the launch will fail.Another side, VM name is much straight
forward for end user to identify VMs, whereas the VM name defined
in launch script has not been passed to hypervisor VM configuration
so it is not consistent with the VM name when user list VM
in hypervisor shell, this would confuse user a lot.

This patch will resolve these issues by removing UUID as VM identifier
and use VM name instead:
1. Hypervisor will check the VM name duplication during VM creation time
   to make sure the VM name is unique.
2. If the VM name passed from acrn-dm matches one of pre-configured
   VM configurations, the corresponding VM will be launched,
   we call it static configured VM.
   If there is no matching found, hypervisor will try to allocate one
   unused VM configuration slot for this VM with given VM name and get it
   run if VM number does not reach CONFIG_MAX_VM_NUM,
   we will call it dynamic configured VM.
3. For dynamic configured VMs, we need a guest flag to identify them
   because the VM configuration need to be destroyed
   when it is shutdown or creation failed.

v7->v8:
    -- rename is_static_vm_configured to is_static_configured_vm
    -- only set DM owned guest_flags in hcall_create_vm
    -- add check dynamic flag in get_unused_vmid

v6->v7:
    -- refine get_vmid_by_name, return the first matching vm_id
    -- the GUEST_FLAG_STATIC_VM is added to identify the static or
       dynamic VM, the offline tool will set this flag for
       all the pre-defined VMs.
    -- only clear name field for dynamic VM instead of clear entire
       vm_config

Tracked-On: #6685
Signed-off-by: Mingqiang Chi <mingqiang.chi@intel.com>
Reviewed-by: Zhao Yakui <yakui.zhao@intel.com>
Reviewed-by: Victor Sun<victor.sun@intel.com>
Acked-by: Eddie Dong <eddie.dong@intel.com>
This commit is contained in:
Mingqiang Chi
2021-11-02 23:03:40 +08:00
committed by wenlingz
parent ba9f339f2e
commit bb0327e700
12 changed files with 102 additions and 114 deletions

View File

@@ -156,7 +156,7 @@ struct acrn_vm {
struct vm_io_handler_desc emul_pio[EMUL_PIO_IDX_MAX];
uint8_t uuid[16];
char name[MAX_VM_NAME_LEN];
struct secure_world_control sworld_control;
/* Secure World's snapshot
@@ -241,7 +241,7 @@ bool is_paused_vm(const struct acrn_vm *vm);
bool is_service_vm(const struct acrn_vm *vm);
bool is_postlaunched_vm(const struct acrn_vm *vm);
bool is_prelaunched_vm(const struct acrn_vm *vm);
uint16_t get_vmid_by_uuid(const uint8_t *uuid);
uint16_t get_vmid_by_name(const char *name);
struct acrn_vm *get_vm_from_vmid(uint16_t vm_id);
struct acrn_vm *get_service_vm(void);
@@ -257,6 +257,8 @@ bool is_lapic_pt_configured(const struct acrn_vm *vm);
bool is_rt_vm(const struct acrn_vm *vm);
bool is_nvmx_configured(const struct acrn_vm *vm);
bool is_vcat_configured(const struct acrn_vm *vm);
bool is_static_configured_vm(const struct acrn_vm *vm);
uint16_t get_unused_vmid(void);
bool is_pi_capable(const struct acrn_vm *vm);
bool has_rt_vm(void);
struct acrn_vm *get_highest_severity_vm(bool runtime);

View File

@@ -12,13 +12,10 @@
#include <board_info.h>
#include <boot.h>
#include <acrn_common.h>
#include <vm_uuids.h>
#include <vm_configurations.h>
#include <asm/sgx.h>
#include <acrn_hv_defs.h>
#define CONFIG_MAX_VM_NUM (PRE_VM_NUM + SERVICE_VM_NUM + MAX_POST_VM_NUM)
#define AFFINITY_CPU(n) (1UL << (n))
#define MAX_VCPUS_PER_VM MAX_PCPU_NUM
#define MAX_VUART_NUM_PER_VM 8U
@@ -38,31 +35,24 @@
#define MAX_MMIO_DEV_NUM 2U
#define CONFIG_SERVICE_VM .load_order = SERVICE_VM, \
.uuid = SERVICE_VM_UUID, \
.severity = SEVERITY_SERVICE_VM
#define CONFIG_SAFETY_VM(idx) .load_order = PRE_LAUNCHED_VM, \
.uuid = SAFETY_VM_UUID##idx, \
#define CONFIG_SAFETY_VM .load_order = PRE_LAUNCHED_VM, \
.severity = SEVERITY_SAFETY_VM
#define CONFIG_PRE_STD_VM(idx) .load_order = PRE_LAUNCHED_VM, \
.uuid = PRE_STANDARD_VM_UUID##idx, \
#define CONFIG_PRE_STD_VM .load_order = PRE_LAUNCHED_VM, \
.severity = SEVERITY_STANDARD_VM
#define CONFIG_PRE_RT_VM(idx) .load_order = PRE_LAUNCHED_VM, \
.uuid = PRE_RTVM_UUID##idx, \
#define CONFIG_PRE_RT_VM .load_order = PRE_LAUNCHED_VM, \
.severity = SEVERITY_RTVM
#define CONFIG_POST_STD_VM(idx) .load_order = POST_LAUNCHED_VM, \
.uuid = POST_STANDARD_VM_UUID##idx, \
#define CONFIG_POST_STD_VM .load_order = POST_LAUNCHED_VM, \
.severity = SEVERITY_STANDARD_VM
#define CONFIG_POST_RT_VM(idx) .load_order = POST_LAUNCHED_VM, \
.uuid = POST_RTVM_UUID##idx, \
#define CONFIG_POST_RT_VM .load_order = POST_LAUNCHED_VM, \
.severity = SEVERITY_RTVM
#define CONFIG_KATA_VM(idx) .load_order = POST_LAUNCHED_VM, \
.uuid = KATA_VM_UUID##idx, \
#define CONFIG_KATA_VM .load_order = POST_LAUNCHED_VM, \
.severity = SEVERITY_STANDARD_VM
/* ACRN guest severity */
@@ -154,8 +144,7 @@ struct pt_intx_config {
struct acrn_vm_config {
enum acrn_vm_load_order load_order; /* specify the load order of VM */
char name[MAX_VM_OS_NAME_LEN]; /* VM name identifier, useful for debug. */
const uint8_t uuid[16]; /* UUID of the VM */
char name[MAX_VM_NAME_LEN]; /* VM name identifier */
uint8_t reserved[2]; /* Temporarily reserve it so that don't need to update
* the users of get_platform_info frequently.
*/
@@ -214,7 +203,7 @@ struct acrn_vm_config {
struct acrn_vm_config *get_vm_config(uint16_t vm_id);
uint8_t get_vm_severity(uint16_t vm_id);
bool vm_has_matched_uuid(uint16_t vmid, const uint8_t *uuid);
bool vm_has_matched_name(uint16_t vmid, const char *name);
extern struct acrn_vm_config vm_configs[CONFIG_MAX_VM_NUM];