From a87fa12895ce284f6a1c7efbc8edec148360c667 Mon Sep 17 00:00:00 2001 From: Mingqiang Chi Date: Tue, 16 Nov 2021 16:01:42 +0800 Subject: [PATCH] dm: use MAX_VM_NAME_LEN instead of MAX_VMNAME_LEN use the common MAX_VM_NAME_LEN to keep sync with hypervisor. Tracked-On: #6685 Signed-off-by: Mingqiang Chi --- devicemodel/core/main.c | 4 ++-- devicemodel/core/vmmapi.c | 2 +- devicemodel/hw/platform/ioc.c | 2 +- devicemodel/include/dm.h | 3 +-- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/devicemodel/core/main.c b/devicemodel/core/main.c index 3f3fbcb86..3f34c1cbc 100644 --- a/devicemodel/core/main.c +++ b/devicemodel/core/main.c @@ -1007,8 +1007,8 @@ main(int argc, char *argv[]) vmname = argv[0]; - if (strnlen(vmname, MAX_VMNAME_LEN) >= MAX_VMNAME_LEN) { - pr_err("The name of the VM exceeds the maximum length: %u\n", MAX_VMNAME_LEN - 1); + if (strnlen(vmname, MAX_VM_NAME_LEN) >= MAX_VM_NAME_LEN) { + pr_err("The name of the VM exceeds the maximum length: %u\n", MAX_VM_NAME_LEN - 1); exit(1); } diff --git a/devicemodel/core/vmmapi.c b/devicemodel/core/vmmapi.c index aae7e8ae9..aa02e7fcf 100644 --- a/devicemodel/core/vmmapi.c +++ b/devicemodel/core/vmmapi.c @@ -210,7 +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)); + strncpy((char *)create_vm.name, name, strnlen(name, MAX_VM_NAME_LEN)); if (is_rtvm) { create_vm.vm_flag |= GUEST_FLAG_RT; diff --git a/devicemodel/hw/platform/ioc.c b/devicemodel/hw/platform/ioc.c index 93dd4454a..c962a2e6b 100644 --- a/devicemodel/hw/platform/ioc.c +++ b/devicemodel/hw/platform/ioc.c @@ -91,7 +91,7 @@ typedef void* (*ioc_work)(void *arg); * IOC mediator and virtual UART communication channel path, * comes from DM command line parameters. */ -static char virtual_uart_path[32 + MAX_VMNAME_LEN]; +static char virtual_uart_path[32 + MAX_VM_NAME_LEN]; /* * To activate CBC signal channel(/dev/cbc-signals). diff --git a/devicemodel/include/dm.h b/devicemodel/include/dm.h index ea3499b9b..c8bfb9168 100644 --- a/devicemodel/include/dm.h +++ b/devicemodel/include/dm.h @@ -32,8 +32,7 @@ #include #include "types.h" #include "dm_string.h" - -#define MAX_VMNAME_LEN 16U +#include "acrn_common.h" struct vmctx; extern uint8_t trusty_enabled;