aboutsummaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/examples/xmexample.nbd4
-rw-r--r--tools/examples/xmexample.vmx4
-rw-r--r--tools/examples/xmexample.vti5
-rw-r--r--tools/examples/xmexample118
-rw-r--r--tools/examples/xmexample218
-rw-r--r--tools/examples/xmexample33
-rw-r--r--tools/python/xen/xm/create.py121
-rw-r--r--tools/xm-test/lib/XmTestLib/XenDomain.py2
-rw-r--r--tools/xm-test/tests/create/13_create_multinic_pos.py3
-rw-r--r--tools/xm-test/tests/network/02_network_local_ping_pos.py2
-rw-r--r--tools/xm-test/tests/network/05_network_dom0_ping_pos.py2
-rw-r--r--tools/xm-test/tests/network/11_network_domU_ping_pos.py2
-rw-r--r--tools/xm-test/tests/restore/04_restore_withdevices_pos.py4
13 files changed, 87 insertions, 101 deletions
diff --git a/tools/examples/xmexample.nbd b/tools/examples/xmexample.nbd
index 274be6eb06..90dadc294d 100644
--- a/tools/examples/xmexample.nbd
+++ b/tools/examples/xmexample.nbd
@@ -12,9 +12,7 @@ kernel = "/boot/vmlinuz-2.6.13-15b-xen"
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 --git a/tools/examples/xmexample.vmx b/tools/examples/xmexample.vmx
index 8b694e32fe..9030b06117 100644
--- a/tools/examples/xmexample.vmx
+++ b/tools/examples/xmexample.vmx
@@ -37,9 +37,7 @@ vcpus=1
# 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 --git a/tools/examples/xmexample.vti b/tools/examples/xmexample.vti
index 5722eb0699..2daa58ca39 100644
--- a/tools/examples/xmexample.vti
+++ b/tools/examples/xmexample.vti
@@ -28,12 +28,9 @@ name = "ExampleVMXDomain"
#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 --git a/tools/examples/xmexample1 b/tools/examples/xmexample1
index 4e7fb4d72f..8985ff2582 100644
--- a/tools/examples/xmexample1
+++ b/tools/examples/xmexample1
@@ -33,12 +33,20 @@ name = "ExampleDomain"
#----------------------------------------------------------------------------
# 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 --git a/tools/examples/xmexample2 b/tools/examples/xmexample2
index 6a562a9609..ff39c4e7d9 100644
--- a/tools/examples/xmexample2
+++ b/tools/examples/xmexample2
@@ -64,12 +64,20 @@ vcpus = 4 # make your domain a 4-way
#----------------------------------------------------------------------------
# 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 --git a/tools/examples/xmexample3 b/tools/examples/xmexample3
index cdb993a2ff..bf20dd4862 100644
--- a/tools/examples/xmexample3
+++ b/tools/examples/xmexample3
@@ -60,9 +60,6 @@ cpus = "%s" % vmid # set based on vmid (mod number of CPUs)
#----------------------------------------------------------------------------
# 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 --git a/tools/python/xen/xm/create.py b/tools/python/xen/xm/create.py
index 622bea9b18..e82ff6cc91 100644
--- a/tools/python/xen/xm/create.py
+++ b/tools/python/xen/xm/create.py
@@ -253,17 +253,12 @@ gopts.var('usb', val='PATH',
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 @@ gopts.var('vtpm', val="instance=INSTANCE,backend=DOM",
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 @@ def configure_vtpm(config_devs, vals):
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 @@ def preprocess_ioports(vals):
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 @@ def preprocess(vals):
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 --git a/tools/xm-test/lib/XmTestLib/XenDomain.py b/tools/xm-test/lib/XmTestLib/XenDomain.py
index 4ea9c66f93..05ad6b36dc 100644
--- a/tools/xm-test/lib/XmTestLib/XenDomain.py
+++ b/tools/xm-test/lib/XmTestLib/XenDomain.py
@@ -203,7 +203,6 @@ class XmTestVmxDomain(XenDomain):
# 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 @@ class XmTestPvDomain(XenDomain):
# Defaults
self.defaults = {"memory" : 64,
"vcpus" : 1,
- "nics" : 0,
"kernel" : getDefaultKernel(),
"root" : "/dev/ram0",
"name" : name or self.getUniqueName(),
diff --git a/tools/xm-test/tests/create/13_create_multinic_pos.py b/tools/xm-test/tests/create/13_create_multinic_pos.py
index 810bf9829c..0c5c659469 100644
--- a/tools/xm-test/tests/create/13_create_multinic_pos.py
+++ b/tools/xm-test/tests/create/13_create_multinic_pos.py
@@ -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 --git a/tools/xm-test/tests/network/02_network_local_ping_pos.py b/tools/xm-test/tests/network/02_network_local_ping_pos.py
index a904d49dd9..510711ae23 100644
--- a/tools/xm-test/tests/network/02_network_local_ping_pos.py
+++ b/tools/xm-test/tests/network/02_network_local_ping_pos.py
@@ -28,7 +28,7 @@ ip = Net.ip("dom1", "eth0")
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 --git a/tools/xm-test/tests/network/05_network_dom0_ping_pos.py b/tools/xm-test/tests/network/05_network_dom0_ping_pos.py
index b252c2d3ed..84e6be058a 100644
--- a/tools/xm-test/tests/network/05_network_dom0_ping_pos.py
+++ b/tools/xm-test/tests/network/05_network_dom0_ping_pos.py
@@ -31,7 +31,7 @@ except NetworkError, e:
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 --git a/tools/xm-test/tests/network/11_network_domU_ping_pos.py b/tools/xm-test/tests/network/11_network_domU_ping_pos.py
index ca3fe35793..5ac8021562 100644
--- a/tools/xm-test/tests/network/11_network_domU_ping_pos.py
+++ b/tools/xm-test/tests/network/11_network_domU_ping_pos.py
@@ -21,7 +21,7 @@ from XmTestLib import *
def netDomain(ip):
- dom = XmTestDomain(extraOpts={ 'nics' : 1 })
+ dom = XmTestDomain()
try:
dom.configSetVar('vif', " [ 'ip=" + ip + "' ]")
dom.start()
diff --git a/tools/xm-test/tests/restore/04_restore_withdevices_pos.py b/tools/xm-test/tests/restore/04_restore_withdevices_pos.py
index 0b82943142..af290f4b8b 100644
--- a/tools/xm-test/tests/restore/04_restore_withdevices_pos.py
+++ b/tools/xm-test/tests/restore/04_restore_withdevices_pos.py
@@ -7,7 +7,9 @@ from XmTestLib import *
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")