From: Gonglei <arei.gong...@huawei.com> Determine whether a given bootindex exists or not. If exists, we report an error.
Signed-off-by: Gonglei <arei.gong...@huawei.com> --- include/sysemu/sysemu.h | 1 + vl.c | 15 +++++++++++++++ 2 files changed, 16 insertions(+) diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index d8539fd..b343df5 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -207,6 +207,7 @@ void do_usb_add(Monitor *mon, const QDict *qdict); 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 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 95be92d..76fb008 100644 --- a/vl.c +++ b/vl.c @@ -1237,6 +1237,21 @@ static void restore_boot_order(void *opaque) g_free(normal_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) { -- 1.7.12.4