diff mbox series

[19/21] hw/s390x/zpci-bus: Add QOM parentship relation with zPCI devices

Message ID 20240216110313.17039-20-philmd@linaro.org
State New
Headers show
Series hw: More QDev cleanups | expand

Commit Message

Philippe Mathieu-Daudé Feb. 16, 2024, 11:03 a.m. UTC
QDev objects created with qdev_*new() need to manually add
their parent relationship with object_property_add_child().

Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
---
 hw/s390x/s390-pci-bus.c | 1 +
 1 file changed, 1 insertion(+)

Comments

Thomas Huth Feb. 19, 2024, 1:38 p.m. UTC | #1
On 16/02/2024 12.03, Philippe Mathieu-Daudé wrote:
> QDev objects created with qdev_*new() need to manually add
> their parent relationship with object_property_add_child().
> 
> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> ---
>   hw/s390x/s390-pci-bus.c | 1 +
>   1 file changed, 1 insertion(+)
> 
> diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c
> index 3e57d5faca..6d07a7b530 100644
> --- a/hw/s390x/s390-pci-bus.c
> +++ b/hw/s390x/s390-pci-bus.c
> @@ -934,6 +934,7 @@ static S390PCIBusDevice *s390_pci_device_new(S390pciState *s,
>                                   "zPCI device could not be created: ");
>           return NULL;
>       }
> +    object_property_add_child(OBJECT(s), "zpci[*]", OBJECT(dev));

I think there can only be one zpci device per PCI device, so do we need the 
"[*]" here?

  Thomas

>       if (!qdev_realize_and_unref(dev, BUS(s->bus), &local_err)) {
>           object_unparent(OBJECT(dev));
>           error_propagate_prepend(errp, local_err,
Philippe Mathieu-Daudé Feb. 19, 2024, 2:37 p.m. UTC | #2
On 19/2/24 14:38, Thomas Huth wrote:
> On 16/02/2024 12.03, Philippe Mathieu-Daudé wrote:
>> QDev objects created with qdev_*new() need to manually add
>> their parent relationship with object_property_add_child().
>>
>> Signed-off-by: Philippe Mathieu-Daudé <philmd@linaro.org>
>> ---
>>   hw/s390x/s390-pci-bus.c | 1 +
>>   1 file changed, 1 insertion(+)
>>
>> diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c
>> index 3e57d5faca..6d07a7b530 100644
>> --- a/hw/s390x/s390-pci-bus.c
>> +++ b/hw/s390x/s390-pci-bus.c
>> @@ -934,6 +934,7 @@ static S390PCIBusDevice 
>> *s390_pci_device_new(S390pciState *s,
>>                                   "zPCI device could not be created: ");
>>           return NULL;
>>       }
>> +    object_property_add_child(OBJECT(s), "zpci[*]", OBJECT(dev));
> 
> I think there can only be one zpci device per PCI device, so do we need 
> the "[*]" here?

Oh I missed that, I'll change, thanks.
diff mbox series

Patch

diff --git a/hw/s390x/s390-pci-bus.c b/hw/s390x/s390-pci-bus.c
index 3e57d5faca..6d07a7b530 100644
--- a/hw/s390x/s390-pci-bus.c
+++ b/hw/s390x/s390-pci-bus.c
@@ -934,6 +934,7 @@  static S390PCIBusDevice *s390_pci_device_new(S390pciState *s,
                                 "zPCI device could not be created: ");
         return NULL;
     }
+    object_property_add_child(OBJECT(s), "zpci[*]", OBJECT(dev));
     if (!qdev_realize_and_unref(dev, BUS(s->bus), &local_err)) {
         object_unparent(OBJECT(dev));
         error_propagate_prepend(errp, local_err,