All of lore.kernel.org
 help / color / mirror / Atom feed
From: Gleb Natapov <gleb@redhat.com>
To: qemu-devel@nongnu.org
Cc: kvm@vger.kernel.org, blauwirbel@gmail.com, armbru@redhat.com,
	alex.williamson@redhat.com
Subject: [PATCHv2 8/8] Add bootindex parameter to net/block/fd device
Date: Sun, 31 Oct 2010 13:40:09 +0200	[thread overview]
Message-ID: <1288525209-3303-9-git-send-email-gleb@redhat.com> (raw)
In-Reply-To: <1288525209-3303-1-git-send-email-gleb@redhat.com>

If bootindex is specified on command line a string that describes device
in firmware readable way is added into sorted list. Later this list will
be passed into firmware to control boot order.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
 block_int.h     |    4 +++-
 hw/e1000.c      |    7 +++++++
 hw/fdc.c        |   13 +++++++++++++
 hw/ide/qdev.c   |    6 ++++++
 hw/qdev.c       |   52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/qdev.h       |    3 +++
 hw/virtio-blk.c |    4 ++++
 hw/virtio-net.c |    4 ++++
 net.h           |    4 +++-
 sysemu.h        |    9 +++++++++
 vl.c            |   24 ++++++++++++++++++++++++
 11 files changed, 128 insertions(+), 2 deletions(-)

diff --git a/block_int.h b/block_int.h
index e8e7156..60e7be2 100644
--- a/block_int.h
+++ b/block_int.h
@@ -225,6 +225,7 @@ typedef struct BlockConf {
     uint16_t logical_block_size;
     uint16_t min_io_size;
     uint32_t opt_io_size;
+    int32_t bootindex;
 } BlockConf;
 
 static inline unsigned int get_physical_block_exp(BlockConf *conf)
@@ -247,6 +248,7 @@ static inline unsigned int get_physical_block_exp(BlockConf *conf)
     DEFINE_PROP_UINT16("physical_block_size", _state,                   \
                        _conf.physical_block_size, 512),                 \
     DEFINE_PROP_UINT16("min_io_size", _state, _conf.min_io_size, 0),  \
-    DEFINE_PROP_UINT32("opt_io_size", _state, _conf.opt_io_size, 0)
+    DEFINE_PROP_UINT32("opt_io_size", _state, _conf.opt_io_size, 0),    \
+    DEFINE_PROP_INT32("bootindex", _state, _conf.bootindex, -1)         \
 
 #endif /* BLOCK_INT_H */
diff --git a/hw/e1000.c b/hw/e1000.c
index 532efdc..55f6f15 100644
--- a/hw/e1000.c
+++ b/hw/e1000.c
@@ -1148,6 +1148,12 @@ static int pci_e1000_init(PCIDevice *pci_dev)
                           d->dev.qdev.info->name, d->dev.qdev.id, d);
 
     qemu_format_nic_info_str(&d->nic->nc, macaddr);
+
+    if (d->conf.bootindex >= 0) {
+        qdev_add_boot_device_path(d->conf.bootindex, &pci_dev->qdev,
+                                  "ethernet-phy@0");
+    }
+
     return 0;
 }
 
