[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Qemu-devel] [PATCH 1/6] bootindex: add {del, modify}_boot_device_path f
From: |
arei.gonglei |
Subject: |
[Qemu-devel] [PATCH 1/6] bootindex: add {del, modify}_boot_device_path function |
Date: |
Thu, 24 Jul 2014 16:38:57 +0800 |
From: Gonglei <address@hidden>
When we want to change one device's bootindex, we should do three
things. On the on hand, remove the device from global fw_boot_order list,
regardless attaching suffix or not delete. On the other hand, delete
original object of the assigned bootindex. Finally add the new device's
bootindex into the global fw_boot_order list.
Signed-off-by: Chenliang <address@hidden>
Signed-off-by: Gonglei <address@hidden>
---
include/sysemu/sysemu.h | 4 ++++
vl.c | 57 +++++++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 61 insertions(+)
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index d8539fd..e368627 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -209,6 +209,10 @@ 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(int32_t bootindex, DeviceState *dev,
+ const char *suffix);
+void modify_boot_device_path(int32_t bootindex, DeviceState *dev,
+ const char *suffix);
char *get_boot_devices_list(size_t *size, bool ignore_suffixes);
DeviceState *get_boot_device(uint32_t position);
diff --git a/vl.c b/vl.c
index fe451aa..e304a93 100644
--- a/vl.c
+++ b/vl.c
@@ -1248,6 +1248,63 @@ void add_boot_device_path(int32_t bootindex, DeviceState
*dev,
QTAILQ_INSERT_TAIL(&fw_boot_order, node, link);
}
+static bool is_same_fw_dev_path(DeviceState *src, DeviceState *target)
+{
+ bool ret = false;
+ char *devpath_src = qdev_get_fw_dev_path(src);
+ char *devpath_target = qdev_get_fw_dev_path(target);
+
+ if (!strcmp(devpath_src, devpath_target)) {
+ ret = true;
+ }
+
+ g_free(devpath_src);
+ g_free(devpath_target);
+ return ret;
+}
+
+void del_boot_device_path(int32_t bootindex, DeviceState *dev,
+ const char *suffix)
+{
+ FWBootEntry *i;
+
+ assert(dev != NULL);
+ assert(bootindex >= 0 || suffix != NULL);
+
+ QTAILQ_FOREACH(i, &fw_boot_order, link) {
+ if (is_same_fw_dev_path(i->dev, dev)) {
+ if (suffix && i->suffix && strcmp(i->suffix, suffix)) {
+ continue;
+ }
+ /* if suffix is NULL, remove all entries of the assigend dev */
+ QTAILQ_REMOVE(&fw_boot_order, i, link);
+ g_free(i->suffix);
+ g_free(i);
+ break;
+ }
+ }
+
+ if (bootindex < 0) {
+ return;
+ }
+ /* find the object of assigned bootindex, and then remove it */
+ QTAILQ_FOREACH(i, &fw_boot_order, link) {
+ if (i->bootindex == bootindex) {
+ 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)
+{
+ del_boot_device_path(bootindex, dev, suffix);
+ add_boot_device_path(bootindex, dev, suffix);
+}
+
DeviceState *get_boot_device(uint32_t position)
{
uint32_t counter = 0;
--
1.7.12.4
[Qemu-devel] [PATCH 2/6] fw_cfg: add fw_cfg_machine_reset function, arei.gonglei, 2014/07/24
[Qemu-devel] [PATCH 5/6] qemu-monitor: HMP set-bootindex wrapper, arei.gonglei, 2014/07/24
[Qemu-devel] [PATCH 4/6] qmp: add set-bootindex command, arei.gonglei, 2014/07/24
[Qemu-devel] [PATCH 3/6] bootindex: delete bootindex when device is removed, arei.gonglei, 2014/07/24
[Qemu-devel] [PATCH 6/6] spapr: fix possible memory leak, arei.gonglei, 2014/07/24