[libvirt] Is seems necessary to pass "migratable=no/yes" to qemu.

zhang bo oscar.zhangbo at huawei.com
Wed Sep 24 03:28:06 UTC 2014


The patch
http://libvirt.org/git/?p=libvirt.git;a=commitdiff;h=de0aeafe9ce3eb414c8b5d3aa8995d776a2952de
removes invtsc flag in the host-model CPU.

I'm wondering, will it be better to pass args "migratable=no/yes" to qemu, and let qemu complete the
remaining work? As that qemu has checked whether it's necessary to use invtsc or not.
----------
"invtsc is available only if using: -cpu host,migratable=no,+invtsc."
http://git.qemu.org/?p=qemu.git;a=commit;h=120eee7d1fdb2eba15766cfff7b9bcdc902690b4
----------

There's another problem, if we do not pass "migratable=no" to qemu.
Consider if we set host mode to pass-through
   ---------
      <cpu mode='host-passthrough'>
      </cpu>
   ---------
then the vm->def->cpu->features contains invtsc. however, qemu will automatically remove this cpu flag
as that "migration=no" is not passed to it. thus, the guest will not start up. This problem is in fact
caused by the patch:
http://libvirt.org/git/?p=libvirt.git;a=commit;h=fba6bc47cbcabbe08d42279691efb0dff3b9c997,
it forbids guest domain to start up if the host has INVTSC while the guest(qemu) does not.
   -------------
        for (i = 0; def->cpu && i < def->cpu->nfeatures; i++) {
            virCPUFeatureDefPtr feature = &def->cpu->features[i];

            if (feature->policy != VIR_CPU_FEATURE_REQUIRE)
                continue;

            if (STREQ(feature->name, "invtsc") &&
                !cpuHasFeature(guestcpu, feature->name)) {
                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
                               _("host doesn't support invariant TSC"));
                goto cleanup;
            }
        }
        break;
   --------------


In conclusion:
1 Will it better to pass args "migratable=yes/no" to qemu rather than doing the mask-invtsc job in libvirt?
2 If the guest has "pass-through" cpu mode, then it's unable to start up, because qemu removes invtsc, and
vm->def->cpu->features has it. It seems a BUG.














More information about the libvir-list mailing list