Reputation: 7315
I'm trying to create the following domain on a host running oVirt Node in nested virtualization (it won't be nested forever, just for now):
<domain type="kvm">
<name>clara</name>
<memory unit="MiB">4096</memory>
<vcpu>2</vcpu>
<os>
<type>hvm</type>
<boot dev="hd"></boot>
</os>
<features>
<pae></pae>
<acpi></acpi>
<apic></apic>
</features>
<cpu></cpu>
<devices>
<disk type="volume" device="disk">
<driver name="qemu" type="qcow2"></driver>
<source pool="default" volume="clara-rootfs"></source>
<target dev="vda" bus="scsi"></target>
<wwn>05abcd62857fe8f1</wwn>
</disk>
<disk type="file" device="cdrom">
<driver name="qemu" type="raw"></driver>
<source file="/var/lib/libvirt/images/cloudinit.clara.iso"></source>
<target dev="hdd" bus="ide"></target>
</disk>
<controller type="scsi" model="virtio-scsi"></controller>
<interface type="bridge">
<mac address="E2:F5:2A:A9:4A:42"></mac>
<source bridge="bridge0"></source>
<model type="virtio"></model>
</interface>
<channel type="unix">
<target type="virtio" name="org.qemu.guest_agent.0"></target>
</channel>
<graphics type="spice" autoport="yes"></graphics>
<rng model="virtio">
<backend model="random">/dev/urandom</backend>
</rng>
</devices>
</domain>
When I do, I get this error:
# virsh define clara.xml
error: Failed to define domain from clara.xml
error: invalid argument: could not get preferred machine for /usr/libexec/qemu-kvm type=kvm
What does this error mean, and how do I fix it?
Upvotes: 1
Views: 5494
Reputation: 7315
Figured it out. This error happened because of a combination of two problems:
<type>hvm</type>
, and an error happened when trying to discover the "preferred" default value. Setting the arch
and machine
fields revealed the real problem:kvm
is not available in my setup because the host is running in nested virtualization. Changing <domain type="kvm">
to <domain type="qemu">
made it work.If you are doing this in Terraform, you can modify the generated XML file by adding this configuration:
resource "libvirt_domain" "vm" {
# ...
xml {
xslt = <<-EOT
<?xml version="1.0" ?>
<xsl:stylesheet version="1.0"
xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output omit-xml-declaration="yes" indent="yes"/>
<!-- Copy everything from the generated XML -->
<xsl:template match="node()|@*">
<xsl:copy>
<xsl:apply-templates select="node()|@*"/>
</xsl:copy>
</xsl:template>
<!-- Set domain#type to 'qemu' for nested virtualization -->
<xsl:template match="/domain/@type">
<xsl:attribute name="type">
<xsl:value-of select="'qemu'"/>
</xsl:attribute>
</xsl:template>
</xsl:stylesheet>
EOT
}
}
Upvotes: 4