virReportError(VIR_ERR_INTERNAL_ERROR, \
"Unexpected count of items in " #list ": %zu, " \
"expecting %zu", actualCount, (size_t) cnt); \
- goto cleanup; \
+ return -1; \
} \
} while (0)
static int
testVirHostdevPreparePCIHostdevs_unmanaged(void)
{
- int ret = -1;
size_t active_count, inactive_count, i;
for (i = 0; i < nhostdevs; i++)
VIR_DEBUG("Test 0 hostdevs");
if (virHostdevPreparePCIDevices(mgr, drv_name, dom_name, uuid,
NULL, 0, 0) < 0)
- goto cleanup;
+ return -1;
CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, active_count);
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count);
VIR_DEBUG("Test >=1 unmanaged hostdevs");
if (virHostdevPreparePCIDevices(mgr, drv_name, dom_name, uuid,
hostdevs, nhostdevs, 0) < 0)
- goto cleanup;
+ return -1;
CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, active_count + nhostdevs);
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count - nhostdevs);
VIR_DEBUG("Test: prepare same hostdevs for same driver/domain again");
if (virHostdevPreparePCIDevices(mgr, drv_name, dom_name, uuid,
&hostdevs[0], 1, 0) == 0)
- goto cleanup;
+ return -1;
CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, active_count);
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count);
VIR_DEBUG("Test: prepare same hostdevs for same driver, diff domain again");
if (virHostdevPreparePCIDevices(mgr, drv_name, "test_domain1", uuid,
&hostdevs[1], 1, 0) == 0)
- goto cleanup;
+ return -1;
CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, active_count);
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count);
VIR_DEBUG("Test: prepare same hostdevs for diff driver/domain again");
if (virHostdevPreparePCIDevices(mgr, "test_driver1", dom_name, uuid,
&hostdevs[2], 1, 0) == 0)
- goto cleanup;
+ return -1;
CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, active_count);
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count);
- ret = 0;
-
- cleanup:
- return ret;
-
+ return 0;
}
static int
testVirHostdevReAttachPCIHostdevs_unmanaged(void)
{
- int ret = -1;
size_t active_count, inactive_count, i;
for (i = 0; i < nhostdevs; i++) {
CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, active_count - nhostdevs);
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count + nhostdevs);
- ret = 0;
-
- cleanup:
- return ret;
-
+ return 0;
}
static int
testVirHostdevPreparePCIHostdevs_managed(bool mixed)
{
- int ret = -1;
size_t active_count, inactive_count, i;
for (i = 0; i < nhostdevs; i++)
VIR_DEBUG("Test >=1 hostdevs");
if (virHostdevPreparePCIDevices(mgr, drv_name, dom_name, uuid,
hostdevs, nhostdevs, 0) < 0)
- goto cleanup;
+ return -1;
CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, active_count + nhostdevs);
/* If testing a mixed roundtrip, devices are already in the inactive list
* before we start and are removed from it as soon as we attach them to
VIR_DEBUG("Test: prepare same hostdevs for same driver/domain again");
if (virHostdevPreparePCIDevices(mgr, drv_name, dom_name, uuid,
&hostdevs[0], 1, 0) == 0)
- goto cleanup;
+ return -1;
CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, active_count);
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count);
VIR_DEBUG("Test: prepare same hostdevs for same driver, diff domain again");
if (virHostdevPreparePCIDevices(mgr, drv_name, "test_domain1", uuid,
&hostdevs[1], 1, 0) == 0)
- goto cleanup;
+ return -1;
CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, active_count);
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count);
VIR_DEBUG("Test: prepare same hostdevs for diff driver/domain again");
if (virHostdevPreparePCIDevices(mgr, "test_driver1", dom_name, uuid,
&hostdevs[2], 1, 0) == 0)
- goto cleanup;
+ return -1;
CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, active_count);
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count);
- ret = 0;
-
- cleanup:
- return ret;
-
+ return 0;
}
static int
testVirHostdevReAttachPCIHostdevs_managed(bool mixed)
{
- int ret = -1;
size_t active_count, inactive_count, i;
for (i = 0; i < nhostdevs; i++) {
else
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count);
- ret = 0;
-
- cleanup:
- return ret;
-
+ return 0;
}
static int
testVirHostdevDetachPCINodeDevice(void)
{
- int ret = -1;
size_t active_count, inactive_count, i;
for (i = 0; i < nhostdevs; i++) {
active_count = virPCIDeviceListCount(mgr->activePCIHostdevs);
inactive_count = virPCIDeviceListCount(mgr->inactivePCIHostdevs);
if (virHostdevPCINodeDeviceDetach(mgr, dev[i]) < 0)
- goto cleanup;
+ return -1;
CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, active_count);
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count + 1);
}
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
static int
testVirHostdevResetPCINodeDevice(void)
{
- int ret = -1;
size_t active_count, inactive_count, i;
for (i = 0; i < nhostdevs; i++) {
active_count = virPCIDeviceListCount(mgr->activePCIHostdevs);
inactive_count = virPCIDeviceListCount(mgr->inactivePCIHostdevs);
if (virHostdevPCINodeDeviceReset(mgr, dev[i]) < 0)
- goto cleanup;
+ return -1;
CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, active_count);
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count);
}
- ret = 0;
-
- cleanup:
- return ret;
-
+ return 0;
}
static int
testVirHostdevReAttachPCINodeDevice(void)
{
- int ret = -1;
size_t active_count, inactive_count, i;
for (i = 0; i < nhostdevs; i++) {
active_count = virPCIDeviceListCount(mgr->activePCIHostdevs);
inactive_count = virPCIDeviceListCount(mgr->inactivePCIHostdevs);
if (virHostdevPCINodeDeviceReAttach(mgr, dev[i]) < 0)
- goto cleanup;
+ return -1;
CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, active_count);
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count - 1);
}
- ret = 0;
-
- cleanup:
- return ret;
-
+ return 0;
}
static int
testVirHostdevUpdateActivePCIHostdevs(void)
{
- int ret = -1;
size_t active_count, inactive_count;
active_count = virPCIDeviceListCount(mgr->activePCIHostdevs);
VIR_DEBUG("Test 0 hostdevs");
if (virHostdevUpdateActivePCIDevices(mgr, NULL, 0,
drv_name, dom_name) < 0)
- goto cleanup;
+ return -1;
CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, active_count);
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count);
VIR_DEBUG("Test >=1 hostdevs");
if (virHostdevUpdateActivePCIDevices(mgr, hostdevs, nhostdevs,
drv_name, dom_name) < 0)
- goto cleanup;
+ return -1;
CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, active_count + nhostdevs);
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count);
- ret = 0;
-
- cleanup:
- return ret;
+ return 0;
}
/**
static int
testVirHostdevRoundtripNoGuest(const void *opaque ATTRIBUTE_UNUSED)
{
- int ret = -1;
-
if (testVirHostdevDetachPCINodeDevice() < 0)
- goto out;
+ return -1;
if (testVirHostdevReAttachPCINodeDevice() < 0)
- goto out;
-
- ret = 0;
+ return -1;
- out:
- return ret;
+ return 0;
}
/**
static int
testVirHostdevRoundtripUnmanaged(const void *opaque ATTRIBUTE_UNUSED)
{
- int ret = -1;
-
if (testVirHostdevDetachPCINodeDevice() < 0)
- goto out;
+ return -1;
if (testVirHostdevPreparePCIHostdevs_unmanaged() < 0)
- goto out;
+ return -1;
if (testVirHostdevReAttachPCIHostdevs_unmanaged() < 0)
- goto out;
+ return -1;
if (testVirHostdevReAttachPCINodeDevice() < 0)
- goto out;
+ return -1;
- ret = 0;
-
- out:
- return ret;
+ return 0;
}
/**
static int
testVirHostdevRoundtripManaged(const void *opaque ATTRIBUTE_UNUSED)
{
- int ret = -1;
-
if (testVirHostdevPreparePCIHostdevs_managed(false) < 0)
- goto out;
+ return -1;
if (testVirHostdevReAttachPCIHostdevs_managed(false) < 0)
- goto out;
-
- ret = 0;
+ return -1;
- out:
- return ret;
+ return 0;
}
/**
static int
testVirHostdevRoundtripMixed(const void *opaque ATTRIBUTE_UNUSED)
{
- int ret = -1;
-
if (testVirHostdevDetachPCINodeDevice() < 0)
- goto out;
+ return -1;
if (testVirHostdevPreparePCIHostdevs_managed(true) < 0)
- goto out;
+ return -1;
if (testVirHostdevReAttachPCIHostdevs_managed(true) < 0)
- goto out;
+ return -1;
if (testVirHostdevReAttachPCINodeDevice() < 0)
- goto out;
+ return -1;
- ret = 0;
-
- out:
- return ret;
+ return 0;
}
/**
static int
testVirHostdevOther(const void *opaque ATTRIBUTE_UNUSED)
{
- int ret = -1;
-
if (testVirHostdevResetPCINodeDevice() < 0)
- goto out;
+ return -1;
if (testVirHostdevUpdateActivePCIHostdevs() < 0)
- goto out;
-
- ret = 0;
+ return -1;
- out:
- return ret;
+ return 0;
}
# define FAKEROOTDIRTEMPLATE abs_builddir "/fakerootdir-XXXXXX"