aboutsummaryrefslogtreecommitdiffstats
path: root/tools/libxen
diff options
context:
space:
mode:
authorEwan Mellor <ewan@xensource.com>2007-03-17 23:55:03 +0000
committerEwan Mellor <ewan@xensource.com>2007-03-17 23:55:03 +0000
commit98321440ec5681052fc4cadfaed5471b01cfd451 (patch)
tree2781b355ce6569d1341c74dc33f3650369fd2501 /tools/libxen
parent716d0617c936b721deb6fc2212add0acca58af32 (diff)
downloadxen-98321440ec5681052fc4cadfaed5471b01cfd451.tar.gz
xen-98321440ec5681052fc4cadfaed5471b01cfd451.tar.bz2
xen-98321440ec5681052fc4cadfaed5471b01cfd451.zip
Replace VDI.location with a more generic VDI.other_config map. Remove
VDI.sector_size. Xend work by Tom Wilkie <tom.wilkie@gmail.com>. Signed-off-by: Ewan Mellor <ewan@xensource.com>
Diffstat (limited to 'tools/libxen')
-rw-r--r--tools/libxen/include/xen_vbd.h1
-rw-r--r--tools/libxen/include/xen_vdi.h44
-rw-r--r--tools/libxen/src/xen_vbd.c3
-rw-r--r--tools/libxen/src/xen_vdi.c90
-rw-r--r--tools/libxen/test/test_bindings.c3
5 files changed, 105 insertions, 36 deletions
diff --git a/tools/libxen/include/xen_vbd.h b/tools/libxen/include/xen_vbd.h
index 7b36266a04..14a6685a95 100644
--- a/tools/libxen/include/xen_vbd.h
+++ b/tools/libxen/include/xen_vbd.h
@@ -72,7 +72,6 @@ typedef struct xen_vbd_record
struct xen_vm_record_opt *vm;
struct xen_vdi_record_opt *vdi;
char *device;
- char *image;
bool bootable;
enum xen_vbd_mode mode;
enum xen_vbd_type type;
diff --git a/tools/libxen/include/xen_vdi.h b/tools/libxen/include/xen_vdi.h
index 26e147250e..9ebb8fd9ee 100644
--- a/tools/libxen/include/xen_vdi.h
+++ b/tools/libxen/include/xen_vdi.h
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, XenSource Inc.
+ * Copyright (c) 2006-2007, XenSource Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -22,6 +22,7 @@
#include "xen_common.h"
#include "xen_crashdump_decl.h"
#include "xen_sr_decl.h"
+#include "xen_string_string_map.h"
#include "xen_vbd_decl.h"
#include "xen_vdi_decl.h"
#include "xen_vdi_type.h"
@@ -73,11 +74,10 @@ typedef struct xen_vdi_record
struct xen_crashdump_record_opt_set *crash_dumps;
int64_t virtual_size;
int64_t physical_utilisation;
- int64_t sector_size;
- char *location;
enum xen_vdi_type type;
bool sharable;
bool read_only;
+ xen_string_string_map *other_config;
} xen_vdi_record;
/**
@@ -251,13 +251,6 @@ xen_vdi_get_physical_utilisation(xen_session *session, int64_t *result, xen_vdi
/**
- * Get the sector_size field of the given VDI.
- */
-extern bool
-xen_vdi_get_sector_size(xen_session *session, int64_t *result, xen_vdi vdi);
-
-
-/**
* Get the type field of the given VDI.
*/
extern bool
@@ -279,6 +272,13 @@ xen_vdi_get_read_only(xen_session *session, bool *result, xen_vdi vdi);
/**
+ * Get the other_config field of the given VDI.
+ */
+extern bool
+xen_vdi_get_other_config(xen_session *session, xen_string_string_map **result, xen_vdi vdi);
+
+
+/**
* Set the name/label field of the given VDI.
*/
extern bool
@@ -314,6 +314,30 @@ xen_vdi_set_read_only(xen_session *session, xen_vdi vdi, bool read_only);
/**
+ * Set the other_config field of the given VDI.
+ */
+extern bool
+xen_vdi_set_other_config(xen_session *session, xen_vdi vdi, xen_string_string_map *other_config);
+
+
+/**
+ * Add the given key-value pair to the other_config field of the given
+ * VDI.
+ */
+extern bool
+xen_vdi_add_to_other_config(xen_session *session, xen_vdi vdi, char *key, char *value);
+
+
+/**
+ * Remove the given key and its corresponding value from the
+ * other_config field of the given VDI. If the key is not in that Map, then
+ * do nothing.
+ */
+extern bool
+xen_vdi_remove_from_other_config(xen_session *session, xen_vdi vdi, char *key);
+
+
+/**
* Take an exact copy of the VDI; the snapshot lives in the same
* Storage Repository as its parent.
*/
diff --git a/tools/libxen/src/xen_vbd.c b/tools/libxen/src/xen_vbd.c
index 300f1d857d..893bf70958 100644
--- a/tools/libxen/src/xen_vbd.c
+++ b/tools/libxen/src/xen_vbd.c
@@ -54,9 +54,6 @@ static const struct_member xen_vbd_record_struct_members[] =
{ .key = "device",
.type = &abstract_type_string,
.offset = offsetof(xen_vbd_record, device) },
- { .key = "image",
- .type = &abstract_type_string,
- .offset = offsetof(xen_vbd_record, image) },
{ .key = "bootable",
.type = &abstract_type_bool,
.offset = offsetof(xen_vbd_record, bootable) },
diff --git a/tools/libxen/src/xen_vdi.c b/tools/libxen/src/xen_vdi.c
index 2e50db9e80..10f3fc4066 100644
--- a/tools/libxen/src/xen_vdi.c
+++ b/tools/libxen/src/xen_vdi.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006, XenSource Inc.
+ * Copyright (c) 2006-2007, XenSource Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
@@ -24,6 +24,7 @@
#include "xen_crashdump.h"
#include "xen_internal.h"
#include "xen_sr.h"
+#include "xen_string_string_map.h"
#include "xen_vbd.h"
#include "xen_vdi.h"
#include "xen_vdi_type_internal.h"
@@ -64,12 +65,6 @@ static const struct_member xen_vdi_record_struct_members[] =
{ .key = "physical_utilisation",
.type = &abstract_type_int,
.offset = offsetof(xen_vdi_record, physical_utilisation) },
- { .key = "sector_size",
- .type = &abstract_type_int,
- .offset = offsetof(xen_vdi_record, sector_size) },
- { .key = "location",
- .type = &abstract_type_string,
- .offset = offsetof(xen_vdi_record, location) },
{ .key = "type",
.type = &xen_vdi_type_abstract_type_,
.offset = offsetof(xen_vdi_record, type) },
@@ -78,7 +73,10 @@ static const struct_member xen_vdi_record_struct_members[] =
.offset = offsetof(xen_vdi_record, sharable) },
{ .key = "read_only",
.type = &abstract_type_bool,
- .offset = offsetof(xen_vdi_record, read_only) }
+ .offset = offsetof(xen_vdi_record, read_only) },
+ { .key = "other_config",
+ .type = &abstract_type_string_string_map,
+ .offset = offsetof(xen_vdi_record, other_config) }
};
const abstract_type xen_vdi_record_abstract_type_ =
@@ -105,6 +103,7 @@ xen_vdi_record_free(xen_vdi_record *record)
xen_sr_record_opt_free(record->sr);
xen_vbd_record_opt_set_free(record->vbds);
xen_crashdump_record_opt_set_free(record->crash_dumps);
+ xen_string_string_map_free(record->other_config);
free(record);
}
@@ -315,7 +314,7 @@ xen_vdi_get_physical_utilisation(xen_session *session, int64_t *result, xen_vdi
bool
-xen_vdi_get_sector_size(xen_session *session, int64_t *result, xen_vdi vdi)
+xen_vdi_get_type(xen_session *session, enum xen_vdi_type *result, xen_vdi vdi)
{
abstract_value param_values[] =
{
@@ -323,15 +322,14 @@ xen_vdi_get_sector_size(xen_session *session, int64_t *result, xen_vdi vdi)
.u.string_val = vdi }
};
- abstract_type result_type = abstract_type_int;
-
- XEN_CALL_("VDI.get_sector_size");
+ abstract_type result_type = xen_vdi_type_abstract_type_;
+ XEN_CALL_("VDI.get_type");
return session->ok;
}
bool
-xen_vdi_get_type(xen_session *session, enum xen_vdi_type *result, xen_vdi vdi)
+xen_vdi_get_sharable(xen_session *session, bool *result, xen_vdi vdi)
{
abstract_value param_values[] =
{
@@ -339,14 +337,15 @@ xen_vdi_get_type(xen_session *session, enum xen_vdi_type *result, xen_vdi vdi)
.u.string_val = vdi }
};
- abstract_type result_type = xen_vdi_type_abstract_type_;
- XEN_CALL_("VDI.get_type");
+ abstract_type result_type = abstract_type_bool;
+
+ XEN_CALL_("VDI.get_sharable");
return session->ok;
}
bool
-xen_vdi_get_sharable(xen_session *session, bool *result, xen_vdi vdi)
+xen_vdi_get_read_only(xen_session *session, bool *result, xen_vdi vdi)
{
abstract_value param_values[] =
{
@@ -356,13 +355,13 @@ xen_vdi_get_sharable(xen_session *session, bool *result, xen_vdi vdi)
abstract_type result_type = abstract_type_bool;
- XEN_CALL_("VDI.get_sharable");
+ XEN_CALL_("VDI.get_read_only");
return session->ok;
}
bool
-xen_vdi_get_read_only(xen_session *session, bool *result, xen_vdi vdi)
+xen_vdi_get_other_config(xen_session *session, xen_string_string_map **result, xen_vdi vdi)
{
abstract_value param_values[] =
{
@@ -370,9 +369,10 @@ xen_vdi_get_read_only(xen_session *session, bool *result, xen_vdi vdi)
.u.string_val = vdi }
};
- abstract_type result_type = abstract_type_bool;
+ abstract_type result_type = abstract_type_string_string_map;
- XEN_CALL_("VDI.get_read_only");
+ *result = NULL;
+ XEN_CALL_("VDI.get_other_config");
return session->ok;
}
@@ -458,6 +458,56 @@ xen_vdi_set_read_only(xen_session *session, xen_vdi vdi, bool read_only)
bool
+xen_vdi_set_other_config(xen_session *session, xen_vdi vdi, xen_string_string_map *other_config)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = vdi },
+ { .type = &abstract_type_string_string_map,
+ .u.set_val = (arbitrary_set *)other_config }
+ };
+
+ xen_call_(session, "VDI.set_other_config", param_values, 2, NULL, NULL);
+ return session->ok;
+}
+
+
+bool
+xen_vdi_add_to_other_config(xen_session *session, xen_vdi vdi, char *key, char *value)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = vdi },
+ { .type = &abstract_type_string,
+ .u.string_val = key },
+ { .type = &abstract_type_string,
+ .u.string_val = value }
+ };
+
+ xen_call_(session, "VDI.add_to_other_config", param_values, 3, NULL, NULL);
+ return session->ok;
+}
+
+
+bool
+xen_vdi_remove_from_other_config(xen_session *session, xen_vdi vdi, char *key)
+{
+ abstract_value param_values[] =
+ {
+ { .type = &abstract_type_string,
+ .u.string_val = vdi },
+ { .type = &abstract_type_string,
+ .u.string_val = key }
+ };
+
+ xen_call_(session, "VDI.remove_from_other_config", param_values, 2, NULL, NULL);
+ return session->ok;
+}
+
+
+bool
xen_vdi_snapshot(xen_session *session, xen_vdi *result, xen_vdi vdi)
{
abstract_value param_values[] =
diff --git a/tools/libxen/test/test_bindings.c b/tools/libxen/test/test_bindings.c
index f18c5c5ac5..92f2d9b6ca 100644
--- a/tools/libxen/test/test_bindings.c
+++ b/tools/libxen/test/test_bindings.c
@@ -421,8 +421,7 @@ static xen_vm create_new_vm(xen_session *session, bool hvm)
.name_label = "MyRootFS",
.name_description = "MyRootFS description",
.sr = &sr_record,
- .virtual_size = (1 << 21), // 1GiB / 512 bytes/sector
- .sector_size = 512,
+ .virtual_size = (INT64_C(1) << 30), // 1GiB
.type = XEN_VDI_TYPE_SYSTEM,
.sharable = false,
.read_only = false