# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1199911546 28800
# Node ID 1fe9e5492885e9af358f392c01ff6a88b613ab96
# Parent f04c92eecc4513ea251084e02e078bb22fa75daa
Add get_dominfo_from_xml() function to device_parsing
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r f04c92eecc45 -r 1fe9e5492885 libxkutil/device_parsing.c
--- a/libxkutil/device_parsing.c Wed Jan 09 12:45:45 2008 -0800
+++ b/libxkutil/device_parsing.c Wed Jan 09 12:45:46 2008 -0800
@@ -742,28 +742,17 @@ static int _get_dominfo(const char *xml,
return ret;
}
-int get_dominfo(virDomainPtr dom, struct domain **dominfo)
-{
- char *xml;
+int get_dominfo_from_xml(const char *xml, struct domain **dominfo)
+{
int ret;
*dominfo = malloc(sizeof(**dominfo));
if (*dominfo == NULL)
return 0;
- xml = virDomainGetXMLDesc(dom, 0);
- if (xml == NULL) {
- free(*dominfo);
- *dominfo = NULL;
- return 0;
- }
-
ret = _get_dominfo(xml, *dominfo);
- if (ret == 0) {
- free(*dominfo);
- *dominfo = NULL;
- goto out;
- }
+ if (ret == 0)
+ goto err;
parse_devices(xml, &(*dominfo)->dev_emu, VIRT_DEV_EMU);
parse_devices(xml, &(*dominfo)->dev_graphics, VIRT_DEV_GRAPHICS);
@@ -778,7 +767,27 @@ int get_dominfo(virDomainPtr dom, struct
(*dominfo)->dev_vcpu_ct = parse_devices(xml,
&(*dominfo)->dev_vcpu,
VIRT_DEV_VCPU);
-out:
+
+ return ret;
+
+ err:
+ free(*dominfo);
+ *dominfo = NULL;
+
+ return 0;
+}
+
+int get_dominfo(virDomainPtr dom, struct domain **dominfo)
+{
+ char *xml;
+ int ret;
+
+ xml = virDomainGetXMLDesc(dom, 0);
+ if (xml == NULL)
+ return 0;
+
+ ret = get_dominfo_from_xml(xml, dominfo);
+
free(xml);
return ret;
diff -r f04c92eecc45 -r 1fe9e5492885 libxkutil/device_parsing.h
--- a/libxkutil/device_parsing.h Wed Jan 09 12:45:45 2008 -0800
+++ b/libxkutil/device_parsing.h Wed Jan 09 12:45:46 2008 -0800
@@ -134,6 +134,7 @@ int disk_type_from_file(const char *path
int disk_type_from_file(const char *path);
int get_dominfo(virDomainPtr dom, struct domain **dominfo);
+int get_dominfo_from_xml(const char *xml, struct domain **dominfo);
void cleanup_dominfo(struct domain **dominfo);