WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-changelog

[Xen-changelog] Deprecate the nics option from the xm create configurati

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Deprecate the nics option from the xm create configuration. Instead, we use the
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Tue, 13 Dec 2005 02:14:07 +0000
Delivery-date: Tue, 13 Dec 2005 02:15:33 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User emellor@xxxxxxxxxxxxxxxxxxxxxx
# Node ID 55d464295da37a125c1905347bf222eb3b03d185
# Parent  fa5dddabda0cbf33c013dab77696e983ac5f45c4
Deprecate the nics option from the xm create configuration.  Instead, we use the
entries in vif to guide the configuration.  This is much less confusing.

Closes bug #440.

Change the example configuration files to match.  Also change them to use the
XenSource OUI in the MAC addresses.  Also change xm-test to match.

Remove the obsolete ipaddr configuration entry, and the backend_mac vif config
option.

Remove the preprocess_vifs function, folding it into the configure_vifs
function, and creating a simple comma_sep_kv_to_dict helper.

Remove the configure_vfr method, as it is unused.

Signed-off-by: Ewan Mellor <ewan@xxxxxxxxxxxxx>

diff -r fa5dddabda0c -r 55d464295da3 docs/src/user.tex
--- a/docs/src/user.tex Tue Dec 13 00:10:19 2005
+++ b/docs/src/user.tex Tue Dec 13 00:15:53 2005
@@ -1087,16 +1087,17 @@
 \item[vcpus] The number of virtual CPUs. 
 \item[console] Port to export the domain console on (default 9600 +
   domain ID).
-\item[nics] Number of virtual network interfaces.
-\item[vif] List of MAC addresses (random addresses are assigned if not
-  given) and bridges to use for the domain's network interfaces, e.g.\ 
+\item[vif] Network interface configuration.  This may simply contain
+an empty string for each desired interface, or may override various
+settings, e.g.\ 
 \begin{verbatim}
 vif = [ 'mac=00:16:3E:00:00:11, bridge=xen-br0',
         'bridge=xen-br1' ]
 \end{verbatim}
   to assign a MAC address and bridge to the first interface and assign
   a different bridge to the second interface, leaving \xend\ to choose
-  the MAC address.
+  the MAC address.  The settings that may be overridden in this way are
+  type, mac, bridge, ip, script, backend, and vifname.
 \item[disk] List of block devices to export to the domain e.g. 
   \verb_disk = [ 'phy:hda1,sda1,r' ]_ 
   exports physical device \path{/dev/hda1} to the domain as
diff -r fa5dddabda0c -r 55d464295da3 tools/examples/xmexample.nbd
--- a/tools/examples/xmexample.nbd      Tue Dec 13 00:10:19 2005
+++ b/tools/examples/xmexample.nbd      Tue Dec 13 00:15:53 2005
@@ -12,9 +12,7 @@
 ramdisk = "/boot/initrd-2.6.13-15b-xen"
 memory = 128
 name = "nbd4"
-nics=1
-# Please change MAC
-vif = [ 'mac=aa:cc:10:10:00:a0, bridge=xenbr0' ]
+vif = [ '' ]
 # Please change PORT
 disk = [ 'nbd:134.100.233.115 20004,hda1,w' ]
 dhcp = "dhcp"
diff -r fa5dddabda0c -r 55d464295da3 tools/examples/xmexample.vmx
--- a/tools/examples/xmexample.vmx      Tue Dec 13 00:10:19 2005
+++ b/tools/examples/xmexample.vmx      Tue Dec 13 00:15:53 2005
@@ -37,9 +37,7 @@
 
 # Optionally define mac and/or bridge for the network interfaces.
 # Random MACs are assigned if not given.
-# nics default is 1
-#vif = [ 'type=ioemu, mac=aa:00:00:00:00:11, bridge=xenbr0' ]
-nics=1 
+#vif = [ 'type=ioemu, mac=00:16:3e:00:00:11, bridge=xenbr0' ]
 # type=ioemu specify the NIC is an ioemu device not netfront
 vif = [ 'type=ioemu, bridge=xenbr0' ]
 
diff -r fa5dddabda0c -r 55d464295da3 tools/examples/xmexample.vti
--- a/tools/examples/xmexample.vti      Tue Dec 13 00:10:19 2005
+++ b/tools/examples/xmexample.vti      Tue Dec 13 00:15:53 2005
@@ -28,12 +28,9 @@
 #cpus = "0"        # all vcpus run on CPU0
 #cpus = "0-3,5,^1" # run on cpus 0,2,3,5
 
