Received: from eggs.gnu.org ([208.118.235.92]:47144) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UViFM-0004qV-Ol for qemu-devel@nongnu.org; Fri, 26 Apr 2013 08:59:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UVhXR-0002Wx-S8 for qemu-devel@nongnu.org; Fri, 26 Apr 2013 08:14:31 -0400 Received: from e06smtp14.uk.ibm.com ([195.75.94.110]:49418) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVhXR-0002W6-Cq for qemu-devel@nongnu.org; Fri, 26 Apr 2013 08:14:05 -0400 Received: from /spool/local by e06smtp14.uk.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Fri, 26 Apr 2013 13:08:48 +0100 Received: from b06cxnps4076.portsmouth.uk.ibm.com (d06relay13.portsmouth.uk.ibm.com [9.149.109.198]) by d06dlp03.portsmouth.uk.ibm.com (Postfix) with ESMTP id 4C1F81B0807C for ; Fri, 26 Apr 2013 13:14:02 +0100 (BST) Received: from d06av07.portsmouth.uk.ibm.com (d06av07.portsmouth.uk.ibm.com [9.149.37.248]) by b06cxnps4076.portsmouth.uk.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id r3QCCqbH47448068 for ; Fri, 26 Apr 2013 12:12:52 GMT Received: from d06av07.portsmouth.uk.ibm.com (d06av07.portsmouth.uk.ibm.com [127.0.0.1]) by d06av07.portsmouth.uk.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id r3QAuOIP021918 for ; Fri, 26 Apr 2013 06:56:24 -0400 From: Dominik Dingel Date: Fri, 26 Apr 2013 14:12:49 +0200 Message-Id: <1366978377-16823-3-git-send-email-dingel@linux.vnet.ibm.com> In-Reply-To: <1366978377-16823-1-git-send-email-dingel@linux.vnet.ibm.com> References: <1366978377-16823-1-git-send-email-dingel@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH 02/10] Common: Add quick access to first boot device List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Christian Borntraeger , Alexander Graf , Dominik Dingel 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 diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 6578782..43b961c 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -181,6 +181,8 @@ void add_boot_device_path(int32_t bootindex, DeviceState *dev, const char *suffix); char *get_boot_devices_list(size_t *size); +DeviceState *get_boot_device(uint32_t position); + bool usb_enabled(bool default_usb); extern QemuOptsList qemu_drive_opts; diff --git a/vl.c b/vl.c index 84d7031..429e6ea 100644 --- a/vl.c +++ b/vl.c @@ -1247,6 +1247,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. -- 1.7.9.5