On Mon, Mar 27, 2017 at 05:38:58PM +0200, Andrea Bolognani wrote:
These tests cover a number of scenarios where we care about the memory locking limit being set correctly for the guest to work properly. ---+static int +testCompareMemLock(const void *data) +{ + const struct testInfo *info = data; + virConnectPtr conn = NULL; + virDomainObjPtr vm = NULL; + char *xml = NULL; + int ret = -1; + + if (!(conn = virGetConnect())) + goto cleanup; + + if (virAsprintf(&xml, "%s/qemumemlockdata/qemumemlock-%s.xml", + abs_srcdir, info->name) < 0) + goto cleanup; + + if (!(vm = virDomainObjNew(driver.xmlopt))) + goto cleanup; + + if (!(vm->def = virDomainDefParseFile(xml, driver.caps, driver.xmlopt, NULL, + VIR_DOMAIN_DEF_PARSE_INACTIVE))) { + goto cleanup; + } + + if (virTestCompareToULL(info->memlock, qemuDomainGetMemLockLimitBytes(vm->def)) < 0) + goto cleanup; + + ret = 0; + + cleanup: + virObjectUnref(vm); + virObjectUnref(conn); + VIR_FREE(xml); + + return ret; +} +
Looking at this function I don't think we really understood each other.
Looks like I explain better with code than words, so let me fix that
right up. ACK with the following squashed in:
diff --git c/tests/qemumemlocktest.c w/tests/qemumemlocktest.c
index 91593884656f..50e23d584e30 100644
--- c/tests/qemumemlocktest.c
+++ w/tests/qemumemlocktest.c
@@ -34,34 +34,23 @@ static int
testCompareMemLock(const void *data)
{
const struct testInfo *info = data;
- virConnectPtr conn = NULL;
- virDomainObjPtr vm = NULL;
+ virDomainDefPtr def = NULL;
char *xml = NULL;
int ret = -1;
- if (!(conn = virGetConnect()))
- goto cleanup;
-
if (virAsprintf(&xml, "%s/qemumemlockdata/qemumemlock-%s.xml",
abs_srcdir, info->name) < 0)
goto cleanup;
- if (!(vm = virDomainObjNew(driver.xmlopt)))
- goto cleanup;
-
- if (!(vm->def = virDomainDefParseFile(xml, driver.caps, driver.xmlopt,
NULL,
- VIR_DOMAIN_DEF_PARSE_INACTIVE))) {
+ if (!(def = virDomainDefParseFile(xml, driver.caps, driver.xmlopt, NULL,
+ VIR_DOMAIN_DEF_PARSE_INACTIVE))) {
goto cleanup;
}
- if (virTestCompareToULL(info->memlock,
qemuDomainGetMemLockLimitBytes(vm->def)) < 0)
- goto cleanup;
-
- ret = 0;
-
+ ret = virTestCompareToULL(info->memlock,
+ qemuDomainGetMemLockLimitBytes(def));
cleanup:
- virObjectUnref(vm);
- virObjectUnref(conn);
+ virDomainDefFree(def);
VIR_FREE(xml);
return ret;
--
signature.asc
Description: Digital signature
-- libvir-list mailing list [email protected] https://www.redhat.com/mailman/listinfo/libvir-list
