From: Wei Liu <wei.liu2@citrix.com>
To: xen-devel@lists.xen.org
Cc: Wei Liu <wei.liu2@citrix.com>,
ian.jackson@eu.citrix.com, ian.campbell@citrix.com
Subject: [PATCH v1 01/10] libxl: libxl-json format and internal functions to get / set it
Date: Thu, 10 Jul 2014 15:32:16 +0100 [thread overview]
Message-ID: <1405002745-5034-2-git-send-email-wei.liu2@citrix.com> (raw)
In-Reply-To: <1405002745-5034-1-git-send-email-wei.liu2@citrix.com>
Introduce a new format in libxl userdata store called "libxl-json". This
file format contains JSON version of libxl_domain_config, generated by
libxl.
Two internal functions to get and set libxl_domain_configuration
are also introduced.
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
tools/libxl/libxl.h | 2 ++
tools/libxl/libxl_internal.c | 56 ++++++++++++++++++++++++++++++++++++++++++
tools/libxl/libxl_internal.h | 10 ++++++++
3 files changed, 68 insertions(+)
diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index e6e0301..2dc6a51 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -1182,6 +1182,8 @@ void libxl_cpuid_set(libxl_ctx *ctx, uint32_t domid,
* "xl" domain config file in xl format, Unix line endings
* "libvirt-xml" domain config file in libvirt XML format. See
* http://libvirt.org/formatdomain.html
+ * "libxl-json" libxl_domain_config object in JSON format, generated
+ * by libxl
*
* libxl does not enforce the registration of userdata userids or the
* semantics of the data. For specifications of the data formats
diff --git a/tools/libxl/libxl_internal.c b/tools/libxl/libxl_internal.c
index 81f8985..dc47177 100644
--- a/tools/libxl/libxl_internal.c
+++ b/tools/libxl/libxl_internal.c
@@ -381,6 +381,62 @@ out:
return rc;
}
+int libxl__get_domain_configuration(libxl__gc *gc, uint32_t domid,
+ libxl_domain_config *d_config)
+{
+ uint8_t *data = NULL;
+ int rc, len;
+
+ rc = libxl_userdata_retrieve(CTX, domid, "libxl-json", &data, &len);
+ if (rc) {
+ LOGEV(ERROR, rc,
+ "failed to retrieve domain configuration for domain %d", domid);
+ rc = ERROR_FAIL;
+ goto out;
+ }
+
+ if (len == 0) {
+ LOGE(ERROR, "configuration data stream empty for domain %d", domid);
+ rc = ERROR_FAIL;
+ goto out;
+ }
+ rc = libxl_domain_config_from_json(CTX, d_config, (const char *)data);
+
+out:
+ free(data);
+ return rc;
+}
+
+int libxl__set_domain_configuration(libxl__gc *gc, uint32_t domid,
+ libxl_domain_config *d_config)
+{
+ char *d_config_json;
+ int rc;
+
+ d_config_json = libxl_domain_config_to_json(CTX, d_config);
+ if (!d_config_json) {
+ LOGE(ERROR, "failed to convert domain configuration to JSON for domain %d",
+ domid);
+ rc = ERROR_FAIL;
+ goto out;
+ }
+
+ rc = libxl_userdata_store(CTX, domid, "libxl-json",
+ (const uint8_t *)d_config_json,
+ strlen(d_config_json) + 1 /* include '\0' */);
+ if (rc) {
+ LOGEV(ERROR, rc, "failed to store domain configuration for domain %d",
+ domid);
+ rc = ERROR_FAIL;
+ goto out;
+ }
+
+out:
+ free(d_config_json);
+ return rc;
+}
+
+
/*
* Local variables:
* mode: C
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index beb052e..ef2111b 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -3219,6 +3219,16 @@ static inline int libxl__key_value_list_is_empty(libxl_key_value_list *pkvl)
int libxl__cpuid_policy_is_empty(libxl_cpuid_policy_list *pl);
+/*
+ * Retrieve / store domain configuration from / to libxl private
+ * data store. The registry entry in libxl private data store
+ * is "libxl-json".
+ */
+int libxl__get_domain_configuration(libxl__gc *gc, uint32_t domid,
+ libxl_domain_config *d_config);
+int libxl__set_domain_configuration(libxl__gc *gc, uint32_t domid,
+ libxl_domain_config *d_config);
+
#endif
/*
--
1.7.10.4
next prev parent reply other threads:[~2014-07-10 14:32 UTC|newest]
Thread overview: 70+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-07-10 14:32 [PATCH v1 00/10] libxl: synchronise domain configuration Wei Liu
2014-07-10 14:32 ` Wei Liu [this message]
2014-07-16 16:11 ` [PATCH v1 01/10] libxl: libxl-json format and internal functions to get / set it Ian Campbell
2014-07-16 16:44 ` Wei Liu
2014-07-24 18:09 ` Ian Jackson
2014-07-24 18:29 ` Ian Jackson
2014-07-25 10:30 ` Wei Liu
2014-07-25 14:51 ` Ian Jackson
2014-07-10 14:32 ` [PATCH v1 02/10] libxl_internal: functions to lock / unlock domain configuration Wei Liu
2014-07-16 16:15 ` Ian Campbell
2014-07-16 16:44 ` Wei Liu
2014-07-17 11:29 ` Ian Campbell
2014-07-17 11:41 ` Wei Liu
2014-07-17 11:48 ` Ian Campbell
2014-07-24 18:24 ` Ian Jackson
2014-07-25 10:36 ` Wei Liu
2014-07-10 14:32 ` [PATCH v1 03/10] libxl: store a copy of vanilla domain configuration when creating domain Wei Liu
2014-07-16 16:18 ` Ian Campbell
2014-07-16 16:47 ` Wei Liu
2014-07-17 11:06 ` Ian Campbell
2014-07-17 11:46 ` Wei Liu
2014-07-24 18:52 ` Ian Jackson
2014-07-25 10:53 ` Wei Liu
2014-07-25 15:01 ` Ian Jackson
2014-07-25 15:43 ` Wei Liu
2014-07-25 17:14 ` Ian Jackson
2014-07-25 17:34 ` Wei Liu
2014-07-25 18:31 ` Ian Jackson
2014-07-25 19:47 ` Wei Liu
2014-07-28 9:42 ` Ian Campbell
2014-07-28 9:50 ` Ian Jackson
2014-07-10 14:32 ` [PATCH v1 04/10] libxl: separate device add/rm complete callbacks Wei Liu
2014-07-16 16:26 ` Ian Campbell
2014-07-16 16:48 ` Wei Liu
2014-07-10 14:32 ` [PATCH v1 05/10] libxl: synchronise configuration when we hotplug a device Wei Liu
2014-07-16 16:48 ` Ian Campbell
2014-07-16 17:12 ` Wei Liu
2014-07-17 11:44 ` Ian Campbell
2014-07-17 14:13 ` Wei Liu
2014-07-18 8:49 ` Ian Campbell
2014-07-18 11:22 ` Wei Liu
2014-07-18 12:20 ` Ian Campbell
2014-07-18 13:41 ` Wei Liu
2014-07-18 13:44 ` Ian Campbell
2014-07-25 16:06 ` Ian Jackson
2014-07-25 16:40 ` Wei Liu
2014-07-25 17:11 ` Ian Jackson
2014-07-25 17:19 ` Wei Liu
2014-07-10 14:32 ` [PATCH v1 06/10] libxl: synchronise configuration when we remove/destroy " Wei Liu
2014-07-16 16:58 ` Ian Campbell
2014-07-10 14:32 ` [PATCH v1 07/10] libxl: make libxl_cd_insert "eject" + "insert" Wei Liu
2014-07-17 10:44 ` Ian Campbell
2014-07-17 14:20 ` Wei Liu
2014-07-10 14:32 ` [PATCH v1 08/10] libxl: introduce libxl_get_memory_static_max Wei Liu
2014-07-17 10:47 ` Ian Campbell
2014-07-17 12:02 ` Wei Liu
2014-07-17 13:59 ` Ian Campbell
2014-07-29 13:39 ` Ian Jackson
2014-07-10 14:32 ` [PATCH v1 09/10] libxl: introduce libxl_retrieve_domain_configuration Wei Liu
2014-07-17 10:59 ` Ian Campbell
2014-07-17 12:11 ` Wei Liu
2014-07-17 14:02 ` Ian Campbell
2014-07-17 14:28 ` Wei Liu
2014-07-18 8:52 ` Ian Campbell
2014-07-18 11:17 ` Wei Liu
2014-07-29 15:31 ` Ian Jackson
2014-07-29 15:29 ` Ian Jackson
2014-07-10 14:32 ` [PATCH v1 10/10] xl: use libxl_retrieve_domain_configuration and JSON format Wei Liu
2014-07-17 11:13 ` Ian Campbell
2014-07-17 12:14 ` Wei Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1405002745-5034-2-git-send-email-wei.liu2@citrix.com \
--to=wei.liu2@citrix.com \
--cc=ian.campbell@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=xen-devel@lists.xen.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.