提交 5b24d250 编写于 作者: M Michal Privoznik

qemuDomainAttachMemory: Crate hugepage dir if needed

https://bugzilla.redhat.com/show_bug.cgi?id=1455819

It may happen that a domain is started without any huge pages.
However, user might try to attach a DIMM module later. DIMM
backed by huge pages (why would somebody want to mix regular and
huge pages is beyond me). Therefore we have to create the dir if
we haven't done so far.
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
上级 055c7c48
...@@ -2258,6 +2258,9 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver, ...@@ -2258,6 +2258,9 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver,
priv->qemuCaps, vm->def, mem, NULL, true) < 0) priv->qemuCaps, vm->def, mem, NULL, true) < 0)
goto cleanup; goto cleanup;
if (qemuProcessBuildDestroyHugepagesPath(driver, vm, mem, true) < 0)
goto cleanup;
if (qemuDomainNamespaceSetupMemory(driver, vm, mem) < 0) if (qemuDomainNamespaceSetupMemory(driver, vm, mem) < 0)
goto cleanup; goto cleanup;
teardowndevice = true; teardowndevice = true;
......
...@@ -3284,7 +3284,8 @@ qemuProcessReconnectCheckMemAliasOrderMismatch(virDomainObjPtr vm) ...@@ -3284,7 +3284,8 @@ qemuProcessReconnectCheckMemAliasOrderMismatch(virDomainObjPtr vm)
static bool static bool
qemuProcessNeedHugepagesPath(virDomainDefPtr def) qemuProcessNeedHugepagesPath(virDomainDefPtr def,
virDomainMemoryDefPtr mem)
{ {
const long system_pagesize = virGetSystemPageSizeKB(); const long system_pagesize = virGetSystemPageSizeKB();
size_t i; size_t i;
...@@ -3304,13 +3305,20 @@ qemuProcessNeedHugepagesPath(virDomainDefPtr def) ...@@ -3304,13 +3305,20 @@ qemuProcessNeedHugepagesPath(virDomainDefPtr def)
return true; return true;
} }
if (mem &&
mem->model == VIR_DOMAIN_MEMORY_MODEL_DIMM &&
mem->pagesize &&
mem->pagesize != system_pagesize)
return true;
return false; return false;
} }
static int int
qemuProcessBuildDestroyHugepagesPath(virQEMUDriverPtr driver, qemuProcessBuildDestroyHugepagesPath(virQEMUDriverPtr driver,
virDomainObjPtr vm, virDomainObjPtr vm,
virDomainMemoryDefPtr mem,
bool build) bool build)
{ {
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
...@@ -3320,7 +3328,7 @@ qemuProcessBuildDestroyHugepagesPath(virQEMUDriverPtr driver, ...@@ -3320,7 +3328,7 @@ qemuProcessBuildDestroyHugepagesPath(virQEMUDriverPtr driver,
int ret = -1; int ret = -1;
if (build) if (build)
shouldBuild = qemuProcessNeedHugepagesPath(vm->def); shouldBuild = qemuProcessNeedHugepagesPath(vm->def, mem);
if (!build || shouldBuild) { if (!build || shouldBuild) {
for (i = 0; i < cfg->nhugetlbfs; i++) { for (i = 0; i < cfg->nhugetlbfs; i++) {
...@@ -3331,6 +3339,11 @@ qemuProcessBuildDestroyHugepagesPath(virQEMUDriverPtr driver, ...@@ -3331,6 +3339,11 @@ qemuProcessBuildDestroyHugepagesPath(virQEMUDriverPtr driver,
goto cleanup; goto cleanup;
if (build) { if (build) {
if (virFileExists(hugepagePath)) {
ret = 0;
goto cleanup;
}
if (virFileMakePathWithMode(hugepagePath, 0700) < 0) { if (virFileMakePathWithMode(hugepagePath, 0700) < 0) {
virReportSystemError(errno, virReportSystemError(errno,
_("Unable to create %s"), _("Unable to create %s"),
...@@ -3504,7 +3517,7 @@ qemuProcessReconnect(void *opaque) ...@@ -3504,7 +3517,7 @@ qemuProcessReconnect(void *opaque)
goto cleanup; goto cleanup;
} }
if (qemuProcessBuildDestroyHugepagesPath(driver, obj, true) < 0) if (qemuProcessBuildDestroyHugepagesPath(driver, obj, NULL, true) < 0)
goto error; goto error;
if ((qemuDomainAssignAddresses(obj->def, priv->qemuCaps, if ((qemuDomainAssignAddresses(obj->def, priv->qemuCaps,
...@@ -5572,7 +5585,7 @@ qemuProcessPrepareHost(virQEMUDriverPtr driver, ...@@ -5572,7 +5585,7 @@ qemuProcessPrepareHost(virQEMUDriverPtr driver,
NULL) < 0) NULL) < 0)
goto cleanup; goto cleanup;
if (qemuProcessBuildDestroyHugepagesPath(driver, vm, true) < 0) if (qemuProcessBuildDestroyHugepagesPath(driver, vm, NULL, true) < 0)
goto cleanup; goto cleanup;
/* Ensure no historical cgroup for this VM is lying around bogus /* Ensure no historical cgroup for this VM is lying around bogus
...@@ -6259,7 +6272,7 @@ void qemuProcessStop(virQEMUDriverPtr driver, ...@@ -6259,7 +6272,7 @@ void qemuProcessStop(virQEMUDriverPtr driver,
goto endjob; goto endjob;
} }
qemuProcessBuildDestroyHugepagesPath(driver, vm, false); qemuProcessBuildDestroyHugepagesPath(driver, vm, NULL, false);
vm->def->id = -1; vm->def->id = -1;
......
...@@ -38,6 +38,11 @@ int qemuProcessStopCPUs(virQEMUDriverPtr driver, ...@@ -38,6 +38,11 @@ int qemuProcessStopCPUs(virQEMUDriverPtr driver,
virDomainPausedReason reason, virDomainPausedReason reason,
qemuDomainAsyncJob asyncJob); qemuDomainAsyncJob asyncJob);
int qemuProcessBuildDestroyHugepagesPath(virQEMUDriverPtr driver,
virDomainObjPtr vm,
virDomainMemoryDefPtr mem,
bool build);
void qemuProcessAutostartAll(virQEMUDriverPtr driver); void qemuProcessAutostartAll(virQEMUDriverPtr driver);
void qemuProcessReconnectAll(virConnectPtr conn, virQEMUDriverPtr driver); void qemuProcessReconnectAll(virConnectPtr conn, virQEMUDriverPtr driver);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册