Virtualbox » Historial » Versió 14
Pau Escrich, 06-01-2013 21:03
1 | 13 | Pau Escrich | {{toc}} |
---|---|---|---|
2 | |||
3 | 1 | Pau Escrich | h1. Virtualbox |
4 | |||
5 | It is possible to emulate qMp with Virtual Box. |
||
6 | |||
7 | 5 | Pau Escrich | First of all open your virtualbox (VB) and create a new machine (type linux 2.6). |
8 | 6 | Pau Escrich | If you are using the VB wizard, do not select any storage device, we will do it latter. |
9 | 5 | Pau Escrich | |
10 | 3 | Pau Escrich | h3. Storage |
11 | 1 | Pau Escrich | |
12 | 10 | Pau Escrich | To make the things easy it is better to use IDE instead of SATA. |
13 | Create a new IDE disk and browse between your foldersand select the qMp vdi image file. |
||
14 | |||
15 | 11 | Pau Escrich | The vdi file can be obtained here: http://fw.qmp.cat/testing with the name VBox-qMp_testing-factory-XXXXX.bin |
16 | It should be renamed to something such as VBox-qMp1.vd1 |
||
17 | 3 | Pau Escrich | |
18 | 2 | Pau Escrich | h3. Network Configuration |
19 | 1 | Pau Escrich | |
20 | First of all we create a virtual tun/tap device in the host machine. |
||
21 | 3 | Pau Escrich | |
22 | 8 | Pau Escrich | <pre>ip tuntap add mode tap dev vbox |
23 | 1 | Pau Escrich | ip link set vbox up |
24 | ip addr add 172.30.22.10/24 dev vbox |
||
25 | 3 | Pau Escrich | </pre> |
26 | 1 | Pau Escrich | |
27 | 3 | Pau Escrich | In VB machine configuration at least one network interface must be added. |
28 | 1 | Pau Escrich | It should be configured as bridged interface to our new "vbox" network device. |
29 | The driver "PCnet-PCI II" works fine. |
||
30 | |||
31 | |||
32 | h3. Serial |
||
33 | 3 | Pau Escrich | |
34 | A serial port is needed because OpenWRT expects it. So it should be added in the VB machine configuration. |
||
35 | |||
36 | It is possible to use it to connect with the qMp node from the host machine (useful for debug), but it is NOT NEEDED. |
||
37 | To do so you should configure the VB serial as host pipe. |
||
38 | 1 | Pau Escrich | Check the option "create pipe" and add the path "/tmp/vboxS0". |
39 | 3 | Pau Escrich | Then in the host machine execute: |
40 | 8 | Pau Escrich | <pre>socat UNIX-CONNECT:/tmp/vboxS0 TCP-LISTEN:7777 & |
41 | 3 | Pau Escrich | netcat localhost 7777 |
42 | </pre> |
||
43 | |||
44 | And you will get serial! |
||
45 | 9 | Pau Escrich | |
46 | h3. Start VM |
||
47 | |||
48 | At this point you can start your virtual machine with qMp, open a browser and go to http://172.30.22.1 |
||
49 | |||
50 | If after the first reboot (automatic reboot) it does not boot (stays in "GRUB LOADING") reboot manually the VM. |
||
51 | |||
52 | h3. Clone |
||
53 | |||
54 | Ok, but just one node is quite boring so let's go to create more of them. Just switch-off the virtual machine, right click and Clone it. |
||
55 | Select the option "regenerate MAC addresses", boot the new machine and then execute: |
||
56 | |||
57 | <pre>rm /qmp_configured |
||
58 | /etc/init.d/qmp_autoconf start |
||
59 | </pre> |
||
60 | |||
61 | Then both nodes should see each other! |
||
62 | 12 | Pau Escrich | |
63 | h1. QEMU |
||
64 | |||
65 | It is possible to use the same VirtualBox VDI image file. So again, you can get it from http://fw.qmp.cat |
||
66 | Copy it to somewhere and change the name to, for instance "qMp1.vdi". |
||
67 | |||
68 | Then just start QEMU: |
||
69 | |||
70 | <pre>sudo qemu -net nic,model=pcnet -m 64 -hda qMp1.vdi</pre> |
||
71 | 1 | Pau Escrich | |
72 | 14 | Pau Escrich | You can add "-nographic" option and "-daemonize". |
73 | 12 | Pau Escrich | |
74 | h3. Serial |
||
75 | |||
76 | Get serial is very easy, just add this option to QEMU |
||
77 | |||
78 | <pre>-serial pty</pre> |
||
79 | |||
80 | The qmeu will show you the pty device attached to the serial port of the virtual machine, then just use it: |
||
81 | |||
82 | <pre>screen /dev/pts/3</pre> |
||
83 | |||
84 | Amazing! |
||
85 | |||
86 | h3. Network |
||
87 | |||
88 | There are several ways to get the network working, I use the combo bridge+tap. |
||
89 | In the host machine we will have a bridge named "qemu" and the network interface of the virtual machine |
||
90 | will be a tap device attached to such bridge. |
||
91 | |||
92 | The next options must be added to the qemu exec command line |
||
93 | |||
94 | <pre>-net tap,ifname=qmp1</pre> |
||
95 | |||
96 | And these two scripts are needed: |
||
97 | |||
98 | */etc/qemu-ifup* |
||
99 | <pre> |
||
100 | #!/bin/sh |
||
101 | if ! brctl show | grep qemu; then |
||
102 | brctl addbr qemu |
||
103 | ip link set qemu up |
||
104 | fi |
||
105 | echo "Executing /etc/qemu-ifup" |
||
106 | echo "Bringing up $1 for bridged mode..." |
||
107 | sudo /sbin/ip link set $1 up promisc on |
||
108 | echo "Adding $1 to br0..." |
||
109 | sudo brctl addif qemu $1 |
||
110 | sleep 2 |
||
111 | </pre> |
||
112 | |||
113 | */etc/qemu-ifdown* |
||
114 | <pre> |
||
115 | #!/bin/sh |
||
116 | echo "Executing /etc/qemu-ifdown" |
||
117 | sudo /sbin/ip link set $1 down |
||
118 | sudo /usr/sbin/brctl delif qemu $1 |
||
119 | sudo /sbin/ip link delete dev $1 |
||
120 | </pre> |
||
121 | |||
122 | And make them executable |
||
123 | |||
124 | <pre>chmod +x /etc/qemu-if*</pre> |
||
125 | |||
126 | To reach the node it is needed to add an IP to the host machine bridge: |
||
127 | <pre>ip addr add 172.30.22.10/24 dev qemu</pre> |