From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:58906) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XEHg0-00019q-90 for qemu-devel@nongnu.org; Mon, 04 Aug 2014 08:47:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XEHfv-0001ju-Dt for qemu-devel@nongnu.org; Mon, 04 Aug 2014 08:47:44 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:41327) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XEHfu-0001iP-Le for qemu-devel@nongnu.org; Mon, 04 Aug 2014 08:47:39 -0400 From: Date: Mon, 4 Aug 2014 20:46:16 +0800 Message-ID: <1407156382-2836-3-git-send-email-arei.gonglei@huawei.com> In-Reply-To: <1407156382-2836-1-git-send-email-arei.gonglei@huawei.com> References: <1407156382-2836-1-git-send-email-arei.gonglei@huawei.com> MIME-Version: 1.0 Content-Type: text/plain Subject: [Qemu-devel] [PATCH v5 2/8] bootindex: add del_boot_device_path function List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: chenliang88@huawei.com, weidong.huang@huawei.com, mst@redhat.com, aik@ozlabs.ru, hutao@cn.fujitsu.com, armbru@redhat.com, kraxel@redhat.com, akong@redhat.com, agraf@suse.de, Gonglei , aliguori@amazon.com, gaowanlong@cn.fujitsu.com, ehabkost@redhat.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 From: Gonglei Introduce del_boot_device_path() to clean up fw_cfg content when hot-unplugging a device that refers to a bootindex. Signed-off-by: Gonglei Signed-off-by: Chenliang --- include/sysemu/sysemu.h | 1 + vl.c | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 06e1b72..130f971 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, Error **errp); char *get_boot_devices_list(size_t *size, bool ignore_suffixes); diff --git a/vl.c b/vl.c index 770ad67..2424135 100644 --- a/vl.c +++ b/vl.c @@ -1263,6 +1263,26 @@ static bool is_same_fw_dev_path(DeviceState *src, DeviceState *dst) return ret; } +void del_boot_device_path(DeviceState *dev) +{ + FWBootEntry *i; + + assert(dev != NULL); + + /* remove all entries of the assigned device */ + QTAILQ_FOREACH(i, &fw_boot_order, link) { + if ((i->dev->id && dev->id && + !strcmp(i->dev->id, dev->id)) || + (!i->dev->id && is_same_fw_dev_path(i->dev, 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, Error **errp) { -- 1.7.12.4