-# Disable vif for now
-nics=0
-
 # 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=xen-br0' ]
+#vif = [ 'mac=00:16:3e:00:00:11, bridge=xen-br0' ]
 
 #----------------------------------------------------------------------------
 # Define the disk devices you want the domain to have access to, and
diff -r fa5dddabda0c -r 55d464295da3 tools/examples/xmexample1
--- a/tools/examples/xmexample1 Tue Dec 13 00:10:19 2005
+++ b/tools/examples/xmexample1 Tue Dec 13 00:15:53 2005
@@ -33,12 +33,20 @@
 #----------------------------------------------------------------------------
 # Define network interfaces.
 
-# Number of network interfaces. Default is 1.
-#nics=1
+# By default, no network interfaces are configured.  You may have one created
+# with sensible defaults using an empty vif clause:
+#
+# vif = [ '' ]
+#
+# or optionally override backend, bridge, ip, mac, script, type, or vifname:
+#
+# vif = [ 'mac=00:16:3e:00:00:11, bridge=xenbr0' ]
+#
+# or more than one interface may be configured:
+#
+# vif = [ '', 'bridge=xenbr1' ]
 
-# 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' ]
+vif = [ '' ]
 
 #----------------------------------------------------------------------------
 # Define the disk devices you want the domain to have access to, and
diff -r fa5dddabda0c -r 55d464295da3 tools/examples/xmexample2
--- a/tools/examples/xmexample2 Tue Dec 13 00:10:19 2005
+++ b/tools/examples/xmexample2 Tue Dec 13 00:15:53 2005
@@ -64,12 +64,20 @@
 #----------------------------------------------------------------------------
 # Define network interfaces.
 
-# Number of network interfaces. Default is 1.
-#nics=1
+# By default, no network interfaces are configured.  You may have one created
+# with sensible defaults using an empty vif clause:
+#
+# vif = [ '' ]
+#
+# or optionally override backend, bridge, ip, mac, script, type, or vifname:
+#
+# vif = [ 'mac=00:16:3e:00:00:11, bridge=xenbr0' ]
+#
+# or more than one interface may be configured:
+#
+# vif = [ '', 'bridge=xenbr1' ]
 
-# 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' ]
+vif = [ '' ]
 
 #----------------------------------------------------------------------------
 # Define the disk devices you want the domain to have access to, and
diff -r fa5dddabda0c -r 55d464295da3 tools/examples/xmexample3
--- a/tools/examples/xmexample3 Tue Dec 13 00:10:19 2005
+++ b/tools/examples/xmexample3 Tue Dec 13 00:15:53 2005
@@ -59,9 +59,6 @@
 
 #----------------------------------------------------------------------------
 # Define network interfaces.
-
-# Number of network interfaces. Default is 1.
-#nics=1
 
 # Optionally define mac and/or bridge for the network interfaces.
 # Random MACs are assigned if not given.
diff -r fa5dddabda0c -r 55d464295da3 tools/python/xen/xm/create.py
--- a/tools/python/xen/xm/create.py     Tue Dec 13 00:10:19 2005
+++ b/tools/python/xen/xm/create.py     Tue Dec 13 00:15:53 2005
@@ -253,17 +253,12 @@
           use="""Add a physical USB port to a domain, as specified by the path
           to that port.  This option may be repeated to add more than one 
port.""")
 
