util: mdev: Introduce virMediatedDeviceType structure

This is later going to replace the existing virNodeDevCapMdevType, since:
1) it's going to couple related stuff in a single module
2) util is supposed to contain helpers that are widely accessible across
the whole repository.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
This commit is contained in:
Erik Skultety 2018-01-23 09:47:43 +01:00
parent 0674ddd317
commit c3faa92a1b
3 changed files with 26 additions and 0 deletions

View File

@ -2181,6 +2181,7 @@ virMediatedDeviceModelTypeFromString;
virMediatedDeviceModelTypeToString;
virMediatedDeviceNew;
virMediatedDeviceSetUsedBy;
virMediatedDeviceTypeFree;

View File

@ -483,3 +483,16 @@ virMediatedDeviceListMarkDevices(virMediatedDeviceListPtr dst,
}
goto cleanup;
}
void
virMediatedDeviceTypeFree(virMediatedDeviceTypePtr type)
{
if (!type)
return;
VIR_FREE(type->id);
VIR_FREE(type->name);
VIR_FREE(type->device_api);
VIR_FREE(type);
}

View File

@ -37,6 +37,15 @@ typedef virMediatedDevice *virMediatedDevicePtr;
typedef struct _virMediatedDeviceList virMediatedDeviceList;
typedef virMediatedDeviceList *virMediatedDeviceListPtr;
typedef struct _virMediatedDeviceType virMediatedDeviceType;
typedef virMediatedDeviceType *virMediatedDeviceTypePtr;
struct _virMediatedDeviceType {
char *id;
char *name;
char *device_api;
unsigned int available_instances;
};
typedef int (*virMediatedDeviceCallback)(virMediatedDevicePtr dev,
const char *path, void *opaque);
@ -117,4 +126,7 @@ virMediatedDeviceListMarkDevices(virMediatedDeviceListPtr dst,
virMediatedDeviceListPtr src,
const char *drvname,
const char *domname);
void
virMediatedDeviceTypeFree(virMediatedDeviceTypePtr type);
#endif /* __VIR_MDEV_H__ */