From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54593) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aO76Z-0003RF-DK for qemu-devel@nongnu.org; Tue, 26 Jan 2016 12:08:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aO76W-00039e-7M for qemu-devel@nongnu.org; Tue, 26 Jan 2016 12:08:35 -0500 Received: from mx1.redhat.com ([209.132.183.28]:50666) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aO76W-00039Y-1d for qemu-devel@nongnu.org; Tue, 26 Jan 2016 12:08:32 -0500 Message-ID: <1453828111.26652.78.camel@redhat.com> From: Alex Williamson Date: Tue, 26 Jan 2016 10:08:31 -0700 In-Reply-To: <56A78AC0.7080300@linaro.org> References: <20160120180552.21926.99964.stgit@gimli.home> <56A78AC0.7080300@linaro.org> Content-Type: text/plain; charset="UTF-8" Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [RFC PATCH] vfio: Add sysfsdev property for pci & platform List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Eric Auger , qemu-devel@nongnu.org Cc: jike.song@intel.com, kevin.tian@intel.com, laine@redhat.com On Tue, 2016-01-26 at 16:03 +0100, Eric Auger wrote: >=20 > Hi Alex, >=20 > 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=3D"fff51000.ethernet" > -device > vfio-calxeda-xgmac,sysfsdev=3D"/sys/bus/platform/devices/fff51000.ether= net" >=20 > Tested-by: Eric Auger > Reviewed-by: Eric Auger 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 *vb= asedev) > > =C2=A0{ > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0VFIOGroup *group; > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0VFIODevice *vbasedev_iter; > > -=C2=A0=C2=A0=C2=A0=C2=A0char path[PATH_MAX], iommu_group_path[PATH_M= AX], *group_name; > > +=C2=A0=C2=A0=C2=A0=C2=A0char *tmp, group_path[PATH_MAX], *group_name= ; > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0ssize_t len; > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0struct stat st; > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0int groupid; > > =C2=A0=C2=A0=C2=A0=C2=A0=C2=A0int ret; > > =C2=A0 > > -=C2=A0=C2=A0=C2=A0=C2=A0/* name must be set prior to the call */ > > -=C2=A0=C2=A0=C2=A0=C2=A0if (!vbasedev->name || strchr(vbasedev->name= , '/')) { > > -=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0return -EINVAL; > > -=C2=A0=C2=A0=C2=A0=C2=A0} > > +=C2=A0=C2=A0=C2=A0=C2=A0/* @sysfsdev takes precedence over @host */ > > +=C2=A0=C2=A0=C2=A0=C2=A0if (vbasedev->sysfsdev) { > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0g_free(vbasedev->nam= e); > > +=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0vbasedev->name =3D g= _strdup(basename(vbasedev->sysfsdev)); > do we need the g_strdup here? Versus pointing ->name to the offset within sysfsdev where the name starts? =C2=A0My concern was that both @sysfsdev and @name are allocated = via device properties and presumably automatically collected when the device is destroyed. =C2=A0If I set one within the buffer of another, I'd likely get a double free. =C2=A0So creating a new string buffer seemed li= ke the safest approach. =C2=A0Agree? =C2=A0Thanks, Alex