From: David Matlack <dmatlack@google.com>
To: Raghavendra Rao Ananta <rananta@google.com>
Cc: Alex Williamson <alex@shazbot.org>,
Alex Williamson <alex.williamson@redhat.com>,
Josh Hilke <jrhilke@google.com>,
kvm@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 1/4] vfio: selftests: Add support for passing vf_token in device init
Date: Thu, 6 Nov 2025 17:17:46 +0000 [thread overview]
Message-ID: <aQzYOjWPs0qsW4YR@google.com> (raw)
In-Reply-To: <CAJHc60xb_=v9k46MEo=6S5QmMXKnd_1FiuWQr9dkCnE_XtTkfQ@mail.gmail.com>
On 2025-11-06 09:56 PM, Raghavendra Rao Ananta wrote:
> On Thu, Nov 6, 2025 at 5:22 AM David Matlack <dmatlack@google.com> wrote:
> > On 2025-11-04 12:35 AM, Raghavendra Rao Ananta wrote:
> >
> > > -struct vfio_pci_device *vfio_pci_device_init(const char *bdf, const char *iommu_mode);
> > > +struct vfio_pci_device *vfio_pci_device_init(const char *bdf,
> > > + const char *iommu_mode,
> > > + const char *vf_token);
> >
> > Vipin is also looking at adding an optional parameter to
> > vfio_pci_device_init():
> > https://lore.kernel.org/kvm/20251018000713.677779-20-vipinsh@google.com/
> >
> > I am wondering if we should support an options struct for such
> > parameters. e.g. something like this
> >
> > diff --git a/tools/testing/selftests/vfio/lib/include/vfio_util.h b/tools/testing/selftests/vfio/lib/include/vfio_util.h
> > index b01068d98fda..cee837fe561c 100644
> > --- a/tools/testing/selftests/vfio/lib/include/vfio_util.h
> > +++ b/tools/testing/selftests/vfio/lib/include/vfio_util.h
> > @@ -160,6 +160,10 @@ struct vfio_pci_driver {
> > int msi;
> > };
> >
> > +struct vfio_pci_device_options {
> > + const char *vf_token;
> > +};
> > +
> > struct vfio_pci_device {
> > int fd;
> >
> > @@ -202,9 +206,18 @@ const char *vfio_pci_get_cdev_path(const char *bdf);
> >
> > extern const char *default_iommu_mode;
> >
> > -struct vfio_pci_device *vfio_pci_device_init(const char *bdf,
> > - const char *iommu_mode,
> > - const char *vf_token);
> > +struct vfio_pci_device *__vfio_pci_device_init(const char *bdf,
> > + const char *iommu_mode,
> > + const struct vfio_pci_device_options *options);
> > +
> > +static inline struct vfio_pci_device *vfio_pci_device_init(const char *bdf,
> > + const char *iommu_mode)
> > +{
> > + static const struct vfio_pci_device_options default_options = {};
> > +
> > + return __vfio_pci_device_init(bdf, iommu_mode, &default_options);
> > +}
> > +
> >
> > This will avoid you having to update every test.
> >
> > You can create a helper function in vfio_pci_sriov_uapi_test.c to call
> > __vfio_pci_device_init() and abstract away the options stuff from your
> > test.
> >
> I like the idea of an optional expandable struct. I'll implement this in v2.
Just to make sure we're on the same page: I don't think you need to add
this in v2 since you don't need to call vfio_pci_device_init(). For the
inner functions that you want to call from your test, passing vf_token
directly makes more sense IMO. vfio_pci_device_init() will just pass in
NULL to those functions for vf_token by default.
If/when we want to pass vf_token to vfio_pci_device_init() we can add
the options struct.
> > No space necessary after a cast. This is another one checkpatch.pl will
> > catch for you.
> >
> > CHECK:SPACING: No space is necessary after a cast
> > #81: FILE: tools/testing/selftests/vfio/lib/vfio_pci_device.c:338:
> > + char *arg = (char *) bdf;
> >
> Actually, I did run checkpatch.pl on the entire series as:
> .$ ./scripts/checkpatch.pl *.patch
>
> I didn't see any of these warnings. Are there any other options to consider?
Ah, I run with a few additional options. That's probably why we are
seeing different output. Here's what I have in my .bashrc:
function checkpatch() {
scripts/checkpatch.pl \
-q \
--strict \
--codespell \
--no-signoff \
--show-types \
--ignore gerrit_change_id,FILE_PATH_CHANGES,NOT_UNIFIED_DIFF \
--no-summary \
"$@"
}
next prev parent reply other threads:[~2025-11-06 17:17 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-04 0:35 [PATCH 0/4] vfio: selftest: Add SR-IOV UAPI test Raghavendra Rao Ananta
2025-11-04 0:35 ` [PATCH 1/4] vfio: selftests: Add support for passing vf_token in device init Raghavendra Rao Ananta
2025-11-05 23:52 ` David Matlack
2025-11-06 0:12 ` David Matlack
2025-11-06 16:33 ` Raghavendra Rao Ananta
2025-11-06 16:26 ` Raghavendra Rao Ananta
2025-11-06 17:17 ` David Matlack [this message]
2025-11-07 2:46 ` Raghavendra Rao Ananta
2025-11-06 0:14 ` David Matlack
2025-11-06 16:36 ` Raghavendra Rao Ananta
2025-11-06 17:10 ` David Matlack
2025-11-04 0:35 ` [PATCH 2/4] vfio: selftests: Export vfio_pci_device functions Raghavendra Rao Ananta
2025-11-06 0:41 ` David Matlack
2025-11-06 16:43 ` Raghavendra Rao Ananta
2025-11-06 17:08 ` David Matlack
2025-11-04 0:35 ` [PATCH 3/4] vfio: selftests: Add helper to set/override a vf_token Raghavendra Rao Ananta
2025-11-06 0:01 ` David Matlack
2025-11-06 16:44 ` Raghavendra Rao Ananta
2025-11-04 0:35 ` [PATCH 4/4] vfio: selftests: Add tests to validate SR-IOV UAPI Raghavendra Rao Ananta
2025-11-06 1:00 ` David Matlack
2025-11-06 17:05 ` Raghavendra Rao Ananta
2025-11-06 17:34 ` David Matlack
2025-11-07 2:56 ` Raghavendra Rao Ananta
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=aQzYOjWPs0qsW4YR@google.com \
--to=dmatlack@google.com \
--cc=alex.williamson@redhat.com \
--cc=alex@shazbot.org \
--cc=jrhilke@google.com \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=rananta@google.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).