const char *iface;
const char *state;
char *value;
- char *desc;
virMacAddr macaddr;
const char *element;
const char *attr;
bool config;
bool ret = false;
unsigned int flags = 0;
+ unsigned int xmlflags = 0;
size_t i;
xmlDocPtr xml = NULL;
xmlXPathContextPtr ctxt = NULL;
goto cleanup;
}
- /* get persistent or live description of network device */
- desc = virDomainGetXMLDesc(dom, config ? VIR_DOMAIN_XML_INACTIVE : 0);
- if (desc == NULL) {
- vshError(ctl, _("Failed to get domain description xml"));
- goto cleanup;
- }
-
- if (config)
+ if (config) {
flags = VIR_DOMAIN_AFFECT_CONFIG;
- else
+ xmlflags |= VIR_DOMAIN_XML_INACTIVE;
+ } else {
flags = VIR_DOMAIN_AFFECT_LIVE;
+ }
if (virDomainIsActive(dom) == 0)
flags = VIR_DOMAIN_AFFECT_CONFIG;
- /* extract current network device description */
- xml = virXMLParseStringCtxt(desc, _("(domain_definition)"), &ctxt);
- VIR_FREE(desc);
- if (!xml) {
- vshError(ctl, _("Failed to parse domain description xml"));
+ if (virshDomainGetXMLFromDom(ctl, dom, xmlflags, &xml, &ctxt) < 0)
goto cleanup;
- }
obj = xmlXPathEval(BAD_CAST "/domain/devices/interface", ctxt);
if (obj == NULL || obj->type != XPATH_NODESET ||
int nvol_list = 0;
virshUndefineVolume *vols = NULL; /* info about the volumes to delete*/
size_t nvols = 0;
- char *def = NULL; /* domain def */
xmlDocPtr doc = NULL;
xmlXPathContextPtr ctxt = NULL;
xmlNodePtr *vol_nodes = NULL; /* XML nodes of volumes of the guest */
goto cleanup;
}
- if (!(def = virDomainGetXMLDesc(dom, 0))) {
- vshError(ctl, _("Could not retrieve domain XML description"));
+ if (virshDomainGetXMLFromDom(ctl, dom, 0, &doc, &ctxt) < 0)
goto cleanup;
- }
-
- if (!(doc = virXMLParseStringCtxt(def, _("(domain_definition)"),
- &ctxt)))
- goto error;
/* tokenize the string from user and save its parts into an array */
if (vol_string &&
VIR_FREE(vol_list[i]);
VIR_FREE(vol_list);
- VIR_FREE(def);
VIR_FREE(vol_nodes);
xmlFreeDoc(doc);
xmlXPathFreeContext(ctxt);
int ret = -2;
virDomainInfo info;
int count;
- char *def = NULL;
xmlDocPtr xml = NULL;
xmlXPathContextPtr ctxt = NULL;
count = info.nrVirtCpu;
}
} else {
- if (!(def = virDomainGetXMLDesc(dom, VIR_DOMAIN_XML_INACTIVE)))
- goto cleanup;
-
- if (!(xml = virXMLParseStringCtxt(def, _("(domain_definition)"), &ctxt)))
+ if (virshDomainGetXMLFromDom(ctl, dom, VIR_DOMAIN_XML_INACTIVE,
+ &xml, &ctxt) < 0)
goto cleanup;
if (flags & VIR_DOMAIN_VCPU_MAXIMUM) {
ret = count;
cleanup:
- VIR_FREE(def);
xmlXPathFreeContext(ctxt);
xmlFreeDoc(xml);
bool inactive)
{
unsigned int flags = 0;
- char *def = NULL;
virBitmapPtr ret = NULL;
xmlDocPtr xml = NULL;
xmlXPathContextPtr ctxt = NULL;
if (inactive)
flags |= VIR_DOMAIN_XML_INACTIVE;
- if (!(def = virDomainGetXMLDesc(dom, flags)))
- goto cleanup;
-
- if (!(xml = virXMLParseStringCtxt(def, _("(domain_definition)"), &ctxt)))
+ if (virshDomainGetXMLFromDom(ctl, dom, flags, &xml, &ctxt) < 0)
goto cleanup;
if (virXPathUInt("string(/domain/vcpu)", ctxt, &maxvcpus) < 0) {
VIR_FREE(nodes);
xmlXPathFreeContext(ctxt);
xmlFreeDoc(xml);
- VIR_FREE(def);
return ret;
}
virDomainPtr dom;
virBuffer buf = VIR_BUFFER_INITIALIZER;
bool ret = false;
- char *doc = NULL;
char *xpath = NULL;
char *listen_addr = NULL;
int port, tls_port = 0;
if (vshCommandOptStringReq(ctl, cmd, "type", &type) < 0)
goto cleanup;
- if (!(doc = virDomainGetXMLDesc(dom, flags)))
- goto cleanup;
-
- if (!(xml = virXMLParseStringCtxt(doc, _("(domain_definition)"), &ctxt)))
+ if (virshDomainGetXMLFromDom(ctl, dom, flags, &xml, &ctxt) < 0)
goto cleanup;
/* Attempt to grab our display info */
}
cleanup:
- VIR_FREE(doc);
VIR_FREE(xpath);
VIR_FREE(passwd);
VIR_FREE(listen_addr);
VIR_FREE(output);
xmlXPathFreeContext(ctxt);
xmlFreeDoc(xml);
- virshDomainFree(dom);
return ret;
}
virDomainPtr dom;
bool ret = false;
int port = 0;
- char *doc = NULL;
char *listen_addr = NULL;
if (!(dom = virshCommandOptDomain(ctl, cmd, NULL)))
goto cleanup;
}
- if (!(doc = virDomainGetXMLDesc(dom, 0)))
- goto cleanup;
-
- if (!(xml = virXMLParseStringCtxt(doc, _("(domain_definition)"), &ctxt)))
+ if (virshDomainGetXMLFromDom(ctl, dom, 0, &xml, &ctxt) < 0)
goto cleanup;
/* Get the VNC port */
ret = true;
cleanup:
- VIR_FREE(doc);
VIR_FREE(listen_addr);
xmlXPathFreeContext(ctxt);
xmlFreeDoc(xml);