ia64/xen-unstable

changeset 4299:e769a20ff878

bitkeeper revision 1.1159.258.64 (42433016pzi5kr8wggkPTZcHlxXCpg)

Back out changes to netif backend messaging to set vifname.
Try using 'ip link' instead.

Signed-off-by: Mike Wray <mike.wray@hp.com>
author mjw@wray-m-3.hpl.hp.com
date Thu Mar 24 21:24:38 2005 +0000 (2005-03-24)
parents 633ed557a95c
children ac7313eb3788
files linux-2.6.11-xen-sparse/drivers/xen/netback/interface.c tools/python/xen/lowlevel/xu/xu.c tools/python/xen/xend/Vifctl.py tools/python/xen/xend/server/netif.py xen/include/public/io/domain_controller.h
line diff
     1.1 --- a/linux-2.6.11-xen-sparse/drivers/xen/netback/interface.c	Mon Mar 21 16:33:03 2005 +0000
     1.2 +++ b/linux-2.6.11-xen-sparse/drivers/xen/netback/interface.c	Thu Mar 24 21:24:38 2005 +0000
     1.3 @@ -121,11 +121,7 @@ void netif_create(netif_be_create_t *cre
     1.4      netif_t          **pnetif, *netif;
     1.5      char               name[IFNAMSIZ] = {};
     1.6  
     1.7 -    if(create->vifname[0] == '\0'){
     1.8 -        snprintf(name, IFNAMSIZ - 1, "vif%u.%u", domid, handle);
     1.9 -    } else {
    1.10 -        snprintf(name, IFNAMSIZ - 1, "%s", create->vifname);
    1.11 -    }
    1.12 +    snprintf(name, IFNAMSIZ - 1, "vif%u.%u", domid, handle);
    1.13      dev = alloc_netdev(sizeof(netif_t), name, ether_setup);
    1.14      if ( dev == NULL )
    1.15      {
     2.1 --- a/tools/python/xen/lowlevel/xu/xu.c	Mon Mar 21 16:33:03 2005 +0000
     2.2 +++ b/tools/python/xen/lowlevel/xu/xu.c	Thu Mar 24 21:24:38 2005 +0000
     2.3 @@ -480,7 +480,6 @@ static PyObject *xu_message_get_payload(
     2.4          C2P(netif_be_create_t, domid,        Int, Long);
     2.5          C2P(netif_be_create_t, netif_handle, Int, Long);
     2.6          C2P(netif_be_create_t, status,       Int, Long);
     2.7 -        C2P(netif_be_create_t, vifname,      String, String);
     2.8          return dict;
     2.9      case TYPE(CMSG_NETIF_BE, CMSG_NETIF_BE_DESTROY):
    2.10          C2P(netif_be_destroy_t, domid,        Int, Long);
    2.11 @@ -648,7 +647,6 @@ static PyObject *xu_message_new(PyObject
    2.12          P2C(netif_be_create_t, mac[3],       u8);
    2.13          P2C(netif_be_create_t, mac[4],       u8);
    2.14          P2C(netif_be_create_t, mac[5],       u8);
    2.15 -        P2CSTRING(netif_be_create_t, vifname);
    2.16          break;
    2.17      case TYPE(CMSG_NETIF_BE, CMSG_NETIF_BE_DESTROY):
    2.18          P2C(netif_be_destroy_t, domid,        u32);
     3.1 --- a/tools/python/xen/xend/Vifctl.py	Mon Mar 21 16:33:03 2005 +0000
     3.2 +++ b/tools/python/xen/xend/Vifctl.py	Thu Mar 24 21:24:38 2005 +0000
     3.3 @@ -37,6 +37,19 @@ def network(op, script=None, bridge=None
     3.4      args = ' '.join(args)
     3.5      os.system(script + ' ' + args)
     3.6  
     3.7 +def set_vif_name(vif_old, vif_new):
     3.8 +    if vif_old == vif_new:
     3.9 +        vif = view_new
    3.10 +    if os.system("ip link show %s" % vif_old) == 0:
    3.11 +        os.system("ip link set %s down" % vif_old)
    3.12 +        os.system("ip link set %s name %s" % (vif_old, vif_new))
    3.13 +        os.system("ip link set %s up" % vif_new)
    3.14 +    if os.system("ip link show %s" % vif_new) == 0:
    3.15 +        vif = vif_new
    3.16 +    else:
    3.17 +        vif = vif_old
    3.18 +    return vif
    3.19 +
    3.20  def vifctl(op, vif=None, script=None, domain=None, mac=None, bridge=None, ipaddr=[]):
    3.21      """Call a vif control script.
    3.22      Xend calls this when bringing vifs up or down.
     4.1 --- a/tools/python/xen/xend/server/netif.py	Mon Mar 21 16:33:03 2005 +0000
     4.2 +++ b/tools/python/xen/xend/server/netif.py	Thu Mar 24 21:24:38 2005 +0000
     4.3 @@ -134,7 +134,7 @@ class NetDev(controller.SplitDev):
     4.4  
     4.5          self.vifname = sxp.child_value(config, 'vifname')
     4.6          if self.vifname is None:
     4.7 -            self.vifname = "vif%d.%d" % (self.controller.dom, self.vif)
     4.8 +            self.vifname = self.default_vifname()
     4.9          if len(self.vifname) > 15:
    4.10              raise XendError('invalid vifname: too long: ' + self.vifname)
    4.11          mac = self._get_config_mac(config)
    4.12 @@ -217,6 +217,9 @@ class NetDev(controller.SplitDev):
    4.13          """
    4.14          return self.vifname
    4.15  
    4.16 +    def default_vifname(self):
    4.17 +        return "vif%d.%d" % (self.controller.dom, self.vif)
    4.18 +    
    4.19      def get_mac(self):
    4.20          """Get the MAC address as a string.
    4.21          """
    4.22 @@ -248,6 +251,8 @@ class NetDev(controller.SplitDev):
    4.23          @param op: operation name (up, down)
    4.24          @param vmname: vmname
    4.25          """
    4.26 +        if op == 'up':
    4.27 +            Vifctl.set_vif_name(self.default_vifname(), self.vifname)
    4.28          Vifctl.vifctl(op, **self.vifctl_params(vmname=vmname))
    4.29          vnet = XendVnet.instance().vnet_of_bridge(self.bridge)
    4.30          if vnet:
    4.31 @@ -276,7 +281,7 @@ class NetDev(controller.SplitDev):
    4.32                        { 'domid'        : self.controller.dom,
    4.33                          'netif_handle' : self.vif,
    4.34                          'mac'          : self.mac,
    4.35 -                        'vifname'      : self.vifname
    4.36 +                        #'vifname'      : self.vifname
    4.37                          })
    4.38          self.getBackendInterface().writeRequest(msg, response=d)
    4.39          return d
     5.1 --- a/xen/include/public/io/domain_controller.h	Mon Mar 21 16:33:03 2005 +0000
     5.2 +++ b/xen/include/public/io/domain_controller.h	Thu Mar 24 21:24:38 2005 +0000
     5.3 @@ -466,10 +466,9 @@ typedef struct {
     5.4      u32        netif_handle;  /*  4: Domain-specific interface handle.   */
     5.5      u8         mac[6];        /*  8 */
     5.6      u16        __pad1;        /* 14 */
     5.7 -    char       vifname[16];   /* 16 */
     5.8      /* OUT */
     5.9 -    u32        status;        /* 32 */
    5.10 -} PACKED netif_be_create_t; /* 36 bytes */
    5.11 +    u32        status;        /* 16 */
    5.12 +} PACKED netif_be_create_t; /* 20 bytes */
    5.13  
    5.14  /*
    5.15   * CMSG_NETIF_BE_DESTROY: