From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42184) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XDDYN-0006G8-G7 for qemu-devel@nongnu.org; Fri, 01 Aug 2014 10:11:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XDDYH-00042E-4B for qemu-devel@nongnu.org; Fri, 01 Aug 2014 10:11:26 -0400 Received: from mx1.redhat.com ([209.132.183.28]:40132) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XDDYG-0003zG-RV for qemu-devel@nongnu.org; Fri, 01 Aug 2014 10:11:21 -0400 Date: Fri, 1 Aug 2014 11:06:00 -0300 From: Eduardo Habkost Message-ID: <20140801140600.GA28519@thinpad.lan.raisama.net> References: <1406349933-17536-1-git-send-email-arei.gonglei@huawei.com> <1406349933-17536-3-git-send-email-arei.gonglei@huawei.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1406349933-17536-3-git-send-email-arei.gonglei@huawei.com> Subject: Re: [Qemu-devel] [PATCH v3 2/7] bootindex: add del_boot_device_path function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: arei.gonglei@huawei.com Cc: chenliang88@huawei.com, weidong.huang@huawei.com, mst@redhat.com, aik@ozlabs.ru, hutao@cn.fujitsu.com, qemu-devel@nongnu.org, agraf@suse.de, kraxel@redhat.com, akong@redhat.com, armbru@redhat.com, aliguori@amazon.com, gaowanlong@cn.fujitsu.com, luonengjun@huawei.com, peter.huangpeng@huawei.com, hani@linux.com, stefanha@redhat.com, pbonzini@redhat.com, lcapitulino@redhat.com, kwolf@redhat.com, peter.crosthwaite@xilinx.com, imammedo@redhat.com, afaerber@suse.de On Sat, Jul 26, 2014 at 12:45:28PM +0800, arei.gonglei@huawei.com wrote: > From: Gonglei > > Introduce a del_boot_device_path() cleanup fw_cfg content > when hot-unplugging devcie refer to bootindex. > > Signed-off-by: Gonglei > Signed-off-by: Chenliang > --- > include/sysemu/sysemu.h | 1 + > vl.c | 17 +++++++++++++++++ > 2 files changed, 18 insertions(+) > > diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h > index e1b0659..7a79ff4 100644 > --- a/include/sysemu/sysemu.h > +++ b/include/sysemu/sysemu.h > @@ -209,6 +209,7 @@ void usb_info(Monitor *mon, const QDict *qdict); > > void add_boot_device_path(int32_t bootindex, DeviceState *dev, > const char *suffix); > +void del_boot_device_path(DeviceState *dev); > void modify_boot_device_path(int32_t bootindex, DeviceState *dev, > const char *suffix); > char *get_boot_devices_list(size_t *size, bool ignore_suffixes); > diff --git a/vl.c b/vl.c > index 3e42eaa..0cdadb4 100644 > --- a/vl.c > +++ b/vl.c > @@ -1248,6 +1248,23 @@ void add_boot_device_path(int32_t bootindex, DeviceState *dev, > QTAILQ_INSERT_TAIL(&fw_boot_order, node, link); > } > > +void del_boot_device_path(DeviceState *dev) > +{ > + FWBootEntry *i; > + > + assert(dev != NULL); > + > + QTAILQ_FOREACH(i, &fw_boot_order, link) { > + if (i->dev->id && dev->id && !strcmp(i->dev->id, dev->id)) { What if the device doesn't have any ID set? I don't see anything on add_boot_device_path() ensuring that dev->id is always set. Why you don't just check if i->dev == dev? > + /* remove all entries of the assigend dev */ > + QTAILQ_REMOVE(&fw_boot_order, i, link); > + g_free(i->suffix); > + g_free(i); > + break; > + } > + } > +} > + > void modify_boot_device_path(int32_t bootindex, DeviceState *dev, > const char *suffix) > { > -- > 1.7.12.4 > > > -- Eduardo