[libvirt] CPU compare and baseline

Hi, I try to understand the compare and baseline CPU commands with libvirt. This functions are useful for the migration ? Before migrate a domain to other host, libvirt verifies the CPU compatibility, that's right ? I've got two 64bits hosts, one with an Intel CPU :
*<cpu>*
* **<arch>x86_64</arch>* * **<model>Penryn</model>* * **<vendor>Intel</vendor>* * **<topology sockets='1' cores='2' threads='1'/>* * **<feature name='xtpr'/>* * **<feature name='tm2'/>* * **<feature name='est'/>* * **<feature name='vmx'/>* * **<feature name='ds_cpl'/>* * **<feature name='monitor'/>* * **<feature name='pbe'/>* * **<feature name='tm'/>* * **<feature name='ht'/>* * **<feature name='ss'/>* * **<feature name='acpi'/>* * **<feature name='ds'/>* * **<feature name='vme'/>* *</cpu>* and one with an AMD CPU
*<cpu>*
* **<arch>x86_64</arch>* * **<model>Opteron_G2</model>* * **<vendor>AMD</vendor>* * **<topology sockets='1' cores='2' threads='1'/>* * **<feature name='3dnowprefetch'/>* * **<feature name='cr8legacy'/>* * **<feature name='extapic'/>* * **<feature name='cmp_legacy'/>* * **<feature name='3dnow'/>* * **<feature name='3dnowext'/>* * **<feature name='fxsr_opt'/>* * **<feature name='mmxext'/>* * **<feature name='ht'/>* * **<feature name='vme'/>* *</cpu>* Baseline output : AMD to intel:
*$ virsh cpu-baseline cpu_gargamel.xml *
*<cpu match='exact'>* * <model>Opteron_G2</model>* * <vendor>AMD</vendor>* * <feature policy='require' name='3dnowprefetch'/>* * <feature policy='require' name='cr8legacy'/>* * <feature policy='require' name='extapic'/>* * <feature policy='require' name='cmp_legacy'/>* * <feature policy='require' name='3dnow'/>* * <feature policy='require' name='3dnowext'/>* * <feature policy='require' name='fxsr_opt'/>* * <feature policy='require' name='mmxext'/>* * <feature policy='require' name='ht'/>* * <feature policy='require' name='vme'/>* *</cpu>* Intel to AMD:
*$ virsh cpu-baseline cpu_azrael.xml *
*<cpu match='exact'>* * <model>Penryn</model>* * <vendor>Intel</vendor>* * <feature policy='require' name='xtpr'/>* * <feature policy='require' name='tm2'/>* * <feature policy='require' name='est'/>* * <feature policy='require' name='vmx'/>* * <feature policy='require' name='ds_cpl'/>* * <feature policy='require' name='monitor'/>* * <feature policy='require' name='pbe'/>* * <feature policy='require' name='tm'/>* * <feature policy='require' name='ht'/>* * <feature policy='require' name='ss'/>* * <feature policy='require' name='acpi'/>* * <feature policy='require' name='ds'/>* * <feature policy='require' name='vme'/>* *</cpu>* But if I try to migrate a domain from a host to another, the CPU compare says there are incompatible. I don't understand, I've done live migration manually (*migrate -d tcp: 192.168.1.10:4444*) with KVM and it's works nicely. Why it's not possible trough libvirt ? I use libvirt 0.7.5 with KVM on an Ubuntu LTS 10.04. Regards, Doude.

On Mon, Mar 21, 2011 at 06:34:40PM +0100, Edouard Thuleau wrote:
Hi, I try to understand the compare and baseline CPU commands with libvirt. This functions are useful for the migration ? Before migrate a domain to other host, libvirt verifies the CPU compatibility, that's right ?
I've got two 64bits hosts, one with an Intel CPU :
[snip]
But if I try to migrate a domain from a host to another, the CPU compare says there are incompatible. I don't understand, I've done live migration manually (*migrate -d tcp: 192.168.1.10:4444*) with KVM and it's works nicely. Why it's not possible trough libvirt ?
You have left out the one important piece of information... What is the <cpu> block configured for your *guest* XML. I expect that your guest XML has set an explicit vendor model name, and so libvirt will be refusing to migrate from Intel to AMD even though the flags look compatible. You can use the 'virsh cpu-compare' command, giving it the <cpu> XML from your *guest*, and it will tell you if it is compatible with that host. Daniel -- |: http://berrange.com -o- http://www.flickr.com/photos/dberrange/ :| |: http://libvirt.org -o- http://virt-manager.org :| |: http://autobuild.org -o- http://search.cpan.org/~danberr/ :| |: http://entangle-photo.org -o- http://live.gnome.org/gtk-vnc :|

