Skip to content
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

Implement virtio-blk device #21

Merged
merged 6 commits into from
Jul 24, 2023
Merged

Conversation

shengwen-tw
Copy link
Collaborator

@shengwen-tw shengwen-tw commented Jul 23, 2023

This pull request aims to provide the support of the virtio-blk device for the project. The modification mainly includes:

  1. A code implementation of virtio-blk device
  2. Device tree source adjustment
  3. Linux kernel configuration adjustment
  4. Interrupt assignment / handling of the virtio-blk device

To test the new feature, you need to:

  1. Create a test disk image using dd, cfdisk, losetup, and mkfs.ext4, where I followed the guide of the presentation "Embedded linux from scratch in 45 minutes" at page 35.
  2. Launch the emulator using:
./semu <linux-image> [<dtb>] [<disk-img>]

The virtio-blk device should be enumerated at /dev/vda during the boot-up process. The following experiment can help to verify the device works properly:

  1. Observe the partition table of the disk:
fdisk -l
  1. Mount the disk to a directory:
mkdir mnt/
mount /dev/vda1 mnt/
  1. Try writing some thing to the mount directory:
echo "Hello World!" > mnt/test.txt
  1. Unmount the disk:
umount mnt/
  1. After re-launching the semu, the written file should remain existing.

configs/linux.config Outdated Show resolved Hide resolved
virtio-blk.c Outdated Show resolved Hide resolved
virtio-blk.c Outdated Show resolved Hide resolved
virtio-blk.c Outdated Show resolved Hide resolved
@jserv jserv changed the title Add support of emulating virtio-blk device Implement virtio-blk device Jul 23, 2023
@jserv
Copy link
Collaborator

jserv commented Jul 23, 2023

Check kvm-host for generating ext4 file system image for validation.

@jserv
Copy link
Collaborator

jserv commented Jul 23, 2023

Update README.md for command line options.

.gitignore Outdated Show resolved Hide resolved
virtio-blk.c Outdated Show resolved Hide resolved
main.c Outdated Show resolved Hide resolved
main.c Outdated Show resolved Hide resolved
main.c Outdated Show resolved Hide resolved
virtio-blk.c Outdated Show resolved Hide resolved
virtio-blk.c Outdated Show resolved Hide resolved
virtio-blk.c Outdated Show resolved Hide resolved
virtio-blk.c Outdated Show resolved Hide resolved
virtio-blk.c Outdated Show resolved Hide resolved
virtio-blk.c Outdated Show resolved Hide resolved
main.c Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
main.c Outdated Show resolved Hide resolved
virtio-blk.c Show resolved Hide resolved
virtio-blk.c Outdated Show resolved Hide resolved
main.c Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
virtio-blk.c Outdated Show resolved Hide resolved
virtio-blk.c Outdated Show resolved Hide resolved
virtio-blk.c Outdated Show resolved Hide resolved
virtio-blk.c Outdated Show resolved Hide resolved
virtio-blk.c Outdated Show resolved Hide resolved
virtio-blk.c Outdated Show resolved Hide resolved
@sysprog21 sysprog21 deleted a comment from shengwen-tw Jul 24, 2023
@jserv jserv merged commit 21dc47d into sysprog21:master Jul 24, 2023
2 checks passed
@jserv
Copy link
Collaborator

jserv commented Jul 24, 2023

Thank @shengwen-tw for contributing!

@shengwen-tw
Copy link
Collaborator Author

Thanks for the code review!

@shengwen-tw shengwen-tw deleted the virtio-blk branch July 25, 2023 17:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants