mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
Add ability to register callback for virCommand dry run
To allow for fault injection of the virCommand dry run, add the ability to register a callback. The callback will be passed the argv, env and stdin buffer and is expected to return the exit status and optionally fill stdout and stderr buffers. Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
This commit is contained in:
@@ -96,7 +96,7 @@ testKModLoad(const void *args)
|
||||
bool useBlacklist = info->useBlacklist;
|
||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
||||
|
||||
virCommandSetDryRun(&buf);
|
||||
virCommandSetDryRun(&buf, NULL, NULL);
|
||||
|
||||
errbuf = virKModLoad(module, useBlacklist);
|
||||
if (errbuf) {
|
||||
@@ -110,7 +110,7 @@ testKModLoad(const void *args)
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
virCommandSetDryRun(NULL);
|
||||
virCommandSetDryRun(NULL, NULL, NULL);
|
||||
VIR_FREE(errbuf);
|
||||
return ret;
|
||||
}
|
||||
@@ -125,7 +125,7 @@ testKModUnload(const void *args)
|
||||
const char *module = info->module;
|
||||
virBuffer buf = VIR_BUFFER_INITIALIZER;
|
||||
|
||||
virCommandSetDryRun(&buf);
|
||||
virCommandSetDryRun(&buf, NULL, NULL);
|
||||
|
||||
errbuf = virKModUnload(module);
|
||||
if (errbuf) {
|
||||
@@ -139,7 +139,7 @@ testKModUnload(const void *args)
|
||||
ret = 0;
|
||||
|
||||
cleanup:
|
||||
virCommandSetDryRun(NULL);
|
||||
virCommandSetDryRun(NULL, NULL, NULL);
|
||||
VIR_FREE(errbuf);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -77,7 +77,7 @@ testVirNetDevBandwidthSet(const void *data)
|
||||
if (!iface)
|
||||
iface = "eth0";
|
||||
|
||||
virCommandSetDryRun(&buf);
|
||||
virCommandSetDryRun(&buf, NULL, NULL);
|
||||
|
||||
if (virNetDevBandwidthSet(iface, band, info->hierarchical_class) < 0)
|
||||
goto cleanup;
|
||||
@@ -101,6 +101,7 @@ testVirNetDevBandwidthSet(const void *data)
|
||||
|
||||
ret = 0;
|
||||
cleanup:
|
||||
virCommandSetDryRun(NULL, NULL, NULL);
|
||||
virNetDevBandwidthFree(band);
|
||||
virBufferFreeAndReset(&buf);
|
||||
VIR_FREE(actual_cmd);
|
||||
|
||||
Reference in New Issue
Block a user