On Mon, Mar 21, 2011 at 18:34:40 +0100, Edouard Thuleau wrote:
Hi, I try to understand the compare and baseline CPU commands with libvirt. This functions are useful for the migration ? Before migrate a domain to other host, libvirt verifies the CPU compatibility, that's right ? Right.
*$ virsh cpu-baseline cpu_gargamel.xml *
It's not clear what the content of cpu_gargamel.xml is. Does it contain CPU definitions from both hosts? virsh cpu-baseline is supposed to give you an intersection of the CPUs given in the XML file; it doesn't use host CPU on which this command is called. If you take the two host CPUs above, remove <vendor> elements (since CPUs with non-matching vendors are considered incompatible), and pass that to cpu-baseline, you will get the following guest CPU which you can use to be able to migrate between the two hosts: <cpu match='exact'> <model>Opteron_G2</model> <feature policy='require' name='ht'/> <feature policy='require' name='vme'/> <feature policy='disable' name='svm'/> <feature policy='disable' name='rdtscp'/> </cpu> Note, that there is no <vendor> element there since mentioning vendor in guest CPU config means that you always want to run the domain on CPUs from this specific vendor and migrating it to another vendor will fail. Jirka

Thanks for your help. Ok, I didn't understand how to use "cpu-baseline", it's not clear in the help command. So "cpu-baseline" give me the CPU XML file I need to use to be able to migrate between two hosts but how I use this XML file ? Another question, why Libvirt consider CPUs with non-matching vendors cannot be compatible ? Doude. On Tue, Mar 22, 2011 at 3:01 PM, Jiri Denemark <jdenemar@redhat.com> wrote:
On Mon, Mar 21, 2011 at 18:34:40 +0100, Edouard Thuleau wrote:
Hi, I try to understand the compare and baseline CPU commands with libvirt. This functions are useful for the migration ? Before migrate a domain to other host, libvirt verifies the CPU compatibility, that's right ? Right.
*$ virsh cpu-baseline cpu_gargamel.xml *
It's not clear what the content of cpu_gargamel.xml is. Does it contain CPU definitions from both hosts? virsh cpu-baseline is supposed to give you an intersection of the CPUs given in the XML file; it doesn't use host CPU on which this command is called.
If you take the two host CPUs above, remove <vendor> elements (since CPUs with non-matching vendors are considered incompatible), and pass that to cpu-baseline, you will get the following guest CPU which you can use to be able to migrate between the two hosts:
<cpu match='exact'> <model>Opteron_G2</model> <feature policy='require' name='ht'/> <feature policy='require' name='vme'/> <feature policy='disable' name='svm'/> <feature policy='disable' name='rdtscp'/> </cpu>
Note, that there is no <vendor> element there since mentioning vendor in guest CPU config means that you always want to run the domain on CPUs from this specific vendor and migrating it to another vendor will fail.
Jirka
-- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list

Ok, I didn't understand how to use "cpu-baseline", it's not clear in the help command. So "cpu-baseline" give me the CPU XML file I need to use to be able to migrate between two hosts but how I use this XML file ?
You can just stick the output of cpu-baseline to guest's XML file, so you could have something like the following: <domain type='kvm'> <name>domain-name</name> <memory>262144</memory> <currentMemory>262144</currentMemory> <vcpu>2</vcpu> <os> <type arch='x86_64' machine='pc-0.12'>hvm</type> <boot dev='cdrom'/> </os> <cpu match='exact'> <model>Opteron_G2</model> <feature policy='require' name='ht'/> <feature policy='require' name='vme'/> <feature policy='disable' name='svm'/> <feature policy='disable' name='rdtscp'/> </cpu> ... </domain>
Another question, why Libvirt consider CPUs with non-matching vendors cannot be compatible ?
That's because CPUs made by different vendors are not generally compatible. Migration between them may work but it's not guaranteed. Libvirt allows you to choose whether you want to stick with a single CPU vendor or not. If you put <vendor> tag into the <cpu> element above, libvirt will forbid migration to a CPU made by a different vendor. If no <vendor> tag is present, CPU vendor is not checked during migration. Jirka
participants (3)
-
Daniel P. Berrange
-
Edouard Thuleau
-
Jiri Denemark