[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] Implement new PIF-based network model, and match movement of I/O-statistics.
# HG changeset patch # User Ewan Mellor <ewan@xxxxxxxxxxxxx> # Node ID 8f090c551b09577d93aab5b71b30edae671bbf98 # Parent de31d79add5e591bca6c37d122d4ab060eea53bc Implement new PIF-based network model, and match movement of I/O-statistics. Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx> --- tools/libxen/include/xen_host.h | 9 tools/libxen/include/xen_network.h | 33 --- tools/libxen/include/xen_pif.h | 283 ++++++++++++++++++++++++++ tools/libxen/include/xen_pif_decl.h | 30 ++ tools/libxen/include/xen_vbd.h | 34 +-- tools/libxen/include/xen_vif.h | 42 +-- tools/libxen/src/xen_host.c | 22 ++ tools/libxen/src/xen_network.c | 86 +------- tools/libxen/src/xen_pif.c | 385 ++++++++++++++++++++++++++++++++++++ tools/libxen/src/xen_vbd.c | 42 ++- tools/libxen/src/xen_vif.c | 64 +---- 11 files changed, 828 insertions(+), 202 deletions(-) diff -r de31d79add5e -r 8f090c551b09 tools/libxen/include/xen_host.h --- a/tools/libxen/include/xen_host.h Thu Oct 26 15:57:29 2006 +0100 +++ b/tools/libxen/include/xen_host.h Thu Oct 26 15:59:51 2006 +0100 @@ -22,6 +22,7 @@ #include "xen_common.h" #include "xen_host_cpu_decl.h" #include "xen_host_decl.h" +#include "xen_pif_decl.h" #include "xen_string_string_map.h" #include "xen_vm_decl.h" @@ -69,6 +70,7 @@ typedef struct xen_host_record char *name_description; xen_string_string_map *software_version; struct xen_vm_record_opt_set *resident_vms; + struct xen_pif_record_opt_set *pifs; struct xen_host_cpu_record_opt_set *host_cpus; } xen_host_record; @@ -215,6 +217,13 @@ xen_host_get_resident_vms(xen_session *s /** + * Get the PIFs field of the given host. + */ +extern bool +xen_host_get_pifs(xen_session *session, xen_pif *result, xen_host host); + + +/** * Get the host_CPUs field of the given host. */ extern bool diff -r de31d79add5e -r 8f090c551b09 tools/libxen/include/xen_network.h --- a/tools/libxen/include/xen_network.h Thu Oct 26 15:57:29 2006 +0100 +++ b/tools/libxen/include/xen_network.h Thu Oct 26 15:59:51 2006 +0100 @@ -21,6 +21,7 @@ #include "xen_common.h" #include "xen_network_decl.h" +#include "xen_pif_decl.h" #include "xen_vif_decl.h" @@ -66,8 +67,7 @@ typedef struct xen_network_record char *name_label; char *name_description; struct xen_vif_record_opt_set *vifs; - char *nic; - char *vlan; + struct xen_pif_record_opt_set *pifs; char *default_gateway; char *default_netmask; } xen_network_record; @@ -208,17 +208,10 @@ xen_network_get_vifs(xen_session *sessio /** - * Get the NIC field of the given network. - */ -extern bool -xen_network_get_nic(xen_session *session, char **result, xen_network network); - - -/** - * Get the VLAN field of the given network. - */ -extern bool -xen_network_get_vlan(xen_session *session, char **result, xen_network network); + * Get the PIFs field of the given network. + */ +extern bool +xen_network_get_pifs(xen_session *session, xen_pif *result, xen_network network); /** @@ -250,20 +243,6 @@ xen_network_set_name_description(xen_ses /** - * Set the NIC field of the given network. - */ -extern bool -xen_network_set_nic(xen_session *session, xen_network xen_network, char *nic); - - -/** - * Set the VLAN field of the given network. - */ -extern bool -xen_network_set_vlan(xen_session *session, xen_network xen_network, char *vlan); - - -/** * Set the default_gateway field of the given network. */ extern bool diff -r de31d79add5e -r 8f090c551b09 tools/libxen/include/xen_vbd.h --- a/tools/libxen/include/xen_vbd.h Thu Oct 26 15:57:29 2006 +0100 +++ b/tools/libxen/include/xen_vbd.h Thu Oct 26 15:59:51 2006 +0100 @@ -71,8 +71,8 @@ typedef struct xen_vbd_record char *device; enum xen_vbd_mode mode; enum xen_driver_type driver; - double io_bandwidth_incoming_kbs; - double io_bandwidth_outgoing_kbs; + double io_read_kbs; + double io_write_kbs; } xen_vbd_record; /** @@ -218,17 +218,17 @@ xen_vbd_get_driver(xen_session *session, /** - * Get the IO_bandwidth/incoming_kbs field of the given VBD. - */ -extern bool -xen_vbd_get_io_bandwidth_incoming_kbs(xen_session *session, double *result, xen_vbd vbd); - - -/** - * Get the IO_bandwidth/outgoing_kbs field of the given VBD. - */ -extern bool -xen_vbd_get_io_bandwidth_outgoing_kbs(xen_session *session, double *result, xen_vbd vbd); + * Get the io/read_kbs field of the given VBD. + */ +extern bool +xen_vbd_get_io_read_kbs(xen_session *session, double *result, xen_vbd vbd); + + +/** + * Get the io/write_kbs field of the given VBD. + */ +extern bool +xen_vbd_get_io_write_kbs(xen_session *session, double *result, xen_vbd vbd); /** @@ -266,4 +266,12 @@ xen_vbd_set_driver(xen_session *session, xen_vbd_set_driver(xen_session *session, xen_vbd xen_vbd, enum xen_driver_type driver); +/** + * Change the media in the device for CDROM-like devices only. For + * other devices, detach the VBD and attach a new one + */ +extern bool +xen_vbd_media_change(xen_session *session, xen_vbd vbd, xen_vdi vdi); + + #endif diff -r de31d79add5e -r 8f090c551b09 tools/libxen/include/xen_vif.h --- a/tools/libxen/include/xen_vif.h Thu Oct 26 15:57:29 2006 +0100 +++ b/tools/libxen/include/xen_vif.h Thu Oct 26 15:59:51 2006 +0100 @@ -72,10 +72,8 @@ typedef struct xen_vif_record struct xen_vm_record_opt *vm; char *mac; uint64_t mtu; - double network_read_kbs; - double network_write_kbs; - double io_bandwidth_incoming_kbs; - double io_bandwidth_outgoing_kbs; + double io_read_kbs; + double io_write_kbs; } xen_vif_record; /** @@ -235,31 +233,17 @@ xen_vif_get_mtu(xen_session *session, ui /** - * Get the network_read_kbs field of the given VIF. - */ -extern bool -xen_vif_get_network_read_kbs(xen_session *session, double *result, xen_vif vif); - - -/** - * Get the network_write_kbs field of the given VIF. - */ -extern bool -xen_vif_get_network_write_kbs(xen_session *session, double *result, xen_vif vif); - - -/** - * Get the IO_bandwidth/incoming_kbs field of the given VIF. - */ -extern bool -xen_vif_get_io_bandwidth_incoming_kbs(xen_session *session, double *result, xen_vif vif); - - -/** - * Get the IO_bandwidth/outgoing_kbs field of the given VIF. - */ -extern bool -xen_vif_get_io_bandwidth_outgoing_kbs(xen_session *session, double *result, xen_vif vif); + * Get the io/read_kbs field of the given VIF. + */ +extern bool +xen_vif_get_io_read_kbs(xen_session *session, double *result, xen_vif vif); + + +/** + * Get the io/write_kbs field of the given VIF. + */ +extern bool +xen_vif_get_io_write_kbs(xen_session *session, double *result, xen_vif vif); /** diff -r de31d79add5e -r 8f090c551b09 tools/libxen/src/xen_host.c --- a/tools/libxen/src/xen_host.c Thu Oct 26 15:57:29 2006 +0100 +++ b/tools/libxen/src/xen_host.c Thu Oct 26 15:59:51 2006 +0100 @@ -24,6 +24,7 @@ #include "xen_host.h" #include "xen_host_cpu.h" #include "xen_internal.h" +#include "xen_pif.h" #include "xen_string_string_map.h" #include "xen_vm.h" @@ -54,6 +55,9 @@ static const struct_member xen_host_reco { .key = "resident_vms", .type = &abstract_type_ref_set, .offset = offsetof(xen_host_record, resident_vms) }, + { .key = "pifs", + .type = &abstract_type_ref_set, + .offset = offsetof(xen_host_record, pifs) }, { .key = "host_cpus", .type = &abstract_type_ref_set, .offset = offsetof(xen_host_record, host_cpus) } @@ -78,6 +82,7 @@ xen_host_record_free(xen_host_record *re free(record->name_description); xen_string_string_map_free(record->software_version); xen_vm_record_opt_set_free(record->resident_vms); + xen_pif_record_opt_set_free(record->pifs); xen_host_cpu_record_opt_set_free(record->host_cpus); free(record); } @@ -226,6 +231,23 @@ xen_host_get_resident_vms(xen_session *s bool +xen_host_get_pifs(xen_session *session, xen_pif *result, xen_host host) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = host } + }; + + abstract_type result_type = abstract_type_string_set; + + *result = NULL; + XEN_CALL_("host.get_pifs"); + return session->ok; +} + + +bool xen_host_get_host_cpus(xen_session *session, xen_host_cpu *result, xen_host host) { abstract_value param_values[] = diff -r de31d79add5e -r 8f090c551b09 tools/libxen/src/xen_network.c --- a/tools/libxen/src/xen_network.c Thu Oct 26 15:57:29 2006 +0100 +++ b/tools/libxen/src/xen_network.c Thu Oct 26 15:59:51 2006 +0100 @@ -23,6 +23,7 @@ #include "xen_common.h" #include "xen_internal.h" #include "xen_network.h" +#include "xen_pif.h" #include "xen_vif.h" @@ -49,12 +50,9 @@ static const struct_member xen_network_r { .key = "vifs", .type = &abstract_type_ref_set, .offset = offsetof(xen_network_record, vifs) }, - { .key = "nic", - .type = &abstract_type_string, - .offset = offsetof(xen_network_record, nic) }, - { .key = "vlan", - .type = &abstract_type_string, - .offset = offsetof(xen_network_record, vlan) }, + { .key = "pifs", + .type = &abstract_type_ref_set, + .offset = offsetof(xen_network_record, pifs) }, { .key = "default_gateway", .type = &abstract_type_string, .offset = offsetof(xen_network_record, default_gateway) }, @@ -81,8 +79,7 @@ xen_network_record_free(xen_network_reco free(record->name_label); free(record->name_description); xen_vif_record_opt_set_free(record->vifs); - free(record->nic); - free(record->vlan); + xen_pif_record_opt_set_free(record->pifs); free(record->default_gateway); free(record->default_netmask); free(record); @@ -215,35 +212,18 @@ xen_network_get_vifs(xen_session *sessio bool -xen_network_get_nic(xen_session *session, char **result, xen_network network) -{ - abstract_value param_values[] = - { - { .type = &abstract_type_string, - .u.string_val = network } - }; - - abstract_type result_type = abstract_type_string; - - *result = NULL; - XEN_CALL_("network.get_nic"); - return session->ok; -} - - -bool -xen_network_get_vlan(xen_session *session, char **result, xen_network network) -{ - abstract_value param_values[] = - { - { .type = &abstract_type_string, - .u.string_val = network } - }; - - abstract_type result_type = abstract_type_string; - - *result = NULL; - XEN_CALL_("network.get_vlan"); +xen_network_get_pifs(xen_session *session, xen_pif *result, xen_network network) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = network } + }; + + abstract_type result_type = abstract_type_string_set; + + *result = NULL; + XEN_CALL_("network.get_pifs"); return session->ok; } @@ -315,38 +295,6 @@ xen_network_set_name_description(xen_ses bool -xen_network_set_nic(xen_session *session, xen_network xen_network, char *nic) -{ - abstract_value param_values[] = - { - { .type = &abstract_type_string, - .u.string_val = xen_network }, - { .type = &abstract_type_string, - .u.string_val = nic } - }; - - xen_call_(session, "network.set_nic", param_values, 2, NULL, NULL); - return session->ok; -} - - -bool -xen_network_set_vlan(xen_session *session, xen_network xen_network, char *vlan) -{ - abstract_value param_values[] = - { - { .type = &abstract_type_string, - .u.string_val = xen_network }, - { .type = &abstract_type_string, - .u.string_val = vlan } - }; - - xen_call_(session, "network.set_vlan", param_values, 2, NULL, NULL); - return session->ok; -} - - -bool xen_network_set_default_gateway(xen_session *session, xen_network xen_network, char *default_gateway) { abstract_value param_values[] = diff -r de31d79add5e -r 8f090c551b09 tools/libxen/src/xen_vbd.c --- a/tools/libxen/src/xen_vbd.c Thu Oct 26 15:57:29 2006 +0100 +++ b/tools/libxen/src/xen_vbd.c Thu Oct 26 15:59:51 2006 +0100 @@ -58,12 +58,12 @@ static const struct_member xen_vbd_recor { .key = "driver", .type = &xen_driver_type_abstract_type_, .offset = offsetof(xen_vbd_record, driver) }, - { .key = "io_bandwidth_incoming_kbs", + { .key = "io_read_kbs", .type = &abstract_type_float, - .offset = offsetof(xen_vbd_record, io_bandwidth_incoming_kbs) }, - { .key = "io_bandwidth_outgoing_kbs", + .offset = offsetof(xen_vbd_record, io_read_kbs) }, + { .key = "io_write_kbs", .type = &abstract_type_float, - .offset = offsetof(xen_vbd_record, io_bandwidth_outgoing_kbs) } + .offset = offsetof(xen_vbd_record, io_write_kbs) } }; const abstract_type xen_vbd_record_abstract_type_ = @@ -231,7 +231,7 @@ xen_vbd_get_driver(xen_session *session, bool -xen_vbd_get_io_bandwidth_incoming_kbs(xen_session *session, double *result, xen_vbd vbd) +xen_vbd_get_io_read_kbs(xen_session *session, double *result, xen_vbd vbd) { abstract_value param_values[] = { @@ -241,13 +241,13 @@ xen_vbd_get_io_bandwidth_incoming_kbs(xe abstract_type result_type = abstract_type_float; - XEN_CALL_("VBD.get_io_bandwidth_incoming_kbs"); - return session->ok; -} - - -bool -xen_vbd_get_io_bandwidth_outgoing_kbs(xen_session *session, double *result, xen_vbd vbd) + XEN_CALL_("VBD.get_io_read_kbs"); + return session->ok; +} + + +bool +xen_vbd_get_io_write_kbs(xen_session *session, double *result, xen_vbd vbd) { abstract_value param_values[] = { @@ -257,7 +257,7 @@ xen_vbd_get_io_bandwidth_outgoing_kbs(xe abstract_type result_type = abstract_type_float; - XEN_CALL_("VBD.get_io_bandwidth_outgoing_kbs"); + XEN_CALL_("VBD.get_io_write_kbs"); return session->ok; } @@ -343,6 +343,22 @@ xen_vbd_set_driver(xen_session *session, bool +xen_vbd_media_change(xen_session *session, xen_vbd vbd, xen_vdi vdi) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = vbd }, + { .type = &abstract_type_string, + .u.string_val = vdi } + }; + + xen_call_(session, "VBD.media_change", param_values, 2, NULL, NULL); + return session->ok; +} + + +bool xen_vbd_get_uuid(xen_session *session, char **result, xen_vbd vbd) { *result = session->ok ? xen_strdup_((char *)vbd) : NULL; diff -r de31d79add5e -r 8f090c551b09 tools/libxen/src/xen_vif.c --- a/tools/libxen/src/xen_vif.c Thu Oct 26 15:57:29 2006 +0100 +++ b/tools/libxen/src/xen_vif.c Thu Oct 26 15:59:51 2006 +0100 @@ -63,18 +63,12 @@ static const struct_member xen_vif_recor { .key = "mtu", .type = &abstract_type_int, .offset = offsetof(xen_vif_record, mtu) }, - { .key = "network_read_kbs", + { .key = "io_read_kbs", .type = &abstract_type_float, - .offset = offsetof(xen_vif_record, network_read_kbs) }, - { .key = "network_write_kbs", + .offset = offsetof(xen_vif_record, io_read_kbs) }, + { .key = "io_write_kbs", .type = &abstract_type_float, - .offset = offsetof(xen_vif_record, network_write_kbs) }, - { .key = "io_bandwidth_incoming_kbs", - .type = &abstract_type_float, - .offset = offsetof(xen_vif_record, io_bandwidth_incoming_kbs) }, - { .key = "io_bandwidth_outgoing_kbs", - .type = &abstract_type_float, - .offset = offsetof(xen_vif_record, io_bandwidth_outgoing_kbs) } + .offset = offsetof(xen_vif_record, io_write_kbs) } }; const abstract_type xen_vif_record_abstract_type_ = @@ -277,7 +271,7 @@ xen_vif_get_mtu(xen_session *session, ui bool -xen_vif_get_network_read_kbs(xen_session *session, double *result, xen_vif vif) +xen_vif_get_io_read_kbs(xen_session *session, double *result, xen_vif vif) { abstract_value param_values[] = { @@ -287,13 +281,13 @@ xen_vif_get_network_read_kbs(xen_session abstract_type result_type = abstract_type_float; - XEN_CALL_("VIF.get_network_read_kbs"); - return session->ok; -} - - -bool -xen_vif_get_network_write_kbs(xen_session *session, double *result, xen_vif vif) + XEN_CALL_("VIF.get_io_read_kbs"); + return session->ok; +} + + +bool +xen_vif_get_io_write_kbs(xen_session *session, double *result, xen_vif vif) { abstract_value param_values[] = { @@ -303,39 +297,7 @@ xen_vif_get_network_write_kbs(xen_sessio abstract_type result_type = abstract_type_float; - XEN_CALL_("VIF.get_network_write_kbs"); - return session->ok; -} - - -bool -xen_vif_get_io_bandwidth_incoming_kbs(xen_session *session, double *result, xen_vif vif) -{ - abstract_value param_values[] = - { - { .type = &abstract_type_string, - .u.string_val = vif } - }; - - abstract_type result_type = abstract_type_float; - - XEN_CALL_("VIF.get_io_bandwidth_incoming_kbs"); - return session->ok; -} - - -bool -xen_vif_get_io_bandwidth_outgoing_kbs(xen_session *session, double *result, xen_vif vif) -{ - abstract_value param_values[] = - { - { .type = &abstract_type_string, - .u.string_val = vif } - }; - - abstract_type result_type = abstract_type_float; - - XEN_CALL_("VIF.get_io_bandwidth_outgoing_kbs"); + XEN_CALL_("VIF.get_io_write_kbs"); return session->ok; } diff -r de31d79add5e -r 8f090c551b09 tools/libxen/include/xen_pif.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/libxen/include/xen_pif.h Thu Oct 26 15:59:51 2006 +0100 @@ -0,0 +1,283 @@ +/* + * Copyright (c) 2006, XenSource Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef XEN_PIF_H +#define XEN_PIF_H + +#include "xen_common.h" +#include "xen_host_decl.h" +#include "xen_network_decl.h" +#include "xen_pif_decl.h" + + +/* + * The PIF class. + * + * A physical network interface (note separate VLANs are represented as + * several PIFs). + */ + + +/** + * Free the given xen_pif. The given handle must have been allocated + * by this library. + */ +extern void +xen_pif_free(xen_pif pif); + + +typedef struct xen_pif_set +{ + size_t size; + xen_pif *contents[]; +} xen_pif_set; + +/** + * Allocate a xen_pif_set of the given size. + */ +extern xen_pif_set * +xen_pif_set_alloc(size_t size); + +/** + * Free the given xen_pif_set. The given set must have been allocated + * by this library. + */ +extern void +xen_pif_set_free(xen_pif_set *set); + + +typedef struct xen_pif_record +{ + xen_pif handle; + char *uuid; + char *name; + struct xen_network_record_opt *network; + struct xen_host_record_opt *host; + char *mac; + uint64_t mtu; + char *vlan; + double io_read_kbs; + double io_write_kbs; +} xen_pif_record; + +/** + * Allocate a xen_pif_record. + */ +extern xen_pif_record * +xen_pif_record_alloc(void); + +/** + * Free the given xen_pif_record, and all referenced values. The given + * record must have been allocated by this library. + */ +extern void +xen_pif_record_free(xen_pif_record *record); + + +typedef struct xen_pif_record_opt +{ + bool is_record; + union + { + xen_pif handle; + xen_pif_record *record; + } u; +} xen_pif_record_opt; + +/** + * Allocate a xen_pif_record_opt. + */ +extern xen_pif_record_opt * +xen_pif_record_opt_alloc(void); + +/** + * Free the given xen_pif_record_opt, and all referenced values. The + * given record_opt must have been allocated by this library. + */ +extern void +xen_pif_record_opt_free(xen_pif_record_opt *record_opt); + + +typedef struct xen_pif_record_set +{ + size_t size; + xen_pif_record *contents[]; +} xen_pif_record_set; + +/** + * Allocate a xen_pif_record_set of the given size. + */ +extern xen_pif_record_set * +xen_pif_record_set_alloc(size_t size); + +/** + * Free the given xen_pif_record_set, and all referenced values. The + * given set must have been allocated by this library. + */ +extern void +xen_pif_record_set_free(xen_pif_record_set *set); + + + +typedef struct xen_pif_record_opt_set +{ + size_t size; + xen_pif_record_opt *contents[]; +} xen_pif_record_opt_set; + +/** + * Allocate a xen_pif_record_opt_set of the given size. + */ +extern xen_pif_record_opt_set * +xen_pif_record_opt_set_alloc(size_t size); + +/** + * Free the given xen_pif_record_opt_set, and all referenced values. + * The given set must have been allocated by this library. + */ +extern void +xen_pif_record_opt_set_free(xen_pif_record_opt_set *set); + + +/** + * Get the current state of the given PIF. !!! + */ +extern bool +xen_pif_get_record(xen_session *session, xen_pif_record **result, xen_pif pif); + + +/** + * Get a reference to the object with the specified UUID. !!! + */ +extern bool +xen_pif_get_by_uuid(xen_session *session, xen_pif *result, char *uuid); + + +/** + * Create a new PIF instance, and return its handle. + */ +extern bool +xen_pif_create(xen_session *session, xen_pif *result, xen_pif_record *record); + + +/** + * Get the uuid field of the given PIF. + */ +extern bool +xen_pif_get_uuid(xen_session *session, char **result, xen_pif pif); + + +/** + * Get the name field of the given PIF. + */ +extern bool +xen_pif_get_name(xen_session *session, char **result, xen_pif pif); + + +/** + * Get the network field of the given PIF. + */ +extern bool +xen_pif_get_network(xen_session *session, xen_network *result, xen_pif pif); + + +/** + * Get the host field of the given PIF. + */ +extern bool +xen_pif_get_host(xen_session *session, xen_host *result, xen_pif pif); + + +/** + * Get the MAC field of the given PIF. + */ +extern bool +xen_pif_get_mac(xen_session *session, char **result, xen_pif pif); + + +/** + * Get the MTU field of the given PIF. + */ +extern bool +xen_pif_get_mtu(xen_session *session, uint64_t *result, xen_pif pif); + + +/** + * Get the VLAN field of the given PIF. + */ +extern bool +xen_pif_get_vlan(xen_session *session, char **result, xen_pif pif); + + +/** + * Get the io/read_kbs field of the given PIF. + */ +extern bool +xen_pif_get_io_read_kbs(xen_session *session, double *result, xen_pif pif); + + +/** + * Get the io/write_kbs field of the given PIF. + */ +extern bool +xen_pif_get_io_write_kbs(xen_session *session, double *result, xen_pif pif); + + +/** + * Set the name field of the given PIF. + */ +extern bool +xen_pif_set_name(xen_session *session, xen_pif xen_pif, char *name); + + +/** + * Set the network field of the given PIF. + */ +extern bool +xen_pif_set_network(xen_session *session, xen_pif xen_pif, xen_network network); + + +/** + * Set the host field of the given PIF. + */ +extern bool +xen_pif_set_host(xen_session *session, xen_pif xen_pif, xen_host host); + + +/** + * Set the MAC field of the given PIF. + */ +extern bool +xen_pif_set_mac(xen_session *session, xen_pif xen_pif, char *mac); + + +/** + * Set the MTU field of the given PIF. + */ +extern bool +xen_pif_set_mtu(xen_session *session, xen_pif xen_pif, uint64_t mtu); + + +/** + * Set the VLAN field of the given PIF. + */ +extern bool +xen_pif_set_vlan(xen_session *session, xen_pif xen_pif, char *vlan); + + +#endif diff -r de31d79add5e -r 8f090c551b09 tools/libxen/include/xen_pif_decl.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/libxen/include/xen_pif_decl.h Thu Oct 26 15:59:51 2006 +0100 @@ -0,0 +1,30 @@ +/* + * Copyright (c) 2006, XenSource Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + +#ifndef XEN_PIF_DECL_H +#define XEN_PIF_DECL_H + +typedef void *xen_pif; + +struct xen_pif_set; +struct xen_pif_record; +struct xen_pif_record_set; +struct xen_pif_record_opt; +struct xen_pif_record_opt_set; + +#endif diff -r de31d79add5e -r 8f090c551b09 tools/libxen/src/xen_pif.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/tools/libxen/src/xen_pif.c Thu Oct 26 15:59:51 2006 +0100 @@ -0,0 +1,385 @@ +/* + * Copyright (c) 2006, XenSource Inc. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + + +#include <stddef.h> +#include <stdlib.h> + +#include "xen_common.h" +#include "xen_host.h" +#include "xen_internal.h" +#include "xen_network.h" +#include "xen_pif.h" + + +XEN_FREE(xen_pif) +XEN_SET_ALLOC_FREE(xen_pif) +XEN_ALLOC(xen_pif_record) +XEN_SET_ALLOC_FREE(xen_pif_record) +XEN_ALLOC(xen_pif_record_opt) +XEN_RECORD_OPT_FREE(xen_pif) +XEN_SET_ALLOC_FREE(xen_pif_record_opt) + + +static const struct_member xen_pif_record_struct_members[] = + { + { .key = "uuid", + .type = &abstract_type_string, + .offset = offsetof(xen_pif_record, uuid) }, + { .key = "name", + .type = &abstract_type_string, + .offset = offsetof(xen_pif_record, name) }, + { .key = "network", + .type = &abstract_type_ref, + .offset = offsetof(xen_pif_record, network) }, + { .key = "host", + .type = &abstract_type_ref, + .offset = offsetof(xen_pif_record, host) }, + { .key = "mac", + .type = &abstract_type_string, + .offset = offsetof(xen_pif_record, mac) }, + { .key = "mtu", + .type = &abstract_type_int, + .offset = offsetof(xen_pif_record, mtu) }, + { .key = "vlan", + .type = &abstract_type_string, + .offset = offsetof(xen_pif_record, vlan) }, + { .key = "io_read_kbs", + .type = &abstract_type_float, + .offset = offsetof(xen_pif_record, io_read_kbs) }, + { .key = "io_write_kbs", + .type = &abstract_type_float, + .offset = offsetof(xen_pif_record, io_write_kbs) } + }; + +const abstract_type xen_pif_record_abstract_type_ = + { + .typename = STRUCT, + .struct_size = sizeof(xen_pif_record), + .member_count = + sizeof(xen_pif_record_struct_members) / sizeof(struct_member), + .members = xen_pif_record_struct_members + }; + + +void +xen_pif_record_free(xen_pif_record *record) +{ + free(record->handle); + free(record->uuid); + free(record->name); + xen_network_record_opt_free(record->network); + xen_host_record_opt_free(record->host); + free(record->mac); + free(record->vlan); + free(record); +} + + +bool +xen_pif_get_record(xen_session *session, xen_pif_record **result, xen_pif pif) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = pif } + }; + + abstract_type result_type = xen_pif_record_abstract_type_; + + *result = NULL; + XEN_CALL_("PIF.get_record"); + + if (session->ok) + { + (*result)->handle = xen_strdup_((*result)->uuid); + } + + return session->ok; +} + + +bool +xen_pif_get_by_uuid(xen_session *session, xen_pif *result, char *uuid) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = uuid } + }; + + abstract_type result_type = abstract_type_string; + + *result = NULL; + XEN_CALL_("PIF.get_by_uuid"); + return session->ok; +} + + +bool +xen_pif_create(xen_session *session, xen_pif *result, xen_pif_record *record) +{ + abstract_value param_values[] = + { + { .type = &xen_pif_record_abstract_type_, + .u.struct_val = record } + }; + + abstract_type result_type = abstract_type_string; + + *result = NULL; + XEN_CALL_("PIF.create"); + return session->ok; +} + + +bool +xen_pif_get_name(xen_session *session, char **result, xen_pif pif) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = pif } + }; + + abstract_type result_type = abstract_type_string; + + *result = NULL; + XEN_CALL_("PIF.get_name"); + return session->ok; +} + + +bool +xen_pif_get_network(xen_session *session, xen_network *result, xen_pif pif) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = pif } + }; + + abstract_type result_type = abstract_type_string; + + *result = NULL; + XEN_CALL_("PIF.get_network"); + return session->ok; +} + + +bool +xen_pif_get_host(xen_session *session, xen_host *result, xen_pif pif) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = pif } + }; + + abstract_type result_type = abstract_type_string; + + *result = NULL; + XEN_CALL_("PIF.get_host"); + return session->ok; +} + + +bool +xen_pif_get_mac(xen_session *session, char **result, xen_pif pif) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = pif } + }; + + abstract_type result_type = abstract_type_string; + + *result = NULL; + XEN_CALL_("PIF.get_mac"); + return session->ok; +} + + +bool +xen_pif_get_mtu(xen_session *session, uint64_t *result, xen_pif pif) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = pif } + }; + + abstract_type result_type = abstract_type_int; + + XEN_CALL_("PIF.get_mtu"); + return session->ok; +} + + +bool +xen_pif_get_vlan(xen_session *session, char **result, xen_pif pif) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = pif } + }; + + abstract_type result_type = abstract_type_string; + + *result = NULL; + XEN_CALL_("PIF.get_vlan"); + return session->ok; +} + + +bool +xen_pif_get_io_read_kbs(xen_session *session, double *result, xen_pif pif) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = pif } + }; + + abstract_type result_type = abstract_type_float; + + XEN_CALL_("PIF.get_io_read_kbs"); + return session->ok; +} + + +bool +xen_pif_get_io_write_kbs(xen_session *session, double *result, xen_pif pif) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = pif } + }; + + abstract_type result_type = abstract_type_float; + + XEN_CALL_("PIF.get_io_write_kbs"); + return session->ok; +} + + +bool +xen_pif_set_name(xen_session *session, xen_pif xen_pif, char *name) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = xen_pif }, + { .type = &abstract_type_string, + .u.string_val = name } + }; + + xen_call_(session, "PIF.set_name", param_values, 2, NULL, NULL); + return session->ok; +} + + +bool +xen_pif_set_network(xen_session *session, xen_pif xen_pif, xen_network network) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = xen_pif }, + { .type = &abstract_type_string, + .u.string_val = network } + }; + + xen_call_(session, "PIF.set_network", param_values, 2, NULL, NULL); + return session->ok; +} + + +bool +xen_pif_set_host(xen_session *session, xen_pif xen_pif, xen_host host) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = xen_pif }, + { .type = &abstract_type_string, + .u.string_val = host } + }; + + xen_call_(session, "PIF.set_host", param_values, 2, NULL, NULL); + return session->ok; +} + + +bool +xen_pif_set_mac(xen_session *session, xen_pif xen_pif, char *mac) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = xen_pif }, + { .type = &abstract_type_string, + .u.string_val = mac } + }; + + xen_call_(session, "PIF.set_mac", param_values, 2, NULL, NULL); + return session->ok; +} + + +bool +xen_pif_set_mtu(xen_session *session, xen_pif xen_pif, uint64_t mtu) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = xen_pif }, + { .type = &abstract_type_int, + .u.int_val = mtu } + }; + + xen_call_(session, "PIF.set_mtu", param_values, 2, NULL, NULL); + return session->ok; +} + + +bool +xen_pif_set_vlan(xen_session *session, xen_pif xen_pif, char *vlan) +{ + abstract_value param_values[] = + { + { .type = &abstract_type_string, + .u.string_val = xen_pif }, + { .type = &abstract_type_string, + .u.string_val = vlan } + }; + + xen_call_(session, "PIF.set_vlan", param_values, 2, NULL, NULL); + return session->ok; +} + + +bool +xen_pif_get_uuid(xen_session *session, char **result, xen_pif pif) +{ + *result = session->ok ? xen_strdup_((char *)pif) : NULL; + return session->ok; +} _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |