driver: Add typedef for the anonymous enum used for driver features

Add typedef for the anonymous enum used for the driver features. This
allows the usage of the type in a switch statement and taking
advantage of the compilers feature to detect uncovered cases.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
Marc Hartmayer 2018-03-08 13:20:24 +01:00 committed by John Ferlan
parent ddbee9f82a
commit d1c89c9b2d
9 changed files with 114 additions and 17 deletions

View File

@ -1122,7 +1122,7 @@ esxConnectSupportsFeature(virConnectPtr conn, int feature)
esxPrivate *priv = conn->privateData; esxPrivate *priv = conn->privateData;
esxVI_Boolean supportsVMotion = esxVI_Boolean_Undefined; esxVI_Boolean supportsVMotion = esxVI_Boolean_Undefined;
switch (feature) { switch ((virDrvFeature) feature) {
case VIR_DRV_FEATURE_MIGRATION_V1: case VIR_DRV_FEATURE_MIGRATION_V1:
supportsVMotion = esxSupportsVMotion(priv); supportsVMotion = esxSupportsVMotion(priv);
@ -1133,6 +1133,20 @@ esxConnectSupportsFeature(virConnectPtr conn, int feature)
return priv->vCenter && return priv->vCenter &&
supportsVMotion == esxVI_Boolean_True ? 1 : 0; supportsVMotion == esxVI_Boolean_True ? 1 : 0;
case VIR_DRV_FEATURE_FD_PASSING:
case VIR_DRV_FEATURE_MIGRATE_CHANGE_PROTECTION:
case VIR_DRV_FEATURE_MIGRATION_DIRECT:
case VIR_DRV_FEATURE_MIGRATION_OFFLINE:
case VIR_DRV_FEATURE_MIGRATION_P2P:
case VIR_DRV_FEATURE_MIGRATION_PARAMS:
case VIR_DRV_FEATURE_MIGRATION_V2:
case VIR_DRV_FEATURE_MIGRATION_V3:
case VIR_DRV_FEATURE_PROGRAM_KEEPALIVE:
case VIR_DRV_FEATURE_REMOTE:
case VIR_DRV_FEATURE_REMOTE_CLOSE_CALLBACK:
case VIR_DRV_FEATURE_REMOTE_EVENT_CALLBACK:
case VIR_DRV_FEATURE_TYPED_PARAM_STRING:
case VIR_DRV_FEATURE_XML_MIGRATABLE:
default: default:
return 0; return 0;
} }

View File

