From 694fb857abd770db623b6df5475291797b86187c Mon Sep 17 00:00:00 2001 From: Gonglei Date: Tue, 7 Oct 2014 16:00:06 +0800 Subject: bootindex: add check bootindex function Determine whether a given bootindex exists or not. If exists, we report an error. Signed-off-by: Gonglei Reviewed-by: Gerd Hoffmann Signed-off-by: Gerd Hoffmann --- bootdevice.c | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'bootdevice.c') diff --git a/bootdevice.c b/bootdevice.c index d5b8789994..f5399df4b7 100644 --- a/bootdevice.c +++ b/bootdevice.c @@ -36,6 +36,21 @@ struct FWBootEntry { static QTAILQ_HEAD(, FWBootEntry) fw_boot_order = QTAILQ_HEAD_INITIALIZER(fw_boot_order); +void check_boot_index(int32_t bootindex, Error **errp) +{ + FWBootEntry *i; + + if (bootindex >= 0) { + QTAILQ_FOREACH(i, &fw_boot_order, link) { + if (i->bootindex == bootindex) { + error_setg(errp, "The bootindex %d has already been used", + bootindex); + return; + } + } + } +} + void add_boot_device_path(int32_t bootindex, DeviceState *dev, const char *suffix) { -- cgit v1.2.1