-gopts.var('ipaddr', val="IPADDR",
-          fn=append_value, default=[],
-          use="Add an IP address to the domain.")
-
-gopts.var('vif', 
val="type=TYPE,mac=MAC,be_mac=MAC,bridge=BRIDGE,script=SCRIPT,backend=DOM,vifname=NAME",
+gopts.var('vif', 
val="type=TYPE,mac=MAC,bridge=BRIDGE,ip=IPADDR,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.
           If bridge is not specified the first bridge found is used.
           If script is not specified the default script is used.
@@ -284,8 +279,10 @@
           given domain.""")
 
 gopts.var('nics', val="NUM",
-          fn=set_int, default=1,
-          use="""Set the number of network interfaces.
+          fn=set_int, default=-1,
+          use="""DEPRECATED.  Use empty vif entries instead.
+
+          Set the number of network interfaces.
           Use the vif option to define interface parameters, otherwise
           defaults are used. Specifying vifs will increase the
           number of interfaces as needed.""")
@@ -487,58 +484,38 @@
                 config_vtpm.append(['backend', backend])
             config_devs.append(['device', config_vtpm])
 
+
 def configure_vifs(config_devs, vals):
     """Create the config for virtual network interfaces.
     """
+
     vifs = vals.vif
-    vifs_n = max(vals.nics, len(vifs))
-
-    for idx in range(0, vifs_n):
-        if idx < len(vifs):
-            d = vifs[idx]
-            mac = d.get('mac')
-            be_mac = d.get('be_mac')
-            bridge = d.get('bridge')
-            script = d.get('script')
-            backend = d.get('backend')
-            ip = d.get('ip')
-            vifname = d.get('vifname')
-            type = d.get('type')
-        else:
-            mac = None
-            be_mac = None
-            bridge = None
-            script = None
-            backend = None
-            ip = None
-            vifname = None
-            type = None
+    vifs_n = len(vifs)
+
+    if hasattr(vals, 'nics'):
+        if vals.nics > 0:
+            warn("The nics option is deprecated.  Please use an empty vif "
+                 "entry instead:\n\n  vif = [ '' ]\n")
+            for _ in range(vifs_n, vals.nics):
+                vifs.append('')
+            vifs_n = len(vifs)
+        elif vals.nics == 0:
+            warn("The nics option is deprecated.  Please remove it.")
+
+    for c in vifs:
+        d = comma_sep_kv_to_dict(c)
         config_vif = ['vif']
-        if mac:
-            config_vif.append(['mac', mac])
-        if vifname:
-            config_vif.append(['vifname', vifname])
-        if be_mac:
-            config_vif.append(['be_mac', be_mac])
-        if bridge:
-            config_vif.append(['bridge', bridge])
-        if script:
-            config_vif.append(['script', script])
-        if backend:
-            config_vif.append(['backend', backend])
-        if ip:
-            config_vif.append(['ip', ip])
-        if type:
-            config_vif.append(['type', type])
+
+        def f(k):
+            if k not in ['backend', 'bridge', 'ip', 'mac', 'script', 'type',
+                         'vifname']:
+                err('Invalid vif option: ' + k)
+
+            config_vif.append([k, d[k]])
+
+        map(f, d.keys())
         config_devs.append(['device', config_vif])
 
-def configure_vfr(config, vals):
-     if not vals.ipaddr: return
-     config_vfr = ['vfr']
-     idx = 0 # No way of saying which IP is for which vif?
-     for ip in vals.ipaddr:
-         config_vfr.append(['vif', ['id', idx], ['ip', ip]])
-     config.append(config_vfr)
 
 def configure_vmx(config_image, vals):
     """Create the config for VMX devices.
@@ -649,22 +626,6 @@
         ioports.append(hexd)
     vals.ioports = ioports
         
-def preprocess_vifs(vals):
-    if not vals.vif: return
-    vifs = []
-    for vif in vals.vif:
-        d = {}
-        a = vif.split(',')
-        for b in a:
-            (k, v) = b.strip().split('=', 1)
-            k = k.strip()
-            v = v.strip()
-            if k not in ['type', 'mac', 'be_mac', 'bridge', 'script', 
'backend', 'ip', 'vifname']:
-                err('Invalid vif specifier: ' + vif)
-            d[k] = v
-        vifs.append(d)
-    vals.vif = vifs
-
 def preprocess_vtpm(vals):
     if not vals.vtpm: return
     vtpms = []
@@ -766,12 +727,30 @@
     preprocess_disk(vals)
     preprocess_pci(vals)
     preprocess_ioports(vals)
-    preprocess_vifs(vals)
     preprocess_ip(vals)
     preprocess_nfs(vals)
     preprocess_vnc(vals)
     preprocess_vtpm(vals)
-         
+
+
+def comma_sep_kv_to_dict(c):
+    """Convert comma-separated, equals-separated key-value pairs into a
+    dictionary.
+    """
+    d = {}
+    c = c.strip()
+    if len(c) > 0:
+        a = c.split(',')
+        for b in a:
+            if b.find('=') == -1:
+                err("%s should be a pair, separated by an equals sign." % b)
+            (k, v) = b.split('=', 1)
+            k = k.strip()
+            v = v.strip()
+            d[k] = v
+    return d
+
+
 def make_domain(opts, config):
     """Create, build and start a domain.
 
diff -r fa5dddabda0c -r 55d464295da3 tools/xm-test/lib/XmTestLib/XenDomain.py
--- a/tools/xm-test/lib/XmTestLib/XenDomain.py  Tue Dec 13 00:10:19 2005
+++ b/tools/xm-test/lib/XmTestLib/XenDomain.py  Tue Dec 13 00:15:53 2005
@@ -203,7 +203,6 @@
         # Defaults
         self.defaults = {"memory"    : 64,
                          "vcpus"     : 1,
-                         "nics"      : 0,
                          "kernel"    : "/usr/lib/xen/boot/vmxloader",
                          "builder"   : "\'vmx\'",
                          "name"      : name or self.getUniqueName()
@@ -264,7 +263,6 @@
         # Defaults
         self.defaults = {"memory"  : 64,
                          "vcpus"   : 1,
-                         "nics"    : 0,
                          "kernel"  : getDefaultKernel(),
                          "root"    : "/dev/ram0",
                          "name"    : name or self.getUniqueName(),
diff -r fa5dddabda0c -r 55d464295da3 
tools/xm-test/tests/create/13_create_multinic_pos.py
--- a/tools/xm-test/tests/create/13_create_multinic_pos.py      Tue Dec 13 
00:10:19 2005
+++ b/tools/xm-test/tests/create/13_create_multinic_pos.py      Tue Dec 13 
00:15:53 2005
@@ -6,7 +6,8 @@
 from XmTestLib import *
 
 for i in range(0,10):
-    domain = XmTestDomain(extraOpts={"nics":"%i" % i})
+    domain = XmTestDomain()
+    domain.configSetVar('vif', str(['' for _ in range(0, i)]))
 
     try:
         domain.start()
diff -r fa5dddabda0c -r 55d464295da3 
tools/xm-test/tests/network/02_network_local_ping_pos.py
--- a/tools/xm-test/tests/network/02_network_local_ping_pos.py  Tue Dec 13 
00:10:19 2005
+++ b/tools/xm-test/tests/network/02_network_local_ping_pos.py  Tue Dec 13 
00:15:53 2005
@@ -28,7 +28,7 @@
 mask = Net.mask("dom1", "eth0")
 
 # Fire up a guest domain w/1 nic
-domain = XmTestDomain(extraOpts={ 'nics' : 1 })
+domain = XmTestDomain()
 try:
     domain.configSetVar('vif', " [ 'ip=" + ip + "' ]")
     domain.start()
diff -r fa5dddabda0c -r 55d464295da3 
tools/xm-test/tests/network/05_network_dom0_ping_pos.py
--- a/tools/xm-test/tests/network/05_network_dom0_ping_pos.py   Tue Dec 13 
00:10:19 2005
+++ b/tools/xm-test/tests/network/05_network_dom0_ping_pos.py   Tue Dec 13 
00:15:53 2005
@@ -31,7 +31,7 @@
         FAIL(str(e))
 
 # Fire up a guest domain w/1 nic
-domain = XmTestDomain(extraOpts={ 'nics' : 1 })
+domain = XmTestDomain()
 try:
     domain.configSetVar('vif', " [ 'ip=" + ip + "' ]")
     domain.start()
diff -r fa5dddabda0c -r 55d464295da3 
tools/xm-test/tests/network/11_network_domU_ping_pos.py
--- a/tools/xm-test/tests/network/11_network_domU_ping_pos.py   Tue Dec 13 
00:10:19 2005
+++ b/tools/xm-test/tests/network/11_network_domU_ping_pos.py   Tue Dec 13 
00:15:53 2005
@@ -21,7 +21,7 @@
 
 
 def netDomain(ip):
-    dom = XmTestDomain(extraOpts={ 'nics' : 1 })
+    dom = XmTestDomain()
     try:
         dom.configSetVar('vif', " [ 'ip=" + ip + "' ]")
         dom.start()
diff -r fa5dddabda0c -r 55d464295da3 
tools/xm-test/tests/restore/04_restore_withdevices_pos.py
--- a/tools/xm-test/tests/restore/04_restore_withdevices_pos.py Tue Dec 13 
00:10:19 2005
+++ b/tools/xm-test/tests/restore/04_restore_withdevices_pos.py Tue Dec 13 
00:15:53 2005
@@ -7,7 +7,9 @@
 
 import re
 
-domain = XmTestDomain(extraOpts={"nics":2})
+domain = XmTestDomain()
+
+domain.configSetVar('vif', "[ '', '' ]")
 
 domain.configAddDisk("phy:/dev/ram0", "hda1", "w")
 domain.configAddDisk("phy:/dev/ram1", "hdb2", "w")

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

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Deprecate the nics option from the xm create configuration. Instead, we use the, Xen patchbot -unstable <=