ia64/xen-unstable

view tools/xm-test/tests/restore/04_restore_withdevices_pos.py @ 16739:33dcf04d7715

tools/docs: Fix example and default IP addresses.

In various places in documentation and code, IP addresses are provided
as examples, defaults, or dummy configuration. In general the
specific IP addresses used in Xen are not always appropriate. (For
example, 1.2.3.4 is used in a few places!)

The following addresses should be used:
* For examples and documentation, 192.0.2.0/24. (See RFC3330.)
* For defaults for private networks, a random network from RFC1918.
I have randomly selected 172.30.206.0/24 for this purpose and
documented this in at the only registry I know of,
www.ucam.org/cam-grin. This network should henceforth be used for
default configurations of local bridges, test networks, etc. in
Xen tools.

The following addresses should NOT be used:
* 10.0.*.*, 10.1.*.*, 192.168.0.*, 192.168.1.*, etc. Using these
addresses gives greatly increased likelihood of collision, as
ignorant network administrators and reckless middlebox vendors
often pick networks from the bottom of 10/8 and 192.168/16.
* 169.254.*.*. These are reserved for zeroconf (ad-hoc networking)
and should not be used for Xen private networks, bridges, etc.,
etc. Use of these addresses by Xen scripts causes trouble on hosts
(eg laptops) which find themselves in ad-hoc networking
environments. I think this is not hypothetical (!) since at least
one Linux distribution have specific code to detect this case and
cause Xen startup to fail iff the host already has an external
zeroconf address.
* 1.2.3.4. WTF !?

I have also used 127.0.255.255 in one place where apparently a dummy
address is needed (some Linux kernels won't accept a lack of an NFS
server address). If 127.0.255.255 is mistakenly used it is unlikely
to do any damage to real traffic even if it does escape into the
network at large.

Signed-off-by: Ian Jackson <ian.jackson@eu.citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Thu Jan 17 15:13:40 2008 +0000 (2008-01-17)
parents bef7f5fcf207
children
line source
1 #!/usr/bin/python
3 # Copyright (C) International Business Machines Corp., 2005
4 # Author: Dan Smith <danms@us.ibm.com>
6 from XmTestLib import *
8 import re
10 if ENABLE_HVM_SUPPORT:
11 SKIP("Restore currently not supported for HVM domains")
13 config = {"disk": ["phy:/dev/ram0,hda1,w", "phy:/dev/ram1,hdb2,w"],
14 "vif": ['', '']}
15 domain = XmTestDomain(extraConfig=config)
17 s, o = traceCommand("mke2fs -q /dev/ram0")
18 if s != 0:
19 FAIL("Unable to mke2fs /dev/ram0 in dom0")
21 s, o = traceCommand("mke2fs -q /dev/ram1")
22 if s != 0:
23 FAIL("Unable to mke2fs /dev/ram1 in dom0")
25 try:
26 console = domain.start()
27 except DomainError, e:
28 FAIL(str(e))
30 try:
31 run = console.runCmd("mkdir /mnt/a /mnt/b")
32 if run["return"] != 0:
33 FAIL("Unable to mkdir /mnt/a /mnt/b")
35 run = console.runCmd("mount /dev/hda1 /mnt/a")
36 if run["return"] != 0:
37 FAIL("Unable to mount /dev/hda1")
39 run = console.runCmd("mount /dev/hdb2 /mnt/b")
40 if run["return"] != 0:
41 FAIL("Unable to mount /dev/hdb2")
43 run = console.runCmd("echo hda1 > /mnt/a/foo")
44 if run["return"] != 0:
45 FAIL("Unable to write to block device hda1!")
47 run = console.runCmd("echo hdb2 > /mnt/b/foo")
48 if run["return"] != 0:
49 FAIL("Unable to write to block device hdb2!")
51 run = console.runCmd("ifconfig eth0 172.30.206.1 netmask 255.255.255.240")
52 if run["return"] != 0:
53 FAIL("Unable to configure DomU's eth0")
55 run = console.runCmd("ifconfig eth1 172.30.206.17 netmask 255.255.255.240")
56 if run["return"] != 0:
57 FAIL("Unable to configure DomU's eth1")
59 run = console.runCmd("ifconfig lo 127.0.0.1")
60 if run["return"] != 0:
61 FAIL("Unable to configure DomU's lo")
64 except ConsoleError, e:
65 FAIL(str(e))
67 domain.closeConsole()
69 try:
70 s, o = traceCommand("xm save %s /tmp/test.state" % domain.getName(),
71 timeout=30)
72 except TimeoutError, e:
73 FAIL(str(e))
75 if s != 0:
76 FAIL("xm save exited with %i != 0" % s)
78 # Let things settle
79 time.sleep(15)
81 try:
82 s, o = traceCommand("xm restore /tmp/test.state",
83 timeout=30)
84 except TimeoutError, e:
85 FAIL(str(e))
87 if s != 0:
88 FAIL("xm restore exited with %i != 0" % s)
90 try:
91 console = domain.getConsole()
92 # Enable debug dumping, as this causes an Oops on x86_64
93 console.debugMe = True
95 # In case the domain is rebooted
96 console.sendInput("ls")
98 run = console.runCmd("ls | grep proc")
99 if run["return"] != 0:
100 FAIL("ls failed on restored domain")
102 run = console.runCmd("cat /mnt/a/foo")
103 if run["return"] != 0:
104 FAIL("Unable to read from block device hda1")
105 if not re.search("hda1", run["output"]):
106 FAIL("Failed to read correct data from hda1")
108 run = console.runCmd("cat /mnt/b/foo")
109 if run["return"] != 0:
110 FAIL("Unable to read from block device hdb2")
111 if not re.search("hdb2", run["output"]):
112 FAIL("Failed to read correct data from hdb2")
114 run = console.runCmd("ifconfig")
115 if not re.search("eth0", run["output"]):
116 FAIL("DomU's eth0 disappeared")
117 if not re.search("172.30.206.1", run["output"]):
118 FAIL("DomU's eth0 lost its IP")
119 if not re.search("eth1", run["output"]):
120 FAIL("DomU's eth1 disappeared")
121 if not re.search("172.30.206.17", run["output"]):
122 FAIL("DomU's eth1 lost its IP")
123 if not re.search("Loopback", run["output"]):
124 FAIL("DomU's lo disappeared")
125 if not re.search("127.0.0.1", run["output"]):
126 FAIL("DomU's lo lost its IP")
128 except ConsoleError, e:
129 FAIL(str(e))