virtPortProfiles are currently only used in the domain XML, but will
soon also be used in the network XML. To prepare for that change, this
patch moves the structure definition into util/network.h and the parse
and format functions into util/network.c (I decided that this was a
better choice than macvtap.h/c for something that needed to always be
available on all platforms).
---
docs/schemas/Makefile.am | 1 +
docs/schemas/domain.rng | 45 +---------
docs/schemas/networkcommon.rng | 50 ++++++++++
libvirt.spec.in | 1 +
mingw32-libvirt.spec.in | 1 +
src/conf/domain_conf.c | 188 -------------------------------------
src/libvirt_private.syms | 2 +
src/util/macvtap.c | 6 +-
src/util/macvtap.h | 36 +-------
src/util/network.c | 200 ++++++++++++++++++++++++++++++++++++++++
src/util/network.h | 46 +++++++++
11 files changed, 308 insertions(+), 268 deletions(-)
create mode 100644 docs/schemas/networkcommon.rng
diff --git a/docs/schemas/Makefile.am b/docs/schemas/Makefile.am
index 5ef7737..75a0e73 100644
--- a/docs/schemas/Makefile.am
+++ b/docs/schemas/Makefile.am
@@ -8,6 +8,7 @@ schema_DATA = \
domainsnapshot.rng \
interface.rng \
network.rng \
+ networkcommon.rng \
nodedev.rng \
nwfilter.rng \
secret.rng \
diff --git a/docs/schemas/domain.rng b/docs/schemas/domain.rng
index 8a4e3fe..2f656ed 100644
--- a/docs/schemas/domain.rng
+++ b/docs/schemas/domain.rng
@@ -7,6 +7,7 @@
<include href='basictypes.rng'/>
<include href='storageencryption.rng'/>
+ <include href='networkcommon.rng'/>
<!--
description element, maybe placed anywhere under the root
@@ -1172,45 +1173,6 @@
</optional>
</interleave>
</define>
- <define name="virtualPortProfile">
- <choice>
- <group>
- <element name="virtualport">
- <attribute name="type">
- <value>802.1Qbg</value>
- </attribute>
- <element name="parameters">
- <attribute name="managerid">
- <ref name="uint8range"/>
- </attribute>
- <attribute name="typeid">
- <ref name="uint24range"/>
- </attribute>
- <attribute name="typeidversion">
- <ref name="uint8range"/>
- </attribute>
- <optional>
- <attribute name="instanceid">
- <ref name="UUID"/>
- </attribute>
- </optional>
- </element>
- </element>
- </group>
- <group>
- <element name="virtualport">
- <attribute name="type">
- <value>802.1Qbh</value>
- </attribute>
- <element name="parameters">
- <attribute name="profileid">
- <ref name="virtualPortProfileID"/>
- </attribute>
- </element>
- </element>
- </group>
- </choice>
- </define>
<!--
An emulator description is just a path to the binary used for the task
-->
@@ -2515,9 +2477,4 @@
<param name="pattern">[a-zA-Z0-9_\.:]+</param>
</data>
</define>
- <define name="virtualPortProfileID">
- <data type="string">
- <param name="maxLength">39</param>
- </data>
- </define>
</grammar>
diff --git a/docs/schemas/networkcommon.rng b/docs/schemas/networkcommon.rng
new file mode 100644
index 0000000..0251813
--- /dev/null
+++ b/docs/schemas/networkcommon.rng
@@ -0,0 +1,50 @@
+<?xml version="1.0"?>
+<!-- network-related definitions used in multiple grammars -->
+<grammar
xmlns="http://relaxng.org/ns/structure/1.0"
datatypeLibrary="http://www.w3.org/2001/XMLSchema-datatypes">
+
+ <define name="virtualPortProfileID">
+ <data type="string">
+ <param name="maxLength">39</param>
+ </data>
+ </define>
+
+ <define name="virtualPortProfile">
+ <choice>
+ <group>
+ <element name="virtualport">
+ <attribute name="type">
+ <value>802.1Qbg</value>
+ </attribute>
+ <element name="parameters">
+ <attribute name="managerid">
+ <ref name="uint8range"/>
+ </attribute>
+ <attribute name="typeid">
+ <ref name="uint24range"/>
+ </attribute>
+ <attribute name="typeidversion">
+ <ref name="uint8range"/>
+ </attribute>
+ <optional>
+ <attribute name="instanceid">
+ <ref name="UUID"/>
+ </attribute>
+ </optional>
+ </element>
+ </element>
+ </group>
+ <group>
+ <element name="virtualport">
+ <attribute name="type">
+ <value>802.1Qbh</value>
+ </attribute>
+ <element name="parameters">
+ <attribute name="profileid">
+ <ref name="virtualPortProfileID"/>
+ </attribute>
+ </element>
+ </element>
+ </group>
+ </choice>
+ </define>
+</grammar>
diff --git a/libvirt.spec.in b/libvirt.spec.in
index 667a1ba..6cbd9ac 100644
--- a/libvirt.spec.in
+++ b/libvirt.spec.in
@@ -1077,6 +1077,7 @@ fi
%{_datadir}/libvirt/schemas/storageencryption.rng
%{_datadir}/libvirt/schemas/nwfilter.rng
%{_datadir}/libvirt/schemas/basictypes.rng
+%{_datadir}/libvirt/schemas/networkcommon.rng
%{_datadir}/libvirt/cpu_map.xml
diff --git a/mingw32-libvirt.spec.in b/mingw32-libvirt.spec.in
index a8a39da..3958d33 100644
--- a/mingw32-libvirt.spec.in
+++ b/mingw32-libvirt.spec.in
@@ -109,6 +109,7 @@ rm -rf $RPM_BUILD_ROOT
%{_mingw32_datadir}/libvirt/schemas/secret.rng
%{_mingw32_datadir}/libvirt/schemas/storageencryption.rng
%{_mingw32_datadir}/libvirt/schemas/basictypes.rng
+%{_mingw32_datadir}/libvirt/schemas/networkcommon.rng
%{_mingw32_datadir}/libvirt/cpu_map.xml
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 3c3ab39..0af8860 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -467,11 +467,6 @@ VIR_ENUM_IMPL(virDomainSeclabel, VIR_DOMAIN_SECLABEL_LAST,
"dynamic",
"static")
-VIR_ENUM_IMPL(virVirtualPort, VIR_VIRTUALPORT_TYPE_LAST,
- "none",
- "802.1Qbg",
- "802.1Qbh")
-
VIR_ENUM_IMPL(virDomainClockOffset, VIR_DOMAIN_CLOCK_OFFSET_LAST,
"utc",
"localtime",
@@ -2591,146 +2586,6 @@ cleanup:
}
-static int
-virVirtualPortProfileParamsParseXML(xmlNodePtr node,
- virVirtualPortProfileParamsPtr virtPort)
-{
- int ret = -1;
- char *virtPortType;
- char *virtPortManagerID = NULL;
- char *virtPortTypeID = NULL;
- char *virtPortTypeIDVersion = NULL;
- char *virtPortInstanceID = NULL;
- char *virtPortProfileID = NULL;
- xmlNodePtr cur = node->children;
- const char *msg = NULL;
-
- virtPortType = virXMLPropString(node, "type");
- if (!virtPortType)
- return -1;
-
- while (cur != NULL) {
- if (xmlStrEqual(cur->name, BAD_CAST "parameters")) {
-
- virtPortManagerID = virXMLPropString(cur, "managerid");
- virtPortTypeID = virXMLPropString(cur, "typeid");
- virtPortTypeIDVersion = virXMLPropString(cur, "typeidversion");
- virtPortInstanceID = virXMLPropString(cur, "instanceid");
- virtPortProfileID = virXMLPropString(cur, "profileid");
-
- break;
- }
-
- cur = cur->next;
- }
-
- virtPort->virtPortType = VIR_VIRTUALPORT_NONE;
-
- switch (virVirtualPortTypeFromString(virtPortType)) {
-
- case VIR_VIRTUALPORT_8021QBG:
- if (virtPortManagerID != NULL && virtPortTypeID != NULL
&&
- virtPortTypeIDVersion != NULL) {
- unsigned int val;
-
- if (virStrToLong_ui(virtPortManagerID, NULL, 0, &val)) {
- msg = _("cannot parse value of managerid parameter");
- goto err_exit;
- }
-
- if (val > 0xff) {
- msg = _("value of managerid out of range");
- goto err_exit;
- }
-
- virtPort->u.virtPort8021Qbg.managerID = (uint8_t)val;
-
- if (virStrToLong_ui(virtPortTypeID, NULL, 0, &val)) {
- msg = _("cannot parse value of typeid parameter");
- goto err_exit;
- }
-
- if (val > 0xffffff) {
- msg = _("value for typeid out of range");
- goto err_exit;
- }
-
- virtPort->u.virtPort8021Qbg.typeID = (uint32_t)val;
-
- if (virStrToLong_ui(virtPortTypeIDVersion, NULL, 0, &val)) {
- msg = _("cannot parse value of typeidversion parameter");
- goto err_exit;
- }
-
- if (val > 0xff) {
- msg = _("value of typeidversion out of range");
- goto err_exit;
- }
-
- virtPort->u.virtPort8021Qbg.typeIDVersion = (uint8_t)val;
-
- if (virtPortInstanceID != NULL) {
- if (virUUIDParse(virtPortInstanceID,
- virtPort->u.virtPort8021Qbg.instanceID)) {
- msg = _("cannot parse instanceid parameter as a uuid");
- goto err_exit;
- }
- } else {
- if (virUUIDGenerate(virtPort->u.virtPort8021Qbg.instanceID)) {
- msg = _("cannot generate a random uuid for instanceid");
- goto err_exit;
- }
- }
-
- virtPort->virtPortType = VIR_VIRTUALPORT_8021QBG;
- ret = 0;
- } else {
- msg = _("a parameter is missing for 802.1Qbg description");
- goto err_exit;
- }
- break;
-
- case VIR_VIRTUALPORT_8021QBH:
- if (virtPortProfileID != NULL) {
- if (virStrcpyStatic(virtPort->u.virtPort8021Qbh.profileID,
- virtPortProfileID) != NULL) {
- virtPort->virtPortType = VIR_VIRTUALPORT_8021QBH;
- ret = 0;
- } else {
- msg = _("profileid parameter too long");
- goto err_exit;
- }
- } else {
- msg = _("profileid parameter is missing for 802.1Qbh descripion");
- goto err_exit;
- }
- break;
-
-
- default:
- case VIR_VIRTUALPORT_NONE:
- case VIR_VIRTUALPORT_TYPE_LAST:
- msg = _("unknown virtualport type");
- goto err_exit;
- break;
- }
-
-err_exit:
-
- if (msg)
- virDomainReportError(VIR_ERR_INTERNAL_ERROR, "%s", msg);
-
- VIR_FREE(virtPortManagerID);
- VIR_FREE(virtPortTypeID);
- VIR_FREE(virtPortTypeIDVersion);
- VIR_FREE(virtPortInstanceID);
- VIR_FREE(virtPortProfileID);
- VIR_FREE(virtPortType);
-
- return ret;
-}
-
-
/* Parse the XML definition for a network interface
* @param node XML nodeset to parse for net definition
* @return 0 on success, -1 on failure
@@ -5319,49 +5174,6 @@ virDomainChrTargetTypeToString(int deviceType,
return type;
}
-static void
-virVirtualPortProfileFormat(virBufferPtr buf,
- virVirtualPortProfileParamsPtr virtPort,
- const char *indent)
-{
- char uuidstr[VIR_UUID_STRING_BUFLEN];
-
- if (virtPort->virtPortType == VIR_VIRTUALPORT_NONE)
- return;
-
- virBufferAsprintf(buf, "%s<virtualport type='%s'>\n",
- indent,
- virVirtualPortTypeToString(virtPort->virtPortType));
-
- switch (virtPort->virtPortType) {
- case VIR_VIRTUALPORT_NONE:
- case VIR_VIRTUALPORT_TYPE_LAST:
- break;
-
- case VIR_VIRTUALPORT_8021QBG:
- virUUIDFormat(virtPort->u.virtPort8021Qbg.instanceID,
- uuidstr);
- virBufferAsprintf(buf,
- "%s <parameters managerid='%d'
typeid='%d' "
- "typeidversion='%d'
instanceid='%s'/>\n",
- indent,
- virtPort->u.virtPort8021Qbg.managerID,
- virtPort->u.virtPort8021Qbg.typeID,
- virtPort->u.virtPort8021Qbg.typeIDVersion,
- uuidstr);
- break;
-
- case VIR_VIRTUALPORT_8021QBH:
- virBufferAsprintf(buf,
- "%s <parameters profileid='%s'/>\n",
- indent,
- virtPort->u.virtPort8021Qbh.profileID);
- break;
- }
-
- virBufferAsprintf(buf, "%s</virtualport>\n", indent);
-}
-
int virDomainDiskIndexByName(virDomainDefPtr def, const char *name)
{
virDomainDiskDefPtr vdisk;
diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms
index 3e3b1dd..fba596e 100644
--- a/src/libvirt_private.syms
+++ b/src/libvirt_private.syms
@@ -715,6 +715,8 @@ virSocketParseAddr;
virSocketParseIpv4Addr;
virSocketParseIpv6Addr;
virSocketSetPort;
+virVirtualPortProfileFormat;
+virVirtualPortProfileParamsParseXML;
# network_conf.h
diff --git a/src/util/macvtap.c b/src/util/macvtap.c
index 30343c8..052f76b 100644
--- a/src/util/macvtap.c
+++ b/src/util/macvtap.c
@@ -50,6 +50,7 @@
#include "util.h"
#include "macvtap.h"
+#include "network.h"
VIR_ENUM_IMPL(virMacvtapMode, VIR_MACVTAP_MODE_LAST,
"vepa",
@@ -1089,7 +1090,7 @@ vpAssociatePortProfileId(const char *macvtap_ifname,
VIR_DEBUG("%s: VM OPERATION: %s", __FUNCTION__,
virVMOperationTypeToString(vmOp));
- if (vmOp == VIR_VM_OP_NO_OP)
+ if (!virtPort || vmOp == VIR_VM_OP_NO_OP)
return 0;
switch (virtPort->virtPortType) {
@@ -1145,6 +1146,9 @@ vpDisassociatePortProfileId(const char *macvtap_ifname,
VIR_DEBUG("%s: VM OPERATION: %s", __FUNCTION__,
virVMOperationTypeToString(vmOp));
+ if (!virtPort)
+ return 0;
+
switch (virtPort->virtPortType) {
case VIR_VIRTUALPORT_NONE:
case VIR_VIRTUALPORT_TYPE_LAST:
diff --git a/src/util/macvtap.h b/src/util/macvtap.h
index 1b85989..8e8613d 100644
--- a/src/util/macvtap.h
+++ b/src/util/macvtap.h
@@ -25,15 +25,6 @@
# include <config.h>
-
-enum virVirtualPortType {
- VIR_VIRTUALPORT_NONE,
- VIR_VIRTUALPORT_8021QBG,
- VIR_VIRTUALPORT_8021QBH,
-
- VIR_VIRTUALPORT_TYPE_LAST,
-};
-
/* the mode type for macvtap devices */
enum virMacvtapMode {
VIR_MACVTAP_MODE_VEPA,
@@ -44,31 +35,6 @@ enum virMacvtapMode {
VIR_MACVTAP_MODE_LAST,
};
-
-# ifdef IFLA_VF_PORT_PROFILE_MAX
-# define LIBVIRT_IFLA_VF_PORT_PROFILE_MAX IFLA_VF_PORT_PROFILE_MAX
-# else
-# define LIBVIRT_IFLA_VF_PORT_PROFILE_MAX 40
-# endif
-
-/* profile data for macvtap (VEPA) */
-typedef struct _virVirtualPortProfileParams virVirtualPortProfileParams;
-typedef virVirtualPortProfileParams *virVirtualPortProfileParamsPtr;
-struct _virVirtualPortProfileParams {
- enum virVirtualPortType virtPortType;
- union {
- struct {
- uint8_t managerID;
- uint32_t typeID; /* 24 bit valid */
- uint8_t typeIDVersion;
- unsigned char instanceID[VIR_UUID_BUFLEN];
- } virtPort8021Qbg;
- struct {
- char profileID[LIBVIRT_IFLA_VF_PORT_PROFILE_MAX];
- } virtPort8021Qbh;
- } u;
-};
-
enum virVMOperationType {
VIR_VM_OP_CREATE,
VIR_VM_OP_SAVE,
@@ -85,6 +51,7 @@ enum virVMOperationType {
# if WITH_MACVTAP
# include "internal.h"
+# include "network.h"
int openMacvtapTap(const char *ifname,
const unsigned char *macaddress,
@@ -119,7 +86,6 @@ int vpDisassociatePortProfileId(const char *macvtap_ifname,
# endif /* WITH_MACVTAP */
-VIR_ENUM_DECL(virVirtualPort)
VIR_ENUM_DECL(virVMOperation)
VIR_ENUM_DECL(virMacvtapMode)
diff --git a/src/util/network.c b/src/util/network.c
index eb16e0c..a323b26 100644
--- a/src/util/network.c
+++ b/src/util/network.c
@@ -12,6 +12,7 @@
#include <arpa/inet.h>
#include "memory.h"
+#include "uuid.h"
#include "network.h"
#include "util.h"
#include "virterror_internal.h"
@@ -674,3 +675,202 @@ virSocketAddrPrefixToNetmask(unsigned int prefix,
error:
return result;
}
+
+/* virtualPortProfile utilities */
+
+VIR_ENUM_IMPL(virVirtualPort, VIR_VIRTUALPORT_TYPE_LAST,
+ "none",
+ "802.1Qbg",
+ "802.1Qbh")
+
+int
+virVirtualPortProfileParamsParseXML(xmlNodePtr node,
+ virVirtualPortProfileParamsPtr virtPort)
+{
+ int ret = -1;
+ char *virtPortType;
+ char *virtPortManagerID = NULL;
+ char *virtPortTypeID = NULL;
+ char *virtPortTypeIDVersion = NULL;
+ char *virtPortInstanceID = NULL;
+ char *virtPortProfileID = NULL;
+ xmlNodePtr cur = node->children;
+
+ virtPortType = virXMLPropString(node, "type");
+ if (!virtPortType) {
+ virSocketError(VIR_ERR_XML_ERROR, "%s",
+ _("missing virtualportprofile type"));
+ goto error;
+ }
+
+ while (cur != NULL) {
+ if (xmlStrEqual(cur->name, BAD_CAST "parameters")) {
+
+ virtPortManagerID = virXMLPropString(cur, "managerid");
+ virtPortTypeID = virXMLPropString(cur, "typeid");
+ virtPortTypeIDVersion = virXMLPropString(cur, "typeidversion");
+ virtPortInstanceID = virXMLPropString(cur, "instanceid");
+ virtPortProfileID = virXMLPropString(cur, "profileid");
+
+ break;
+ }
+
+ cur = cur->next;
+ }
+
+ virtPort->virtPortType = VIR_VIRTUALPORT_NONE;
+
+ switch (virVirtualPortTypeFromString(virtPortType)) {
+
+ case VIR_VIRTUALPORT_8021QBG:
+ if (virtPortManagerID != NULL && virtPortTypeID != NULL
&&
+ virtPortTypeIDVersion != NULL) {
+ unsigned int val;
+
+ if (virStrToLong_ui(virtPortManagerID, NULL, 0, &val)) {
+ virSocketError(VIR_ERR_XML_ERROR, "%s",
+ _("cannot parse value of managerid
parameter"));
+ goto error;
+ }
+
+ if (val > 0xff) {
+ virSocketError(VIR_ERR_XML_ERROR, "%s",
+ _("value of managerid out of range"));
+ goto error;
+ }
+
+ virtPort->u.virtPort8021Qbg.managerID = (uint8_t)val;
+
+ if (virStrToLong_ui(virtPortTypeID, NULL, 0, &val)) {
+ virSocketError(VIR_ERR_XML_ERROR, "%s",
+ _("cannot parse value of typeid
parameter"));
+ goto error;
+ }
+
+ if (val > 0xffffff) {
+ virSocketError(VIR_ERR_XML_ERROR, "%s",
+ _("value for typeid out of range"));
+ goto error;
+ }
+
+ virtPort->u.virtPort8021Qbg.typeID = (uint32_t)val;
+
+ if (virStrToLong_ui(virtPortTypeIDVersion, NULL, 0, &val)) {
+ virSocketError(VIR_ERR_XML_ERROR, "%s",
+ _("cannot parse value of typeidversion
parameter"));
+ goto error;
+ }
+
+ if (val > 0xff) {
+ virSocketError(VIR_ERR_XML_ERROR, "%s",
+ _("value of typeidversion out of
range"));
+ goto error;
+ }
+
+ virtPort->u.virtPort8021Qbg.typeIDVersion = (uint8_t)val;
+
+ if (virtPortInstanceID != NULL) {
+ if (virUUIDParse(virtPortInstanceID,
+ virtPort->u.virtPort8021Qbg.instanceID)) {
+ virSocketError(VIR_ERR_XML_ERROR, "%s",
+ _("cannot parse instanceid parameter as a
uuid"));
+ goto error;
+ }
+ } else {
+ if (virUUIDGenerate(virtPort->u.virtPort8021Qbg.instanceID)) {
+ virSocketError(VIR_ERR_XML_ERROR, "%s",
+ _("cannot generate a random uuid for
instanceid"));
+ goto error;
+ }
+ }
+
+ virtPort->virtPortType = VIR_VIRTUALPORT_8021QBG;
+ ret = 0;
+ } else {
+ virSocketError(VIR_ERR_XML_ERROR, "%s",
+ _("a parameter is missing for 802.1Qbg
description"));
+ goto error;
+ }
+ break;
+
+ case VIR_VIRTUALPORT_8021QBH:
+ if (virtPortProfileID != NULL) {
+ if (virStrcpyStatic(virtPort->u.virtPort8021Qbh.profileID,
+ virtPortProfileID) != NULL) {
+ virtPort->virtPortType = VIR_VIRTUALPORT_8021QBH;
+ ret = 0;
+ } else {
+ virSocketError(VIR_ERR_XML_ERROR, "%s",
+ _("profileid parameter too long"));
+ goto error;
+ }
+ } else {
+ virSocketError(VIR_ERR_XML_ERROR, "%s",
+ _("profileid parameter is missing for 802.1Qbh
descripion"));
+ goto error;
+ }
+ break;
+
+
+ default:
+ case VIR_VIRTUALPORT_NONE:
+ case VIR_VIRTUALPORT_TYPE_LAST:
+ virSocketError(VIR_ERR_XML_ERROR, "%s",
+ _("unknown virtualport type"));
+ goto error;
+ break;
+ }
+
+error:
+ VIR_FREE(virtPortManagerID);
+ VIR_FREE(virtPortTypeID);
+ VIR_FREE(virtPortTypeIDVersion);
+ VIR_FREE(virtPortInstanceID);
+ VIR_FREE(virtPortProfileID);
+ VIR_FREE(virtPortType);
+
+ return ret;
+}
+
+void
+virVirtualPortProfileFormat(virBufferPtr buf,
+ virVirtualPortProfileParamsPtr virtPort,
+ const char *indent)
+{
+ char uuidstr[VIR_UUID_STRING_BUFLEN];
+
+ if (!virtPort || virtPort->virtPortType == VIR_VIRTUALPORT_NONE)
+ return;
+
+ virBufferAsprintf(buf, "%s<virtualport type='%s'>\n",
+ indent,
+ virVirtualPortTypeToString(virtPort->virtPortType));
+
+ switch (virtPort->virtPortType) {
+ case VIR_VIRTUALPORT_NONE:
+ case VIR_VIRTUALPORT_TYPE_LAST:
+ break;
+
+ case VIR_VIRTUALPORT_8021QBG:
+ virUUIDFormat(virtPort->u.virtPort8021Qbg.instanceID,
+ uuidstr);
+ virBufferAsprintf(buf,
+ "%s <parameters managerid='%d'
typeid='%d' "
+ "typeidversion='%d'
instanceid='%s'/>\n",
+ indent,
+ virtPort->u.virtPort8021Qbg.managerID,
+ virtPort->u.virtPort8021Qbg.typeID,
+ virtPort->u.virtPort8021Qbg.typeIDVersion,
+ uuidstr);
+ break;
+
+ case VIR_VIRTUALPORT_8021QBH:
+ virBufferAsprintf(buf,
+ "%s <parameters profileid='%s'/>\n",
+ indent,
+ virtPort->u.virtPort8021Qbh.profileID);
+ break;
+ }
+
+ virBufferAsprintf(buf, "%s</virtualport>\n", indent);
+}
diff --git a/src/util/network.h b/src/util/network.h
index ed0b78c..0a8fc03 100644
--- a/src/util/network.h
+++ b/src/util/network.h
@@ -12,6 +12,8 @@
# define __VIR_NETWORK_H__
# include "internal.h"
+# include "buf.h"
+# include "util.h"
# include <sys/types.h>
# include <sys/socket.h>
@@ -20,6 +22,7 @@
# endif
# include <netdb.h>
# include <netinet/in.h>
+# include <xml.h>
typedef struct {
union {
@@ -90,4 +93,47 @@ int virSocketAddrPrefixToNetmask(unsigned int prefix,
virSocketAddrPtr netmask,
int family);
+/* virtualPortProfile utilities */
+# ifdef IFLA_VF_PORT_PROFILE_MAX
+# define LIBVIRT_IFLA_VF_PORT_PROFILE_MAX IFLA_VF_PORT_PROFILE_MAX
+# else
+# define LIBVIRT_IFLA_VF_PORT_PROFILE_MAX 40
+# endif
+
+enum virVirtualPortType {
+ VIR_VIRTUALPORT_NONE,
+ VIR_VIRTUALPORT_8021QBG,
+ VIR_VIRTUALPORT_8021QBH,
+
+ VIR_VIRTUALPORT_TYPE_LAST,
+};
+
+VIR_ENUM_DECL(virVirtualPort)
+
+/* profile data for macvtap (VEPA) */
+typedef struct _virVirtualPortProfileParams virVirtualPortProfileParams;
+typedef virVirtualPortProfileParams *virVirtualPortProfileParamsPtr;
+struct _virVirtualPortProfileParams {
+ enum virVirtualPortType virtPortType;
+ union {
+ struct {
+ uint8_t managerID;
+ uint32_t typeID; /* 24 bit valid */
+ uint8_t typeIDVersion;
+ unsigned char instanceID[VIR_UUID_BUFLEN];
+ } virtPort8021Qbg;
+ struct {
+ char profileID[LIBVIRT_IFLA_VF_PORT_PROFILE_MAX];
+ } virtPort8021Qbh;
+ } u;
+};
+
+int
+virVirtualPortProfileParamsParseXML(xmlNodePtr node,
+ virVirtualPortProfileParamsPtr virtPort);
+void
+virVirtualPortProfileFormat(virBufferPtr buf,
+ virVirtualPortProfileParamsPtr virtPort,
+ const char *indent);
+
#endif /* __VIR_NETWORK_H__ */
--
1.7.3.4