mirror of
https://github.com/projectacrn/acrn-hypervisor.git
synced 2025-06-23 14:07:42 +00:00
dm: replace UUID with vmname.
The UUID has several usages before: 1, For HV to identify the static VM configuration of post-launched VM. 2, Seed virtualization. 3, Slightly prevent launching malicous VM from SOS as lack of secure boot. The UUID is confused to user, user don't understand what it is. And user don't know where to get/apply the UUID. The worst experience is user can't launch any VMs w/o re-compile the hv. Everything needs to be static decided in building phase. Now we decide to remove UUID and split each usage. For 1st usage, use vmname as the identifier of static VM configuration. For 2nd one, we will use --vseed as the new parameter. For 3rd one, will pretect by SOS's dm-verity. This patch will remove the UUID parameter and support 1st&3rd usages from DM part. For 2nd usage, another patch will be submitted later. Tracked-On: #6685 Signed-off-by: Yuanyuan Zhao <yuanyuan.zhao@intel.com> Acked-by: Wang, Yu1 <yu1.wang@intel.com>
This commit is contained in:
parent
46f2da7466
commit
5078abc07b
@ -168,8 +168,6 @@ static int unlock_acrn_hugetlb(void)
|
||||
|
||||
static int open_hugetlbfs(struct vmctx *ctx, int level)
|
||||
{
|
||||
char uuid_str[48];
|
||||
uint8_t UUID[16];
|
||||
char *path;
|
||||
size_t len;
|
||||
struct statfs fs;
|
||||
@ -181,27 +179,14 @@ static int open_hugetlbfs(struct vmctx *ctx, int level)
|
||||
|
||||
path = hugetlb_priv[level].node_path;
|
||||
memset(path, '\0', MAX_PATH_LEN);
|
||||
snprintf(path, MAX_PATH_LEN, "%s%s/", hugetlb_priv[level].mount_path, ctx->name);
|
||||
snprintf(path, MAX_PATH_LEN, "%s%s", hugetlb_priv[level].mount_path, ctx->name);
|
||||
|
||||
len = strnlen(path, MAX_PATH_LEN);
|
||||
/* UUID will use 32 bytes */
|
||||
if (len + 32 > MAX_PATH_LEN) {
|
||||
if (len > MAX_PATH_LEN) {
|
||||
pr_err("PATH overflow");
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
uuid_copy(UUID, ctx->vm_uuid);
|
||||
snprintf(uuid_str, sizeof(uuid_str),
|
||||
"%02X%02X%02X%02X%02X%02X%02X%02X"
|
||||
"%02X%02X%02X%02X%02X%02X%02X%02X",
|
||||
UUID[0], UUID[1], UUID[2], UUID[3],
|
||||
UUID[4], UUID[5], UUID[6], UUID[7],
|
||||
UUID[8], UUID[9], UUID[10], UUID[11],
|
||||
UUID[12], UUID[13], UUID[14], UUID[15]);
|
||||
|
||||
*(path + len) = '\0';
|
||||
strncat(path, uuid_str, strnlen(uuid_str, sizeof(uuid_str)));
|
||||
|
||||
pr_info("open hugetlbfs file %s\n", path);
|
||||
|
||||
hugetlb_priv[level].fd = open(path, O_CREAT | O_RDWR, 0644);
|
||||
@ -383,7 +368,7 @@ static int rm_hugetlb_dirs(int level)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
snprintf(path,MAX_PATH_LEN, "%s%s/",hugetlb_priv[level].mount_path,vmname);
|
||||
snprintf(path,MAX_PATH_LEN, "%s/",hugetlb_priv[level].mount_path);
|
||||
|
||||
if (access(path, F_OK) == 0) {
|
||||
if (rmdir(path) < 0) {
|
||||
@ -405,7 +390,7 @@ static int create_hugetlb_dirs(int level)
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
snprintf(path,MAX_PATH_LEN, "%s%s/",hugetlb_priv[level].mount_path,vmname);
|
||||
snprintf(path,MAX_PATH_LEN, "%s/",hugetlb_priv[level].mount_path);
|
||||
|
||||
len = strnlen(path, MAX_PATH_LEN);
|
||||
for (i = 1; i < len; i++) {
|
||||
@ -437,7 +422,7 @@ static int mount_hugetlbfs(int level)
|
||||
if (hugetlb_priv[level].mounted)
|
||||
return 0;
|
||||
|
||||
snprintf(path, MAX_PATH_LEN, "%s%s", hugetlb_priv[level].mount_path,vmname);
|
||||
snprintf(path, MAX_PATH_LEN, "%s", hugetlb_priv[level].mount_path);
|
||||
|
||||
/* only support x86 as HUGETLB level-1 2M page, level-2 1G page*/
|
||||
ret = mount("none", path, "hugetlbfs",
|
||||
@ -457,7 +442,7 @@ static void umount_hugetlbfs(int level)
|
||||
return;
|
||||
}
|
||||
|
||||
snprintf(path, MAX_PATH_LEN, "%s%s", hugetlb_priv[level].mount_path,vmname);
|
||||
snprintf(path, MAX_PATH_LEN, "%s", hugetlb_priv[level].mount_path);
|
||||
|
||||
|
||||
if (hugetlb_priv[level].mounted) {
|
||||
|
@ -81,7 +81,6 @@ typedef void (*vmexit_handler_t)(struct vmctx *,
|
||||
|
||||
char *vmname;
|
||||
|
||||
char *guest_uuid_str;
|
||||
char *vsbl_file_name;
|
||||
char *ovmf_file_name;
|
||||
char *ovmf_code_file_name;
|
||||
@ -145,7 +144,7 @@ usage(int code)
|
||||
"Usage: %s [-hAWYv] [-B bootargs] [-E elf_image_path]\n"
|
||||
" %*s [-G GVT_args] [-i ioc_mediator_parameters] [-k kernel_image_path]\n"
|
||||
" %*s [-l lpc] [-m mem] [-r ramdisk_image_path]\n"
|
||||
" %*s [-s pci] [-U uuid] [--vsbl vsbl_file_name] [--ovmf ovmf_file_path]\n"
|
||||
" %*s [-s pci] [--vsbl vsbl_file_name] [--ovmf ovmf_file_path]\n"
|
||||
" %*s [--part_info part_info_name] [--enable_trusty] [--intr_monitor param_setting]\n"
|
||||
" %*s [--acpidev_pt HID] [--mmiodev_pt MMIO_Regions]\n"
|
||||
" %*s [--vtpm2 sock_path] [--virtio_poll interval] [--mac_seed seed_string]\n"
|
||||
@ -164,7 +163,6 @@ usage(int code)
|
||||
" -m: memory size in MB\n"
|
||||
" -r: ramdisk image path\n"
|
||||
" -s: <slot,driver,configinfo> PCI slot config\n"
|
||||
" -U: uuid\n"
|
||||
" -v: version\n"
|
||||
" -W: force virtio to use single-vector MSI\n"
|
||||
" -Y: disable MPtable generation\n"
|
||||
@ -777,7 +775,6 @@ static struct option long_options[] = {
|
||||
{"lpc", required_argument, 0, 'l' },
|
||||
{"pci_slot", required_argument, 0, 's' },
|
||||
{"memsize", required_argument, 0, 'm' },
|
||||
{"uuid", required_argument, 0, 'U' },
|
||||
{"virtio_msix", no_argument, 0, 'W' },
|
||||
{"mptgen", no_argument, 0, 'Y' },
|
||||
{"kernel", required_argument, 0, 'k' },
|
||||
@ -872,9 +869,6 @@ main(int argc, char *argv[])
|
||||
if (vm_parse_memsize(optarg, &memsize) != 0)
|
||||
errx(EX_USAGE, "invalid memsize '%s'", optarg);
|
||||
break;
|
||||
case 'U':
|
||||
guest_uuid_str = optarg;
|
||||
break;
|
||||
case 'W':
|
||||
virtio_msix = 0;
|
||||
break;
|
||||
@ -1006,12 +1000,15 @@ main(int argc, char *argv[])
|
||||
argc -= optind;
|
||||
argv += optind;
|
||||
|
||||
if (argc != 1)
|
||||
if (argc != 1) {
|
||||
pr_err("You must provide the name of the Virtual Machine (VM) you want to start. Exiting.\n");
|
||||
usage(1);
|
||||
}
|
||||
|
||||
vmname = argv[0];
|
||||
|
||||
if (strnlen(vmname, MAX_VMNAME_LEN) >= MAX_VMNAME_LEN) {
|
||||
pr_err("vmname size exceed %u\n", MAX_VMNAME_LEN);
|
||||
pr_err("The name of the VM exceeds the maximum length: %u\n", MAX_VMNAME_LEN - 1);
|
||||
exit(1);
|
||||
}
|
||||
|
||||
|
@ -167,7 +167,6 @@ vm_create(const char *name, uint64_t req_buf, int *vcpu_num)
|
||||
struct vmctx *ctx;
|
||||
struct acrn_vm_creation create_vm;
|
||||
int error, retry = 10;
|
||||
uuid_t vm_uuid;
|
||||
struct stat tmp_st;
|
||||
|
||||
memset(&create_vm, 0, sizeof(struct acrn_vm_creation));
|
||||
@ -187,19 +186,6 @@ vm_create(const char *name, uint64_t req_buf, int *vcpu_num)
|
||||
goto err;
|
||||
}
|
||||
|
||||
if (guest_uuid_str == NULL)
|
||||
guest_uuid_str = "d2795438-25d6-11e8-864e-cb7a18b34643";
|
||||
|
||||
error = uuid_parse(guest_uuid_str, vm_uuid);
|
||||
if (error != 0)
|
||||
goto err;
|
||||
|
||||
/* save vm uuid to ctx */
|
||||
uuid_copy(ctx->vm_uuid, vm_uuid);
|
||||
|
||||
/* Pass uuid as parameter of create vm*/
|
||||
uuid_copy(create_vm.uuid, vm_uuid);
|
||||
|
||||
ctx->gvt_enabled = false;
|
||||
ctx->fd = devfd;
|
||||
ctx->lowmem_limit = PCI_EMUL_MEMBASE32;
|
||||
@ -224,6 +210,7 @@ vm_create(const char *name, uint64_t req_buf, int *vcpu_num)
|
||||
|
||||
/* command line arguments specified CPU affinity could overwrite HV's static configuration */
|
||||
create_vm.cpu_affinity = cpu_affinity_bitmap;
|
||||
strncpy((char *)create_vm.name, name, strnlen(name, MAX_VMNAME_LEN));
|
||||
|
||||
if (is_rtvm) {
|
||||
create_vm.vm_flag |= GUEST_FLAG_RT;
|
||||
@ -711,7 +698,7 @@ vm_get_config(struct vmctx *ctx, struct acrn_vm_config_header *vm_cfg, struct ac
|
||||
|
||||
for (i = 0; i < platform_info.sw.max_vms; i++) {
|
||||
pcfg = (struct acrn_vm_config_header *)(configs_buff + (i * platform_info.sw.vm_config_size));
|
||||
if (!uuid_compare(ctx->vm_uuid, pcfg->uuid))
|
||||
if (!strncmp(ctx->name, pcfg->name, strnlen(ctx->name, MAX_VMNAME_LEN)))
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -33,10 +33,9 @@
|
||||
#include "types.h"
|
||||
#include "dm_string.h"
|
||||
|
||||
#define MAX_VMNAME_LEN 128U
|
||||
#define MAX_VMNAME_LEN 16U
|
||||
|
||||
struct vmctx;
|
||||
extern char *guest_uuid_str;
|
||||
extern uint8_t trusty_enabled;
|
||||
extern char *vsbl_file_name;
|
||||
extern char *ovmf_file_name;
|
||||
|
@ -57,7 +57,6 @@ struct vmctx {
|
||||
size_t highmem;
|
||||
char *baseaddr;
|
||||
char *name;
|
||||
uuid_t vm_uuid;
|
||||
|
||||
/* fields to track virtual devices */
|
||||
void *atkbdc_base;
|
||||
|
Loading…
Reference in New Issue
Block a user