@@ -1159,6 +1165,7 @@ static void qdev_e1000_reset(DeviceState *dev)
 
 static PCIDeviceInfo e1000_info = {
     .qdev.name  = "e1000",
+    .qdev.driver_name  = "ethernet",
     .qdev.desc  = "Intel Gigabit Ethernet",
     .qdev.size  = sizeof(E1000State),
     .qdev.reset = qdev_e1000_reset,
diff --git a/hw/fdc.c b/hw/fdc.c
index 51ca404..e7a1399 100644
--- a/hw/fdc.c
+++ b/hw/fdc.c
@@ -35,6 +35,7 @@
 #include "sysbus.h"
 #include "qdev-addr.h"
 #include "blockdev.h"
+#include "sysemu.h"
 
 /********************************************************/
 /* debug Floppy devices */
@@ -523,6 +524,8 @@ typedef struct FDCtrlSysBus {
 typedef struct FDCtrlISABus {
     ISADevice busdev;
     struct FDCtrl state;
+    int32_t bootindexA;
+    int32_t bootindexB;
 } FDCtrlISABus;
 
 static uint32_t fdctrl_read (void *opaque, uint32_t reg)
@@ -1992,6 +1995,14 @@ static int isabus_fdc_init1(ISADevice *dev)
     qdev_set_legacy_instance_id(&dev->qdev, iobase, 2);
     ret = fdctrl_init_common(fdctrl);
 
+    if (isa->bootindexA >= 0) {
+        qdev_add_boot_device_path(isa->bootindexA, &dev->qdev, "floppy@0");
+    }
+
+    if (isa->bootindexB >= 0) {
+        qdev_add_boot_device_path(isa->bootindexB, &dev->qdev, "floppy@1");
+    }
+
     return ret;
 }
 
@@ -2051,6 +2062,8 @@ static ISADeviceInfo isa_fdc_info = {
     .qdev.props = (Property[]) {
         DEFINE_PROP_DRIVE("driveA", FDCtrlISABus, state.drives[0].bs),
         DEFINE_PROP_DRIVE("driveB", FDCtrlISABus, state.drives[1].bs),
+        DEFINE_PROP_INT32("bootindexA", FDCtrlISABus, bootindexA, -1),
+        DEFINE_PROP_INT32("bootindexB", FDCtrlISABus, bootindexB, -1),
         DEFINE_PROP_END_OF_LIST(),
     },
 };
diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
index 7db2f19..49d2ac1 100644
--- a/hw/ide/qdev.c
+++ b/hw/ide/qdev.c
@@ -21,6 +21,7 @@
 #include "qemu-error.h"
 #include <hw/ide/internal.h>
 #include "blockdev.h"
+#include "sysemu.h"
 
 /* --------------------------------- */
 
@@ -144,6 +145,11 @@ static int ide_drive_initfn(IDEDevice *dev)
     if (!dev->serial) {
         dev->serial = qemu_strdup(s->drive_serial_str);
     }
+
+    if (dev->conf.bootindex >= 0) {
+        qdev_add_boot_device_path(dev->conf.bootindex, &dev->qdev, NULL);
+    }
+
     return 0;
 }
 
diff --git a/hw/qdev.c b/hw/qdev.c
index 35858cb..2306b06 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -820,3 +820,55 @@ int do_device_del(Monitor *mon, const QDict *qdict, QObject **ret_data)
     }
     return qdev_unplug(dev);
 }
+
+static int qdev_get_dev_path_helper(DeviceState *dev, char *p, int size)
+{
+    int l = 0;
+
+    if (dev && dev->parent_bus) {
+        char *d;
+        l = qdev_get_dev_path_helper(dev->parent_bus->parent, p, size);
+        if (dev->parent_bus->info->get_dev_path) {
+            d = dev->parent_bus->info->get_dev_path(dev);
+            l += snprintf(p + l, size - l, "%s", d);
+            qemu_free(d);
+        } else {
+            l += snprintf(p + l, size - l, "%s", dev->info->name);
+        }
+    }
+    l += snprintf(p + l , size - l, "/");
+
+    return l;
+}
+
+char* qdev_get_dev_path(DeviceState *dev)
+{
+    char path[128];
+    int l;
+
+    l = qdev_get_dev_path_helper(dev, path, 128);
+
+    path[l-1] = '\0';
+
+    return strdup(path);
+}
+
+void qdev_add_boot_device_path(int32_t bootindex, DeviceState *dev,
+                               const char *name)
+{
+    char *devpath, *bootpath;
+
+    devpath = qdev_get_dev_path(dev);
+
+    if (name) {
+        bootpath = qemu_malloc(strlen(devpath) + strlen(name) + 2);
+        sprintf(bootpath, "%s/%s", devpath, name);
+        qemu_free(devpath);
+    } else {
+        bootpath = devpath;
+    }
+
+    add_boot_device_path(bootindex, bootpath);
+
+    qemu_free(bootpath);
+}
diff --git a/hw/qdev.h b/hw/qdev.h
index a9a98f8..6d8a543 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -294,6 +294,9 @@ static inline const char *qdev_driver_name(DeviceState *dev)
     return dev->info->driver_name ? : dev->info->name;
 }
 
