mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2024-08-27 19:11:16 +00:00
Cleanup switch statements on the hostdev subsystem type
As was suggested in an earlier review comment[1], we can catch some additional code points by cleaning up how we use the hostdev subsystem type in some switch statements. [1] End of https://www.redhat.com/archives/libvir-list/2016-September/msg00399.html Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com> Signed-off-by: John Ferlan <jferlan@redhat.com>
This commit is contained in:
parent
7b8e1dff1a
commit
85b0721095
@ -12994,7 +12994,7 @@ virDomainHostdevDefParseXML(virDomainXMLOptionPtr xmlopt,
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (def->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) {
|
if (def->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) {
|
||||||
switch (def->source.subsys.type) {
|
switch ((virDomainHostdevSubsysType) def->source.subsys.type) {
|
||||||
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI:
|
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI:
|
||||||
if (def->info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
|
if (def->info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
|
||||||
def->info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
|
def->info->type != VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) {
|
||||||
@ -13016,6 +13016,9 @@ virDomainHostdevDefParseXML(virDomainXMLOptionPtr xmlopt,
|
|||||||
if (virXPathBoolean("boolean(./shareable)", ctxt))
|
if (virXPathBoolean("boolean(./shareable)", ctxt))
|
||||||
def->shareable = true;
|
def->shareable = true;
|
||||||
break;
|
break;
|
||||||
|
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB:
|
||||||
|
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -13882,7 +13885,7 @@ virDomainHostdevMatchSubsys(virDomainHostdevDefPtr a,
|
|||||||
if (a->source.subsys.type != b->source.subsys.type)
|
if (a->source.subsys.type != b->source.subsys.type)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
switch (a->source.subsys.type) {
|
switch ((virDomainHostdevSubsysType) a->source.subsys.type) {
|
||||||
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI:
|
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI:
|
||||||
return virDomainHostdevMatchSubsysPCI(a, b);
|
return virDomainHostdevMatchSubsysPCI(a, b);
|
||||||
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB:
|
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB:
|
||||||
@ -13896,6 +13899,8 @@ virDomainHostdevMatchSubsys(virDomainHostdevDefPtr a,
|
|||||||
return virDomainHostdevMatchSubsysSCSIiSCSI(a, b);
|
return virDomainHostdevMatchSubsysSCSIiSCSI(a, b);
|
||||||
else
|
else
|
||||||
return virDomainHostdevMatchSubsysSCSIHost(a, b);
|
return virDomainHostdevMatchSubsysSCSIHost(a, b);
|
||||||
|
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST:
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -301,7 +301,7 @@ qemuSetupHostdevCgroup(virDomainObjPtr vm,
|
|||||||
|
|
||||||
if (dev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) {
|
if (dev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) {
|
||||||
|
|
||||||
switch (dev->source.subsys.type) {
|
switch ((virDomainHostdevSubsysType) dev->source.subsys.type) {
|
||||||
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI:
|
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI:
|
||||||
if (pcisrc->backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) {
|
if (pcisrc->backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) {
|
||||||
int rv;
|
int rv;
|
||||||
@ -376,7 +376,7 @@ qemuSetupHostdevCgroup(virDomainObjPtr vm,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -410,7 +410,7 @@ qemuTeardownHostdevCgroup(virDomainObjPtr vm,
|
|||||||
|
|
||||||
if (dev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) {
|
if (dev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS) {
|
||||||
|
|
||||||
switch (dev->source.subsys.type) {
|
switch ((virDomainHostdevSubsysType) dev->source.subsys.type) {
|
||||||
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI:
|
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI:
|
||||||
if (pcisrc->backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) {
|
if (pcisrc->backend == VIR_DOMAIN_HOSTDEV_PCI_BACKEND_VFIO) {
|
||||||
int rv;
|
int rv;
|
||||||
@ -437,7 +437,10 @@ qemuTeardownHostdevCgroup(virDomainObjPtr vm,
|
|||||||
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB:
|
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB:
|
||||||
/* nothing to tear down for USB */
|
/* nothing to tear down for USB */
|
||||||
break;
|
break;
|
||||||
default:
|
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI:
|
||||||
|
/* nothing to tear down for SCSI */
|
||||||
|
break;
|
||||||
|
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -856,7 +856,7 @@ AppArmorSetSecurityHostdevLabel(virSecurityManagerPtr mgr,
|
|||||||
ptr->mgr = mgr;
|
ptr->mgr = mgr;
|
||||||
ptr->def = def;
|
ptr->def = def;
|
||||||
|
|
||||||
switch (dev->source.subsys.type) {
|
switch ((virDomainHostdevSubsysType) dev->source.subsys.type) {
|
||||||
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: {
|
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: {
|
||||||
virUSBDevicePtr usb =
|
virUSBDevicePtr usb =
|
||||||
virUSBDeviceNew(usbsrc->bus, usbsrc->device, vroot);
|
virUSBDeviceNew(usbsrc->bus, usbsrc->device, vroot);
|
||||||
@ -909,7 +909,7 @@ AppArmorSetSecurityHostdevLabel(virSecurityManagerPtr mgr,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST:
|
||||||
ret = 0;
|
ret = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -1436,7 +1436,7 @@ virSecuritySELinuxSetHostdevSubsysLabel(virSecurityManagerPtr mgr,
|
|||||||
scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI)
|
scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
switch (dev->source.subsys.type) {
|
switch ((virDomainHostdevSubsysType) dev->source.subsys.type) {
|
||||||
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: {
|
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: {
|
||||||
virUSBDevicePtr usb;
|
virUSBDevicePtr usb;
|
||||||
|
|
||||||
@ -1498,7 +1498,7 @@ virSecuritySELinuxSetHostdevSubsysLabel(virSecurityManagerPtr mgr,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST:
|
||||||
ret = 0;
|
ret = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -1640,7 +1640,7 @@ virSecuritySELinuxRestoreHostdevSubsysLabel(virSecurityManagerPtr mgr,
|
|||||||
scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI)
|
scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
switch (dev->source.subsys.type) {
|
switch ((virDomainHostdevSubsysType) dev->source.subsys.type) {
|
||||||
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: {
|
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: {
|
||||||
virUSBDevicePtr usb;
|
virUSBDevicePtr usb;
|
||||||
|
|
||||||
@ -1700,7 +1700,7 @@ virSecuritySELinuxRestoreHostdevSubsysLabel(virSecurityManagerPtr mgr,
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
default:
|
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST:
|
||||||
ret = 0;
|
ret = 0;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user