# HG changeset patch
# User Keir Fraser <keir.fraser@xxxxxxxxxx>
# Date 1262177229 0
# Node ID a4aace0808d2b0516ca5e97084d5763859c4de47
# Parent c21ae3e20134a4fefbb9badf20eea8095751e9c5
libxl: add a versioning number to ctx_init that permit to detect
incompatible client.
at the moment if the versioning of the library is not exactly the same
used in the client then the ctx_init return an ERROR_VERSION. however
the same mechanism can be use in the future to be able to support
older version and offer a compatibility layer.
Signed-off-by: Vincent Hanquez <vincent.hanquez@xxxxxxxxxxxxx>
---
tools/libxl/libxl.c | 6 ++++--
tools/libxl/libxl.h | 4 +++-
tools/libxl/xl.c | 24 ++++++++++++------------
3 files changed, 19 insertions(+), 15 deletions(-)
diff -r c21ae3e20134 -r a4aace0808d2 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c Wed Dec 30 12:46:16 2009 +0000
+++ b/tools/libxl/libxl.c Wed Dec 30 12:47:09 2009 +0000
@@ -34,8 +34,10 @@
#include "libxl_internal.h"
#include "flexarray.h"
-int libxl_ctx_init(struct libxl_ctx *ctx)
-{
+int libxl_ctx_init(struct libxl_ctx *ctx, int version)
+{
+ if (version != LIBXL_VERSION)
+ return ERROR_VERSION;
memset(ctx, 0, sizeof(struct libxl_ctx));
ctx->alloc_maxsize = 256;
ctx->alloc_ptrs = calloc(ctx->alloc_maxsize, sizeof(void *));
diff -r c21ae3e20134 -r a4aace0808d2 tools/libxl/libxl.h
--- a/tools/libxl/libxl.h Wed Dec 30 12:46:16 2009 +0000
+++ b/tools/libxl/libxl.h Wed Dec 30 12:47:09 2009 +0000
@@ -234,8 +234,10 @@ enum {
ERROR_INVAL = -5,
};
+#define LIBXL_VERSION 0
+
/* context functions */
-int libxl_ctx_init(struct libxl_ctx *ctx);
+int libxl_ctx_init(struct libxl_ctx *ctx, int version);
int libxl_ctx_free(struct libxl_ctx *ctx);
int libxl_ctx_set_log(struct libxl_ctx *ctx, libxl_log_callback log_callback,
void *log_data);
diff -r c21ae3e20134 -r a4aace0808d2 tools/libxl/xl.c
--- a/tools/libxl/xl.c Wed Dec 30 12:46:16 2009 +0000
+++ b/tools/libxl/xl.c Wed Dec 30 12:47:09 2009 +0000
@@ -730,7 +730,7 @@ start:
start:
domid = 0;
- libxl_ctx_init(&ctx);
+ libxl_ctx_init(&ctx, LIBXL_VERSION);
libxl_ctx_set_log(&ctx, log_callback, NULL);
libxl_domain_make(&ctx, &info1, &domid);
@@ -942,7 +942,7 @@ void set_memory_target(char *p, char *me
struct libxl_ctx ctx;
uint32_t domid;
- libxl_ctx_init(&ctx);
+ libxl_ctx_init(&ctx, LIBXL_VERSION);
libxl_ctx_set_log(&ctx, log_callback, NULL);
if (libxl_param_to_domid(&ctx, p, &domid) < 0) {
@@ -984,7 +984,7 @@ void console(char *p, int cons_num)
struct libxl_ctx ctx;
uint32_t domid;
- libxl_ctx_init(&ctx);
+ libxl_ctx_init(&ctx, LIBXL_VERSION);
libxl_ctx_set_log(&ctx, log_callback, NULL);
if (libxl_param_to_domid(&ctx, p, &domid) < 0) {
@@ -1001,7 +1001,7 @@ void cd_insert(char *dom, char *virtdev,
libxl_device_disk disk;
char *p;
- libxl_ctx_init(&ctx);
+ libxl_ctx_init(&ctx, LIBXL_VERSION);
libxl_ctx_set_log(&ctx, log_callback, NULL);
if (libxl_param_to_domid(&ctx, dom, &domid) < 0) {
@@ -1134,7 +1134,7 @@ void pcilist(char *dom)
libxl_device_pci *pcidevs;
int num, i;
- libxl_ctx_init(&ctx);
+ libxl_ctx_init(&ctx, LIBXL_VERSION);
libxl_ctx_set_log(&ctx, log_callback, NULL);
if (libxl_param_to_domid(&ctx, dom, &domid) < 0) {
@@ -1184,7 +1184,7 @@ void pcidetach(char *dom, char *bdf)
libxl_device_pci pcidev;
unsigned int domain, bus, dev, func;
- libxl_ctx_init(&ctx);
+ libxl_ctx_init(&ctx, LIBXL_VERSION);
libxl_ctx_set_log(&ctx, log_callback, NULL);
if (libxl_param_to_domid(&ctx, dom, &domid) < 0) {
@@ -1230,7 +1230,7 @@ void pciattach(char *dom, char *bdf, cha
libxl_device_pci pcidev;
unsigned int domain, bus, dev, func;
- libxl_ctx_init(&ctx);
+ libxl_ctx_init(&ctx, LIBXL_VERSION);
libxl_ctx_set_log(&ctx, log_callback, NULL);
if (libxl_param_to_domid(&ctx, dom, &domid) < 0) {
@@ -1278,7 +1278,7 @@ void pause_domain(char *p)
struct libxl_ctx ctx;
uint32_t domid;
- libxl_ctx_init(&ctx);
+ libxl_ctx_init(&ctx, LIBXL_VERSION);
libxl_ctx_set_log(&ctx, log_callback, NULL);
if (libxl_param_to_domid(&ctx, p, &domid) < 0) {
@@ -1293,7 +1293,7 @@ void unpause_domain(char *p)
struct libxl_ctx ctx;
uint32_t domid;
- libxl_ctx_init(&ctx);
+ libxl_ctx_init(&ctx, LIBXL_VERSION);
libxl_ctx_set_log(&ctx, log_callback, NULL);
if (libxl_param_to_domid(&ctx, p, &domid) < 0) {
@@ -1308,7 +1308,7 @@ void destroy_domain(char *p)
struct libxl_ctx ctx;
uint32_t domid;
- libxl_ctx_init(&ctx);
+ libxl_ctx_init(&ctx, LIBXL_VERSION);
libxl_ctx_set_log(&ctx, log_callback, NULL);
if (libxl_param_to_domid(&ctx, p, &domid) < 0) {
@@ -1324,7 +1324,7 @@ void list_domains(void)
struct libxl_dominfo *info;
int nb_domain, i;
- libxl_ctx_init(&ctx);
+ libxl_ctx_init(&ctx, LIBXL_VERSION);
libxl_ctx_set_log(&ctx, log_callback, NULL);
info = libxl_domain_list(&ctx, &nb_domain);
@@ -1351,7 +1351,7 @@ int save_domain(char *p, char *filename,
uint32_t domid;
int fd;
- libxl_ctx_init(&ctx);
+ libxl_ctx_init(&ctx, LIBXL_VERSION);
libxl_ctx_set_log(&ctx, log_callback, NULL);
if (libxl_param_to_domid(&ctx, p, &domid) < 0) {
_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog
|