[libvirt] [PATCH V5 01/12] src/xenxs: Export code for reuse
David kiarie
davidkiarie4 at gmail.com
Tue Aug 12 05:31:02 UTC 2014
On Tue, Aug 12, 2014 at 12:21 AM, Kiarie Kahurani
<davidkiarie4 at gmail.com> wrote:
> wrap code tagged for resuse into one function and export it
>
> Signed-off-by: Kiarie Kahurani <davidkiarie4 at gmail.com>
> ---
> src/xenxs/xen_xm.c | 73 +++++++++++++++++++++++++++++++-----------------------
> src/xenxs/xen_xm.h | 2 ++
> 2 files changed, 44 insertions(+), 31 deletions(-)
>
> diff --git a/src/xenxs/xen_xm.c b/src/xenxs/xen_xm.c
> index f70b395..8238026 100644
> --- a/src/xenxs/xen_xm.c
> +++ b/src/xenxs/xen_xm.c
> @@ -1263,59 +1263,70 @@ xenParseXMOS(virConfPtr conf, virDomainDefPtr def)
> }
>
>
> -/*
> - * Turn a config record into a lump of XML describing the
> - * domain, suitable for later feeding for virDomainCreateXML
> - */
> -virDomainDefPtr
> -xenParseXM(virConfPtr conf, int xendConfigVersion,
> - virCapsPtr caps)
> +int
> +xenParseConfigCommon(virConfPtr conf, virDomainDefPtr def,
> + virCapsPtr caps, int xendConfigVersion)
> {
> - virDomainDefPtr def = NULL;
> -
> - if (VIR_ALLOC(def) < 0)
> - return NULL;
> -
> - def->virtType = VIR_DOMAIN_VIRT_XEN;
> - def->id = -1;
>
> if (xenParseXMGeneralMeta(conf, def, caps) < 0)
> - goto cleanup;
> + return -1;
>
> if (xenParseXMOS(conf, def) < 0)
> - goto cleanup;
> + return -1;
>
> if (xenParseXMMem(conf, def) < 0)
> - goto cleanup;
> + return -1;
> +
> + if (xenParseXMTimeOffset(conf, def, xendConfigVersion) < 0)
> + return -1;
>
> if (xenParseXMEventsActions(conf, def) < 0)
> - goto cleanup;
> + return -1;
> +
> + if (xenParseXMPCI(conf, def) < 0)
> + return -1;
>
> if (xenParseXMCPUFeatures(conf, def) < 0)
> - goto cleanup;
> + return -1;
>
> - if (xenParseXMTimeOffset(conf, def, xendConfigVersion) < 0)
> - goto cleanup;
> + if (xenParseXMEmulatedDevices(conf, def) < 0)
> + return -1;
>
> - if (xenParseXMDisk(conf, def, xendConfigVersion) < 0)
> - goto cleanup;
> + if (xenParseXMCharDev(conf, def) < 0)
> + return -1;
> +
> + if (xenParseXMVfb(conf, def, xendConfigVersion) < 0)
> + return -1;
>
> if (xenXMConfigCopyStringOpt(conf, "device_model", &def->emulator) < 0)
> - goto cleanup;
> + return -1;
I guess this should come of too; its already taken care of by xenParseXMOS.
>
> if (xenParseXMVif(conf, def) < 0)
> - goto cleanup;
> + return -1;
>
> - if (xenParseXMPCI(conf, def) < 0)
> - goto cleanup;
> + return 0;
> +}
>
> - if (xenParseXMEmulatedDevices(conf, def) < 0)
> - goto cleanup;
> +/*
> + * Turn a config record into a lump of XML describing the
> + * domain, suitable for later feeding for virDomainCreateXML
> + */
> +virDomainDefPtr
> +xenParseXM(virConfPtr conf, int xendConfigVersion,
> + virCapsPtr caps)
> +{
> + virDomainDefPtr def = NULL;
>
> - if (xenParseXMVfb(conf, def, xendConfigVersion) < 0)
> + if (VIR_ALLOC(def) < 0)
> + return NULL;
> +
> + def->virtType = VIR_DOMAIN_VIRT_XEN;
> + def->id = -1;
> +
> + if (xenParseConfigCommon(conf, def, caps, xendConfigVersion) < 0)
> goto cleanup;
>
> - if (xenParseXMCharDev(conf, def) < 0)
> + if (xenParseXMDisk(conf, def, xendConfigVersion) < 0)
> goto cleanup;
>
> return def;
> diff --git a/src/xenxs/xen_xm.h b/src/xenxs/xen_xm.h
> index 629a4b3..261ba1f 100644
> --- a/src/xenxs/xen_xm.h
> +++ b/src/xenxs/xen_xm.h
> @@ -35,5 +35,7 @@ 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
>
More information about the libvir-list
mailing list