+void qdev_add_boot_device_path(int32_t bootindex, DeviceState *dev,
+                               const char *name);
+char *qdev_get_dev_path(DeviceState *dev);
 /* This is a nasty hack to allow passing a NULL bus to qdev_create.  */
 extern struct BusInfo system_bus_info;
 
diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
index a1df26d..c3175fb 100644
--- a/hw/virtio-blk.c
+++ b/hw/virtio-blk.c
@@ -542,6 +542,10 @@ VirtIODevice *virtio_blk_init(DeviceState *dev, BlockConf *conf)
     bdrv_set_removable(s->bs, 0);
     s->bs->buffer_alignment = conf->logical_block_size;
 
+    if (conf->bootindex >= 0) {
+        qdev_add_boot_device_path(conf->bootindex, dev, "virtio-disk@0");
+    }
+
     return &s->vdev;
 }
 
diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index 7e1688c..75a4407 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -1018,6 +1018,10 @@ VirtIODevice *virtio_net_init(DeviceState *dev, NICConf *conf,
                     virtio_net_save, virtio_net_load, n);
     n->vmstate = qemu_add_vm_change_state_handler(virtio_net_vmstate_change, n);
 
+    if (conf->bootindex >= 0) {
+        qdev_add_boot_device_path(conf->bootindex, dev, "ethernet-phy@0");
+    }
+
     return &n->vdev;
 }
 
diff --git a/net.h b/net.h
index 44c31a9..6ceca50 100644
--- a/net.h
+++ b/net.h
@@ -17,12 +17,14 @@ typedef struct NICConf {
     MACAddr macaddr;
     VLANState *vlan;
     VLANClientState *peer;
+    int32_t bootindex;
 } NICConf;
 
 #define DEFINE_NIC_PROPERTIES(_state, _conf)                            \
     DEFINE_PROP_MACADDR("mac",   _state, _conf.macaddr),                \
     DEFINE_PROP_VLAN("vlan",     _state, _conf.vlan),                   \
-    DEFINE_PROP_NETDEV("netdev", _state, _conf.peer)
+    DEFINE_PROP_NETDEV("netdev", _state, _conf.peer),                   \
+    DEFINE_PROP_INT32("bootindex", _state, _conf.bootindex, -1)
 
 /* VLANs support */
 
diff --git a/sysemu.h b/sysemu.h
index 849dc8c..cc35731 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -193,4 +193,13 @@ void rtc_change_mon_event(struct tm *tm);
 
 void register_devices(void);
 
+typedef struct FWBootEntry FWBootEntry;
+
+struct FWBootEntry {
+    QTAILQ_ENTRY(FWBootEntry) link;
+    int32_t bootindex;
+    char *fw_device_path;
+};
+
+void add_boot_device_path(int32_t bootindex, char *fw_device_path);
 #endif
diff --git a/vl.c b/vl.c
index 42617c2..25d5767 100644
--- a/vl.c
+++ b/vl.c
@@ -234,6 +234,8 @@ const char *prom_envs[MAX_PROM_ENVS];
 const char *nvram = NULL;
 int boot_menu;
 
+QTAILQ_HEAD(, FWBootEntry) fw_boot_order = QTAILQ_HEAD_INITIALIZER(fw_boot_order);
+
 int nb_numa_nodes;
 uint64_t node_mem[MAX_NODES];
 uint64_t node_cpumask[MAX_NODES];