@ -45,7 +45,7 @@ int virStateStop(void);
* feature. Queries for VIR_DRV_FEATURE_PROGRAM* features are answered * feature. Queries for VIR_DRV_FEATURE_PROGRAM* features are answered
* directly by the RPC layer and not by the real driver. * directly by the RPC layer and not by the real driver.
*/ */
enum { typedef enum {
/* Driver supports V1-style virDomainMigrate, ie. domainMigratePrepare/ /* Driver supports V1-style virDomainMigrate, ie. domainMigratePrepare/
* domainMigratePerform/domainMigrateFinish. * domainMigratePerform/domainMigrateFinish.
*/ */
@ -123,7 +123,7 @@ enum {
* Support for driver close callback rpc * Support for driver close callback rpc
*/ */
VIR_DRV_FEATURE_REMOTE_CLOSE_CALLBACK = 15, VIR_DRV_FEATURE_REMOTE_CLOSE_CALLBACK = 15,
}; } virDrvFeature;
int virConnectSupportsFeature(virConnectPtr conn, int feature); int virConnectSupportsFeature(virConnectPtr conn, int feature);

View File

@ -5684,12 +5684,23 @@ libxlConnectSupportsFeature(virConnectPtr conn, int feature)
if (virConnectSupportsFeatureEnsureACL(conn) < 0) if (virConnectSupportsFeatureEnsureACL(conn) < 0)
return -1; return -1;
switch (feature) { switch ((virDrvFeature) feature) {
case VIR_DRV_FEATURE_MIGRATION_V3: case VIR_DRV_FEATURE_MIGRATION_V3:
case VIR_DRV_FEATURE_TYPED_PARAM_STRING: case VIR_DRV_FEATURE_TYPED_PARAM_STRING:
case VIR_DRV_FEATURE_MIGRATION_PARAMS: case VIR_DRV_FEATURE_MIGRATION_PARAMS:
case VIR_DRV_FEATURE_MIGRATION_P2P: case VIR_DRV_FEATURE_MIGRATION_P2P:
return 1; return 1;
case VIR_DRV_FEATURE_FD_PASSING:
case VIR_DRV_FEATURE_MIGRATE_CHANGE_PROTECTION:
case VIR_DRV_FEATURE_MIGRATION_DIRECT:
case VIR_DRV_FEATURE_MIGRATION_OFFLINE:
case VIR_DRV_FEATURE_MIGRATION_V1:
case VIR_DRV_FEATURE_MIGRATION_V2:
case VIR_DRV_FEATURE_PROGRAM_KEEPALIVE:
case VIR_DRV_FEATURE_REMOTE:
case VIR_DRV_FEATURE_REMOTE_CLOSE_CALLBACK:
case VIR_DRV_FEATURE_REMOTE_EVENT_CALLBACK:
case VIR_DRV_FEATURE_XML_MIGRATABLE:
default: default:
return 0; return 0;
} }

View File

@ -1793,9 +1793,23 @@ lxcConnectSupportsFeature(virConnectPtr conn, int feature)
if (virConnectSupportsFeatureEnsureACL(conn) < 0) if (virConnectSupportsFeatureEnsureACL(conn) < 0)
return -1; return -1;
switch (feature) { switch ((virDrvFeature) feature) {
case VIR_DRV_FEATURE_TYPED_PARAM_STRING: case VIR_DRV_FEATURE_TYPED_PARAM_STRING:
return 1; return 1;
case VIR_DRV_FEATURE_FD_PASSING:
case VIR_DRV_FEATURE_MIGRATE_CHANGE_PROTECTION:
case VIR_DRV_FEATURE_MIGRATION_DIRECT:
case VIR_DRV_FEATURE_MIGRATION_OFFLINE:
case VIR_DRV_FEATURE_MIGRATION_P2P:
case VIR_DRV_FEATURE_MIGRATION_PARAMS:
case VIR_DRV_FEATURE_MIGRATION_V1:
case VIR_DRV_FEATURE_MIGRATION_V2:
case VIR_DRV_FEATURE_MIGRATION_V3:
case VIR_DRV_FEATURE_PROGRAM_KEEPALIVE:
case VIR_DRV_FEATURE_REMOTE:
case VIR_DRV_FEATURE_REMOTE_CLOSE_CALLBACK:
case VIR_DRV_FEATURE_REMOTE_EVENT_CALLBACK:
case VIR_DRV_FEATURE_XML_MIGRATABLE:
default: default:
return 0; return 0;
} }

View File

@ -2203,10 +2203,23 @@ openvzNodeGetCPUMap(virConnectPtr conn ATTRIBUTE_UNUSED,
static int static int
openvzConnectSupportsFeature(virConnectPtr conn ATTRIBUTE_UNUSED, int feature) openvzConnectSupportsFeature(virConnectPtr conn ATTRIBUTE_UNUSED, int feature)
{ {
switch (feature) { switch ((virDrvFeature) feature) {
case VIR_DRV_FEATURE_MIGRATION_PARAMS: case VIR_DRV_FEATURE_MIGRATION_PARAMS:
case VIR_DRV_FEATURE_MIGRATION_V3: case VIR_DRV_FEATURE_MIGRATION_V3:
return 1; return 1;
case VIR_DRV_FEATURE_FD_PASSING:
case VIR_DRV_FEATURE_MIGRATE_CHANGE_PROTECTION:
case VIR_DRV_FEATURE_MIGRATION_DIRECT:
case VIR_DRV_FEATURE_MIGRATION_OFFLINE:
case VIR_DRV_FEATURE_MIGRATION_P2P:
case VIR_DRV_FEATURE_MIGRATION_V1:
case VIR_DRV_FEATURE_MIGRATION_V2:
case VIR_DRV_FEATURE_PROGRAM_KEEPALIVE:
case VIR_DRV_FEATURE_REMOTE:
case VIR_DRV_FEATURE_REMOTE_CLOSE_CALLBACK:
case VIR_DRV_FEATURE_REMOTE_EVENT_CALLBACK:
case VIR_DRV_FEATURE_TYPED_PARAM_STRING:
case VIR_DRV_FEATURE_XML_MIGRATABLE:
default: default:
return 0; return 0;
} }

View File

@ -1210,7 +1210,7 @@ qemuConnectSupportsFeature(virConnectPtr conn, int feature)
if (virConnectSupportsFeatureEnsureACL(conn) < 0) if (virConnectSupportsFeatureEnsureACL(conn) < 0)
return -1; return -1;
switch (feature) { switch ((virDrvFeature) feature) {
case VIR_DRV_FEATURE_MIGRATION_V2: case VIR_DRV_FEATURE_MIGRATION_V2:
case VIR_DRV_FEATURE_MIGRATION_V3: case VIR_DRV_FEATURE_MIGRATION_V3:
case VIR_DRV_FEATURE_MIGRATION_P2P: case VIR_DRV_FEATURE_MIGRATION_P2P:
@ -1221,6 +1221,12 @@ qemuConnectSupportsFeature(virConnectPtr conn, int feature)
case VIR_DRV_FEATURE_MIGRATION_OFFLINE: case VIR_DRV_FEATURE_MIGRATION_OFFLINE:
case VIR_DRV_FEATURE_MIGRATION_PARAMS: case VIR_DRV_FEATURE_MIGRATION_PARAMS:
return 1; return 1;
case VIR_DRV_FEATURE_MIGRATION_DIRECT:
case VIR_DRV_FEATURE_MIGRATION_V1:
case VIR_DRV_FEATURE_PROGRAM_KEEPALIVE:
case VIR_DRV_FEATURE_REMOTE:
case VIR_DRV_FEATURE_REMOTE_CLOSE_CALLBACK:
case VIR_DRV_FEATURE_REMOTE_EVENT_CALLBACK:
default: default:
return 0; return 0;
} }

View File

@ -4645,7 +4645,7 @@ static int remoteDispatchConnectSupportsFeature(virNetServerPtr server ATTRIBUTE
remote_connect_supports_feature_ret *ret) remote_connect_supports_feature_ret *ret)
{ {
int rv = -1; int rv = -1;
int supported; int supported = -1;
struct daemonClientPrivate *priv = struct daemonClientPrivate *priv =
virNetServerClientGetPrivateData(client); virNetServerClientGetPrivateData(client);
@ -4664,17 +4664,30 @@ static int remoteDispatchConnectSupportsFeature(virNetServerPtr server ATTRIBUTE
goto cleanup; goto cleanup;
} }
switch (args->feature) { switch ((virDrvFeature) args->feature) {
case VIR_DRV_FEATURE_FD_PASSING: case VIR_DRV_FEATURE_FD_PASSING:
case VIR_DRV_FEATURE_REMOTE_EVENT_CALLBACK: case VIR_DRV_FEATURE_REMOTE_EVENT_CALLBACK:
case VIR_DRV_FEATURE_REMOTE_CLOSE_CALLBACK: case VIR_DRV_FEATURE_REMOTE_CLOSE_CALLBACK:
supported = 1; supported = 1;
break; break;
case VIR_DRV_FEATURE_MIGRATION_V1:
case VIR_DRV_FEATURE_REMOTE:
case VIR_DRV_FEATURE_MIGRATION_V2:
case VIR_DRV_FEATURE_MIGRATION_P2P:
case VIR_DRV_FEATURE_MIGRATION_DIRECT:
case VIR_DRV_FEATURE_MIGRATION_V3:
case VIR_DRV_FEATURE_MIGRATE_CHANGE_PROTECTION:
case VIR_DRV_FEATURE_TYPED_PARAM_STRING:
case VIR_DRV_FEATURE_XML_MIGRATABLE:
case VIR_DRV_FEATURE_MIGRATION_OFFLINE:
case VIR_DRV_FEATURE_MIGRATION_PARAMS:
default: default:
if ((supported = virConnectSupportsFeature(priv->conn, args->feature)) < 0) if ((supported = virConnectSupportsFeature(priv->conn, args->feature)) < 0)
goto cleanup; goto cleanup;
break; break;
case VIR_DRV_FEATURE_PROGRAM_KEEPALIVE:
/* should not be possible! */
goto cleanup;
} }
done: done:

View File

@ -3079,10 +3079,23 @@ vzConnectSupportsFeature(virConnectPtr conn ATTRIBUTE_UNUSED, int feature)
if (virConnectSupportsFeatureEnsureACL(conn) < 0) if (virConnectSupportsFeatureEnsureACL(conn) < 0)
return -1; return -1;
switch (feature) { switch ((virDrvFeature) feature) {
case VIR_DRV_FEATURE_MIGRATION_PARAMS: case VIR_DRV_FEATURE_MIGRATION_PARAMS:
case VIR_DRV_FEATURE_MIGRATION_P2P: case VIR_DRV_FEATURE_MIGRATION_P2P:
return 1; return 1;
case VIR_DRV_FEATURE_FD_PASSING:
case VIR_DRV_FEATURE_MIGRATE_CHANGE_PROTECTION:
case VIR_DRV_FEATURE_MIGRATION_DIRECT:
case VIR_DRV_FEATURE_MIGRATION_OFFLINE:
case VIR_DRV_FEATURE_MIGRATION_V1:
case VIR_DRV_FEATURE_MIGRATION_V2:
case VIR_DRV_FEATURE_MIGRATION_V3:
case VIR_DRV_FEATURE_PROGRAM_KEEPALIVE:
case VIR_DRV_FEATURE_REMOTE:
case VIR_DRV_FEATURE_REMOTE_CLOSE_CALLBACK:
case VIR_DRV_FEATURE_REMOTE_EVENT_CALLBACK:
case VIR_DRV_FEATURE_TYPED_PARAM_STRING:
case VIR_DRV_FEATURE_XML_MIGRATABLE:
default: default:
return 0; return 0;
} }

View File

@ -619,10 +619,23 @@ xenUnifiedConnectSupportsFeature(virConnectPtr conn, int feature)
if (virConnectSupportsFeatureEnsureACL(conn) < 0) if (virConnectSupportsFeatureEnsureACL(conn) < 0)
return -1; return -1;
switch (feature) { switch ((virDrvFeature) feature) {
case VIR_DRV_FEATURE_MIGRATION_V1: case VIR_DRV_FEATURE_MIGRATION_V1:
case VIR_DRV_FEATURE_MIGRATION_DIRECT: case VIR_DRV_FEATURE_MIGRATION_DIRECT:
return 1; return 1;
case VIR_DRV_FEATURE_MIGRATION_V2:
case VIR_DRV_FEATURE_MIGRATION_V3:
case VIR_DRV_FEATURE_MIGRATION_P2P:
case VIR_DRV_FEATURE_MIGRATE_CHANGE_PROTECTION:
case VIR_DRV_FEATURE_FD_PASSING:
case VIR_DRV_FEATURE_TYPED_PARAM_STRING:
case VIR_DRV_FEATURE_XML_MIGRATABLE:
case VIR_DRV_FEATURE_MIGRATION_OFFLINE:
case VIR_DRV_FEATURE_MIGRATION_PARAMS:
case VIR_DRV_FEATURE_PROGRAM_KEEPALIVE:
case VIR_DRV_FEATURE_REMOTE:
case VIR_DRV_FEATURE_REMOTE_CLOSE_CALLBACK:
case VIR_DRV_FEATURE_REMOTE_EVENT_CALLBACK:
default: default:
return 0; return 0;
} }