for (i = 0; i < data->mdev.nattributes; i++)
virMediatedDeviceAttrFree(data->mdev.attributes[i]);
g_free(data->mdev.attributes);
+ g_free(data->mdev.parent_addr);
break;
case VIR_NODE_DEV_CAP_CSS_DEV:
for (i = 0; i < data->ccw_dev.nmdev_types; i++)
mdev = &child->caps->data.mdev;
mdev->uuid = g_strdup(uuid);
+ mdev->parent_addr = g_strdup(parent);
mdev->type =
g_strdup(virJSONValueObjectGetString(props, "mdev_type"));
char *linkpath = NULL;
char *canonicalpath = NULL;
virNodeDevCapMdev *data = &def->caps->data.mdev;
+ struct udev_device *parent_device = NULL;
/* Because of a kernel uevent race, we might get the 'add' event prior to
* the sysfs tree being ready, so any attempt to access any sysfs attribute
if ((iommugrp = virMediatedDeviceGetIOMMUGroupNum(data->uuid)) < 0)
goto cleanup;
+ /* lookup the address of parent device */
+ parent_device = udev_device_get_parent(dev);
+ if (parent_device) {
+ const char *parent_sysfs_path = udev_device_get_syspath(parent_device);
+ if (parent_sysfs_path)
+ data->parent_addr = g_path_get_basename(parent_sysfs_path);
+ }
+
+ if (!data->parent_addr) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("Could not get parent of '%s'"),
+ udev_device_get_syspath(dev));
+ return -1;
+ }
+
udevGenerateDeviceName(dev, def, NULL);
data->iommuGroupNumber = iommugrp;