Skip to content

Instantly share code, notes, and snippets.

@mcastelino
mcastelino / qemu_netdev_socket_vlan.md
Last active December 21, 2023 13:20
QEMU usermode virtual vlan using -netdev socket

Goal

How to launch multiple QEMU based VM's that can communicate with the outside world and between each other other without any setup on the host.

This uses two features available in qemu

  • User Mode Networking stack - SLIRP
  • Socket networking backend allows you to create a network of guests that can see each other

This allows us to have

@mcastelino
mcastelino / VFIO_nested.md
Last active February 5, 2024 09:34
QEMU VFIO in Nested VM vIOMMU

How to use VFIO to assign a device to nested VM

  • Here the vfio-pci device is passed in into the L1 VM
  • The L1 VM is setup with kernel_irqchip=split
  • The L0 exposes a virtual IOMMU to the L1 VM
qemu-system-x86_64 \
    -machine q35,accel=kvm,kernel_irqchip=split \
    -enable-kvm \
@mcastelino
mcastelino / nemu_qemu_early_serial.md
Last active October 22, 2018 19:01
NEMU QEMU Early Serial Port Early Kernel Debug

How to debug early boot kernel crashes

On the virt platform if the kernel crashes early (even before the virtio-serial port comes up), you need to be able to debug the early boot process. This can be done using the sysbug-debugcon device which is available right at boot.

The key items to note below are

  • Kernel commandline: console=ttyS0
  • Additional sysbus-debugcon device: -device sysbus-debugcon,iobase=0x3f8,chardev=serialcon -chardev file,path=/tmp/serial-log,id=serialcon

Note:

@mcastelino
mcastelino / qemu_qboot_acpi_pcie_shpc_hotplug.md
Last active October 18, 2018 20:25
Qemu Qboot APCI PCIE SHPIC Hotplug

Goal

QEMU supports multiple methods to perform device hotplug.

  • ACPI Hotplug on pci bus 0. (pcie.0 on virt or pci.0 on pc).
  • SHPC Based hotplug
  • PCIe Native hotplug

Kernel Requirements

The following config options have to be enabled

@mcastelino
mcastelino / qemu_optionrom.md
Last active June 14, 2022 07:09
QEMU Option ROMS and booting from option rom

With seabios

  1. QEMU includes bundled option ROMs which are loaded by default unless a device is specifically setup with --romfile="".
  2. These options roms are bundled as binaries. The source code for the same can be found at http://ipxe.org/
  3. These options roms are useful for example when you want to PXE boot over a virtio-net device.

Here is an example of booting via Network PXE using the option ROM

qemu-system-x86_64 \
@mcastelino
mcastelino / graphics-vfio.md
Created October 11, 2018 23:11 — forked from egernst/graphics-vfio.md
Passing graphics card to a Clear Container

Passing a graphics card to a Clear Container

Host system setup:

The directions below are specific to an Ubuntu 16.04 host system equipped with a GeForce GTX 550 Ti graphics card. While the process should be the same, YMMV.

  1. Make sure your system supports IOMMU groups

todo -- get directions from SRIOV page

@mcastelino
mcastelino / VFIO: PC vs Q35
Created October 11, 2018 20:44
VFIO: PC vs Q35
PC: | Q35:
00:04.0 VGA compatible controller: NVIDIA Corporation GK107 [GeForce GTX 650] (rev a1) (prog-if 00 [VGA controller]) | 00:03.0 VGA compatible controller: NVIDIA Corporation GK107 [GeForce GTX 650] (rev a1) (prog-if 00 [VGA controller])
Physical Slot: 4 <
Region 0: Memory at 80000000 (32-bit, non-prefetchable) [size=16M] | Region 0: Memory at 90000000 (32-bit, non-prefetchable) [size=16M]
Region 5: I/O ports at c000 [size=128] | Region 5: I/O ports at 6000 [size=128]
Capabilities: [78] Express (v2) Endpoint, MSI 00 | Capabi
@mcastelino
mcastelino / acpi_qemu_debug.md
Last active December 23, 2021 16:47
Debugging APCI using QEMU
@mcastelino
mcastelino / qemu_all_pcie.md
Last active April 12, 2024 01:31
qemu all pcie devices
Note: virtio-serial does cannot be connected to a pcie bus. It does work when connected directly to the host bridge as a transistional virtio device.
This needs to be investigated
```
#!/bin/bash
# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
# ex: ts=8 sw=4 sts=4 et filetype=sh
VMN=${VMN:=1}