提交 4385df97 编写于 作者: E Erik Skultety

nodedev: Introduce new mdev_types and mdev nodedev capabilities

The reason for introducing two capabilities, one for the device itself
(cap 'mdev') and one for the parent device listing the available types
('mdev_types'), is that we should be able to do
'virsh nodedev-list --cap' not only for existing mdev devices but also
for devices that support creation of mdev devices, since one day libvirt
might be actually able to create the mdev devices in an automated way
(just like we do for NPIV/vHBA).

https://bugzilla.redhat.com/show_bug.cgi?id=1452072Signed-off-by: NErik Skultety <eskultet@redhat.com>
上级 a5c1f3b7
...@@ -79,6 +79,8 @@ typedef enum { ...@@ -79,6 +79,8 @@ typedef enum {
VIR_CONNECT_LIST_NODE_DEVICES_CAP_VPORTS = 1 << 10, /* Capable of vport */ VIR_CONNECT_LIST_NODE_DEVICES_CAP_VPORTS = 1 << 10, /* Capable of vport */
VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI_GENERIC = 1 << 11, /* Capable of scsi_generic */ VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI_GENERIC = 1 << 11, /* Capable of scsi_generic */
VIR_CONNECT_LIST_NODE_DEVICES_CAP_DRM = 1 << 12, /* DRM device */ VIR_CONNECT_LIST_NODE_DEVICES_CAP_DRM = 1 << 12, /* DRM device */
VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV_TYPES = 1 << 13, /* Capable of mediated devices */
VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV = 1 << 14, /* Mediated device */
} virConnectListAllNodeDeviceFlags; } virConnectListAllNodeDeviceFlags;
int virConnectListAllNodeDevices (virConnectPtr conn, int virConnectListAllNodeDevices (virConnectPtr conn,
......
...@@ -60,7 +60,9 @@ VIR_ENUM_IMPL(virNodeDevCap, VIR_NODE_DEV_CAP_LAST, ...@@ -60,7 +60,9 @@ VIR_ENUM_IMPL(virNodeDevCap, VIR_NODE_DEV_CAP_LAST,
"fc_host", "fc_host",
"vports", "vports",
"scsi_generic", "scsi_generic",
"drm") "drm",
"mdev_types",
"mdev")
VIR_ENUM_IMPL(virNodeDevNetCap, VIR_NODE_DEV_CAP_NET_LAST, VIR_ENUM_IMPL(virNodeDevNetCap, VIR_NODE_DEV_CAP_NET_LAST,
"80203", "80203",
...@@ -540,6 +542,8 @@ virNodeDeviceDefFormat(const virNodeDeviceDef *def) ...@@ -540,6 +542,8 @@ virNodeDeviceDefFormat(const virNodeDeviceDef *def)
case VIR_NODE_DEV_CAP_DRM: case VIR_NODE_DEV_CAP_DRM:
virBufferEscapeString(&buf, "<type>%s</type>\n", virNodeDevDRMTypeToString(data->drm.type)); virBufferEscapeString(&buf, "<type>%s</type>\n", virNodeDevDRMTypeToString(data->drm.type));
break; break;
case VIR_NODE_DEV_CAP_MDEV:
case VIR_NODE_DEV_CAP_MDEV_TYPES:
case VIR_NODE_DEV_CAP_FC_HOST: case VIR_NODE_DEV_CAP_FC_HOST:
case VIR_NODE_DEV_CAP_VPORTS: case VIR_NODE_DEV_CAP_VPORTS:
case VIR_NODE_DEV_CAP_LAST: case VIR_NODE_DEV_CAP_LAST:
...@@ -1612,6 +1616,8 @@ virNodeDevCapsDefParseXML(xmlXPathContextPtr ctxt, ...@@ -1612,6 +1616,8 @@ virNodeDevCapsDefParseXML(xmlXPathContextPtr ctxt,
case VIR_NODE_DEV_CAP_DRM: case VIR_NODE_DEV_CAP_DRM:
ret = virNodeDevCapDRMParseXML(ctxt, def, node, &caps->data.drm); ret = virNodeDevCapDRMParseXML(ctxt, def, node, &caps->data.drm);
break; break;
case VIR_NODE_DEV_CAP_MDEV:
case VIR_NODE_DEV_CAP_MDEV_TYPES:
case VIR_NODE_DEV_CAP_FC_HOST: case VIR_NODE_DEV_CAP_FC_HOST:
case VIR_NODE_DEV_CAP_VPORTS: case VIR_NODE_DEV_CAP_VPORTS:
case VIR_NODE_DEV_CAP_SCSI_GENERIC: case VIR_NODE_DEV_CAP_SCSI_GENERIC:
...@@ -1930,6 +1936,8 @@ virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps) ...@@ -1930,6 +1936,8 @@ virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps)
case VIR_NODE_DEV_CAP_SCSI_GENERIC: case VIR_NODE_DEV_CAP_SCSI_GENERIC:
VIR_FREE(data->sg.path); VIR_FREE(data->sg.path);
break; break;
case VIR_NODE_DEV_CAP_MDEV:
case VIR_NODE_DEV_CAP_MDEV_TYPES:
case VIR_NODE_DEV_CAP_DRM: case VIR_NODE_DEV_CAP_DRM:
case VIR_NODE_DEV_CAP_FC_HOST: case VIR_NODE_DEV_CAP_FC_HOST:
case VIR_NODE_DEV_CAP_VPORTS: case VIR_NODE_DEV_CAP_VPORTS:
......
...@@ -64,6 +64,8 @@ typedef enum { ...@@ -64,6 +64,8 @@ typedef enum {
VIR_NODE_DEV_CAP_VPORTS, /* HBA which is capable of vports */ VIR_NODE_DEV_CAP_VPORTS, /* HBA which is capable of vports */
VIR_NODE_DEV_CAP_SCSI_GENERIC, /* SCSI generic device */ VIR_NODE_DEV_CAP_SCSI_GENERIC, /* SCSI generic device */
VIR_NODE_DEV_CAP_DRM, /* DRM device */ VIR_NODE_DEV_CAP_DRM, /* DRM device */
VIR_NODE_DEV_CAP_MDEV_TYPES, /* Device capable of mediated devices */
VIR_NODE_DEV_CAP_MDEV, /* Mediated device */
VIR_NODE_DEV_CAP_LAST VIR_NODE_DEV_CAP_LAST
} virNodeDevCapType; } virNodeDevCapType;
...@@ -351,7 +353,9 @@ virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps); ...@@ -351,7 +353,9 @@ virNodeDevCapsDefFree(virNodeDevCapsDefPtr caps);
VIR_CONNECT_LIST_NODE_DEVICES_CAP_FC_HOST | \ VIR_CONNECT_LIST_NODE_DEVICES_CAP_FC_HOST | \
VIR_CONNECT_LIST_NODE_DEVICES_CAP_VPORTS | \ VIR_CONNECT_LIST_NODE_DEVICES_CAP_VPORTS | \
VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI_GENERIC | \ VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI_GENERIC | \
VIR_CONNECT_LIST_NODE_DEVICES_CAP_DRM) VIR_CONNECT_LIST_NODE_DEVICES_CAP_DRM | \
VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV_TYPES | \
VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV)
char * char *
virNodeDeviceGetParentName(virConnectPtr conn, virNodeDeviceGetParentName(virConnectPtr conn,
......
...@@ -550,7 +550,9 @@ virNodeDeviceMatch(virNodeDeviceObjPtr devobj, ...@@ -550,7 +550,9 @@ virNodeDeviceMatch(virNodeDeviceObjPtr devobj,
MATCH(FC_HOST) || MATCH(FC_HOST) ||
MATCH(VPORTS) || MATCH(VPORTS) ||
MATCH(SCSI_GENERIC) || MATCH(SCSI_GENERIC) ||
MATCH(DRM))) MATCH(DRM) ||
MATCH(MDEV_TYPES) ||
MATCH(MDEV)))
return false; return false;
} }
......
...@@ -98,6 +98,8 @@ virNodeNumOfDevices(virConnectPtr conn, const char *cap, unsigned int flags) ...@@ -98,6 +98,8 @@ virNodeNumOfDevices(virConnectPtr conn, const char *cap, unsigned int flags)
* VIR_CONNECT_LIST_NODE_DEVICES_CAP_VPORTS * VIR_CONNECT_LIST_NODE_DEVICES_CAP_VPORTS
* VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI_GENERIC * VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI_GENERIC
* VIR_CONNECT_LIST_NODE_DEVICES_CAP_DRM * VIR_CONNECT_LIST_NODE_DEVICES_CAP_DRM
* VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV_TYPES
* VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV
* *
* Returns the number of node devices found or -1 and sets @devices to NULL in * Returns the number of node devices found or -1 and sets @devices to NULL in
* case of error. On success, the array stored into @devices is guaranteed to * case of error. On success, the array stored into @devices is guaranteed to
......
...@@ -82,6 +82,8 @@ static int update_caps(virNodeDeviceObjPtr dev) ...@@ -82,6 +82,8 @@ static int update_caps(virNodeDeviceObjPtr dev)
case VIR_NODE_DEV_CAP_FC_HOST: case VIR_NODE_DEV_CAP_FC_HOST:
case VIR_NODE_DEV_CAP_VPORTS: case VIR_NODE_DEV_CAP_VPORTS:
case VIR_NODE_DEV_CAP_SCSI_GENERIC: case VIR_NODE_DEV_CAP_SCSI_GENERIC:
case VIR_NODE_DEV_CAP_MDEV_TYPES:
case VIR_NODE_DEV_CAP_MDEV:
case VIR_NODE_DEV_CAP_LAST: case VIR_NODE_DEV_CAP_LAST:
break; break;
} }
......
...@@ -43,6 +43,7 @@ ...@@ -43,6 +43,7 @@
#include "virpci.h" #include "virpci.h"
#include "virstring.h" #include "virstring.h"
#include "virnetdev.h" #include "virnetdev.h"
#include "virmdev.h"
#define VIR_FROM_THIS VIR_FROM_NODEDEV #define VIR_FROM_THIS VIR_FROM_NODEDEV
...@@ -1060,6 +1061,8 @@ static int udevGetDeviceDetails(struct udev_device *device, ...@@ -1060,6 +1061,8 @@ static int udevGetDeviceDetails(struct udev_device *device,
return udevProcessSCSIGeneric(device, def); return udevProcessSCSIGeneric(device, def);
case VIR_NODE_DEV_CAP_DRM: case VIR_NODE_DEV_CAP_DRM:
return udevProcessDRMDevice(device, def); return udevProcessDRMDevice(device, def);
case VIR_NODE_DEV_CAP_MDEV:
case VIR_NODE_DEV_CAP_MDEV_TYPES:
case VIR_NODE_DEV_CAP_SYSTEM: case VIR_NODE_DEV_CAP_SYSTEM:
case VIR_NODE_DEV_CAP_FC_HOST: case VIR_NODE_DEV_CAP_FC_HOST:
case VIR_NODE_DEV_CAP_VPORTS: case VIR_NODE_DEV_CAP_VPORTS:
......
...@@ -454,6 +454,12 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED) ...@@ -454,6 +454,12 @@ cmdNodeListDevices(vshControl *ctl, const vshCmd *cmd ATTRIBUTE_UNUSED)
case VIR_NODE_DEV_CAP_DRM: case VIR_NODE_DEV_CAP_DRM:
flags |= VIR_CONNECT_LIST_NODE_DEVICES_CAP_DRM; flags |= VIR_CONNECT_LIST_NODE_DEVICES_CAP_DRM;
break; break;
case VIR_NODE_DEV_CAP_MDEV_TYPES:
flags |= VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV_TYPES;
break;
case VIR_NODE_DEV_CAP_MDEV:
flags |= VIR_CONNECT_LIST_NODE_DEVICES_CAP_MDEV;
break;
case VIR_NODE_DEV_CAP_LAST: case VIR_NODE_DEV_CAP_LAST:
break; break;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册