Git Product home page Git Product logo

pciemu's Introduction

pciemu

License Build

pciemu provides an example of PCIe Device Emulation in QEMU.

The idea is to help those willing to explore PCIe devices but do not have access to a real hardware. Or maybe someone with research ideas for a new PCIe device or capability who want to easily test those ideas.

Virtual devices can also be used to speed up the development process of a new PCIe device and create test suites that do not require the existence of the physical HW.

Please note that pciemu implements a relatively simple device, with the goal mainly being to provide an initial tutorial on how to write a virtual PCIe device in QEMU.

Preparing the environment

There are mainly two ways of building and running : locally or using codespaces.

Codespaces

Users willing to use codespaces will benefit from scripts properly preparing and configuring codespaces to be used "out-of-the-box".

Basically, during the instantiation of the codespace, the "post create" script will install all necessary dependencies, ensure configurations are correct and execute the scripts to intialize the qcow2 disk images.

Locally

Another option is to build and run locally. In this case, configuring the environment can vary depending on the system being used. Users are encouraged to check the "post create" script to understand all necessary dependencies and configurations for building and running.

Setup and Compiling QEMU

The setup script will modify build files and configure QEMU to properly compile the pciemu device along with all other QEMU files. Thus, once all preparation is finished, run the following:

$ ./setup.sh

Note here for those running locally: though normally not necessary, you may need to change the arguments of the ./configure command inside the setup script to better translate them to your system requirements.

Running

There is basically no distinction between running locally or inside a codespace.

Once all dependencies are installed and QEMU is properly compiled, all you have to do is run QEMU:

$ qemu_fedora

This alias will launch a Virtual Machine (VM) with QEMU in the background with the correct set of arguments. (see .qemu_config)

Finally, to login into the VM, use the alias:

$ fedora

Check the image information file for more details regarding the image files.

Inside the VM

In order to make the qcow2 files relatively small, the VM images do not come with several packages installed. A few are very important for the purpose of compiling the kernel module and userspace program. Thus, inside the VM, the first order of business is to run the following:

sudo dnf install -y make gcc "kernel-devel-uname-r == $(uname -r)"

Later, it's all standard kernel module compilation and insertion into the kernel:

$ cd /hostdir/src/sw/kernel/
$ make
$ sudo insmod pciemu.ko

Finally, the userspace program:

$ cd /hostdir/src/sw/userspace/
$ make
$ ./pciemu_example -h

Don't forget that lspci is your friend when it comes to PCIe devices.

pciemu's People

Contributors

luizinhosuraty avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.