2008-11-21 12:20:45 +00:00
|
|
|
/*
|
|
|
|
* node_device_conf.h: config handling for node devices
|
|
|
|
*
|
2010-03-01 23:38:28 +00:00
|
|
|
* Copyright (C) 2010 Red Hat, Inc.
|
2008-11-21 12:20:45 +00:00
|
|
|
* 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, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*
|
|
|
|
* Author: David F. Lively <dlively@virtualiron.com>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __VIR_NODE_DEVICE_CONF_H__
|
2010-03-09 18:22:22 +00:00
|
|
|
# define __VIR_NODE_DEVICE_CONF_H__
|
2008-11-21 12:20:45 +00:00
|
|
|
|
2010-03-09 18:22:22 +00:00
|
|
|
# include "internal.h"
|
|
|
|
# include "util.h"
|
|
|
|
# include "threads.h"
|
2008-11-21 12:20:45 +00:00
|
|
|
|
2010-03-09 18:22:22 +00:00
|
|
|
# include <libxml/tree.h>
|
2009-10-02 14:03:55 +00:00
|
|
|
|
2010-03-09 18:22:22 +00:00
|
|
|
# define CREATE_DEVICE 1
|
|
|
|
# define EXISTING_DEVICE 0
|
2009-06-02 15:12:53 +00:00
|
|
|
|
2008-11-21 12:20:45 +00:00
|
|
|
enum virNodeDevCapType {
|
|
|
|
/* Keep in sync with VIR_ENUM_IMPL in node_device_conf.c */
|
|
|
|
VIR_NODE_DEV_CAP_SYSTEM, /* System capability */
|
|
|
|
VIR_NODE_DEV_CAP_PCI_DEV, /* PCI device */
|
|
|
|
VIR_NODE_DEV_CAP_USB_DEV, /* USB device */
|
|
|
|
VIR_NODE_DEV_CAP_USB_INTERFACE, /* USB interface */
|
|
|
|
VIR_NODE_DEV_CAP_NET, /* Network device */
|
|
|
|
VIR_NODE_DEV_CAP_SCSI_HOST, /* SCSI Host Bus Adapter */
|
2009-11-12 22:03:47 +00:00
|
|
|
VIR_NODE_DEV_CAP_SCSI_TARGET, /* SCSI Target */
|
2008-11-21 12:20:45 +00:00
|
|
|
VIR_NODE_DEV_CAP_SCSI, /* SCSI device */
|
|
|
|
VIR_NODE_DEV_CAP_STORAGE, /* Storage device */
|
|
|
|
VIR_NODE_DEV_CAP_LAST
|
|
|
|
};
|
|
|
|
|
|
|
|
enum virNodeDevNetCapType {
|
|
|
|
/* Keep in sync with VIR_ENUM_IMPL in node_device_conf.c */
|
|
|
|
VIR_NODE_DEV_CAP_NET_80203, /* 802.03 network device */
|
|
|
|
VIR_NODE_DEV_CAP_NET_80211, /* 802.11 network device */
|
|
|
|
VIR_NODE_DEV_CAP_NET_LAST
|
|
|
|
};
|
|
|
|
|
2009-06-02 15:12:53 +00:00
|
|
|
enum virNodeDevHBACapType {
|
|
|
|
/* Keep in sync with VIR_ENUM_IMPL in node_device_conf.c */
|
|
|
|
VIR_NODE_DEV_CAP_HBA_FC_HOST, /* fibre channel HBA */
|
|
|
|
VIR_NODE_DEV_CAP_HBA_VPORT_OPS, /* capable of vport operations */
|
|
|
|
VIR_NODE_DEV_CAP_HBA_LAST
|
|
|
|
};
|
|
|
|
|
2008-12-17 21:09:44 +00:00
|
|
|
VIR_ENUM_DECL(virNodeDevCap)
|
|
|
|
VIR_ENUM_DECL(virNodeDevNetCap)
|
2009-06-02 15:12:53 +00:00
|
|
|
VIR_ENUM_DECL(virNodeDevHBACap)
|
2008-11-21 12:20:45 +00:00
|
|
|
|
|
|
|
enum virNodeDevStorageCapFlags {
|
|
|
|
VIR_NODE_DEV_CAP_STORAGE_REMOVABLE = (1 << 0),
|
|
|
|
VIR_NODE_DEV_CAP_STORAGE_REMOVABLE_MEDIA_AVAILABLE = (1 << 1),
|
|
|
|
VIR_NODE_DEV_CAP_STORAGE_HOTPLUGGABLE = (1 << 2),
|
|
|
|
};
|
|
|
|
|
2009-06-02 15:12:53 +00:00
|
|
|
enum virNodeDevScsiHostCapFlags {
|
|
|
|
VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST = (1 << 0),
|
|
|
|
VIR_NODE_DEV_CAP_FLAG_HBA_VPORT_OPS = (1 << 1),
|
|
|
|
};
|
|
|
|
|
2009-12-14 13:44:12 +00:00
|
|
|
enum virNodeDevPCICapFlags {
|
|
|
|
VIR_NODE_DEV_CAP_FLAG_PCI_PHYSICAL_FUNCTION = (1 << 0),
|
|
|
|
VIR_NODE_DEV_CAP_FLAG_PCI_VIRTUAL_FUNCTION = (1 << 1),
|
|
|
|
};
|
|
|
|
|
|
|
|
struct pci_config_address {
|
|
|
|
unsigned domain;
|
|
|
|
unsigned bus;
|
|
|
|
unsigned slot;
|
|
|
|
unsigned function;
|
|
|
|
};
|
|
|
|
|
2008-11-21 12:20:45 +00:00
|
|
|
typedef struct _virNodeDevCapsDef virNodeDevCapsDef;
|
|
|
|
typedef virNodeDevCapsDef *virNodeDevCapsDefPtr;
|
|
|
|
struct _virNodeDevCapsDef {
|
|
|
|
enum virNodeDevCapType type;
|
|
|
|
union _virNodeDevCapData {
|
|
|
|
struct {
|
|
|
|
char *product_name;
|
|
|
|
struct {
|
|
|
|
char *vendor_name;
|
|
|
|
char *version;
|
|
|
|
char *serial;
|
|
|
|
unsigned char uuid[VIR_UUID_BUFLEN];
|
|
|
|
} hardware;
|
|
|
|
struct {
|
|
|
|
char *vendor_name;
|
|
|
|
char *version;
|
|
|
|
char *release_date;
|
|
|
|
} firmware;
|
|
|
|
} system;
|
|
|
|
struct {
|
|
|
|
unsigned domain;
|
|
|
|
unsigned bus;
|
|
|
|
unsigned slot;
|
|
|
|
unsigned function;
|
|
|
|
unsigned product;
|
|
|
|
unsigned vendor;
|
2009-11-12 21:39:40 +00:00
|
|
|
unsigned class;
|
2008-11-21 12:20:45 +00:00
|
|
|
char *product_name;
|
|
|
|
char *vendor_name;
|
2009-12-14 13:44:12 +00:00
|
|
|
struct pci_config_address *physical_function;
|
|
|
|
struct pci_config_address **virtual_functions;
|
|
|
|
unsigned num_virtual_functions;
|
|
|
|
unsigned flags;
|
2008-11-21 12:20:45 +00:00
|
|
|
} pci_dev;
|
|
|
|
struct {
|
|
|
|
unsigned bus;
|
|
|
|
unsigned device;
|
|
|
|
unsigned product;
|
|
|
|
unsigned vendor;
|
|
|
|
char *product_name;
|
|
|
|
char *vendor_name;
|
|
|
|
} usb_dev;
|
|
|
|
struct {
|
|
|
|
unsigned number;
|
|
|
|
unsigned _class; /* "class" is reserved in C */
|
|
|
|
unsigned subclass;
|
|
|
|
unsigned protocol;
|
|
|
|
char *description;
|
|
|
|
} usb_if;
|
|
|
|
struct {
|
|
|
|
char *address;
|
2009-11-12 21:39:40 +00:00
|
|
|
unsigned address_len;
|
2008-11-25 10:37:02 +00:00
|
|
|
char *ifname;
|
2008-11-21 12:20:45 +00:00
|
|
|
enum virNodeDevNetCapType subtype; /* LAST -> no subtype */
|
|
|
|
} net;
|
|
|
|
struct {
|
|
|
|
unsigned host;
|
2009-06-02 15:12:53 +00:00
|
|
|
char *wwnn;
|
|
|
|
char *wwpn;
|
|
|
|
unsigned flags;
|
2008-11-21 12:20:45 +00:00
|
|
|
} scsi_host;
|
2009-11-12 22:03:47 +00:00
|
|
|
struct {
|
|
|
|
char *name;
|
|
|
|
} scsi_target;
|
2008-11-21 12:20:45 +00:00
|
|
|
struct {
|
|
|
|
unsigned host;
|
|
|
|
unsigned bus;
|
|
|
|
unsigned target;
|
|
|
|
unsigned lun;
|
|
|
|
char *type;
|
|
|
|
} scsi;
|
|
|
|
struct {
|
|
|
|
unsigned long long size;
|
2009-11-12 21:39:40 +00:00
|
|
|
unsigned long long num_blocks;
|
|
|
|
unsigned long long logical_block_size;
|
2008-11-21 12:20:45 +00:00
|
|
|
unsigned long long removable_media_size;
|
2008-11-21 12:46:39 +00:00
|
|
|
char *block;
|
2008-11-21 12:20:45 +00:00
|
|
|
char *bus;
|
|
|
|
char *drive_type;
|
|
|
|
char *model;
|
|
|
|
char *vendor;
|
2009-06-11 14:25:19 +00:00
|
|
|
char *serial;
|
2009-12-14 13:58:23 +00:00
|
|
|
char *media_label;
|
2008-11-21 12:20:45 +00:00
|
|
|
unsigned flags; /* virNodeDevStorageCapFlags bits */
|
|
|
|
} storage;
|
|
|
|
} data;
|
|
|
|
virNodeDevCapsDefPtr next; /* next capability */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct _virNodeDeviceDef virNodeDeviceDef;
|
|
|
|
typedef virNodeDeviceDef *virNodeDeviceDefPtr;
|
|
|
|
struct _virNodeDeviceDef {
|
|
|
|
char *name; /* device name (unique on node) */
|
2009-11-12 21:48:24 +00:00
|
|
|
char *sysfs_path; /* udev name/sysfs path */
|
2008-11-21 12:20:45 +00:00
|
|
|
char *parent; /* optional parent device name */
|
2009-11-12 21:48:24 +00:00
|
|
|
char *parent_sysfs_path; /* udev parent name/sysfs path */
|
2009-06-12 13:12:55 +00:00
|
|
|
char *driver; /* optional driver name */
|
2008-11-21 12:20:45 +00:00
|
|
|
virNodeDevCapsDefPtr caps; /* optional device capabilities */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct _virNodeDeviceObj virNodeDeviceObj;
|
|
|
|
typedef virNodeDeviceObj *virNodeDeviceObjPtr;
|
|
|
|
struct _virNodeDeviceObj {
|
2009-01-15 19:56:05 +00:00
|
|
|
virMutex lock;
|
2008-12-04 22:00:14 +00:00
|
|
|
|
2008-11-21 12:20:45 +00:00
|
|
|
virNodeDeviceDefPtr def; /* device definition */
|
|
|
|
void *privateData; /* driver-specific private data */
|
|
|
|
void (*privateFree)(void *data); /* destructor for private data */
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _virNodeDeviceObjList virNodeDeviceObjList;
|
|
|
|
typedef virNodeDeviceObjList *virNodeDeviceObjListPtr;
|
|
|
|
struct _virNodeDeviceObjList {
|
|
|
|
unsigned int count;
|
|
|
|
virNodeDeviceObjPtr *objs;
|
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _virDeviceMonitorState virDeviceMonitorState;
|
|
|
|
typedef virDeviceMonitorState *virDeviceMonitorStatePtr;
|
|
|
|
struct _virDeviceMonitorState {
|
2009-01-15 19:56:05 +00:00
|
|
|
virMutex lock;
|
2008-12-04 21:48:31 +00:00
|
|
|
|
2008-11-21 12:20:45 +00:00
|
|
|
virNodeDeviceObjList devs; /* currently-known devices */
|
|
|
|
void *privateData; /* driver-specific private data */
|
|
|
|
};
|
|
|
|
|
2010-03-09 18:22:22 +00:00
|
|
|
# define virNodeDeviceReportError(code, ...) \
|
2010-02-10 10:40:18 +00:00
|
|
|
virReportErrorHelper(NULL, VIR_FROM_NODEDEV, code, __FILE__, \
|
2010-03-01 23:38:28 +00:00
|
|
|
__FUNCTION__, __LINE__, __VA_ARGS__)
|
2008-11-21 12:20:45 +00:00
|
|
|
|
2009-10-01 18:53:43 +00:00
|
|
|
int virNodeDeviceHasCap(const virNodeDeviceObjPtr dev, const char *cap);
|
|
|
|
|
2008-11-21 12:20:45 +00:00
|
|
|
virNodeDeviceObjPtr virNodeDeviceFindByName(const virNodeDeviceObjListPtr devs,
|
|
|
|
const char *name);
|
2009-11-12 21:48:24 +00:00
|
|
|
virNodeDeviceObjPtr
|
|
|
|
virNodeDeviceFindBySysfsPath(const virNodeDeviceObjListPtr devs,
|
|
|
|
const char *sysfs_path);
|
2008-11-21 12:20:45 +00:00
|
|
|
|
2010-02-10 10:40:18 +00:00
|
|
|
virNodeDeviceObjPtr virNodeDeviceAssignDef(virNodeDeviceObjListPtr devs,
|
2008-11-21 12:20:45 +00:00
|
|
|
const virNodeDeviceDefPtr def);
|
|
|
|
|
|
|
|
void virNodeDeviceObjRemove(virNodeDeviceObjListPtr devs,
|
|
|
|
const virNodeDeviceObjPtr dev);
|
|
|
|
|
2010-02-10 10:40:18 +00:00
|
|
|
char *virNodeDeviceDefFormat(const virNodeDeviceDefPtr def);
|
2008-11-21 12:20:45 +00:00
|
|
|
|
2010-02-10 10:40:18 +00:00
|
|
|
virNodeDeviceDefPtr virNodeDeviceDefParseString(const char *str,
|
2009-06-02 15:12:53 +00:00
|
|
|
int create);
|
2010-02-10 10:40:18 +00:00
|
|
|
virNodeDeviceDefPtr virNodeDeviceDefParseFile(const char *filename,
|
2009-10-02 14:03:55 +00:00
|
|
|
int create);
|
2010-02-10 10:40:18 +00:00
|
|
|
virNodeDeviceDefPtr virNodeDeviceDefParseNode(xmlDocPtr xml,
|
2009-10-02 14:03:55 +00:00
|
|
|
xmlNodePtr root,
|
|
|
|
int create);
|
2008-11-21 12:20:45 +00:00
|
|
|
|
2010-02-10 10:40:18 +00:00
|
|
|
int virNodeDeviceGetWWNs(virNodeDeviceDefPtr def,
|
2009-10-14 19:47:10 +00:00
|
|
|
char **wwnn,
|
|
|
|
char **wwpn);
|
|
|
|
|
2010-02-10 10:40:18 +00:00
|
|
|
int virNodeDeviceGetParentHost(const virNodeDeviceObjListPtr devs,
|
2009-10-14 19:47:10 +00:00
|
|
|
const char *dev_name,
|
|
|
|
const char *parent_name,
|
|
|
|
int *parent_host);
|
|
|
|
|
2008-11-21 12:20:45 +00:00
|
|
|
void virNodeDeviceDefFree(virNodeDeviceDefPtr def);
|
|
|
|
|
|
|
|
void virNodeDeviceObjFree(virNodeDeviceObjPtr dev);
|
|
|
|
|
|
|
|
void virNodeDeviceObjListFree(virNodeDeviceObjListPtr devs);
|
|
|
|
|
|
|
|
void virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps);
|
|
|
|
|
2008-12-04 20:53:20 +00:00
|
|
|
void virNodeDeviceObjLock(virNodeDeviceObjPtr obj);
|
|
|
|
void virNodeDeviceObjUnlock(virNodeDeviceObjPtr obj);
|
|
|
|
|
2008-11-21 12:20:45 +00:00
|
|
|
#endif /* __VIR_NODE_DEVICE_CONF_H__ */
|