@@ -722,6 +724,28 @@ static void restore_boot_devices(void *opaque)
     qemu_free(standard_boot_devices);
 }
 
+void add_boot_device_path(int32_t bootindex, char *fw_device_path)
+{
+    FWBootEntry *node = qemu_mallocz(sizeof(FWBootEntry)), *i;
+
+    node->bootindex = bootindex;
+    node->fw_device_path = fw_device_path;
+
+    printf("adding '%s' at index %d\n", fw_device_path, bootindex);
+    QTAILQ_FOREACH(i, &fw_boot_order, link) {
+        if (i->bootindex == bootindex) {
+            fprintf(stderr, "Two devices with same boot index %d (%s %s)\n",
+                    bootindex, i->fw_device_path, fw_device_path);
+            exit(1);
+        } else if (i->bootindex < bootindex) {
+            continue;
+        }
+        QTAILQ_INSERT_BEFORE(i, node, link);
+        return;
+    }
+    QTAILQ_INSERT_TAIL(&fw_boot_order, node, link);
+}
+
 static void numa_add(const char *optarg)
 {
     char option[128];
-- 
1.7.1


WARNING: multiple messages have this Message-ID (diff)
From: Gleb Natapov <gleb@redhat.com>
To: qemu-devel@nongnu.org
Cc: blauwirbel@gmail.com, alex.williamson@redhat.com,
	armbru@redhat.com, kvm@vger.kernel.org
Subject: [Qemu-devel] [PATCHv2 8/8] Add bootindex parameter to net/block/fd device
Date: Sun, 31 Oct 2010 13:40:09 +0200	[thread overview]
Message-ID: <1288525209-3303-9-git-send-email-gleb@redhat.com> (raw)
In-Reply-To: <1288525209-3303-1-git-send-email-gleb@redhat.com>

If bootindex is specified on command line a string that describes device
in firmware readable way is added into sorted list. Later this list will
be passed into firmware to control boot order.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
 block_int.h     |    4 +++-
 hw/e1000.c      |    7 +++++++
 hw/fdc.c        |   13 +++++++++++++
 hw/ide/qdev.c   |    6 ++++++
 hw/qdev.c       |   52 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 hw/qdev.h       |    3 +++
 hw/virtio-blk.c |    4 ++++
 hw/virtio-net.c |    4 ++++
 net.h           |    4 +++-
 sysemu.h        |    9 +++++++++
 vl.c            |   24 ++++++++++++++++++++++++
 11 files changed, 128 insertions(+), 2 deletions(-)

diff --git a/block_int.h b/block_int.h
index e8e7156..60e7be2 100644
--- a/block_int.h
+++ b/block_int.h
@@ -225,6 +225,7 @@ typedef struct BlockConf {
     uint16_t logical_block_size;
     uint16_t min_io_size;
     uint32_t opt_io_size;
+    int32_t bootindex;
 } BlockConf;
 
 static inline unsigned int get_physical_block_exp(BlockConf *conf)
@@ -247,6 +248,7 @@ static inline unsigned int get_physical_block_exp(BlockConf *conf)
     DEFINE_PROP_UINT16("physical_block_size", _state,                   \
                        _conf.physical_block_size, 512),                 \
     DEFINE_PROP_UINT16("min_io_size", _state, _conf.min_io_size, 0),  \
-    DEFINE_PROP_UINT32("opt_io_size", _state, _conf.opt_io_size, 0)
+    DEFINE_PROP_UINT32("opt_io_size", _state, _conf.opt_io_size, 0),    \
+    DEFINE_PROP_INT32("bootindex", _state, _conf.bootindex, -1)         \
 
 #endif /* BLOCK_INT_H */
diff --git a/hw/e1000.c b/hw/e1000.c
index 532efdc..55f6f15 100644
--- a/hw/e1000.c
+++ b/hw/e1000.c
@@ -1148,6 +1148,12 @@ static int pci_e1000_init(PCIDevice *pci_dev)
                           d->dev.qdev.info->name, d->dev.qdev.id, d);
 
     qemu_format_nic_info_str(&d->nic->nc, macaddr);
