libvirt/src/conf/device_conf.h

204 lines
6.2 KiB
C
Raw Normal View History

/*
* device_conf.h: device XML handling entry points
*
* Copyright (C) 2006-2012, 2014-2016 Red Hat, Inc.
*
* 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/>.
*
* Author: Daniel P. Berrange <berrange@redhat.com>
*/
#ifndef __DEVICE_CONF_H__
# define __DEVICE_CONF_H__
# include <libxml/parser.h>
# include <libxml/tree.h>
# include <libxml/xpath.h>
# include "internal.h"
2012-12-13 17:44:57 +00:00
# include "virutil.h"
# include "virthread.h"
# include "virbuffer.h"
# include "virpci.h"
typedef enum {
VIR_INTERFACE_STATE_UNKNOWN = 1,
VIR_INTERFACE_STATE_NOT_PRESENT,
VIR_INTERFACE_STATE_DOWN,
VIR_INTERFACE_STATE_LOWER_LAYER_DOWN,
VIR_INTERFACE_STATE_TESTING,
VIR_INTERFACE_STATE_DORMANT,
VIR_INTERFACE_STATE_UP,
VIR_INTERFACE_STATE_LAST
} virInterfaceState;
VIR_ENUM_DECL(virInterfaceState)
typedef struct _virInterfaceLink virInterfaceLink;
typedef virInterfaceLink *virInterfaceLinkPtr;
struct _virInterfaceLink {
virInterfaceState state; /* link state */
unsigned int speed; /* link speed in Mbits per second */
};
typedef enum {
VIR_NET_DEV_FEAT_GRXCSUM,
VIR_NET_DEV_FEAT_GTXCSUM,
VIR_NET_DEV_FEAT_GSG,
VIR_NET_DEV_FEAT_GTSO,
VIR_NET_DEV_FEAT_GGSO,
VIR_NET_DEV_FEAT_GGRO,
VIR_NET_DEV_FEAT_LRO,
VIR_NET_DEV_FEAT_RXVLAN,
VIR_NET_DEV_FEAT_TXVLAN,
VIR_NET_DEV_FEAT_NTUPLE,
VIR_NET_DEV_FEAT_RXHASH,
VIR_NET_DEV_FEAT_RDMA,
VIR_NET_DEV_FEAT_TXUDPTNL,
VIR_NET_DEV_FEAT_LAST
} virNetDevFeature;
VIR_ENUM_DECL(virNetDevFeature)
typedef enum {
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE,
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI,
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE,
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_SERIAL,
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCID,
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_USB,
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_SPAPRVIO,
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_S390,
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_CCW,
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_VIRTIO_MMIO,
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_ISA,
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DIMM,
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_LAST
} virDomainDeviceAddressType;
typedef struct _virDomainDeviceDriveAddress {
unsigned int controller;
unsigned int bus;
unsigned int target;
unsigned int unit;
} virDomainDeviceDriveAddress, *virDomainDeviceDriveAddressPtr;
typedef struct _virDomainDeviceVirtioSerialAddress {
unsigned int controller;
unsigned int bus;
unsigned int port;
} virDomainDeviceVirtioSerialAddress, *virDomainDeviceVirtioSerialAddressPtr;
# define VIR_DOMAIN_DEVICE_CCW_MAX_CSSID 254
# define VIR_DOMAIN_DEVICE_CCW_MAX_SSID 3
# define VIR_DOMAIN_DEVICE_CCW_MAX_DEVNO 65535
typedef struct _virDomainDeviceCCWAddress {
unsigned int cssid;
unsigned int ssid;
unsigned int devno;
bool assigned;
} virDomainDeviceCCWAddress, *virDomainDeviceCCWAddressPtr;
typedef struct _virDomainDeviceCcidAddress {
unsigned int controller;
unsigned int slot;
} virDomainDeviceCcidAddress, *virDomainDeviceCcidAddressPtr;
typedef struct _virDomainDeviceUSBAddress {
unsigned int bus;
char *port;
} virDomainDeviceUSBAddress, *virDomainDeviceUSBAddressPtr;
typedef struct _virDomainDeviceSpaprVioAddress {
unsigned long long reg;
bool has_reg;
} virDomainDeviceSpaprVioAddress, *virDomainDeviceSpaprVioAddressPtr;
typedef enum {
VIR_DOMAIN_CONTROLLER_MASTER_NONE,
VIR_DOMAIN_CONTROLLER_MASTER_USB,
VIR_DOMAIN_CONTROLLER_MASTER_LAST
} virDomainControllerMaster;
typedef struct _virDomainDeviceUSBMaster {
unsigned int startport;
} virDomainDeviceUSBMaster, *virDomainDeviceUSBMasterPtr;
typedef struct _virDomainDeviceISAAddress {
unsigned int iobase;
unsigned int irq;
} virDomainDeviceISAAddress, *virDomainDeviceISAAddressPtr;
typedef struct _virDomainDeviceDimmAddress {
unsigned int slot;
unsigned long long base;
} virDomainDeviceDimmAddress, *virDomainDeviceDimmAddressPtr;
typedef struct _virDomainDeviceInfo {
/* If adding to this struct, ensure that
* virDomainDeviceInfoIsSet() is updated
* to consider the new fields
*/
char *alias;
int type; /* virDomainDeviceAddressType */
union {
virPCIDeviceAddress pci;
virDomainDeviceDriveAddress drive;
virDomainDeviceVirtioSerialAddress vioserial;
virDomainDeviceCcidAddress ccid;
virDomainDeviceUSBAddress usb;
virDomainDeviceSpaprVioAddress spaprvio;
virDomainDeviceCCWAddress ccw;
virDomainDeviceISAAddress isa;
virDomainDeviceDimmAddress dimm;
} addr;
int mastertype;
union {
virDomainDeviceUSBMaster usb;
} master;
/* rombar and romfile are only used for pci hostdev and network
* devices. */
int rombar; /* enum virTristateSwitch */
char *romfile;
/* bootIndex is only used for disk, network interface, hostdev
* and redirdev devices */
unsigned int bootIndex;
} virDomainDeviceInfo, *virDomainDeviceInfoPtr;
int virPCIDeviceAddressIsValid(virPCIDeviceAddressPtr addr,
conf: more useful error message when pci function is out of range If a pci address had a function number out of range, the error message would be: Insufficient specification for PCI address which is logged by virDevicePCIAddressParseXML() after virDevicePCIAddressIsValid returns a failure. This patch enhances virDevicePCIAddressIsValid() to optionally report the error itself (since it is the place that decides which part of the address is "invalid"), and uses that feature when calling from virDevicePCIAddressParseXML(), so that the error will be more useful, e.g.: Invalid PCI address function=0x8, must be <= 7 Previously, virDevicePCIAddressIsValid didn't check for the theoretical limits of domain or bus, only for slot or function. While adding log messages, we also correct that ommission. (The RNG for PCI addresses already enforces this limit, which by the way means that we can't add any negative tests for this - as far as I know our domainschematest has no provisions for passing XML that is supposed to fail). Note that virDevicePCIAddressIsValid() can only check against the absolute maximum attribute values for *any* possible PCI controller, not for the actual maximums of the specific controller that this device is attaching to; fortunately there is later more specific validation for guest-side PCI addresses when building the set of assigned PCI addresses. For host-side PCI addresses (e.g. for <hostdev> and for network device pools), we rely on the error that will be logged when it is found that the device doesn't actually exist. This resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1004596
2015-07-22 15:59:00 +00:00
bool report);
int virPCIDeviceAddressParseXML(xmlNodePtr node,
virPCIDeviceAddressPtr addr);
int virPCIDeviceAddressFormat(virBufferPtr buf,
virPCIDeviceAddress addr,
bool includeTypeInAddr);
bool virPCIDeviceAddressEqual(virPCIDeviceAddress *addr1,
virPCIDeviceAddress *addr2);
int virInterfaceLinkParseXML(xmlNodePtr node,
virInterfaceLinkPtr lnk);
int virInterfaceLinkFormat(virBufferPtr buf,
const virInterfaceLink *lnk);
#endif /* __DEVICE_CONF_H__ */