2014-03-01 06:28:59 +00:00
|
|
|
/* virhostdev.h: hostdev management
|
|
|
|
*
|
2014-03-05 12:14:38 +00:00
|
|
|
* Copyright (C) 2006-2007, 2009-2013 Red Hat, Inc.
|
|
|
|
* Copyright (C) 2006 Daniel P. Berrange
|
2014-03-01 06:28:59 +00:00
|
|
|
* Copyright (C) 2014 SUSE LINUX Products GmbH, Nuernberg, Germany.
|
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2018-12-13 14:53:50 +00:00
|
|
|
#ifndef LIBVIRT_VIRHOSTDEV_H
|
|
|
|
# define LIBVIRT_VIRHOSTDEV_H
|
2014-03-01 06:28:59 +00:00
|
|
|
|
|
|
|
# include "internal.h"
|
|
|
|
|
|
|
|
# include "virpci.h"
|
|
|
|
# include "virusb.h"
|
|
|
|
# include "virscsi.h"
|
2016-11-22 03:58:17 +00:00
|
|
|
# include "virscsivhost.h"
|
2017-02-20 13:54:12 +00:00
|
|
|
# include "conf/domain_conf.h"
|
2017-02-03 13:04:59 +00:00
|
|
|
# include "virmdev.h"
|
2014-03-05 12:14:38 +00:00
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
VIR_HOSTDEV_STRICT_ACS_CHECK = (1 << 0), /* strict acs check */
|
|
|
|
VIR_HOSTDEV_COLD_BOOT = (1 << 1), /* cold boot */
|
2014-03-06 07:57:03 +00:00
|
|
|
|
|
|
|
VIR_HOSTDEV_SP_PCI = (1 << 8), /* support pci passthrough */
|
|
|
|
VIR_HOSTDEV_SP_USB = (1 << 9), /* support usb passthrough */
|
|
|
|
VIR_HOSTDEV_SP_SCSI = (1 << 10), /* support scsi passthrough */
|
2014-03-05 12:14:38 +00:00
|
|
|
} virHostdevFlag;
|
|
|
|
|
2014-03-01 06:28:59 +00:00
|
|
|
|
|
|
|
typedef struct _virHostdevManager virHostdevManager;
|
|
|
|
typedef virHostdevManager *virHostdevManagerPtr;
|
|
|
|
struct _virHostdevManager {
|
2014-03-12 22:57:36 +00:00
|
|
|
virObject parent;
|
|
|
|
|
2014-03-01 06:28:59 +00:00
|
|
|
char *stateDir;
|
|
|
|
|
2014-03-12 16:38:18 +00:00
|
|
|
virPCIDeviceListPtr activePCIHostdevs;
|
|
|
|
virPCIDeviceListPtr inactivePCIHostdevs;
|
|
|
|
virUSBDeviceListPtr activeUSBHostdevs;
|
|
|
|
virSCSIDeviceListPtr activeSCSIHostdevs;
|
2016-11-22 03:58:17 +00:00
|
|
|
virSCSIVHostDeviceListPtr activeSCSIVHostHostdevs;
|
2017-02-03 13:04:59 +00:00
|
|
|
virMediatedDeviceListPtr activeMediatedHostdevs;
|
2014-03-01 06:28:59 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
virHostdevManagerPtr virHostdevManagerGetDefault(void);
|
2014-03-05 12:14:38 +00:00
|
|
|
int
|
|
|
|
virHostdevPreparePCIDevices(virHostdevManagerPtr hostdev_mgr,
|
|
|
|
const char *drv_name,
|
2014-03-06 07:24:06 +00:00
|
|
|
const char *dom_name,
|
2014-03-05 12:14:38 +00:00
|
|
|
const unsigned char *uuid,
|
|
|
|
virDomainHostdevDefPtr *hostdevs,
|
2014-03-06 05:53:56 +00:00
|
|
|
int nhostdevs,
|
2014-03-06 08:02:31 +00:00
|
|
|
unsigned int flags)
|
|
|
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3)
|
|
|
|
ATTRIBUTE_NONNULL(4);
|
2016-08-11 00:39:11 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
virHostdevFindUSBDevice(virDomainHostdevDefPtr hostdev,
|
|
|
|
bool mandatory,
|
|
|
|
virUSBDevicePtr *usb)
|
|
|
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(3);
|
2014-03-06 05:53:56 +00:00
|
|
|
int
|
|
|
|
virHostdevPrepareUSBDevices(virHostdevManagerPtr hostdev_mgr,
|
|
|
|
const char *drv_name,
|
2014-03-06 07:24:06 +00:00
|
|
|
const char *dom_name,
|
2014-03-06 05:53:56 +00:00
|
|
|
virDomainHostdevDefPtr *hostdevs,
|
2014-03-05 12:14:38 +00:00
|
|
|
int nhostdevs,
|
2014-03-06 08:02:31 +00:00
|
|
|
unsigned int flags)
|
|
|
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
|
2014-03-06 06:19:11 +00:00
|
|
|
int
|
|
|
|
virHostdevPrepareSCSIDevices(virHostdevManagerPtr hostdev_mgr,
|
|
|
|
const char *drv_name,
|
2014-03-06 07:24:06 +00:00
|
|
|
const char *dom_name,
|
2014-03-06 06:19:11 +00:00
|
|
|
virDomainHostdevDefPtr *hostdevs,
|
2014-03-06 08:02:31 +00:00
|
|
|
int nhostdevs)
|
|
|
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
|
2016-11-22 03:58:17 +00:00
|
|
|
int
|
|
|
|
virHostdevPrepareSCSIVHostDevices(virHostdevManagerPtr hostdev_mgr,
|
|
|
|
const char *drv_name,
|
|
|
|
const char *dom_name,
|
|
|
|
virDomainHostdevDefPtr *hostdevs,
|
|
|
|
int nhostdevs)
|
|
|
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
|
2017-02-03 13:04:59 +00:00
|
|
|
int
|
|
|
|
virHostdevPrepareMediatedDevices(virHostdevManagerPtr hostdev_mgr,
|
|
|
|
const char *drv_name,
|
|
|
|
const char *dom_name,
|
|
|
|
virDomainHostdevDefPtr *hostdevs,
|
|
|
|
int nhostdevs)
|
|
|
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
|
2014-03-05 12:14:38 +00:00
|
|
|
void
|
|
|
|
virHostdevReAttachPCIDevices(virHostdevManagerPtr hostdev_mgr,
|
|
|
|
const char *drv_name,
|
2014-03-06 07:24:06 +00:00
|
|
|
const char *dom_name,
|
2014-03-05 12:14:38 +00:00
|
|
|
virDomainHostdevDefPtr *hostdevs,
|
|
|
|
int nhostdevs,
|
2014-03-06 08:02:31 +00:00
|
|
|
const char *oldStateDir)
|
2017-03-21 18:23:11 +00:00
|
|
|
ATTRIBUTE_NONNULL(1);
|
2014-03-06 06:37:30 +00:00
|
|
|
void
|
2014-03-12 16:35:30 +00:00
|
|
|
virHostdevReAttachUSBDevices(virHostdevManagerPtr hostdev_mgr,
|
2014-03-06 06:37:30 +00:00
|
|
|
const char *drv_name,
|
2014-03-06 07:24:06 +00:00
|
|
|
const char *dom_name,
|
2014-03-06 06:37:30 +00:00
|
|
|
virDomainHostdevDefPtr *hostdevs,
|
2014-03-06 08:02:31 +00:00
|
|
|
int nhostdevs)
|
2017-03-21 18:25:43 +00:00
|
|
|
ATTRIBUTE_NONNULL(1);
|
2014-03-06 06:49:23 +00:00
|
|
|
void
|
2014-03-12 16:35:30 +00:00
|
|
|
virHostdevReAttachSCSIDevices(virHostdevManagerPtr hostdev_mgr,
|
|
|
|
const char *drv_name,
|
|
|
|
const char *dom_name,
|
|
|
|
virDomainHostdevDefPtr *hostdevs,
|
2014-03-06 08:02:31 +00:00
|
|
|
int nhostdevs)
|
|
|
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
|
2016-11-22 03:58:17 +00:00
|
|
|
void
|
|
|
|
virHostdevReAttachSCSIVHostDevices(virHostdevManagerPtr hostdev_mgr,
|
|
|
|
const char *drv_name,
|
|
|
|
const char *dom_name,
|
|
|
|
virDomainHostdevDefPtr *hostdevs,
|
|
|
|
int nhostdevs)
|
2017-03-22 11:23:46 +00:00
|
|
|
ATTRIBUTE_NONNULL(1);
|
2017-02-03 13:04:59 +00:00
|
|
|
void
|
|
|
|
virHostdevReAttachMediatedDevices(virHostdevManagerPtr hostdev_mgr,
|
|
|
|
const char *drv_name,
|
|
|
|
const char *dom_name,
|
|
|
|
virDomainHostdevDefPtr *hostdevs,
|
|
|
|
int nhostdevs)
|
2017-03-27 15:25:20 +00:00
|
|
|
ATTRIBUTE_NONNULL(1);
|
2014-03-06 05:13:00 +00:00
|
|
|
int
|
2014-03-12 16:35:30 +00:00
|
|
|
virHostdevUpdateActivePCIDevices(virHostdevManagerPtr mgr,
|
2014-03-06 07:48:49 +00:00
|
|
|
virDomainHostdevDefPtr *hostdevs,
|
|
|
|
int nhostdevs,
|
2014-03-12 16:35:30 +00:00
|
|
|
const char *drv_name,
|
2014-03-06 08:02:31 +00:00
|
|
|
const char *dom_name)
|
|
|
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5);
|
2014-03-06 05:13:00 +00:00
|
|
|
int
|
2014-03-12 16:35:30 +00:00
|
|
|
virHostdevUpdateActiveUSBDevices(virHostdevManagerPtr mgr,
|
2014-03-06 07:48:49 +00:00
|
|
|
virDomainHostdevDefPtr *hostdevs,
|
|
|
|
int nhostdevs,
|
2014-03-12 16:35:30 +00:00
|
|
|
const char *drv_name,
|
2014-03-06 08:02:31 +00:00
|
|
|
const char *dom_name)
|
|
|
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5);
|
2014-03-12 16:35:30 +00:00
|
|
|
int
|
|
|
|
virHostdevUpdateActiveSCSIDevices(virHostdevManagerPtr mgr,
|
2014-03-06 07:48:49 +00:00
|
|
|
virDomainHostdevDefPtr *hostdevs,
|
|
|
|
int nhostdevs,
|
2014-03-06 05:13:00 +00:00
|
|
|
const char *drv_name,
|
2014-03-06 08:02:31 +00:00
|
|
|
const char *dom_name)
|
|
|
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5);
|
2014-03-06 07:57:03 +00:00
|
|
|
int
|
2017-02-03 13:04:59 +00:00
|
|
|
virHostdevUpdateActiveMediatedDevices(virHostdevManagerPtr mgr,
|
|
|
|
virDomainHostdevDefPtr *hostdevs,
|
|
|
|
int nhostdevs,
|
|
|
|
const char *drv_name,
|
|
|
|
const char *dom_name)
|
|
|
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(4) ATTRIBUTE_NONNULL(5);
|
|
|
|
int
|
2015-10-26 10:59:41 +00:00
|
|
|
virHostdevUpdateActiveDomainDevices(virHostdevManagerPtr mgr,
|
2014-03-06 07:57:03 +00:00
|
|
|
const char *driver,
|
|
|
|
virDomainDefPtr def,
|
2014-03-06 08:02:31 +00:00
|
|
|
unsigned int flags)
|
|
|
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
|
2014-03-06 07:57:03 +00:00
|
|
|
int
|
|
|
|
virHostdevPrepareDomainDevices(virHostdevManagerPtr mgr,
|
|
|
|
const char *driver,
|
|
|
|
virDomainDefPtr def,
|
2014-03-06 08:02:31 +00:00
|
|
|
unsigned int flags)
|
2017-03-21 18:32:01 +00:00
|
|
|
ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
|
2014-03-06 07:57:03 +00:00
|
|
|
void
|
|
|
|
virHostdevReAttachDomainDevices(virHostdevManagerPtr mgr,
|
|
|
|
const char *driver,
|
|
|
|
virDomainDefPtr def,
|
|
|
|
unsigned int flags,
|
2014-03-06 08:02:31 +00:00
|
|
|
const char *oldStateDir)
|
2017-03-22 12:30:15 +00:00
|
|
|
ATTRIBUTE_NONNULL(2) ATTRIBUTE_NONNULL(3);
|
2016-11-15 18:25:40 +00:00
|
|
|
bool
|
|
|
|
virHostdevIsSCSIDevice(virDomainHostdevDefPtr hostdev)
|
|
|
|
ATTRIBUTE_NONNULL(1);
|
2018-05-07 14:41:13 +00:00
|
|
|
bool
|
|
|
|
virHostdevIsMdevDevice(virDomainHostdevDefPtr hostdev)
|
|
|
|
ATTRIBUTE_NONNULL(1);
|
2014-03-01 06:28:59 +00:00
|
|
|
|
2014-03-06 07:20:14 +00:00
|
|
|
/* functions used by NodeDevDetach/Reattach/Reset */
|
2014-03-06 07:35:03 +00:00
|
|
|
int virHostdevPCINodeDeviceDetach(virHostdevManagerPtr mgr,
|
2014-03-06 08:02:31 +00:00
|
|
|
virPCIDevicePtr pci)
|
|
|
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
2014-03-06 07:35:03 +00:00
|
|
|
int virHostdevPCINodeDeviceReAttach(virHostdevManagerPtr mgr,
|
2014-03-06 08:02:31 +00:00
|
|
|
virPCIDevicePtr pci)
|
|
|
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
2014-03-06 07:35:03 +00:00
|
|
|
int virHostdevPCINodeDeviceReset(virHostdevManagerPtr mgr,
|
2014-03-06 08:02:31 +00:00
|
|
|
virPCIDevicePtr pci)
|
|
|
|
ATTRIBUTE_NONNULL(1) ATTRIBUTE_NONNULL(2);
|
2014-03-06 07:20:14 +00:00
|
|
|
|
2018-12-13 14:53:50 +00:00
|
|
|
#endif /* LIBVIRT_VIRHOSTDEV_H */
|