+
+    if (d->conf.bootindex >= 0) {
+        qdev_add_boot_device_path(d->conf.bootindex, &pci_dev->qdev,
+                                  "ethernet-phy@0");
+    }
+
     return 0;
 }
 
@@ -1159,6 +1165,7 @@ static void qdev_e1000_reset(DeviceState *dev)
 
 static PCIDeviceInfo e1000_info = {
     .qdev.name  = "e1000",
+    .qdev.driver_name  = "ethernet",
     .qdev.desc  = "Intel Gigabit Ethernet",
     .qdev.size  = sizeof(E1000State),
     .qdev.reset = qdev_e1000_reset,
diff --git a/hw/fdc.c b/hw/fdc.c
index 51ca404..e7a1399 100644
--- a/hw/fdc.c
+++ b/hw/fdc.c
@@ -35,6 +35,7 @@
 #include "sysbus.h"
 #include "qdev-addr.h"
 #include "blockdev.h"
+#include "sysemu.h"
 
 /********************************************************/
 /* debug Floppy devices */
@@ -523,6 +524,8 @@ typedef struct FDCtrlSysBus {
 typedef struct FDCtrlISABus {
     ISADevice busdev;
     struct FDCtrl state;
+    int32_t bootindexA;
+    int32_t bootindexB;
 } FDCtrlISABus;
 
 static uint32_t fdctrl_read (void *opaque, uint32_t reg)
@@ -1992,6 +1995,14 @@ static int isabus_fdc_init1(ISADevice *dev)
     qdev_set_legacy_instance_id(&dev->qdev, iobase, 2);
     ret = fdctrl_init_common(fdctrl);
 
+    if (isa->bootindexA >= 0) {
+        qdev_add_boot_device_path(isa->bootindexA, &dev->qdev, "floppy@0");
+    }
+
+    if (isa->bootindexB >= 0) {
+        qdev_add_boot_device_path(isa->bootindexB, &dev->qdev, "floppy@1");
+    }
+
     return ret;
 }
 
@@ -2051,6 +2062,8 @@ static ISADeviceInfo isa_fdc_info = {
     .qdev.props = (Property[]) {
         DEFINE_PROP_DRIVE("driveA", FDCtrlISABus, state.drives[0].bs),
         DEFINE_PROP_DRIVE("driveB", FDCtrlISABus, state.drives[1].bs),
+        DEFINE_PROP_INT32("bootindexA", FDCtrlISABus, bootindexA, -1),
+        DEFINE_PROP_INT32("bootindexB", FDCtrlISABus, bootindexB, -1),
         DEFINE_PROP_END_OF_LIST(),
     },
 };
diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
index 7db2f19..49d2ac1 100644
--- a/hw/ide/qdev.c
+++ b/hw/ide/qdev.c
@@ -21,6 +21,7 @@
 #include "qemu-error.h"
 #include <hw/ide/internal.h>
 #include "blockdev.h"
+#include "sysemu.h"
 
 /* --------------------------------- */
 
@@ -144,6 +145,11 @@ static int ide_drive_initfn(IDEDevice *dev)
     if (!dev->serial) {
         dev->serial = qemu_strdup(s->drive_serial_str);
     }
+
+    if (dev->conf.bootindex >= 0) {
+        qdev_add_boot_device_path(dev->conf.bootindex, &dev->qdev, NULL);
+    }
+
     return 0;
 }
 
diff --git a/hw/qdev.c b/hw/qdev.c
index 35858cb..2306b06 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -820,3 +820,55 @@ int do_device_del(Monitor *mon, const QDict *qdict, QObject **ret_data)
     }
     return qdev_unplug(dev);
 }
