On Tue, Jun 24, 2008 at 05:03:16PM +0100, Daniel P. Berrange wrote:
This patch ports the Test driver over to the domain XML apis.
Basically the 'struct _testDom' is removed, and replaced by usage of the
generic virDomainObjPtr and virDomainDefPtr objects. The XML parser
and formatters are ripped out and replaced by calls to the generic APIs
in domain_conf.h. Finally there is just alot of cleanup of all the
individual domain driver implementations to adjust to the style of the
new APIs used.
Big cleanup, less code and more functionalities, yay !
This actually dramatically increases the functionality of the test
driver - previously its XML parser didn't support any of the <device>
section in the XML. This should make it much more useful for advanced
apps like virt-manager
and more advanced regression tests like for the bindings.
+
+static const char *defaultDomainXML =
+"<domain type='test'>"
+" <name>test</name>"
+" <memory>8388608</memory>"
+" <currentMemory>2097152</currentMemory>"
+" <vcpu>2</vcpu>"
+" <os>"
+" <type>hvm</type>"
+" </os>"
shouldn't we add a couple of device (one disk, one net) for good measure here ?
+"</domain>";
+
[...]
+ if (ret > 0) {
+ for (i = 0 ; i < ret ; i++) {
+ xmlChar *netFile = xmlGetProp(domains[i], BAD_CAST "file");
+ char *absFile = testBuildFilename(file, (const char *)netFile);
+ VIR_FREE(netFile);
+ if (!absFile) {
+ testError(NULL, NULL, NULL, VIR_ERR_INTERNAL_ERROR, _("resolving
domain filename"));
+ goto error;
+ }
+ if ((dom = testLoadDomainFromFile(conn, absFile)) == NULL) {
+ VIR_FREE(absFile);
+ goto error;
+ }
+ dom->state = VIR_DOMAIN_RUNNING;
+ dom->def->id = privconn->nextDomID++;
+ dom->persistent = 1;
+ dom->configFile = absFile;
+ }
+ if (domains != NULL) {
+ VIR_FREE(domains);
+ domains = NULL;
+ }
}
One thing i'm wondering is if we couldn't do single instance XML definitions
for tests including the domains, network, etc... just reusing the new routines
to parse up the full set. that way a test could be defined as a single
standalone file, we could also easilly get testing of the full set of parsing
code just by using the test driver pointing to xml test instances.
This just push the actual test configuration one step further, and
actually I would not be too annnoyed to break some existing support in the
test driver to gte that more complete and convenient coverage.
What do you think ?
+1 for the patch
Daniel
--
Red Hat Virtualization group
http://redhat.com/virtualization/
Daniel Veillard | virtualization library
http://libvirt.org/
veillard(a)redhat.com | libxml GNOME XML XSLT toolkit
http://xmlsoft.org/
http://veillard.com/ | Rpmfind RPM search engine
http://rpmfind.net/