From patchwork Wed Oct 15 09:05:35 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gerd Hoffmann X-Patchwork-Id: 399826 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A839F1400F4 for ; Wed, 15 Oct 2014 20:07:56 +1100 (EST) Received: from localhost ([::1]:42902 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XeKYk-00082f-FH for incoming@patchwork.ozlabs.org; Wed, 15 Oct 2014 05:07:54 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53112) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XeKXl-0006SZ-Mp for qemu-devel@nongnu.org; Wed, 15 Oct 2014 05:07:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XeKXd-00071e-GG for qemu-devel@nongnu.org; Wed, 15 Oct 2014 05:06:53 -0400 Received: from mx1.redhat.com ([209.132.183.28]:55630) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XeKXd-00071C-7d for qemu-devel@nongnu.org; Wed, 15 Oct 2014 05:06:45 -0400 Received: from int-mx11.intmail.prod.int.phx2.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by mx1.redhat.com (8.14.4/8.14.4) with ESMTP id s9F96aGr015142 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=FAIL); Wed, 15 Oct 2014 05:06:36 -0400 Received: from nilsson.home.kraxel.org (ovpn-116-60.ams2.redhat.com [10.36.116.60]) by int-mx11.intmail.prod.int.phx2.redhat.com (8.14.4/8.14.4) with ESMTP id s9F96aLT004615; Wed, 15 Oct 2014 05:06:36 -0400 Received: by nilsson.home.kraxel.org (Postfix, from userid 500) id 695418101B; Wed, 15 Oct 2014 11:06:35 +0200 (CEST) From: Gerd Hoffmann To: qemu-devel@nongnu.org Date: Wed, 15 Oct 2014 11:05:35 +0200 Message-Id: <1413363967-2489-3-git-send-email-kraxel@redhat.com> In-Reply-To: <1413363967-2489-1-git-send-email-kraxel@redhat.com> References: <1413363967-2489-1-git-send-email-kraxel@redhat.com> X-Scanned-By: MIMEDefang 2.68 on 10.5.11.24 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 209.132.183.28 Cc: Gonglei , Gerd Hoffmann Subject: [Qemu-devel] [PULL 02/34] bootindex: add check bootindex function X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org From: Gonglei 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 +++++++++++++++ include/sysemu/sysemu.h | 1 + 2 files changed, 16 insertions(+) diff --git a/bootdevice.c b/bootdevice.c index d5b8789..f5399df 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) { diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h index 8de5100..72463de 100644 --- a/include/sysemu/sysemu.h +++ b/include/sysemu/sysemu.h @@ -213,6 +213,7 @@ void add_boot_device_path(int32_t bootindex, DeviceState *dev, char *get_boot_devices_list(size_t *size, bool ignore_suffixes); DeviceState *get_boot_device(uint32_t position); +void check_boot_index(int32_t bootindex, Error **errp); QemuOpts *qemu_get_machine_opts(void);