From: Michal Privoznik <mprivozn(a)redhat.com>
Convert the member to the appropriate type, fix few missing cases
in switch() and switch to virXMLPropEnum() in parsing.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
src/conf/netdev_vport_profile_conf.c | 9 ++++-----
src/hypervisor/virhostdev.c | 1 +
src/qemu/qemu_migration_cookie.c | 2 ++
src/util/virnetdevvportprofile.c | 17 +++++++++++++++--
src/util/virnetdevvportprofile.h | 2 +-
5 files changed, 23 insertions(+), 8 deletions(-)
diff --git a/src/conf/netdev_vport_profile_conf.c b/src/conf/netdev_vport_profile_conf.c
index f7928a5679..6106130a39 100644
--- a/src/conf/netdev_vport_profile_conf.c
+++ b/src/conf/netdev_vport_profile_conf.c
@@ -28,16 +28,15 @@
virNetDevVPortProfile *
virNetDevVPortProfileParse(xmlNodePtr node, unsigned int flags)
{
- g_autofree char *virtPortType = NULL;
g_autofree virNetDevVPortProfile *virtPort = NULL;
xmlNodePtr parameters;
virtPort = g_new0(virNetDevVPortProfile, 1);
- if ((virtPortType = virXMLPropString(node, "type")) &&
- (virtPort->virtPortType = virNetDevVPortTypeFromString(virtPortType)) <= 0)
{
- virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
- _("unknown virtualport type %1$s"), virtPortType);
+ if (virXMLPropEnum(node, "type",
+ virNetDevVPortTypeFromString,
+ VIR_XML_PROP_NONZERO,
+ &virtPort->virtPortType) < 0) {
return NULL;
}
diff --git a/src/hypervisor/virhostdev.c b/src/hypervisor/virhostdev.c
index 0a1d8500d4..7d7df4418d 100644
--- a/src/hypervisor/virhostdev.c
+++ b/src/hypervisor/virhostdev.c
@@ -370,6 +370,7 @@ virHostdevNetConfigVirtPortProfile(const char *linkdev, int vf,
case VIR_NETDEV_VPORT_PROFILE_NONE:
case VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH:
case VIR_NETDEV_VPORT_PROFILE_8021QBG:
+ case VIR_NETDEV_VPORT_PROFILE_MIDONET:
case VIR_NETDEV_VPORT_PROFILE_LAST:
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
_("virtualport type %1$s is currently not supported on
interfaces of type hostdev"),
diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_cookie.c
index 90cc079c1a..01529c99b8 100644
--- a/src/qemu/qemu_migration_cookie.c
+++ b/src/qemu/qemu_migration_cookie.c
@@ -283,6 +283,7 @@ qemuMigrationCookieNetworkAlloc(virQEMUDriver *driver G_GNUC_UNUSED,
case VIR_NETDEV_VPORT_PROFILE_NONE:
case VIR_NETDEV_VPORT_PROFILE_8021QBG:
case VIR_NETDEV_VPORT_PROFILE_8021QBH:
+ case VIR_NETDEV_VPORT_PROFILE_MIDONET:
break;
case VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH:
if (virNetDevOpenvswitchGetMigrateData(&mig->net[i].portdata,
@@ -293,6 +294,7 @@ qemuMigrationCookieNetworkAlloc(virQEMUDriver *driver G_GNUC_UNUSED,
return NULL;
}
break;
+ case VIR_NETDEV_VPORT_PROFILE_LAST:
default:
break;
}
diff --git a/src/util/virnetdevvportprofile.c b/src/util/virnetdevvportprofile.c
index 221e0888b3..d6674390a7 100644
--- a/src/util/virnetdevvportprofile.c
+++ b/src/util/virnetdevvportprofile.c
@@ -109,11 +109,13 @@ virNetDevVPortProfileEqual(const virNetDevVPortProfile *a, const
virNetDevVPortP
break;
case VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH:
+ case VIR_NETDEV_VPORT_PROFILE_MIDONET:
if (STRNEQ(a->profileID, b->profileID) ||
memcmp(a->interfaceID, b->interfaceID, VIR_UUID_BUFLEN) != 0)
return false;
break;
+ case VIR_NETDEV_VPORT_PROFILE_LAST:
default:
break;
}
@@ -151,7 +153,7 @@ virNetDevVPortProfileCheckComplete(virNetDevVPortProfile *virtport,
{
const char *missing = NULL;
- if (!virtport || virtport->virtPortType == VIR_NETDEV_VPORT_PROFILE_NONE)
+ if (!virtport)
return 0;
switch (virtport->virtPortType) {
@@ -201,6 +203,10 @@ virNetDevVPortProfileCheckComplete(virNetDevVPortProfile *virtport,
if (!virtport->interfaceID_specified)
missing = "interfaceid";
break;
+
+ case VIR_NETDEV_VPORT_PROFILE_NONE:
+ case VIR_NETDEV_VPORT_PROFILE_LAST:
+ break;
}
if (missing) {
@@ -224,7 +230,7 @@ virNetDevVPortProfileCheckNoExtras(const virNetDevVPortProfile
*virtport)
{
const char *extra = NULL;
- if (!virtport || virtport->virtPortType == VIR_NETDEV_VPORT_PROFILE_NONE)
+ if (!virtport)
return 0;
switch (virtport->virtPortType) {
@@ -249,6 +255,7 @@ virNetDevVPortProfileCheckNoExtras(const virNetDevVPortProfile
*virtport)
break;
case VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH:
+ case VIR_NETDEV_VPORT_PROFILE_MIDONET:
if (virtport->managerID_specified)
extra = "managerid";
else if (virtport->typeID_specified)
@@ -258,6 +265,10 @@ virNetDevVPortProfileCheckNoExtras(const virNetDevVPortProfile
*virtport)
else if (virtport->instanceID_specified)
extra = "instanceid";
break;
+
+ case VIR_NETDEV_VPORT_PROFILE_NONE:
+ case VIR_NETDEV_VPORT_PROFILE_LAST:
+ break;
}
if (extra) {
@@ -1238,6 +1249,7 @@ virNetDevVPortProfileAssociate(const char *macvtap_ifname,
switch (virtPort->virtPortType) {
case VIR_NETDEV_VPORT_PROFILE_NONE:
case VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH:
+ case VIR_NETDEV_VPORT_PROFILE_MIDONET:
case VIR_NETDEV_VPORT_PROFILE_LAST:
break;
@@ -1303,6 +1315,7 @@ virNetDevVPortProfileDisassociate(const char *macvtap_ifname,
switch (virtPort->virtPortType) {
case VIR_NETDEV_VPORT_PROFILE_NONE:
case VIR_NETDEV_VPORT_PROFILE_OPENVSWITCH:
+ case VIR_NETDEV_VPORT_PROFILE_MIDONET:
case VIR_NETDEV_VPORT_PROFILE_LAST:
break;
diff --git a/src/util/virnetdevvportprofile.h b/src/util/virnetdevvportprofile.h
index 43ccb891e7..c15fd4163a 100644
--- a/src/util/virnetdevvportprofile.h
+++ b/src/util/virnetdevvportprofile.h
@@ -53,7 +53,7 @@ VIR_ENUM_DECL(virNetDevVPortProfileOp);
/* profile data for macvtap (VEPA) and openvswitch */
typedef struct _virNetDevVPortProfile virNetDevVPortProfile;
struct _virNetDevVPortProfile {
- int virtPortType; /* enum virNetDevVPortProfile */
+ virNetDevVPortProfileType virtPortType;
/* these members are used when virtPortType == 802.1Qbg */
uint8_t managerID;
bool managerID_specified;
--
2.49.1