Skip to content

Instantly share code, notes, and snippets.

@franferrax
Last active June 11, 2025 13:48
Show Gist options
  • Save franferrax/bfd5d047be56a8b4acf033de10295a6b to your computer and use it in GitHub Desktop.
Save franferrax/bfd5d047be56a8b4acf033de10295a6b to your computer and use it in GitHub Desktop.
Passthrough the host BIOS DMI info to a QEMU VM

Passthrough the host BIOS DMI info to a QEMU VM

Step-by-step guide

  1. In the host (real hardware), obtain the data to pass through:
    function DMI {  # Get DMI value and XML-escape it
        sudo sed \
            's/&/\&amp;/g; s/</\&lt;/g; s/>/\&gt;/g; s/"/\&quot;/g; s/'"'"'/\&#39;/g' \
            "/sys/class/dmi/id/$1"
    }
    cat <<EOF && unset -f DMI
      <qemu:commandline>
        <qemu:arg value="-smbios"/>
        <qemu:arg value="type=1,manufacturer=$(DMI sys_vendor),product=$(DMI product_name),\
    version=$(DMI product_version),serial=$(DMI product_serial),uuid=$(DMI product_uuid),\
    sku=$(DMI product_sku),family=$(DMI product_family)"/>
      </qemu:commandline>
    EOF
  2. Open Virtual Machine Manager, go to EditPreferencesGeneral and ensure Enable XML editing is ON
  3. Shut down the VM
  4. Go to the VM Details view (where you can add or remove hardware)
  5. Open the XML tab, and add the following qemu XML namespace to <domain> (if not already present):
    <domain xmlns:qemu="http://libvirt.org/schemas/domain/qemu/1.0" type="kvm">
    <!--    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
                            add this if not present                    -->
  6. Somewhere inside <domain>, paste the output generated at STEP 1, for example:
    <domain xmlns:qemu="http://libvirt.org/schemas/domain/qemu/1.0" type="kvm">
      <name>VM_NAME</name>
      <uuid>VM_UUID</uuid>
      <qemu:commandline>
        <qemu:arg value="-smbios"/>
        <qemu:arg value="type=1,manufacturer=XXXXXXXX,product=XXXXXXXX,version=XXXXXXXX,serial=XXXXXXXX,uuid=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx,sku=XXXXXXXX,family=XXXXXXXX"/>
      </qemu:commandline>
      <!-- Rest of the values [...]  -->
    </domain>
  7. Click Apply and make sure the <qemu:commandline> element isn't deleted (in my case it was moved to the end of the XML)
  8. Power on the VM again

Consulted sources:

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment