diff options
author | Ewan Mellor <ewan@xensource.com> | 2007-02-20 22:40:55 +0000 |
---|---|---|
committer | Ewan Mellor <ewan@xensource.com> | 2007-02-20 22:40:55 +0000 |
commit | 1a84dd141d339bde3d33963097860f40f9553776 (patch) | |
tree | 02fffa25826b917bcd1aa61130382bb3fc4de6f2 /tools/libxen | |
parent | fa4627735b0d9117cda8c9f7cc96eefcf91db8e4 (diff) | |
download | xen-1a84dd141d339bde3d33963097860f40f9553776.tar.gz xen-1a84dd141d339bde3d33963097860f40f9553776.tar.bz2 xen-1a84dd141d339bde3d33963097860f40f9553776.zip |
Added modelling and C bindings for VIF/VBD QoS parameter setting. No Xend
implementation yet.
Signed-off-by: Ewan Mellor <ewan@xensource.com>
Diffstat (limited to 'tools/libxen')
-rw-r--r-- | tools/libxen/include/xen_vbd.h | 48 | ||||
-rw-r--r-- | tools/libxen/include/xen_vif.h | 48 | ||||
-rw-r--r-- | tools/libxen/src/xen_vbd.c | 109 | ||||
-rw-r--r-- | tools/libxen/src/xen_vif.c | 109 |
4 files changed, 314 insertions, 0 deletions
diff --git a/tools/libxen/include/xen_vbd.h b/tools/libxen/include/xen_vbd.h index d86ef6d3cd..543a42288c 100644 --- a/tools/libxen/include/xen_vbd.h +++ b/tools/libxen/include/xen_vbd.h @@ -20,6 +20,7 @@ #define XEN_VBD_H #include "xen_common.h" +#include "xen_string_string_map.h" #include "xen_vbd_decl.h" #include "xen_vbd_metrics_decl.h" #include "xen_vbd_mode.h" @@ -74,6 +75,8 @@ typedef struct xen_vbd_record bool bootable; enum xen_vbd_mode mode; enum xen_vbd_type type; + char *qos_algorithm_type; + xen_string_string_map *qos_algorithm_params; struct xen_vbd_metrics_record_opt *metrics; } xen_vbd_record; @@ -234,6 +237,20 @@ xen_vbd_get_type(xen_session *session, enum xen_vbd_type *result, xen_vbd vbd); /** + * Get the qos/algorithm_type field of the given VBD. + */ +extern bool +xen_vbd_get_qos_algorithm_type(xen_session *session, char **result, xen_vbd vbd); + + +/** + * Get the qos/algorithm_params field of the given VBD. + */ +extern bool +xen_vbd_get_qos_algorithm_params(xen_session *session, xen_string_string_map **result, xen_vbd vbd); + + +/** * Get the metrics field of the given VBD. */ extern bool @@ -269,6 +286,37 @@ xen_vbd_set_type(xen_session *session, xen_vbd vbd, enum xen_vbd_type type); /** + * Set the qos/algorithm_type field of the given VBD. + */ +extern bool +xen_vbd_set_qos_algorithm_type(xen_session *session, xen_vbd vbd, char *algorithm_type); + + +/** + * Set the qos/algorithm_params field of the given VBD. + */ +extern bool +xen_vbd_set_qos_algorithm_params(xen_session *session, xen_vbd vbd, xen_string_string_map *algorithm_params); + + +/** + * Add the given key-value pair to the qos/algorithm_params field of + * the given VBD. + */ +extern bool +xen_vbd_add_to_qos_algorithm_params(xen_session *session, xen_vbd vbd, char *key, char *value); + + +/** + * Remove the given key and its corresponding value from the + * qos/algorithm_params field of the given VBD. If the key is not in that + * Map, then do nothing. + */ +extern bool +xen_vbd_remove_from_qos_algorithm_params(xen_session *session, xen_vbd vbd, char *key); + + +/** * Change the media in the device for CDROM-like devices only. For * other devices, detach the VBD and attach a new one */ diff --git a/tools/libxen/include/xen_vif.h b/tools/libxen/include/xen_vif.h index 160d8a02b3..c6ec71ee03 100644 --- a/tools/libxen/include/xen_vif.h +++ b/tools/libxen/include/xen_vif.h @@ -21,6 +21,7 @@ #include "xen_common.h" #include "xen_network_decl.h" +#include "xen_string_string_map.h" #include "xen_vif_decl.h" #include "xen_vif_metrics_decl.h" #include "xen_vm_decl.h" @@ -70,6 +71,8 @@ typedef struct xen_vif_record struct xen_vm_record_opt *vm; char *mac; int64_t mtu; + char *qos_algorithm_type; + xen_string_string_map *qos_algorithm_params; struct xen_vif_metrics_record_opt *metrics; } xen_vif_record; @@ -223,6 +226,20 @@ xen_vif_get_mtu(xen_session *session, int64_t *result, xen_vif vif); /** + * Get the qos/algorithm_type field of the given VIF. + */ +extern bool +xen_vif_get_qos_algorithm_type(xen_session *session, char **result, xen_vif vif); + + +/** + * Get the qos/algorithm_params field of the given VIF. + */ +extern bool +xen_vif_get_qos_algorithm_params(xen_session *session, xen_string_string_map **result, xen_vif vif); + + +/** * Get the metrics field of the given VIF. */ extern bool @@ -250,4 +267,35 @@ extern bool xen_vif_set_mtu(xen_session *session, xen_vif vif, int64_t mtu); +/** + * Set the qos/algorithm_type field of the given VIF. + */ +extern bool +xen_vif_set_qos_algorithm_type(xen_session *session, xen_vif vif, char *algorithm_type); + + +/** + * Set the qos/algorithm_params field of the given VIF. + */ +extern bool +xen_vif_set_qos_algorithm_params(xen_session *session, xen_vif vif, xen_string_string_map *algorithm_params); + + +/** + * Add the given key-value pair to the qos/algorithm_params field of + * the given VIF. + */ +extern bool +xen_vif_add_to_qos_algorithm_params(xen_session *session, xen_vif vif, char *key, char *value); + + +/** + * Remove the given key and its corresponding value from the + * qos/algorithm_params field of the given VIF. If the key is not in that + * Map, then do nothing. + */ +extern bool +xen_vif_remove_from_qos_algorithm_params(xen_session *session, xen_vif vif, char *key); + + #endif diff --git a/tools/libxen/src/xen_vbd.c b/tools/libxen/src/xen_vbd.c index d3c5709952..5e0b14dfbb 100644 --- a/tools/libxen/src/xen_vbd.c +++ b/tools/libxen/src/xen_vbd.c @@ -22,6 +22,7 @@ #include "xen_common.h" #include "xen_internal.h" +#include "xen_string_string_map.h" #include "xen_vbd.h" #include "xen_vbd_metrics.h" #include "xen_vbd_mode_internal.h" @@ -65,6 +66,12 @@ static const struct_member xen_vbd_record_struct_members[] = { .key = "type", .type = &xen_vbd_type_abstract_type_, .offset = offsetof(xen_vbd_record, type) }, + { .key = "qos_algorithm_type", + .type = &abstract_type_string, + .offset = offsetof(xen_vbd_record, qos_algorithm_type) }, + { .key = "qos_algorithm_params", + .type = &abstract_type_string_string_map, + .offset = offsetof(xen_vbd_record, qos_algorithm_params) }, { .key = "metrics", .type = &abstract_type_ref, .offset = offsetof(xen_vbd_record, metrics) } @@ -92,6 +99,8 @@ xen_vbd_record_free(xen_vbd_record *record) xen_vm_record_opt_free(record->vm); xen_vdi_record_opt_free(record->vdi); free(record->device); + free(record->qos_algorithm_type); + xen_string_string_map_free(record->qos_algorithm_params); xen_vbd_metrics_record_opt_free(record->metrics); free(record); } @@ -266,6 +275,40 @@ xen_vbd_get_type(xen_session *session, enum xen_vbd_type *result, xen_vbd vbd) bool +xen_vbd_get_qos_algorithm_type(xen_session *session, char **result, xen_vbd vbd) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = vbd } + }; + + abstract_type result_type = abstract_type_string; + + *result = NULL; + XEN_CALL_("VBD.get_qos_algorithm_type"); + return session->ok; +} + + +bool +xen_vbd_get_qos_algorithm_params(xen_session *session, xen_string_string_map **result, xen_vbd vbd) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = vbd } + }; + + abstract_type result_type = abstract_type_string_string_map; + + *result = NULL; + XEN_CALL_("VBD.get_qos_algorithm_params"); + return session->ok; +} + + +bool xen_vbd_get_metrics(xen_session *session, xen_vbd_metrics *result, xen_vbd vbd) { abstract_value param_values[] = @@ -347,6 +390,72 @@ xen_vbd_set_type(xen_session *session, xen_vbd vbd, enum xen_vbd_type type) bool +xen_vbd_set_qos_algorithm_type(xen_session *session, xen_vbd vbd, char *algorithm_type) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = vbd }, + { .type = &abstract_type_string, + .u.string_val = algorithm_type } + }; + + xen_call_(session, "VBD.set_qos_algorithm_type", param_values, 2, NULL, NULL); + return session->ok; +} + + +bool +xen_vbd_set_qos_algorithm_params(xen_session *session, xen_vbd vbd, xen_string_string_map *algorithm_params) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = vbd }, + { .type = &abstract_type_string_string_map, + .u.set_val = (arbitrary_set *)algorithm_params } + }; + + xen_call_(session, "VBD.set_qos_algorithm_params", param_values, 2, NULL, NULL); + return session->ok; +} + + +bool +xen_vbd_add_to_qos_algorithm_params(xen_session *session, xen_vbd vbd, char *key, char *value) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = vbd }, + { .type = &abstract_type_string, + .u.string_val = key }, + { .type = &abstract_type_string, + .u.string_val = value } + }; + + xen_call_(session, "VBD.add_to_qos_algorithm_params", param_values, 3, NULL, NULL); + return session->ok; +} + + +bool +xen_vbd_remove_from_qos_algorithm_params(xen_session *session, xen_vbd vbd, char *key) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = vbd }, + { .type = &abstract_type_string, + .u.string_val = key } + }; + + xen_call_(session, "VBD.remove_from_qos_algorithm_params", param_values, 2, NULL, NULL); + return session->ok; +} + + +bool xen_vbd_media_change(xen_session *session, xen_vbd vbd, xen_vdi vdi) { abstract_value param_values[] = diff --git a/tools/libxen/src/xen_vif.c b/tools/libxen/src/xen_vif.c index 3fc214b16e..62a6ef16a2 100644 --- a/tools/libxen/src/xen_vif.c +++ b/tools/libxen/src/xen_vif.c @@ -23,6 +23,7 @@ #include "xen_common.h" #include "xen_internal.h" #include "xen_network.h" +#include "xen_string_string_map.h" #include "xen_vif.h" #include "xen_vif_metrics.h" #include "xen_vm.h" @@ -57,6 +58,12 @@ static const struct_member xen_vif_record_struct_members[] = { .key = "MTU", .type = &abstract_type_int, .offset = offsetof(xen_vif_record, mtu) }, + { .key = "qos_algorithm_type", + .type = &abstract_type_string, + .offset = offsetof(xen_vif_record, qos_algorithm_type) }, + { .key = "qos_algorithm_params", + .type = &abstract_type_string_string_map, + .offset = offsetof(xen_vif_record, qos_algorithm_params) }, { .key = "metrics", .type = &abstract_type_ref, .offset = offsetof(xen_vif_record, metrics) } @@ -85,6 +92,8 @@ xen_vif_record_free(xen_vif_record *record) xen_network_record_opt_free(record->network); xen_vm_record_opt_free(record->vm); free(record->mac); + free(record->qos_algorithm_type); + xen_string_string_map_free(record->qos_algorithm_params); xen_vif_metrics_record_opt_free(record->metrics); free(record); } @@ -246,6 +255,40 @@ xen_vif_get_mtu(xen_session *session, int64_t *result, xen_vif vif) bool +xen_vif_get_qos_algorithm_type(xen_session *session, char **result, xen_vif vif) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = vif } + }; + + abstract_type result_type = abstract_type_string; + + *result = NULL; + XEN_CALL_("VIF.get_qos_algorithm_type"); + return session->ok; +} + + +bool +xen_vif_get_qos_algorithm_params(xen_session *session, xen_string_string_map **result, xen_vif vif) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = vif } + }; + + abstract_type result_type = abstract_type_string_string_map; + + *result = NULL; + XEN_CALL_("VIF.get_qos_algorithm_params"); + return session->ok; +} + + +bool xen_vif_get_metrics(xen_session *session, xen_vif_metrics *result, xen_vif vif) { abstract_value param_values[] = @@ -311,6 +354,72 @@ xen_vif_set_mtu(xen_session *session, xen_vif vif, int64_t mtu) bool +xen_vif_set_qos_algorithm_type(xen_session *session, xen_vif vif, char *algorithm_type) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = vif }, + { .type = &abstract_type_string, + .u.string_val = algorithm_type } + }; + + xen_call_(session, "VIF.set_qos_algorithm_type", param_values, 2, NULL, NULL); + return session->ok; +} + + +bool +xen_vif_set_qos_algorithm_params(xen_session *session, xen_vif vif, xen_string_string_map *algorithm_params) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = vif }, + { .type = &abstract_type_string_string_map, + .u.set_val = (arbitrary_set *)algorithm_params } + }; + + xen_call_(session, "VIF.set_qos_algorithm_params", param_values, 2, NULL, NULL); + return session->ok; +} + + +bool +xen_vif_add_to_qos_algorithm_params(xen_session *session, xen_vif vif, char *key, char *value) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = vif }, + { .type = &abstract_type_string, + .u.string_val = key }, + { .type = &abstract_type_string, + .u.string_val = value } + }; + + xen_call_(session, "VIF.add_to_qos_algorithm_params", param_values, 3, NULL, NULL); + return session->ok; +} + + +bool +xen_vif_remove_from_qos_algorithm_params(xen_session *session, xen_vif vif, char *key) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = vif }, + { .type = &abstract_type_string, + .u.string_val = key } + }; + + xen_call_(session, "VIF.remove_from_qos_algorithm_params", param_values, 2, NULL, NULL); + return session->ok; +} + + +bool xen_vif_get_uuid(xen_session *session, char **result, xen_vif vif) { *result = session->ok ? xen_strdup_((char *)vif) : NULL; |