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