mirror of
https://github.com/libvirt/libvirt.git
synced 2025-02-25 18:55:26 -06:00
This is not a 1:1 mapping to mdevctl commands because mdevctl doesn't support a separate 'create' command. mdevctl uses 'start' for both starting a pre-defined device as well as for creating and starting a new transient device. The libvirt code will be more readable if we treat these as separate commands. When we need to actually execute mdevctl, the 'create' command will be translated into the appropriate 'mdevctl start' command. Signed-off-by: Erik Skultety <eskultet@redhat.com> Reviewed-by: Jonathon Jongsma <jjongsma@redhat.com>
190 lines
5.3 KiB
C
190 lines
5.3 KiB
C
/*
|
|
* node_device_driver.h: node device enumeration
|
|
*
|
|
* Copyright (C) 2008 Virtual Iron Software, Inc.
|
|
* Copyright (C) 2008 David F. Lively
|
|
*
|
|
* 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 "driver.h"
|
|
#include "virnodedeviceobj.h"
|
|
#include "vircommand.h"
|
|
|
|
#define LINUX_NEW_DEVICE_WAIT_TIME 60
|
|
|
|
#ifdef WITH_UDEV
|
|
int
|
|
udevNodeRegister(void);
|
|
#endif
|
|
|
|
|
|
typedef enum {
|
|
MDEVCTL_CMD_START,
|
|
MDEVCTL_CMD_STOP,
|
|
MDEVCTL_CMD_DEFINE,
|
|
MDEVCTL_CMD_UNDEFINE,
|
|
|
|
/* mdevctl actually doesn't have a 'create' command, it will be replaced
|
|
* with 'start' eventually in nodeDeviceGetMdevctlCommand, but this clear
|
|
* separation makes our code more readable in terms of knowing when we're
|
|
* starting a defined device and when we're creating a transient one */
|
|
MDEVCTL_CMD_CREATE,
|
|
|
|
MDEVCTL_CMD_LAST,
|
|
} virMdevctlCommand;
|
|
|
|
VIR_ENUM_DECL(virMdevctlCommand);
|
|
|
|
|
|
void
|
|
nodeDeviceLock(void);
|
|
|
|
void
|
|
nodeDeviceUnlock(void);
|
|
|
|
extern virNodeDeviceDriverState *driver;
|
|
|
|
int
|
|
nodedevRegister(void);
|
|
|
|
virDrvOpenStatus nodeConnectOpen(virConnectPtr conn,
|
|
virConnectAuthPtr auth,
|
|
virConf *conf,
|
|
unsigned int flags);
|
|
int nodeConnectClose(virConnectPtr conn);
|
|
int nodeConnectIsSecure(virConnectPtr conn);
|
|
int nodeConnectIsEncrypted(virConnectPtr conn);
|
|
int nodeConnectIsAlive(virConnectPtr conn);
|
|
|
|
int
|
|
nodeNumOfDevices(virConnectPtr conn,
|
|
const char *cap,
|
|
unsigned int flags);
|
|
|
|
int nodeListDevices(virConnectPtr conn,
|
|
const char *cap,
|
|
char **const names,
|
|
int maxnames,
|
|
unsigned int flags);
|
|
|
|
int
|
|
nodeConnectListAllNodeDevices(virConnectPtr conn,
|
|
virNodeDevicePtr **devices,
|
|
unsigned int flags);
|
|
|
|
virNodeDevicePtr
|
|
nodeDeviceLookupByName(virConnectPtr conn,
|
|
const char *name);
|
|
|
|
virNodeDevicePtr
|
|
nodeDeviceLookupSCSIHostByWWN(virConnectPtr conn,
|
|
const char *wwnn,
|
|
const char *wwpn,
|
|
unsigned int flags);
|
|
|
|
char *
|
|
nodeDeviceGetXMLDesc(virNodeDevicePtr dev,
|
|
unsigned int flags);
|
|
|
|
char *
|
|
nodeDeviceGetParent(virNodeDevicePtr dev);
|
|
|
|
int
|
|
nodeDeviceNumOfCaps(virNodeDevicePtr dev);
|
|
|
|
int
|
|
nodeDeviceListCaps(virNodeDevicePtr dev,
|
|
char **const names,
|
|
int maxnames);
|
|
|
|
virNodeDevicePtr
|
|
nodeDeviceCreateXML(virConnectPtr conn,
|
|
const char *xmlDesc,
|
|
unsigned int flags);
|
|
|
|
int
|
|
nodeDeviceDestroy(virNodeDevicePtr dev);
|
|
|
|
virNodeDevice*
|
|
nodeDeviceDefineXML(virConnect *conn,
|
|
const char *xmlDesc,
|
|
unsigned int flags);
|
|
|
|
int
|
|
nodeDeviceUndefine(virNodeDevice *dev,
|
|
unsigned int flags);
|
|
|
|
int
|
|
nodeConnectNodeDeviceEventRegisterAny(virConnectPtr conn,
|
|
virNodeDevicePtr dev,
|
|
int eventID,
|
|
virConnectNodeDeviceEventGenericCallback callback,
|
|
void *opaque,
|
|
virFreeCallback freecb);
|
|
int
|
|
nodeConnectNodeDeviceEventDeregisterAny(virConnectPtr conn,
|
|
int callbackID);
|
|
|
|
virCommand *
|
|
nodeDeviceGetMdevctlCreateCommand(virNodeDeviceDef *def,
|
|
char **uuid_out,
|
|
char **errmsg);
|
|
|
|
virCommand*
|
|
nodeDeviceGetMdevctlDefineCommand(virNodeDeviceDef *def,
|
|
char **uuid_out,
|
|
char **errmsg);
|
|
|
|
virCommand *
|
|
nodeDeviceGetMdevctlStopCommand(const char *uuid,
|
|
char **errmsg);
|
|
|
|
virCommand *
|
|
nodeDeviceGetMdevctlUndefineCommand(const char *uuid,
|
|
char **errmsg);
|
|
|
|
virCommand *
|
|
nodeDeviceGetMdevctlListCommand(bool defined,
|
|
char **output,
|
|
char **errmsg);
|
|
|
|
int
|
|
nodeDeviceParseMdevctlJSON(const char *jsonstring,
|
|
virNodeDeviceDef ***devs);
|
|
|
|
int
|
|
nodeDeviceUpdateMediatedDevices(void);
|
|
|
|
void
|
|
nodeDeviceGenerateName(virNodeDeviceDef *def,
|
|
const char *subsystem,
|
|
const char *sysname,
|
|
const char *s);
|
|
|
|
bool nodeDeviceDefCopyFromMdevctl(virNodeDeviceDef *dst,
|
|
virNodeDeviceDef *src);
|
|
|
|
virCommand*
|
|
nodeDeviceGetMdevctlStartCommand(const char *uuid,
|
|
char **errmsg);
|
|
|
|
int
|
|
nodeDeviceCreate(virNodeDevice *dev,
|
|
unsigned int flags);
|