From: "Cédric Le Goater" <clg@redhat.com>
To: "Philippe Mathieu-Daudé" <philmd@linaro.org>, qemu-devel@nongnu.org
Cc: Alex Williamson <alex.williamson@redhat.com>
Subject: Re: [PATCH v2 4/9] vfio: Introduce vfio_get_vfio_device()
Date: Mon, 10 Feb 2025 17:19:49 +0100 [thread overview]
Message-ID: <9ff6b8cb-e30f-4e5e-bd8b-714388e7a7b6@redhat.com> (raw)
In-Reply-To: <281482d8-f6db-440f-a892-ad1600e7dc56@linaro.org>
On 2/10/25 15:32, Philippe Mathieu-Daudé wrote:
> On 30/1/25 14:43, Cédric Le Goater wrote:
>> This helper will be useful in the listener handlers to extract the
>> VFIO device from a memory region using memory_region_owner(). At the
>> moment, we only care for PCI passthrough devices. If the need arises,
>> we will add more.
>>
>> Signed-off-by: Cédric Le Goater <clg@redhat.com>
>> ---
>> include/hw/vfio/vfio-common.h | 1 +
>> hw/vfio/helpers.c | 10 ++++++++++
>> 2 files changed, 11 insertions(+)
>>
>> diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h
>> index 0c60be5b15c70168f4f94ad7054d9bd750a162d3..ac35136a11051b079cd9d04e6becd344a0e0f7e7 100644
>> --- a/include/hw/vfio/vfio-common.h
>> +++ b/include/hw/vfio/vfio-common.h
>> @@ -252,6 +252,7 @@ bool vfio_device_hiod_realize(VFIODevice *vbasedev, Error **errp);
>> bool vfio_attach_device(char *name, VFIODevice *vbasedev,
>> AddressSpace *as, Error **errp);
>> void vfio_detach_device(VFIODevice *vbasedev);
>> +VFIODevice *vfio_get_vfio_device(Object *obj);
>> int vfio_kvm_device_add_fd(int fd, Error **errp);
>> int vfio_kvm_device_del_fd(int fd, Error **errp);
>> diff --git a/hw/vfio/helpers.c b/hw/vfio/helpers.c
>> index 913796f437f84eece8711cb4b4b654a44040d17c..4b255d4f3a9e81f55df00c68fc71da769fd5bd04 100644
>> --- a/hw/vfio/helpers.c
>> +++ b/hw/vfio/helpers.c
>> @@ -23,6 +23,7 @@
>> #include <sys/ioctl.h>
>> #include "hw/vfio/vfio-common.h"
>> +#include "hw/vfio/pci.h"
>> #include "hw/hw.h"
>> #include "trace.h"
>> #include "qapi/error.h"
>> @@ -728,3 +729,12 @@ bool vfio_device_hiod_realize(VFIODevice *vbasedev, Error **errp)
>> return HOST_IOMMU_DEVICE_GET_CLASS(hiod)->realize(hiod, vbasedev, errp);
>> }
>> +
>> +VFIODevice *vfio_get_vfio_device(Object *obj)
>
> Can't we take a VFIOPCIDevice argument?
It could be some other VFIO (AP, Plateform) device type and we wouldn't
need to do the cast below in that case.
Thanks,
C.
>
>> +{
>> + if (object_dynamic_cast(obj, TYPE_VFIO_PCI)) {
>> + return &VFIO_PCI(obj)->vbasedev;
>> + } else {
>> + return NULL;
>> + }
>> +}
>
next prev parent reply other threads:[~2025-02-10 16:21 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-30 13:43 [PATCH v2 0/9]vfio: Improve error reporting when MMIO region mapping fails Cédric Le Goater
2025-01-30 13:43 ` [PATCH v2 1/9] util/error: Introduce warn_report_once_err() Cédric Le Goater
2025-01-30 14:25 ` Markus Armbruster
2025-01-30 16:03 ` Cédric Le Goater
2025-01-30 16:28 ` Cédric Le Goater
2025-01-30 17:55 ` Alex Williamson
2025-01-30 21:26 ` Cédric Le Goater
2025-01-31 8:30 ` Markus Armbruster
2025-01-30 13:43 ` [PATCH v2 2/9] vfio/pci: Replace "iommu_device" by "vIOMMU" Cédric Le Goater
2025-02-10 14:28 ` Philippe Mathieu-Daudé
2025-01-30 13:43 ` [PATCH v2 3/9] vfio: Rephrase comment in vfio_listener_region_add() error path Cédric Le Goater
2025-01-30 13:43 ` [PATCH v2 4/9] vfio: Introduce vfio_get_vfio_device() Cédric Le Goater
2025-02-10 14:32 ` Philippe Mathieu-Daudé
2025-02-10 16:19 ` Cédric Le Goater [this message]
2025-01-30 13:43 ` [PATCH v2 5/9] vfio: Improve error reporting when MMIO region mapping fails Cédric Le Goater
2025-02-10 14:36 ` Philippe Mathieu-Daudé
2025-02-10 16:17 ` Cédric Le Goater
2025-01-30 13:43 ` [PATCH v2 6/9] vfio: Remove reports of DMA mapping errors in backends Cédric Le Goater
2025-01-30 13:43 ` [PATCH v2 7/9] cpu: Introduce cpu_get_phys_bits() Cédric Le Goater
2025-02-10 14:40 ` Philippe Mathieu-Daudé
2025-03-06 10:37 ` Philippe Mathieu-Daudé
2025-03-06 14:41 ` Cédric Le Goater
2025-01-30 13:43 ` [PATCH v2 8/9] vfio: Check compatibility of CPU and IOMMU address space width Cédric Le Goater
2025-01-30 18:58 ` Alex Williamson
2025-01-31 12:42 ` Cédric Le Goater
2025-01-31 13:23 ` Gerd Hoffmann
2025-01-31 17:03 ` Cédric Le Goater
2025-02-06 7:54 ` Gerd Hoffmann
2025-02-06 17:05 ` Cédric Le Goater
2025-01-31 22:18 ` Alex Williamson
2025-02-06 8:22 ` Gerd Hoffmann
2025-03-06 10:33 ` Philippe Mathieu-Daudé
2025-09-05 13:04 ` Daniel Kral
2025-09-08 8:35 ` Cédric Le Goater
2025-01-30 13:43 ` [PATCH v2 9/9] vfio: Remove superfluous error report in vfio_listener_region_add() Cédric Le Goater
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=9ff6b8cb-e30f-4e5e-bd8b-714388e7a7b6@redhat.com \
--to=clg@redhat.com \
--cc=alex.williamson@redhat.com \
--cc=philmd@linaro.org \
--cc=qemu-devel@nongnu.org \
/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).