# HG changeset patch
# User Dan Smith <danms(a)us.ibm.com>
# Date 1199911995 28800
# Node ID a32cbc024d15b65dce1841025fafec5477614953
# Parent a229f95979d52c955d46b93c589fd1cf4744ee27
Add get_dominfo_from_xml() function to device_parsing
Signed-off-by: Dan Smith <danms(a)us.ibm.com>
diff -r a229f95979d5 -r a32cbc024d15 libxkutil/device_parsing.c
--- a/libxkutil/device_parsing.c Wed Jan 09 12:53:15 2008 -0800
+++ b/libxkutil/device_parsing.c Wed Jan 09 12:53:15 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 a229f95979d5 -r a32cbc024d15 libxkutil/device_parsing.h
--- a/libxkutil/device_parsing.h Wed Jan 09 12:53:15 2008 -0800
+++ b/libxkutil/device_parsing.h Wed Jan 09 12:53:15 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);