[libvirt] [PATCH v2 2/5] virpcitest: Test virPCIDeviceDetach
Martin Kletzander
mkletzan at redhat.com
Mon Nov 4 15:35:21 UTC 2013
On Thu, Oct 31, 2013 at 11:23:39AM +0000, Michal Privoznik wrote:
> This commit introduces yet another test under virpcitest:
> virPCIDeviceDetach. However, in order to be able to do this, the
> virpcimock needs to be extended to model the kernel behavior on PCI
> device binding and unbinding (create 'driver' symlinks under the device
> tree, check for device ID in driver's ID table, etc.)
>
> Signed-off-by: Michal Privoznik <mprivozn at redhat.com>
> ---
> cfg.mk | 2 +-
> tests/Makefile.am | 10 +-
> tests/virpcimock.c | 603 ++++++++++++++++++++++++++++++++++++++++++++++++++++-
> tests/virpcitest.c | 42 ++++
> 4 files changed, 652 insertions(+), 5 deletions(-)
>
[...]
> diff --git a/tests/virpcimock.c b/tests/virpcimock.c
> index d545361..2adc337 100644
> --- a/tests/virpcimock.c
> +++ b/tests/virpcimock.c
[...]
> +static int
> +pci_driver_handle_unbind(const char *path)
> +{
> + int ret = -1;
> + struct pciDevice *dev = pci_device_find_by_content(path);
> +
> + if (!dev || !dev->driver) {
> + /* This should never happen (TM) */
> + errno = ENODEV;
> + goto cleanup;
> + }
> +
I spoke too soon, this function might check whether the driver is what
the device is really binded to and error out if not.
> + ret = pci_driver_unbind(dev->driver, dev);
than this one can be called only with 'dev'.
But since we are not testing/emulating faulty kernel behaviour, this
is not necesarily needed. However it would be nice to have cleaned up
so it's easier to read for others when adding more tests.
Martin
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 836 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20131104/fe5afe4d/attachment-0001.sig>
More information about the libvir-list
mailing list