appliance: Use -cpu max.

QEMU has a newish feature (from about 2017 / qemu 2.9) called -cpu max
which is supposed to select the best CPU, ideal for libguestfs.

After this change, on x86-64:

               KVM                          TCG

Direct         -cpu max                     -cpu max
(non-libvirt)

Libvirt   <cpu mode="host-passthrough">     <cpu mode="host-model">
            <model fallback="allow"/>         <model fallback="allow"/>
          </cpu>                            </cpu>

Thanks: Daniel Berrangé
This commit is contained in:
Richard W.M. Jones
2021-01-28 12:20:49 +00:00
parent 7ac82beb89
commit 30f74f38bd
2 changed files with 17 additions and 8 deletions

View File

@@ -1169,6 +1169,15 @@ construct_libvirt_xml_cpu (guestfs_h *g,
attribute ("fallback", "allow");
} end_element ();
}
else if (STREQ (cpu_model, "max")) {
if (params->data->is_kvm)
attribute ("mode", "host-passthrough");
else
attribute ("mode", "host-model");
start_element ("model") {
attribute ("fallback", "allow");
} end_element ();
}
else
single_element ("model", cpu_model);
} end_element ();