qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [PATCH v6 04/27] bootindex: rework add_boot_device_path fun


From: arei.gonglei
Subject: [Qemu-devel] [PATCH v6 04/27] bootindex: rework add_boot_device_path function
Date: Sat, 30 Aug 2014 18:00:04 +0800

From: Gonglei <address@hidden>

Add the function of updating bootindex about fw_boot_order list
in add_boot_device_path(). We should delete the old one if a
device has existed in global fw_boot_order list.

Signed-off-by: Gonglei <address@hidden>
---
 vl.c | 21 +++++++++++++++++++++
 1 file changed, 21 insertions(+)

diff --git a/vl.c b/vl.c
index 5e57541..4d5a889 100644
--- a/vl.c
+++ b/vl.c
@@ -1288,6 +1288,25 @@ void del_boot_device_path(DeviceState *dev)
     }
 }
 
+static void del_original_boot_device(DeviceState *dev, const char *suffix)
+{
+    FWBootEntry *i;
+
+    if (dev == NULL) {
+        return;
+    }
+
+    QTAILQ_FOREACH(i, &fw_boot_order, link) {
+        if (i->dev == dev && !strcmp(i->suffix, suffix)) {
+            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)
 {
@@ -1299,6 +1318,8 @@ void add_boot_device_path(int32_t bootindex, DeviceState 
*dev,
 
     assert(dev != NULL || suffix != NULL);
 
+    del_original_boot_device(dev, suffix);
+
     node = g_malloc0(sizeof(FWBootEntry));
     node->bootindex = bootindex;
     node->suffix = g_strdup(suffix);
-- 
1.7.12.4





reply via email to

[Prev in Thread] Current Thread [Next in Thread]