Philippe Mathieu-Daudé <[email protected]> writes:

> (See commits dc3edf8d8a "Convert to qdev_unrealize() manually"
>  and 981c3dcd94 "Convert to qdev_unrealize() with Coccinelle").
>
> Reported-by: Markus Armbruster <[email protected]>
> Signed-off-by: Philippe Mathieu-Daudé <[email protected]>
> ---
>  hw/pci/pcie_sriov.c | 5 ++---
>  1 file changed, 2 insertions(+), 3 deletions(-)
>
> diff --git a/hw/pci/pcie_sriov.c b/hw/pci/pcie_sriov.c
> index 93b0624599..0b6101302b 100644
> --- a/hw/pci/pcie_sriov.c
> +++ b/hw/pci/pcie_sriov.c
> @@ -204,11 +204,10 @@ static void unregister_vfs(PCIDevice *dev)
>      for (i = 0; i < num_vfs; i++) {
>          Error *errp = NULL;
>          PCIDevice *vf = dev->exp.sriov_pf.vf[i];
> -        object_property_set_bool(OBJECT(vf), "realized", false, &errp);
> -        if (errp) {
> +
> +        if (!qdev_unrealize_and_unref(DEVICE(vf), &errp)) {
>              warn_reportf_err(errp, "Failed to unplug: ");
>          }
> -        object_unparent(OBJECT(vf));
>      }
>      g_free(dev->exp.sriov_pf.vf);
>      dev->exp.sriov_pf.vf = NULL;

This replaces object_unref() by object_unparent().  Why is that okay?


Reply via email to