mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-02-21 19:02:25 +00:00
driver: Introduce global driver feature flag handling function
The 'virDrvFeature' has a combination of features which are asserted by the specific driver and features which are actually global. In many cases the implementation was cargo-culted into newer drivers without re-assesing whether it makes sense. This patch introduces a global function which will specifically handle these global flags and defer the rest to the driver. Signed-off-by: Peter Krempa <pkrempa@redhat.com> Reviewed-by: Ján Tomko <jtomko@redhat.com> Reviewed-by: Andrea Bolognani <abologna@redhat.com>
This commit is contained in:
parent
f3c2b321e0
commit
f24a22315b
@ -919,9 +919,14 @@ static int
|
||||
chConnectSupportsFeature(virConnectPtr conn,
|
||||
int feature)
|
||||
{
|
||||
int supported;
|
||||
|
||||
if (virConnectSupportsFeatureEnsureACL(conn) < 0)
|
||||
return -1;
|
||||
|
||||
if (virDriverFeatureIsGlobal(feature, &supported))
|
||||
return supported;
|
||||
|
||||
switch ((virDrvFeature) feature) {
|
||||
case VIR_DRV_FEATURE_TYPED_PARAM_STRING:
|
||||
case VIR_DRV_FEATURE_NETWORK_UPDATE_HAS_CORRECT_ORDER:
|
||||
|
41
src/driver.c
41
src/driver.c
@ -316,3 +316,44 @@ virConnectValidateURIPath(const char *uriPath,
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* virDriverFeatureIsGlobal:
|
||||
* @feat: a VIR_DRV_FEATURE
|
||||
* @supported: If a feature is globally handled
|
||||
*
|
||||
* Certain driver feature flags are really not for individual drivers to decide
|
||||
* whether they implement them or not, but are rather global based on e.g.
|
||||
* whether the RPC protocol supports it.
|
||||
*
|
||||
* This function returns 'true' and fills @supported if a feature is a global
|
||||
* feature and the individual driver implementations don't decide whether
|
||||
* they support it or not.
|
||||
*/
|
||||
bool
|
||||
virDriverFeatureIsGlobal(virDrvFeature feat,
|
||||
int *supported G_GNUC_UNUSED)
|
||||
|
||||
{
|
||||
switch (feat) {
|
||||
case VIR_DRV_FEATURE_TYPED_PARAM_STRING:
|
||||
case VIR_DRV_FEATURE_NETWORK_UPDATE_HAS_CORRECT_ORDER:
|
||||
case VIR_DRV_FEATURE_FD_PASSING:
|
||||
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_XML_MIGRATABLE:
|
||||
case VIR_DRV_FEATURE_MIGRATION_OFFLINE:
|
||||
case VIR_DRV_FEATURE_MIGRATION_PARAMS:
|
||||
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:
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
@ -131,3 +131,6 @@ int virSetConnectStorage(virConnectPtr conn);
|
||||
bool virConnectValidateURIPath(const char *uriPath,
|
||||
const char *entityName,
|
||||
bool privileged);
|
||||
|
||||
bool virDriverFeatureIsGlobal(virDrvFeature feat,
|
||||
int *supported);
|
||||
|
@ -1018,6 +1018,10 @@ esxConnectSupportsFeature(virConnectPtr conn, int feature)
|
||||
{
|
||||
esxPrivate *priv = conn->privateData;
|
||||
esxVI_Boolean supportsVMotion = esxVI_Boolean_Undefined;
|
||||
int supported;
|
||||
|
||||
if (virDriverFeatureIsGlobal(feature, &supported))
|
||||
return supported;
|
||||
|
||||
switch ((virDrvFeature) feature) {
|
||||
case VIR_DRV_FEATURE_MIGRATION_V1:
|
||||
|
@ -1528,6 +1528,7 @@ virStreamClass;
|
||||
|
||||
# driver.h
|
||||
virConnectValidateURIPath;
|
||||
virDriverFeatureIsGlobal;
|
||||
virDriverShouldAutostart;
|
||||
virGetConnectInterface;
|
||||
virGetConnectNetwork;
|
||||
|
@ -5697,9 +5697,14 @@ libxlConnectListAllDomains(virConnectPtr conn,
|
||||
static int
|
||||
libxlConnectSupportsFeature(virConnectPtr conn, int feature)
|
||||
{
|
||||
int supported;
|
||||
|
||||
if (virConnectSupportsFeatureEnsureACL(conn) < 0)
|
||||
return -1;
|
||||
|
||||
if (virDriverFeatureIsGlobal(feature, &supported))
|
||||
return supported;
|
||||
|
||||
switch ((virDrvFeature) feature) {
|
||||
case VIR_DRV_FEATURE_MIGRATION_V3:
|
||||
case VIR_DRV_FEATURE_TYPED_PARAM_STRING:
|
||||
|
@ -1618,9 +1618,14 @@ static int lxcStateCleanup(void)
|
||||
static int
|
||||
lxcConnectSupportsFeature(virConnectPtr conn, int feature)
|
||||
{
|
||||
int supported;
|
||||
|
||||
if (virConnectSupportsFeatureEnsureACL(conn) < 0)
|
||||
return -1;
|
||||
|
||||
if (virDriverFeatureIsGlobal(feature, &supported))
|
||||
return supported;
|
||||
|
||||
switch ((virDrvFeature) feature) {
|
||||
case VIR_DRV_FEATURE_TYPED_PARAM_STRING:
|
||||
case VIR_DRV_FEATURE_NETWORK_UPDATE_HAS_CORRECT_ORDER:
|
||||
|
@ -857,9 +857,14 @@ static int networkConnectIsAlive(virConnectPtr conn G_GNUC_UNUSED)
|
||||
static int
|
||||
networkConnectSupportsFeature(virConnectPtr conn, int feature)
|
||||
{
|
||||
int supported;
|
||||
|
||||
if (virConnectSupportsFeatureEnsureACL(conn) < 0)
|
||||
return -1;
|
||||
|
||||
if (virDriverFeatureIsGlobal(feature, &supported))
|
||||
return supported;
|
||||
|
||||
switch ((virDrvFeature) feature) {
|
||||
case VIR_DRV_FEATURE_NETWORK_UPDATE_HAS_CORRECT_ORDER:
|
||||
return 1;
|
||||
|
@ -1938,6 +1938,11 @@ openvzNodeGetCPUMap(virConnectPtr conn G_GNUC_UNUSED,
|
||||
static int
|
||||
openvzConnectSupportsFeature(virConnectPtr conn G_GNUC_UNUSED, int feature)
|
||||
{
|
||||
int supported;
|
||||
|
||||
if (virDriverFeatureIsGlobal(feature, &supported))
|
||||
return supported;
|
||||
|
||||
switch ((virDrvFeature) feature) {
|
||||
case VIR_DRV_FEATURE_MIGRATION_PARAMS:
|
||||
case VIR_DRV_FEATURE_MIGRATION_V3:
|
||||
|
@ -1173,9 +1173,14 @@ static int qemuConnectClose(virConnectPtr conn)
|
||||
static int
|
||||
qemuConnectSupportsFeature(virConnectPtr conn, int feature)
|
||||
{
|
||||
int supported;
|
||||
|
||||
if (virConnectSupportsFeatureEnsureACL(conn) < 0)
|
||||
return -1;
|
||||
|
||||
if (virDriverFeatureIsGlobal(feature, &supported))
|
||||
return supported;
|
||||
|
||||
switch ((virDrvFeature) feature) {
|
||||
case VIR_DRV_FEATURE_MIGRATION_V2:
|
||||
case VIR_DRV_FEATURE_MIGRATION_V3:
|
||||
|
@ -1667,6 +1667,11 @@ static int
|
||||
testConnectSupportsFeature(virConnectPtr conn G_GNUC_UNUSED,
|
||||
int feature)
|
||||
{
|
||||
int supported;
|
||||
|
||||
if (virDriverFeatureIsGlobal(feature, &supported))
|
||||
return supported;
|
||||
|
||||
switch ((virDrvFeature) feature) {
|
||||
case VIR_DRV_FEATURE_TYPED_PARAM_STRING:
|
||||
case VIR_DRV_FEATURE_NETWORK_UPDATE_HAS_CORRECT_ORDER:
|
||||
|
@ -3006,9 +3006,14 @@ vzDomainMigratePrepare3Params(virConnectPtr conn,
|
||||
static int
|
||||
vzConnectSupportsFeature(virConnectPtr conn G_GNUC_UNUSED, int feature)
|
||||
{
|
||||
int supported;
|
||||
|
||||
if (virConnectSupportsFeatureEnsureACL(conn) < 0)
|
||||
return -1;
|
||||
|
||||
if (virDriverFeatureIsGlobal(feature, &supported))
|
||||
return supported;
|
||||
|
||||
switch ((virDrvFeature) feature) {
|
||||
case VIR_DRV_FEATURE_MIGRATION_PARAMS:
|
||||
case VIR_DRV_FEATURE_MIGRATION_P2P:
|
||||
|
Loading…
x
Reference in New Issue
Block a user