All of lore.kernel.org
 help / color / mirror / Atom feed
From: Alex Williamson <alex.williamson@redhat.com>
To: Eric Auger <eric.auger@linaro.org>, qemu-devel@nongnu.org
Cc: jike.song@intel.com, kevin.tian@intel.com, laine@redhat.com
Subject: Re: [Qemu-devel] [RFC PATCH] vfio: Add sysfsdev property for pci & platform
Date: Tue, 26 Jan 2016 10:08:31 -0700	[thread overview]
Message-ID: <1453828111.26652.78.camel@redhat.com> (raw)
In-Reply-To: <56A78AC0.7080300@linaro.org>

On Tue, 2016-01-26 at 16:03 +0100, Eric Auger wrote:
> 
> Hi Alex,
> 
> I did a try with both legacy cmd line and new one and it works fine for
> vfio platform too:
> -device vfio-calxeda-xgmac,host="fff51000.ethernet"
> -device
> vfio-calxeda-xgmac,sysfsdev="/sys/bus/platform/devices/fff51000.ethernet"
> 
> Tested-by: Eric Auger <eric.auger@linaro.org>
> Reviewed-by: Eric Auger <eric.auger@linaro.org>

Thanks!

> just 1 question below.
...
> > diff --git a/hw/vfio/platform.c b/hw/vfio/platform.c
> > index 289b498..99f0642 100644
> > --- a/hw/vfio/platform.c
> > +++ b/hw/vfio/platform.c
> > @@ -559,38 +559,45 @@ static int vfio_base_device_init(VFIODevice *vbasedev)
> >  {
> >      VFIOGroup *group;
> >      VFIODevice *vbasedev_iter;
> > -    char path[PATH_MAX], iommu_group_path[PATH_MAX], *group_name;
> > +    char *tmp, group_path[PATH_MAX], *group_name;
> >      ssize_t len;
> >      struct stat st;
> >      int groupid;
> >      int ret;
> >  
> > -    /* name must be set prior to the call */
> > -    if (!vbasedev->name || strchr(vbasedev->name, '/')) {
> > -        return -EINVAL;
> > -    }
> > +    /* @sysfsdev takes precedence over @host */
> > +    if (vbasedev->sysfsdev) {
> > +        g_free(vbasedev->name);
> > +        vbasedev->name = g_strdup(basename(vbasedev->sysfsdev));
> do we need the g_strdup here?


Versus pointing ->name to the offset within sysfsdev where the name
starts?  My concern was that both @sysfsdev and @name are allocated via
device properties and presumably automatically collected when the
device is destroyed.  If I set one within the buffer of another, I'd
likely get a double free.  So creating a new string buffer seemed like
the safest approach.  Agree?  Thanks,

Alex

  reply	other threads:[~2016-01-26 17:08 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-01-20 18:06 [Qemu-devel] [RFC PATCH] vfio: Add sysfsdev property for pci & platform Alex Williamson
2016-01-20 18:11 ` Daniel P. Berrange
2016-01-20 18:28   ` Alex Williamson
2016-01-21  7:09     ` P J P
2016-01-21  7:51 ` Tian, Kevin
2016-01-21 15:14   ` Alex Williamson
2016-01-25 19:27     ` Tian, Kevin
2016-01-26 15:03 ` Eric Auger
2016-01-26 17:08   ` Alex Williamson [this message]
2016-02-01 17:32     ` Eric Auger

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=1453828111.26652.78.camel@redhat.com \
    --to=alex.williamson@redhat.com \
    --cc=eric.auger@linaro.org \
    --cc=jike.song@intel.com \
    --cc=kevin.tian@intel.com \
    --cc=laine@redhat.com \
    --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 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.