2009-07-15 17:34:04 +00:00
|
|
|
/*
|
|
|
|
* interface_conf.h: interface XML handling entry points
|
|
|
|
*
|
maint: avoid 'const fooPtr' in conf
'const fooPtr' is the same as 'foo * const' (the pointer won't
change, but it's contents can). But in general, if an interface
is trying to be const-correct, it should be using 'const foo *'
(the pointer is to data that can't be changed).
Fix up remaining offenders in src/conf, and their fallout.
* src/conf/snapshot_conf.h (virDomainSnapshotAssignDef)
(virDomainSnapshotFindByName): Drop attempt at const.
* src/conf/interface_conf.h (virInterfaceObjIsActive)
(virInterfaceDefFormat): Use intended type.
(virInterfaceFindByMACString, virInterfaceFindByName)
(virInterfaceAssignDef, virInterfaceRemove): Drop attempt at
const.
* src/conf/network_conf.h (virNetworkObjIsActive)
(virNetworkDefFormat, virNetworkDefForwardIf)
(virNetworkDefGetIpByIndex, virNetworkIpDefPrefix)
(virNetworkIpDefNetmask): Use intended type.
(virNetworkFindByUUID, virNetworkFindByName, virNetworkAssignDef)
(virNetworkObjAssignDef, virNetworkRemoveInactive)
(virNetworkBridgeInUse, virNetworkSetBridgeName)
(virNetworkAllocateBridge): Drop attempt at const.
* src/conf/netdev_vlan_conf.h (virNetDevVlanFormat): Make
const-correct.
* src/conf/node_device_conf.h (virNodeDeviceHasCap)
(virNodeDeviceDefFormat): Use intended type.
(virNodeDeviceFindByName, virNodeDeviceFindBySysfsPath)
(virNodeDeviceAssignDef, virNodeDeviceObjRemove)
(virNodeDeviceGetParentHost): Drop attempt at const.
* src/conf/secret_conf.h (virSecretDefFormat): Use intended type.
* src/conf/snapshot_conf.c (virDomainSnapshotAssignDef)
(virDomainSnapshotFindByName): Fix fallout.
* src/conf/interface_conf.c (virInterfaceBridgeDefFormat)
(virInterfaceBondDefFormat, virInterfaceVlanDefFormat)
(virInterfaceProtocolDefFormat, virInterfaceDefDevFormat)
(virInterfaceDefFormat, virInterfaceFindByMACString)
(virInterfaceFindByName, virInterfaceAssignDef)
(virInterfaceRemove): Likewise.
* src/conf/network_conf.c
(VIR_ENUM_IMPL, virNetworkFindByName, virNetworkObjAssignDef)
(virNetworkAssignDef, virNetworkRemoveInactive)
(virNetworkDefGetIpByIndex, virNetworkIpDefPrefix)
(virNetworkIpDefNetmask, virNetworkDHCPHostDefParseXML)
(virNetworkIpDefFormat, virNetworkRouteDefFormat)
(virPortGroupDefFormat, virNetworkForwardNatDefFormat)
(virNetworkDefFormatInternal, virNetworkBridgeInUse)
(virNetworkAllocateBridge, virNetworkSetBridgeName)
(virNetworkDNSDefFormat, virNetworkDefFormat): Likewise.
* src/conf/netdev_vlan_conf.c (virNetDevVlanFormat): Likewise.
* src/conf/node_device_conf.c (virNodeDeviceHasCap)
(virNodeDeviceFindBySysfsPath, virNodeDeviceFindByName)
(virNodeDeviceAssignDef, virNodeDeviceObjRemove)
(virNodeDeviceDefFormat, virNodeDeviceGetParentHost): Likewise.
* src/conf/secret_conf.c (virSecretDefFormatUsage)
(virSecretDefFormat): Likewise.
Signed-off-by: Eric Blake <eblake@redhat.com>
2013-10-08 16:36:37 +00:00
|
|
|
* Copyright (C) 2006-2009, 2013 Red Hat, Inc.
|
2009-07-15 17:34:04 +00:00
|
|
|
*
|
|
|
|
* 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
|
2012-09-20 22:30:55 +00:00
|
|
|
* License along with this library. If not, see
|
2012-07-21 10:06:23 +00:00
|
|
|
* <http://www.gnu.org/licenses/>.
|
2009-07-15 17:34:04 +00:00
|
|
|
*/
|
|
|
|
|
2019-06-07 20:20:21 +00:00
|
|
|
#pragma once
|
2009-07-15 17:34:04 +00:00
|
|
|
|
2019-06-07 20:20:21 +00:00
|
|
|
#include <libxml/parser.h>
|
|
|
|
#include <libxml/tree.h>
|
|
|
|
#include <libxml/xpath.h>
|
2009-07-15 17:34:04 +00:00
|
|
|
|
2019-06-07 20:20:21 +00:00
|
|
|
#include "internal.h"
|
|
|
|
#include "virthread.h"
|
|
|
|
#include "device_conf.h"
|
|
|
|
#include "virenum.h"
|
2009-07-15 17:34:04 +00:00
|
|
|
|
|
|
|
/* There is currently 3 types of interfaces */
|
|
|
|
|
2014-04-28 00:15:22 +00:00
|
|
|
typedef enum {
|
2009-07-15 17:34:04 +00:00
|
|
|
VIR_INTERFACE_TYPE_ETHERNET, /* simple ethernet */
|
|
|
|
VIR_INTERFACE_TYPE_BRIDGE, /* bridge interface */
|
|
|
|
VIR_INTERFACE_TYPE_BOND, /* bonding interface */
|
|
|
|
VIR_INTERFACE_TYPE_VLAN, /* vlan description */
|
|
|
|
|
|
|
|
VIR_INTERFACE_TYPE_LAST,
|
2014-04-28 00:15:22 +00:00
|
|
|
} virInterfaceType;
|
2009-07-15 17:34:04 +00:00
|
|
|
|
2019-01-20 16:04:56 +00:00
|
|
|
VIR_ENUM_DECL(virInterface);
|
2009-07-15 17:34:04 +00:00
|
|
|
|
|
|
|
/* types of start mode */
|
|
|
|
|
2014-04-28 00:15:22 +00:00
|
|
|
typedef enum {
|
2009-10-28 08:55:33 +00:00
|
|
|
VIR_INTERFACE_START_UNSPECIFIED = 0, /* not given in config */
|
|
|
|
VIR_INTERFACE_START_NONE, /* specified as not defined */
|
2009-07-15 17:34:04 +00:00
|
|
|
VIR_INTERFACE_START_ONBOOT, /* startup at boot */
|
|
|
|
VIR_INTERFACE_START_HOTPLUG, /* on hotplug */
|
2014-04-28 00:15:22 +00:00
|
|
|
} virInterfaceStartMode;
|
2009-07-15 17:34:04 +00:00
|
|
|
|
2014-04-28 00:15:22 +00:00
|
|
|
typedef enum {
|
2009-07-15 17:34:04 +00:00
|
|
|
VIR_INTERFACE_BOND_NONE = 0,
|
|
|
|
VIR_INTERFACE_BOND_BALRR, /* balance-rr */
|
|
|
|
VIR_INTERFACE_BOND_ABACKUP, /* active backup */
|
|
|
|
VIR_INTERFACE_BOND_BALXOR, /* balance-xor */
|
|
|
|
VIR_INTERFACE_BOND_BCAST, /* broadcast */
|
|
|
|
VIR_INTERFACE_BOND_8023AD, /* 802.3ad */
|
|
|
|
VIR_INTERFACE_BOND_BALTLB, /* balance-tlb */
|
|
|
|
VIR_INTERFACE_BOND_BALALB, /* balance-alb */
|
2014-04-28 00:15:22 +00:00
|
|
|
} virInterfaceBondMode;
|
2009-07-15 17:34:04 +00:00
|
|
|
|
2014-04-28 00:15:22 +00:00
|
|
|
typedef enum {
|
2009-07-15 17:34:04 +00:00
|
|
|
VIR_INTERFACE_BOND_MONIT_NONE = 0,
|
|
|
|
VIR_INTERFACE_BOND_MONIT_MII, /* mii based monitoring */
|
|
|
|
VIR_INTERFACE_BOND_MONIT_ARP, /* arp based monitoring */
|
2014-04-28 00:15:22 +00:00
|
|
|
} virInterfaceBondMonit;
|
2009-07-15 17:34:04 +00:00
|
|
|
|
2014-04-28 00:15:22 +00:00
|
|
|
typedef enum {
|
2009-07-15 17:34:04 +00:00
|
|
|
VIR_INTERFACE_BOND_MII_NONE = 0,
|
|
|
|
VIR_INTERFACE_BOND_MII_IOCTL, /* mii/ethtool ioctl */
|
|
|
|
VIR_INTERFACE_BOND_MII_NETIF, /* netif_carrier_ok */
|
2014-04-28 00:15:22 +00:00
|
|
|
} virInterfaceBondMiiCarrier;
|
2009-07-15 17:34:04 +00:00
|
|
|
|
2014-04-28 00:15:22 +00:00
|
|
|
typedef enum {
|
2009-07-15 17:34:04 +00:00
|
|
|
VIR_INTERFACE_BOND_ARP_NONE = 0,
|
|
|
|
VIR_INTERFACE_BOND_ARP_ACTIVE, /* validate active */
|
|
|
|
VIR_INTERFACE_BOND_ARP_BACKUP, /* validate backup */
|
|
|
|
VIR_INTERFACE_BOND_ARP_ALL, /* validate all */
|
2014-04-28 00:15:22 +00:00
|
|
|
} virInterfaceBondArpValid;
|
2009-07-15 17:34:04 +00:00
|
|
|
|
2010-01-02 01:40:25 +00:00
|
|
|
struct _virInterfaceDef; /* forward declaration required for bridge/bond */
|
2009-07-15 17:34:04 +00:00
|
|
|
|
|
|
|
typedef struct _virInterfaceBridgeDef virInterfaceBridgeDef;
|
|
|
|
typedef virInterfaceBridgeDef *virInterfaceBridgeDefPtr;
|
|
|
|
struct _virInterfaceBridgeDef {
|
|
|
|
int stp; /* 0, 1 or -1 if undefined */
|
2010-01-02 01:40:23 +00:00
|
|
|
char *delay;
|
2009-07-15 17:34:04 +00:00
|
|
|
int nbItf; /* number of defined interfaces */
|
2010-01-02 01:40:25 +00:00
|
|
|
struct _virInterfaceDef **itf;/* interfaces */
|
2009-07-15 17:34:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _virInterfaceBondDef virInterfaceBondDef;
|
|
|
|
typedef virInterfaceBondDef *virInterfaceBondDefPtr;
|
|
|
|
struct _virInterfaceBondDef {
|
|
|
|
int mode; /* virInterfaceBondMode */
|
|
|
|
int monit; /* virInterfaceBondMonit */
|
|
|
|
int frequency; /* miimon frequency in ms */
|
|
|
|
int downdelay; /* miimon downdelay */
|
|
|
|
int updelay; /* miimon updelay */
|
|
|
|
int carrier; /* virInterfaceBondMiiCarrier */
|
|
|
|
int interval; /* arp monitoring interval */
|
|
|
|
char *target; /* arp monitoring target */
|
|
|
|
int validate; /* virInterfaceBondArpmValid */
|
|
|
|
int nbItf; /* number of defined interfaces */
|
2010-01-02 01:40:25 +00:00
|
|
|
struct _virInterfaceDef **itf; /* interfaces ethernet only */
|
2009-07-15 17:34:04 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
typedef struct _virInterfaceVlanDef virInterfaceVlanDef;
|
|
|
|
typedef virInterfaceVlanDef *virInterfaceVlanDefPtr;
|
|
|
|
struct _virInterfaceVlanDef {
|
|
|
|
char *tag; /* TAG for vlan */
|
2014-10-01 14:07:46 +00:00
|
|
|
char *dev_name; /* device name for vlan */
|
2009-07-15 17:34:04 +00:00
|
|
|
};
|
|
|
|
|
2016-06-08 16:48:50 +00:00
|
|
|
typedef struct _virInterfaceIPDef virInterfaceIPDef;
|
|
|
|
typedef virInterfaceIPDef *virInterfaceIPDefPtr;
|
|
|
|
struct _virInterfaceIPDef {
|
2009-10-28 13:13:18 +00:00
|
|
|
char *address; /* ip address */
|
|
|
|
int prefix; /* ip prefix */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
2009-07-15 17:34:04 +00:00
|
|
|
typedef struct _virInterfaceProtocolDef virInterfaceProtocolDef;
|
|
|
|
typedef virInterfaceProtocolDef *virInterfaceProtocolDefPtr;
|
|
|
|
struct _virInterfaceProtocolDef {
|
2009-10-28 13:13:18 +00:00
|
|
|
char *family; /* ipv4 or ipv6 */
|
2009-07-15 17:34:04 +00:00
|
|
|
int dhcp; /* use dhcp */
|
|
|
|
int peerdns; /* dhcp peerdns ? */
|
2009-10-28 13:13:18 +00:00
|
|
|
int autoconf; /* only useful if family is ipv6 */
|
|
|
|
int nips;
|
2016-06-08 16:48:50 +00:00
|
|
|
virInterfaceIPDefPtr *ips; /* ptr to array of ips[nips] */
|
2009-07-15 17:34:04 +00:00
|
|
|
char *gateway; /* route gateway */
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
typedef struct _virInterfaceDef virInterfaceDef;
|
|
|
|
typedef virInterfaceDef *virInterfaceDefPtr;
|
|
|
|
struct _virInterfaceDef {
|
|
|
|
int type; /* interface type */
|
|
|
|
char *name; /* interface name */
|
|
|
|
unsigned int mtu; /* maximum transmit size in byte */
|
|
|
|
char *mac; /* MAC address */
|
2016-06-13 17:06:15 +00:00
|
|
|
virNetDevIfLink lnk; /* interface link info */
|
2009-07-15 17:34:04 +00:00
|
|
|
|
2014-04-28 00:15:22 +00:00
|
|
|
virInterfaceStartMode startmode; /* how it is started */
|
2009-07-15 17:34:04 +00:00
|
|
|
|
|
|
|
union {
|
|
|
|
virInterfaceBridgeDef bridge;
|
|
|
|
virInterfaceVlanDef vlan;
|
|
|
|
virInterfaceBondDef bond;
|
|
|
|
} data;
|
|
|
|
|
2009-10-28 13:13:18 +00:00
|
|
|
int nprotos;
|
|
|
|
virInterfaceProtocolDefPtr *protos; /* ptr to array of protos[nprotos] */
|
2009-07-15 17:34:04 +00:00
|
|
|
};
|
|
|
|
|
2017-03-02 17:01:29 +00:00
|
|
|
void
|
|
|
|
virInterfaceDefFree(virInterfaceDefPtr def);
|
2009-07-15 17:34:04 +00:00
|
|
|
|
2017-03-02 17:01:29 +00:00
|
|
|
virInterfaceDefPtr
|
|
|
|
virInterfaceDefParseString(const char *xmlStr);
|
2009-07-15 17:34:04 +00:00
|
|
|
|
2017-03-02 17:01:29 +00:00
|
|
|
virInterfaceDefPtr
|
|
|
|
virInterfaceDefParseFile(const char *filename);
|
|
|
|
|
|
|
|
virInterfaceDefPtr
|
|
|
|
virInterfaceDefParseNode(xmlDocPtr xml,
|
|
|
|
xmlNodePtr root);
|
|
|
|
|
|
|
|
char *
|
|
|
|
virInterfaceDefFormat(const virInterfaceDef *def);
|
2009-07-15 17:34:04 +00:00
|
|
|
|
2019-06-07 20:20:21 +00:00
|
|
|
#define VIR_CONNECT_LIST_INTERFACES_FILTERS_ACTIVE \
|
2013-05-21 13:29:38 +00:00
|
|
|
(VIR_CONNECT_LIST_INTERFACES_ACTIVE | \
|
|
|
|
VIR_CONNECT_LIST_INTERFACES_INACTIVE)
|