2017-02-28 13:24:26 -05:00
|
|
|
/*
|
|
|
|
* virnodedeviceobj.h: node device object handling for node devices
|
|
|
|
* (derived from node_device_conf.h)
|
|
|
|
*
|
|
|
|
* 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-07 15:20:19 -05:00
|
|
|
#pragma once
|
2017-02-28 13:24:26 -05:00
|
|
|
|
2019-06-07 15:20:19 -05:00
|
|
|
#include "internal.h"
|
|
|
|
#include "virthread.h"
|
2017-02-28 13:24:26 -05:00
|
|
|
|
2019-06-07 15:20:19 -05:00
|
|
|
#include "node_device_conf.h"
|
|
|
|
#include "object_event.h"
|
2017-02-28 13:24:26 -05:00
|
|
|
|
|
|
|
|
2017-05-12 13:56:14 -04:00
|
|
|
typedef struct _virNodeDeviceObj virNodeDeviceObj;
|
|
|
|
|
|
|
|
typedef struct _virNodeDeviceObjList virNodeDeviceObjList;
|
|
|
|
|
2017-02-28 13:24:26 -05:00
|
|
|
typedef struct _virNodeDeviceDriverState virNodeDeviceDriverState;
|
|
|
|
struct _virNodeDeviceDriverState {
|
|
|
|
virMutex lock;
|
2020-03-13 11:53:25 +00:00
|
|
|
virCond initCond;
|
|
|
|
bool initialized;
|
2017-02-28 13:24:26 -05:00
|
|
|
|
2019-05-23 11:34:08 +01:00
|
|
|
/* pid file FD, ensures two copies of the driver can't use the same root */
|
|
|
|
int lockFD;
|
|
|
|
|
|
|
|
char *stateDir;
|
|
|
|
|
2021-03-11 08:16:13 +01:00
|
|
|
virNodeDeviceObjList *devs; /* currently-known devices */
|
2017-10-17 17:05:47 +02:00
|
|
|
void *privateData; /* driver-specific private data */
|
2017-10-16 11:53:33 +02:00
|
|
|
bool privileged; /* whether we run in privileged mode */
|
2017-02-28 13:24:26 -05:00
|
|
|
|
|
|
|
/* Immutable pointer, self-locking APIs */
|
2021-03-11 08:16:13 +01:00
|
|
|
virObjectEventState *nodeDeviceEventState;
|
2021-07-16 13:46:52 -05:00
|
|
|
virNodeDeviceDefParserCallbacks parserCallbacks;
|
2017-02-28 13:24:26 -05:00
|
|
|
};
|
|
|
|
|
2017-05-15 11:00:59 -04:00
|
|
|
void
|
2021-03-11 08:16:13 +01:00
|
|
|
virNodeDeviceObjEndAPI(virNodeDeviceObj **obj);
|
2017-02-28 13:24:26 -05:00
|
|
|
|
2021-03-11 08:16:13 +01:00
|
|
|
virNodeDeviceDef *
|
|
|
|
virNodeDeviceObjGetDef(virNodeDeviceObj *obj);
|
2017-06-03 07:36:01 -04:00
|
|
|
|
2021-03-11 08:16:13 +01:00
|
|
|
virNodeDeviceObj *
|
|
|
|
virNodeDeviceObjListFindByName(virNodeDeviceObjList *devs,
|
2017-05-12 14:47:17 -04:00
|
|
|
const char *name);
|
2017-02-28 13:24:26 -05:00
|
|
|
|
2021-03-11 08:16:13 +01:00
|
|
|
virNodeDeviceObj *
|
|
|
|
virNodeDeviceObjListFindBySysfsPath(virNodeDeviceObjList *devs,
|
2017-05-12 14:47:17 -04:00
|
|
|
const char *sysfs_path)
|
2017-02-28 13:24:26 -05:00
|
|
|
ATTRIBUTE_NONNULL(2);
|
|
|
|
|
2021-03-11 08:16:13 +01:00
|
|
|
virNodeDeviceObj *
|
|
|
|
virNodeDeviceObjListFindSCSIHostByWWNs(virNodeDeviceObjList *devs,
|
2017-05-12 15:31:10 -04:00
|
|
|
const char *wwnn,
|
|
|
|
const char *wwpn);
|
|
|
|
|
2021-03-11 08:16:13 +01:00
|
|
|
virNodeDeviceObj *
|
|
|
|
virNodeDeviceObjListAssignDef(virNodeDeviceObjList *devs,
|
|
|
|
virNodeDeviceDef *def);
|
2017-03-02 08:50:27 -05:00
|
|
|
|
|
|
|
void
|
2021-03-11 08:16:13 +01:00
|
|
|
virNodeDeviceObjListRemove(virNodeDeviceObjList *devs,
|
|
|
|
virNodeDeviceObj *dev);
|
2017-02-28 13:24:26 -05:00
|
|
|
|
2020-10-15 11:30:35 -05:00
|
|
|
void
|
|
|
|
virNodeDeviceObjListRemoveLocked(virNodeDeviceObjList *devs,
|
|
|
|
virNodeDeviceObj *dev);
|
|
|
|
|
2017-03-02 08:50:27 -05:00
|
|
|
int
|
2021-03-11 08:16:13 +01:00
|
|
|
virNodeDeviceObjListGetParentHost(virNodeDeviceObjList *devs,
|
|
|
|
virNodeDeviceDef *def);
|
2017-02-28 13:24:26 -05:00
|
|
|
|
2021-03-11 08:16:13 +01:00
|
|
|
virNodeDeviceObjList *
|
2017-05-12 13:51:25 -04:00
|
|
|
virNodeDeviceObjListNew(void);
|
|
|
|
|
2017-03-02 08:50:27 -05:00
|
|
|
void
|
2021-03-11 08:16:13 +01:00
|
|
|
virNodeDeviceObjListFree(virNodeDeviceObjList *devs);
|
2017-02-28 13:24:26 -05:00
|
|
|
|
2017-03-02 08:50:27 -05:00
|
|
|
typedef bool
|
|
|
|
(*virNodeDeviceObjListFilter)(virConnectPtr conn,
|
2021-03-11 08:16:13 +01:00
|
|
|
virNodeDeviceDef *def);
|
2017-02-28 13:24:26 -05:00
|
|
|
|
2017-03-19 07:49:38 -04:00
|
|
|
int
|
2021-03-11 08:16:13 +01:00
|
|
|
virNodeDeviceObjListNumOfDevices(virNodeDeviceObjList *devs,
|
2017-05-12 14:47:17 -04:00
|
|
|
virConnectPtr conn,
|
|
|
|
const char *cap,
|
2017-08-16 09:23:27 -04:00
|
|
|
virNodeDeviceObjListFilter filter);
|
2017-03-19 07:49:38 -04:00
|
|
|
|
2017-03-19 15:51:03 -04:00
|
|
|
int
|
2021-03-11 08:16:13 +01:00
|
|
|
virNodeDeviceObjListGetNames(virNodeDeviceObjList *devs,
|
2017-05-12 14:47:17 -04:00
|
|
|
virConnectPtr conn,
|
2017-08-16 09:23:27 -04:00
|
|
|
virNodeDeviceObjListFilter filter,
|
2017-05-12 14:47:17 -04:00
|
|
|
const char *cap,
|
|
|
|
char **const names,
|
|
|
|
int maxnames);
|
2017-03-19 15:51:03 -04:00
|
|
|
|
2017-03-02 08:50:27 -05:00
|
|
|
int
|
|
|
|
virNodeDeviceObjListExport(virConnectPtr conn,
|
2021-03-11 08:16:13 +01:00
|
|
|
virNodeDeviceObjList *devobjs,
|
2017-03-02 08:50:27 -05:00
|
|
|
virNodeDevicePtr **devices,
|
2017-08-16 09:23:27 -04:00
|
|
|
virNodeDeviceObjListFilter filter,
|
2017-03-02 08:50:27 -05:00
|
|
|
unsigned int flags);
|
2017-02-28 13:24:26 -05:00
|
|
|
|
2018-02-23 18:09:20 -05:00
|
|
|
void
|
2021-03-11 08:16:13 +01:00
|
|
|
virNodeDeviceObjSetSkipUpdateCaps(virNodeDeviceObj *obj,
|
2018-02-23 18:09:20 -05:00
|
|
|
bool skipUpdateCaps);
|
2021-03-11 08:16:13 +01:00
|
|
|
virNodeDeviceObj *
|
|
|
|
virNodeDeviceObjListFindMediatedDeviceByUUID(virNodeDeviceObjList *devs,
|
2021-07-16 14:33:50 -05:00
|
|
|
const char *uuid,
|
|
|
|
const char *parent_addr);
|
2020-07-09 10:39:34 -05:00
|
|
|
|
|
|
|
bool
|
|
|
|
virNodeDeviceObjIsActive(virNodeDeviceObj *obj);
|
|
|
|
|
|
|
|
void
|
|
|
|
virNodeDeviceObjSetActive(virNodeDeviceObj *obj,
|
|
|
|
bool active);
|
2021-01-15 16:41:51 -06:00
|
|
|
bool
|
|
|
|
virNodeDeviceObjIsPersistent(virNodeDeviceObj *obj);
|
|
|
|
|
|
|
|
void
|
|
|
|
virNodeDeviceObjSetPersistent(virNodeDeviceObj *obj,
|
|
|
|
bool persistent);
|
2020-10-15 11:30:35 -05:00
|
|
|
|
2021-07-15 17:07:32 -05:00
|
|
|
typedef bool (*virNodeDeviceObjListPredicate)(virNodeDeviceObj *obj,
|
|
|
|
const void *opaque);
|
2020-10-15 11:30:35 -05:00
|
|
|
|
|
|
|
void virNodeDeviceObjListForEachRemove(virNodeDeviceObjList *devs,
|
2021-07-15 17:07:32 -05:00
|
|
|
virNodeDeviceObjListPredicate callback,
|
2020-10-15 11:30:35 -05:00
|
|
|
void *opaque);
|
2021-07-15 17:07:32 -05:00
|
|
|
|
|
|
|
virNodeDeviceObj *
|
|
|
|
virNodeDeviceObjListFind(virNodeDeviceObjList *devs,
|
|
|
|
virNodeDeviceObjListPredicate callback,
|
|
|
|
void *opaque);
|