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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list




[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]