From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:50524) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVleE-0004tn-H9 for qemu-devel@nongnu.org; Fri, 26 Apr 2013 12:37:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1UVleC-0001ou-Td for qemu-devel@nongnu.org; Fri, 26 Apr 2013 12:37:22 -0400 Received: from mail-ob0-x22a.google.com ([2607:f8b0:4003:c01::22a]:54364) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1UVleC-0001oj-LJ for qemu-devel@nongnu.org; Fri, 26 Apr 2013 12:37:20 -0400 Received: by mail-ob0-f170.google.com with SMTP id eh20so3757324obb.29 for ; Fri, 26 Apr 2013 09:37:20 -0700 (PDT) From: Anthony Liguori In-Reply-To: <1366978377-16823-3-git-send-email-dingel@linux.vnet.ibm.com> References: <1366978377-16823-1-git-send-email-dingel@linux.vnet.ibm.com> <1366978377-16823-3-git-send-email-dingel@linux.vnet.ibm.com> Date: Fri, 26 Apr 2013 11:37:18 -0500 Message-ID: <8738udi6yp.fsf@codemonkey.ws> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Subject: Re: [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: Dominik Dingel , qemu-devel@nongnu.org Cc: Christian Borntraeger , Alexander Graf Dominik Dingel writes: > 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 Regards, Anthony Liguori > 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