Re: [libvirt] PATCH: Don't reset / detach host PCI devices in test scripts !

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

 



Daniel P. Berrange wrote:
> The PCI passthrough patches made it so that qemudBuildCommandLine() would
> actually try to detach your host devices & reset them. Most definitely not
> what you want when running this via a test case!
>
> This patch moves the host device management out into a separate method,
> so that qemudBuildCommandLine() doesn't do anything except safely build
> the command line.

Ah.  This fixes the failure I just reported.
Looks good.

> +    /* Now that all the PCI hostdevs have be dettached, we can safely

Obviously this is just "moved" code, but might as well fix the comment:
s/be/been/

> +     * reset them */
> +    for (i = 0 ; i < def->nhostdevs ; i++) {
> +        virDomainHostdevDefPtr hostdev = def->hostdevs[i];
> +        pciDevice *dev;
> +
> +        if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS)
> +            continue;
> +        if (hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI)
> +            continue;
> +
> +        dev = pciGetDevice(conn,
> +                           hostdev->source.subsys.u.pci.domain,
> +                           hostdev->source.subsys.u.pci.bus,
> +                           hostdev->source.subsys.u.pci.slot,
> +                           hostdev->source.subsys.u.pci.function);
> +        if (!dev)
> +            goto error;
> +
> +        if (pciResetDevice(conn, dev) < 0) {
> +            pciFreeDevice(conn, dev);
> +            goto error;
> +        }
> +
> +        pciFreeDevice(conn, dev);

You can remove a duplicate free and save two lines
by replacing the above with this:

           int err = pciResetDevice(conn, dev);
           pciFreeDevice(conn, dev);
           if (err < 0)
               goto error;

> +    }
> +
> +    return 0;
> +
> +error:
> +    return -1;
> +}

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