From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58800) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDkpb-0005LJ-PI for qemu-devel@nongnu.org; Tue, 20 Jan 2015 21:15:48 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YDkpS-0007X5-9o for qemu-devel@nongnu.org; Tue, 20 Jan 2015 21:15:43 -0500 Received: from szxga03-in.huawei.com ([119.145.14.66]:59326) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YDkpR-0007U7-IO for qemu-devel@nongnu.org; Tue, 20 Jan 2015 21:15:34 -0500 Message-ID: <54BF0BA3.8040307@huawei.com> Date: Wed, 21 Jan 2015 10:14:59 +0800 From: Gonglei MIME-Version: 1.0 References: <1421673818-11224-1-git-send-email-arei.gonglei@huawei.com> <1421673818-11224-2-git-send-email-arei.gonglei@huawei.com> <54BE7E02.4030602@redhat.com> In-Reply-To: <54BE7E02.4030602@redhat.com> Content-Type: text/plain; charset="windows-1252" Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 1/4] qdev: support to get a device firmware path directly List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: "mst@redhat.com" , "Huangweidong (C)" , "qemu-devel@nongnu.org" , "Subo (A)" , "Huangpeng (Peter)" On 2015/1/21 0:10, Paolo Bonzini wrote: > > > On 19/01/2015 14:23, arei.gonglei@huawei.com wrote: >> @@ -780,6 +788,12 @@ static int qdev_get_fw_dev_path_helper(DeviceState *dev, char *p, int size) >> d = bus_get_fw_dev_path(dev->parent_bus, dev); >> } >> if (d) { >> + l += snprintf(p + l, size - l, "%s/", d); >> + g_free(d); >> + } >> + >> + d = qdev_get_own_fw_dev_path_from_handler(dev->parent_bus, dev); > > This changes preexisting behavior. If d was true, you wouldn't go down > the following else. Now it does. > On the face of things, it is. But actually they are equal. Please notice I added a "/" at the end p, and then the function can return if d was NULL. l += snprintf(p + l, size - l, "%s/", d); > I was thinking it should be handled though the "suffix" argument to > add_boot_device_path, but that's harder now that the suffix has to be > passed to device_add_bootindex_property. > Yes. > Perhaps you could call qdev_get_own_fw_dev_path_from_handler in > get_boot_devices_list, and convert non-NULL suffixes to implementations > of FWPathProvider? > Maybe your meaning is "convert NULL suffixes to implementations of FWPathProvider"? Something like below: diff --git a/bootdevice.c b/bootdevice.c index 5914417..546ca9d 100644 --- a/bootdevice.c +++ b/bootdevice.c @@ -225,7 +225,18 @@ char *get_boot_devices_list(size_t *size, bool ignore_suffixes) snprintf(bootpath, bootpathlen, "%s%s", devpath, i->suffix); g_free(devpath); } else if (devpath) { - bootpath = devpath; + char *d = NULL; + size_t bootpathlen; + + d = qdev_get_own_fw_dev_path_from_handler(i->dev->parent_bus, i->dev); + if (d) { + bootpathlen = strlen(devpath) + strlen(d) + 1; + bootpath = g_malloc(bootpathlen); + snprintf(bootpath, bootpathlen, "%s%s", devpath, d); + g_free(devpath); + } else { + bootpath = devpath; + } } else if (!ignore_suffixes) { assert(i->suffix); bootpath = g_strdup(i->suffix); But I feel this more complicated. Isn't ? Regards, -Gonglei > Paolo > >> + if (d) { >> l += snprintf(p + l, size - l, "%s", d); >> g_free(d); >> } else {