From 3775f29e3cfdc58d86724235a39f28caa85cf864 Mon Sep 17 00:00:00 2001 From: Yin Fengwei Date: Fri, 9 Mar 2018 13:33:41 +0800 Subject: [PATCH] vm: Pass uuid from DM commandline to vm as GUID. Also save the uuid to ctx in case DM needs to access the uuid. Signed-off-by: Yin Fengwei --- devicemodel/core/vmmapi.c | 17 +++++++++++++++++ devicemodel/include/vmmapi.h | 2 ++ 2 files changed, 19 insertions(+) diff --git a/devicemodel/core/vmmapi.c b/devicemodel/core/vmmapi.c index 03b9755b1..068f92907 100644 --- a/devicemodel/core/vmmapi.c +++ b/devicemodel/core/vmmapi.c @@ -43,6 +43,7 @@ #include #include #include +#include #include "types.h" #include "cpuset.h" @@ -55,6 +56,8 @@ #include "vmmapi.h" #include "mevent.h" +#include "dm.h" + #define MB (1024 * 1024UL) #define GB (1024 * 1024 * 1024UL) @@ -113,6 +116,7 @@ vm_open(const char *name) struct vmctx *ctx; struct acrn_create_vm create_vm; int error, retry = 10; + uuid_t vm_uuid; ctx = malloc(sizeof(struct vmctx) + strlen(name) + 1); assert(ctx != NULL); @@ -127,6 +131,19 @@ vm_open(const char *name) if (check_api(devfd) < 0) 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.GUID, vm_uuid); + ctx->fd = devfd; ctx->memflags = 0; ctx->lowmem_limit = 2 * GB; diff --git a/devicemodel/include/vmmapi.h b/devicemodel/include/vmmapi.h index a43cd3e5f..a8d274d81 100644 --- a/devicemodel/include/vmmapi.h +++ b/devicemodel/include/vmmapi.h @@ -30,6 +30,7 @@ #define _VMMAPI_H_ #include +#include #include "types.h" #include "vmm.h" @@ -52,6 +53,7 @@ struct vmctx { char *mmap_highmem; char *baseaddr; char *name; + uuid_t vm_uuid; }; /*