From: Gerd Hoffmann <kraxel@redhat.com>
To: qemu-devel@nongnu.org
Cc: Gonglei <arei.gonglei@huawei.com>,
Gerd Hoffmann <kraxel@redhat.com>,
Anthony Liguori <aliguori@amazon.com>
Subject: [Qemu-devel] [PULL 01/34] bootdevice: move bootdevice related code to new file bootdevice.c
Date: Wed, 15 Oct 2014 11:05:34 +0200 [thread overview]
Message-ID: <1413363967-2489-2-git-send-email-kraxel@redhat.com> (raw)
In-Reply-To: <1413363967-2489-1-git-send-email-kraxel@redhat.com>
From: Gonglei <arei.gonglei@huawei.com>
Signed-off-by: Gonglei <arei.gonglei@huawei.com>
Reviewed-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
---
Makefile.target | 2 +-
bootdevice.c | 142 ++++++++++++++++++++++++++++++++++++++++++++++++
include/sysemu/sysemu.h | 1 +
vl.c | 118 +---------------------------------------
4 files changed, 145 insertions(+), 118 deletions(-)
create mode 100644 bootdevice.c
diff --git a/Makefile.target b/Makefile.target
index 1e8d7ab..e9ff1ee 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -127,7 +127,7 @@ endif #CONFIG_BSD_USER
# System emulator target
ifdef CONFIG_SOFTMMU
obj-y += arch_init.o cpus.o monitor.o gdbstub.o balloon.o ioport.o numa.o
-obj-y += qtest.o
+obj-y += qtest.o bootdevice.o
obj-y += hw/
obj-$(CONFIG_FDT) += device_tree.o
obj-$(CONFIG_KVM) += kvm-all.o
diff --git a/bootdevice.c b/bootdevice.c
new file mode 100644
index 0000000..d5b8789
--- /dev/null
+++ b/bootdevice.c
@@ -0,0 +1,142 @@
+/*
+ * QEMU Boot Device Implement
+ *
+ * Copyright (c) 2014 HUAWEI TECHNOLOGIES CO.,LTD.
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+
+#include "sysemu/sysemu.h"
+
+typedef struct FWBootEntry FWBootEntry;
+
+struct FWBootEntry {
+ QTAILQ_ENTRY(FWBootEntry) link;
+ int32_t bootindex;
+ DeviceState *dev;
+ char *suffix;
+};
+
+static QTAILQ_HEAD(, FWBootEntry) fw_boot_order =
+ QTAILQ_HEAD_INITIALIZER(fw_boot_order);
+
+void add_boot_device_path(int32_t bootindex, DeviceState *dev,
+ const char *suffix)
+{
+ FWBootEntry *node, *i;
+
+ if (bootindex < 0) {
+ return;
+ }
+
+ assert(dev != NULL || suffix != NULL);
+
+ node = g_malloc0(sizeof(FWBootEntry));
+ node->bootindex = bootindex;
+ node->suffix = g_strdup(suffix);
+ node->dev = dev;
+
+ QTAILQ_FOREACH(i, &fw_boot_order, link) {
+ if (i->bootindex == bootindex) {
+ fprintf(stderr, "Two devices with same boot index %d\n", bootindex);
+ exit(1);
+ } else if (i->bootindex < bootindex) {
+ continue;
+ }
+ QTAILQ_INSERT_BEFORE(i, node, link);
+ return;
+ }
+ 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.
+ *
+ * memory pointed by "size" is assigned total length of the array in bytes
+ *
+ */
+char *get_boot_devices_list(size_t *size, bool ignore_suffixes)
+{
+ FWBootEntry *i;
+ size_t total = 0;
+ char *list = NULL;
+
+ QTAILQ_FOREACH(i, &fw_boot_order, link) {
+ char *devpath = NULL, *bootpath;
+ size_t len;
+
+ if (i->dev) {
+ devpath = qdev_get_fw_dev_path(i->dev);
+ assert(devpath);
+ }
+
+ if (i->suffix && !ignore_suffixes && devpath) {
+ size_t bootpathlen = strlen(devpath) + strlen(i->suffix) + 1;
+
+ bootpath = g_malloc(bootpathlen);
+ snprintf(bootpath, bootpathlen, "%s%s", devpath, i->suffix);
+ g_free(devpath);
+ } else if (devpath) {
+ bootpath = devpath;
+ } else if (!ignore_suffixes) {
+ assert(i->suffix);
+ bootpath = g_strdup(i->suffix);
+ } else {
+ bootpath = g_strdup("");
+ }
+
+ if (total) {
+ list[total-1] = '\n';
+ }
+ len = strlen(bootpath) + 1;
+ list = g_realloc(list, total + len);
+ memcpy(&list[total], bootpath, len);
+ total += len;
+ g_free(bootpath);
+ }
+
+ *size = total;
+
+ if (boot_strict && *size > 0) {
+ list[total-1] = '\n';
+ list = g_realloc(list, total + 5);
+ memcpy(&list[total], "HALT", 5);
+ *size = total + 5;
+ }
+ return list;
+}
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index d8539fd..8de5100 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -130,6 +130,7 @@ extern int no_shutdown;
extern int semihosting_enabled;
extern int old_param;
extern int boot_menu;
+extern bool boot_strict;
extern uint8_t *boot_splash_filedata;
extern size_t boot_splash_filedata_size;
extern uint8_t qemu_extra_params_fw[2];
diff --git a/vl.c b/vl.c
index 964d634..aee73e1 100644
--- a/vl.c
+++ b/vl.c
@@ -180,23 +180,12 @@ int ctrl_grab = 0;
unsigned int nb_prom_envs = 0;
const char *prom_envs[MAX_PROM_ENVS];
int boot_menu;
-static bool boot_strict;
+bool boot_strict;
uint8_t *boot_splash_filedata;
size_t boot_splash_filedata_size;
uint8_t qemu_extra_params_fw[2];
int icount_align_option;
-typedef struct FWBootEntry FWBootEntry;
-
-struct FWBootEntry {
- QTAILQ_ENTRY(FWBootEntry) link;
- int32_t bootindex;
- DeviceState *dev;
- char *suffix;
-};
-
-static QTAILQ_HEAD(, FWBootEntry) fw_boot_order =
- QTAILQ_HEAD_INITIALIZER(fw_boot_order);
int nb_numa_nodes;
int max_numa_nodeid;
@@ -1246,111 +1235,6 @@ static void restore_boot_order(void *opaque)
g_free(normal_boot_order);
}
-void add_boot_device_path(int32_t bootindex, DeviceState *dev,
- const char *suffix)
-{
- FWBootEntry *node, *i;
-
- if (bootindex < 0) {
- return;
- }
-
- assert(dev != NULL || suffix != NULL);
-
- node = g_malloc0(sizeof(FWBootEntry));
- node->bootindex = bootindex;
- node->suffix = g_strdup(suffix);
- node->dev = dev;
-
- QTAILQ_FOREACH(i, &fw_boot_order, link) {
- if (i->bootindex == bootindex) {
- fprintf(stderr, "Two devices with same boot index %d\n", bootindex);
- exit(1);
- } else if (i->bootindex < bootindex) {
- continue;
- }
- QTAILQ_INSERT_BEFORE(i, node, link);
- return;
- }
- 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.
- *
- * memory pointed by "size" is assigned total length of the array in bytes
- *
- */
-char *get_boot_devices_list(size_t *size, bool ignore_suffixes)
-{
- FWBootEntry *i;
- size_t total = 0;
- char *list = NULL;
-
- QTAILQ_FOREACH(i, &fw_boot_order, link) {
- char *devpath = NULL, *bootpath;
- size_t len;
-
- if (i->dev) {
- devpath = qdev_get_fw_dev_path(i->dev);
- assert(devpath);
- }
-
- if (i->suffix && !ignore_suffixes && devpath) {
- size_t bootpathlen = strlen(devpath) + strlen(i->suffix) + 1;
-
- bootpath = g_malloc(bootpathlen);
- snprintf(bootpath, bootpathlen, "%s%s", devpath, i->suffix);
- g_free(devpath);
- } else if (devpath) {
- bootpath = devpath;
- } else if (!ignore_suffixes) {
- assert(i->suffix);
- bootpath = g_strdup(i->suffix);
- } else {
- bootpath = g_strdup("");
- }
-
- if (total) {
- list[total-1] = '\n';
- }
- len = strlen(bootpath) + 1;
- list = g_realloc(list, total + len);
- memcpy(&list[total], bootpath, len);
- total += len;
- g_free(bootpath);
- }
-
- *size = total;
-
- if (boot_strict && *size > 0) {
- list[total-1] = '\n';
- list = g_realloc(list, total + 5);
- memcpy(&list[total], "HALT", 5);
- *size = total + 5;
- }
- return list;
-}
-
static QemuOptsList qemu_smp_opts = {
.name = "smp-opts",
.implied_opt_name = "cpus",
--
1.8.3.1
next prev parent reply other threads:[~2014-10-15 9:06 UTC|newest]
Thread overview: 38+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-10-15 9:05 [Qemu-devel] [PULL 00/34] allow changing bootorder via monitor Gerd Hoffmann
2014-10-15 9:05 ` Gerd Hoffmann [this message]
2014-10-15 9:05 ` [Qemu-devel] [PULL 02/34] bootindex: add check bootindex function Gerd Hoffmann
2014-10-15 9:05 ` [Qemu-devel] [PULL 03/34] bootindex: add del_boot_device_path function Gerd Hoffmann
2014-10-16 10:04 ` Peter Maydell
2014-10-16 10:11 ` Gonglei
2014-10-15 9:05 ` [Qemu-devel] [PULL 04/34] fw_cfg: add fw_cfg_machine_reset function Gerd Hoffmann
2014-10-15 9:05 ` [Qemu-devel] [PULL 05/34] bootindex: rework add_boot_device_path function Gerd Hoffmann
2014-10-15 9:05 ` [Qemu-devel] [PULL 06/34] bootindex: support to set a existent device's bootindex to -1 Gerd Hoffmann
2014-10-15 9:05 ` [Qemu-devel] [PULL 07/34] bootindex: add a setter/getter functions wrapper for bootindex property Gerd Hoffmann
2014-10-15 9:05 ` [Qemu-devel] [PULL 08/34] virtio-net: add bootindex to qom property Gerd Hoffmann
2014-10-15 9:05 ` [Qemu-devel] [PULL 09/34] e1000: " Gerd Hoffmann
2014-10-15 9:05 ` [Qemu-devel] [PULL 10/34] eepro100: " Gerd Hoffmann
2014-10-15 9:05 ` [Qemu-devel] [PULL 11/34] ne2000: " Gerd Hoffmann
2014-10-15 9:05 ` [Qemu-devel] [PULL 12/34] pcnet: " Gerd Hoffmann
2014-10-15 9:05 ` [Qemu-devel] [PULL 13/34] rtl8139: " Gerd Hoffmann
2014-10-15 9:05 ` [Qemu-devel] [PULL 14/34] spapr_lian: " Gerd Hoffmann
2014-10-15 9:05 ` [Qemu-devel] [PULL 15/34] vmxnet3: " Gerd Hoffmann
2014-10-15 9:05 ` [Qemu-devel] [PULL 16/34] usb-net: " Gerd Hoffmann
2014-10-15 9:05 ` [Qemu-devel] [PULL 17/34] net: remove bootindex property from qdev to qom Gerd Hoffmann
2014-10-15 9:05 ` [Qemu-devel] [PULL 18/34] virtio-net: alias bootindex property explicitly for virt-net-pci/ccw/s390 Gerd Hoffmann
2014-10-15 9:05 ` [Qemu-devel] [PULL 19/34] host-libusb: remove bootindex property from qdev to qom Gerd Hoffmann
2014-10-15 9:05 ` [Qemu-devel] [PULL 20/34] pci-assign: " Gerd Hoffmann
2014-10-15 9:05 ` [Qemu-devel] [PULL 21/34] vfio: " Gerd Hoffmann
2014-10-15 9:05 ` [Qemu-devel] [PULL 22/34] redirect: " Gerd Hoffmann
2014-10-15 9:05 ` [Qemu-devel] [PULL 23/34] isa-fdc: remove bootindexA/B " Gerd Hoffmann
2014-10-15 9:05 ` [Qemu-devel] [PULL 24/34] scsi: add bootindex to qom property Gerd Hoffmann
2014-10-15 9:05 ` [Qemu-devel] [PULL 25/34] ide: " Gerd Hoffmann
2014-10-15 9:05 ` [Qemu-devel] [PULL 26/34] virtio-blk: " Gerd Hoffmann
2014-10-15 9:06 ` [Qemu-devel] [PULL 27/34] block: remove bootindex property from qdev to qom Gerd Hoffmann
2014-10-15 9:06 ` [Qemu-devel] [PULL 28/34] virtio-blk: alias bootindex property explicitly for virt-blk-pci/ccw/s390 Gerd Hoffmann
2014-10-15 9:06 ` [Qemu-devel] [PULL 29/34] usb-storage: add bootindex to qom property Gerd Hoffmann
2014-10-15 9:06 ` [Qemu-devel] [PULL 30/34] nvma: ide: " Gerd Hoffmann
2014-10-15 9:06 ` [Qemu-devel] [PULL 31/34] ide: add calling add_boot_device_patch in bootindex setter function Gerd Hoffmann
2014-10-15 9:06 ` [Qemu-devel] [PULL 32/34] bootindex: move calling add_boot_device_patch to " Gerd Hoffmann
2014-10-15 9:06 ` [Qemu-devel] [PULL 33/34] bootindex: delete bootindex when device is removed Gerd Hoffmann
2014-10-15 9:06 ` [Qemu-devel] [PULL 34/34] bootindex: change fprintf to error_report Gerd Hoffmann
2014-10-16 8:25 ` [Qemu-devel] [PULL 00/34] allow changing bootorder via monitor Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1413363967-2489-2-git-send-email-kraxel@redhat.com \
--to=kraxel@redhat.com \
--cc=aliguori@amazon.com \
--cc=arei.gonglei@huawei.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).