virtio/vhost-scsi: use aliases instead of duplicate qdev properties
{virtio, vhost}-scsi-{pci, s390, ccw} all duplicate the qdev properties of their VirtIOSCSI/VHostSCSI child. This approach does not work well with string or pointer properties since we must be careful about leaking or double-freeing them. Use the QOM alias property to forward property accesses to the VirtIOSCSI/VHostSCSI child. This way no duplication is necessary. Signed-off-by: Gonglei <arei.gonglei@huawei.com> Reviewed-by: Cornelia Huck <cornelia.huck@de.ibm.com> Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
6a0c6b5978
commit
c39343fd81
|
@ -258,6 +258,7 @@ static void s390_virtio_scsi_instance_init(Object *obj)
|
||||||
VirtIOSCSIS390 *dev = VIRTIO_SCSI_S390(obj);
|
VirtIOSCSIS390 *dev = VIRTIO_SCSI_S390(obj);
|
||||||
object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_SCSI);
|
object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_SCSI);
|
||||||
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
|
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
|
||||||
|
qdev_alias_all_properties(DEVICE(&dev->vdev), obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_VHOST_SCSI
|
#ifdef CONFIG_VHOST_SCSI
|
||||||
|
@ -279,6 +280,7 @@ static void s390_vhost_scsi_instance_init(Object *obj)
|
||||||
VHostSCSIS390 *dev = VHOST_SCSI_S390(obj);
|
VHostSCSIS390 *dev = VHOST_SCSI_S390(obj);
|
||||||
object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VHOST_SCSI);
|
object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VHOST_SCSI);
|
||||||
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
|
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
|
||||||
|
qdev_alias_all_properties(DEVICE(&dev->vdev), obj);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -614,7 +616,6 @@ static const TypeInfo virtio_s390_device_info = {
|
||||||
};
|
};
|
||||||
|
|
||||||
static Property s390_virtio_scsi_properties[] = {
|
static Property s390_virtio_scsi_properties[] = {
|
||||||
DEFINE_VIRTIO_SCSI_PROPERTIES(VirtIOSCSIS390, vdev.parent_obj.conf),
|
|
||||||
DEFINE_VIRTIO_COMMON_FEATURES(VirtIOS390Device, host_features),
|
DEFINE_VIRTIO_COMMON_FEATURES(VirtIOS390Device, host_features),
|
||||||
DEFINE_VIRTIO_SCSI_FEATURES(VirtIOS390Device, host_features),
|
DEFINE_VIRTIO_SCSI_FEATURES(VirtIOS390Device, host_features),
|
||||||
DEFINE_PROP_END_OF_LIST(),
|
DEFINE_PROP_END_OF_LIST(),
|
||||||
|
@ -640,7 +641,6 @@ static const TypeInfo s390_virtio_scsi = {
|
||||||
#ifdef CONFIG_VHOST_SCSI
|
#ifdef CONFIG_VHOST_SCSI
|
||||||
static Property s390_vhost_scsi_properties[] = {
|
static Property s390_vhost_scsi_properties[] = {
|
||||||
DEFINE_VIRTIO_COMMON_FEATURES(VirtIOS390Device, host_features),
|
DEFINE_VIRTIO_COMMON_FEATURES(VirtIOS390Device, host_features),
|
||||||
DEFINE_VHOST_SCSI_PROPERTIES(VHostSCSIS390, vdev.parent_obj.conf),
|
|
||||||
DEFINE_PROP_END_OF_LIST(),
|
DEFINE_PROP_END_OF_LIST(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -938,6 +938,7 @@ static void virtio_ccw_scsi_instance_init(Object *obj)
|
||||||
VirtIOSCSICcw *dev = VIRTIO_SCSI_CCW(obj);
|
VirtIOSCSICcw *dev = VIRTIO_SCSI_CCW(obj);
|
||||||
object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_SCSI);
|
object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_SCSI);
|
||||||
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
|
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
|
||||||
|
qdev_alias_all_properties(DEVICE(&dev->vdev), obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef CONFIG_VHOST_SCSI
|
#ifdef CONFIG_VHOST_SCSI
|
||||||
|
@ -959,6 +960,7 @@ static void vhost_ccw_scsi_instance_init(Object *obj)
|
||||||
VHostSCSICcw *dev = VHOST_SCSI_CCW(obj);
|
VHostSCSICcw *dev = VHOST_SCSI_CCW(obj);
|
||||||
object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VHOST_SCSI);
|
object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VHOST_SCSI);
|
||||||
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
|
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
|
||||||
|
qdev_alias_all_properties(DEVICE(&dev->vdev), obj);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -1481,7 +1483,6 @@ static const TypeInfo virtio_ccw_balloon = {
|
||||||
|
|
||||||
static Property virtio_ccw_scsi_properties[] = {
|
static Property virtio_ccw_scsi_properties[] = {
|
||||||
DEFINE_PROP_STRING("devno", VirtioCcwDevice, bus_id),
|
DEFINE_PROP_STRING("devno", VirtioCcwDevice, bus_id),
|
||||||
DEFINE_VIRTIO_SCSI_PROPERTIES(VirtIOSCSICcw, vdev.parent_obj.conf),
|
|
||||||
DEFINE_VIRTIO_SCSI_FEATURES(VirtioCcwDevice, host_features[0]),
|
DEFINE_VIRTIO_SCSI_FEATURES(VirtioCcwDevice, host_features[0]),
|
||||||
DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags,
|
DEFINE_PROP_BIT("ioeventfd", VirtioCcwDevice, flags,
|
||||||
VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true),
|
VIRTIO_CCW_FLAG_USE_IOEVENTFD_BIT, true),
|
||||||
|
@ -1510,7 +1511,6 @@ static const TypeInfo virtio_ccw_scsi = {
|
||||||
#ifdef CONFIG_VHOST_SCSI
|
#ifdef CONFIG_VHOST_SCSI
|
||||||
static Property vhost_ccw_scsi_properties[] = {
|
static Property vhost_ccw_scsi_properties[] = {
|
||||||
DEFINE_PROP_STRING("devno", VirtioCcwDevice, bus_id),
|
DEFINE_PROP_STRING("devno", VirtioCcwDevice, bus_id),
|
||||||
DEFINE_VHOST_SCSI_PROPERTIES(VirtIOSCSICcw, vdev.parent_obj.conf),
|
|
||||||
DEFINE_PROP_END_OF_LIST(),
|
DEFINE_PROP_END_OF_LIST(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1135,7 +1135,6 @@ static Property virtio_scsi_pci_properties[] = {
|
||||||
DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors,
|
DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors,
|
||||||
DEV_NVECTORS_UNSPECIFIED),
|
DEV_NVECTORS_UNSPECIFIED),
|
||||||
DEFINE_VIRTIO_SCSI_FEATURES(VirtIOPCIProxy, host_features),
|
DEFINE_VIRTIO_SCSI_FEATURES(VirtIOPCIProxy, host_features),
|
||||||
DEFINE_VIRTIO_SCSI_PROPERTIES(VirtIOSCSIPCI, vdev.parent_obj.conf),
|
|
||||||
DEFINE_PROP_END_OF_LIST(),
|
DEFINE_PROP_END_OF_LIST(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1187,6 +1186,7 @@ static void virtio_scsi_pci_instance_init(Object *obj)
|
||||||
VirtIOSCSIPCI *dev = VIRTIO_SCSI_PCI(obj);
|
VirtIOSCSIPCI *dev = VIRTIO_SCSI_PCI(obj);
|
||||||
object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_SCSI);
|
object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VIRTIO_SCSI);
|
||||||
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
|
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
|
||||||
|
qdev_alias_all_properties(DEVICE(&dev->vdev), obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo virtio_scsi_pci_info = {
|
static const TypeInfo virtio_scsi_pci_info = {
|
||||||
|
@ -1203,7 +1203,6 @@ static const TypeInfo virtio_scsi_pci_info = {
|
||||||
static Property vhost_scsi_pci_properties[] = {
|
static Property vhost_scsi_pci_properties[] = {
|
||||||
DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors,
|
DEFINE_PROP_UINT32("vectors", VirtIOPCIProxy, nvectors,
|
||||||
DEV_NVECTORS_UNSPECIFIED),
|
DEV_NVECTORS_UNSPECIFIED),
|
||||||
DEFINE_VHOST_SCSI_PROPERTIES(VHostSCSIPCI, vdev.parent_obj.conf),
|
|
||||||
DEFINE_PROP_END_OF_LIST(),
|
DEFINE_PROP_END_OF_LIST(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1243,6 +1242,7 @@ static void vhost_scsi_pci_instance_init(Object *obj)
|
||||||
VHostSCSIPCI *dev = VHOST_SCSI_PCI(obj);
|
VHostSCSIPCI *dev = VHOST_SCSI_PCI(obj);
|
||||||
object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VHOST_SCSI);
|
object_initialize(&dev->vdev, sizeof(dev->vdev), TYPE_VHOST_SCSI);
|
||||||
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
|
object_property_add_child(obj, "virtio-backend", OBJECT(&dev->vdev), NULL);
|
||||||
|
qdev_alias_all_properties(DEVICE(&dev->vdev), obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
static const TypeInfo vhost_scsi_pci_info = {
|
static const TypeInfo vhost_scsi_pci_info = {
|
||||||
|
|
Loading…
Reference in a new issue