[Libvirt-cim] [PATCH] Restructure infostore to facilitate code reuse of some functions
Richard Maciel
rmaciel at linux.vnet.ibm.com
Tue Oct 13 16:02:04 UTC 2009
+1
On 10/12/2009 03:51 PM, Kaitlin Rupert wrote:
> # HG changeset patch
> # User Kaitlin Rupert<karupert at us.ibm.com>
> # Date 1255007573 25200
> # Node ID 65f03165609a2291ff6ab4dcb774087055b6d568
> # Parent 10f3bc589ff7754578b96b77a735526425d1e212
> Restructure infostore to facilitate code reuse of some functions
>
> These changes are to prepare for some upcoming patches. Those patches will
> create a job store, which will be used to persist job instances.
>
> Signed-off-by: Kaitlin Rupert<karupert at us.ibm.com>
>
> diff -r 10f3bc589ff7 -r 65f03165609a libxkutil/infostore.c
> --- a/libxkutil/infostore.c Wed Oct 07 11:50:59 2009 -0700
> +++ b/libxkutil/infostore.c Thu Oct 08 06:12:53 2009 -0700
> @@ -168,11 +168,10 @@
> return size>= 0;
> }
>
> -static struct infostore_ctx *_infostore_open(virDomainPtr dom)
> +static struct infostore_ctx *_generic_infostore_open(char *filename)
> {
> struct infostore_ctx *isc;
> struct stat s;
> - char *filename = NULL;
>
> isc = calloc(1, sizeof(*isc));
> if (isc == NULL) {
> @@ -180,10 +179,6 @@
> return NULL;
> }
>
> - filename = make_filename(dom);
> - if (filename == NULL)
> - goto err;
> -
> isc->fd = open(filename, O_RDWR|O_CREAT, 0600);
> if (isc->fd< 0) {
> CU_DEBUG("Unable to open `%s': %m", filename);
> @@ -212,6 +207,27 @@
> goto err;
> }
>
> + return isc;
> +
> + err:
> + infostore_cleanup_ctx(isc);
> +
> + return NULL;
> +}
> +
> +static struct infostore_ctx *_infostore_open(virDomainPtr dom)
> +{
> + struct infostore_ctx *isc = NULL;
> + char *filename = NULL;
> +
> + filename = make_filename(dom);
> + if (filename == NULL)
> + return NULL;
> +
> + isc = _generic_infostore_open(filename);
> + if (isc == NULL)
> + return NULL;
> +
> if (!xmlStrEqual(isc->root->name, BAD_CAST "dominfo")) {
> CU_DEBUG("XML does not start with<dominfo>");
> goto err;
> @@ -286,7 +302,7 @@
> return isc;
> }
>
> -void infostore_close(struct infostore_ctx *ctx)
> +static void _infostore_close(struct infostore_ctx *ctx)
> {
> if (ctx == NULL)
> return;
> @@ -295,6 +311,11 @@
> infostore_cleanup_ctx(ctx);
> }
>
> +void infostore_close(struct infostore_ctx *ctx)
> +{
> + _infostore_close(ctx);
> +}
> +
> void infostore_delete(const char *type, const char *name)
> {
> char *path = NULL;
>
> _______________________________________________
> Libvirt-cim mailing list
> Libvirt-cim at redhat.com
> https://www.redhat.com/mailman/listinfo/libvirt-cim
--
Richard Maciel, MSc
IBM Linux Technology Center
rmaciel at linux.vnet.ibm.com
More information about the Libvirt-cim
mailing list