From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53076) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XeKXk-0006RS-T8 for qemu-devel@nongnu.org; Wed, 15 Oct 2014 05:06:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XeKXc-00070i-BM for qemu-devel@nongnu.org; Wed, 15 Oct 2014 05:06:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:31457) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XeKXb-00070F-TZ for qemu-devel@nongnu.org; Wed, 15 Oct 2014 05:06:44 -0400 From: Gerd Hoffmann Date: Wed, 15 Oct 2014 11:05:36 +0200 Message-Id: <1413363967-2489-4-git-send-email-kraxel@redhat.com> In-Reply-To: <1413363967-2489-1-git-send-email-kraxel@redhat.com> References: <1413363967-2489-1-git-send-email-kraxel@redhat.com> Subject: [Qemu-devel] [PULL 03/34] 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: Chenliang , Gonglei , Gerd Hoffmann From: Gonglei Introduce del_boot_device_path() to clean up fw_cfg content when hot-unplugging a device that refers to a bootindex or update a existent devcie's bootindex. Signed-off-by: Gonglei Signed-off-by: Chenliang Reviewed-by: Gerd Hoffmann Signed-off-by: Gerd Hoffmann --- bootdevice.c | 20 ++++++++++++++++++++ include/sysemu/sysemu.h | 1 + 2 files changed, 21 insertions(+) diff --git a/bootdevice.c b/bootdevice.c index f5399df..7167fbc 100644 --- a/bootdevice.c +++ b/bootdevice.c @@ -51,6 +51,26 @@ void check_boot_index(int32_t bootindex, Error **errp) } } +void del_boot_device_path(DeviceState *dev, const char *suffix) +{ + FWBootEntry *i; + + if (dev == NULL) { + return; + } + + QTAILQ_FOREACH(i, &fw_boot_order, link) { + if ((!suffix || !g_strcmp0(i->suffix, suffix)) && + i->dev == dev) { + QTAILQ_REMOVE(&fw_boot_order, i, link); + g_free(i->suffix); + g_free(i); + + break; + } + } +} + void add_boot_device_path(int32_t bootindex, DeviceState *dev, const char *suffix) { diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 72463de..b3489be 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -214,6 +214,7 @@ char *get_boot_devices_list(size_t *size, bool ignore_suffixes); DeviceState *get_boot_device(uint32_t position); void check_boot_index(int32_t bootindex, Error **errp); +void del_boot_device_path(DeviceState *dev, const char *suffix); QemuOpts *qemu_get_machine_opts(void); -- 1.8.3.1