qemu-devel
[Top][All Lists]
Advanced

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

Re: About the instance_finalize callback in VFIO PCI


From: Cédric Le Goater
Subject: Re: About the instance_finalize callback in VFIO PCI
Date: Tue, 21 Mar 2023 18:30:14 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.9.0

On 3/20/23 10:31, Yang Zhong wrote:
Hello Alex and Paolo,

There is one instance_finalize callback definition in hw/vfio/pci.c, but
i find this callback(vfio_instance_finalize()) never be called during the
VM shutdown with close VM or "init 0" command in guest.

The Qemu related command:
    ......
    -device vfio-pci,host=d9:00.0
    ......

well, the finalize op is correctly called for hot unplugged devices, using
device_add.

static const TypeInfo vfio_pci_dev_info = {
     .name = TYPE_VFIO_PCI,
     .parent = TYPE_PCI_DEVICE,
     .instance_size = sizeof(VFIOPCIDevice),
     .class_init = vfio_pci_dev_class_init,
     .instance_init = vfio_instance_init,
     .instance_finalize = vfio_instance_finalize,
     .interfaces = (InterfaceInfo[]) {
         { INTERFACE_PCIE_DEVICE },
         { INTERFACE_CONVENTIONAL_PCI_DEVICE },
         { }
     },
};

If my test method is wrong, would you please tell me how to trigger to
this callback when VM shutdown? thanks

I would have thought that user_creatable_cleanup would have taken care
of it. But it's not. This needs some digging.

C.

By the way, i also debugged other instance_finalize callback functions,
if my understanding is right, all instance_finalize callback should be
called from object_unref(object) from qemu_cleanup(void) in
./softmmu/runstate.c. But there is no VFIO related object_unref() call in
this cleanup function, So the instance_finalize callback in vfio pci
should be useless? thanks!

Regards,
Yang






reply via email to

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