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