[libvirt] [RFC PATCH 0/3] Implement mockup capabilities cache in QEMU tests

Pavel Fedin p.fedin at samsung.com
Thu Sep 3 06:51:11 UTC 2015


> The current xmlopt structure has two callbacks in parser
> configuration, one for post-parsing of the whole domain XML and one
> for device XML.  We could add new (optional) callback in this
> structure that would be called before other post-parse callbacks, but
> still after the xml is parsed.  This would not be utilized anywhere
> else than in tests

 We don't need to add this because we already have domain post-parse callback. And this is what i
actually disliked.
 There is a very simple way to patch this callback. Currently in our tests we call
virQEMUDriverCreateXMLConf(), which returns a structure, containing our callbacks. Actually we could
make a wrapper around this function which would replace domainPostParseCallback with own pointer,
remembering the original one. Then our function would take emulator name from the parsed XML, insert
capabilities cache, and proceed to original function.

> We should be really careful about not depending on the host in tests,
> so any assert like this would be much appreciated.

 To tell the truth i'm not a big fan of test-only code in library body. But, i agree with this, and
i see no other way round. I think we could add some global Boolean variable like bool testMode,
which would be set to true by test suite.
 Actually, this variable could even modify capsCache behavior to ignore binary name at all, and
return, let's say, the first entry. But we should be really careful about it because i believe we
want to exercise the actual library code, and not some test-only code.

Kind regards,
Pavel Fedin
Expert Engineer
Samsung Electronics Research center Russia

More information about the libvir-list mailing list