Re: [PATCHv3 11/14] Add bootindex parameter to net/block/fd device

2010-11-10 Thread Gleb Natapov
On Wed, Nov 10, 2010 at 06:32:54PM +, Blue Swirl wrote:
> On Wed, Nov 10, 2010 at 5:14 PM, Gleb Natapov  wrote:
> > 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 
> > ---
> >  block_int.h     |    4 +++-
> >  hw/e1000.c      |    7 +++
> >  hw/eepro100.c   |    6 ++
> >  hw/fdc.c        |   13 +
> >  hw/ide/qdev.c   |    7 +++
> >  hw/ne2000.c     |    6 ++
> >  hw/pcnet.c      |    6 ++
> >  hw/qdev.c       |   32 
> >  hw/qdev.h       |    1 +
> >  hw/rtl8139.c    |    7 +++
> >  hw/usb-net.c    |    4 
> >  hw/virtio-blk.c |    4 
> >  hw/virtio-net.c |    4 
> >  net.h           |    4 +++-
> >  sysemu.h        |    2 ++
> >  vl.c            |   35 +++
> >  16 files changed, 140 insertions(+), 2 deletions(-)
> >
> > diff --git a/block_int.h b/block_int.h
> > index 87e60b8..f9042a8 100644
> > --- a/block_int.h
> > +++ b/block_int.h
> > @@ -227,6 +227,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)
> > @@ -249,6 +250,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..009e24b 100644
> > --- a/hw/e1000.c
> > +++ b/hw/e1000.c
> > @@ -30,6 +30,7 @@
> >  #include "net.h"
> >  #include "net/checksum.h"
> >  #include "loader.h"
> > +#include "sysemu.h"
> >
> >  #include "e1000_hw.h"
> >
> > @@ -1148,6 +1149,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) {
> 
> Maybe these checks should be moved into add_boot_device_path, that
> would simplify the callers.
Yep, good point.

--
Gleb.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


Re: [PATCHv3 11/14] Add bootindex parameter to net/block/fd device

2010-11-10 Thread Blue Swirl
On Wed, Nov 10, 2010 at 5:14 PM, Gleb Natapov  wrote:
> 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 
> ---
>  block_int.h     |    4 +++-
>  hw/e1000.c      |    7 +++
>  hw/eepro100.c   |    6 ++
>  hw/fdc.c        |   13 +
>  hw/ide/qdev.c   |    7 +++
>  hw/ne2000.c     |    6 ++
>  hw/pcnet.c      |    6 ++
>  hw/qdev.c       |   32 
>  hw/qdev.h       |    1 +
>  hw/rtl8139.c    |    7 +++
>  hw/usb-net.c    |    4 
>  hw/virtio-blk.c |    4 
>  hw/virtio-net.c |    4 
>  net.h           |    4 +++-
>  sysemu.h        |    2 ++
>  vl.c            |   35 +++
>  16 files changed, 140 insertions(+), 2 deletions(-)
>
> diff --git a/block_int.h b/block_int.h
> index 87e60b8..f9042a8 100644
> --- a/block_int.h
> +++ b/block_int.h
> @@ -227,6 +227,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)
> @@ -249,6 +250,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..009e24b 100644
> --- a/hw/e1000.c
> +++ b/hw/e1000.c
> @@ -30,6 +30,7 @@
>  #include "net.h"
>  #include "net/checksum.h"
>  #include "loader.h"
> +#include "sysemu.h"
>
>  #include "e1000_hw.h"
>
> @@ -1148,6 +1149,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) {

Maybe these checks should be moved into add_boot_device_path, that
would simplify the callers.
--
To unsubscribe from this list: send the line "unsubscribe kvm" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[PATCHv3 11/14] Add bootindex parameter to net/block/fd device

2010-11-10 Thread Gleb Natapov
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 
---
 block_int.h |4 +++-
 hw/e1000.c  |7 +++
 hw/eepro100.c   |6 ++
 hw/fdc.c|   13 +
 hw/ide/qdev.c   |7 +++
 hw/ne2000.c |6 ++
 hw/pcnet.c  |6 ++
 hw/qdev.c   |   32 
 hw/qdev.h   |1 +
 hw/rtl8139.c|7 +++
 hw/usb-net.c|4 
 hw/virtio-blk.c |4 
 hw/virtio-net.c |4 
 net.h   |4 +++-
 sysemu.h|2 ++
 vl.c|   35 +++
 16 files changed, 140 insertions(+), 2 deletions(-)

diff --git a/block_int.h b/block_int.h
index 87e60b8..f9042a8 100644
--- a/block_int.h
+++ b/block_int.h
@@ -227,6 +227,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)
@@ -249,6 +250,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..009e24b 100644
--- a/hw/e1000.c
+++ b/hw/e1000.c
@@ -30,6 +30,7 @@
 #include "net.h"
 #include "net/checksum.h"
 #include "loader.h"
+#include "sysemu.h"
 
 #include "e1000_hw.h"
 
@@ -1148,6 +1149,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) {
+add_boot_device_path(d->conf.bootindex, &pci_dev->qdev,
+ "ethernet-...@0");
+}
+
 return 0;
 }
 
diff --git a/hw/eepro100.c b/hw/eepro100.c
index 218472d..2a7c6cb 100644
--- a/hw/eepro100.c
+++ b/hw/eepro100.c
@@ -46,6 +46,7 @@
 #include "pci.h"
 #include "net.h"
 #include "eeprom93xx.h"
+#include "sysemu.h"
 
 #define KiB 1024
 
@@ -1907,6 +1908,11 @@ static int e100_nic_init(PCIDevice *pci_dev)
 s->vmstate->name = s->nic->nc.model;
 vmstate_register(&pci_dev->qdev, -1, s->vmstate, s);
 
+if (s->conf.bootindex >= 0) {
+add_boot_device_path(s->conf.bootindex, &pci_dev->qdev,
+ "ethernet-...@0");
+}
+
 return 0;
 }
 
diff --git a/hw/fdc.c b/hw/fdc.c
index 5ab754b..732728e 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) {
+add_boot_device_path(isa->bootindexA, &dev->qdev, "flo...@0");
+}
+
+if (isa->bootindexB >= 0) {
+add_boot_device_path(isa->bootindexB, &dev->qdev, "flo...@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 01a181b..dcd49aa 100644
--- a/hw/ide/qdev.c
+++ b/hw/ide/qdev.c
@@ -21,6 +21,7 @@
 #include "qemu-error.h"
 #include 
 #include "blockdev.h"
+#include "sysemu.h"
 
 /* - */
 
@@ -143,6 +144,12 @@ static int ide_drive_initfn(IDEDevice *dev)
 if (!dev->serial) {
 dev->serial = qemu_strdup(s->drive_serial_str);
 }
+
+if (dev->conf.bootindex >= 0) {
+add_boot_device_path(dev->conf.bootindex, &dev->qdev,
+ dev->unit ? "d...@1" : "d...@0");
+}
+
 return 0;
 }
 
diff --git a/hw/ne2000.c b/hw/ne2000.c
index 126e7cf..d0a0dc6 100644
--- a/hw/ne20