From: Kiarie Kahurani <davidkiarie4(a)gmail.com>
In the refactored code I have wrapped common code in
one function that I will use latter
signed-off-by: David Kiarie<davidkiarie4(a)gmail.com>
---
src/xenxs/xen_xm.c | 60 +++++++++++++++++++++++++++++++++++++-----------------
src/xenxs/xen_xm.h | 2 ++
2 files changed, 43 insertions(+), 19 deletions(-)
diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
index 157d7d3..289f0ad 100644
--- a/src/xenxs/xen_xm.c
+++ b/src/xenxs/xen_xm.c
@@ -1253,6 +1253,46 @@ int xenParseXMGeneralMeta(virConfPtr conf, virDomainDefPtr def,
return 0;
}
+
+
+int xenParseConfigCommon(virConfPtr conf, virDomainDefPtr def,
+ virCapsPtr caps, int xendConfigVersion)
+{
+
+ if (xenParseXMGeneralMeta(conf, def, caps) < 0)
+ return -1;
+
+ if (xenParseXMOS(conf, def) < 0)
+ return -1;
+
+ if (xenParseXMMem(conf, def) < 0)
+ return -1;
+
+ if (xenParseXMTimeOffset(conf, def, xendConfigVersion) < 0)
+ return -1;
+
+ if (xenParseXMEventsActions(conf, def) < 0)
+ return -1;
+
+ if (xenParseXMPCI(conf, def) < 0)
+ return -1;
+
+ if (xenParseXMCPUFeatures(conf, def) < 0)
+ return -1;
+
+ if (xenParseXMEmulatedDevices(conf, def) < 0)
+ return -1;
+
+ if (xenParseXMCharDev(conf, def) < 0)
+ return -1;
+
+ if (xenParseXMVfb(conf, def, xendConfigVersion) < 0)
+ return -1;
+
+ return 0;
+}
+
+
virDomainDefPtr
xenParseXM(virConfPtr conf, int xendConfigVersion,
virCapsPtr caps)
@@ -1264,30 +1304,12 @@ xenParseXM(virConfPtr conf, int xendConfigVersion,
def->virtType = VIR_DOMAIN_VIRT_XEN;
def->id = -1;
- if (xenParseXMGeneralMeta(conf, def, caps) < 0)
- goto cleanup;
- if (xenParseXMOS(conf, def) < 0)
- goto cleanup;
- if (xenParseXMMem(conf, def) < 0)
- goto cleanup;
- if (xenParseXMEventsActions(conf, def) < 0)
- goto cleanup;
- if (xenParseXMTimeOffset(conf, def, xendConfigVersion) < 0)
- goto cleanup;
- if (xenParseXMCPUFeatures(conf, def) < 0)
+ if (xenParseConfigCommon(conf, def, caps, xendConfigVersion) < 0)
goto cleanup;
if (xenParseXMDisk(conf, def, xendConfigVersion) < 0)
goto cleanup;
- if (xenParseXMVfb(conf, def, xendConfigVersion) < 0)
- goto cleanup;
if (xenParseXMVif(conf, def) < 0)
goto cleanup;
- if (xenParseXMPCI(conf, def) < 0)
- goto cleanup;
- if (xenParseXMEmulatedDevices(conf, def) < 0)
- goto cleanup;
- if (xenParseXMCharDev(conf, def) < 0)
- goto cleanup;
return def;
cleanup:
diff --git a/src/xenxs/xen_xm.h b/src/xenxs/xen_xm.h
index 629a4b3..69a2d44 100644
--- a/src/xenxs/xen_xm.h
+++ b/src/xenxs/xen_xm.h
@@ -36,4 +36,6 @@ virConfPtr xenFormatXM(virConnectPtr conn, virDomainDefPtr def,
virDomainDefPtr xenParseXM(virConfPtr conf, int xendConfigVersion,
virCapsPtr caps);
+int xenParseConfigCommon(virConfPtr conf, virDomainDefPtr def,
+ virCapsPtr caps, int xendConfigVersion);
#endif /* __VIR_XEN_XM_H__ */
--
1.8.4.5