mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-12-22 17:34:18 +03:00
Revert "tests: Use qemu:///embed to simplify fakerootdir management"
Turns out that it's not enough to pass the qemu:///embed root to
virQEMUDriverConfigNew(), you also have to make sure the same
string is copied into the virQEMUDriver structure yourself, and
not doing so in our case resulted in the cleanup never happening
and in distcheck failing because of that.
On the other hand, actually setting config->embeddedRoot would
result in different paths being generated for each test run, which
would obviously break qemuxml2argvtest, so that's not an option
either.
This reverts commit d98cc1968e
.
Signed-off-by: Andrea Bolognani <abologna@redhat.com>
This commit is contained in:
parent
d98cc1968e
commit
2e93af279a
@ -594,6 +594,8 @@ testQemuHotplugCpuIndividual(const void *opaque)
|
||||
return ret;
|
||||
}
|
||||
|
||||
#define FAKEROOTDIRTEMPLATE abs_builddir "/fakerootdir-XXXXXX"
|
||||
|
||||
|
||||
static int
|
||||
mymain(void)
|
||||
@ -602,8 +604,18 @@ mymain(void)
|
||||
int ret = 0;
|
||||
struct qemuHotplugTestData data = {0};
|
||||
struct testQemuHotplugCpuParams cpudata;
|
||||
g_autofree char *fakerootdir = NULL;
|
||||
g_autoptr(virQEMUDriverConfig) cfg = NULL;
|
||||
|
||||
fakerootdir = g_strdup(FAKEROOTDIRTEMPLATE);
|
||||
|
||||
if (!g_mkdtemp(fakerootdir)) {
|
||||
fprintf(stderr, "Cannot create fakerootdir");
|
||||
abort();
|
||||
}
|
||||
|
||||
g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, TRUE);
|
||||
|
||||
if (qemuTestDriverInit(&driver) < 0)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
@ -879,6 +891,9 @@ mymain(void)
|
||||
DO_TEST_CPU_INDIVIDUAL("ppc64-modern-individual", "16-22", true, true, true);
|
||||
DO_TEST_CPU_INDIVIDUAL("ppc64-modern-individual", "17", true, true, true);
|
||||
|
||||
if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
|
||||
virFileDeleteTree(fakerootdir);
|
||||
|
||||
qemuTestDriverFree(&driver);
|
||||
virObjectUnref(data.vm);
|
||||
return (ret == 0) ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
|
@ -51,14 +51,28 @@ testCompareMemLock(const void *data)
|
||||
return ret;
|
||||
}
|
||||
|
||||
# define FAKEROOTDIRTEMPLATE abs_builddir "/fakerootdir-XXXXXX"
|
||||
|
||||
static int
|
||||
mymain(void)
|
||||
{
|
||||
int ret = 0;
|
||||
char *fakerootdir;
|
||||
virQEMUCapsPtr qemuCaps = NULL;
|
||||
|
||||
if (qemuTestDriverInit(&driver) < 0)
|
||||
fakerootdir = g_strdup(FAKEROOTDIRTEMPLATE);
|
||||
|
||||
if (!g_mkdtemp(fakerootdir)) {
|
||||
fprintf(stderr, "Cannot create fakerootdir");
|
||||
abort();
|
||||
}
|
||||
|
||||
g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, TRUE);
|
||||
|
||||
if (qemuTestDriverInit(&driver) < 0) {
|
||||
VIR_FREE(fakerootdir);
|
||||
return EXIT_FAILURE;
|
||||
}
|
||||
|
||||
driver.privileged = true;
|
||||
|
||||
@ -136,7 +150,11 @@ mymain(void)
|
||||
cleanup:
|
||||
virObjectUnref(qemuCaps);
|
||||
|
||||
if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
|
||||
virFileDeleteTree(fakerootdir);
|
||||
|
||||
qemuTestDriverFree(&driver);
|
||||
VIR_FREE(fakerootdir);
|
||||
|
||||
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
}
|
||||
|
@ -609,12 +609,24 @@ testInfoSetPaths(struct testQemuInfo *info,
|
||||
abs_srcdir, info->name, suffix ? suffix : "");
|
||||
}
|
||||
|
||||
# define FAKEROOTDIRTEMPLATE abs_builddir "/fakerootdir-XXXXXX"
|
||||
|
||||
static int
|
||||
mymain(void)
|
||||
{
|
||||
int ret = 0;
|
||||
char *fakerootdir;
|
||||
virHashTablePtr capslatest = NULL;
|
||||
|
||||
fakerootdir = g_strdup(FAKEROOTDIRTEMPLATE);
|
||||
|
||||
if (!g_mkdtemp(fakerootdir)) {
|
||||
fprintf(stderr, "Cannot create fakerootdir");
|
||||
abort();
|
||||
}
|
||||
|
||||
g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, TRUE);
|
||||
|
||||
/* Set the timezone because we are mocking the time() function.
|
||||
* If we don't do that, then localtime() may return unpredictable
|
||||
* results. In order to detect things that just work by a blind
|
||||
@ -3220,8 +3232,12 @@ mymain(void)
|
||||
|
||||
DO_TEST_CAPS_LATEST("virtio-9p-multidevs");
|
||||
|
||||
if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
|
||||
virFileDeleteTree(fakerootdir);
|
||||
|
||||
VIR_FREE(driver.config->nbdTLSx509certdir);
|
||||
qemuTestDriverFree(&driver);
|
||||
VIR_FREE(fakerootdir);
|
||||
virHashFree(capslatest);
|
||||
virFileWrapperClearPrefixes();
|
||||
|
||||
|
@ -126,10 +126,13 @@ testInfoSetStatusPaths(struct testQemuInfo *info)
|
||||
}
|
||||
|
||||
|
||||
# define FAKEROOTDIRTEMPLATE abs_builddir "/fakerootdir-XXXXXX"
|
||||
|
||||
static int
|
||||
mymain(void)
|
||||
{
|
||||
int ret = 0;
|
||||
char *fakerootdir;
|
||||
virQEMUDriverConfigPtr cfg = NULL;
|
||||
virHashTablePtr capslatest = NULL;
|
||||
|
||||
@ -137,6 +140,15 @@ mymain(void)
|
||||
if (!capslatest)
|
||||
return EXIT_FAILURE;
|
||||
|
||||
fakerootdir = g_strdup(FAKEROOTDIRTEMPLATE);
|
||||
|
||||
if (!g_mkdtemp(fakerootdir)) {
|
||||
fprintf(stderr, "Cannot create fakerootdir");
|
||||
abort();
|
||||
}
|
||||
|
||||
g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, TRUE);
|
||||
|
||||
/* Required for tpm-emulator tests
|
||||
*/
|
||||
virFileWrapperAddPrefix(SYSCONFDIR "/qemu/firmware",
|
||||
@ -1466,8 +1478,12 @@ mymain(void)
|
||||
|
||||
DO_TEST_CAPS_LATEST("virtio-9p-multidevs");
|
||||
|
||||
if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
|
||||
virFileDeleteTree(fakerootdir);
|
||||
|
||||
virHashFree(capslatest);
|
||||
qemuTestDriverFree(&driver);
|
||||
VIR_FREE(fakerootdir);
|
||||
virFileWrapperClearPrefixes();
|
||||
|
||||
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
||||
|
@ -307,10 +307,11 @@ qemuTestParseCapabilitiesArch(virArch arch,
|
||||
|
||||
void qemuTestDriverFree(virQEMUDriver *driver)
|
||||
{
|
||||
if (g_getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
|
||||
virFileDeleteTree(driver->embeddedRoot);
|
||||
|
||||
virMutexDestroy(&driver->lock);
|
||||
if (driver->config) {
|
||||
virFileDeleteTree(driver->config->stateDir);
|
||||
virFileDeleteTree(driver->config->configDir);
|
||||
}
|
||||
virObjectUnref(driver->qemuCapsCache);
|
||||
virObjectUnref(driver->xmlopt);
|
||||
virObjectUnref(driver->caps);
|
||||
@ -369,21 +370,14 @@ int qemuTestCapsCacheInsert(virFileCachePtr cache,
|
||||
}
|
||||
|
||||
|
||||
# define FAKEROOTDIRTEMPLATE abs_builddir "/fakerootdir-XXXXXX"
|
||||
# define STATEDIRTEMPLATE abs_builddir "/qemustatedir-XXXXXX"
|
||||
# define CONFIGDIRTEMPLATE abs_builddir "/qemuconfigdir-XXXXXX"
|
||||
|
||||
int qemuTestDriverInit(virQEMUDriver *driver)
|
||||
{
|
||||
virSecurityManagerPtr mgr = NULL;
|
||||
g_autofree char *fakerootdir = NULL;
|
||||
|
||||
fakerootdir = g_strdup(FAKEROOTDIRTEMPLATE);
|
||||
|
||||
if (!g_mkdtemp(fakerootdir)) {
|
||||
fprintf(stderr, "Cannot create fakerootdir");
|
||||
abort();
|
||||
}
|
||||
|
||||
g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, TRUE);
|
||||
char statedir[] = STATEDIRTEMPLATE;
|
||||
char configdir[] = CONFIGDIRTEMPLATE;
|
||||
|
||||
memset(driver, 0, sizeof(*driver));
|
||||
|
||||
@ -397,16 +391,35 @@ int qemuTestDriverInit(virQEMUDriver *driver)
|
||||
return -1;
|
||||
|
||||
driver->hostarch = virArchFromHost();
|
||||
driver->config = virQEMUDriverConfigNew(false, fakerootdir);
|
||||
driver->config = virQEMUDriverConfigNew(false, NULL);
|
||||
if (!driver->config)
|
||||
goto error;
|
||||
|
||||
/* Do this early so that qemuTestDriverFree() doesn't see (unlink) the real
|
||||
* dirs. */
|
||||
VIR_FREE(driver->config->stateDir);
|
||||
VIR_FREE(driver->config->configDir);
|
||||
|
||||
/* Overwrite some default paths so it's consistent for tests. */
|
||||
VIR_FREE(driver->config->libDir);
|
||||
VIR_FREE(driver->config->channelTargetDir);
|
||||
driver->config->libDir = g_strdup("/tmp/lib");
|
||||
driver->config->channelTargetDir = g_strdup("/tmp/channel");
|
||||
|
||||
if (!g_mkdtemp(statedir)) {
|
||||
fprintf(stderr, "Cannot create fake stateDir");
|
||||
goto error;
|
||||
}
|
||||
|
||||
driver->config->stateDir = g_strdup(statedir);
|
||||
|
||||
if (!g_mkdtemp(configdir)) {
|
||||
fprintf(stderr, "Cannot create fake configDir");
|
||||
goto error;
|
||||
}
|
||||
|
||||
driver->config->configDir = g_strdup(configdir);
|
||||
|
||||
driver->caps = testQemuCapsInit();
|
||||
if (!driver->caps)
|
||||
goto error;
|
||||
|
Loading…
Reference in New Issue
Block a user