Skip to content

Commit

Permalink
Update virtio blk readme
Browse files Browse the repository at this point in the history
  • Loading branch information
erichchan999 committed Feb 8, 2024
1 parent 00fa516 commit ff3b7ac
Showing 1 changed file with 28 additions and 29 deletions.
57 changes: 28 additions & 29 deletions examples/virtio/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,44 +36,43 @@ to any serial device on the platform. The virtIO console support in libvmm talks
a serial multiplexor which then talks to a driver for input/output to the physical
serial device.

When you boot the example, you will see different coloured output for each guest.
When you boot the example, you will see different coloured output for each guest. The Linux logs will be interleaving like so:
```
Starting klogd: OKStarting klogd:
OK
Running sysctl: Running sysctl: OK
OKSaving random seed:
Saving random seed: [ 4.070358] random: crng init done
[ 4.103992] random: crng init done
OK
Starting network: OK
Starting network: OK
OK
Welcome to Buildroot
buildroot login:
Welcome to Buildroot
buildroot login:
```

Initially all input is defaulted
to guest 1 in green. To switch to input into the other guest (red), type in `@2`.
The `@` symbol is used to switch between clients of the serial system, in this case the red guest is client 2.

### virtIO block

Guest 1 also doubles as a client in the block system that talks virtIO to a driver VM (guest 2) that has passthrough access to the block device.
Guest 1 and guest 2 also doubles as a client in the block system that talks virtIO to a driver VM (guest 3) that acts as both a block MUX and driver that has passthrough access to the block device.

When you boot the example, the block driver VM in red will boot first. When it is ready, the client VM in green will boot.
When you boot the example, the block driver VM will boot first. When it is ready, the client VMs will boot together.

After the block client VM boots it will attempt to mount the virtIO block device `/dev/vda` into `/mnt`. The block device contains an ext4 filesystem allowing us to test it using block benchmark programs like `postmark`, which has been included in `/root`.
After the client VMs boot, they will attempt to mount the virtIO block device `/dev/vda` into `/mnt`. Whilst this is atypical usage of raw block devices (it has no partition tables and only contains an ext4 file system emulated by the driver VM) it is sufficient to demonstrate that the virtIO block implementation works.

Client VM requests to the driver VM will print out debugging messages using the serial system.
```
Starting syslogd: OK
Starting klogd: OK
Running sysctl: OK
Saving random seed: [ 18.959300] random: crng init done
OK
Starting network: OK
VIRTIO(BLOCK): ------------- Driver notified device -------------
VIRTIO(BLOCK): ----- Request type is 0x0 -----
VIRTIO(BLOCK): Request type is VIRTIO_BLK_T_IN
VIRTIO(BLOCK): Sector (read/write offset) is 2
VIRTIO(BLOCK): Descriptor index is 1, Descriptor flags are: 0x3, length is 0x400
UIO_DRIVER: received irq, count: 2
UIO_DRIVER(BLOCK): Received command: code=0, addr=0x30601000, block_number=1, count=1, id=1
VIRTIO(BLOCK): ------------- Driver notified device -------------
VIRTIO(BLOCK): ----- Request type is 0x0 -----
VIRTIO(BLOCK): Request type is VIRTIO_BLK_T_IN
VIRTIO(BLOCK): Sector (read/write offset) is 0
VIRTIO(BLOCK): Descriptor index is 1, Descriptor flags are: 0x3, length is 0x1000
UIO_DRIVER: received irq, count: 3
UIO_DRIVER(BLOCK): Received command: code=0, addr=0x30601400, block_number=0, count=4, id=2
...
...
...
[ 19.708718] EXT4-fs (vda): mounted filesystem without journal. Quota mode: none.
[ 22.860300] EXT4-fs (vda): mounted filesystem without journal. Quota mode: none.
[ 22.793574] EXT4-fs (vda): mounted filesystem without journal. Quota mode: none.
```

We can further test it using block benchmark programs like `postmark`, which has been included in `/root`, by running it in the `/mnt` directory.

To use a zeroed out emulated raw block device in the clients, replace this line in the Makefile:
`BLK_DRIVER_VM_USERLEVEL := uio_blk_driver storage_0 storage_1` with this `BLK_DRIVER_VM_USERLEVEL := uio_blk_driver`

0 comments on commit ff3b7ac

Please sign in to comment.