-
-
Save mcastelino/005db8df4e63de12af37ad9d4bb5edf7 to your computer and use it in GitHub Desktop.
Q35 + Hotplug devices (no ACPI)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Get qemu | |
git clone https://github.com/qemu/qemu | |
# Apply configure patch | |
curl https://raw.githubusercontent.com/clearcontainers/packaging/master/qemu-lite/configure.patch | patch -p1 | |
# Configure qemu line | |
./configure --disable-static --disable-bluez --disable-brlapi --disable-bzip2 --disable-curl --disable-curses --disable-debug-tcg --disable-fdt --disable-glusterfs --disable-gtk --disable-libiscsi --disable-libnfs --disable-libssh2 --disable-libusb --disable-linux-aio --disable-lzo --disable-opengl --disable-qom-cast-debug --disable-rbd --disable-rdma --disable-sdl --disable-seccomp --disable-slirp --disable-snappy --disable-spice --disable-strip --disable-tcg-interpreter --disable-tcmalloc --disable-tools --disable-tpm --disable-usb-redir --disable-uuid --disable-vnc --disable-vnc-jpeg --disable-vnc-png --disable-vnc-sasl --disable-vte --disable-xen --enable-attr --enable-cap-ng --enable-kvm --enable-virtfs --target-list=x86_64-softmmu --extra-cflags="-fno-semantic-interposition -O3 -falign-functions=32" --datadir=/usr/share/qemu-lite --libdir=/usr/lib64/qemu-lite --libexecdir=/usr/libexec/qemu-lite --enable-vhost-net --disable-docs | |
# Create a device mapper | |
dd if=/dev/zero of=devmap.img count=1 bs=50M | |
fdisk devmap.img | |
# Command (m for help): g | |
# Command (m for help): n | |
# Partition number (1-128, default 1): <RETURN> | |
# First sector (2048-102366, default 2048): <RETURN> | |
# Last sector, +sectors or +size{K,M,G,T,P} (2048-102366, default 102366): <RETURN> | |
# Command (m for help): w | |
fdisk -l devmap.img | |
# Disk devmap.img: 50 MiB, 52428800 bytes, 102400 sectors | |
sudo partx -av devmap.img | |
# /dev/loop4: partition #1 added | |
sudo mkfs.ext4 /dev/loop4p1 | |
sudo dmsetup create devmap --table '0 102400 linear /dev/loop4 0' | |
# do not forget remove it once you finish with your tests | |
ls -l /dev/mapper/devmap | |
# /dev/mapper/devmap -> ../dm-4 | |
sudo dmsetup remove -f /dev/dm-4 | |
sudo partx -d /dev/loop4 | |
# Option 1 - hot-plug a pcie-pci-bridge -> hot-plug a device | |
./qemu-system-x86_64 -machine q35,accel=kvm,kernel_irqchip,nvdimm -cpu host -device nvdimm,id=nv0,memdev=mem0 -object memory-backend-file,id=mem0,mem-path=container.img,size=524288000 -m 2048M,slots=2,maxmem=16998M -smp 4,cores=4,threads=1,sockets=1 -vga none -nographic -no-user-config -nodefaults -kernel vmlinuz-4.9.47-77.container -append "root=/dev/pmem0p1 rootflags=dax,data=ordered,errors=remount-ro rw rootfstype=ext4 tsc=reliable no_timer_check rcupdate.rcu_expedited=1 i8042.direct=1 i8042.dumbkbd=1 i8042.nopnp=1 i8042.noaux=1 noreplace-smp noacpi noapic pci=conf1 reboot=k panic=1 console=hvc0 console=hvc1 initcall_debug iommu=off cryptomgr.notests net.ifnames=0 console=ttyS0" -device virtio-serial-pci,id=virtio-serial0 -chardev stdio,id=charconsole0,signal=off -device virtconsole,chardev=charconsole0,id=console0 -enable-kvm -qmp unix:hypervisor.sock,server,nowait -device pcie-root-port,bus=pcie.0,id=rp3,bus-reserve=1 | |
# Option 2 - hot plug a device | |
./qemu-system-x86_64 -machine q35,accel=kvm,kernel_irqchip,nvdimm -cpu host -device nvdimm,id=nv0,memdev=mem0 -object memory-backend-file,id=mem0,mem-path=container.img,size=524288000 -m 2048M,slots=2,maxmem=16998M -smp 4,cores=4,threads=1,sockets=1 -vga none -nographic -no-user-config -nodefaults -kernel vmlinuz-4.9.47-77.container -append "root=/dev/pmem0p1 rootflags=dax,data=ordered,errors=remount-ro rw rootfstype=ext4 tsc=reliable no_timer_check rcupdate.rcu_expedited=1 i8042.direct=1 i8042.dumbkbd=1 i8042.nopnp=1 i8042.noaux=1 noreplace-smp noacpi noapic pci=conf1 reboot=k panic=1 console=hvc0 console=hvc1 initcall_debug iommu=off cryptomgr.notests net.ifnames=0 console=ttyS0" -device virtio-serial-pci,id=virtio-serial0 -chardev stdio,id=charconsole0,signal=off -device virtconsole,chardev=charconsole0,id=console0 -enable-kvm -qmp unix:hypervisor.sock,server,nowait -device ioh3420,bus=pcie.0,id=rp3 -device pcie-pci-bridge,id=br3,bus=rp3 | |
# Connect to hypervisor.sock | |
socat stdin,raw unix-connect:hypervisor.sock | |
# check qmp capabilities | |
{ "execute": "qmp_capabilities" } | |
# (Option 1) - Add a pcie-pci-bridge | |
{ "execute": "device_add", "arguments": { "driver": "pcie-pci-bridge", "id": "br3", "bus": "rp3" } } | |
# Hotplugging virtio disk | |
{ "execute": "blockdev-add", "arguments":{"driver":"raw","node-name":"disk1", "file":{"driver":"file","filename":"/dev/mapper/devmap"}}} | |
{ "execute": "device_add", "arguments": { "driver": "virtio-blk", "drive": "disk1", "id": "virtio0", "bus": "br3", "addr": "1" } } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment