From patchwork Sat Jul 26 04:45:28 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gonglei (Arei)" X-Patchwork-Id: 373913 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 780B81400D2 for ; Sat, 26 Jul 2014 14:47:37 +1000 (EST) Received: from localhost ([::1]:57766 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XAttP-0002y0-LH for incoming@patchwork.ozlabs.org; Sat, 26 Jul 2014 00:47:35 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:42075) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XAtsQ-00018H-OU for qemu-devel@nongnu.org; Sat, 26 Jul 2014 00:46:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XAtsK-0003gd-3i for qemu-devel@nongnu.org; Sat, 26 Jul 2014 00:46:34 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:46302) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XAtsJ-0003ev-D8 for qemu-devel@nongnu.org; Sat, 26 Jul 2014 00:46:28 -0400 Received: from 172.24.2.119 (EHLO szxeml418-hub.china.huawei.com) ([172.24.2.119]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id BXE34037; Sat, 26 Jul 2014 12:45:55 +0800 (CST) Received: from localhost (10.177.19.102) by szxeml418-hub.china.huawei.com (10.82.67.157) with Microsoft SMTP Server id 14.3.158.1; Sat, 26 Jul 2014 12:45:45 +0800 From: To: Date: Sat, 26 Jul 2014 12:45:28 +0800 Message-ID: <1406349933-17536-3-git-send-email-arei.gonglei@huawei.com> X-Mailer: git-send-email 1.7.3.1.msysgit.0 In-Reply-To: <1406349933-17536-1-git-send-email-arei.gonglei@huawei.com> References: <1406349933-17536-1-git-send-email-arei.gonglei@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.19.102] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 119.145.14.65 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 Subject: [Qemu-devel] [PATCH v3 2/7] bootindex: add del_boot_device_path function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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)) { + /* 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) {