Bladeren bron

bootindex: add del_boot_device_path function

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>
Gonglei 11 jaren geleden
bovenliggende
commit
9d27572d62
2 gewijzigde bestanden met toevoegingen van 21 en 0 verwijderingen
  1. 20 0
      bootdevice.c
  2. 1 0
      include/sysemu/sysemu.h

+ 20 - 0
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,
 void add_boot_device_path(int32_t bootindex, DeviceState *dev,
                           const char *suffix)
                           const char *suffix)
 {
 {

+ 1 - 0
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);
 DeviceState *get_boot_device(uint32_t position);
 void check_boot_index(int32_t bootindex, Error **errp);
 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);
 QemuOpts *qemu_get_machine_opts(void);