提交 eff2b2ed 编写于 作者: M Michal Privoznik

qemu: Rename qemuProcessBuildDestroyHugepagesPath

At the same time, move its internals into a separate function so
that they can be reused.
Signed-off-by: NMichal Privoznik <mprivozn@redhat.com>
Reviewed-by: NJohn Ferlan <jferlan@redhat.com>
上级 d52e6043
...@@ -2077,7 +2077,7 @@ qemuDomainAttachMemory(virQEMUDriverPtr driver, ...@@ -2077,7 +2077,7 @@ 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) if (qemuProcessBuildDestroyMemoryPaths(driver, vm, mem, true) < 0)
goto cleanup; goto cleanup;
if (qemuDomainNamespaceSetupMemory(driver, vm, mem) < 0) if (qemuDomainNamespaceSetupMemory(driver, vm, mem) < 0)
......
...@@ -3324,11 +3324,45 @@ qemuProcessNeedHugepagesPath(virDomainDefPtr def, ...@@ -3324,11 +3324,45 @@ qemuProcessNeedHugepagesPath(virDomainDefPtr def,
} }
static int
qemuProcessBuildDestroyMemoryPathsImpl(virQEMUDriverPtr driver,
virDomainDefPtr def,
const char *path,
bool build)
{
if (build) {
if (virFileExists(path))
return 0;
if (virFileMakePathWithMode(path, 0700) < 0) {
virReportSystemError(errno,
_("Unable to create %s"),
path);
return -1;
}
if (qemuSecurityDomainSetPathLabel(driver->securityManager,
def, path) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
_("Unable to label %s"), path);
return -1;
}
} else {
if (rmdir(path) < 0 &&
errno != ENOENT)
VIR_WARN("Unable to remove hugepage path: %s (errno=%d)",
path, errno);
}
return 0;
}
int int
qemuProcessBuildDestroyHugepagesPath(virQEMUDriverPtr driver, qemuProcessBuildDestroyMemoryPaths(virQEMUDriverPtr driver,
virDomainObjPtr vm, virDomainObjPtr vm,
virDomainMemoryDefPtr mem, virDomainMemoryDefPtr mem,
bool build) bool build)
{ {
virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver);
char *hugepagePath = NULL; char *hugepagePath = NULL;
...@@ -3347,31 +3381,11 @@ qemuProcessBuildDestroyHugepagesPath(virQEMUDriverPtr driver, ...@@ -3347,31 +3381,11 @@ qemuProcessBuildDestroyHugepagesPath(virQEMUDriverPtr driver,
if (!hugepagePath) if (!hugepagePath)
goto cleanup; goto cleanup;
if (build) { if (qemuProcessBuildDestroyMemoryPathsImpl(driver, vm->def,
if (virFileExists(hugepagePath)) { hugepagePath, build) < 0)
ret = 0; goto cleanup;
goto cleanup;
}
if (virFileMakePathWithMode(hugepagePath, 0700) < 0) {
virReportSystemError(errno,
_("Unable to create %s"),
hugepagePath);
goto cleanup;
}
if (qemuSecurityDomainSetPathLabel(driver->securityManager, VIR_FREE(hugepagePath);
vm->def, hugepagePath) < 0) {
virReportError(VIR_ERR_INTERNAL_ERROR,
"%s", _("Unable to set huge path in security driver"));
goto cleanup;
}
} else {
if (rmdir(hugepagePath) < 0 &&
errno != ENOENT)
VIR_WARN("Unable to remove hugepage path: %s (errno=%d)",
hugepagePath, errno);
}
} }
} }
...@@ -5550,7 +5564,7 @@ qemuProcessPrepareHost(virQEMUDriverPtr driver, ...@@ -5550,7 +5564,7 @@ qemuProcessPrepareHost(virQEMUDriverPtr driver,
NULL) < 0) NULL) < 0)
goto cleanup; goto cleanup;
if (qemuProcessBuildDestroyHugepagesPath(driver, vm, NULL, true) < 0) if (qemuProcessBuildDestroyMemoryPaths(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
...@@ -6254,7 +6268,7 @@ void qemuProcessStop(virQEMUDriverPtr driver, ...@@ -6254,7 +6268,7 @@ void qemuProcessStop(virQEMUDriverPtr driver,
goto endjob; goto endjob;
} }
qemuProcessBuildDestroyHugepagesPath(driver, vm, NULL, false); qemuProcessBuildDestroyMemoryPaths(driver, vm, NULL, false);
vm->def->id = -1; vm->def->id = -1;
...@@ -7112,7 +7126,7 @@ qemuProcessReconnect(void *opaque) ...@@ -7112,7 +7126,7 @@ qemuProcessReconnect(void *opaque)
goto cleanup; goto cleanup;
} }
if (qemuProcessBuildDestroyHugepagesPath(driver, obj, NULL, true) < 0) if (qemuProcessBuildDestroyMemoryPaths(driver, obj, NULL, true) < 0)
goto error; goto error;
if ((qemuDomainAssignAddresses(obj->def, priv->qemuCaps, if ((qemuDomainAssignAddresses(obj->def, priv->qemuCaps,
......
...@@ -38,10 +38,10 @@ int qemuProcessStopCPUs(virQEMUDriverPtr driver, ...@@ -38,10 +38,10 @@ int qemuProcessStopCPUs(virQEMUDriverPtr driver,
virDomainPausedReason reason, virDomainPausedReason reason,
qemuDomainAsyncJob asyncJob); qemuDomainAsyncJob asyncJob);
int qemuProcessBuildDestroyHugepagesPath(virQEMUDriverPtr driver, int qemuProcessBuildDestroyMemoryPaths(virQEMUDriverPtr driver,
virDomainObjPtr vm, virDomainObjPtr vm,
virDomainMemoryDefPtr mem, virDomainMemoryDefPtr mem,
bool build); 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.
先完成此消息的编辑!
想要评论请 注册