+
+static int qdev_get_dev_path_helper(DeviceState *dev, char *p, int size)
+{
+    int l = 0;
+
+    if (dev && dev->parent_bus) {
+        char *d;
+        l = qdev_get_dev_path_helper(dev->parent_bus->parent, p, size);
+        if (dev->parent_bus->info->get_dev_path) {
+            d = dev->parent_bus->info->get_dev_path(dev);
+            l += snprintf(p + l, size - l, "%s", d);
+            qemu_free(d);
+        } else {
+            l += snprintf(p + l, size - l, "%s", dev->info->name);
+        }
+    }
+    l += snprintf(p + l , size - l, "/");
+
+    return l;
+}
+
+char* qdev_get_dev_path(DeviceState *dev)
+{
+    char path[128];
+    int l;
+
+    l = qdev_get_dev_path_helper(dev, path, 128);
+
+    path[l-1] = '\0';
+
+    return strdup(path);
+}
+
+void qdev_add_boot_device_path(int32_t bootindex, DeviceState *dev,
+                               const char *name)
+{
+    char *devpath, *bootpath;
+
+    devpath = qdev_get_dev_path(dev);
+
+    if (name) {
+        bootpath = qemu_malloc(strlen(devpath) + strlen(name) + 2);
+        sprintf(bootpath, "%s/%s", devpath, name);
+        qemu_free(devpath);
+    } else {
+        bootpath = devpath;
+    }
+
+    add_boot_device_path(bootindex, bootpath);
+
+    qemu_free(bootpath);
+}
diff --git a/hw/qdev.h b/hw/qdev.h
index a9a98f8..6d8a543 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -294,6 +294,9 @@ static inline const char *qdev_driver_name(DeviceState *dev)
     return dev->info->driver_name ? : dev->info->name;
 }
 
+void qdev_add_boot_device_path(int32_t bootindex, DeviceState *dev,
+                               const char *name);
+char *qdev_get_dev_path(DeviceState *dev);
 /* This is a nasty hack to allow passing a NULL bus to qdev_create.  */
 extern struct BusInfo system_bus_info;
 
diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
index a1df26d..c3175fb 100644
--- a/hw/virtio-blk.c
+++ b/hw/virtio-blk.c
@@ -542,6 +542,10 @@ VirtIODevice *virtio_blk_init(DeviceState *dev, BlockConf *conf)
     bdrv_set_removable(s->bs, 0);
     s->bs->buffer_alignment = conf->logical_block_size;
 
+    if (conf->bootindex >= 0) {
+        qdev_add_boot_device_path(conf->bootindex, dev, "virtio-disk@0");
+    }
+
     return &s->vdev;
 }
 
diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index 7e1688c..75a4407 100644
--- a/hw/virtio-net.c
+++ b/hw/virtio-net.c
@@ -1018,6 +1018,10 @@ VirtIODevice *virtio_net_init(DeviceState *dev, NICConf *conf,
                     virtio_net_save, virtio_net_load, n);
     n->vmstate = qemu_add_vm_change_state_handler(virtio_net_vmstate_change, n);
 
+    if (conf->bootindex >= 0) {
+        qdev_add_boot_device_path(conf->bootindex, dev, "ethernet-phy@0");
+    }
+
     return &n->vdev;
 }
 
diff --git a/net.h b/net.h
index 44c31a9..6ceca50 100644
--- a/net.h
+++ b/net.h
@@ -17,12 +17,14 @@ typedef struct NICConf {
     MACAddr macaddr;
     VLANState *vlan;
     VLANClientState *peer;
+    int32_t bootindex;
 } NICConf;
 
 #define DEFINE_NIC_PROPERTIES(_state, _conf)                            \
     DEFINE_PROP_MACADDR("mac",   _state, _conf.macaddr),                \
     DEFINE_PROP_VLAN("vlan",     _state, _conf.vlan),                   \
-    DEFINE_PROP_NETDEV("netdev", _state, _conf.peer)
+    DEFINE_PROP_NETDEV("netdev", _state, _conf.peer),                   \
+    DEFINE_PROP_INT32("bootindex", _state, _conf.bootindex, -1)
 
 /* VLANs support */
 
