mirror of https://gitee.com/openkylin/libvirt.git
lxc: handle missing switch enum cases
Ensure all enum cases are listed in switch statements, or cast away enum type in places where we don't wish to cover all cases. Reviewed-by: John Ferlan <jferlan@redhat.com> Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
This commit is contained in:
parent
072579cf13
commit
017dfa27dd
|
@ -2035,7 +2035,7 @@ static int lxcContainerDropCapabilities(virDomainDefPtr def,
|
|||
break;
|
||||
|
||||
case VIR_DOMAIN_CAPABILITIES_POLICY_DEFAULT:
|
||||
switch ((virDomainCapsFeature) i) {
|
||||
switch (i) {
|
||||
case VIR_DOMAIN_CAPS_FEATURE_SYS_BOOT: /* No use of reboot */
|
||||
toDrop = !keepReboot && (state != VIR_TRISTATE_SWITCH_ON);
|
||||
break;
|
||||
|
@ -2066,10 +2066,10 @@ static int lxcContainerDropCapabilities(virDomainDefPtr def,
|
|||
}
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_CAPABILITIES_POLICY_LAST:
|
||||
default:
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("Unsupported capabilities policy: %s"),
|
||||
virDomainCapabilitiesPolicyTypeToString(policy));
|
||||
virReportEnumRangeError(virDomainCapabilitiesPolicy, policy);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -395,8 +395,14 @@ static int virLXCControllerGetNICIndexes(virLXCControllerPtr ctrl)
|
|||
case VIR_DOMAIN_NET_TYPE_INTERNAL:
|
||||
case VIR_DOMAIN_NET_TYPE_DIRECT:
|
||||
case VIR_DOMAIN_NET_TYPE_HOSTDEV:
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED,
|
||||
_("Unsupported net type %s"),
|
||||
virDomainNetTypeToString(ctrl->def->nets[i]->type));
|
||||
goto cleanup;
|
||||
case VIR_DOMAIN_NET_TYPE_LAST:
|
||||
default:
|
||||
break;
|
||||
virReportEnumRangeError(virDomainNetType, ctrl->def->nets[i]->type);
|
||||
goto cleanup;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -3968,10 +3968,21 @@ lxcDomainAttachDeviceNetLive(virConnectPtr conn,
|
|||
if (!(veth = virLXCProcessSetupInterfaceDirect(conn, vm->def, net)))
|
||||
goto cleanup;
|
||||
} break;
|
||||
default:
|
||||
case VIR_DOMAIN_NET_TYPE_USER:
|
||||
case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
|
||||
case VIR_DOMAIN_NET_TYPE_SERVER:
|
||||
case VIR_DOMAIN_NET_TYPE_CLIENT:
|
||||
case VIR_DOMAIN_NET_TYPE_MCAST:
|
||||
case VIR_DOMAIN_NET_TYPE_INTERNAL:
|
||||
case VIR_DOMAIN_NET_TYPE_HOSTDEV:
|
||||
case VIR_DOMAIN_NET_TYPE_UDP:
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("Network device type is not supported"));
|
||||
goto cleanup;
|
||||
case VIR_DOMAIN_NET_TYPE_LAST:
|
||||
default:
|
||||
virReportEnumRangeError(virDomainNetType, actualType);
|
||||
goto cleanup;
|
||||
}
|
||||
/* Set bandwidth or warn if requested and not supported. */
|
||||
actualBandwidth = virDomainNetGetActualBandwidth(net);
|
||||
|
@ -4011,6 +4022,15 @@ lxcDomainAttachDeviceNetLive(virConnectPtr conn,
|
|||
ignore_value(virNetDevMacVLanDelete(veth));
|
||||
break;
|
||||
|
||||
case VIR_DOMAIN_NET_TYPE_USER:
|
||||
case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
|
||||
case VIR_DOMAIN_NET_TYPE_SERVER:
|
||||
case VIR_DOMAIN_NET_TYPE_CLIENT:
|
||||
case VIR_DOMAIN_NET_TYPE_MCAST:
|
||||
case VIR_DOMAIN_NET_TYPE_INTERNAL:
|
||||
case VIR_DOMAIN_NET_TYPE_HOSTDEV:
|
||||
case VIR_DOMAIN_NET_TYPE_UDP:
|
||||
case VIR_DOMAIN_NET_TYPE_LAST:
|
||||
default:
|
||||
/* no-op */
|
||||
break;
|
||||
|
@ -4446,13 +4466,23 @@ lxcDomainDetachDeviceNetLive(virDomainObjPtr vm,
|
|||
* the host side. Further the container can change
|
||||
* the mac address of NIC name, so we can't easily
|
||||
* find out which guest NIC it maps to
|
||||
*/
|
||||
case VIR_DOMAIN_NET_TYPE_DIRECT:
|
||||
*/
|
||||
|
||||
default:
|
||||
case VIR_DOMAIN_NET_TYPE_USER:
|
||||
case VIR_DOMAIN_NET_TYPE_VHOSTUSER:
|
||||
case VIR_DOMAIN_NET_TYPE_SERVER:
|
||||
case VIR_DOMAIN_NET_TYPE_CLIENT:
|
||||
case VIR_DOMAIN_NET_TYPE_MCAST:
|
||||
case VIR_DOMAIN_NET_TYPE_INTERNAL:
|
||||
case VIR_DOMAIN_NET_TYPE_HOSTDEV:
|
||||
case VIR_DOMAIN_NET_TYPE_UDP:
|
||||
virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s",
|
||||
_("Only bridged veth devices can be detached"));
|
||||
goto cleanup;
|
||||
case VIR_DOMAIN_NET_TYPE_LAST:
|
||||
default:
|
||||
virReportEnumRangeError(virDomainNetType, actualType);
|
||||
goto cleanup;
|
||||
}
|
||||
|
||||
virDomainAuditNet(vm, detach, NULL, "detach", true);
|
||||
|
|
Loading…
Reference in New Issue