Skip to content

Commit ca32881

Browse files
yakuizhaowenlingz
authored andcommitted
acrn/dm: Add the check of acrn_vhm/acrn_hsm to open the VHM driver
Currently VHM driver is opened by using the device file of /dev/acrn_vhm. But for the upstream purpose it is renamed to /dev/acrn_hsm. So we need to check that the device file is acrn_vhm or acrn_hsm and then open the VHM driver. Tracked-On: #2356 Acked-by: Anthony Xu <anthony.xu@intel.com> Signed-off-by: Zhao Yakui <yakui.zhao@intel.com>
1 parent e4a3a63 commit ca32881

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

devicemodel/core/vmmapi.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
#include <ctype.h>
3838
#include <fcntl.h>
3939
#include <unistd.h>
40-
40+
#include <sys/types.h>
41+
#include <sys/stat.h>
4142

4243

4344
#include "vmmapi.h"
@@ -91,13 +92,20 @@ vm_create(const char *name, uint64_t req_buf)
9192
struct acrn_create_vm create_vm;
9293
int error, retry = 10;
9394
uuid_t vm_uuid;
95+
struct stat tmp_st;
9496

9597
memset(&create_vm, 0, sizeof(struct acrn_create_vm));
9698
ctx = calloc(1, sizeof(struct vmctx) + strnlen(name, PATH_MAX) + 1);
9799
assert(ctx != NULL);
98100
assert(devfd == -1);
99101

100-
devfd = open("/dev/acrn_vhm", O_RDWR|O_CLOEXEC);
102+
if (stat("/dev/acrn_vhm", &tmp_st) == 0) {
103+
devfd = open("/dev/acrn_vhm", O_RDWR|O_CLOEXEC);
104+
} else if (stat("/dev/acrn_hsm", &tmp_st) == 0) {
105+
devfd = open("/dev/acrn_hsm", O_RDWR|O_CLOEXEC);
106+
} else {
107+
devfd = -1;
108+
}
101109
if (devfd == -1) {
102110
fprintf(stderr, "Could not open /dev/acrn_vhm\n");
103111
goto err;

0 commit comments

Comments
 (0)