Introduce framework for a hostdev SCSI_host subsystem type

We already have a "scsi" hostdev subsys type, which refers to a single
LUN that is passed through to a guest.  But what of things where
multiple LUNs are passed through via a single SCSI HBA, such as with
the vhost-scsi target?  Create a new hostdev subsys type that will
carry this.

Signed-off-by: Eric Farman <farman@linux.vnet.ibm.com>
This commit is contained in:
Eric Farman 2016-11-21 22:58:16 -05:00 committed by John Ferlan
parent c271fc1f35
commit fc0e627bac
8 changed files with 58 additions and 1 deletions

View File

@ -648,7 +648,8 @@ VIR_ENUM_IMPL(virDomainHostdevMode, VIR_DOMAIN_HOSTDEV_MODE_LAST,
VIR_ENUM_IMPL(virDomainHostdevSubsys, VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST, VIR_ENUM_IMPL(virDomainHostdevSubsys, VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST,
"usb", "usb",
"pci", "pci",
"scsi") "scsi",
"scsi_host")
VIR_ENUM_IMPL(virDomainHostdevSubsysPCIBackend, VIR_ENUM_IMPL(virDomainHostdevSubsysPCIBackend,
VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_LAST, VIR_DOMAIN_HOSTDEV_PCI_BACKEND_TYPE_LAST,
@ -662,6 +663,11 @@ VIR_ENUM_IMPL(virDomainHostdevSubsysSCSIProtocol,
"adapter", "adapter",
"iscsi") "iscsi")
VIR_ENUM_IMPL(virDomainHostdevSubsysSCSIHostProtocol,
VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_HOST_PROTOCOL_TYPE_LAST,
"none",
"vhost")
VIR_ENUM_IMPL(virDomainHostdevCaps, VIR_DOMAIN_HOSTDEV_CAPS_TYPE_LAST, VIR_ENUM_IMPL(virDomainHostdevCaps, VIR_DOMAIN_HOSTDEV_CAPS_TYPE_LAST,
"storage", "storage",
"misc", "misc",
@ -13015,6 +13021,7 @@ 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_SCSI_HOST:
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB: case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB:
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST: case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST:
break; break;
@ -13898,6 +13905,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_SCSI_HOST:
/* Fall through for now */
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST: case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST:
return 0; return 0;
} }

View File

@ -294,6 +294,7 @@ typedef enum {
VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB, VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_USB,
VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI, VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_PCI,
VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI, VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI,
VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST,
VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST
} virDomainHostdevSubsysType; } virDomainHostdevSubsysType;
@ -368,6 +369,22 @@ struct _virDomainHostdevSubsysSCSI {
} u; } u;
}; };
typedef enum {
VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_HOST_PROTOCOL_TYPE_NONE,
VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_HOST_PROTOCOL_TYPE_VHOST,
VIR_DOMAIN_HOSTDEV_SUBSYS_SCSI_HOST_PROTOCOL_TYPE_LAST,
} virDomainHostdevSubsysSCSIHostProtocolType;
VIR_ENUM_DECL(virDomainHostdevSubsysSCSIHostProtocol)
typedef struct _virDomainHostdevSubsysSCSIVHost virDomainHostdevSubsysSCSIVHost;
typedef virDomainHostdevSubsysSCSIVHost *virDomainHostdevSubsysSCSIVHostPtr;
struct _virDomainHostdevSubsysSCSIVHost {
int protocol; /* enum virDomainHostdevSubsysSCSIHostProtocolType */
char *wwpn;
};
typedef struct _virDomainHostdevSubsys virDomainHostdevSubsys; typedef struct _virDomainHostdevSubsys virDomainHostdevSubsys;
typedef virDomainHostdevSubsys *virDomainHostdevSubsysPtr; typedef virDomainHostdevSubsys *virDomainHostdevSubsysPtr;
struct _virDomainHostdevSubsys { struct _virDomainHostdevSubsys {
@ -376,6 +393,7 @@ struct _virDomainHostdevSubsys {
virDomainHostdevSubsysUSB usb; virDomainHostdevSubsysUSB usb;
virDomainHostdevSubsysPCI pci; virDomainHostdevSubsysPCI pci;
virDomainHostdevSubsysSCSI scsi; virDomainHostdevSubsysSCSI scsi;
virDomainHostdevSubsysSCSIVHost scsi_host;
} u; } u;
}; };

View File

@ -398,6 +398,10 @@ qemuSetupHostdevCgroup(virDomainObjPtr vm,
break; break;
} }
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST: {
break;
}
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST: case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST:
break; break;
} }
@ -462,6 +466,9 @@ qemuTeardownHostdevCgroup(virDomainObjPtr vm,
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI: case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI:
/* nothing to tear down for SCSI */ /* nothing to tear down for SCSI */
break; break;
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST:
/* nothing to tear down for scsi_host */
break;
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST: case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST:
break; break;
} }

View File

@ -3664,6 +3664,8 @@ qemuDomainRemoveHostDevice(virQEMUDriverPtr driver,
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI: case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI:
qemuDomainRemoveSCSIHostDevice(driver, vm, hostdev); qemuDomainRemoveSCSIHostDevice(driver, vm, hostdev);
break; break;
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST:
break;
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST: case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST:
break; break;
} }

View File

@ -909,6 +909,10 @@ AppArmorSetSecurityHostdevLabel(virSecurityManagerPtr mgr,
break; break;
} }
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST: {
/* Fall through for now */
}
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST: case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST:
ret = 0; ret = 0;
break; break;

View File

@ -676,6 +676,10 @@ virSecurityDACSetHostdevLabel(virSecurityManagerPtr mgr,
break; break;
} }
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST: {
/* Fall through for now */
}
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST: case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST:
ret = 0; ret = 0;
break; break;
@ -805,6 +809,10 @@ virSecurityDACRestoreHostdevLabel(virSecurityManagerPtr mgr,
break; break;
} }
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST: {
/* Fall through for now */
}
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST: case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST:
ret = 0; ret = 0;
break; break;

View File

@ -1498,6 +1498,10 @@ virSecuritySELinuxSetHostdevSubsysLabel(virSecurityManagerPtr mgr,
break; break;
} }
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST: {
/* Fall through for now */
}
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST: case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST:
ret = 0; ret = 0;
break; break;
@ -1700,6 +1704,10 @@ virSecuritySELinuxRestoreHostdevSubsysLabel(virSecurityManagerPtr mgr,
break; break;
} }
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI_HOST: {
/* Fall through for now */
}
case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST: case VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_LAST:
ret = 0; ret = 0;
break; break;

View File

@ -87,6 +87,7 @@
<value>usb</value> <value>usb</value>
<value>pci</value> <value>pci</value>
<value>scsi</value> <value>scsi</value>
<value>scsi_host</value>
</enum> </enum>
<enum name='capsType'> <enum name='capsType'>
<value>storage</value> <value>storage</value>