2017-03-22 14:50:33 +00:00
|
|
|
/*
|
|
|
|
* virmdev.h: helper APIs for managing host mediated devices
|
|
|
|
*
|
|
|
|
* 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/>.
|
|
|
|
*/
|
|
|
|
|
2019-06-18 16:13:08 +00:00
|
|
|
#pragma once
|
2017-03-22 14:50:33 +00:00
|
|
|
|
2019-06-18 16:13:08 +00:00
|
|
|
#include "internal.h"
|
|
|
|
#include "virobject.h"
|
|
|
|
#include "virenum.h"
|
2017-03-22 14:50:33 +00:00
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
VIR_MDEV_MODEL_TYPE_VFIO_PCI = 0,
|
2018-05-07 14:41:14 +00:00
|
|
|
VIR_MDEV_MODEL_TYPE_VFIO_CCW = 1,
|
2018-10-18 14:54:07 +00:00
|
|
|
VIR_MDEV_MODEL_TYPE_VFIO_AP = 2,
|
2017-03-22 14:50:33 +00:00
|
|
|
|
|
|
|
VIR_MDEV_MODEL_TYPE_LAST
|
|
|
|
} virMediatedDeviceModelType;
|
|
|
|
|
2019-01-20 16:04:56 +00:00
|
|
|
VIR_ENUM_DECL(virMediatedDeviceModel);
|
2017-03-22 14:50:33 +00:00
|
|
|
|
|
|
|
|
|
|
|
typedef struct _virMediatedDevice virMediatedDevice;
|
|
|
|
typedef struct _virMediatedDeviceList virMediatedDeviceList;
|
2020-06-18 21:05:56 +00:00
|
|
|
typedef struct _virMediatedDeviceAttr virMediatedDeviceAttr;
|
|
|
|
struct _virMediatedDeviceAttr {
|
|
|
|
char *name;
|
|
|
|
char *value;
|
|
|
|
};
|
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virMediatedDeviceAttr *virMediatedDeviceAttrNew(void);
|
|
|
|
void virMediatedDeviceAttrFree(virMediatedDeviceAttr *attr);
|
2020-06-18 21:05:56 +00:00
|
|
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virMediatedDeviceAttr, virMediatedDeviceAttrFree);
|
2017-03-22 14:50:33 +00:00
|
|
|
|
2019-10-04 16:14:10 +00:00
|
|
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virMediatedDeviceList, virObjectUnref);
|
|
|
|
|
|
|
|
|
2018-01-23 08:47:43 +00:00
|
|
|
typedef struct _virMediatedDeviceType virMediatedDeviceType;
|
|
|
|
struct _virMediatedDeviceType {
|
|
|
|
char *id;
|
|
|
|
char *name;
|
|
|
|
char *device_api;
|
|
|
|
unsigned int available_instances;
|
|
|
|
};
|
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
typedef int (*virMediatedDeviceCallback)(virMediatedDevice *dev,
|
2017-03-22 14:50:33 +00:00
|
|
|
const char *path, void *opaque);
|
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virMediatedDevice *
|
2017-03-22 14:50:33 +00:00
|
|
|
virMediatedDeviceNew(const char *uuidstr, virMediatedDeviceModelType model);
|
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virMediatedDevice *
|
|
|
|
virMediatedDeviceCopy(virMediatedDevice *dev);
|
2017-03-22 14:50:33 +00:00
|
|
|
|
|
|
|
void
|
2021-03-11 07:16:13 +00:00
|
|
|
virMediatedDeviceFree(virMediatedDevice *dev);
|
2017-03-22 14:50:33 +00:00
|
|
|
|
|
|
|
const char *
|
2021-03-11 07:16:13 +00:00
|
|
|
virMediatedDeviceGetPath(virMediatedDevice *dev);
|
2017-03-22 14:50:33 +00:00
|
|
|
|
|
|
|
void
|
2021-03-11 07:16:13 +00:00
|
|
|
virMediatedDeviceGetUsedBy(virMediatedDevice *dev,
|
2017-03-22 14:50:33 +00:00
|
|
|
const char **drvname, const char **domname);
|
|
|
|
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virMediatedDeviceSetUsedBy(virMediatedDevice *dev,
|
2017-03-22 14:50:33 +00:00
|
|
|
const char *drvname,
|
|
|
|
const char *domname);
|
|
|
|
|
|
|
|
char *
|
2017-04-26 12:47:15 +00:00
|
|
|
virMediatedDeviceGetIOMMUGroupDev(const char *uuidstr);
|
2017-03-22 14:50:33 +00:00
|
|
|
|
|
|
|
int
|
2017-04-26 12:47:15 +00:00
|
|
|
virMediatedDeviceGetIOMMUGroupNum(const char *uuidstr);
|
2017-03-22 14:50:33 +00:00
|
|
|
|
|
|
|
char *
|
|
|
|
virMediatedDeviceGetSysfsPath(const char *uuidstr);
|
|
|
|
|
|
|
|
bool
|
2021-03-11 07:16:13 +00:00
|
|
|
virMediatedDeviceIsUsed(virMediatedDevice *dev,
|
|
|
|
virMediatedDeviceList *list);
|
2017-03-22 14:50:33 +00:00
|
|
|
|
|
|
|
bool
|
2021-03-11 07:16:13 +00:00
|
|
|
virMediatedDeviceIsUsed(virMediatedDevice *dev,
|
|
|
|
virMediatedDeviceList *list);
|
2017-03-22 14:50:33 +00:00
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virMediatedDeviceList *
|
2017-03-22 14:50:33 +00:00
|
|
|
virMediatedDeviceListNew(void);
|
|
|
|
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virMediatedDeviceListAdd(virMediatedDeviceList *list,
|
|
|
|
virMediatedDevice **dev);
|
2017-03-22 14:50:33 +00:00
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virMediatedDevice *
|
|
|
|
virMediatedDeviceListGet(virMediatedDeviceList *list,
|
2017-03-22 14:50:33 +00:00
|
|
|
ssize_t idx);
|
|
|
|
|
|
|
|
size_t
|
2021-03-11 07:16:13 +00:00
|
|
|
virMediatedDeviceListCount(virMediatedDeviceList *list);
|
2017-03-22 14:50:33 +00:00
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virMediatedDevice *
|
|
|
|
virMediatedDeviceListSteal(virMediatedDeviceList *list,
|
|
|
|
virMediatedDevice *dev);
|
2017-03-22 14:50:33 +00:00
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virMediatedDevice *
|
|
|
|
virMediatedDeviceListStealIndex(virMediatedDeviceList *list,
|
2017-03-22 14:50:33 +00:00
|
|
|
ssize_t idx);
|
|
|
|
|
|
|
|
void
|
2021-03-11 07:16:13 +00:00
|
|
|
virMediatedDeviceListDel(virMediatedDeviceList *list,
|
|
|
|
virMediatedDevice *dev);
|
2017-03-22 14:50:33 +00:00
|
|
|
|
2021-03-11 07:16:13 +00:00
|
|
|
virMediatedDevice *
|
|
|
|
virMediatedDeviceListFind(virMediatedDeviceList *list,
|
2021-01-07 15:53:21 +00:00
|
|
|
const char *sysfspath);
|
2017-03-22 14:50:33 +00:00
|
|
|
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virMediatedDeviceListFindIndex(virMediatedDeviceList *list,
|
2021-01-07 15:53:21 +00:00
|
|
|
const char *sysfspath);
|
2017-03-22 14:50:33 +00:00
|
|
|
|
|
|
|
int
|
2021-03-11 07:16:13 +00:00
|
|
|
virMediatedDeviceListMarkDevices(virMediatedDeviceList *dst,
|
|
|
|
virMediatedDeviceList *src,
|
2017-03-22 14:50:33 +00:00
|
|
|
const char *drvname,
|
|
|
|
const char *domname);
|
2018-01-23 08:47:43 +00:00
|
|
|
|
|
|
|
void
|
2021-03-11 07:16:13 +00:00
|
|
|
virMediatedDeviceTypeFree(virMediatedDeviceType *type);
|
2018-01-23 08:55:52 +00:00
|
|
|
|
|
|
|
int
|
|
|
|
virMediatedDeviceTypeReadAttrs(const char *sysfspath,
|
2021-03-11 07:16:13 +00:00
|
|
|
virMediatedDeviceType **type);
|
2018-01-23 08:55:52 +00:00
|
|
|
|
2020-10-23 17:31:44 +00:00
|
|
|
ssize_t
|
|
|
|
virMediatedDeviceGetMdevTypes(const char *sysfspath,
|
2021-03-11 07:16:13 +00:00
|
|
|
virMediatedDeviceType ***types,
|
2020-10-23 17:31:45 +00:00
|
|
|
size_t *ntypes);
|
2020-10-23 17:31:44 +00:00
|
|
|
|
2019-10-15 12:47:50 +00:00
|
|
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virMediatedDevice, virMediatedDeviceFree);
|
|
|
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC(virMediatedDeviceType, virMediatedDeviceTypeFree);
|