mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-07-06 09:55:46 +00:00
virCommandSetDryRun: Rework resetting of the dry run data
While virCommandSetDryRun is used in tests only, there were some cases when error paths would not call the function with NULL arguments to reset the dry run infrastructure. Introduce virCommandDryRunToken type which must be allocated via virCommandDryRunTokenNew and passed to virCommandSetDryRun. This way we can use automatic variable cleaning to trigger the cleanup of virCommandSetDryRun parameters and also the use of the token variable ensures that all callers of virCommandSetDryRun clean up after themselves and also that the token isn't left unused in the code. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
This commit is contained in:
parent
070cc66d16
commit
0dffca8f95
@ -1988,6 +1988,8 @@ virCommandAllowCap;
|
|||||||
virCommandClearCaps;
|
virCommandClearCaps;
|
||||||
virCommandDaemonize;
|
virCommandDaemonize;
|
||||||
virCommandDoAsyncIO;
|
virCommandDoAsyncIO;
|
||||||
|
virCommandDryRunTokenFree;
|
||||||
|
virCommandDryRunTokenNew;
|
||||||
virCommandExec;
|
virCommandExec;
|
||||||
virCommandFree;
|
virCommandFree;
|
||||||
virCommandGetArgList;
|
virCommandGetArgList;
|
||||||
|
@ -3087,8 +3087,45 @@ virCommandDoAsyncIO(virCommandPtr cmd)
|
|||||||
cmd->flags |= VIR_EXEC_ASYNC_IO | VIR_EXEC_NONBLOCK;
|
cmd->flags |= VIR_EXEC_ASYNC_IO | VIR_EXEC_NONBLOCK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
struct _virCommandDryRunToken {
|
||||||
|
int dummy;
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* virCommandDryRunTokenNew:
|
||||||
|
*
|
||||||
|
* Returns a token which is used with virCommandSetDryRun. Freeing the token
|
||||||
|
* with the appropriate automatic cleanup function ensures that the dry run
|
||||||
|
* environment is reset.
|
||||||
|
*/
|
||||||
|
virCommandDryRunToken *
|
||||||
|
virCommandDryRunTokenNew(void)
|
||||||
|
{
|
||||||
|
return g_new0(virCommandDryRunToken, 1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* virCommandDryRunTokenFree:
|
||||||
|
*
|
||||||
|
* Helper to free a virCommandDryRunToken. Do not use this function directly,
|
||||||
|
* always declare virCommandDryRunToken as a g_autoptr.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
virCommandDryRunTokenFree(virCommandDryRunToken *tok)
|
||||||
|
{
|
||||||
|
dryRunBuffer = NULL;
|
||||||
|
dryRunCallback = NULL;
|
||||||
|
dryRunOpaque = NULL;
|
||||||
|
g_free(tok);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* virCommandSetDryRun:
|
* virCommandSetDryRun:
|
||||||
|
* @tok: a virCommandDryRunToken obtained from virCommandDryRunTokenNew
|
||||||
* @buf: buffer to store stringified commands
|
* @buf: buffer to store stringified commands
|
||||||
* @callback: callback to process input/output/args
|
* @callback: callback to process input/output/args
|
||||||
*
|
*
|
||||||
@ -3120,10 +3157,14 @@ virCommandDoAsyncIO(virCommandPtr cmd)
|
|||||||
* To cancel this effect pass NULL for @buf and @callback.
|
* To cancel this effect pass NULL for @buf and @callback.
|
||||||
*/
|
*/
|
||||||
void
|
void
|
||||||
virCommandSetDryRun(virBufferPtr buf,
|
virCommandSetDryRun(virCommandDryRunToken *tok,
|
||||||
|
virBufferPtr buf,
|
||||||
virCommandDryRunCallback cb,
|
virCommandDryRunCallback cb,
|
||||||
void *opaque)
|
void *opaque)
|
||||||
{
|
{
|
||||||
|
if (!tok)
|
||||||
|
abort();
|
||||||
|
|
||||||
dryRunBuffer = buf;
|
dryRunBuffer = buf;
|
||||||
dryRunCallback = cb;
|
dryRunCallback = cb;
|
||||||
dryRunOpaque = opaque;
|
dryRunOpaque = opaque;
|
||||||
|
@ -35,6 +35,13 @@ typedef void (*virCommandDryRunCallback)(const char *const*args,
|
|||||||
int *status,
|
int *status,
|
||||||
void *opaque);
|
void *opaque);
|
||||||
|
|
||||||
void virCommandSetDryRun(virBufferPtr buf,
|
typedef struct _virCommandDryRunToken virCommandDryRunToken;
|
||||||
|
|
||||||
|
virCommandDryRunToken * virCommandDryRunTokenNew(void);
|
||||||
|
void virCommandDryRunTokenFree(virCommandDryRunToken *token);
|
||||||
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virCommandDryRunToken, virCommandDryRunTokenFree);
|
||||||
|
|
||||||
|
void virCommandSetDryRun(virCommandDryRunToken *tok,
|
||||||
|
virBufferPtr buf,
|
||||||
virCommandDryRunCallback cb,
|
virCommandDryRunCallback cb,
|
||||||
void *opaque);
|
void *opaque);
|
||||||
|
@ -96,8 +96,9 @@ static int testCompareXMLToArgvFiles(const char *xml,
|
|||||||
virNetworkDefPtr def = NULL;
|
virNetworkDefPtr def = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
char *actual;
|
char *actual;
|
||||||
|
g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
|
||||||
|
|
||||||
virCommandSetDryRun(&buf, testCommandDryRun, NULL);
|
virCommandSetDryRun(dryRunToken, &buf, testCommandDryRun, NULL);
|
||||||
|
|
||||||
if (!(def = virNetworkDefParseFile(xml, NULL)))
|
if (!(def = virNetworkDefParseFile(xml, NULL)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -107,7 +108,6 @@ static int testCompareXMLToArgvFiles(const char *xml,
|
|||||||
|
|
||||||
actual = actualargv = virBufferContentAndReset(&buf);
|
actual = actualargv = virBufferContentAndReset(&buf);
|
||||||
virTestClearCommandPath(actualargv);
|
virTestClearCommandPath(actualargv);
|
||||||
virCommandSetDryRun(NULL, NULL, NULL);
|
|
||||||
|
|
||||||
/* The first network to be created populates the
|
/* The first network to be created populates the
|
||||||
* libvirt global chains. We must skip args for
|
* libvirt global chains. We must skip args for
|
||||||
|
@ -75,6 +75,7 @@ testMdevctlStartOrDefine(const char *virt_type,
|
|||||||
g_autofree char *errmsg = NULL;
|
g_autofree char *errmsg = NULL;
|
||||||
g_autofree char *stdinbuf = NULL;
|
g_autofree char *stdinbuf = NULL;
|
||||||
g_autoptr(virCommand) cmd = NULL;
|
g_autoptr(virCommand) cmd = NULL;
|
||||||
|
g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
|
||||||
|
|
||||||
if (!(def = virNodeDeviceDefParseFile(mdevxml, create, virt_type)))
|
if (!(def = virNodeDeviceDefParseFile(mdevxml, create, virt_type)))
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -86,7 +87,7 @@ testMdevctlStartOrDefine(const char *virt_type,
|
|||||||
if (!cmd)
|
if (!cmd)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
virCommandSetDryRun(&buf, testCommandDryRunCallback, &stdinbuf);
|
virCommandSetDryRun(dryRunToken, &buf, testCommandDryRunCallback, &stdinbuf);
|
||||||
if (virCommandRun(cmd, NULL) < 0)
|
if (virCommandRun(cmd, NULL) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -102,7 +103,6 @@ testMdevctlStartOrDefine(const char *virt_type,
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virCommandSetDryRun(NULL, NULL, NULL);
|
|
||||||
virNodeDeviceObjEndAPI(&obj);
|
virNodeDeviceObjEndAPI(&obj);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -152,13 +152,14 @@ testMdevctlUuidCommand(const char *uuid, GetStopUndefineCmdFunc func, const char
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
g_autoptr(virCommand) cmd = NULL;
|
g_autoptr(virCommand) cmd = NULL;
|
||||||
g_autofree char *errmsg = NULL;
|
g_autofree char *errmsg = NULL;
|
||||||
|
g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
|
||||||
|
|
||||||
cmd = func(uuid, &errmsg);
|
cmd = func(uuid, &errmsg);
|
||||||
|
|
||||||
if (!cmd)
|
if (!cmd)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
virCommandSetDryRun(&buf, NULL, NULL);
|
virCommandSetDryRun(dryRunToken, &buf, NULL, NULL);
|
||||||
if (virCommandRun(cmd, NULL) < 0)
|
if (virCommandRun(cmd, NULL) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -171,7 +172,6 @@ testMdevctlUuidCommand(const char *uuid, GetStopUndefineCmdFunc func, const char
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virCommandSetDryRun(NULL, NULL, NULL);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,13 +214,14 @@ testMdevctlListDefined(const void *data G_GNUC_UNUSED)
|
|||||||
g_autofree char *cmdlinefile =
|
g_autofree char *cmdlinefile =
|
||||||
g_strdup_printf("%s/nodedevmdevctldata/mdevctl-list-defined.argv",
|
g_strdup_printf("%s/nodedevmdevctldata/mdevctl-list-defined.argv",
|
||||||
abs_srcdir);
|
abs_srcdir);
|
||||||
|
g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
|
||||||
|
|
||||||
cmd = nodeDeviceGetMdevctlListCommand(true, &output, &errmsg);
|
cmd = nodeDeviceGetMdevctlListCommand(true, &output, &errmsg);
|
||||||
|
|
||||||
if (!cmd)
|
if (!cmd)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
virCommandSetDryRun(&buf, NULL, NULL);
|
virCommandSetDryRun(dryRunToken, &buf, NULL, NULL);
|
||||||
if (virCommandRun(cmd, NULL) < 0)
|
if (virCommandRun(cmd, NULL) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
@ -234,7 +235,6 @@ testMdevctlListDefined(const void *data G_GNUC_UNUSED)
|
|||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virBufferFreeAndReset(&buf);
|
virBufferFreeAndReset(&buf);
|
||||||
virCommandSetDryRun(NULL, NULL, NULL);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -103,8 +103,9 @@ testNWFilterEBIPTablesAllTeardown(const void *opaque G_GNUC_UNUSED)
|
|||||||
"ebtables --concurrent -t nat -X libvirt-O-vnet0\n";
|
"ebtables --concurrent -t nat -X libvirt-O-vnet0\n";
|
||||||
char *actual = NULL;
|
char *actual = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
|
||||||
|
|
||||||
virCommandSetDryRun(&buf, NULL, NULL);
|
virCommandSetDryRun(dryRunToken, &buf, NULL, NULL);
|
||||||
|
|
||||||
if (ebiptables_driver.allTeardown("vnet0") < 0)
|
if (ebiptables_driver.allTeardown("vnet0") < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -119,7 +120,6 @@ testNWFilterEBIPTablesAllTeardown(const void *opaque G_GNUC_UNUSED)
|
|||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
virCommandSetDryRun(NULL, NULL, NULL);
|
|
||||||
VIR_FREE(actual);
|
VIR_FREE(actual);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -170,8 +170,9 @@ testNWFilterEBIPTablesTearOldRules(const void *opaque G_GNUC_UNUSED)
|
|||||||
"ebtables --concurrent -t nat -E libvirt-P-vnet0 libvirt-O-vnet0\n";
|
"ebtables --concurrent -t nat -E libvirt-P-vnet0 libvirt-O-vnet0\n";
|
||||||
char *actual = NULL;
|
char *actual = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
|
||||||
|
|
||||||
virCommandSetDryRun(&buf, NULL, NULL);
|
virCommandSetDryRun(dryRunToken, &buf, NULL, NULL);
|
||||||
|
|
||||||
if (ebiptables_driver.tearOldRules("vnet0") < 0)
|
if (ebiptables_driver.tearOldRules("vnet0") < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -186,7 +187,6 @@ testNWFilterEBIPTablesTearOldRules(const void *opaque G_GNUC_UNUSED)
|
|||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
virCommandSetDryRun(NULL, NULL, NULL);
|
|
||||||
VIR_FREE(actual);
|
VIR_FREE(actual);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -215,8 +215,9 @@ testNWFilterEBIPTablesRemoveBasicRules(const void *opaque G_GNUC_UNUSED)
|
|||||||
"ebtables --concurrent -t nat -X libvirt-P-vnet0\n";
|
"ebtables --concurrent -t nat -X libvirt-P-vnet0\n";
|
||||||
char *actual = NULL;
|
char *actual = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
|
||||||
|
|
||||||
virCommandSetDryRun(&buf, NULL, NULL);
|
virCommandSetDryRun(dryRunToken, &buf, NULL, NULL);
|
||||||
|
|
||||||
if (ebiptables_driver.removeBasicRules("vnet0") < 0)
|
if (ebiptables_driver.removeBasicRules("vnet0") < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -231,7 +232,6 @@ testNWFilterEBIPTablesRemoveBasicRules(const void *opaque G_GNUC_UNUSED)
|
|||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
virCommandSetDryRun(NULL, NULL, NULL);
|
|
||||||
VIR_FREE(actual);
|
VIR_FREE(actual);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -245,8 +245,9 @@ testNWFilterEBIPTablesTearNewRules(const void *opaque G_GNUC_UNUSED)
|
|||||||
VIR_NWFILTER_NEW_RULES_TEARDOWN;
|
VIR_NWFILTER_NEW_RULES_TEARDOWN;
|
||||||
char *actual = NULL;
|
char *actual = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
|
||||||
|
|
||||||
virCommandSetDryRun(&buf, NULL, NULL);
|
virCommandSetDryRun(dryRunToken, &buf, NULL, NULL);
|
||||||
|
|
||||||
if (ebiptables_driver.tearNewRules("vnet0") < 0)
|
if (ebiptables_driver.tearNewRules("vnet0") < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -261,7 +262,6 @@ testNWFilterEBIPTablesTearNewRules(const void *opaque G_GNUC_UNUSED)
|
|||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
virCommandSetDryRun(NULL, NULL, NULL);
|
|
||||||
VIR_FREE(actual);
|
VIR_FREE(actual);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -313,8 +313,9 @@ testNWFilterEBIPTablesApplyBasicRules(const void *opaque G_GNUC_UNUSED)
|
|||||||
char *actual = NULL;
|
char *actual = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
virMacAddr mac = { .addr = { 0x10, 0x20, 0x30, 0x40, 0x50, 0x60 } };
|
virMacAddr mac = { .addr = { 0x10, 0x20, 0x30, 0x40, 0x50, 0x60 } };
|
||||||
|
g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
|
||||||
|
|
||||||
virCommandSetDryRun(&buf, NULL, NULL);
|
virCommandSetDryRun(dryRunToken, &buf, NULL, NULL);
|
||||||
|
|
||||||
if (ebiptables_driver.applyBasicRules("vnet0", &mac) < 0)
|
if (ebiptables_driver.applyBasicRules("vnet0", &mac) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -329,7 +330,6 @@ testNWFilterEBIPTablesApplyBasicRules(const void *opaque G_GNUC_UNUSED)
|
|||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
virCommandSetDryRun(NULL, NULL, NULL);
|
|
||||||
VIR_FREE(actual);
|
VIR_FREE(actual);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -399,8 +399,9 @@ testNWFilterEBIPTablesApplyDHCPOnlyRules(const void *opaque G_GNUC_UNUSED)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
|
||||||
|
|
||||||
virCommandSetDryRun(&buf, NULL, NULL);
|
virCommandSetDryRun(dryRunToken, &buf, NULL, NULL);
|
||||||
|
|
||||||
if (ebiptables_driver.applyDHCPOnlyRules("vnet0", &mac, &val, false) < 0)
|
if (ebiptables_driver.applyDHCPOnlyRules("vnet0", &mac, &val, false) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -415,7 +416,6 @@ testNWFilterEBIPTablesApplyDHCPOnlyRules(const void *opaque G_GNUC_UNUSED)
|
|||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
virCommandSetDryRun(NULL, NULL, NULL);
|
|
||||||
VIR_FREE(actual);
|
VIR_FREE(actual);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -468,8 +468,9 @@ testNWFilterEBIPTablesApplyDropAllRules(const void *opaque G_GNUC_UNUSED)
|
|||||||
"ebtables --concurrent -t nat -E libvirt-P-vnet0 libvirt-O-vnet0\n";
|
"ebtables --concurrent -t nat -E libvirt-P-vnet0 libvirt-O-vnet0\n";
|
||||||
char *actual = NULL;
|
char *actual = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
|
||||||
|
|
||||||
virCommandSetDryRun(&buf, NULL, NULL);
|
virCommandSetDryRun(dryRunToken, &buf, NULL, NULL);
|
||||||
|
|
||||||
if (ebiptables_driver.applyDropAllRules("vnet0") < 0)
|
if (ebiptables_driver.applyDropAllRules("vnet0") < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -484,7 +485,6 @@ testNWFilterEBIPTablesApplyDropAllRules(const void *opaque G_GNUC_UNUSED)
|
|||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
virCommandSetDryRun(NULL, NULL, NULL);
|
|
||||||
VIR_FREE(actual);
|
VIR_FREE(actual);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -371,10 +371,11 @@ static int testCompareXMLToArgvFiles(const char *xml,
|
|||||||
GHashTable *vars = virHashNew(virNWFilterVarValueHashFree);
|
GHashTable *vars = virHashNew(virNWFilterVarValueHashFree);
|
||||||
virNWFilterInst inst;
|
virNWFilterInst inst;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
|
||||||
|
|
||||||
memset(&inst, 0, sizeof(inst));
|
memset(&inst, 0, sizeof(inst));
|
||||||
|
|
||||||
virCommandSetDryRun(&buf, NULL, NULL);
|
virCommandSetDryRun(dryRunToken, &buf, NULL, NULL);
|
||||||
|
|
||||||
if (!vars)
|
if (!vars)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -392,7 +393,6 @@ static int testCompareXMLToArgvFiles(const char *xml,
|
|||||||
|
|
||||||
actualargv = virBufferContentAndReset(&buf);
|
actualargv = virBufferContentAndReset(&buf);
|
||||||
virTestClearCommandPath(actualargv);
|
virTestClearCommandPath(actualargv);
|
||||||
virCommandSetDryRun(NULL, NULL, NULL);
|
|
||||||
|
|
||||||
testRemoveCommonRules(actualargv);
|
testRemoveCommonRules(actualargv);
|
||||||
|
|
||||||
|
@ -96,17 +96,17 @@ testSysinfo(const void *data)
|
|||||||
g_autofree char *sysinfo = NULL;
|
g_autofree char *sysinfo = NULL;
|
||||||
g_autofree char *cpuinfo = NULL;
|
g_autofree char *cpuinfo = NULL;
|
||||||
g_autofree char *expected = NULL;
|
g_autofree char *expected = NULL;
|
||||||
|
g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
|
||||||
|
|
||||||
sysinfo = g_strdup_printf("%s/sysinfodata/%ssysinfo.data", abs_srcdir, testdata->name);
|
sysinfo = g_strdup_printf("%s/sysinfodata/%ssysinfo.data", abs_srcdir, testdata->name);
|
||||||
cpuinfo = g_strdup_printf("%s/sysinfodata/%scpuinfo.data", abs_srcdir, testdata->name);
|
cpuinfo = g_strdup_printf("%s/sysinfodata/%scpuinfo.data", abs_srcdir, testdata->name);
|
||||||
expected = g_strdup_printf("%s/sysinfodata/%ssysinfo.expect", abs_srcdir, testdata->name);
|
expected = g_strdup_printf("%s/sysinfodata/%ssysinfo.expect", abs_srcdir, testdata->name);
|
||||||
|
|
||||||
virCommandSetDryRun(NULL, testDMIDecodeDryRun, sysinfo);
|
virCommandSetDryRun(dryRunToken, NULL, testDMIDecodeDryRun, sysinfo);
|
||||||
|
|
||||||
virSysinfoSetup(sysinfo, cpuinfo);
|
virSysinfoSetup(sysinfo, cpuinfo);
|
||||||
|
|
||||||
ret = testdata->func();
|
ret = testdata->func();
|
||||||
virCommandSetDryRun(NULL, NULL, NULL);
|
|
||||||
|
|
||||||
if (!ret)
|
if (!ret)
|
||||||
return -1;
|
return -1;
|
||||||
|
@ -189,6 +189,7 @@ testFirewallSingleGroup(const void *opaque)
|
|||||||
IPTABLES_PATH " -w -A INPUT --source 192.168.122.1 --jump ACCEPT\n"
|
IPTABLES_PATH " -w -A INPUT --source 192.168.122.1 --jump ACCEPT\n"
|
||||||
IPTABLES_PATH " -w -A INPUT --source '!192.168.122.1' --jump REJECT\n";
|
IPTABLES_PATH " -w -A INPUT --source '!192.168.122.1' --jump REJECT\n";
|
||||||
const struct testFirewallData *data = opaque;
|
const struct testFirewallData *data = opaque;
|
||||||
|
g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
|
||||||
|
|
||||||
fwDisabled = data->fwDisabled;
|
fwDisabled = data->fwDisabled;
|
||||||
if (virFirewallSetBackend(data->tryBackend) < 0)
|
if (virFirewallSetBackend(data->tryBackend) < 0)
|
||||||
@ -196,7 +197,7 @@ testFirewallSingleGroup(const void *opaque)
|
|||||||
|
|
||||||
if (data->expectBackend == VIR_FIREWALL_BACKEND_DIRECT ||
|
if (data->expectBackend == VIR_FIREWALL_BACKEND_DIRECT ||
|
||||||
data->expectBackend == VIR_FIREWALL_BACKEND_FIREWALLD)
|
data->expectBackend == VIR_FIREWALL_BACKEND_FIREWALLD)
|
||||||
virCommandSetDryRun(&cmdbuf, NULL, NULL);
|
virCommandSetDryRun(dryRunToken, &cmdbuf, NULL, NULL);
|
||||||
else
|
else
|
||||||
fwBuf = &cmdbuf;
|
fwBuf = &cmdbuf;
|
||||||
|
|
||||||
@ -226,7 +227,6 @@ testFirewallSingleGroup(const void *opaque)
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
fwBuf = NULL;
|
fwBuf = NULL;
|
||||||
virCommandSetDryRun(NULL, NULL, NULL);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,6 +243,7 @@ testFirewallRemoveRule(const void *opaque)
|
|||||||
IPTABLES_PATH " -w -A INPUT --source '!192.168.122.1' --jump REJECT\n";
|
IPTABLES_PATH " -w -A INPUT --source '!192.168.122.1' --jump REJECT\n";
|
||||||
const struct testFirewallData *data = opaque;
|
const struct testFirewallData *data = opaque;
|
||||||
virFirewallRulePtr fwrule;
|
virFirewallRulePtr fwrule;
|
||||||
|
g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
|
||||||
|
|
||||||
fwDisabled = data->fwDisabled;
|
fwDisabled = data->fwDisabled;
|
||||||
if (virFirewallSetBackend(data->tryBackend) < 0)
|
if (virFirewallSetBackend(data->tryBackend) < 0)
|
||||||
@ -250,7 +251,7 @@ testFirewallRemoveRule(const void *opaque)
|
|||||||
|
|
||||||
if (data->expectBackend == VIR_FIREWALL_BACKEND_DIRECT ||
|
if (data->expectBackend == VIR_FIREWALL_BACKEND_DIRECT ||
|
||||||
data->expectBackend == VIR_FIREWALL_BACKEND_FIREWALLD)
|
data->expectBackend == VIR_FIREWALL_BACKEND_FIREWALLD)
|
||||||
virCommandSetDryRun(&cmdbuf, NULL, NULL);
|
virCommandSetDryRun(dryRunToken, &cmdbuf, NULL, NULL);
|
||||||
else
|
else
|
||||||
fwBuf = &cmdbuf;
|
fwBuf = &cmdbuf;
|
||||||
|
|
||||||
@ -286,7 +287,6 @@ testFirewallRemoveRule(const void *opaque)
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
fwBuf = NULL;
|
fwBuf = NULL;
|
||||||
virCommandSetDryRun(NULL, NULL, NULL);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -304,6 +304,7 @@ testFirewallManyGroups(const void *opaque G_GNUC_UNUSED)
|
|||||||
IPTABLES_PATH " -w -A OUTPUT --source 192.168.122.1 --jump ACCEPT\n"
|
IPTABLES_PATH " -w -A OUTPUT --source 192.168.122.1 --jump ACCEPT\n"
|
||||||
IPTABLES_PATH " -w -A OUTPUT --jump DROP\n";
|
IPTABLES_PATH " -w -A OUTPUT --jump DROP\n";
|
||||||
const struct testFirewallData *data = opaque;
|
const struct testFirewallData *data = opaque;
|
||||||
|
g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
|
||||||
|
|
||||||
fwDisabled = data->fwDisabled;
|
fwDisabled = data->fwDisabled;
|
||||||
if (virFirewallSetBackend(data->tryBackend) < 0)
|
if (virFirewallSetBackend(data->tryBackend) < 0)
|
||||||
@ -311,7 +312,7 @@ testFirewallManyGroups(const void *opaque G_GNUC_UNUSED)
|
|||||||
|
|
||||||
if (data->expectBackend == VIR_FIREWALL_BACKEND_DIRECT ||
|
if (data->expectBackend == VIR_FIREWALL_BACKEND_DIRECT ||
|
||||||
data->expectBackend == VIR_FIREWALL_BACKEND_FIREWALLD)
|
data->expectBackend == VIR_FIREWALL_BACKEND_FIREWALLD)
|
||||||
virCommandSetDryRun(&cmdbuf, NULL, NULL);
|
virCommandSetDryRun(dryRunToken, &cmdbuf, NULL, NULL);
|
||||||
else
|
else
|
||||||
fwBuf = &cmdbuf;
|
fwBuf = &cmdbuf;
|
||||||
|
|
||||||
@ -353,7 +354,6 @@ testFirewallManyGroups(const void *opaque G_GNUC_UNUSED)
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
fwBuf = NULL;
|
fwBuf = NULL;
|
||||||
virCommandSetDryRun(NULL, NULL, NULL);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -392,6 +392,7 @@ testFirewallIgnoreFailGroup(const void *opaque G_GNUC_UNUSED)
|
|||||||
IPTABLES_PATH " -w -A OUTPUT --source 192.168.122.1 --jump ACCEPT\n"
|
IPTABLES_PATH " -w -A OUTPUT --source 192.168.122.1 --jump ACCEPT\n"
|
||||||
IPTABLES_PATH " -w -A OUTPUT --jump DROP\n";
|
IPTABLES_PATH " -w -A OUTPUT --jump DROP\n";
|
||||||
const struct testFirewallData *data = opaque;
|
const struct testFirewallData *data = opaque;
|
||||||
|
g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
|
||||||
|
|
||||||
fwDisabled = data->fwDisabled;
|
fwDisabled = data->fwDisabled;
|
||||||
if (virFirewallSetBackend(data->tryBackend) < 0)
|
if (virFirewallSetBackend(data->tryBackend) < 0)
|
||||||
@ -399,7 +400,7 @@ testFirewallIgnoreFailGroup(const void *opaque G_GNUC_UNUSED)
|
|||||||
|
|
||||||
if (data->expectBackend == VIR_FIREWALL_BACKEND_DIRECT ||
|
if (data->expectBackend == VIR_FIREWALL_BACKEND_DIRECT ||
|
||||||
data->expectBackend == VIR_FIREWALL_BACKEND_FIREWALLD) {
|
data->expectBackend == VIR_FIREWALL_BACKEND_FIREWALLD) {
|
||||||
virCommandSetDryRun(&cmdbuf, testFirewallRollbackHook, NULL);
|
virCommandSetDryRun(dryRunToken, &cmdbuf, testFirewallRollbackHook, NULL);
|
||||||
} else {
|
} else {
|
||||||
fwBuf = &cmdbuf;
|
fwBuf = &cmdbuf;
|
||||||
fwError = true;
|
fwError = true;
|
||||||
@ -443,7 +444,6 @@ testFirewallIgnoreFailGroup(const void *opaque G_GNUC_UNUSED)
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
fwBuf = NULL;
|
fwBuf = NULL;
|
||||||
virCommandSetDryRun(NULL, NULL, NULL);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -461,6 +461,7 @@ testFirewallIgnoreFailRule(const void *opaque G_GNUC_UNUSED)
|
|||||||
IPTABLES_PATH " -w -A OUTPUT --source 192.168.122.1 --jump ACCEPT\n"
|
IPTABLES_PATH " -w -A OUTPUT --source 192.168.122.1 --jump ACCEPT\n"
|
||||||
IPTABLES_PATH " -w -A OUTPUT --jump DROP\n";
|
IPTABLES_PATH " -w -A OUTPUT --jump DROP\n";
|
||||||
const struct testFirewallData *data = opaque;
|
const struct testFirewallData *data = opaque;
|
||||||
|
g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
|
||||||
|
|
||||||
fwDisabled = data->fwDisabled;
|
fwDisabled = data->fwDisabled;
|
||||||
if (virFirewallSetBackend(data->tryBackend) < 0)
|
if (virFirewallSetBackend(data->tryBackend) < 0)
|
||||||
@ -468,7 +469,7 @@ testFirewallIgnoreFailRule(const void *opaque G_GNUC_UNUSED)
|
|||||||
|
|
||||||
if (data->expectBackend == VIR_FIREWALL_BACKEND_DIRECT ||
|
if (data->expectBackend == VIR_FIREWALL_BACKEND_DIRECT ||
|
||||||
data->expectBackend == VIR_FIREWALL_BACKEND_FIREWALLD) {
|
data->expectBackend == VIR_FIREWALL_BACKEND_FIREWALLD) {
|
||||||
virCommandSetDryRun(&cmdbuf, testFirewallRollbackHook, NULL);
|
virCommandSetDryRun(dryRunToken, &cmdbuf, testFirewallRollbackHook, NULL);
|
||||||
} else {
|
} else {
|
||||||
fwBuf = &cmdbuf;
|
fwBuf = &cmdbuf;
|
||||||
fwError = true;
|
fwError = true;
|
||||||
@ -511,7 +512,6 @@ testFirewallIgnoreFailRule(const void *opaque G_GNUC_UNUSED)
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
fwBuf = NULL;
|
fwBuf = NULL;
|
||||||
virCommandSetDryRun(NULL, NULL, NULL);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -527,6 +527,7 @@ testFirewallNoRollback(const void *opaque G_GNUC_UNUSED)
|
|||||||
IPTABLES_PATH " -w -A INPUT --source 192.168.122.1 --jump ACCEPT\n"
|
IPTABLES_PATH " -w -A INPUT --source 192.168.122.1 --jump ACCEPT\n"
|
||||||
IPTABLES_PATH " -w -A INPUT --source 192.168.122.255 --jump REJECT\n";
|
IPTABLES_PATH " -w -A INPUT --source 192.168.122.255 --jump REJECT\n";
|
||||||
const struct testFirewallData *data = opaque;
|
const struct testFirewallData *data = opaque;
|
||||||
|
g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
|
||||||
|
|
||||||
fwDisabled = data->fwDisabled;
|
fwDisabled = data->fwDisabled;
|
||||||
if (virFirewallSetBackend(data->tryBackend) < 0)
|
if (virFirewallSetBackend(data->tryBackend) < 0)
|
||||||
@ -534,7 +535,7 @@ testFirewallNoRollback(const void *opaque G_GNUC_UNUSED)
|
|||||||
|
|
||||||
if (data->expectBackend == VIR_FIREWALL_BACKEND_DIRECT ||
|
if (data->expectBackend == VIR_FIREWALL_BACKEND_DIRECT ||
|
||||||
data->expectBackend == VIR_FIREWALL_BACKEND_FIREWALLD) {
|
data->expectBackend == VIR_FIREWALL_BACKEND_FIREWALLD) {
|
||||||
virCommandSetDryRun(&cmdbuf, testFirewallRollbackHook, NULL);
|
virCommandSetDryRun(dryRunToken, &cmdbuf, testFirewallRollbackHook, NULL);
|
||||||
} else {
|
} else {
|
||||||
fwBuf = &cmdbuf;
|
fwBuf = &cmdbuf;
|
||||||
fwError = true;
|
fwError = true;
|
||||||
@ -573,7 +574,6 @@ testFirewallNoRollback(const void *opaque G_GNUC_UNUSED)
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
fwBuf = NULL;
|
fwBuf = NULL;
|
||||||
virCommandSetDryRun(NULL, NULL, NULL);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -591,6 +591,7 @@ testFirewallSingleRollback(const void *opaque G_GNUC_UNUSED)
|
|||||||
IPTABLES_PATH " -w -D INPUT --source 192.168.122.255 --jump REJECT\n"
|
IPTABLES_PATH " -w -D INPUT --source 192.168.122.255 --jump REJECT\n"
|
||||||
IPTABLES_PATH " -w -D INPUT --source '!192.168.122.1' --jump REJECT\n";
|
IPTABLES_PATH " -w -D INPUT --source '!192.168.122.1' --jump REJECT\n";
|
||||||
const struct testFirewallData *data = opaque;
|
const struct testFirewallData *data = opaque;
|
||||||
|
g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
|
||||||
|
|
||||||
fwDisabled = data->fwDisabled;
|
fwDisabled = data->fwDisabled;
|
||||||
if (virFirewallSetBackend(data->tryBackend) < 0)
|
if (virFirewallSetBackend(data->tryBackend) < 0)
|
||||||
@ -598,7 +599,7 @@ testFirewallSingleRollback(const void *opaque G_GNUC_UNUSED)
|
|||||||
|
|
||||||
if (data->expectBackend == VIR_FIREWALL_BACKEND_DIRECT ||
|
if (data->expectBackend == VIR_FIREWALL_BACKEND_DIRECT ||
|
||||||
data->expectBackend == VIR_FIREWALL_BACKEND_FIREWALLD) {
|
data->expectBackend == VIR_FIREWALL_BACKEND_FIREWALLD) {
|
||||||
virCommandSetDryRun(&cmdbuf, testFirewallRollbackHook, NULL);
|
virCommandSetDryRun(dryRunToken, &cmdbuf, testFirewallRollbackHook, NULL);
|
||||||
} else {
|
} else {
|
||||||
fwError = true;
|
fwError = true;
|
||||||
fwBuf = &cmdbuf;
|
fwBuf = &cmdbuf;
|
||||||
@ -654,7 +655,6 @@ testFirewallSingleRollback(const void *opaque G_GNUC_UNUSED)
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
fwBuf = NULL;
|
fwBuf = NULL;
|
||||||
virCommandSetDryRun(NULL, NULL, NULL);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -671,6 +671,7 @@ testFirewallManyRollback(const void *opaque G_GNUC_UNUSED)
|
|||||||
IPTABLES_PATH " -w -D INPUT --source 192.168.122.255 --jump REJECT\n"
|
IPTABLES_PATH " -w -D INPUT --source 192.168.122.255 --jump REJECT\n"
|
||||||
IPTABLES_PATH " -w -D INPUT --source '!192.168.122.1' --jump REJECT\n";
|
IPTABLES_PATH " -w -D INPUT --source '!192.168.122.1' --jump REJECT\n";
|
||||||
const struct testFirewallData *data = opaque;
|
const struct testFirewallData *data = opaque;
|
||||||
|
g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
|
||||||
|
|
||||||
fwDisabled = data->fwDisabled;
|
fwDisabled = data->fwDisabled;
|
||||||
if (virFirewallSetBackend(data->tryBackend) < 0)
|
if (virFirewallSetBackend(data->tryBackend) < 0)
|
||||||
@ -678,7 +679,7 @@ testFirewallManyRollback(const void *opaque G_GNUC_UNUSED)
|
|||||||
|
|
||||||
if (data->expectBackend == VIR_FIREWALL_BACKEND_DIRECT ||
|
if (data->expectBackend == VIR_FIREWALL_BACKEND_DIRECT ||
|
||||||
data->expectBackend == VIR_FIREWALL_BACKEND_FIREWALLD) {
|
data->expectBackend == VIR_FIREWALL_BACKEND_FIREWALLD) {
|
||||||
virCommandSetDryRun(&cmdbuf, testFirewallRollbackHook, NULL);
|
virCommandSetDryRun(dryRunToken, &cmdbuf, testFirewallRollbackHook, NULL);
|
||||||
} else {
|
} else {
|
||||||
fwBuf = &cmdbuf;
|
fwBuf = &cmdbuf;
|
||||||
fwError = true;
|
fwError = true;
|
||||||
@ -738,7 +739,6 @@ testFirewallManyRollback(const void *opaque G_GNUC_UNUSED)
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
fwBuf = NULL;
|
fwBuf = NULL;
|
||||||
virCommandSetDryRun(NULL, NULL, NULL);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -759,6 +759,7 @@ testFirewallChainedRollback(const void *opaque G_GNUC_UNUSED)
|
|||||||
IPTABLES_PATH " -w -D INPUT --source 192.168.122.255 --jump REJECT\n"
|
IPTABLES_PATH " -w -D INPUT --source 192.168.122.255 --jump REJECT\n"
|
||||||
IPTABLES_PATH " -w -D INPUT --source '!192.168.122.1' --jump REJECT\n";
|
IPTABLES_PATH " -w -D INPUT --source '!192.168.122.1' --jump REJECT\n";
|
||||||
const struct testFirewallData *data = opaque;
|
const struct testFirewallData *data = opaque;
|
||||||
|
g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
|
||||||
|
|
||||||
fwDisabled = data->fwDisabled;
|
fwDisabled = data->fwDisabled;
|
||||||
if (virFirewallSetBackend(data->tryBackend) < 0)
|
if (virFirewallSetBackend(data->tryBackend) < 0)
|
||||||
@ -766,7 +767,7 @@ testFirewallChainedRollback(const void *opaque G_GNUC_UNUSED)
|
|||||||
|
|
||||||
if (data->expectBackend == VIR_FIREWALL_BACKEND_DIRECT ||
|
if (data->expectBackend == VIR_FIREWALL_BACKEND_DIRECT ||
|
||||||
data->expectBackend == VIR_FIREWALL_BACKEND_FIREWALLD) {
|
data->expectBackend == VIR_FIREWALL_BACKEND_FIREWALLD) {
|
||||||
virCommandSetDryRun(&cmdbuf, testFirewallRollbackHook, NULL);
|
virCommandSetDryRun(dryRunToken, &cmdbuf, testFirewallRollbackHook, NULL);
|
||||||
} else {
|
} else {
|
||||||
fwBuf = &cmdbuf;
|
fwBuf = &cmdbuf;
|
||||||
fwError = true;
|
fwError = true;
|
||||||
@ -852,7 +853,6 @@ testFirewallChainedRollback(const void *opaque G_GNUC_UNUSED)
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
fwBuf = NULL;
|
fwBuf = NULL;
|
||||||
virCommandSetDryRun(NULL, NULL, NULL);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -953,6 +953,7 @@ testFirewallQuery(const void *opaque G_GNUC_UNUSED)
|
|||||||
IPTABLES_PATH " -w -A INPUT --source 192.168.122.128 --jump REJECT\n"
|
IPTABLES_PATH " -w -A INPUT --source 192.168.122.128 --jump REJECT\n"
|
||||||
IPTABLES_PATH " -w -A INPUT --source '!192.168.122.1' --jump REJECT\n";
|
IPTABLES_PATH " -w -A INPUT --source '!192.168.122.1' --jump REJECT\n";
|
||||||
const struct testFirewallData *data = opaque;
|
const struct testFirewallData *data = opaque;
|
||||||
|
g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
|
||||||
|
|
||||||
expectedLineNum = 0;
|
expectedLineNum = 0;
|
||||||
expectedLineError = false;
|
expectedLineError = false;
|
||||||
@ -962,7 +963,7 @@ testFirewallQuery(const void *opaque G_GNUC_UNUSED)
|
|||||||
|
|
||||||
if (data->expectBackend == VIR_FIREWALL_BACKEND_DIRECT ||
|
if (data->expectBackend == VIR_FIREWALL_BACKEND_DIRECT ||
|
||||||
data->expectBackend == VIR_FIREWALL_BACKEND_FIREWALLD) {
|
data->expectBackend == VIR_FIREWALL_BACKEND_FIREWALLD) {
|
||||||
virCommandSetDryRun(&cmdbuf, testFirewallQueryHook, NULL);
|
virCommandSetDryRun(dryRunToken, &cmdbuf, testFirewallQueryHook, NULL);
|
||||||
} else {
|
} else {
|
||||||
fwBuf = &cmdbuf;
|
fwBuf = &cmdbuf;
|
||||||
fwError = true;
|
fwError = true;
|
||||||
@ -1030,7 +1031,6 @@ testFirewallQuery(const void *opaque G_GNUC_UNUSED)
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
fwBuf = NULL;
|
fwBuf = NULL;
|
||||||
virCommandSetDryRun(NULL, NULL, NULL);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,10 +212,11 @@ testISCSIGetSession(const void *data)
|
|||||||
struct testIscsiadmCbData cbData = { 0 };
|
struct testIscsiadmCbData cbData = { 0 };
|
||||||
char *actual_session = NULL;
|
char *actual_session = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
|
||||||
|
|
||||||
cbData.output_version = info->output_version;
|
cbData.output_version = info->output_version;
|
||||||
|
|
||||||
virCommandSetDryRun(NULL, testIscsiadmCb, &cbData);
|
virCommandSetDryRun(dryRunToken, NULL, testIscsiadmCb, &cbData);
|
||||||
|
|
||||||
actual_session = virISCSIGetSession(info->device_path, true);
|
actual_session = virISCSIGetSession(info->device_path, true);
|
||||||
|
|
||||||
@ -230,7 +231,6 @@ testISCSIGetSession(const void *data)
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virCommandSetDryRun(NULL, NULL, NULL);
|
|
||||||
VIR_FREE(actual_session);
|
VIR_FREE(actual_session);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -250,8 +250,9 @@ testISCSIScanTargets(const void *data)
|
|||||||
char **targets = NULL;
|
char **targets = NULL;
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
size_t i;
|
size_t i;
|
||||||
|
g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
|
||||||
|
|
||||||
virCommandSetDryRun(NULL, testIscsiadmCb, NULL);
|
virCommandSetDryRun(dryRunToken, NULL, testIscsiadmCb, NULL);
|
||||||
|
|
||||||
if (virISCSIScanTargets(info->portal, NULL,
|
if (virISCSIScanTargets(info->portal, NULL,
|
||||||
false, &ntargets, &targets) < 0)
|
false, &ntargets, &targets) < 0)
|
||||||
@ -276,7 +277,6 @@ testISCSIScanTargets(const void *data)
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virCommandSetDryRun(NULL, NULL, NULL);
|
|
||||||
for (i = 0; i < ntargets; i++)
|
for (i = 0; i < ntargets; i++)
|
||||||
VIR_FREE(targets[i]);
|
VIR_FREE(targets[i]);
|
||||||
VIR_FREE(targets);
|
VIR_FREE(targets);
|
||||||
@ -297,15 +297,15 @@ testISCSIConnectionLogin(const void *data)
|
|||||||
const struct testConnectionInfoLogin *info = data;
|
const struct testConnectionInfoLogin *info = data;
|
||||||
struct testIscsiadmCbData cbData = { 0 };
|
struct testIscsiadmCbData cbData = { 0 };
|
||||||
int ret = -1;
|
int ret = -1;
|
||||||
|
g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
|
||||||
|
|
||||||
virCommandSetDryRun(NULL, testIscsiadmCb, &cbData);
|
virCommandSetDryRun(dryRunToken, NULL, testIscsiadmCb, &cbData);
|
||||||
|
|
||||||
if (virISCSIConnectionLogin(info->portal, info->initiatoriqn, info->target) < 0)
|
if (virISCSIConnectionLogin(info->portal, info->initiatoriqn, info->target) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
virCommandSetDryRun(NULL, NULL, NULL);
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,8 +61,9 @@ testKModLoad(const void *args G_GNUC_UNUSED)
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
char *errbuf = NULL;
|
char *errbuf = NULL;
|
||||||
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||||
|
g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
|
||||||
|
|
||||||
virCommandSetDryRun(&buf, NULL, NULL);
|
virCommandSetDryRun(dryRunToken, &buf, NULL, NULL);
|
||||||
|
|
||||||
errbuf = virKModLoad(MODNAME);
|
errbuf = virKModLoad(MODNAME);
|
||||||
if (errbuf) {
|
if (errbuf) {
|
||||||
@ -76,7 +77,6 @@ testKModLoad(const void *args G_GNUC_UNUSED)
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virCommandSetDryRun(NULL, NULL, NULL);
|
|
||||||
VIR_FREE(errbuf);
|
VIR_FREE(errbuf);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
@ -88,8 +88,9 @@ testKModUnload(const void *args G_GNUC_UNUSED)
|
|||||||
int ret = -1;
|
int ret = -1;
|
||||||
char *errbuf = NULL;
|
char *errbuf = NULL;
|
||||||
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||||
|
g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
|
||||||
|
|
||||||
virCommandSetDryRun(&buf, NULL, NULL);
|
virCommandSetDryRun(dryRunToken, &buf, NULL, NULL);
|
||||||
|
|
||||||
errbuf = virKModUnload(MODNAME);
|
errbuf = virKModUnload(MODNAME);
|
||||||
if (errbuf) {
|
if (errbuf) {
|
||||||
@ -103,7 +104,6 @@ testKModUnload(const void *args G_GNUC_UNUSED)
|
|||||||
ret = 0;
|
ret = 0;
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
virCommandSetDryRun(NULL, NULL, NULL);
|
|
||||||
VIR_FREE(errbuf);
|
VIR_FREE(errbuf);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -72,13 +72,14 @@ testVirNetDevBandwidthSet(const void *data)
|
|||||||
g_autoptr(virNetDevBandwidth) band = NULL;
|
g_autoptr(virNetDevBandwidth) band = NULL;
|
||||||
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER;
|
||||||
char *actual_cmd = NULL;
|
char *actual_cmd = NULL;
|
||||||
|
g_autoptr(virCommandDryRunToken) dryRunToken = virCommandDryRunTokenNew();
|
||||||
|
|
||||||
PARSE(info->band, band);
|
PARSE(info->band, band);
|
||||||
|
|
||||||
if (!iface)
|
if (!iface)
|
||||||
iface = "eth0";
|
iface = "eth0";
|
||||||
|
|
||||||
virCommandSetDryRun(&buf, NULL, NULL);
|
virCommandSetDryRun(dryRunToken, &buf, NULL, NULL);
|
||||||
|
|
||||||
if (virNetDevBandwidthSet(iface, band, info->hierarchical_class, true) < 0)
|
if (virNetDevBandwidthSet(iface, band, info->hierarchical_class, true) < 0)
|
||||||
goto cleanup;
|
goto cleanup;
|
||||||
@ -97,7 +98,6 @@ testVirNetDevBandwidthSet(const void *data)
|
|||||||
|
|
||||||
ret = 0;
|
ret = 0;
|
||||||
cleanup:
|
cleanup:
|
||||||
virCommandSetDryRun(NULL, NULL, NULL);
|
|
||||||
VIR_FREE(actual_cmd);
|
VIR_FREE(actual_cmd);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user