From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56277) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aQIL1-0001dg-I2 for qemu-devel@nongnu.org; Mon, 01 Feb 2016 12:32:36 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aQIKx-0005UA-7J for qemu-devel@nongnu.org; Mon, 01 Feb 2016 12:32:31 -0500 Received: from mail-wm0-x22f.google.com ([2a00:1450:400c:c09::22f]:36656) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aQIKx-0005U5-0A for qemu-devel@nongnu.org; Mon, 01 Feb 2016 12:32:27 -0500 Received: by mail-wm0-x22f.google.com with SMTP id p63so81685594wmp.1 for ; Mon, 01 Feb 2016 09:32:26 -0800 (PST) References: <20160120180552.21926.99964.stgit@gimli.home> <56A78AC0.7080300@linaro.org> <1453828111.26652.78.camel@redhat.com> From: Eric Auger Message-ID: <56AF9696.4090408@linaro.org> Date: Mon, 1 Feb 2016 18:32:06 +0100 MIME-Version: 1.0 In-Reply-To: <1453828111.26652.78.camel@redhat.com> Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit 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: Alex Williamson , qemu-devel@nongnu.org Cc: jike.song@intel.com, kevin.tian@intel.com, laine@redhat.com On 01/26/2016 06:08 PM, Alex Williamson wrote: > 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 >> 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 *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, Yes I agree Best Regards Eric > > Alex >