bootindex: add del_boot_device_path function
authorGonglei <arei.gonglei@huawei.com>
Tue, 7 Oct 2014 08:00:07 +0000 (16:00 +0800)
committerGerd Hoffmann <kraxel@redhat.com>
Wed, 15 Oct 2014 07:49:48 +0000 (09:49 +0200)
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 <arei.gonglei@huawei.com>
Signed-off-by: Chenliang <chenliang88@huawei.com>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
bootdevice.c
include/sysemu/sysemu.h

index f5399df4b76759e6e4c3b68b63aa249b9525fe85..7167fbcfe676308aace7264f13f4125b88ad3256 100644 (file)
@@ -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)
 {
index 72463de56ce78e217d1d367eb384004ffb2918fa..b3489be7ca3a8439fcab16c6f232f30ac2f937a3 100644 (file)
@@ -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);