mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
virpcitest: Test virPCIDeviceDetach failure
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
This commit is contained in:
parent
b803b29c1a
commit
b70c093ffa
@ -258,6 +258,37 @@ cleanup:
|
|||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static int
|
||||||
|
testVirPCIDeviceDetachFail(const void *opaque)
|
||||||
|
{
|
||||||
|
const struct testPCIDevData *data = opaque;
|
||||||
|
int ret = -1;
|
||||||
|
virPCIDevicePtr dev;
|
||||||
|
|
||||||
|
dev = virPCIDeviceNew(data->domain, data->bus, data->slot, data->function);
|
||||||
|
if (!dev)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
if (virPCIDeviceSetStubDriver(dev, "vfio-pci") < 0)
|
||||||
|
goto cleanup;
|
||||||
|
|
||||||
|
if (virPCIDeviceDetach(dev, NULL, NULL) < 0) {
|
||||||
|
if (virTestGetVerbose() || virTestGetDebug())
|
||||||
|
virDispatchError(NULL);
|
||||||
|
virResetLastError();
|
||||||
|
ret = 0;
|
||||||
|
} else {
|
||||||
|
virReportError(VIR_ERR_INTERNAL_ERROR,
|
||||||
|
"Attaching device %s to %s should have failed",
|
||||||
|
virPCIDeviceGetName(dev),
|
||||||
|
virPCIDeviceGetStubDriver(dev));
|
||||||
|
}
|
||||||
|
|
||||||
|
cleanup:
|
||||||
|
virPCIDeviceFree(dev);
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
static int
|
static int
|
||||||
testVirPCIDeviceReattachSingle(const void *opaque)
|
testVirPCIDeviceReattachSingle(const void *opaque)
|
||||||
{
|
{
|
||||||
@ -390,6 +421,8 @@ mymain(void)
|
|||||||
DO_TEST_PCI(testVirPCIDeviceIsAssignable, 5, 0x90, 1, 0);
|
DO_TEST_PCI(testVirPCIDeviceIsAssignable, 5, 0x90, 1, 0);
|
||||||
DO_TEST_PCI(testVirPCIDeviceIsAssignable, 1, 1, 0, 0);
|
DO_TEST_PCI(testVirPCIDeviceIsAssignable, 1, 1, 0, 0);
|
||||||
|
|
||||||
|
DO_TEST_PCI(testVirPCIDeviceDetachFail, 0, 0x0a, 1, 0);
|
||||||
|
|
||||||
/* Reattach a device already bound to non-stub a driver */
|
/* Reattach a device already bound to non-stub a driver */
|
||||||
DO_TEST_PCI_DRIVER(0, 0x0a, 1, 0, "i915");
|
DO_TEST_PCI_DRIVER(0, 0x0a, 1, 0, "i915");
|
||||||
DO_TEST_PCI(testVirPCIDeviceReattachSingle, 0, 0x0a, 1, 0);
|
DO_TEST_PCI(testVirPCIDeviceReattachSingle, 0, 0x0a, 1, 0);
|
||||||
|
Loading…
Reference in New Issue
Block a user