diff --git a/sysemu.h b/sysemu.h
index 849dc8c..cc35731 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -193,4 +193,13 @@ void rtc_change_mon_event(struct tm *tm);
 
 void register_devices(void);
 
+typedef struct FWBootEntry FWBootEntry;
+
+struct FWBootEntry {
+    QTAILQ_ENTRY(FWBootEntry) link;
+    int32_t bootindex;
+    char *fw_device_path;
+};
+
+void add_boot_device_path(int32_t bootindex, char *fw_device_path);
 #endif
diff --git a/vl.c b/vl.c
index 42617c2..25d5767 100644
--- a/vl.c
+++ b/vl.c
@@ -234,6 +234,8 @@ const char *prom_envs[MAX_PROM_ENVS];
 const char *nvram = NULL;
 int boot_menu;
 
+QTAILQ_HEAD(, FWBootEntry) fw_boot_order = QTAILQ_HEAD_INITIALIZER(fw_boot_order);
+
 int nb_numa_nodes;
 uint64_t node_mem[MAX_NODES];
 uint64_t node_cpumask[MAX_NODES];
@@ -722,6 +724,28 @@ static void restore_boot_devices(void *opaque)
     qemu_free(standard_boot_devices);
 }
 
+void add_boot_device_path(int32_t bootindex, char *fw_device_path)
+{
+    FWBootEntry *node = qemu_mallocz(sizeof(FWBootEntry)), *i;
+
+    node->bootindex = bootindex;
+    node->fw_device_path = fw_device_path;
+
+    printf("adding '%s' at index %d\n", fw_device_path, bootindex);
+    QTAILQ_FOREACH(i, &fw_boot_order, link) {
+        if (i->bootindex == bootindex) {
+            fprintf(stderr, "Two devices with same boot index %d (%s %s)\n",
+                    bootindex, i->fw_device_path, fw_device_path);
+            exit(1);
+        } else if (i->bootindex < bootindex) {
+            continue;
+        }
+        QTAILQ_INSERT_BEFORE(i, node, link);
+        return;
+    }
+    QTAILQ_INSERT_TAIL(&fw_boot_order, node, link);
+}
+
 static void numa_add(const char *optarg)
 {
     char option[128];
-- 
1.7.1

  parent reply	other threads:[~2010-10-31 11:40 UTC|newest]

Thread overview: 70+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-31 11:40 [PATCHv2 0/8 RFC] boot order specification Gleb Natapov
2010-10-31 11:40 ` [Qemu-devel] " Gleb Natapov
2010-10-31 11:40 ` [PATCHv2 1/8] Introduce deriver_name field to DeviceInfo structure Gleb Natapov
2010-10-31 11:40   ` [Qemu-devel] " Gleb Natapov
2010-11-04  9:20   ` Markus Armbruster
2010-11-04  9:20     ` Markus Armbruster
2010-11-04  9:42     ` Gleb Natapov
2010-11-04  9:42       ` Gleb Natapov
2010-11-04 14:58       ` Markus Armbruster
2010-11-04 15:44         ` Gleb Natapov
2010-11-05 14:14           ` Markus Armbruster
2010-11-05 15:41             ` Gleb Natapov
2010-11-05 16:24               ` Markus Armbruster
2010-11-05 18:31                 ` Gleb Natapov
2010-11-06  9:01                   ` Markus Armbruster
2010-11-06 11:53                     ` Gleb Natapov
2010-11-06 12:55                       ` Markus Armbruster
2010-10-31 11:40 ` [PATCHv2 2/8] Keep track of ISA ports ISA device is using in qdev Gleb Natapov
2010-10-31 11:40   ` [Qemu-devel] " Gleb Natapov
2010-10-31 11:40 ` [PATCHv2 3/8] Add get_dev_path callback to ISA bus " Gleb Natapov
2010-10-31 11:40   ` [Qemu-devel] " Gleb Natapov
2010-10-31 11:40 ` [PATCHv2 4/8] Store IDE bus id in IDEBus structure for easy access Gleb Natapov
2010-10-31 11:40   ` [Qemu-devel] " Gleb Natapov
2010-11-03 13:39   ` Markus Armbruster
2010-11-03 13:39     ` Markus Armbruster
2010-11-03 13:47     ` Gleb Natapov
2010-11-03 13:47       ` Gleb Natapov
2010-11-03 15:18       ` Markus Armbruster
2010-11-03 16:43         ` Gleb Natapov
2010-11-03 17:22           ` Markus Armbruster
2010-11-04  8:07             ` Gleb Natapov
2010-11-04  8:46               ` Markus Armbruster
2010-11-04  9:23                 ` Gleb Natapov
2010-11-04 14:22                   ` Markus Armbruster
2010-11-04 15:26                     ` Gleb Natapov
2010-11-05 14:04                       ` Markus Armbruster
2010-11-05 15:54                         ` Gleb Natapov
2010-11-05 16:31                           ` Markus Armbruster
2010-11-05 18:44                             ` Gleb Natapov
2010-11-06  9:25                               ` Markus Armbruster
2010-11-06 11:37                                 ` Gleb Natapov
2010-11-06 12:46                                   ` Markus Armbruster
2010-10-31 11:40 ` [PATCHv2 5/8] Add get_dev_path callback to IDE bus Gleb Natapov
2010-10-31 11:40   ` [Qemu-devel] " Gleb Natapov
2010-10-31 11:40 ` [PATCHv2 6/8] Add get_dev_path callback for system bus Gleb Natapov
2010-10-31 11:40   ` [Qemu-devel] " Gleb Natapov
2010-10-31 11:40 ` [PATCHv2 7/8] Change pci bus get_dev_path callback to print only slot and func Gleb Natapov
2010-10-31 11:40   ` [Qemu-devel] " Gleb Natapov
2010-11-08 17:17   ` Michael S. Tsirkin
2010-11-08 17:17     ` [Qemu-devel] " Michael S. Tsirkin
2010-11-08 17:29     ` Gleb Natapov
2010-11-08 17:29       ` [Qemu-devel] " Gleb Natapov
2010-11-08 18:12       ` Michael S. Tsirkin
2010-11-08 18:12         ` [Qemu-devel] " Michael S. Tsirkin
2010-11-08 18:22         ` Gleb Natapov
2010-11-08 18:22           ` [Qemu-devel] " Gleb Natapov
2010-11-08 21:00       ` Michael S. Tsirkin
2010-11-08 21:00         ` [Qemu-devel] " Michael S. Tsirkin
2010-11-08 21:12         ` Gleb Natapov
2010-11-08 21:12           ` [Qemu-devel] " Gleb Natapov
2010-11-08 17:26   ` Michael S. Tsirkin
2010-11-08 17:26     ` [Qemu-devel] " Michael S. Tsirkin
2010-10-31 11:40 ` Gleb Natapov [this message]
2010-10-31 11:40   ` [Qemu-devel] [PATCHv2 8/8] Add bootindex parameter to net/block/fd device Gleb Natapov
2010-10-31 22:25 ` [PATCHv2 0/8 RFC] boot order specification Kevin O'Connor
2010-10-31 22:25   ` [Qemu-devel] " Kevin O'Connor
2010-11-01  7:53   ` Gleb Natapov
2010-11-01  7:53     ` [Qemu-devel] " Gleb Natapov
2010-11-04  9:24     ` Markus Armbruster
2010-11-04  9:45       ` Gleb Natapov

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=1288525209-3303-9-git-send-email-gleb@redhat.com \
    --to=gleb@redhat.com \
    --cc=alex.williamson@redhat.com \
    --cc=armbru@redhat.com \
    --cc=blauwirbel@gmail.com \
    --cc=kvm@vger.kernel.org \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.