From 7dc5af5545bb72e1343cc959b3f0e5cdd8758f1f Mon Sep 17 00:00:00 2001 From: Dominik Dingel Date: Fri, 26 Apr 2013 02:12:49 +0000 Subject: Common: Add quick access to first boot device Instead of manually parsing the boot_list as character stream, we can access the nth boot device, specified by the position in the boot order. Signed-off-by: Dominik Dingel Reviewed-by: Anthony Liguori Signed-off-by: Alexander Graf --- vl.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'vl.c') diff --git a/vl.c b/vl.c index 2e0d1a744c..322ea804f9 100644 --- a/vl.c +++ b/vl.c @@ -1222,6 +1222,24 @@ void add_boot_device_path(int32_t bootindex, DeviceState *dev, QTAILQ_INSERT_TAIL(&fw_boot_order, node, link); } +DeviceState *get_boot_device(uint32_t position) +{ + uint32_t counter = 0; + FWBootEntry *i = NULL; + DeviceState *res = NULL; + + if (!QTAILQ_EMPTY(&fw_boot_order)) { + QTAILQ_FOREACH(i, &fw_boot_order, link) { + if (counter == position) { + res = i->dev; + break; + } + counter++; + } + } + return res; +} + /* * This function returns null terminated string that consist of new line * separated device paths. -- cgit v1.2.1