qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@linaro.org>
To: Zhenzhong Duan <zhenzhong.duan@intel.com>, qemu-devel@nongnu.org
Cc: alex.williamson@redhat.com, clg@redhat.com,
	eric.auger@redhat.com, chao.p.peng@intel.com
Subject: Re: [PATCH v3] vfio: Introduce helper vfio_pci_from_vfio_device()
Date: Fri, 1 Aug 2025 16:14:05 +0200	[thread overview]
Message-ID: <83d920b8-1838-43c7-a86f-5f4e5e5980b3@linaro.org> (raw)
In-Reply-To: <20250801023533.1458644-1-zhenzhong.duan@intel.com>

On 1/8/25 04:35, Zhenzhong Duan wrote:
> Introduce helper vfio_pci_from_vfio_device() to transform from VFIODevice
> to VFIOPCIDevice, also to hide low level VFIO_DEVICE_TYPE_PCI type check.
> 
> Suggested-by: Cédric Le Goater <clg@redhat.com>
> Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
> ---
> v3: add one line comment to the helper
> v2: move helper to hw/vfio/pci.[hc]
>      rename with vfio_pci_ prefix
> 
>   hw/vfio/pci.h       | 1 +
>   hw/vfio/container.c | 4 ++--
>   hw/vfio/device.c    | 2 +-
>   hw/vfio/iommufd.c   | 4 ++--
>   hw/vfio/listener.c  | 4 ++--
>   hw/vfio/pci.c       | 9 +++++++++
>   6 files changed, 17 insertions(+), 7 deletions(-)
> 
> diff --git a/hw/vfio/pci.h b/hw/vfio/pci.h
> index 81465a8214..53842cb149 100644
> --- a/hw/vfio/pci.h
> +++ b/hw/vfio/pci.h
> @@ -219,6 +219,7 @@ void vfio_pci_write_config(PCIDevice *pdev,
>   uint64_t vfio_vga_read(void *opaque, hwaddr addr, unsigned size);
>   void vfio_vga_write(void *opaque, hwaddr addr, uint64_t data, unsigned size);
>   

[*]

> +VFIOPCIDevice *vfio_pci_from_vfio_device(VFIODevice *vbasedev);
>   void vfio_sub_page_bar_update_mappings(VFIOPCIDevice *vdev);
>   bool vfio_opt_rom_in_denylist(VFIOPCIDevice *vdev);
>   bool vfio_config_quirk_setup(VFIOPCIDevice *vdev, Error **errp);

Quoting https://lore.kernel.org/qemu-devel/87bjpl25e6.fsf@draig.linaro.org/:

   Generally APIs to the rest of QEMU should be documented in the
   headers. Comments on individual functions or internal details are
   fine to live in the C files.

> diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
> index 4fa692c1a3..85761544ba 100644
> --- a/hw/vfio/pci.c
> +++ b/hw/vfio/pci.c
> @@ -2824,6 +2824,15 @@ static int vfio_pci_load_config(VFIODevice *vbasedev, QEMUFile *f)
>       return ret;
>   }
>   
> +/* Transform from VFIODevice to VFIOPCIDevice. Return NULL if fails. */

So this comment preferably goes in [*]. Otherwise,

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>

> +VFIOPCIDevice *vfio_pci_from_vfio_device(VFIODevice *vbasedev)
> +{
> +    if (vbasedev && vbasedev->type == VFIO_DEVICE_TYPE_PCI) {
> +        return container_of(vbasedev, VFIOPCIDevice, vbasedev);
> +    }
> +    return NULL;
> +}



  parent reply	other threads:[~2025-08-01 14:26 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-08-01  2:35 [PATCH v3] vfio: Introduce helper vfio_pci_from_vfio_device() Zhenzhong Duan
2025-08-01  5:42 ` Cédric Le Goater
2025-08-01 15:05   ` Cédric Le Goater
2025-08-01 15:56     ` Peter Maydell
2025-08-01 16:33       ` Cédric Le Goater
2025-08-04  2:22     ` Duan, Zhenzhong
2025-08-01 14:14 ` Philippe Mathieu-Daudé [this message]
2025-08-04  2:27   ` Duan, Zhenzhong

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=83d920b8-1838-43c7-a86f-5f4e5e5980b3@linaro.org \
    --to=philmd@linaro.org \
    --cc=alex.williamson@redhat.com \
    --cc=chao.p.peng@intel.com \
    --cc=clg@redhat.com \
    --cc=eric.auger@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=zhenzhong.duan@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).