From: Lin Yang <lin.a.yang@xxxxxxxxx> According to the result parsing from xml, add the argument of SGX EPC memory backend into QEMU command line: -object memory-backend-epc,id=mem1,size=<epc_size>K,prealloc \ -sgx-epc id=epc1,memdev=mem1 --- src/qemu/qemu_command.c | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 01812cd39b..3993f95988 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9424,6 +9424,27 @@ qemuBuildSEVCommandLine(virDomainObjPtr vm, virCommandPtr cmd, return 0; } + +static int +qemuBuildSGXCommandLine(virCommandPtr cmd, virDomainSGXDefPtr sgx) +{ + if (!sgx) + return 0; + + VIR_DEBUG("sgx->epc_size=%lluKiB", sgx->epc_size); + + virCommandAddArg(cmd, "-object"); + virCommandAddArgFormat(cmd, + "memory-backend-epc,id=mem1,size=%lluK,prealloc", + sgx->epc_size); + + virCommandAddArg(cmd, "-sgx-epc"); + virCommandAddArg(cmd, "id=epc1,memdev=mem1"); + + return 0; +} + + static int qemuBuildVMCoreInfoCommandLine(virCommandPtr cmd, const virDomainDef *def) @@ -10114,6 +10135,8 @@ qemuBuildCommandLine(virQEMUDriverPtr driver, if (qemuBuildSEVCommandLine(vm, cmd, def->sev) < 0) return NULL; + if (qemuBuildSGXCommandLine(cmd, def->sgx) < 0) + return NULL; if (snapshot) virCommandAddArgList(cmd, "-loadvm", snapshot->def->name, NULL); -- 2.17.1