mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-09-09 09:14:57 +00:00
tests: Add convenience variable for QEMU driver config
This makes the code less clunky. Signed-off-by: Andrea Bolognani <abologna@redhat.com> Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
This commit is contained in:
parent
0f49b6cc6b
commit
98a6618d07
@ -612,6 +612,7 @@ qemuTestCapsCacheInsertMacOS(virFileCache *cache,
|
|||||||
|
|
||||||
int qemuTestDriverInit(virQEMUDriver *driver)
|
int qemuTestDriverInit(virQEMUDriver *driver)
|
||||||
{
|
{
|
||||||
|
virQEMUDriverConfig *cfg = NULL;
|
||||||
virSecurityManager *mgr = NULL;
|
virSecurityManager *mgr = NULL;
|
||||||
char statedir[] = STATEDIRTEMPLATE;
|
char statedir[] = STATEDIRTEMPLATE;
|
||||||
char configdir[] = CONFIGDIRTEMPLATE;
|
char configdir[] = CONFIGDIRTEMPLATE;
|
||||||
@ -629,34 +630,36 @@ int qemuTestDriverInit(virQEMUDriver *driver)
|
|||||||
return -1;
|
return -1;
|
||||||
|
|
||||||
driver->hostarch = virArchFromHost();
|
driver->hostarch = virArchFromHost();
|
||||||
driver->config = virQEMUDriverConfigNew(true, NULL);
|
|
||||||
if (!driver->config)
|
cfg = virQEMUDriverConfigNew(true, NULL);
|
||||||
|
if (!cfg)
|
||||||
goto error;
|
goto error;
|
||||||
|
driver->config = cfg;
|
||||||
|
|
||||||
/* Do this early so that qemuTestDriverFree() doesn't see (unlink) the real
|
/* Do this early so that qemuTestDriverFree() doesn't see (unlink) the real
|
||||||
* dirs. */
|
* dirs. */
|
||||||
VIR_FREE(driver->config->stateDir);
|
VIR_FREE(cfg->stateDir);
|
||||||
VIR_FREE(driver->config->configDir);
|
VIR_FREE(cfg->configDir);
|
||||||
|
|
||||||
/* Overwrite some default paths so it's consistent for tests. */
|
/* Overwrite some default paths so it's consistent for tests. */
|
||||||
VIR_FREE(driver->config->libDir);
|
VIR_FREE(cfg->libDir);
|
||||||
VIR_FREE(driver->config->channelTargetDir);
|
VIR_FREE(cfg->channelTargetDir);
|
||||||
driver->config->libDir = g_strdup("/tmp/lib");
|
cfg->libDir = g_strdup("/tmp/lib");
|
||||||
driver->config->channelTargetDir = g_strdup("/tmp/channel");
|
cfg->channelTargetDir = g_strdup("/tmp/channel");
|
||||||
|
|
||||||
if (!g_mkdtemp(statedir)) {
|
if (!g_mkdtemp(statedir)) {
|
||||||
fprintf(stderr, "Cannot create fake stateDir");
|
fprintf(stderr, "Cannot create fake stateDir");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
driver->config->stateDir = g_strdup(statedir);
|
cfg->stateDir = g_strdup(statedir);
|
||||||
|
|
||||||
if (!g_mkdtemp(configdir)) {
|
if (!g_mkdtemp(configdir)) {
|
||||||
fprintf(stderr, "Cannot create fake configDir");
|
fprintf(stderr, "Cannot create fake configDir");
|
||||||
goto error;
|
goto error;
|
||||||
}
|
}
|
||||||
|
|
||||||
driver->config->configDir = g_strdup(configdir);
|
cfg->configDir = g_strdup(configdir);
|
||||||
|
|
||||||
driver->caps = testQemuCapsInit();
|
driver->caps = testQemuCapsInit();
|
||||||
if (!driver->caps)
|
if (!driver->caps)
|
||||||
|
Loading…
Reference in New Issue
Block a user