All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] vfio/pci: Fix instance_size of VFIO_PCI_BASE
@ 2025-06-11  2:42 Zhenzhong Duan
  2025-06-11  6:43 ` Yi Liu
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Zhenzhong Duan @ 2025-06-11  2:42 UTC (permalink / raw)
  To: qemu-devel
  Cc: john.levon, chao.p.peng, Zhenzhong Duan, Alex Williamson,
	Cédric Le Goater

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.

Fixes: d4e392d0a99b ("vfio: add vfio-pci-base class")
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
---
 hw/vfio/pci.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 92562898e4..03f52a9b8f 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -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,
-- 
2.34.1



^ permalink raw reply related	[flat|nested] 5+ messages in thread

* Re: [PATCH] vfio/pci: Fix instance_size of VFIO_PCI_BASE
  2025-06-11  2:42 [PATCH] vfio/pci: Fix instance_size of VFIO_PCI_BASE Zhenzhong Duan
@ 2025-06-11  6:43 ` Yi Liu
  2025-06-11  7:19 ` Cédric Le Goater
  2025-06-11 10:28 ` John Levon
  2 siblings, 0 replies; 5+ messages in thread
From: Yi Liu @ 2025-06-11  6:43 UTC (permalink / raw)
  To: Zhenzhong Duan, qemu-devel
  Cc: john.levon, chao.p.peng, Alex Williamson, Cédric Le Goater

On 2025/6/11 10:42, Zhenzhong Duan wrote:
> Currently the final instance_size of VFIO_PCI_BASE is 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.


> 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.
> 
> Fixes: d4e392d0a99b ("vfio: add vfio-pci-base class")
> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
> ---
>   hw/vfio/pci.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
> index 92562898e4..03f52a9b8f 100644
> --- a/hw/vfio/pci.c
> +++ b/hw/vfio/pci.c
> @@ -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,

LGTM.

Reviewed-by: Yi Liu <yi.l.liu@intel.com>

-- 
Regards,
Yi Liu


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] vfio/pci: Fix instance_size of VFIO_PCI_BASE
  2025-06-11  2:42 [PATCH] vfio/pci: Fix instance_size of VFIO_PCI_BASE Zhenzhong Duan
  2025-06-11  6:43 ` Yi Liu
@ 2025-06-11  7:19 ` Cédric Le Goater
  2025-06-11  8:38   ` Duan, Zhenzhong
  2025-06-11 10:28 ` John Levon
  2 siblings, 1 reply; 5+ messages in thread
From: Cédric Le Goater @ 2025-06-11  7:19 UTC (permalink / raw)
  To: Zhenzhong Duan, qemu-devel; +Cc: john.levon, chao.p.peng, Alex Williamson

On 6/11/25 04:42, Zhenzhong Duan wrote:
> 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.
> 
> Fixes: d4e392d0a99b ("vfio: add vfio-pci-base class")
> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>


Hey, we were discussing this issue on IRC yesterday (#qemu on OFTC)

Reviewed-by: Cédric Le Goater <clg@redhat.com>

Applied to vfio-next.

Thanks,

C.


> ---
>   hw/vfio/pci.c | 3 +--
>   1 file changed, 1 insertion(+), 2 deletions(-)
> 
> diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
> index 92562898e4..03f52a9b8f 100644
> --- a/hw/vfio/pci.c
> +++ b/hw/vfio/pci.c
> @@ -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,



^ permalink raw reply	[flat|nested] 5+ messages in thread

* RE: [PATCH] vfio/pci: Fix instance_size of VFIO_PCI_BASE
  2025-06-11  7:19 ` Cédric Le Goater
@ 2025-06-11  8:38   ` Duan, Zhenzhong
  0 siblings, 0 replies; 5+ messages in thread
From: Duan, Zhenzhong @ 2025-06-11  8:38 UTC (permalink / raw)
  To: Cédric Le Goater, qemu-devel@nongnu.org
  Cc: john.levon@nutanix.com, Peng, Chao P, Alex Williamson



>-----Original Message-----
>From: Cédric Le Goater <clg@redhat.com>
>Subject: Re: [PATCH] vfio/pci: Fix instance_size of VFIO_PCI_BASE
>
>On 6/11/25 04:42, Zhenzhong Duan wrote:
>> 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.
>>
>> Fixes: d4e392d0a99b ("vfio: add vfio-pci-base class")
>> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
>
>
>Hey, we were discussing this issue on IRC yesterday (#qemu on OFTC)

Ah, What a coincidence!

BRs,
Zhenzhong


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH] vfio/pci: Fix instance_size of VFIO_PCI_BASE
  2025-06-11  2:42 [PATCH] vfio/pci: Fix instance_size of VFIO_PCI_BASE Zhenzhong Duan
  2025-06-11  6:43 ` Yi Liu
  2025-06-11  7:19 ` Cédric Le Goater
@ 2025-06-11 10:28 ` John Levon
  2 siblings, 0 replies; 5+ messages in thread
From: John Levon @ 2025-06-11 10:28 UTC (permalink / raw)
  To: Zhenzhong Duan
  Cc: qemu-devel, chao.p.peng, Alex Williamson, Cédric Le Goater

On Wed, Jun 11, 2025 at 10:42:28AM +0800, Zhenzhong Duan wrote:

> 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.
> 
> Fixes: d4e392d0a99b ("vfio: add vfio-pci-base class")
> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>

Thanks! I had a similar patch after IRC discussion.

Reviewed-by: John Levon <john.levon@nutanix.com>

regards
john


^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2025-06-11 10:29 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-06-11  2:42 [PATCH] vfio/pci: Fix instance_size of VFIO_PCI_BASE Zhenzhong Duan
2025-06-11  6:43 ` Yi Liu
2025-06-11  7:19 ` Cédric Le Goater
2025-06-11  8:38   ` Duan, Zhenzhong
2025-06-11 10:28 ` John Levon

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.