diff --git a/devicemodel/core/hugetlb.c b/devicemodel/core/hugetlb.c index 72f735686..7f23e4fe1 100644 --- a/devicemodel/core/hugetlb.c +++ b/devicemodel/core/hugetlb.c @@ -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) { diff --git a/devicemodel/core/main.c b/devicemodel/core/main.c index 60d4c72a9..f88cad144 100644 --- a/devicemodel/core/main.c +++ b/devicemodel/core/main.c @@ -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: 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); } diff --git a/devicemodel/core/vmmapi.c b/devicemodel/core/vmmapi.c index 38507a993..75ae76aa1 100644 --- a/devicemodel/core/vmmapi.c +++ b/devicemodel/core/vmmapi.c @@ -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; } diff --git a/devicemodel/include/dm.h b/devicemodel/include/dm.h index 1d28e1b90..ea3499b9b 100644 --- a/devicemodel/include/dm.h +++ b/devicemodel/include/dm.h @@ -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; diff --git a/devicemodel/include/vmmapi.h b/devicemodel/include/vmmapi.h index c8dab4f52..523c2ef10 100644 --- a/devicemodel/include/vmmapi.h +++ b/devicemodel/include/vmmapi.h @@ -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;