+Thu, 4 Dec 2008 12:46:01 CET Guido Günther <agx@sigxcpu.org>
+
+ Differentiate between active and inactive configs by honoring the
+ VIR_DOMAIN_XML_INACTIVE flag.
+ * src/domain_conf.c (virDomainDefParseXML): add and pass on flags arg
+ (virDomainDefParseFile): Likewise
+ (virDomainDefParseNode): Likewise
+ (virDomainGraphicsDefParseXML): Likewise
+ * src/domain_conf.c (virDomainDefParseXML): only restore domain id if
+ !VIR_DOMAIN_XML_INACTIVE
+ * src/domain_conf. (virDomainGraphicsDefParseXML): only restore vnc
+ port if !VIR_DOMAIN_XML_INACTIVE
+ * src/lxc_driver.c (lxcStartup): pass 0 flag since we restore life
+ config
+ * src/lxc_controller.c: pass VIR_DOMAIN_XML_INACTIVE
+ * src/test.c: pass VIR_DOMAIN_XML_INACTIVE
+ * tests/qemuxml2argvtest.c: pass VIR_DOMAIN_XML_INACTIVE
+
Thu, 4 Dec 2008 11:41:12 CET Guido Günther <agx@sigxcpu.org>
* src/qemu_driver.c: also look for /usr/bin/kvm
/* Parse the XML definition for a graphics device */
static virDomainGraphicsDefPtr
virDomainGraphicsDefParseXML(virConnectPtr conn,
- xmlNodePtr node) {
+ xmlNodePtr node, int flags) {
virDomainGraphicsDefPtr def;
char *type = NULL;
VIR_FREE(port);
/* Legacy compat syntax, used -1 for auto-port */
if (def->data.vnc.port == -1) {
- def->data.vnc.port = 0;
+ if (flags & VIR_DOMAIN_XML_INACTIVE)
+ def->data.vnc.port = 0;
def->data.vnc.autoport = 1;
}
} else {
if ((autoport = virXMLPropString(node, "autoport")) != NULL) {
if (STREQ(autoport, "yes")) {
- def->data.vnc.port = 0;
+ if (flags & VIR_DOMAIN_XML_INACTIVE)
+ def->data.vnc.port = 0;
def->data.vnc.autoport = 1;
}
VIR_FREE(autoport);
#ifndef PROXY
static virDomainDefPtr virDomainDefParseXML(virConnectPtr conn,
virCapsPtr caps,
- xmlXPathContextPtr ctxt)
+ xmlXPathContextPtr ctxt, int flags)
{
xmlNodePtr *nodes = NULL, node = NULL;
char *tmp = NULL;
int i, n;
+ long id = -1;
virDomainDefPtr def;
if (VIR_ALLOC(def) < 0) {
"%s", _("failed to allocate space for xmlXPathContext"));
return NULL;
}
- def->id = -1;
+
+ if (!(flags & VIR_DOMAIN_XML_INACTIVE))
+ if((virXPathLong(conn, "string(./@id)", ctxt, &id)) < 0)
+ id = -1;
+ def->id = (int)id;
/* Find out what type of virtualization to use */
if (!(tmp = virXPathString(conn, "string(./@type)", ctxt))) {
}
if (n > 0) {
virDomainGraphicsDefPtr graphics = virDomainGraphicsDefParseXML(conn,
- nodes[0]);
+ nodes[0],
+ flags);
if (!graphics)
goto error;
goto cleanup;
}
- def = virDomainDefParseNode(conn, caps, xml, root);
+ def = virDomainDefParseNode(conn, caps, xml, root,
+ VIR_DOMAIN_XML_INACTIVE);
cleanup:
xmlFreeParserCtxt (pctxt);
virDomainDefPtr virDomainDefParseFile(virConnectPtr conn,
virCapsPtr caps,
- const char *filename)
+ const char *filename, int flags)
{
xmlParserCtxtPtr pctxt;
xmlDocPtr xml = NULL;
goto cleanup;
}
- def = virDomainDefParseNode(conn, caps, xml, root);
+ def = virDomainDefParseNode(conn, caps, xml, root, flags);
cleanup:
xmlFreeParserCtxt (pctxt);
virDomainDefPtr virDomainDefParseNode(virConnectPtr conn,
virCapsPtr caps,
xmlDocPtr xml,
- xmlNodePtr root)
+ xmlNodePtr root,
+ int flags)
{
xmlXPathContextPtr ctxt = NULL;
virDomainDefPtr def = NULL;
}
ctxt->node = root;
- def = virDomainDefParseXML(conn, caps, ctxt);
+ def = virDomainDefParseXML(conn, caps, ctxt, flags);
cleanup:
xmlXPathFreeContext(ctxt);
if ((autostart = virFileLinkPointsTo(autostartLink, configFile)) < 0)
goto error;
- if (!(def = virDomainDefParseFile(conn, caps, configFile)))
+ if (!(def = virDomainDefParseFile(conn, caps, configFile,
+ VIR_DOMAIN_XML_INACTIVE)))
goto error;
if (virDomainFindByName(doms, def->name))
testError(NULL, VIR_ERR_INTERNAL_ERROR, "%s", _("resolving domain filename"));
goto error;
}
- def = virDomainDefParseFile(conn, privconn->caps, absFile);
+ def = virDomainDefParseFile(conn, privconn->caps, absFile,
+ VIR_DOMAIN_XML_INACTIVE);
VIR_FREE(absFile);
if (!def)
goto error;
} else {
- if ((def = virDomainDefParseNode(conn, privconn->caps, xml, domains[i])) == NULL)
+ if ((def = virDomainDefParseNode(conn, privconn->caps, xml, domains[i],
+ VIR_DOMAIN_XML_INACTIVE)) == NULL)
goto error;
}