ia64/xen-unstable

changeset 7770:6a593de2f8ba

This patch use same expression as vif for vmx guest but has a distinguish "type=ioemu"
just like block device.
e.g. vif=['type=ioemu, mac=01:00:00:00:00:33, bridge=xenbr0']
type=ioemu to specify for vmx NIC device.
nics=4 can specify 4 vmx NIC now.
bridge is passed to device model now.
With this patch, the error
"Error: Device 0 (vif) could not be connected."
will not happen for creating vmx guest
currently, it happens on some linux distribution.

Signed-off-by: Xiaofeng Ling <xiaofeng.ling@intel.com>
author Xiaofeng Ling <xiaofeng.ling@intel.com>
date Thu Nov 10 17:07:13 2005 +0100 (2005-11-10)
parents 10e6946477b8
children 476d02c1346c c927e3761a96
files tools/examples/xmexample.vmx tools/ioemu/target-i386-dm/qemu-ifup tools/ioemu/vl.c tools/python/xen/xend/image.py tools/python/xen/xend/server/netif.py tools/python/xen/xm/create.py
line diff
     1.1 --- a/tools/examples/xmexample.vmx	Thu Nov 10 16:59:51 2005 +0100
     1.2 +++ b/tools/examples/xmexample.vmx	Thu Nov 10 17:07:13 2005 +0100
     1.3 @@ -35,7 +35,11 @@ vcpus=1
     1.4  
     1.5  # Optionally define mac and/or bridge for the network interfaces.
     1.6  # Random MACs are assigned if not given.
     1.7 -#vif = [ 'mac=aa:00:00:00:00:11, bridge=xenbr0' ]
     1.8 +# nics default is 1
     1.9 +#vif = [ 'type=ioemu, mac=aa:00:00:00:00:11, bridge=xenbr0' ]
    1.10 +nics=1 
    1.11 +# type=ioemu specify the NIC is an ioemu device not netfront
    1.12 +vif = [ 'type=ioemu, bridge=xenbr0' ]
    1.13  
    1.14  #----------------------------------------------------------------------------
    1.15  # Define the disk devices you want the domain to have access to, and
     2.1 --- a/tools/ioemu/target-i386-dm/qemu-ifup	Thu Nov 10 16:59:51 2005 +0100
     2.2 +++ b/tools/ioemu/target-i386-dm/qemu-ifup	Thu Nov 10 17:07:13 2005 +0100
     2.3 @@ -7,4 +7,4 @@ echo 'config qemu network with xen bridg
     2.4  echo $*
     2.5  
     2.6  ifconfig $1 0.0.0.0 up
     2.7 -brctl addif xenbr0 $1
     2.8 +brctl addif $2 $1
     3.1 --- a/tools/ioemu/vl.c	Thu Nov 10 16:59:51 2005 +0100
     3.2 +++ b/tools/ioemu/vl.c	Thu Nov 10 17:07:13 2005 +0100
     3.3 @@ -124,6 +124,7 @@ int domid = -1;
     3.4  static char network_script[1024];
     3.5  int pit_min_timer_count = 0;
     3.6  int nb_nics;
     3.7 +char bridge[16];
     3.8  NetDriverState nd_table[MAX_NICS];
     3.9  QEMUTimer *gui_timer;
    3.10  QEMUTimer *polling_timer;
    3.11 @@ -1586,7 +1587,7 @@ static void tun_add_read_packet(NetDrive
    3.12  static int net_tun_init(NetDriverState *nd)
    3.13  {
    3.14      int pid, status;
    3.15 -    char *args[3];
    3.16 +    char *args[4];
    3.17      char **parg;
    3.18      extern int highest_fds;
    3.19  
    3.20 @@ -1602,6 +1603,7 @@ static int net_tun_init(NetDriverState *
    3.21              parg = args;
    3.22              *parg++ = network_script;
    3.23              *parg++ = nd->ifname;
    3.24 +            *parg++ = bridge;
    3.25              *parg++ = NULL;
    3.26              execv(network_script, args);
    3.27              exit(1);
    3.28 @@ -2207,6 +2209,7 @@ void help(void)
    3.29             "Network options:\n"
    3.30             "-nics n         simulate 'n' network cards [default=1]\n"
    3.31             "-macaddr addr   set the mac address of the first interface\n"
    3.32 +           "-bridge  br     set the bridge interface for nic\n"
    3.33             "-n script       set tap/tun network init script [default=%s]\n"
    3.34             "-tun-fd fd      use this fd as already opened tap/tun interface\n"
    3.35  #ifdef CONFIG_SLIRP
    3.36 @@ -2297,6 +2300,7 @@ enum {
    3.37  
    3.38      QEMU_OPTION_nics,
    3.39      QEMU_OPTION_macaddr,
    3.40 +    QEMU_OPTION_bridge,
    3.41      QEMU_OPTION_n,
    3.42      QEMU_OPTION_tun_fd,
    3.43      QEMU_OPTION_user_net,
    3.44 @@ -2367,6 +2371,7 @@ const QEMUOption qemu_options[] = {
    3.45  
    3.46      { "nics", HAS_ARG, QEMU_OPTION_nics},
    3.47      { "macaddr", HAS_ARG, QEMU_OPTION_macaddr},
    3.48 +    { "bridge", HAS_ARG, QEMU_OPTION_bridge},
    3.49      { "n", HAS_ARG, QEMU_OPTION_n },
    3.50      { "tun-fd", HAS_ARG, QEMU_OPTION_tun_fd },
    3.51  #ifdef CONFIG_SLIRP
    3.52 @@ -2825,6 +2830,9 @@ int main(int argc, char **argv)
    3.53                      exit(1);
    3.54                  }
    3.55                  break;
    3.56 +            case QEMU_OPTION_bridge:
    3.57 +                pstrcpy(bridge, sizeof(bridge), optarg);
    3.58 +                break;
    3.59              case QEMU_OPTION_macaddr:
    3.60                  {
    3.61                      const char *p;
     4.1 --- a/tools/python/xen/xend/image.py	Thu Nov 10 16:59:51 2005 +0100
     4.2 +++ b/tools/python/xen/xend/image.py	Thu Nov 10 17:07:13 2005 +0100
     4.3 @@ -258,6 +258,7 @@ class VmxImageHandler(ImageHandler):
     4.4              log.debug("args: %s, val: %s" % (a,v))
     4.5  
     4.6          # Handle disk/network related options
     4.7 +        mac = None
     4.8          for (name, info) in deviceConfig:
     4.9              if name == 'vbd':
    4.10                 uname = sxp.child_value(info, 'uname')
    4.11 @@ -276,11 +277,21 @@ class VmxImageHandler(ImageHandler):
    4.12                 ret.append("-%s" % vbddev)
    4.13                 ret.append("%s" % vbdparam)
    4.14              if name == 'vif':
    4.15 +               type = sxp.child_value(info, 'type')
    4.16 +               if type != 'ioemu':
    4.17 +                   continue
    4.18 +               if mac != None:
    4.19 +                   continue
    4.20                 mac = sxp.child_value(info, 'mac')
    4.21 +               bridge = sxp.child_value(info, 'bridge')
    4.22                 if mac == None:
    4.23                     mac = randomMAC()
    4.24 +               if bridge == None:
    4.25 +                   bridge = 'xenbr0'
    4.26                 ret.append("-macaddr")
    4.27                 ret.append("%s" % mac)
    4.28 +               ret.append("-bridge")
    4.29 +               ret.append("%s" % bridge)
    4.30              if name == 'vtpm':
    4.31                 instance = sxp.child_value(info, 'instance')
    4.32                 ret.append("-instance")
     5.1 --- a/tools/python/xen/xend/server/netif.py	Thu Nov 10 16:59:51 2005 +0100
     5.2 +++ b/tools/python/xen/xend/server/netif.py	Thu Nov 10 17:07:13 2005 +0100
     5.3 @@ -71,6 +71,9 @@ class NetifController(DevController):
     5.4          script = os.path.join(xroot.network_script_dir,
     5.5                                sxp.child_value(config, 'script',
     5.6                                                xroot.get_vif_script()))
     5.7 +        type = sxp.child_value(config, 'type')
     5.8 +        if type == 'ioemu':
     5.9 +            return (None,{},{})
    5.10          bridge = sxp.child_value(config, 'bridge')
    5.11          mac    = sxp.child_value(config, 'mac')
    5.12          ipaddr = _get_config_ipaddr(config)
     6.1 --- a/tools/python/xen/xm/create.py	Thu Nov 10 16:59:51 2005 +0100
     6.2 +++ b/tools/python/xen/xm/create.py	Thu Nov 10 17:07:13 2005 +0100
     6.3 @@ -255,10 +255,11 @@ gopts.var('ipaddr', val="IPADDR",
     6.4            fn=append_value, default=[],
     6.5            use="Add an IP address to the domain.")
     6.6  
     6.7 -gopts.var('vif', val="mac=MAC,be_mac=MAC,bridge=BRIDGE,script=SCRIPT,backend=DOM,vifname=NAME",
     6.8 +gopts.var('vif', val="type=TYPE,mac=MAC,be_mac=MAC,bridge=BRIDGE,script=SCRIPT,backend=DOM,vifname=NAME",
     6.9            fn=append_value, default=[],
    6.10            use="""Add a network interface with the given MAC address and bridge.
    6.11            The vif is configured by calling the given configuration script.
    6.12 +          If type is not specified, default is netfront not ioemu device.
    6.13            If mac is not specified a random MAC address is used.
    6.14            The MAC address of the backend interface can be selected with be_mac.
    6.15            If not specified then the network backend chooses it's own MAC address.
    6.16 @@ -356,10 +357,6 @@ gopts.var('cdrom', val='FILE',
    6.17            fn=set_value, default='',
    6.18            use="Path to cdrom")
    6.19  
    6.20 -gopts.var('macaddr', val='MACADDR',
    6.21 -          fn=set_value, default='',
    6.22 -          use="Macaddress of the first network interface")
    6.23 -
    6.24  gopts.var('boot', val="a|b|c|d",
    6.25            fn=set_value, default='c',
    6.26            use="Default boot device")
    6.27 @@ -512,6 +509,7 @@ def configure_vifs(config_devs, vals):
    6.28              backend = d.get('backend')
    6.29              ip = d.get('ip')
    6.30              vifname = d.get('vifname')
    6.31 +            type = d.get('type')
    6.32          else:
    6.33              mac = None
    6.34              be_mac = None
    6.35 @@ -520,6 +518,7 @@ def configure_vifs(config_devs, vals):
    6.36              backend = None
    6.37              ip = None
    6.38              vifname = None
    6.39 +            type = None
    6.40          config_vif = ['vif']
    6.41          if mac:
    6.42              config_vif.append(['mac', mac])
    6.43 @@ -535,6 +534,8 @@ def configure_vifs(config_devs, vals):
    6.44              config_vif.append(['backend', backend])
    6.45          if ip:
    6.46              config_vif.append(['ip', ip])
    6.47 +        if type:
    6.48 +            config_vif.append(['type', type])
    6.49          config_devs.append(['device', config_vif])
    6.50  
    6.51  def configure_vfr(config, vals):
    6.52 @@ -549,7 +550,7 @@ def configure_vmx(config_image, vals):
    6.53      """Create the config for VMX devices.
    6.54      """
    6.55      args = [ 'device_model', 'vcpus', 'cdrom', 'boot', 'fda', 'fdb',
    6.56 -             'localtime', 'serial', 'macaddr', 'stdvga', 'isa', 'nographic',
    6.57 +             'localtime', 'serial', 'stdvga', 'isa', 'nographic',
    6.58               'vnc', 'vncviewer', 'sdl', 'display', 'ne2000', 'lapic']
    6.59      for a in args:
    6.60          if (vals.__dict__[a]):
    6.61 @@ -662,7 +663,7 @@ def preprocess_vifs(vals):
    6.62              (k, v) = b.strip().split('=', 1)
    6.63              k = k.strip()
    6.64              v = v.strip()
    6.65 -            if k not in ['mac', 'be_mac', 'bridge', 'script', 'backend', 'ip', 'vifname']:
    6.66 +            if k not in ['type', 'mac', 'be_mac', 'bridge', 'script', 'backend', 'ip', 'vifname']:
    6.67                  err('Invalid vif specifier: ' + vif)
    6.68              d[k] = v
    6.69          vifs.append(d)