[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH v6 02/27] bootindex: add del_boot_device_path functi
From: |
arei.gonglei |
Subject: |
[Qemu-devel] [PATCH v6 02/27] bootindex: add del_boot_device_path function |
Date: |
Sat, 30 Aug 2014 18:00:02 +0800 |
From: Gonglei <address@hidden>
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 <address@hidden>
Signed-off-by: Chenliang <address@hidden>
---
include/sysemu/sysemu.h | 1 +
vl.c | 36 ++++++++++++++++++++++++++++++++++++
2 files changed, 37 insertions(+)
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index b343df5..672984c 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -208,6 +208,7 @@ void do_usb_del(Monitor *mon, const QDict *qdict);
void usb_info(Monitor *mon, const QDict *qdict);
void check_boot_index(int32_t bootindex, Error **errp);
+void del_boot_device_path(DeviceState *dev);
void add_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 76fb008..5e57541 100644
--- a/vl.c
+++ b/vl.c
@@ -1252,6 +1252,42 @@ void check_boot_index(int32_t bootindex, Error **errp)
}
}
+static bool is_same_fw_dev_path(DeviceState *src, DeviceState *dst)
+{
+ bool ret = false;
+ char *devpath_src = qdev_get_fw_dev_path(src);
+ char *devpath_dst = qdev_get_fw_dev_path(dst);
+
+ if (!strcmp(devpath_src, devpath_dst)) {
+ ret = true;
+ }
+
+ g_free(devpath_src);
+ g_free(devpath_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 == NULL) {
+ continue;
+ }
+ if ((i->dev == dev || is_same_fw_dev_path(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)
{
--
1.7.12.4
- [Qemu-devel] [PATCH v6 18/27] host-libusb: remove bootindex property from qdev to qom, (continued)
- [Qemu-devel] [PATCH v6 18/27] host-libusb: remove bootindex property from qdev to qom, arei.gonglei, 2014/08/30
- [Qemu-devel] [PATCH v6 27/27] bootindex: delete bootindex when device is removed, arei.gonglei, 2014/08/30
- [Qemu-devel] [PATCH v6 14/27] spapr_lian: add bootindex to qom property, arei.gonglei, 2014/08/30
- [Qemu-devel] [PATCH v6 03/27] fw_cfg: add fw_cfg_machine_reset function, arei.gonglei, 2014/08/30
- [Qemu-devel] [PATCH v6 12/27] pcnet: add bootindex to qom property, arei.gonglei, 2014/08/30
- [Qemu-devel] [PATCH v6 22/27] isa-fdc: remove bootindexA/B property from qdev to qom, arei.gonglei, 2014/08/30
- [Qemu-devel] [PATCH v6 16/27] usb-net: add bootindex to qom property, arei.gonglei, 2014/08/30
- [Qemu-devel] [PATCH v6 15/27] vmxnet3: add bootindex to qom property, arei.gonglei, 2014/08/30
- [Qemu-devel] [PATCH v6 11/27] ne2000: add bootindex to qom property, arei.gonglei, 2014/08/30
- [Qemu-devel] [PATCH v6 06/27] bootindex: move setting bootindex on reset() instead of realize/init(), arei.gonglei, 2014/08/30
- [Qemu-devel] [PATCH v6 02/27] bootindex: add del_boot_device_path function,
arei.gonglei <=
- [Qemu-devel] [PATCH v6 13/27] rtl8139: add bootindex to qom property, arei.gonglei, 2014/08/30