/nvmeqemu

NVM Express Device Emulation in QEMU

Primary LanguageCOtherNOASSERTION

1. Introduction
2. How to compile Qemu with NVME support.
3. Make a virtual HD for QEMU
4. Locate and download a Linux based 64b OS to virtualize
5. Install KVM
6. Install the chosen virtualized OS to the virtual HD
7. Boot the virtual machine from the virtual HD
8. Performance notes
9. Usage Notes


Qemu for NVME.

1. Introduction.

To get more details about Qemu visit the official website:
http://wiki.qemu.org/Main_Page

To clone Qemu with support for NVME clone source code from:
git clone git@github.com:nvmeqemu/nvmeqemu.git

2. How to compile Qemu with NVME support.
    a. Clone the above git repository.
    b. Make sure you are using a 64 bit environment and a 64 bit Linux kernel.
    c. You need the following libraries:
       For Ubuntu 10.10 Server 64b host:
           sudo apt-get install linux-headers-2.6.35-22-server
           sudo apt-get install zlib1g-dev
           sudo apt-get install libsdl-dev
           sudo apt-get install libaio-dev

       For RHEL5 host (If the packages are not found, check your repositories' setup):
           yum install kernel-devel
           yum install zlib-devel
           yum install SDL
           yum install libaio-devel
       ./configure --enable-io-thread --enable-linux-aio --target-list=x86_64-softmmu --enable-sdl
       NOTE: With RHEL5 the configure might fail, complaining about AIO even after installing it. Ignore it and re-run configure with the AIO switch removed from the command

       make

    d. The resulting executable is qemu/x86_64-softmnu/qemu-system-x86_64/qemu-system-x86_64. You can add it to $PATH for easy access.

3. Make a virtual HD for QEMU
    1. On RHEL5:
       yum install qemu-img

    2. Execute
       qemu-img create -f raw <your_virtual_HD_filename.img> <size>M

4. Locate and download a Linux based 64b OS to virtualize
    1. Download the iso file and save as <your_iso_image_filename.iso>

5. Install KVM

    1. On RHEL5:
       yum install kvm kmod-kvm

6. Install the guest OS to the virtual HD
   1. Execute
      ./qemu-system-x86_64 -m 1024 -cdrom <path_to_your_iso_image>/<your_iso_image_filename.iso> -hda <path_to_virtual_HD>/<your_virtual_HD_filename.img> -device nvme -boot d
          A terminal window should launch into view booting from the supplied ISO file.
          Follow through the usual actions to install the OS onto the virtual HD.
          Feel free to partition/format/re-initialize virtual HD as necessary.
          At the end of a successful installation reboot the virtual machine.

7. Boot the virtual machine from the virtual HD
    1. Execute with kvm support (recommended)
       sudo ./qemu-system-x86_64 -m 1024 -hda <path_to_virtual_HD>/<your_virtual_HD_filename.img> -device nvme --enable-kvm -smp 2
    2. Execute without kvm support
       sudo ./qemu-system-x86_64 -m 1024 -hda <path_to_virtual_HD>/<your_virtual_HD_filename.img> -device nvme -smp 2

8. Performance notes
    1. Consider adding the following switches when invoking configure:
    --enable-io-thread --enable-linux-aio
    2. Consider adding the following switches when invoking qemu:
    --enable-kvm -smp 2

9. Usage Notes
    1. Config Files
           NVME module of Qemu uses two device config files called "NVME_device_PCI_config" and "NVME_device_NVME_config" located inside the /qemu/hw directory
           They basically enable the user to set up the intial values in both the PCI and NVME config space
           These file names are unique and thus there should not be multiple files with the above names inside the directory from where the qemu is run by executing Step 6
           Program should be executed from an higher level directory so that both the config files are available inside the directory itself else both spaces will be initialized to
           defaulted values
    2. Additional command line options:
            You can configure the number of namespaces and their sizes from the command line. The options are: namespaces=<number_of_namespaces> and size=<size_in_MB>. These options go after the "-device namespace". Example
            sudo ./qemu-system-x86_64 -m 1024 -hda <path_to_virtual_HD>/<your_virtual_HD_filename.img> -device,namespace=1,size=1024 nvme -smp 2
            The program limits the number of namespaces to 16 per device and 8GB in size. There will be 1 namespace of 512 MB by default if no opt

            Full list of -device nvme options:
            namespaces=<number_of_namespaces>  : the maximum number of namespaces the device can have.
            size=<size_in_MB>                  : size each automatically created namespace will be.