[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-changelog] This patch use same expression as vif for vmx guest but has a distinguish "type=ioemu"



# HG changeset patch
# User Xiaofeng Ling <xiaofeng.ling@xxxxxxxxx>
# Node ID 6a593de2f8ba95f3d3eb1c8eaa3970300dc4896f
# Parent  10e6946477b8db2622d196064994092759d25d8f
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@xxxxxxxxx>

diff -r 10e6946477b8 -r 6a593de2f8ba tools/examples/xmexample.vmx
--- a/tools/examples/xmexample.vmx      Thu Nov 10 15:59:51 2005
+++ b/tools/examples/xmexample.vmx      Thu Nov 10 16:07:13 2005
@@ -35,7 +35,11 @@
 
 # Optionally define mac and/or bridge for the network interfaces.
 # Random MACs are assigned if not given.
-#vif = [ 'mac=aa:00:00:00:00:11, bridge=xenbr0' ]
+# nics default is 1
+#vif = [ 'type=ioemu, mac=aa:00:00:00:00:11, bridge=xenbr0' ]
+nics=1 
+# type=ioemu specify the NIC is an ioemu device not netfront
+vif = [ 'type=ioemu, bridge=xenbr0' ]
 
 #----------------------------------------------------------------------------
 # Define the disk devices you want the domain to have access to, and
diff -r 10e6946477b8 -r 6a593de2f8ba tools/ioemu/target-i386-dm/qemu-ifup
--- a/tools/ioemu/target-i386-dm/qemu-ifup      Thu Nov 10 15:59:51 2005
+++ b/tools/ioemu/target-i386-dm/qemu-ifup      Thu Nov 10 16:07:13 2005
@@ -7,4 +7,4 @@
 echo $*
 
 ifconfig $1 0.0.0.0 up
-brctl addif xenbr0 $1
+brctl addif $2 $1
diff -r 10e6946477b8 -r 6a593de2f8ba tools/ioemu/vl.c
--- a/tools/ioemu/vl.c  Thu Nov 10 15:59:51 2005
+++ b/tools/ioemu/vl.c  Thu Nov 10 16:07:13 2005
@@ -124,6 +124,7 @@
 static char network_script[1024];
 int pit_min_timer_count = 0;
 int nb_nics;
+char bridge[16];
 NetDriverState nd_table[MAX_NICS];
 QEMUTimer *gui_timer;
 QEMUTimer *polling_timer;
