[libvirt] [PATCHv2 8/8] qemu: process: Validate specific CPUID flags of a guest

Daniel P. Berrange berrange at redhat.com
Wed Oct 30 15:42:51 UTC 2013


On Thu, Oct 17, 2013 at 03:10:22PM +0200, Peter Krempa wrote:

> +static bool
> +qemuProcessVerifyGuestCPU(virQEMUDriverPtr driver, virDomainObjPtr vm)
> +{
> +    virDomainDefPtr def = vm->def;
> +    virArch arch = def->os.arch;
> +    virCPUDataPtr guestcpu = NULL;
> +    qemuDomainObjPrivatePtr priv = vm->privateData;
> +    bool ret = false;
> +    int rc;
> +
> +    qemuDomainObjEnterMonitor(driver, vm);
> +    rc = qemuMonitorGetGuestCPU(priv->mon, arch, &guestcpu);
> +    qemuDomainObjExitMonitor(driver, vm);
> +
> +    if (rc < 0) {
> +        if (rc == -2) {
> +            virResetLastError();
> +            return true;
> +        }
> +
> +        goto cleanup;
> +    }
> +
> +    switch (arch) {
> +    case VIR_ARCH_I686:
> +    case VIR_ARCH_X86_64:
> +        if (def->features[VIR_DOMAIN_FEATURE_PVSPINLOCK] == VIR_DOMAIN_FEATURE_STATE_ON) {
> +            if (!cpuHasFeature(guestcpu, VIR_CPU_x86_KVM_PV_UNHALT)) {
> +                virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
> +                               _("host doesn't support paravirtual spinlocks"));
> +                goto cleanup;
> +            }
> +        }
> +        break;
> +
> +    default:
> +        break;
> +    }

If you move the qemuMonitorGetGuestCPU call into this switch() case for
x86, then you avoid the need to have the special -2 error case, and avoid
resetting an already reported error message (which will have spammed the
logs)

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 :|




More information about the libvir-list mailing list