2014-03-06 16:08:36 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
2016-04-06 21:46:49 +08:00
|
|
|
* Copyright (C) 2014-2016 Red Hat, Inc.
|
2014-03-06 16:08:36 +08:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library. If not, see
|
|
|
|
* <http://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#include "testutils.h"
|
|
|
|
|
|
|
|
#ifdef __linux__
|
|
|
|
|
|
|
|
# include <sys/types.h>
|
|
|
|
# include <sys/stat.h>
|
|
|
|
# include <sys/ioctl.h>
|
|
|
|
# include <fcntl.h>
|
|
|
|
# include "virlog.h"
|
|
|
|
# include "virhostdev.h"
|
|
|
|
|
|
|
|
# define VIR_FROM_THIS VIR_FROM_NONE
|
|
|
|
|
2014-02-28 20:16:17 +08:00
|
|
|
VIR_LOG_INIT("tests.hostdevtest");
|
|
|
|
|
2019-06-14 20:30:13 +08:00
|
|
|
# define CHECK_LIST_COUNT(list, cnt, cb) \
|
2017-11-03 20:09:47 +08:00
|
|
|
do { \
|
|
|
|
size_t actualCount; \
|
2019-06-14 20:30:13 +08:00
|
|
|
if ((actualCount = cb(list)) != cnt) { \
|
2017-11-03 20:09:47 +08:00
|
|
|
virReportError(VIR_ERR_INTERNAL_ERROR, \
|
|
|
|
"Unexpected count of items in " #list ": %zu, " \
|
|
|
|
"expecting %zu", actualCount, (size_t) cnt); \
|
2019-08-27 22:00:55 +08:00
|
|
|
return -1; \
|
2017-11-03 20:09:47 +08:00
|
|
|
} \
|
2016-03-02 22:23:51 +08:00
|
|
|
} while (0)
|
2014-03-06 16:08:36 +08:00
|
|
|
|
2019-06-14 20:30:13 +08:00
|
|
|
# define CHECK_PCI_LIST_COUNT(list, cnt) \
|
|
|
|
CHECK_LIST_COUNT(list, cnt, virPCIDeviceListCount)
|
|
|
|
|
2019-06-13 15:41:15 +08:00
|
|
|
# define CHECK_NVME_LIST_COUNT(list, cnt) \
|
|
|
|
CHECK_LIST_COUNT(list, cnt, virNVMeDeviceListCount)
|
|
|
|
|
2014-03-06 16:08:36 +08:00
|
|
|
# define TEST_STATE_DIR abs_builddir "/hostdevmgr"
|
|
|
|
static const char *drv_name = "test_driver";
|
|
|
|
static const char *dom_name = "test_domain";
|
|
|
|
static const unsigned char *uuid =
|
|
|
|
(unsigned char *)("f92360b0-2541-8791-fb32-d1f838811541");
|
|
|
|
static int nhostdevs = 3;
|
|
|
|
static virDomainHostdevDefPtr hostdevs[] = {NULL, NULL, NULL};
|
|
|
|
static virPCIDevicePtr dev[] = {NULL, NULL, NULL};
|
2014-10-29 02:38:04 +08:00
|
|
|
static virHostdevManagerPtr mgr;
|
2019-06-13 15:41:15 +08:00
|
|
|
static const size_t ndisks = 3;
|
|
|
|
static virDomainDiskDefPtr disks[] = {NULL, NULL, NULL};
|
|
|
|
static const char *diskXML[] = {
|
|
|
|
"<disk type='nvme' device='disk'>"
|
|
|
|
" <driver name='qemu' type='raw'/>"
|
|
|
|
" <source type='pci' managed='yes' namespace='1'>"
|
|
|
|
" <address domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>"
|
|
|
|
" </source>"
|
|
|
|
" <target dev='vda' bus='virtio'/>"
|
|
|
|
" <address type='pci' domain='0x0000' bus='0x00' slot='0x04' function='0x0'/>"
|
|
|
|
"</disk>",
|
|
|
|
|
|
|
|
"<disk type='nvme' device='disk'>"
|
|
|
|
" <driver name='qemu' type='raw'/>"
|
|
|
|
" <source type='pci' managed='yes' namespace='2'>"
|
|
|
|
" <address domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>"
|
|
|
|
" </source>"
|
|
|
|
" <target dev='vdb' bus='virtio'/>"
|
|
|
|
" <address type='pci' domain='0x0000' bus='0x00' slot='0x05' function='0x0'/>"
|
|
|
|
"</disk>",
|
|
|
|
|
|
|
|
"<disk type='nvme' device='disk'>"
|
|
|
|
" <driver name='qemu' type='raw'/>"
|
|
|
|
" <source type='pci' managed='no' namespace='1'>"
|
|
|
|
" <address domain='0x0000' bus='0x02' slot='0x00' function='0x0'/>"
|
|
|
|
" </source>"
|
|
|
|
" <target dev='vdc' bus='virtio'/>"
|
|
|
|
" <address type='pci' domain='0x0000' bus='0x00' slot='0x06' function='0x0'/>"
|
|
|
|
"</disk>"
|
|
|
|
};
|
2014-03-06 16:08:36 +08:00
|
|
|
|
|
|
|
static void
|
|
|
|
myCleanup(void)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
for (i = 0; i < nhostdevs; i++) {
|
|
|
|
virPCIDeviceFree(dev[i]);
|
|
|
|
virDomainHostdevDefFree(hostdevs[i]);
|
|
|
|
}
|
|
|
|
|
2019-06-13 15:41:15 +08:00
|
|
|
for (i = 0; i < ndisks; i++)
|
|
|
|
virDomainDiskDefFree(disks[i]);
|
|
|
|
|
2014-03-06 16:08:36 +08:00
|
|
|
if (mgr) {
|
2015-09-16 04:33:36 +08:00
|
|
|
if (!getenv("LIBVIRT_SKIP_CLEANUP"))
|
2014-04-28 21:34:52 +08:00
|
|
|
virFileDeleteTree(mgr->stateDir);
|
|
|
|
|
2014-03-06 16:08:36 +08:00
|
|
|
virObjectUnref(mgr->activePCIHostdevs);
|
|
|
|
virObjectUnref(mgr->activeUSBHostdevs);
|
2017-08-10 15:14:36 +08:00
|
|
|
virObjectUnref(mgr->inactivePCIHostdevs);
|
|
|
|
virObjectUnref(mgr->activeSCSIHostdevs);
|
2019-06-13 15:41:15 +08:00
|
|
|
virObjectUnref(mgr->activeNVMeHostdevs);
|
2014-03-06 16:08:36 +08:00
|
|
|
VIR_FREE(mgr->stateDir);
|
|
|
|
VIR_FREE(mgr);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
myInit(void)
|
|
|
|
{
|
|
|
|
size_t i;
|
|
|
|
|
|
|
|
for (i = 0; i < nhostdevs; i++) {
|
|
|
|
virDomainHostdevSubsys subsys;
|
2017-09-23 19:03:50 +08:00
|
|
|
hostdevs[i] = virDomainHostdevDefNew();
|
2014-03-06 16:08:36 +08:00
|
|
|
if (!hostdevs[i])
|
|
|
|
goto cleanup;
|
|
|
|
hostdevs[i]->mode = VIR_DOMAIN_HOSTDEV_MODE_SUBSYS;
|
|
|
|
subsys.type = VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI;
|
|
|
|
subsys.u.pci.addr.domain = 0;
|
|
|
|
subsys.u.pci.addr.bus = 0;
|
|
|
|
subsys.u.pci.addr.slot = i + 1;
|
|
|
|
subsys.u.pci.addr.function = 0;
|
2019-08-12 23:25:57 +08:00
|
|
|
subsys.u.pci.backend = VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO;
|
2014-03-06 16:08:36 +08:00
|
|
|
hostdevs[i]->source.subsys = subsys;
|
|
|
|
}
|
|
|
|
|
|
|
|
for (i = 0; i < nhostdevs; i++) {
|
2015-10-23 17:54:07 +08:00
|
|
|
if (!(dev[i] = virPCIDeviceNew(0, 0, i + 1, 0)))
|
2014-03-06 16:08:36 +08:00
|
|
|
goto cleanup;
|
2015-10-23 17:54:07 +08:00
|
|
|
|
2019-08-12 23:25:57 +08:00
|
|
|
virPCIDeviceSetStubDriver(dev[i], VIR_PCI_STUB_DRIVER_VFIO);
|
2014-03-06 16:08:36 +08:00
|
|
|
}
|
|
|
|
|
2019-06-13 15:41:15 +08:00
|
|
|
for (i = 0; i < ndisks; i++) {
|
|
|
|
if (!(disks[i] = virDomainDiskDefParse(diskXML[i], NULL, 0)))
|
|
|
|
goto cleanup;
|
|
|
|
}
|
|
|
|
|
2014-03-06 16:08:36 +08:00
|
|
|
if (VIR_ALLOC(mgr) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
if ((mgr->activePCIHostdevs = virPCIDeviceListNew()) == NULL)
|
|
|
|
goto cleanup;
|
|
|
|
if ((mgr->activeUSBHostdevs = virUSBDeviceListNew()) == NULL)
|
|
|
|
goto cleanup;
|
|
|
|
if ((mgr->inactivePCIHostdevs = virPCIDeviceListNew()) == NULL)
|
|
|
|
goto cleanup;
|
|
|
|
if ((mgr->activeSCSIHostdevs = virSCSIDeviceListNew()) == NULL)
|
|
|
|
goto cleanup;
|
2019-06-13 15:41:15 +08:00
|
|
|
if ((mgr->activeNVMeHostdevs = virNVMeDeviceListNew()) == NULL)
|
|
|
|
goto cleanup;
|
2019-10-20 19:49:46 +08:00
|
|
|
mgr->stateDir = g_strdup(TEST_STATE_DIR);
|
2014-03-06 16:08:36 +08:00
|
|
|
if (virFileMakePath(mgr->stateDir) < 0)
|
|
|
|
goto cleanup;
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
|
2014-03-25 14:53:44 +08:00
|
|
|
cleanup:
|
2014-03-06 16:08:36 +08:00
|
|
|
myCleanup();
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2016-03-03 23:13:04 +08:00
|
|
|
testVirHostdevPreparePCIHostdevs_unmanaged(void)
|
2014-03-06 16:08:36 +08:00
|
|
|
{
|
2016-03-02 22:27:06 +08:00
|
|
|
size_t active_count, inactive_count, i;
|
2014-03-06 16:08:36 +08:00
|
|
|
|
|
|
|
for (i = 0; i < nhostdevs; i++)
|
|
|
|
hostdevs[i]->managed = false;
|
|
|
|
|
2016-03-02 22:15:07 +08:00
|
|
|
active_count = virPCIDeviceListCount(mgr->activePCIHostdevs);
|
|
|
|
inactive_count = virPCIDeviceListCount(mgr->inactivePCIHostdevs);
|
2014-03-06 16:08:36 +08:00
|
|
|
|
|
|
|
/* Test normal functionality */
|
2019-08-27 22:07:36 +08:00
|
|
|
VIR_TEST_DEBUG("Test 0 hostdevs");
|
2014-03-06 16:08:36 +08:00
|
|
|
if (virHostdevPreparePCIDevices(mgr, drv_name, dom_name, uuid,
|
|
|
|
NULL, 0, 0) < 0)
|
2019-08-27 22:00:55 +08:00
|
|
|
return -1;
|
2019-06-14 20:30:13 +08:00
|
|
|
CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, active_count);
|
|
|
|
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count);
|
2014-03-06 16:08:36 +08:00
|
|
|
|
|
|
|
/* Test unmanaged hostdevs */
|
2019-08-27 22:07:36 +08:00
|
|
|
VIR_TEST_DEBUG("Test >=1 unmanaged hostdevs");
|
2014-03-06 16:08:36 +08:00
|
|
|
if (virHostdevPreparePCIDevices(mgr, drv_name, dom_name, uuid,
|
|
|
|
hostdevs, nhostdevs, 0) < 0)
|
2019-08-27 22:00:55 +08:00
|
|
|
return -1;
|
2019-06-14 20:30:13 +08:00
|
|
|
CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, active_count + nhostdevs);
|
|
|
|
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count - nhostdevs);
|
2014-03-06 16:08:36 +08:00
|
|
|
|
|
|
|
/* Test conflict */
|
2016-03-02 22:15:07 +08:00
|
|
|
active_count = virPCIDeviceListCount(mgr->activePCIHostdevs);
|
|
|
|
inactive_count = virPCIDeviceListCount(mgr->inactivePCIHostdevs);
|
2019-08-27 22:07:36 +08:00
|
|
|
VIR_TEST_DEBUG("Test: prepare same hostdevs for same driver/domain again");
|
2019-08-27 22:00:10 +08:00
|
|
|
if (virHostdevPreparePCIDevices(mgr, drv_name, dom_name, uuid,
|
|
|
|
&hostdevs[0], 1, 0) == 0)
|
2019-08-27 22:00:55 +08:00
|
|
|
return -1;
|
2019-08-27 22:08:12 +08:00
|
|
|
virResetLastError();
|
2019-06-14 20:30:13 +08:00
|
|
|
CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, active_count);
|
|
|
|
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count);
|
2014-03-06 16:08:36 +08:00
|
|
|
|
2019-08-27 22:07:36 +08:00
|
|
|
VIR_TEST_DEBUG("Test: prepare same hostdevs for same driver, diff domain again");
|
2019-08-27 22:00:10 +08:00
|
|
|
if (virHostdevPreparePCIDevices(mgr, drv_name, "test_domain1", uuid,
|
|
|
|
&hostdevs[1], 1, 0) == 0)
|
2019-08-27 22:00:55 +08:00
|
|
|
return -1;
|
2019-08-27 22:08:12 +08:00
|
|
|
virResetLastError();
|
2019-06-14 20:30:13 +08:00
|
|
|
CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, active_count);
|
|
|
|
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count);
|
2014-03-06 16:08:36 +08:00
|
|
|
|
2019-08-27 22:07:36 +08:00
|
|
|
VIR_TEST_DEBUG("Test: prepare same hostdevs for diff driver/domain again");
|
2019-08-27 22:00:10 +08:00
|
|
|
if (virHostdevPreparePCIDevices(mgr, "test_driver1", dom_name, uuid,
|
|
|
|
&hostdevs[2], 1, 0) == 0)
|
2019-08-27 22:00:55 +08:00
|
|
|
return -1;
|
2019-08-27 22:08:12 +08:00
|
|
|
virResetLastError();
|
2019-06-14 20:30:13 +08:00
|
|
|
CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, active_count);
|
|
|
|
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count);
|
2014-03-06 16:08:36 +08:00
|
|
|
|
2019-08-27 22:00:55 +08:00
|
|
|
return 0;
|
2014-03-06 16:08:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2016-03-03 23:13:04 +08:00
|
|
|
testVirHostdevReAttachPCIHostdevs_unmanaged(void)
|
2014-03-06 16:08:36 +08:00
|
|
|
{
|
2016-03-02 22:27:06 +08:00
|
|
|
size_t active_count, inactive_count, i;
|
2014-03-06 16:08:36 +08:00
|
|
|
|
|
|
|
for (i = 0; i < nhostdevs; i++) {
|
|
|
|
if (hostdevs[i]->managed != false) {
|
2019-08-27 22:07:36 +08:00
|
|
|
VIR_TEST_DEBUG("invalid test");
|
2014-03-06 16:08:36 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-02 22:15:07 +08:00
|
|
|
active_count = virPCIDeviceListCount(mgr->activePCIHostdevs);
|
|
|
|
inactive_count = virPCIDeviceListCount(mgr->inactivePCIHostdevs);
|
2014-03-06 16:08:36 +08:00
|
|
|
|
2019-08-27 22:07:36 +08:00
|
|
|
VIR_TEST_DEBUG("Test 0 hostdevs");
|
2014-03-06 16:08:36 +08:00
|
|
|
virHostdevReAttachPCIDevices(mgr, drv_name, dom_name, NULL, 0, NULL);
|
2019-06-14 20:30:13 +08:00
|
|
|
CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, active_count);
|
|
|
|
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count);
|
2014-03-06 16:08:36 +08:00
|
|
|
|
2019-08-27 22:07:36 +08:00
|
|
|
VIR_TEST_DEBUG("Test >=1 unmanaged hostdevs");
|
2014-03-06 16:08:36 +08:00
|
|
|
virHostdevReAttachPCIDevices(mgr, drv_name, dom_name,
|
|
|
|
hostdevs, nhostdevs, NULL);
|
2019-06-14 20:30:13 +08:00
|
|
|
CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, active_count - nhostdevs);
|
|
|
|
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count + nhostdevs);
|
2014-03-06 16:08:36 +08:00
|
|
|
|
2019-08-27 22:00:55 +08:00
|
|
|
return 0;
|
2014-03-06 16:08:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2016-03-19 01:03:53 +08:00
|
|
|
testVirHostdevPreparePCIHostdevs_managed(bool mixed)
|
2014-03-06 16:08:36 +08:00
|
|
|
{
|
2016-03-02 22:33:18 +08:00
|
|
|
size_t active_count, inactive_count, i;
|
2014-03-06 16:08:36 +08:00
|
|
|
|
|
|
|
for (i = 0; i < nhostdevs; i++)
|
|
|
|
hostdevs[i]->managed = true;
|
|
|
|
|
2016-03-02 22:15:07 +08:00
|
|
|
active_count = virPCIDeviceListCount(mgr->activePCIHostdevs);
|
2016-03-02 22:33:18 +08:00
|
|
|
inactive_count = virPCIDeviceListCount(mgr->inactivePCIHostdevs);
|
2014-03-06 16:08:36 +08:00
|
|
|
|
|
|
|
/* Test normal functionality */
|
2019-08-27 22:07:36 +08:00
|
|
|
VIR_TEST_DEBUG("Test >=1 hostdevs");
|
2014-03-06 16:08:36 +08:00
|
|
|
if (virHostdevPreparePCIDevices(mgr, drv_name, dom_name, uuid,
|
|
|
|
hostdevs, nhostdevs, 0) < 0)
|
2019-08-27 22:00:55 +08:00
|
|
|
return -1;
|
2019-06-14 20:30:13 +08:00
|
|
|
CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, active_count + nhostdevs);
|
2016-03-19 01:03:53 +08:00
|
|
|
/* 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
|
|
|
|
* the guest */
|
|
|
|
if (mixed)
|
2019-06-14 20:30:13 +08:00
|
|
|
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count - nhostdevs);
|
2016-03-19 01:03:53 +08:00
|
|
|
else
|
2019-06-14 20:30:13 +08:00
|
|
|
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count);
|
2014-03-06 16:08:36 +08:00
|
|
|
|
|
|
|
/* Test conflict */
|
2016-03-02 22:15:07 +08:00
|
|
|
active_count = virPCIDeviceListCount(mgr->activePCIHostdevs);
|
2016-03-02 22:33:18 +08:00
|
|
|
inactive_count = virPCIDeviceListCount(mgr->inactivePCIHostdevs);
|
2019-08-27 22:07:36 +08:00
|
|
|
VIR_TEST_DEBUG("Test: prepare same hostdevs for same driver/domain again");
|
2019-08-27 22:00:10 +08:00
|
|
|
if (virHostdevPreparePCIDevices(mgr, drv_name, dom_name, uuid,
|
|
|
|
&hostdevs[0], 1, 0) == 0)
|
2019-08-27 22:00:55 +08:00
|
|
|
return -1;
|
2019-08-27 22:08:12 +08:00
|
|
|
virResetLastError();
|
2019-06-14 20:30:13 +08:00
|
|
|
CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, active_count);
|
|
|
|
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count);
|
2014-03-06 16:08:36 +08:00
|
|
|
|
2019-08-27 22:07:36 +08:00
|
|
|
VIR_TEST_DEBUG("Test: prepare same hostdevs for same driver, diff domain again");
|
2019-08-27 22:00:10 +08:00
|
|
|
if (virHostdevPreparePCIDevices(mgr, drv_name, "test_domain1", uuid,
|
|
|
|
&hostdevs[1], 1, 0) == 0)
|
2019-08-27 22:00:55 +08:00
|
|
|
return -1;
|
2019-08-27 22:08:12 +08:00
|
|
|
virResetLastError();
|
2019-06-14 20:30:13 +08:00
|
|
|
CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, active_count);
|
|
|
|
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count);
|
2014-03-06 16:08:36 +08:00
|
|
|
|
2019-08-27 22:07:36 +08:00
|
|
|
VIR_TEST_DEBUG("Test: prepare same hostdevs for diff driver/domain again");
|
2019-08-27 22:00:10 +08:00
|
|
|
if (virHostdevPreparePCIDevices(mgr, "test_driver1", dom_name, uuid,
|
|
|
|
&hostdevs[2], 1, 0) == 0)
|
2019-08-27 22:00:55 +08:00
|
|
|
return -1;
|
2019-08-27 22:08:12 +08:00
|
|
|
virResetLastError();
|
2019-06-14 20:30:13 +08:00
|
|
|
CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, active_count);
|
|
|
|
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count);
|
2014-03-06 16:08:36 +08:00
|
|
|
|
2019-08-27 22:00:55 +08:00
|
|
|
return 0;
|
2014-03-06 16:08:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2016-03-19 01:03:53 +08:00
|
|
|
testVirHostdevReAttachPCIHostdevs_managed(bool mixed)
|
2014-03-06 16:08:36 +08:00
|
|
|
{
|
2016-03-02 22:33:18 +08:00
|
|
|
size_t active_count, inactive_count, i;
|
2014-03-06 16:08:36 +08:00
|
|
|
|
|
|
|
for (i = 0; i < nhostdevs; i++) {
|
|
|
|
if (hostdevs[i]->managed != true) {
|
2019-08-27 22:07:36 +08:00
|
|
|
VIR_TEST_DEBUG("invalid test");
|
2014-03-06 16:08:36 +08:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-02 22:15:07 +08:00
|
|
|
active_count = virPCIDeviceListCount(mgr->activePCIHostdevs);
|
2016-03-02 22:33:18 +08:00
|
|
|
inactive_count = virPCIDeviceListCount(mgr->inactivePCIHostdevs);
|
2014-03-06 16:08:36 +08:00
|
|
|
|
2019-08-27 22:07:36 +08:00
|
|
|
VIR_TEST_DEBUG("Test 0 hostdevs");
|
2014-03-06 16:08:36 +08:00
|
|
|
virHostdevReAttachPCIDevices(mgr, drv_name, dom_name, NULL, 0, NULL);
|
2019-06-14 20:30:13 +08:00
|
|
|
CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, active_count);
|
|
|
|
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count);
|
2014-03-06 16:08:36 +08:00
|
|
|
|
2019-08-27 22:07:36 +08:00
|
|
|
VIR_TEST_DEBUG("Test >=1 hostdevs");
|
2014-03-06 16:08:36 +08:00
|
|
|
virHostdevReAttachPCIDevices(mgr, drv_name, dom_name,
|
|
|
|
hostdevs, nhostdevs, NULL);
|
2019-06-14 20:30:13 +08:00
|
|
|
CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, active_count - nhostdevs);
|
2016-03-19 01:03:53 +08:00
|
|
|
/* If testing a mixed roundtrip, devices are added back to the inactive
|
|
|
|
* list as soon as we detach from the guest */
|
|
|
|
if (mixed)
|
2019-06-14 20:30:13 +08:00
|
|
|
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count + nhostdevs);
|
2016-03-19 01:03:53 +08:00
|
|
|
else
|
2019-06-14 20:30:13 +08:00
|
|
|
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count);
|
2014-03-06 16:08:36 +08:00
|
|
|
|
2019-08-27 22:00:55 +08:00
|
|
|
return 0;
|
2014-03-06 16:08:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2016-03-03 23:13:04 +08:00
|
|
|
testVirHostdevDetachPCINodeDevice(void)
|
2014-03-06 16:08:36 +08:00
|
|
|
{
|
2016-03-02 22:33:18 +08:00
|
|
|
size_t active_count, inactive_count, i;
|
2014-03-06 16:08:36 +08:00
|
|
|
|
|
|
|
for (i = 0; i < nhostdevs; i++) {
|
2016-03-02 22:33:18 +08:00
|
|
|
active_count = virPCIDeviceListCount(mgr->activePCIHostdevs);
|
2016-03-02 22:15:07 +08:00
|
|
|
inactive_count = virPCIDeviceListCount(mgr->inactivePCIHostdevs);
|
2014-03-06 16:08:36 +08:00
|
|
|
if (virHostdevPCINodeDeviceDetach(mgr, dev[i]) < 0)
|
2019-08-27 22:00:55 +08:00
|
|
|
return -1;
|
2019-06-14 20:30:13 +08:00
|
|
|
CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, active_count);
|
|
|
|
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count + 1);
|
2014-03-06 16:08:36 +08:00
|
|
|
}
|
|
|
|
|
2019-08-27 22:00:55 +08:00
|
|
|
return 0;
|
2014-03-06 16:08:36 +08:00
|
|
|
}
|
2016-03-03 23:13:04 +08:00
|
|
|
|
2014-03-06 16:08:36 +08:00
|
|
|
static int
|
2016-03-03 23:13:04 +08:00
|
|
|
testVirHostdevResetPCINodeDevice(void)
|
2014-03-06 16:08:36 +08:00
|
|
|
{
|
2016-03-02 22:33:18 +08:00
|
|
|
size_t active_count, inactive_count, i;
|
2014-03-06 16:08:36 +08:00
|
|
|
|
|
|
|
for (i = 0; i < nhostdevs; i++) {
|
2016-03-02 22:33:18 +08:00
|
|
|
active_count = virPCIDeviceListCount(mgr->activePCIHostdevs);
|
|
|
|
inactive_count = virPCIDeviceListCount(mgr->inactivePCIHostdevs);
|
2014-03-06 16:08:36 +08:00
|
|
|
if (virHostdevPCINodeDeviceReset(mgr, dev[i]) < 0)
|
2019-08-27 22:00:55 +08:00
|
|
|
return -1;
|
2019-06-14 20:30:13 +08:00
|
|
|
CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, active_count);
|
|
|
|
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count);
|
2014-03-06 16:08:36 +08:00
|
|
|
}
|
|
|
|
|
2019-08-27 22:00:55 +08:00
|
|
|
return 0;
|
2014-03-06 16:08:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2016-03-03 23:13:04 +08:00
|
|
|
testVirHostdevReAttachPCINodeDevice(void)
|
2014-03-06 16:08:36 +08:00
|
|
|
{
|
2016-03-02 22:33:18 +08:00
|
|
|
size_t active_count, inactive_count, i;
|
2014-03-06 16:08:36 +08:00
|
|
|
|
|
|
|
for (i = 0; i < nhostdevs; i++) {
|
2016-03-02 22:33:18 +08:00
|
|
|
active_count = virPCIDeviceListCount(mgr->activePCIHostdevs);
|
2016-03-02 22:15:07 +08:00
|
|
|
inactive_count = virPCIDeviceListCount(mgr->inactivePCIHostdevs);
|
2014-03-06 16:08:36 +08:00
|
|
|
if (virHostdevPCINodeDeviceReAttach(mgr, dev[i]) < 0)
|
2019-08-27 22:00:55 +08:00
|
|
|
return -1;
|
2019-06-14 20:30:13 +08:00
|
|
|
CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, active_count);
|
|
|
|
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count - 1);
|
2014-03-06 16:08:36 +08:00
|
|
|
}
|
|
|
|
|
2019-08-27 22:00:55 +08:00
|
|
|
return 0;
|
2014-03-06 16:08:36 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
2016-03-03 23:13:04 +08:00
|
|
|
testVirHostdevUpdateActivePCIHostdevs(void)
|
2014-03-06 16:08:36 +08:00
|
|
|
{
|
2016-03-02 22:33:18 +08:00
|
|
|
size_t active_count, inactive_count;
|
2014-03-06 16:08:36 +08:00
|
|
|
|
2016-03-02 22:15:07 +08:00
|
|
|
active_count = virPCIDeviceListCount(mgr->activePCIHostdevs);
|
2016-03-02 22:33:18 +08:00
|
|
|
inactive_count = virPCIDeviceListCount(mgr->inactivePCIHostdevs);
|
2014-03-06 16:08:36 +08:00
|
|
|
|
2019-08-27 22:07:36 +08:00
|
|
|
VIR_TEST_DEBUG("Test 0 hostdevs");
|
2014-03-06 16:08:36 +08:00
|
|
|
if (virHostdevUpdateActivePCIDevices(mgr, NULL, 0,
|
|
|
|
drv_name, dom_name) < 0)
|
2019-08-27 22:00:55 +08:00
|
|
|
return -1;
|
2019-06-14 20:30:13 +08:00
|
|
|
CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, active_count);
|
|
|
|
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count);
|
2014-03-06 16:08:36 +08:00
|
|
|
|
2019-08-27 22:07:36 +08:00
|
|
|
VIR_TEST_DEBUG("Test >=1 hostdevs");
|
2014-03-06 16:08:36 +08:00
|
|
|
if (virHostdevUpdateActivePCIDevices(mgr, hostdevs, nhostdevs,
|
|
|
|
drv_name, dom_name) < 0)
|
2019-08-27 22:00:55 +08:00
|
|
|
return -1;
|
2019-06-14 20:30:13 +08:00
|
|
|
CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, active_count + nhostdevs);
|
|
|
|
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, inactive_count);
|
2014-03-06 16:08:36 +08:00
|
|
|
|
2019-08-27 22:00:55 +08:00
|
|
|
return 0;
|
2014-03-06 16:08:36 +08:00
|
|
|
}
|
|
|
|
|
2016-03-19 01:03:53 +08:00
|
|
|
/**
|
|
|
|
* testVirHostdevRoundtripNoGuest:
|
|
|
|
* @opaque: unused
|
|
|
|
*
|
|
|
|
* Perform a roundtrip without ever assigning devices to the guest.
|
|
|
|
*
|
|
|
|
* 1. Detach devices from the host
|
|
|
|
* 2. Reattach devices to the host
|
|
|
|
*/
|
|
|
|
static int
|
2019-10-14 20:45:03 +08:00
|
|
|
testVirHostdevRoundtripNoGuest(const void *opaque G_GNUC_UNUSED)
|
2016-03-19 01:03:53 +08:00
|
|
|
{
|
|
|
|
if (testVirHostdevDetachPCINodeDevice() < 0)
|
2019-08-27 22:00:55 +08:00
|
|
|
return -1;
|
2016-03-19 01:03:53 +08:00
|
|
|
if (testVirHostdevReAttachPCINodeDevice() < 0)
|
2019-08-27 22:00:55 +08:00
|
|
|
return -1;
|
2016-03-19 01:03:53 +08:00
|
|
|
|
2019-08-27 22:00:55 +08:00
|
|
|
return 0;
|
2016-03-19 01:03:53 +08:00
|
|
|
}
|
|
|
|
|
2016-03-03 23:13:04 +08:00
|
|
|
/**
|
|
|
|
* testVirHostdevRoundtripUnmanaged:
|
|
|
|
* @opaque: unused
|
|
|
|
*
|
|
|
|
* Perform a roundtrip with unmanaged devices.
|
|
|
|
*
|
|
|
|
* 1. Detach devices from the host
|
|
|
|
* 2. Attach devices to the guest as unmanaged
|
|
|
|
* 3. Detach devices from the guest as unmanaged
|
|
|
|
* 4. Reattach devices to the host
|
|
|
|
*/
|
|
|
|
static int
|
2019-10-14 20:45:03 +08:00
|
|
|
testVirHostdevRoundtripUnmanaged(const void *opaque G_GNUC_UNUSED)
|
2016-03-03 23:13:04 +08:00
|
|
|
{
|
|
|
|
if (testVirHostdevDetachPCINodeDevice() < 0)
|
2019-08-27 22:00:55 +08:00
|
|
|
return -1;
|
2019-05-02 20:51:52 +08:00
|
|
|
if (testVirHostdevPreparePCIHostdevs_unmanaged() < 0)
|
2019-08-27 22:00:55 +08:00
|
|
|
return -1;
|
2019-05-02 20:51:52 +08:00
|
|
|
if (testVirHostdevReAttachPCIHostdevs_unmanaged() < 0)
|
2019-08-27 22:00:55 +08:00
|
|
|
return -1;
|
2016-03-03 23:13:04 +08:00
|
|
|
if (testVirHostdevReAttachPCINodeDevice() < 0)
|
2019-08-27 22:00:55 +08:00
|
|
|
return -1;
|
2016-03-03 23:13:04 +08:00
|
|
|
|
2019-08-27 22:00:55 +08:00
|
|
|
return 0;
|
2016-03-03 23:13:04 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* testVirHostdevRoundtripManaged:
|
|
|
|
* @opaque: unused
|
|
|
|
*
|
|
|
|
* Perform a roundtrip with managed devices.
|
|
|
|
*
|
|
|
|
* 1. Attach devices to the guest as managed
|
|
|
|
* 2. Detach devices from the guest as managed
|
|
|
|
*/
|
|
|
|
static int
|
2019-10-14 20:45:03 +08:00
|
|
|
testVirHostdevRoundtripManaged(const void *opaque G_GNUC_UNUSED)
|
2016-03-03 23:13:04 +08:00
|
|
|
{
|
2019-05-02 20:51:52 +08:00
|
|
|
if (testVirHostdevPreparePCIHostdevs_managed(false) < 0)
|
2019-08-27 22:00:55 +08:00
|
|
|
return -1;
|
2019-05-02 20:51:52 +08:00
|
|
|
if (testVirHostdevReAttachPCIHostdevs_managed(false) < 0)
|
2019-08-27 22:00:55 +08:00
|
|
|
return -1;
|
2016-03-03 23:13:04 +08:00
|
|
|
|
2019-08-27 22:00:55 +08:00
|
|
|
return 0;
|
2016-03-03 23:13:04 +08:00
|
|
|
}
|
|
|
|
|
2016-03-19 01:03:53 +08:00
|
|
|
/**
|
|
|
|
* testVirHostdevRoundtripMixed:
|
|
|
|
* @opaque: unused
|
|
|
|
*
|
|
|
|
* Perform a roundtrip with managed devices but manually detach the devices
|
|
|
|
* from the host first.
|
|
|
|
*
|
|
|
|
* 1. Detach devices from the host
|
|
|
|
* 2. Attach devices to the guest as managed
|
|
|
|
* 3. Detach devices from the guest as managed
|
|
|
|
* 4. Reattach devices to the host
|
|
|
|
*/
|
|
|
|
static int
|
2019-10-14 20:45:03 +08:00
|
|
|
testVirHostdevRoundtripMixed(const void *opaque G_GNUC_UNUSED)
|
2016-03-19 01:03:53 +08:00
|
|
|
{
|
|
|
|
if (testVirHostdevDetachPCINodeDevice() < 0)
|
2019-08-27 22:00:55 +08:00
|
|
|
return -1;
|
2019-05-02 20:51:52 +08:00
|
|
|
if (testVirHostdevPreparePCIHostdevs_managed(true) < 0)
|
2019-08-27 22:00:55 +08:00
|
|
|
return -1;
|
2019-05-02 20:51:52 +08:00
|
|
|
if (testVirHostdevReAttachPCIHostdevs_managed(true) < 0)
|
2019-08-27 22:00:55 +08:00
|
|
|
return -1;
|
2016-03-19 01:03:53 +08:00
|
|
|
if (testVirHostdevReAttachPCINodeDevice() < 0)
|
2019-08-27 22:00:55 +08:00
|
|
|
return -1;
|
2016-03-19 01:03:53 +08:00
|
|
|
|
2019-08-27 22:00:55 +08:00
|
|
|
return 0;
|
2016-03-19 01:03:53 +08:00
|
|
|
}
|
|
|
|
|
2016-03-03 23:13:04 +08:00
|
|
|
/**
|
|
|
|
* testVirHostdevOther:
|
|
|
|
* @opaque: unused
|
|
|
|
*
|
|
|
|
* Perform other operations on devices.
|
|
|
|
*
|
|
|
|
* 1. Reset devices
|
|
|
|
* 2. Update list of active devices
|
|
|
|
*/
|
|
|
|
static int
|
2019-10-14 20:45:03 +08:00
|
|
|
testVirHostdevOther(const void *opaque G_GNUC_UNUSED)
|
2016-03-03 23:13:04 +08:00
|
|
|
{
|
|
|
|
if (testVirHostdevResetPCINodeDevice() < 0)
|
2019-08-27 22:00:55 +08:00
|
|
|
return -1;
|
2016-03-03 23:13:04 +08:00
|
|
|
if (testVirHostdevUpdateActivePCIHostdevs() < 0)
|
2019-08-27 22:00:55 +08:00
|
|
|
return -1;
|
2016-03-03 23:13:04 +08:00
|
|
|
|
2019-08-27 22:00:55 +08:00
|
|
|
return 0;
|
2016-03-03 23:13:04 +08:00
|
|
|
}
|
|
|
|
|
2019-06-13 15:41:15 +08:00
|
|
|
static int
|
|
|
|
testNVMeDiskRoundtrip(const void *opaque G_GNUC_UNUSED)
|
|
|
|
{
|
|
|
|
/* Don't rely on a state that previous test cases might have
|
|
|
|
* left the manager in. Start with a clean slate. */
|
|
|
|
virHostdevReAttachPCIDevices(mgr, drv_name, dom_name,
|
|
|
|
hostdevs, nhostdevs, NULL);
|
|
|
|
|
|
|
|
CHECK_NVME_LIST_COUNT(mgr->activeNVMeHostdevs, 0);
|
|
|
|
CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, 0);
|
|
|
|
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, 0);
|
|
|
|
|
|
|
|
/* Firstly, attach all NVMe disks */
|
|
|
|
if (virHostdevPrepareNVMeDevices(mgr, drv_name, dom_name, disks, ndisks) < 0)
|
2020-01-07 05:57:49 +08:00
|
|
|
return -1;
|
2019-06-13 15:41:15 +08:00
|
|
|
|
|
|
|
CHECK_NVME_LIST_COUNT(mgr->activeNVMeHostdevs, 3);
|
|
|
|
CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, 2);
|
|
|
|
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, 0);
|
|
|
|
|
|
|
|
/* Now, try to detach the first one. */
|
|
|
|
if (virHostdevReAttachNVMeDevices(mgr, drv_name, dom_name, disks, 1) < 0)
|
2020-01-07 05:57:49 +08:00
|
|
|
return -1;
|
2019-06-13 15:41:15 +08:00
|
|
|
|
|
|
|
CHECK_NVME_LIST_COUNT(mgr->activeNVMeHostdevs, 2);
|
|
|
|
CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, 2);
|
|
|
|
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, 0);
|
|
|
|
|
|
|
|
/* And the last one */
|
|
|
|
if (virHostdevReAttachNVMeDevices(mgr, drv_name, dom_name, &disks[2], 1) < 0)
|
2020-01-07 05:57:49 +08:00
|
|
|
return -1;
|
2019-06-13 15:41:15 +08:00
|
|
|
|
|
|
|
CHECK_NVME_LIST_COUNT(mgr->activeNVMeHostdevs, 1);
|
|
|
|
CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, 1);
|
|
|
|
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, 0);
|
|
|
|
|
|
|
|
/* Finally, detach the middle one */
|
|
|
|
if (virHostdevReAttachNVMeDevices(mgr, drv_name, dom_name, &disks[1], 1) < 0)
|
2020-01-07 05:57:49 +08:00
|
|
|
return -1;
|
2019-06-13 15:41:15 +08:00
|
|
|
|
|
|
|
CHECK_NVME_LIST_COUNT(mgr->activeNVMeHostdevs, 0);
|
|
|
|
CHECK_PCI_LIST_COUNT(mgr->activePCIHostdevs, 0);
|
|
|
|
CHECK_PCI_LIST_COUNT(mgr->inactivePCIHostdevs, 0);
|
|
|
|
|
2020-01-07 05:57:49 +08:00
|
|
|
return 0;
|
2019-06-13 15:41:15 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2015-12-04 20:38:16 +08:00
|
|
|
# define FAKEROOTDIRTEMPLATE abs_builddir "/fakerootdir-XXXXXX"
|
2014-03-06 16:08:36 +08:00
|
|
|
|
|
|
|
static int
|
|
|
|
mymain(void)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
2019-10-15 21:16:31 +08:00
|
|
|
g_autofree char *fakerootdir = NULL;
|
2014-03-06 16:08:36 +08:00
|
|
|
|
2019-10-20 19:49:46 +08:00
|
|
|
fakerootdir = g_strdup(FAKEROOTDIRTEMPLATE);
|
2014-03-06 16:08:36 +08:00
|
|
|
|
2019-11-14 05:35:47 +08:00
|
|
|
if (!g_mkdtemp(fakerootdir)) {
|
2015-12-04 20:38:16 +08:00
|
|
|
fprintf(stderr, "Cannot create fakerootdir");
|
2014-03-06 16:08:36 +08:00
|
|
|
abort();
|
|
|
|
}
|
|
|
|
|
2019-12-19 01:16:19 +08:00
|
|
|
g_setenv("LIBVIRT_FAKE_ROOT_DIR", fakerootdir, TRUE);
|
2014-03-06 16:08:36 +08:00
|
|
|
|
2017-11-03 20:09:47 +08:00
|
|
|
# define DO_TEST(fnc) \
|
|
|
|
do { \
|
|
|
|
if (virTestRun(#fnc, fnc, NULL) < 0) \
|
|
|
|
ret = -1; \
|
2014-03-06 16:08:36 +08:00
|
|
|
} while (0)
|
|
|
|
|
2019-06-14 16:39:24 +08:00
|
|
|
if (myInit() < 0) {
|
2014-03-06 16:08:36 +08:00
|
|
|
fprintf(stderr, "Init data structures failed.");
|
2019-06-14 16:39:24 +08:00
|
|
|
virFileDeleteTree(fakerootdir);
|
|
|
|
return EXIT_FAILURE;
|
|
|
|
}
|
2014-03-06 16:08:36 +08:00
|
|
|
|
2016-03-19 01:03:53 +08:00
|
|
|
DO_TEST(testVirHostdevRoundtripNoGuest);
|
2016-03-03 23:13:04 +08:00
|
|
|
DO_TEST(testVirHostdevRoundtripUnmanaged);
|
|
|
|
DO_TEST(testVirHostdevRoundtripManaged);
|
2016-03-19 01:03:53 +08:00
|
|
|
DO_TEST(testVirHostdevRoundtripMixed);
|
2016-03-03 23:13:04 +08:00
|
|
|
DO_TEST(testVirHostdevOther);
|
2019-06-13 15:41:15 +08:00
|
|
|
DO_TEST(testNVMeDiskRoundtrip);
|
2014-03-06 16:08:36 +08:00
|
|
|
|
|
|
|
myCleanup();
|
|
|
|
|
|
|
|
if (getenv("LIBVIRT_SKIP_CLEANUP") == NULL)
|
2015-12-04 20:38:16 +08:00
|
|
|
virFileDeleteTree(fakerootdir);
|
2014-03-06 16:08:36 +08:00
|
|
|
|
2014-03-17 17:38:38 +08:00
|
|
|
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
2014-03-06 16:08:36 +08:00
|
|
|
}
|
|
|
|
|
2020-05-06 20:38:42 +08:00
|
|
|
VIR_TEST_MAIN_PRELOAD(mymain,
|
|
|
|
VIR_TEST_MOCK("virhostdev"),
|
|
|
|
VIR_TEST_MOCK("virpci"))
|
2014-03-06 16:08:36 +08:00
|
|
|
#else
|
|
|
|
int
|
|
|
|
main(void)
|
|
|
|
{
|
|
|
|
return EXIT_AM_SKIP;
|
|
|
|
}
|
|
|
|
#endif
|