mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-10-31 18:33:11 +00:00
9691440ecb
With recent additions to the node device xml schema, an xml schema can now describe a mdev device sufficiently for libvirt to create and start the device using the mdevctl utility. Note that some of the the configuration for a mediated device must be passed to mdevctl as a JSON-formatted file. In order to avoid creating and cleaning up temporary files, the JSON is instead fed to stdin and we pass the filename /dev/stdin to mdevctl. While this may not be portable, neither are mediated devices, so I don't believe it should cause any problems. Signed-off-by: Jonathon Jongsma <jjongsma@redhat.com> Reviewed-by: Erik Skultety <eskultet@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
124 lines
4.1 KiB
C
124 lines
4.1 KiB
C
/*
|
|
* 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/>.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include "internal.h"
|
|
#include "virthread.h"
|
|
|
|
#include "node_device_conf.h"
|
|
#include "object_event.h"
|
|
|
|
|
|
typedef struct _virNodeDeviceObj virNodeDeviceObj;
|
|
typedef virNodeDeviceObj *virNodeDeviceObjPtr;
|
|
|
|
typedef struct _virNodeDeviceObjList virNodeDeviceObjList;
|
|
typedef virNodeDeviceObjList *virNodeDeviceObjListPtr;
|
|
|
|
typedef struct _virNodeDeviceDriverState virNodeDeviceDriverState;
|
|
typedef virNodeDeviceDriverState *virNodeDeviceDriverStatePtr;
|
|
struct _virNodeDeviceDriverState {
|
|
virMutex lock;
|
|
virCond initCond;
|
|
bool initialized;
|
|
|
|
/* pid file FD, ensures two copies of the driver can't use the same root */
|
|
int lockFD;
|
|
|
|
char *stateDir;
|
|
|
|
virNodeDeviceObjListPtr devs; /* currently-known devices */
|
|
void *privateData; /* driver-specific private data */
|
|
bool privileged; /* whether we run in privileged mode */
|
|
|
|
/* Immutable pointer, self-locking APIs */
|
|
virObjectEventStatePtr nodeDeviceEventState;
|
|
};
|
|
|
|
void
|
|
virNodeDeviceObjEndAPI(virNodeDeviceObjPtr *obj);
|
|
|
|
virNodeDeviceDefPtr
|
|
virNodeDeviceObjGetDef(virNodeDeviceObjPtr obj);
|
|
|
|
virNodeDeviceObjPtr
|
|
virNodeDeviceObjListFindByName(virNodeDeviceObjListPtr devs,
|
|
const char *name);
|
|
|
|
virNodeDeviceObjPtr
|
|
virNodeDeviceObjListFindBySysfsPath(virNodeDeviceObjListPtr devs,
|
|
const char *sysfs_path)
|
|
ATTRIBUTE_NONNULL(2);
|
|
|
|
virNodeDeviceObjPtr
|
|
virNodeDeviceObjListFindSCSIHostByWWNs(virNodeDeviceObjListPtr devs,
|
|
const char *wwnn,
|
|
const char *wwpn);
|
|
|
|
virNodeDeviceObjPtr
|
|
virNodeDeviceObjListAssignDef(virNodeDeviceObjListPtr devs,
|
|
virNodeDeviceDefPtr def);
|
|
|
|
void
|
|
virNodeDeviceObjListRemove(virNodeDeviceObjListPtr devs,
|
|
virNodeDeviceObjPtr dev);
|
|
|
|
int
|
|
virNodeDeviceObjListGetParentHost(virNodeDeviceObjListPtr devs,
|
|
virNodeDeviceDefPtr def);
|
|
|
|
virNodeDeviceObjListPtr
|
|
virNodeDeviceObjListNew(void);
|
|
|
|
void
|
|
virNodeDeviceObjListFree(virNodeDeviceObjListPtr devs);
|
|
|
|
typedef bool
|
|
(*virNodeDeviceObjListFilter)(virConnectPtr conn,
|
|
virNodeDeviceDefPtr def);
|
|
|
|
int
|
|
virNodeDeviceObjListNumOfDevices(virNodeDeviceObjListPtr devs,
|
|
virConnectPtr conn,
|
|
const char *cap,
|
|
virNodeDeviceObjListFilter filter);
|
|
|
|
int
|
|
virNodeDeviceObjListGetNames(virNodeDeviceObjListPtr devs,
|
|
virConnectPtr conn,
|
|
virNodeDeviceObjListFilter filter,
|
|
const char *cap,
|
|
char **const names,
|
|
int maxnames);
|
|
|
|
int
|
|
virNodeDeviceObjListExport(virConnectPtr conn,
|
|
virNodeDeviceObjListPtr devobjs,
|
|
virNodeDevicePtr **devices,
|
|
virNodeDeviceObjListFilter filter,
|
|
unsigned int flags);
|
|
|
|
void
|
|
virNodeDeviceObjSetSkipUpdateCaps(virNodeDeviceObjPtr obj,
|
|
bool skipUpdateCaps);
|
|
virNodeDeviceObjPtr
|
|
virNodeDeviceObjListFindMediatedDeviceByUUID(virNodeDeviceObjListPtr devs,
|
|
const char *uuid);
|