mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-01-21 20:15:17 +00:00
Create temporary dir for socket
to avoid ENAMETOOLONG: https://buildd.debian.org/status/fetch.php?pkg=libvirt&arch=amd64&ver=1.0.0~rc1-1&stamp=1351453521 (cherry picked from commit 0e7fd31fb52482903ebd34764c065867d26f93b5)
This commit is contained in:
parent
58320848d2
commit
0004a11879
@ -423,10 +423,24 @@ static qemuMonitorCallbacks qemuCallbacks = {
|
||||
|
||||
qemuMonitorTestPtr qemuMonitorTestNew(bool json, virCapsPtr caps)
|
||||
{
|
||||
qemuMonitorTestPtr test;
|
||||
const char *path = abs_builddir "/qemumonitorjsontest.sock";
|
||||
qemuMonitorTestPtr test = NULL;
|
||||
virDomainChrSourceDef src;
|
||||
|
||||
char *tmpdir = NULL, *path = NULL;
|
||||
char template[] = "/tmp/libvirt_XXXXXX";
|
||||
|
||||
tmpdir = mkdtemp(template);
|
||||
if (tmpdir == NULL) {
|
||||
virReportSystemError(errno, "%s",
|
||||
"Failed to create temporary directory");
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (virAsprintf(&path, "%s/qemumonitorjsontest.sock", tmpdir) < 0) {
|
||||
virReportOOMError();
|
||||
goto error;
|
||||
}
|
||||
|
||||
memset(&src, 0, sizeof(src));
|
||||
src.type = VIR_DOMAIN_CHR_TYPE_UNIX;
|
||||
src.data.nix.path = (char *)path;
|
||||
@ -494,11 +508,16 @@ qemuMonitorTestPtr qemuMonitorTestNew(bool json, virCapsPtr caps)
|
||||
test->running = true;
|
||||
virMutexUnlock(&test->lock);
|
||||
|
||||
cleanup:
|
||||
if (tmpdir)
|
||||
if (rmdir(tmpdir) < 0)
|
||||
VIR_WARN("Failed to remove tempdir: %s", strerror(errno));
|
||||
VIR_FREE(path);
|
||||
return test;
|
||||
|
||||
error:
|
||||
qemuMonitorTestFree(test);
|
||||
return NULL;
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
qemuMonitorPtr qemuMonitorTestGetMonitor(qemuMonitorTestPtr test)
|
||||
|
Loading…
x
Reference in New Issue
Block a user