@@ -1586,7 +1587,7 @@
 static int net_tun_init(NetDriverState *nd)
 {
     int pid, status;
-    char *args[3];
+    char *args[4];
     char **parg;
     extern int highest_fds;
 
@@ -1602,6 +1603,7 @@
             parg = args;
             *parg++ = network_script;
             *parg++ = nd->ifname;
+            *parg++ = bridge;
             *parg++ = NULL;
             execv(network_script, args);
             exit(1);
@@ -2207,6 +2209,7 @@
            "Network options:\n"
            "-nics n         simulate 'n' network cards [default=1]\n"
            "-macaddr addr   set the mac address of the first interface\n"
+           "-bridge  br     set the bridge interface for nic\n"
            "-n script       set tap/tun network init script [default=%s]\n"
            "-tun-fd fd      use this fd as already opened tap/tun interface\n"
 #ifdef CONFIG_SLIRP
@@ -2297,6 +2300,7 @@
 
     QEMU_OPTION_nics,
     QEMU_OPTION_macaddr,
+    QEMU_OPTION_bridge,
     QEMU_OPTION_n,
     QEMU_OPTION_tun_fd,
     QEMU_OPTION_user_net,
@@ -2367,6 +2371,7 @@
 
     { "nics", HAS_ARG, QEMU_OPTION_nics},
     { "macaddr", HAS_ARG, QEMU_OPTION_macaddr},
+    { "bridge", HAS_ARG, QEMU_OPTION_bridge},
     { "n", HAS_ARG, QEMU_OPTION_n },
     { "tun-fd", HAS_ARG, QEMU_OPTION_tun_fd },
 #ifdef CONFIG_SLIRP
@@ -2824,6 +2829,9 @@
                     fprintf(stderr, "qemu: invalid number of network 
interfaces\n");
                     exit(1);
                 }
+                break;
+            case QEMU_OPTION_bridge:
+                pstrcpy(bridge, sizeof(bridge), optarg);
                 break;
             case QEMU_OPTION_macaddr:
                 {
diff -r 10e6946477b8 -r 6a593de2f8ba tools/python/xen/xend/image.py
--- a/tools/python/xen/xend/image.py    Thu Nov 10 15:59:51 2005
+++ b/tools/python/xen/xend/image.py    Thu Nov 10 16:07:13 2005
@@ -258,6 +258,7 @@
             log.debug("args: %s, val: %s" % (a,v))
 
         # Handle disk/network related options
+        mac = None
         for (name, info) in deviceConfig:
             if name == 'vbd':
                uname = sxp.child_value(info, 'uname')
@@ -276,11 +277,21 @@
                ret.append("-%s" % vbddev)
                ret.append("%s" % vbdparam)
             if name == 'vif':
+               type = sxp.child_value(info, 'type')
+               if type != 'ioemu':
+                   continue
+               if mac != None:
+                   continue
                mac = sxp.child_value(info, 'mac')
+               bridge = sxp.child_value(info, 'bridge')
                if mac == None:
                    mac = randomMAC()
+               if bridge == None:
+                   bridge = 'xenbr0'
                ret.append("-macaddr")
                ret.append("%s" % mac)
+               ret.append("-bridge")
+               ret.append("%s" % bridge)
             if name == 'vtpm':
                instance = sxp.child_value(info, 'instance')
                ret.append("-instance")
diff -r 10e6946477b8 -r 6a593de2f8ba tools/python/xen/xend/server/netif.py
--- a/tools/python/xen/xend/server/netif.py     Thu Nov 10 15:59:51 2005
+++ b/tools/python/xen/xend/server/netif.py     Thu Nov 10 16:07:13 2005
@@ -71,6 +71,9 @@
         script = os.path.join(xroot.network_script_dir,
                               sxp.child_value(config, 'script',
                                               xroot.get_vif_script()))
+        type = sxp.child_value(config, 'type')
+        if type == 'ioemu':
+            return (None,{},{})
         bridge = sxp.child_value(config, 'bridge')
         mac    = sxp.child_value(config, 'mac')
         ipaddr = _get_config_ipaddr(config)
diff -r 10e6946477b8 -r 6a593de2f8ba tools/python/xen/xm/create.py
--- a/tools/python/xen/xm/create.py     Thu Nov 10 15:59:51 2005
+++ b/tools/python/xen/xm/create.py     Thu Nov 10 16:07:13 2005
@@ -255,10 +255,11 @@
           fn=append_value, default=[],
           use="Add an IP address to the domain.")
 
-gopts.var('vif', 
val="mac=MAC,be_mac=MAC,bridge=BRIDGE,script=SCRIPT,backend=DOM,vifname=NAME",
+gopts.var('vif', 
val="type=TYPE,mac=MAC,be_mac=MAC,bridge=BRIDGE,script=SCRIPT,backend=DOM,vifname=NAME",
           fn=append_value, default=[],
           use="""Add a network interface with the given MAC address and bridge.
           The vif is configured by calling the given configuration script.
+          If type is not specified, default is netfront not ioemu device.
           If mac is not specified a random MAC address is used.
           The MAC address of the backend interface can be selected with be_mac.
           If not specified then the network backend chooses it's own MAC 
address.
@@ -355,10 +356,6 @@
 gopts.var('cdrom', val='FILE',
           fn=set_value, default='',
           use="Path to cdrom")
-
-gopts.var('macaddr', val='MACADDR',
-          fn=set_value, default='',
-          use="Macaddress of the first network interface")
 
 gopts.var('boot', val="a|b|c|d",
           fn=set_value, default='c',
@@ -512,6 +509,7 @@
             backend = d.get('backend')
             ip = d.get('ip')
             vifname = d.get('vifname')
+            type = d.get('type')
         else:
             mac = None
             be_mac = None
@@ -520,6 +518,7 @@
             backend = None
             ip = None
             vifname = None
+            type = None
         config_vif = ['vif']
         if mac:
             config_vif.append(['mac', mac])
@@ -535,6 +534,8 @@
             config_vif.append(['backend', backend])
         if ip:
             config_vif.append(['ip', ip])
+        if type:
+            config_vif.append(['type', type])
         config_devs.append(['device', config_vif])
 
 def configure_vfr(config, vals):
@@ -549,7 +550,7 @@
     """Create the config for VMX devices.
     """
     args = [ 'device_model', 'vcpus', 'cdrom', 'boot', 'fda', 'fdb',
-             'localtime', 'serial', 'macaddr', 'stdvga', 'isa', 'nographic',
+             'localtime', 'serial', 'stdvga', 'isa', 'nographic',
              'vnc', 'vncviewer', 'sdl', 'display', 'ne2000', 'lapic']
     for a in args:
         if (vals.__dict__[a]):
@@ -662,7 +663,7 @@
             (k, v) = b.strip().split('=', 1)
             k = k.strip()
             v = v.strip()
-            if k not in ['mac', 'be_mac', 'bridge', 'script', 'backend', 'ip', 
'vifname']:
+            if k not in ['type', 'mac', 'be_mac', 'bridge', 'script', 
'backend', 'ip', 'vifname']:
                 err('Invalid vif specifier: ' + vif)
             d[k] = v
         vifs.append(d)

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog


 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.