Официальный форум СВД Встраиваемые Системы
10 Декабря, 2016, 15:42:07 *
Добро пожаловать, Гость. Пожалуйста, войдите или зарегистрируйтесь.

Войти
 
 
 Сайт СВД ВС  Начало   Помощь Поиск Войти Регистрация  
Страниц: [1]   Вниз
  Печать  
Автор Тема: QEMU network configuration in QNX  (Прочитано 24197 раз)
Александр Молодцов
Сотрудник СВД ВС
Опытный пользователь

Сообщений: 129

Gravatar


WWW
« : 18 Мая, 2010, 16:44:42 »

QEMU network configuration in QNX
(русская версия)

QEMU hardware emulator provides broad range of networking capabilities. Large set of emulated network controllers makes it possible (NE2000, Intel 82551, Intel 82557B, Intel 82559ER, Realtek RTL8139, Intel E1000 etc.), and allows networking in majority of guest systems. It hard to find advanced OS, which doesn't support NE2000 or RTL8139. Flexible network configurations and interactions between guest and host systems also play big role. In this article we will discuss various network configurations for QEMU in QNX host. Additional information you can also find in the Internet, and keep in mind that QNX6 networking subsystem is very similar to NetBSD.

Note 1. In all examples Archlinux installation CD (archlinux-2009.08-netinstall-i686.iso) is used as a guest system. But you can configure network the same way in other guest OS, for example Windows, QNX 4.25 or NetBSD, considering its specifics. QNX Neutrino 6.4.1 is used as a host system, but you can use QNX 6.4.0 or QNX 6.5.0.

Note 2. Following notation conventions are used in examples:

 -
[QNX] -- command is executed on the QNX host system;
 -
[ARCH] -- command is executed on the guest system, in our case Archlinux.


Network user mode

The easiest way to connect to host system is the user mode. In this mode QEMU provides:

 - virtual network (10.0.2.0)
 - firewall which doesn't allow any external connections
 - DHCP server (10.0.2.2)
 - gateway (10.0.2.2)

DHCP server automatically assigns 10.0.2.15 to your interface when a DHCP request is received from guest system. When the host system (QNX) is connected to the Internet, the guest will be automatically be able to access the Internet too. No additional steps are required.

1. [QNX] Start virtual machine:

Код:
# qemu -net user -net nic -cdrom /home/qemu/img/archlinux-2009.08-netinstall-i686.iso

(щёлкните чтобы показать/скрыть)

2. [ARCH] Configure network interface:

Код:
# dhcpcd eth0
# ifconfig

(щёлкните чтобы показать/скрыть)

(щёлкните чтобы показать/скрыть)

3. [ARCH] Test network:

Код:
# ping -c2 10.0.2.2
# telnet 10.0.2.2

(щёлкните чтобы показать/скрыть)


Connecting virtual networks

You need to execute first QEMU process, which would wait for incoming connections on a specific port. Second QEMU process would connect to that port. Each time new packet appears in first QEMU virtual network, it is transfered into second network and vice versa.

Realize following configuration:

 - Guest system 1 waits for incoming connection on 8010 port;
 - Guest system 2 connects to guest system 1 through localhost:8010.

1. [QNX] Start guest system 1:

Код:
# qemu -net nic,macaddr=52:54:00:12:34:57 -net socket,listen=:8010 -cdrom /home/qemu/img/archlinux-2009.08-netinstall-i686.iso

2. [QNX] Start guest system 2:

Код:
# qemu -net nic,vlan=2,macaddr=52:54:00:12:34:56 -net socket,vlan=2,connect=127.0.0.1:8010 -cdrom /home/qemu/img/archlinux-2009.08-netinstall-i686.iso

3. [ARCH1] Configure network on the guest system 1:

Код:
# ifconfig eth0 10.0.2.101 netmask 255.255.255.0 up

(щёлкните чтобы показать/скрыть)

4. [ARCH2] Configure network on the guest system 2:

Код:
# ifconfig eth0 10.0.2.102 netmask 255.255.255.0 up

(щёлкните чтобы показать/скрыть)

5. [ARCH] Test network on both guest systems:

Код:
# ping -c 3 10.0.2.102

(щёлкните чтобы показать/скрыть)

Код:
# ping -c 3 10.0.2.101

(щёлкните чтобы показать/скрыть)


Connecting virtual network to TAP device

There is another way to create virtual network: using a virtual Ethernet device -- TAP driver. Ethernet frames received by such device will be also sent to the guest system's virtual network. Of course, Ethernet frames sent by guest system's virtual network will be also received by TAP device.

Using devnp-qtap.so driver for QNX6, applications are allowed to interact with a network device using a simple file descriptor. Any data sent over the file descriptor will be received on both sides. This means that applications running on the guest system will be able to access and connect to applications running on the host system. If port forwarding is allowed, guest applications can also access the Internet.

With the -net tap option QEMU will try to execute /etc/qemu-ifup script to configure TAP device and /etc/qemu-ifdown script after closing the device. If /etc/qemu-ifup is not found, program will be terminated. You can change default script names, or specify not to run them. For example:

Код:
# qemu -net tap,script=no,downscript=no <...>

To avoid specifying these options every time, you can create empty /etc/qemu-ifup script. Do not forget to set executable flag for file.

1. [QNX] Create and configure TAP device:

Код:
# mount -T io-pkt /lib/dll/devnp-qtap.so
# ifconfig tap0 10.0.0.1 netmask 255.255.255.0 up

2. [QNX] Start virtual machine:

Код:
# qemu -net nic -net tap,ifname=/dev/tap0 -cdrom /home/qemu/img/archlinux-2009.08-netinstall-i686.iso

3. [ARCH] Configure network interface:

Код:
# ifconfig eth0 10.0.0.2 netmask 255.255.255.0 up
# ifconfig

(щёлкните чтобы показать/скрыть)

4. [ARCH] Test network:

Код:
# ping -c 2 10.0.0.1
# telnet 10.0.0.1

(щёлкните чтобы показать/скрыть)

5. [QNX] Test network:

Код:
# ping -c 3 10.0.0.2

(щёлкните чтобы показать/скрыть)


Connecting virtual networks to TAP devices (two guest systems)

In this example we'll have 2 guest systems (two TAP devices). Each guest system is connected to host system using TAP device. In order to allow connections between guest systems you have to setup bridge between both TAP devices. Bridge will be central network node between host and both network systems.

1. [QNX] Create and configure TAP devices:

Код:
# mount -T io-pkt /lib/dll/devnp-qtap.so
# ifconfig tap0 10.0.0.1 netmask 255.255.255.0 up
# mount -T io-pkt /lib/dll/devnp-qtap.so
# ifconfig tap1 10.0.1.1 netmask 255.255.255.0 up

2. [QNX] Start guest system 1:

Код:
# qemu -net tap,ifname=/dev/tap0 -net nic,macaddr=80:00:00:12:34:57 -cdrom /home/qemu/img/archlinux-2009.08-netinstall-i686.iso

3. [QNX] Start guest system 2:

Код:
# qemu -net tap,ifname=/dev/tap1 -net nic,macaddr=80:00:00:12:34:56 -cdrom /home/qemu/img/archlinux-2009.08-netinstall-i686.iso

4. [QNX] Create and configure bridge interface:

Код:
# ifconfig bridge0 create
# brconfig bridge0 add tap0 add tap1 up

(щёлкните чтобы показать/скрыть)

5. [ARCH1] Configure network in guest system 1:

Код:
# ifconfig eth0 10.0.0.2 netmask 255.255.0.0 up

(щёлкните чтобы показать/скрыть)

6. [ARCH2] Configuring network in guest system 2:

Код:
# ifconfig eth0 10.0.1.2 netmask 255.255.0.0 up

(щёлкните чтобы показать/скрыть)

7. Test network using ping. In all cases you should be able to ping/access any system no matter what system you operate on.

« Последнее редактирование: 20 Мая, 2010, 12:35:47 от Александр Молодцов » Записан

Страниц: [1]   Вверх
  Печать  
 
Перейти в:  

Powered by MySQL Powered by PHP © 2002-2016 СВД Встраиваемые Системы.
При использовании материалов сайта ссылка на forum.kpda.ru обязательна.

Powered by SMF 1.1.21 | SMF © 2015, Simple Machines | © Aiwan. Kolobok smiles | Sitemap
Valid XHTML 1.0! Valid CSS!
Сайт СВД ВС

В последний раз google посещал эту страницу 26 Ноября, 2016, 04:26:43