[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 23 of 29 RFC] libxl: add libxl__parse_nic_hotplug_path
# HG changeset patch # User Roger Pau Monne <roger.pau@xxxxxxxxxxxxx> # Date 1328179333 -3600 # Node ID 2708343292be6facb6a2d8aaf9a9d95afa61b7f6 # Parent 478459fa6bfce280bf31e1d971c5f2b39eee6986 libxl: add libxl__parse_nic_hotplug_path Create a libxl_device_nic from hotplug xenstore information. Signed-off-by: Roger Pau Monne <roger.pau@xxxxxxxxxxxxx> diff -r 478459fa6bfc -r 2708343292be tools/libxl/libxl_device.c --- a/tools/libxl/libxl_device.c Thu Feb 02 11:39:24 2012 +0100 +++ b/tools/libxl/libxl_device.c Thu Feb 02 11:42:13 2012 +0100 @@ -123,6 +123,56 @@ int libxl__parse_disk_hotplug_path(libxl return 0; } +int libxl__parse_nic_hotplug_path(libxl__gc *gc, + const char *path, + libxl_device_nic *nic) +{ + libxl_ctx *ctx = libxl__gc_owner(gc); + char *value; + + if (sscanf(path, "/hotplug/%*u/%*u/vif/%d", &nic->devid) != 1) { + LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Unable to get nic device id from " + "%s", path); + return -1; + } + + value = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/%s", path, + "mtu")); + if (value) + nic->mtu = atoi(value); + + nic->model = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/%s", path, + "model")); + + value = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/%s", path, + "mac")); + if (value) { + if (sscanf(value, LIBXL_MAC_FMT, LIBXL_MAC_BYTES(&nic->mac)) != 6) { + LIBXL__LOG(ctx, LIBXL__LOG_ERROR, "Unable to parse mac %s", value); + return -1; + } + } + + nic->ip = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/%s", path, + "ip")); + + nic->bridge = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/%s", path, + "bridge")); + nic->ifname = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/%s", path, + "ifname")); + + nic->script = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/%s", path, + "script")); + + value = libxl__xs_read(gc, XBT_NULL, libxl__sprintf(gc, "%s/%s", path, + "nictype")); + if (value) + nic->nictype = atoi(value); + + return 0; +} + + int libxl__device_generic_add(libxl__gc *gc, libxl__device *device, char **bents, char **fents) { diff -r 478459fa6bfc -r 2708343292be tools/libxl/libxl_internal.h --- a/tools/libxl/libxl_internal.h Thu Feb 02 11:39:24 2012 +0100 +++ b/tools/libxl/libxl_internal.h Thu Feb 02 11:42:13 2012 +0100 @@ -313,6 +313,9 @@ typedef struct { _hidden int libxl__parse_disk_hotplug_path(libxl__gc *gc, const char *path, libxl_device_disk *disk); +_hidden int libxl__parse_nic_hotplug_path(libxl__gc *gc, + const char *path, + libxl_device_nic *nic); _hidden int libxl__device_remove(libxl__gc *gc, libxl__device *dev); _hidden int libxl__device_destroy(libxl__gc *gc, libxl__device *dev); _hidden int libxl__devices_destroy(libxl__gc *gc, uint32_t domid); _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |