Skip to content

ia32-generic-qemu: Move network setup to quickstart and cover setup for IPv6 #190

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
97 changes: 7 additions & 90 deletions ports/azure_sdk.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
- [General information](#general-information)
- [Supported version](#supported-version)
- [Quickstart for ia32-generic-qemu](#quickstart-for-ia32-generic-qemu)
- [Network setup on ia32-generic-qemu](#network-setup-on-ia32-generic-qemu)

Check warning on line 11 in ports/azure_sdk.md

View workflow job for this annotation

GitHub Actions / build

'myst' cross-reference target not found: 'network-setup-on-ia32-generic-qemu' [myst.xref_missing]
- [Running the IoThub Client sample](#running-the-iothub-client-sample)
- [Using azure-iot-sdk-c](#using-azure-iot-sdk-c)
- [Running tests](#running-tests)
Expand Down Expand Up @@ -45,99 +45,16 @@
[Here](https://github.com/phoenix-rtos/phoenix-rtos-doc/blob/master/building/script.md) you can find more about
building scripts.

Next, you will need an internet connection. Here is an example of how to set up a network connection on
`ia32-generic-qemu`:
Next, you will need an internet connection.
[Here](../quickstart/ia32-generic-qemu.md#network-setup-on-ia32-generic-qemu)
is an example of how to set up a network connection on `ia32-generic-qemu`.

## Network setup on ia32-generic-qemu
- To complete the configuration please set the current date using `date` applet, like below:

- Note: This guide was tested on `Ubuntu 20.04 LTS` host OS.
![Image](_images/azure_date.png)

There are few steps to follow:

1. Create and set up `vibr0` bridge on a host using `qemu-bridge-helper`:

- Install the required package and ensure that `libvirtd` is running:

```console
sudo apt-get update
sudo apt-get install qemu-system-common
systemctl enable libvirtd.service
systemctl start libvirtd.service
```

- Start the default network bridge, and configure it to run on startup.

```console
sudo virsh net-autostart --network default
sudo virsh net-start --network default
```

- After that verify that the IP range `192.168.122.1/24` is reported by the `vibr0` bridge:

```console
ip addr show virbr0
```

- The expected output:

```console
virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
```

- Set up `qemu-bridge-helper` (`chmod` is used here to allow running QEMU without root privileges)

```console
echo "allow virbr0" > /etc/qemu/bridge.conf
sudo chmod a+rw /etc/qemu/bridge.conf
```

- If `/etc/qemu` directory does not exist, create it and provide required privileges:

```console
sudo mkdir /etc/qemu
sudo chmod a+rw /etc/qemu
echo "allow virbr0" > /etc/qemu/bridge.conf
sudo chmod a+rw /etc/qemu/bridge.conf
```

![Image](_images/azure_sdk_vibr_setup.png)

- Sources: <https://apiraino.github.io/qemu-bridge-networking/>,
<https://mike42.me/blog/2019-08-how-to-use-the-qemu-bridge-helper-on-debian-10>

2. Launch `qemu` using a starting script with `net` suffix:

```console
./scripts/ia32-generic-qemu-net.sh
```

3. Configure network and run `ash` (Busybox applet) using `rc` script:

- Note: By default `IP` is assigned using `DHCP`. For other possibilities please check the configuration file
located in `_projects/ia32-generic-qemu/rootfs-overlay/etc/rc.conf.d/network`

- Note: There are other programs executed by the script. For more information please check the content of the `rc`
file for `ia32-generic-qemu` in `_projects/ia32-generic-qemu/rootfs-overlay/etc/rc`

```console
/linuxrc
```

- As you can see, the advanced version of `Phoenix-RTOS` with `POSIX` shell has been started:

![Image](_images/azure_linuxrc.png)

- Now you can check the internet connection using the `ping` applet.

- To complete the configuration please set the current date using `date` applet, like below:

![Image](_images/azure_date.png)

- Note: The required argument entered after `@` is EPOCH (POSIX time format) - you can gt it for example from
[here](https://www.epochconverter.com/).
- Note: The required argument entered after `@` is EPOCH (POSIX time format) - you can gt it for example from
[here](https://www.epochconverter.com/).

## Running the IoThub Client sample

Expand Down
File renamed without changes
134 changes: 134 additions & 0 deletions quickstart/ia32-generic-qemu.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,140 @@ The number of detected cores is presented during kernel initialization.

![Image](_images/qemu-ia32-generic-smp.png)

## Network setup on `ia32-generic-qemu`

- Note: This guide was tested on `Ubuntu 24.04 LTS` host OS.

There are few steps to follow:

1. Create and set up `vibr0` bridge on a host using `qemu-bridge-helper`:

- Install the required package and ensure that `libvirtd` is running:

```bash
sudo apt update
sudo apt install qemu-system-common
sudo apt install libvirt-clients libvirt-daemon
systemctl enable libvirtd.service
systemctl start libvirtd.service
```

- Start the default network bridge, and configure it to run on startup.

```bash
sudo virsh net-autostart --network default
sudo virsh net-start --network default
```

- If IPv6 is needed change the configuration of `virbr0`

```bash
sudo virsh net-destroy default
sudo virsh net-edit default
```

The commands above open the editor of the configuration file of `virbr0`. There are two necessary changes:

- Add IPv6 address to the bridge interface:

```XML
<ip family='ipv6' address='2001:db8:dead:beef:fe::2' prefix='64'/>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[LanguageTool] reported by reviewdog 🐶
Unpaired symbol: ‘'’ seems to be missing (EN_UNPAIRED_QUOTES)
URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses
Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US
Category: PUNCTUATION

```

- Enable NAT for IPv6:

```XML
<forward mode='nat'>
<nat ipv6='yes'/>
</forward>
```

The overall config should look something like this:

```XML
<network>
<name>default</name>
<uuid>a9e032b7-e32f-4f91-a273-e6c6f15b8904</uuid>
<forward mode='nat'>
<nat ipv6='yes'/>
</forward>
<bridge name='virbr0' stp='on' delay='0'>
<mac address='52:54:00:99:4d:c3'/>
<ip address='192.168.122.1' netmask='255.255.255.0'>
<dhcp>
<range start='192.168.122.2' end='192.168.122.254'/>
</dhcp>
</ip>
<ip family='ipv6' address='2001:db8:dead:beef:fe::2' prefix='64'/>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[LanguageTool] reported by reviewdog 🐶
Unpaired symbol: ‘'’ seems to be missing (EN_UNPAIRED_QUOTES)
URL: https://languagetool.org/insights/post/punctuation-guide/#what-are-parentheses
Rule: https://community.languagetool.org/rule/show/EN_UNPAIRED_QUOTES?lang=en-US
Category: PUNCTUATION

</network>
```

Save the config file and start the bridge by running:

```bash
sudo virsh net-start default
```

- After that verify that the IP range `192.168.122.1/24` is reported by the `vibr0` bridge:

```bash
ip addr show virbr0
```

- The expected output:

```bash
virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default qlen 1000
link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
inet 192.168.122.1/24 brd 192.168.122.255 scope global virbr0
valid_lft forever preferred_lft forever
```

- Set up `qemu-bridge-helper` (`chmod` is used here to allow running QEMU without root privileges)

```bash
echo "allow virbr0" > /etc/qemu/bridge.conf
sudo chmod a+rw /etc/qemu/bridge.conf
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use valid groups (chown and valid chmod?)

```

- If `/etc/qemu` directory does not exist, create it and provide required privileges:

```bash
sudo mkdir /etc/qemu
sudo chmod a+rw /etc/qemu
echo "allow virbr0" > /etc/qemu/bridge.conf
sudo chmod a+rw /etc/qemu/bridge.conf
```

![Image](_images/ia32_sdk_vibr_setup.png)

- Sources: <https://apiraino.github.io/qemu-bridge-networking/>,
<https://mike42.me/blog/2019-08-how-to-use-the-qemu-bridge-helper-on-debian-10>

2. Launch `qemu` using a starting script with `net` suffix:

```bash
./scripts/ia32-generic-qemu-net.sh
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have:

failed to create tun device: Operation not permitted
qemu-system-i386: -netdev bridge,br=virbr0,id=net0: bridge helper failed

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I run it with sudo, but will try to find another way

```

3. Configure network and run `ash` (Busybox applet) using `rc` script:

- Note: By default `IP` is assigned using `DHCP`. For other possibilities please check the configuration file
located in `_projects/ia32-generic-qemu/rootfs-overlay/etc/rc.conf.d/network`

- Note: There are other programs executed by the script. For more information please check the content of the `rc`
file for `ia32-generic-qemu` in `_projects/ia32-generic-qemu/rootfs-overlay/etc/rc`

```bash
/linuxrc
```

- As you can see, the advanced version of `Phoenix-RTOS` with `POSIX` shell has been started:

![Image](_images/ia32_linuxrc.png)

- Now you can check the internet connection using the `ping` applet.

## Running image on regular hardware

To run the image on regular hardware please be sure that a target system is equipped with an ATA disk supporting the
Expand Down
Loading