When debugging Qemu, it might be helpoful to instrument Linux Kernel to see when interrupts get received, or see data on the other side of a transfer. If you have to modify the Kernel on a regular basis, it can be faster to build it in place than to build a customer RPM/DEB and install inside the VM. Here is how I have been going about updating the kernel.
Continue readingCategory Archives: Virtualization
Viewing the Flattened Device Tree from Qemu
The Qemu implementation uses a Flattened Device Tree (FTD) to manage the virtual implementation of the physical devices in a machine. I need to create a FTD entry for the MCTP-PCC implementation I am writing in Qemu. Since this is new to me, and I am working (as I most often do) via Ttrial and error, I want to see the FTD entry after I write it. Here is how I am dumping it.
Continue readingDebugging Qemu with gdb
When developing Linux Kernel code, I have found myself wanting to have a test fixture inside the Firmware that lets me inspect the values communicated out of and into the Linux Kernel. I am currently writing one such fixture in Qemu. And I have an interrupt that is not getting handled by the Linux Kernel, I think because it is not getting delivered.
I have found it quite valuable to run this Qemu process in the Gnu Debugger. Here is how I (with help) got to the bottom of the mystery.
Continue readingOne liner to install Fedora Cloud image in a local VM
sudo virt-install --name fedora40 --os-variant fedora40 --disk /var/lib/libvirt/images/Fedora-Cloud-Base-Generic.x86_64-40-1.14.qcow2 --import --cloud-init root-ssh-key=/home/ayoung/.ssh/id_rsa.pub
Using virt-install and cloud-init
I want to call out a stellar article that told me exactly what I needed to do in order to use virt-install and cloud-init to launch a cloud-image. The only thing I have to add is the caveat that the #cloud-config comment at the top of the user-data file is required. The system will ignore the file if it does not start with that comment. This is the easiest way I know to launch a brand new VM.
XPath for libvirt external snapshop path
The following xmllint XPath query will pull out the name of the backing file for a VM named fedora-server-36 and an external snapshot named fedora-36-post-install,
virsh snapshot-dumpxml fedora-server-36 fedora-server-36-post-install | xmllint --xpath "string(//domainsnapshot/disks/disk[@snapshot='external']/source/@file)" - |
The string function extracts the attribute value.
This value can be used in the process of using or deleting the snapshot.
Parsing libvirt xmldump using xpath
In a recent article, I saw yet another example of using grep to pull information out of xml, and then to manually look for a field. However, XML is structured, and with XPath, we can pull out exactly what we need.
virsh dumpxml fedora-server-36 | xmllint --xpath "//domain/devices/disk[@device='disk']" - |
That will produce output like this:
<disk type="file" device="disk"> <driver name="qemu" type="qcow2" discard="unmap"/> <source file="/var/lib/libvirt/images/fedora-server-36.qcow2"/> <target dev="vda" bus="virtio"/> <address type="pci" domain="0x0000" bus="0x05" slot="0x00" function="0x0"/> </disk> |
Note that I did more in my XPath than required by the original article. I wanted to show an example of querying based on an attribute inside the selected node.
Update: Here is an example for what is done later in the article: pull the path out of the pool xml.
virsh pool-dumpxml default | xmllint --xpath "//pool/target/path/text()" - /var/lib/libvirt/images |
Enabling Fedora 35 Virtualization on an Ampere based machine
I have a fresh install of Fedora 35 on a lab machine. I want to run a virtual machine on it. I have ssh access to the root account and a public key copied over.
Continue readingPXE Setup Part the First
PXE is conglomeration of tools used to get a new operating system onto a computer. It is based on two protocols: DHCP and TFPT. I used PXER a long time ago at Penguin and have always wanted to set it up for my home personal use. I’m doing that now for my lab. My goal is to first be able to provision virtual machines, and then to provision physical boxes. I need to do a full install of RHEL 7 and RHEL 8, which means I also need Kickstart to automate the install process. I had it working, but after rebooting the NUC it is running on it broke. Here’s my debugging.
Continue readingRemotely Provisioning a Virtual Machine using Ansible and Libvirt
Ansible exists to help automate the time consuming repeated tasks that technologist depend upon. One very common jobs is to create and tear down a virtual machine. While cloud technologies have made this possible to perform remotely, there are many times when I’ve needed to setup and tear down virtual machines on systems that were stand alone Linux servers. In this case, the main interfaces to the machine are ssh and libvirt. I recently worked through an Ansible role to setup and tear down an virtual machine via libvirt, and I’d like to walk through it, and record my reasons for some of the decisions I made.
Continue reading