[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

a quetion about sysbus_realize_and_unref function

From: Chan Kim
Subject: a quetion about sysbus_realize_and_unref function
Date: Mon, 18 Oct 2021 21:01:11 +0900

Hi, list members,

I see for example in hw/arm/virt.c, when it creates a device to attach to a system bus, it calls “sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);” function


static void create_its(VirtMachineState *vms)


    const char *itsclass = its_class_name();

    DeviceState *dev;


    if (!itsclass) {

        /* Do nothing if not supported */




    dev = qdev_new(itsclass);


    object_property_set_link(OBJECT(dev), "parent-gicv3", OBJECT(vms->gic),


    sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);

    sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, vms->memmap[VIRT_GIC_ITS].base);



    vms->msi_controller = VIRT_MSI_CTRL_ITS;



The document says it decrements the reference counter and when the ref count is non zero, the object can’t be removed.

Then why does it call sysbus_realize_and_unref function to reduce the ref count of the system bus(=parent object) of the device being create?

Thank you,

Chan Kim


reply via email to

[Prev in Thread] Current Thread [Next in Thread]