# HG changeset patch
# User Ian Campbell <ian.campbell@xxxxxxxxxx>
# Date 1302106139 -3600
# Node ID a28b8b3880ab73aa663cbce07bc127a87868b348
# Parent ae59c473da8dcd57d473d8d92210db8233f46cfd
libxl/xl: drop support for netchannel2
netchannel2 was never widely deployed and no supported kernel includes
either the front- or back-ends. The last known kernel with this
support was the xen.git 2.6.31 branch which has been unsupported for
ages.
xl will warn the user if it spots a "vif2" configration item but
otherwise support is completely removed.
Work is ongoing to add the interesting features of netchannel2 as
protocol extensions to netchannel1.
Signed-off-by: Ian Campbell <ian.campbell@xxxxxxxxxx>
diff -r ae59c473da8d -r a28b8b3880ab tools/libxl/libxl.c
--- a/tools/libxl/libxl.c Wed Apr 06 16:53:26 2011 +0100
+++ b/tools/libxl/libxl.c Wed Apr 06 17:08:59 2011 +0100
@@ -1379,227 +1379,6 @@ err:
}
/******************************************************************************/
-void libxl_device_net2_init(libxl_device_net2 *net2_info, int devnum)
-{
- const uint8_t *r;
- libxl_uuid uuid;
-
- libxl_uuid_generate(&uuid);
- r = libxl_uuid_bytearray(&uuid);
- memset(net2_info, '\0', sizeof(*net2_info));
-
- net2_info->devid = devnum;
- net2_info->front_mac[0] = 0x00;
- net2_info->front_mac[1] = 0x16;
- net2_info->front_mac[2] = 0x3e;;
- net2_info->front_mac[3] = 0x7f & r[0];
- net2_info->front_mac[4] = r[1];
- net2_info->front_mac[5] = r[2];
- net2_info->back_mac[0] = 0x00;
- net2_info->back_mac[1] = 0x16;
- net2_info->back_mac[2] = 0x3e;
- net2_info->back_mac[3] = 0x7f & r[3];
- net2_info->back_mac[4] = r[4];
- net2_info->back_mac[5] = r[5];
- net2_info->back_trusted = 1;
- net2_info->filter_mac = 1;
- net2_info->max_bypasses = 5;
- net2_info->bridge = strdup("xenbr0");
-}
-
-int libxl_device_net2_add(libxl_ctx *ctx, uint32_t domid, libxl_device_net2
*net2)
-{
- libxl__gc gc = LIBXL_INIT_GC(ctx);
- flexarray_t *front, *back;
- libxl__device device;
- char *dompath, *dom, **l;
- unsigned int nb;
- int rc;
-
- front = flexarray_make(16, 1);
- if (!front) {
- rc = ERROR_NOMEM;
- goto err;
- }
- back = flexarray_make(16, 1);
- if (!back) {
- rc = ERROR_NOMEM;
- goto err_free;
- }
-
- if (!(dompath = libxl__xs_get_dompath(&gc, domid))) {
- rc = ERROR_FAIL;
- goto err_free;
- }
- dom = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc, "%s/name",
dompath));
-
- if (net2->devid == -1) {
- if (!(l = libxl__xs_directory(&gc, XBT_NULL,
- libxl__sprintf(&gc, "%s/device/vif2",
dompath), &nb))) {
- net2->devid = 0;
- } else {
- net2->devid = strtoul(l[nb - 1], NULL, 10) + 1;
- }
- }
-
- device.backend_devid = net2->devid;
- device.backend_domid = net2->backend_domid;
- device.backend_kind = DEVICE_VIF2;
- device.devid = net2->devid;
- device.domid = net2->domid;
- device.kind = DEVICE_VIF2;
-
- flexarray_append(back, "domain");
- flexarray_append(back, dom);
- flexarray_append(back, "frontend-id");
- flexarray_append(back, libxl__sprintf(&gc, "%d", net2->domid));
-
- flexarray_append(back, "local-trusted");
- flexarray_append(back, libxl__sprintf(&gc, "%d", net2->back_trusted));
- flexarray_append(back, "mac");
- flexarray_append(back, libxl__sprintf(&gc, "%02x:%02x:%02x:%02x:%02x:%02x",
- net2->back_mac[0],
net2->back_mac[1],
- net2->back_mac[2],
net2->back_mac[3],
- net2->back_mac[4],
net2->back_mac[5]));
-
- flexarray_append(back, "remote-trusted");
- flexarray_append(back, libxl__sprintf(&gc, "%d", net2->trusted));
- flexarray_append(back, "remote-mac");
- flexarray_append(back, libxl__sprintf(&gc, "%02x:%02x:%02x:%02x:%02x:%02x",
- net2->front_mac[0],
net2->front_mac[1],
- net2->front_mac[2],
net2->front_mac[3],
- net2->front_mac[4],
net2->front_mac[5]));
-
- flexarray_append(back, "max-bypasses");
- flexarray_append(back, libxl__sprintf(&gc, "%d", net2->max_bypasses));
- flexarray_append(back, "filter-mac");
- flexarray_append(back, libxl__sprintf(&gc, "%d", !!(net2->filter_mac)));
- flexarray_append(back, "handle");
- flexarray_append(back, libxl__sprintf(&gc, "%d", net2->devid));
- flexarray_append(back, "online");
- flexarray_append(back, "1");
- flexarray_append(back, "state");
- flexarray_append(back, "1");
-
- flexarray_append(front, "backend-id");
- flexarray_append(front, libxl__sprintf(&gc, "%d", net2->backend_domid));
-
- flexarray_append(front, "local-trusted");
- flexarray_append(front, libxl__sprintf(&gc, "%d", net2->trusted));
- flexarray_append(front, "mac");
- flexarray_append(front, libxl__sprintf(&gc,
"%02x:%02x:%02x:%02x:%02x:%02x",
- net2->front_mac[0],
net2->front_mac[1],
- net2->front_mac[2],
net2->front_mac[3],
- net2->front_mac[4],
net2->front_mac[5]));
-
- flexarray_append(front, "remote-trusted");
- flexarray_append(front, libxl__sprintf(&gc, "%d", net2->back_trusted));
- flexarray_append(front, "remote-mac");
- flexarray_append(front, libxl__sprintf(&gc,
"%02x:%02x:%02x:%02x:%02x:%02x",
- net2->back_mac[0],
net2->back_mac[1],
- net2->back_mac[2],
net2->back_mac[3],
- net2->back_mac[4],
net2->back_mac[5]));
-
- flexarray_append(front, "filter-mac");
- flexarray_append(front, libxl__sprintf(&gc, "%d", !!(net2->filter_mac)));
- flexarray_append(front, "state");
- flexarray_append(front, "1");
-
- libxl__device_generic_add(&gc, &device,
- libxl__xs_kvs_of_flexarray(&gc, back,
back->count),
- libxl__xs_kvs_of_flexarray(&gc, front,
front->count));
-
- /* FIXME: wait for plug */
- rc = 0;
-err_free:
- flexarray_free(back);
- flexarray_free(front);
-err:
- libxl__free_all(&gc);
- return rc;
-}
-
-libxl_net2info *libxl_device_net2_list(libxl_ctx *ctx, uint32_t domid,
unsigned int *nb)
-{
- libxl__gc gc = LIBXL_INIT_GC(ctx);
- char *dompath, *net2_path_fe;
- char **l;
- char *val, *tok;
- unsigned int nb_net2s, i;
- libxl_net2info *res, *net2s;
-
- dompath = libxl__xs_get_dompath(&gc, domid);
- if (!dompath)
- goto err;
- l = libxl__xs_directory(&gc, XBT_NULL,
- libxl__sprintf(&gc, "%s/device/vif2", dompath),
&nb_net2s);
- if (!l)
- goto err;
- res = calloc(nb_net2s, sizeof (libxl_net2info));
- if (!res)
- goto err;
- net2s = res;
- for (*nb = nb_net2s; nb_net2s > 0; --nb_net2s, ++l, ++net2s) {
- net2_path_fe = libxl__sprintf(&gc, "%s/device/vif2/%s", dompath, *l);
-
- net2s->backend = libxl__xs_read(&gc, XBT_NULL,
- libxl__sprintf(&gc, "%s/backend",
net2_path_fe));
- val = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc,
"%s/backend-id", net2_path_fe));
- net2s->backend_id = val ? strtoul(val, NULL, 10) : -1;
-
- net2s->devid = strtoul(*l, NULL, 10);
- val = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc, "%s/state",
net2_path_fe));
- net2s->state = val ? strtoul(val, NULL, 10) : -1;
-
- val = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc, "%s/mac",
net2_path_fe));
- for (i = 0, tok = strtok(val, ":"); tok && (i < 6);
- ++i, tok = strtok(NULL, ":")) {
- net2s->mac[i] = strtoul(tok, NULL, 16);
- }
- val = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc,
"%s/remote-trusted", net2_path_fe));
- net2s->trusted = val ? strtoul(val, NULL, 10) : -1;
-
- val = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc,
"%s/remote-mac", net2_path_fe));
- for (i = 0, tok = strtok(val, ":"); tok && (i < 6);
- ++i, tok = strtok(NULL, ":")) {
- net2s->back_mac[i] = strtoul(tok, NULL, 16);
- }
- val = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc,
"%s/filter-mac", net2_path_fe));
- net2s->filter_mac = val ? strtoul(val, NULL, 10) : -1;
-
- net2s->frontend = libxl__xs_read(&gc, XBT_NULL,
- libxl__sprintf(&gc, "%s/frontend",
net2s->backend));
- val = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc,
"%s/frontend-id", net2s->backend));
- net2s->frontend_id = val ? strtoul(val, NULL, 10) : -1;
- }
-
- libxl__free_all(&gc);
- return res;
-err:
- libxl__free_all(&gc);
- return NULL;
-}
-
-int libxl_device_net2_del(libxl_ctx *ctx, libxl_device_net2 *net2, int wait)
-{
- libxl__gc gc = LIBXL_INIT_GC(ctx);
- libxl__device device;
- int rc;
-
- device.backend_devid = net2->devid;
- device.backend_domid = net2->backend_domid;
- device.backend_kind = DEVICE_VIF2;
- device.devid = net2->devid;
- device.domid = net2->domid;
- device.kind = DEVICE_VIF2;
-
- rc = libxl__device_del(&gc, &device, wait);
- libxl__free_all(&gc);
- return rc;
-}
-
-
-/******************************************************************************/
int libxl_device_console_add(libxl_ctx *ctx, uint32_t domid,
libxl_device_console *console)
{
libxl__gc gc = LIBXL_INIT_GC(ctx);
diff -r ae59c473da8d -r a28b8b3880ab tools/libxl/libxl.h
--- a/tools/libxl/libxl.h Wed Apr 06 16:53:26 2011 +0100
+++ b/tools/libxl/libxl.h Wed Apr 06 17:08:59 2011 +0100
@@ -262,11 +262,10 @@ typedef struct {
libxl_domain_build_info b_info;
libxl_device_model_info dm_info;
- int num_disks, num_vifs, num_vif2s, num_pcidevs, num_vfbs, num_vkbs;
+ int num_disks, num_vifs, num_pcidevs, num_vfbs, num_vkbs;
libxl_device_disk *disks;
libxl_device_nic *vifs;
- libxl_device_net2 *vif2s;
libxl_device_pci *pcidevs;
libxl_device_vfb *vfbs;
libxl_device_vkb *vkbs;
@@ -535,14 +534,6 @@ int libxl_tmem_shared_auth(libxl_ctx *ct
int auth);
int libxl_tmem_freeable(libxl_ctx *ctx);
-void libxl_device_net2_init(libxl_device_net2 *net2, int dev_num);
-int libxl_device_net2_add(libxl_ctx *ctx, uint32_t domid,
- libxl_device_net2 *net2);
-libxl_net2info *libxl_device_net2_list(libxl_ctx *ctx, uint32_t domid,
- unsigned int *nb);
-int libxl_device_net2_del(libxl_ctx *ctx, libxl_device_net2 *net2,
- int wait);
-
int libxl_get_freecpus(libxl_ctx *ctx, libxl_cpumap *cpumap);
int libxl_create_cpupool(libxl_ctx *ctx, const char *name, int schedid,
libxl_cpumap cpumap, libxl_uuid *uuid,
diff -r ae59c473da8d -r a28b8b3880ab tools/libxl/libxl.idl
--- a/tools/libxl/libxl.idl Wed Apr 06 16:53:26 2011 +0100
+++ b/tools/libxl/libxl.idl Wed Apr 06 17:08:59 2011 +0100
@@ -228,21 +228,6 @@ libxl_device_nic = Struct("device_nic",
("nictype", libxl_nic_type),
])
-libxl_device_net2 = Struct("device_net2", [
- ("devid", integer),
- ("front_mac", libxl_mac),
- ("back_mac", libxl_mac),
- ("backend_domid", uint32),
- ("domid", domid),
- ("trusted", BitField(uint32, 1)),
- ("back_trusted", BitField(uint32, 1)),
- ("filter_mac", BitField(uint32, 1)),
- ("front_filter_mac", BitField(uint32, 1)),
- ("pdev", uint32),
- ("max_bypasses", uint32),
- ("bridge", string),
- ])
-
libxl_device_pci = Struct("device_pci", [
("func", uint8),
("dev", uint8),
@@ -316,16 +301,3 @@ libxl_sched_credit = Struct("sched_credi
("weight", integer),
("cap", integer),
], destructor_fn=None)
-
-libxl_net2info = Struct("net2info", [
- ("backend", string),
- ("backend_id", uint32),
- ("frontend", string),
- ("frontend_id", uint32),
- ("devid", integer),
- ("state", integer),
- ("mac", libxl_mac),
- ("trusted", integer),
- ("back_mac", libxl_mac),
- ("filter_mac", integer),
- ])
diff -r ae59c473da8d -r a28b8b3880ab tools/libxl/libxl_create.c
--- a/tools/libxl/libxl_create.c Wed Apr 06 16:53:26 2011 +0100
+++ b/tools/libxl/libxl_create.c Wed Apr 06 17:08:59 2011 +0100
@@ -43,10 +43,6 @@ void libxl_domain_config_destroy(libxl_d
libxl_device_nic_destroy(&d_config->vifs[i]);
free(d_config->vifs);
- for (i=0; i<d_config->num_vif2s; i++)
- libxl_device_net2_destroy(&d_config->vif2s[i]);
- free(d_config->vif2s);
-
for (i=0; i<d_config->num_pcidevs; i++)
libxl_device_pci_destroy(&d_config->pcidevs[i]);
free(d_config->pcidevs);
@@ -464,17 +460,6 @@ static int do_domain_create(libxl__gc *g
goto error_out;
}
}
- if (!d_config->c_info.hvm) {
- for (i = 0; i < d_config->num_vif2s; i++) {
- d_config->vif2s[i].domid = domid;
- ret = libxl_device_net2_add(ctx, domid, &d_config->vif2s[i]);
- if (ret) {
- fprintf(stderr, "cannot add net2 %d to domain: %d\n", i, ret);
- ret = ERROR_FAIL;
- goto error_out;
- }
- }
- }
if (d_config->c_info.hvm) {
libxl_device_console console;
diff -r ae59c473da8d -r a28b8b3880ab tools/libxl/libxl_device.c
--- a/tools/libxl/libxl_device.c Wed Apr 06 16:53:26 2011 +0100
+++ b/tools/libxl/libxl_device.c Wed Apr 06 17:08:59 2011 +0100
@@ -30,7 +30,6 @@
static const char *string_of_kinds[] = {
[DEVICE_VIF] = "vif",
- [DEVICE_VIF2] = "vif2",
[DEVICE_VBD] = "vbd",
[DEVICE_TAP] = "tap",
[DEVICE_QDISK] = "qdisk",
diff -r ae59c473da8d -r a28b8b3880ab tools/libxl/libxl_utils.c
--- a/tools/libxl/libxl_utils.c Wed Apr 06 16:53:26 2011 +0100
+++ b/tools/libxl/libxl_utils.c Wed Apr 06 17:08:59 2011 +0100
@@ -570,75 +570,6 @@ out:
return rc;
}
-int libxl_devid_to_device_net2(libxl_ctx *ctx, uint32_t domid,
- const char *devid, libxl_device_net2 *net2)
-{
- libxl__gc gc = LIBXL_INIT_GC(ctx);
- char *tok, *endptr, *val;
- char *dompath, *net2path, *be_path;
- unsigned int devid_n, i;
- int rc = ERROR_INVAL;
-
- devid_n = strtoul(devid, &endptr, 10);
- if (devid == endptr) {
- goto out;
- }
- rc = ERROR_FAIL;
- dompath = libxl__xs_get_dompath(&gc, domid);
- net2path = libxl__sprintf(&gc, "%s/device/vif2/%s", dompath, devid);
- if (!net2path) {
- goto out;
- }
- memset(net2, 0, sizeof (libxl_device_net2));
- be_path = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc, "%s/backend",
net2path));
-
- net2->devid = devid_n;
- val = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc, "%s/mac",
net2path));
- for (i = 0, tok = strtok(val, ":"); tok && (i < 6);
- ++i, tok = strtok(NULL, ":")) {
- net2->front_mac[i] = strtoul(tok, NULL, 16);
- }
- val = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc, "%s/remote-mac",
net2path));
- for (i = 0, tok = strtok(val, ":"); tok && (i < 6);
- ++i, tok = strtok(NULL, ":")) {
- net2->back_mac[i] = strtoul(tok, NULL, 16);
- }
- val = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc, "%s/backend-id",
net2path));
- net2->backend_domid = strtoul(val, NULL, 10);
-
- net2->domid = domid;
- val = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc,
"%s/remote-trusted", be_path));
- net2->trusted = strtoul(val, NULL, 10);
- val = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc,
"%s/local-trusted", be_path));
- net2->back_trusted = strtoul(val, NULL, 10);
- val = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc, "%s/filter-mac",
be_path));
- net2->filter_mac = strtoul(val, NULL, 10);
- val = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc, "%s/filter-mac",
net2path));
- net2->front_filter_mac = strtoul(val, NULL, 10);
- val = libxl__xs_read(&gc, XBT_NULL, libxl__sprintf(&gc, "%s/max-bypasses",
be_path));
- net2->max_bypasses = strtoul(val, NULL, 10);
- rc = 0;
-
-out:
- libxl__free_all(&gc);
- return rc;
-}
-
-int libxl_strtomac(const char *mac_s, uint8_t *mac)
-{
- const char *end = mac_s + 17;
- char val, *endptr;
-
- for (; mac_s < end; mac_s += 3, ++mac) {
- val = strtoul(mac_s, &endptr, 16);
- if (endptr != (mac_s + 2)) {
- return ERROR_INVAL;
- }
- *mac = val;
- }
- return 0;
-}
-
#define QEMU_VERSION_STR "QEMU emulator version "
diff -r ae59c473da8d -r a28b8b3880ab tools/libxl/libxl_utils.h
--- a/tools/libxl/libxl_utils.h Wed Apr 06 16:53:26 2011 +0100
+++ b/tools/libxl/libxl_utils.h Wed Apr 06 17:08:59 2011 +0100
@@ -66,11 +66,6 @@ int libxl_devid_to_device_nic(libxl_ctx
int libxl_devid_to_device_disk(libxl_ctx *ctx, uint32_t domid,
const char *devid, libxl_device_disk *disk);
-int libxl_strtomac(const char *mac_s, uint8_t *mac);
-
-int libxl_devid_to_device_net2(libxl_ctx *ctx, uint32_t domid,
- const char *devid, libxl_device_net2 *net2);
-
/* check the version of qemu
* return 1 if is the new one
* return 0 if is the old one
diff -r ae59c473da8d -r a28b8b3880ab tools/libxl/xl_cmdimpl.c
--- a/tools/libxl/xl_cmdimpl.c Wed Apr 06 16:53:26 2011 +0100
+++ b/tools/libxl/xl_cmdimpl.c Wed Apr 06 17:08:59 2011 +0100
@@ -620,7 +620,7 @@ static void parse_config_data(const char
const char *buf;
long l;
XLU_Config *config;
- XLU_ConfigList *vbds, *nics, *pcis, *cvfbs, *net2s, *cpuids;
+ XLU_ConfigList *vbds, *nics, *pcis, *cvfbs, *cpuids;
int pci_power_mgmt = 0;
int pci_msitranslate = 1;
int e;
@@ -895,53 +895,8 @@ skip:
}
}
- if (!xlu_cfg_get_list(config, "vif2", &net2s, 0, 0)) {
- d_config->num_vif2s = 0;
- d_config->vif2s = NULL;
- while ((buf = xlu_cfg_get_listitem(net2s, d_config->num_vif2s))) {
- libxl_device_net2 *net2;
- char *buf2 = strdup(buf);
- char *p;
-
- d_config->vif2s = realloc(d_config->vif2s, sizeof
(libxl_device_net2) * (d_config->num_vif2s + 1));
- net2 = d_config->vif2s + d_config->num_vif2s;
-
- libxl_device_net2_init(net2, d_config->num_vif2s);
-
- for (p = strtok(buf2, ","); p; p = strtok(NULL, ",")) {
- char* val;
- while (isblank(*p))
- p++;
- val = strchr(p, '=');
- if (val == NULL)
- continue;
- *val++ = 0;
- if (!strcmp("front_mac", p)) {
- libxl_strtomac(val, net2->front_mac);
- } else if (!strcmp("back_mac", p)) {
- libxl_strtomac(val, net2->back_mac);
- } else if (!strcmp("backend", p)) {
- domain_qualifier_to_domid(val, &net2->backend_domid, 0);
- } else if (!strcmp("trusted", p)) {
- net2->trusted = (*val == '1');
- } else if (!strcmp("back_trusted", p)) {
- net2->back_trusted = (*val == '1');
- } else if (!strcmp("bridge", p)) {
- free(net2->bridge);
- net2->bridge = strdup(val);
- } else if (!strcmp("filter_mac", p)) {
- net2->filter_mac = (*val == '1');
- } else if (!strcmp("front_filter_mac", p)) {
- net2->front_filter_mac = (*val == '1');
- } else if (!strcmp("pdev", p)) {
- net2->pdev = strtoul(val, NULL, 10);
- } else if (!strcmp("max_bypasses", p)) {
- net2->max_bypasses = strtoul(val, NULL, 10);
- }
- }
- free(buf2);
- d_config->num_vif2s++;
- }
+ if (!xlu_cfg_get_list(config, "vif2", NULL, 0, 0)) {
+ fprintf(stderr, "WARNING: vif2: netchannel2 is deprecated and not
supported by xl\n");
}
if (!xlu_cfg_get_list (config, "vfb", &cvfbs, 0, 0)) {
@@ -4569,183 +4524,6 @@ int main_blockdetach(int argc, char **ar
return 0;
}
-int main_network2attach(int argc, char **argv)
-{
- int opt;
- const char *tok;
- char *endptr;
- const char *back_dom = NULL;
- uint32_t domid, back_domid;
- unsigned int val, i;
- libxl_device_net2 net2;
-
- while ((opt = getopt(argc, argv, "h")) != -1) {
- switch (opt) {
- case 'h':
- help("network2-attach");
- return 0;
- default:
- fprintf(stderr, "option `%c' not supported.\n", optopt);
- break;
- }
- }
- if ((argc-optind < 1) || (argc-optind > 10)) {
- help("network2-attach");
- return 0;
- }
-
- if (domain_qualifier_to_domid(argv[optind], &domid, 0) < 0) {
- fprintf(stderr, "%s is an invalid domain identifier\n", argv[optind]);
- return 1;
- }
- libxl_device_net2_init(&net2, -1);
- for (argv += optind+1, argc -= optind+1; argc > 0; --argc, ++argv) {
- if (!strncmp("front_mac=", *argv, 10)) {
- tok = strtok((*argv) + 10, ":");
- for (i = 0; tok && i < 6; tok = strtok(NULL, ":"), ++i) {
- val = strtoul(tok, &endptr, 16);
- if ((tok == endptr) || (val > 255)) {
- fprintf(stderr, "Invalid parameter `front_mac'.\n");
- return 1;
- }
- net2.front_mac[i] = val;
- }
- } else if (!strncmp("back_mac=", *argv, 9)) {
- tok = strtok((*argv) + 10, ":");
- for (i = 0; tok && i < 6; tok = strtok(NULL, ":"), ++i) {
- val = strtoul(tok, &endptr, 16);
- if ((tok == endptr) || (val > 255)) {
- fprintf(stderr, "Invalid parameter back_mac=%s.\n", *argv
+ 9);
- return 1;
- }
- net2.back_mac[i] = val;
- }
- } else if (!strncmp("backend=", *argv, 8)) {
- back_dom = *argv;
- } else if (!strncmp("trusted=", *argv, 8)) {
- net2.trusted = (*((*argv) + 8) == '1');
- } else if (!strncmp("back_trusted=", *argv, 13)) {
- net2.back_trusted = (*((*argv) + 13) == '1');
- } else if (!strncmp("bridge=", *argv, 7)) {
- net2.bridge = *argv + 13;
- } else if (!strncmp("filter_mac=", *argv, 11)) {
- net2.filter_mac = (*((*argv) + 11) == '1');
- } else if (!strncmp("front_filter_mac=", *argv, 17)) {
- net2.front_filter_mac = (*((*argv) + 17) == '1');
- } else if (!strncmp("pdev=", *argv, 5)) {
- val = strtoul(*argv + 5, &endptr, 10);
- if (endptr == (*argv + 5)) {
- fprintf(stderr, "Invalid parameter pdev=%s.\n", *argv + 5);
- return 1;
- }
- net2.pdev = val;
- } else if (!strncmp("max_bypasses=", *argv, 13)) {
- val = strtoul(*argv + 13, &endptr, 10);
- if (endptr == (*argv + 13)) {
- fprintf(stderr, "Invalid parameter max_bypasses=%s.\n", *argv
+ 13);
- return 1;
- }
- net2.max_bypasses = val;
- } else {
- fprintf(stderr, "unrecognized argument `%s'\n", *argv);
- return 1;
- }
- }
-
- if (back_dom) {
- if (domain_qualifier_to_domid(back_dom, &back_domid, 0) < 0) {
- fprintf(stderr, "%s is an invalid domain identifier\n", back_dom);
- return 1;
- }
- }
- net2.domid = domid;
- net2.backend_domid = back_domid;
- if (libxl_device_net2_add(ctx, domid, &net2)) {
- fprintf(stderr, "libxl_device_net2_add failed.\n");
- }
- return 0;
-}
-
-int main_network2list(int argc, char **argv)
-{
- int opt;
- unsigned int nb;
- libxl_net2info *net2s;
-
- while ((opt = getopt(argc, argv, "h")) != -1) {
- switch (opt) {
- case 'h':
- help("network2-list");
- return 0;
- default:
- fprintf(stderr, "option `%c' not supported.\n", optopt);
- break;
- }
- }
- if (argc - optind < 1) {
- help("network2-list");
- return 0;
- }
-
- printf("%-3s %-2s %-5s %-17s %-17s %-7s %-6s %-30s\n",
- "Idx", "BE", "state", "Mac Addr.", "Remote Mac Addr.",
- "trusted", "filter", "backend");
- for (argv += optind, argc -=optind; argc > 0; --argc, ++argv) {
- if (domain_qualifier_to_domid(*argv, &domid, 0) < 0) {
- fprintf(stderr, "%s is an invalid domain identifier\n", *argv);
- continue;
- }
- if ((net2s = libxl_device_net2_list(ctx, domid, &nb))) {
- for (; nb > 0; --nb, ++net2s) {
- printf("%3d %2d %5d ", net2s->devid, net2s->backend_id,
net2s->state);
- printf("%02x:%02x:%02x:%02x:%02x:%02x ",
- net2s->mac[0], net2s->mac[1], net2s->mac[2],
- net2s->mac[3], net2s->mac[4], net2s->mac[5]);
- printf("%02x:%02x:%02x:%02x:%02x:%02x ",
- net2s->back_mac[0], net2s->back_mac[1],
net2s->back_mac[2],
- net2s->back_mac[3], net2s->back_mac[4],
net2s->back_mac[5]);
- printf("%-7d %-6d %-30s\n", net2s->trusted, net2s->filter_mac,
net2s->backend);
- }
- }
- }
- return 0;
-}
-
-int main_network2detach(int argc, char **argv)
-{
- int opt;
- libxl_device_net2 net2;
-
- while ((opt = getopt(argc, argv, "h")) != -1) {
- switch (opt) {
- case 'h':
- help("network2-detach");
- return 0;
- default:
- fprintf(stderr, "option `%c' not supported.\n", optopt);
- break;
- }
- }
- if (argc-optind != 2) {
- help("network2-detach");
- return 0;
- }
-
- if (domain_qualifier_to_domid(argv[optind], &domid, 0) < 0) {
- fprintf(stderr, "%s is an invalid domain identifier\n", argv[optind]);
- return 1;
- }
- if (libxl_devid_to_device_net2(ctx, domid, argv[optind+1], &net2)) {
- fprintf(stderr, "Error: Device %s not connected.\n", argv[optind+1]);
- return 1;
- }
- if (libxl_device_net2_del(ctx, &net2, 1)) {
- fprintf(stderr, "libxl_device_net2_del failed.\n");
- return 1;
- }
- return 0;
-}
-
static char *uptime_to_string(unsigned long time, int short_mode)
{
int sec, min, hour, day;
diff -r ae59c473da8d -r a28b8b3880ab tools/libxl/xl_cmdtable.c
--- a/tools/libxl/xl_cmdtable.c Wed Apr 06 16:53:26 2011 +0100
+++ b/tools/libxl/xl_cmdtable.c Wed Apr 06 17:08:59 2011 +0100
@@ -320,24 +320,6 @@ struct cmd_spec cmd_table[] = {
"Get information about how much freeable memory (MB) is in-use by tmem",
"",
},
- { "network2-attach",
- &main_network2attach,
- "Create a new version 2 virtual network device",
- "<Domain> [front_mac=<mac>] [back_mac=<mac>] [backend=<BackDomain>]"
- " [trusted=<0|1>] [back_trusted=<0|1>] [bridge=<bridge>]"
- " [filter_mac=<0|1>] [front_filter_mac=<0|1>] [pdev=<PDEV>]"
- " [max_bypasses=n]",
- },
- { "network2-list",
- &main_network2list,
- "list version 2 virtual network interfaces for a domain",
- "<Domain(s)>",
- },
- { "network2-detach",
- &main_network2detach,
- "destroy a domain's version 2 virtual network device",
- "<Domain> <DevId>",
- },
{ "cpupool-create",
&main_cpupoolcreate,
"Create a CPU pool based an ConfigFile",
_______________________________________________
Xen-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel
|