vfio/pci: Fix instance_size of VFIO_PCI_BASE
PATCH 1/1 vfio/pci: Fix instance_size of VFIO_PCI_BASE
Currently the final instance_size of VFIO_PCI_BASE is sizeof(PCIDevice). It should be sizeof(VFIOPCIDevice), VFIO_PCI uses same structure as base class VFIO_PCI_BASE, so no need to set its instance_size explicitly.
This isn't catastrophic only because VFIO_PCI_BASE is an abstract class.
--- hw/vfio/pci.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)
hw/vfio/pci.c +1 -2
@@ -3478,7 +3478,7 @@ static void vfio_pci_base_dev_class_init(ObjectClass *klass, const void *data)static const TypeInfo vfio_pci_base_dev_info = { .name =TYPE_VFIO_PCI_BASE , .parent =TYPE_PCI_DEVICE , - .instance_size =0 , + .instance_size =sizeof (VFIOPCIDevice), .abstract = true, .class_init = vfio_pci_base_dev_class_init, .interfaces = (const InterfaceInfo []) {
@@ -3701,7 +3701,6 @@ static void vfio_pci_dev_class_init(ObjectClass *klass, const void *data)static const TypeInfo vfio_pci_dev_info = { .name =TYPE_VFIO_PCI , .parent =TYPE_VFIO_PCI_BASE , - .instance_size =sizeof (VFIOPCIDevice), .class_init = vfio_pci_dev_class_init, .instance_init = vfio_instance_init, .instance_finalize = vfio_instance_finalize,
Signature · 1 line
2.34.1
Quoted 1 line · Zhenzhong Duan
Currently the final
instance_sizeofVFIO_PCI_BASEis sizeof(PCIDevice).
For the people who has a doubt how the size is sizeof(PCIDevice). :)
* @instance_size: The size of the object (derivative of #Object). If
* @instance_size is 0, then the size of the object will be the size of the
* parent object.
Quoted 25 lines
It should be sizeof(VFIOPCIDevice),
VFIO_PCIuses same structure as base classVFIO_PCI_BASE, so no need to set itsinstance_sizeexplicitly.This isn't catastrophic only because
VFIO_PCI_BASEis an abstract class.Fixes d4e392d0a99b ("vfio: add vfio-pci-base class")Signed-off-by Zhenzhong Duan <[email protected]>--- hw/vfio/pci.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)hw/vfio/pci.c +1
-1@@ -3478,7 +3478,7 @@ static void vfio_pci_base_dev_class_init(ObjectClass *klass, const void *data)static const TypeInfo vfio_pci_base_dev_info = { .name =TYPE_VFIO_PCI_BASE , .parent =TYPE_PCI_DEVICE , - .instance_size =0 , + .instance_size =sizeof (VFIOPCIDevice), .abstract = true, .class_init = vfio_pci_base_dev_class_init, .interfaces = (const InterfaceInfo []) {
hw/vfio/pci.c static void vfio_pci_dev_class_init(ObjectClass *klass, const void *data) · line 3706
Quoted 7 lines
hw/vfio/pci.c +0
-1@@ -3701,7 +3701,6 @@ static void vfio_pci_dev_class_init(ObjectClass *klass, const void *data)static const TypeInfo vfio_pci_dev_info = { .name =TYPE_VFIO_PCI , .parent =TYPE_VFIO_PCI_BASE , - .instance_size =sizeof (VFIOPCIDevice), .class_init = vfio_pci_dev_class_init, .instance_init = vfio_instance_init, .instance_finalize = vfio_instance_finalize,
LGTM.
Signature · 2 lines
Regards, Yi Liu
Quoted 8 lines · Zhenzhong Duan
Currently the final
instance_sizeofVFIO_PCI_BASEis sizeof(PCIDevice). It should be sizeof(VFIOPCIDevice),VFIO_PCIuses same structure as base classVFIO_PCI_BASE, so no need to set itsinstance_sizeexplicitly.This isn't catastrophic only because
VFIO_PCI_BASEis an abstract class.Fixes d4e392d0a99b ("vfio: add vfio-pci-base class")Signed-off-by Zhenzhong Duan <[email protected]>
Hey, we were discussing this issue on IRC yesterday (#qemu on OFTC)
Applied to vfio-next.
Thanks,
C.
Quoted 25 lines
--- hw/vfio/pci.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-)hw/vfio/pci.c +1
-2@@ -3478,7 +3478,7 @@ static void vfio_pci_base_dev_class_init(ObjectClass *klass, const void *data)static const TypeInfo vfio_pci_base_dev_info = { .name =TYPE_VFIO_PCI_BASE , .parent =TYPE_PCI_DEVICE , - .instance_size =0 , + .instance_size =sizeof (VFIOPCIDevice), .abstract = true, .class_init = vfio_pci_base_dev_class_init, .interfaces = (const InterfaceInfo []) {@@ -3701,7 +3701,6 @@ static void vfio_pci_dev_class_init(ObjectClass *klass, const void *data)static const TypeInfo vfio_pci_dev_info = { .name =TYPE_VFIO_PCI , .parent =TYPE_VFIO_PCI_BASE , - .instance_size =sizeof (VFIOPCIDevice), .class_init = vfio_pci_dev_class_init, .instance_init = vfio_instance_init, .instance_finalize = vfio_instance_finalize,
Quoted 11 lines
-----Original Message-----
From: Cédric Le Goater <[email protected]>
Subject: Re: [PATCH] vfio/pci: Fixinstance_sizeofVFIO_PCI_BASEQuoted 4 lines · Zhenzhong Duan
Currently the final
instance_sizeofVFIO_PCI_BASEis sizeof(PCIDevice). It should be sizeof(VFIOPCIDevice),VFIO_PCIuses same structure as base classVFIO_PCI_BASE, so no need to set itsinstance_sizeexplicitly.
Quoted 7 lines
Quoted 4 lines
This isn't catastrophic only because
VFIO_PCI_BASEis an abstract class.Fixes d4e392d0a99b ("vfio: add vfio-pci-base class")Signed-off-by Zhenzhong Duan <[email protected]>Hey, we were discussing this issue on IRC yesterday (#qemu on OFTC)
Ah, What a coincidence!
BRs,
Zhenzhong
Quoted 8 lines · Zhenzhong Duan
Currently the final
instance_sizeofVFIO_PCI_BASEis sizeof(PCIDevice). It should be sizeof(VFIOPCIDevice),VFIO_PCIuses same structure as base classVFIO_PCI_BASE, so no need to set itsinstance_sizeexplicitly.This isn't catastrophic only because
VFIO_PCI_BASEis an abstract class.Fixes d4e392d0a99b ("vfio: add vfio-pci-base class")Signed-off-by Zhenzhong Duan <[email protected]>
Thanks! I had a similar patch after IRC discussion.
regards
john