Skip to content

Instantly share code, notes, and snippets.

@Utshaw
Last active November 29, 2025 02:52
Show Gist options
  • Select an option

  • Save Utshaw/2d3c0ccacefe3cba1d0c09f3371d80e4 to your computer and use it in GitHub Desktop.

Select an option

Save Utshaw/2d3c0ccacefe3cba1d0c09f3371d80e4 to your computer and use it in GitHub Desktop.
qemu_centos
sudo dnf install -y virt-viewer
sudo mv ~/Downloads/CentOS-Stream-8-20240603.0-x86_64-dvd1.iso /var/lib/libvirt/images/
sudo chown qemu:qemu /var/lib/libvirt/images/CentOS-Stream-8-20240603.0-x86_64-dvd1.iso
sudo virt-install \
--name utshaw_vm \
--memory 4096 \
--vcpus 4 \
--cpu host-passthrough \
--disk path=/var/lib/libvirt/images/utshaw_vm.qcow2,size=20,format=qcow2 \
--cdrom /var/lib/libvirt/images/CentOS-Stream-8-20240603.0-x86_64-dvd1.iso \
--os-variant centos8 \
--network network=default \
--graphics spice \
--boot uefi
sudo virsh shutdown utshaw_vm
sudo virsh list --all
sudo virsh destroy utshaw_vm
sudo virsh edit utshaw_vm
Inside the XML, find the <cpu> section.
If <cpu> exists, replace it.
If it does not exist, add this block right after <vcpu> element.
<cpu mode='host-passthrough'>
<topology sockets='1' dies='1' cores='2' threads='1'/>
<numa>
<cell id='0' cpus='0-1' memory='2048' unit='MiB'/>
<cell id='1' cpus='2-3' memory='2048' unit='MiB'/>
</numa>
</cpu>
Make sure it is inside the <domain> root section, not outside.
sudo virsh start utshaw_vm
GUI: virt-viewer utshaw_vm
sudo virsh edit utshaw_vm
Replace code with this:
<loader readonly='yes' secure='no' type='pflash'>/usr/share/edk2/ovmf/OVMF_CODE.cc.fd</loader>
<nvram>/var/lib/libvirt/qemu/nvram/utshaw_vm_VARS.fd</nvram>
sudo cp /usr/share/edk2/ovmf/OVMF_VARS.fd /var/lib/libvirt/qemu/nvram/utshaw_vm_VARS.fd
sudo virsh start utshaw_vm
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment