On Tue, Jul 02, 2019 at 03:49:44PM +0200, Ilias Stamatis wrote:
Signed-off-by: Ilias Stamatis <stamatis.iliass(a)gmail.com>
---
src/test/test_driver.c | 58 ++++++++++++++++++++++++++++++++++++++++++
1 file changed, 58 insertions(+)
diff --git a/src/test/test_driver.c b/src/test/test_driver.c
index 15894d98ad..d2a7d2f840 100644
--- a/src/test/test_driver.c
+++ b/src/test/test_driver.c
@@ -2935,6 +2935,63 @@ testDomainGetNumaParameters(virDomainPtr dom,
}
+static int
+testDomainGetInterfaceParameters(virDomainPtr dom,
+ const char *device,
+ virTypedParameterPtr params,
+ int *nparams,
+ unsigned int flags)
+{
+ virNetDevBandwidthRate in = {0};
+ virNetDevBandwidthRate out = {0};
+ virDomainObjPtr vm = NULL;
+ virDomainDefPtr def = NULL;
+ virDomainNetDefPtr net = NULL;
+ int ret = -1;
+
+ virCheckFlags(VIR_DOMAIN_AFFECT_LIVE |
+ VIR_DOMAIN_AFFECT_CONFIG |
+ VIR_TYPED_PARAM_STRING_OKAY, -1);
+
+ if ((*nparams) == 0) {
+ *nparams = 7;
+ return 0;
+ }
+
+ if (!(vm = testDomObjFromDomain(dom)))
+ return -1;
+
+ if (!(def = virDomainObjGetOneDef(vm, flags)))
+ goto cleanup;
+
+ if (!(net = virDomainNetFind(def, device)))
+ goto cleanup;
+
+ if (net->bandwidth) {
+ if (net->bandwidth->in)
+ in = *net->bandwidth->in;
+ if (net->bandwidth->out)
+ out = *net->bandwidth->out;
+ }
+
+ TEST_SET_PARAM(0, VIR_DOMAIN_BANDWIDTH_IN_AVERAGE, VIR_TYPED_PARAM_UINT,
in.average);
+ TEST_SET_PARAM(1, VIR_DOMAIN_BANDWIDTH_IN_PEAK, VIR_TYPED_PARAM_UINT, in.peak);
+ TEST_SET_PARAM(2, VIR_DOMAIN_BANDWIDTH_IN_BURST, VIR_TYPED_PARAM_UINT, in.burst);
+ TEST_SET_PARAM(3, VIR_DOMAIN_BANDWIDTH_IN_FLOOR, VIR_TYPED_PARAM_UINT, in.floor);
+ TEST_SET_PARAM(4, VIR_DOMAIN_BANDWIDTH_OUT_AVERAGE, VIR_TYPED_PARAM_UINT,
out.average);
+ TEST_SET_PARAM(5, VIR_DOMAIN_BANDWIDTH_OUT_PEAK, VIR_TYPED_PARAM_UINT, out.peak);
+ TEST_SET_PARAM(6, VIR_DOMAIN_BANDWIDTH_OUT_BURST, VIR_TYPED_PARAM_UINT, out.burst);
Elegant.
+
+ if (*nparams > 7)
+ *nparams = 7;
+
+ ret = 0;
+ cleanup:
+ virDomainObjEndAPI(&vm);
+ return ret;
+}
+
+
#undef TEST_SET_PARAM
Reviewed-by: Erik Skultety <eskultet(a)redhat.com>