qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCHv3 00/14] boot order specification
@ 2010-11-10 17:14 Gleb Natapov
  2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 01/14] Introduce fw_name field to DeviceInfo structure Gleb Natapov
                   ` (15 more replies)
  0 siblings, 16 replies; 42+ messages in thread
From: Gleb Natapov @ 2010-11-10 17:14 UTC (permalink / raw)
  To: qemu-devel; +Cc: blauwirbel, alex.williamson, armbru, kvm, mst

This is current sate of the patch series for people to comment on.
I am using open firmware naming scheme to specify device path names.

Names look like this on pci machine:
/pci@i0cf8/ide@1,1/drive@1/disk@0
/pci@i0cf8/isa@1/fdc@03f1/floppy@1
/pci@i0cf8/isa@1/fdc@03f1/floppy@0
/pci@i0cf8/ide@1,1/drive@1/disk@1
/pci@i0cf8/ide@1,1/drive@0/disk@0
/pci@i0cf8/scsi@3/disk@0
/pci@i0cf8/ethernet@4/ethernet-phy@0
/pci@i0cf8/ethernet@5/ethernet-phy@0
/pci@i0cf8/ide@1,1/drive@0/disk@1
/pci@i0cf8/isa@1/ide@01e8/drive@0/disk@0
/pci@i0cf8/usb@1,2/network@0/ethernet@0
/pci@i0cf8/usb@1,2/hub@1/network@0/ethernet@0

and on isa machine:
/isa/ide@0170/drive@0/disk@0
/isa/fdc@03f1/floppy@1
/isa/fdc@03f1/floppy@0
/isa/ide@0170/drive@0/disk@1


Instead of using get_dev_path() callback I introduces another one
get_fw_dev_path. Unfortunately the way get_dev_path() callback is used
in migration code makes it hard to reuse it for other purposes. First
of all it is not called recursively so caller expects it to provide
unique name by itself. Device path though is inherently recursive. Each
individual element may not be unique, but the whole path will be. On
the other hand to call get_dev_path() recursively in migration code we
should implement it for all possible buses first. Other problem is
compatibility. If we change get_dev_path() output format now we will not
be able to migrate from old qemu to new one without some additional
compatibility layer.

Gleb Natapov (14):
  Introduce fw_name field to DeviceInfo structure.
  Introduce new BusInfo callback get_fw_dev_path.
  Keep track of ISA ports ISA device is using in qdev.
  Add get_fw_dev_path callback to ISA bus in qdev.
  Store IDE bus id in IDEBus structure for easy access.
  Add get_fw_dev_path callback to IDE bus.
  Add get_dev_path callback for system bus.
  Add get_fw_dev_path callback for pci bus.
  Record which USBDevice USBPort belongs too.
  Add get_dev_path callback for usb bus.
  Add bootindex parameter to net/block/fd device
  Add bootindex parameter to pci assigned device.
  Add notifier that will be called when machine is fully created.
  Pass boot device list to firmware.

 block_int.h            |    4 ++-
 hw/cs4231a.c           |    1 +
 hw/device-assignment.c |    7 ++++
 hw/device-assignment.h |    1 +
 hw/e1000.c             |    7 ++++
 hw/eepro100.c          |    6 +++
 hw/fdc.c               |   17 +++++++++
 hw/fw_cfg.h            |    1 +
 hw/gus.c               |    4 ++
 hw/ide/cmd646.c        |    4 +-
 hw/ide/internal.h      |    3 +-
 hw/ide/isa.c           |    5 ++-
 hw/ide/piix.c          |    4 +-
 hw/ide/qdev.c          |   24 ++++++++++++-
 hw/ide/via.c           |    4 +-
 hw/isa-bus.c           |   41 ++++++++++++++++++++++
 hw/isa.h               |    4 ++
 hw/lance.c             |    1 +
 hw/m48t59.c            |    1 +
 hw/mc146818rtc.c       |    1 +
 hw/ne2000-isa.c        |    3 ++
 hw/ne2000.c            |    6 +++
 hw/parallel.c          |    5 +++
 hw/pc.c                |   19 ++++++++++
 hw/pci.c               |   54 ++++++++++++++++++++++++++++
 hw/pci_host.c          |    2 +
 hw/pckbd.c             |    3 ++
 hw/pcnet.c             |    6 +++
 hw/piix_pci.c          |    1 +
 hw/qdev.c              |   32 +++++++++++++++++
 hw/qdev.h              |    9 +++++
 hw/rtl8139.c           |    7 ++++
 hw/sb16.c              |    4 ++
 hw/serial.c            |    1 +
 hw/sysbus.c            |   30 ++++++++++++++++
 hw/sysbus.h            |    4 ++
 hw/usb-bus.c           |   38 ++++++++++++++++++++-
 hw/usb-hub.c           |    3 +-
 hw/usb-musb.c          |    2 +-
 hw/usb-net.c           |    5 +++
 hw/usb-ohci.c          |    2 +-
 hw/usb-uhci.c          |    2 +-
 hw/usb.h               |    3 +-
 hw/virtio-blk.c        |    4 ++
 hw/virtio-net.c        |    4 ++
 hw/virtio-pci.c        |    1 +
 net.h                  |    4 ++-
 sysemu.h               |    5 +++
 vl.c                   |   90 ++++++++++++++++++++++++++++++++++++++++++++++++
 49 files changed, 472 insertions(+), 17 deletions(-)

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCHv3 01/14] Introduce fw_name field to DeviceInfo structure.
  2010-11-10 17:14 [Qemu-devel] [PATCHv3 00/14] boot order specification Gleb Natapov
@ 2010-11-10 17:14 ` Gleb Natapov
  2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 02/14] Introduce new BusInfo callback get_fw_dev_path Gleb Natapov
                   ` (14 subsequent siblings)
  15 siblings, 0 replies; 42+ messages in thread
From: Gleb Natapov @ 2010-11-10 17:14 UTC (permalink / raw)
  To: qemu-devel; +Cc: blauwirbel, alex.williamson, armbru, kvm, mst

Add "fw_name" to DeviceInfo to use in device path building. In
contrast to "name" "fw_name" should refer to functionality device
provides instead of particular device model like "name" does.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
 hw/fdc.c        |    1 +
 hw/ide/isa.c    |    1 +
 hw/ide/qdev.c   |    1 +
 hw/isa-bus.c    |    1 +
 hw/lance.c      |    1 +
 hw/piix_pci.c   |    1 +
 hw/qdev.h       |    6 ++++++
 hw/usb-hub.c    |    1 +
 hw/usb-net.c    |    1 +
 hw/virtio-pci.c |    1 +
 10 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/hw/fdc.c b/hw/fdc.c
index c159dcb..a467c4b 100644
--- a/hw/fdc.c
+++ b/hw/fdc.c
@@ -2040,6 +2040,7 @@ static const VMStateDescription vmstate_isa_fdc ={
 static ISADeviceInfo isa_fdc_info = {
     .init = isabus_fdc_init1,
     .qdev.name  = "isa-fdc",
+    .qdev.fw_name  = "fdc",
     .qdev.size  = sizeof(FDCtrlISABus),
     .qdev.no_user = 1,
     .qdev.vmsd  = &vmstate_isa_fdc,
diff --git a/hw/ide/isa.c b/hw/ide/isa.c
index 6b57e0d..9856435 100644
--- a/hw/ide/isa.c
+++ b/hw/ide/isa.c
@@ -98,6 +98,7 @@ ISADevice *isa_ide_init(int iobase, int iobase2, int isairq,
 
 static ISADeviceInfo isa_ide_info = {
     .qdev.name  = "isa-ide",
+    .qdev.fw_name  = "ide",
     .qdev.size  = sizeof(ISAIDEState),
     .init       = isa_ide_initfn,
     .qdev.reset = isa_ide_reset,
diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
index 0808760..6d27b60 100644
--- a/hw/ide/qdev.c
+++ b/hw/ide/qdev.c
@@ -134,6 +134,7 @@ static int ide_drive_initfn(IDEDevice *dev)
 
 static IDEDeviceInfo ide_drive_info = {
     .qdev.name  = "ide-drive",
+    .qdev.fw_name  = "drive",
     .qdev.size  = sizeof(IDEDrive),
     .init       = ide_drive_initfn,
     .qdev.props = (Property[]) {
diff --git a/hw/isa-bus.c b/hw/isa-bus.c
index 4e306de..26036e0 100644
--- a/hw/isa-bus.c
+++ b/hw/isa-bus.c
@@ -153,6 +153,7 @@ static int isabus_bridge_init(SysBusDevice *dev)
 static SysBusDeviceInfo isabus_bridge_info = {
     .init = isabus_bridge_init,
     .qdev.name  = "isabus-bridge",
+    .qdev.fw_name  = "isa",
     .qdev.size  = sizeof(SysBusDevice),
     .qdev.no_user = 1,
 };
diff --git a/hw/lance.c b/hw/lance.c
index b6b04dd..309099d 100644
--- a/hw/lance.c
+++ b/hw/lance.c
@@ -147,6 +147,7 @@ static void lance_reset(DeviceState *dev)
 static SysBusDeviceInfo lance_info = {
     .init       = lance_init,
     .qdev.name  = "lance",
+    .qdev.fw_name  = "ethernet",
     .qdev.size  = sizeof(SysBusPCNetState),
     .qdev.reset = lance_reset,
     .qdev.vmsd  = &vmstate_lance,
diff --git a/hw/piix_pci.c b/hw/piix_pci.c
index 00060f3..a4908d7 100644
--- a/hw/piix_pci.c
+++ b/hw/piix_pci.c
@@ -377,6 +377,7 @@ static PCIDeviceInfo i440fx_info[] = {
 static SysBusDeviceInfo i440fx_pcihost_info = {
     .init         = i440fx_pcihost_initfn,
     .qdev.name    = "i440FX-pcihost",
+    .qdev.fw_name = "pci",
     .qdev.size    = sizeof(I440FXState),
     .qdev.no_user = 1,
 };
diff --git a/hw/qdev.h b/hw/qdev.h
index 579328a..9f90efe 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -139,6 +139,7 @@ typedef void (*qdev_resetfn)(DeviceState *dev);
 
 struct DeviceInfo {
     const char *name;
+    const char *fw_name;
     const char *alias;
     const char *desc;
     size_t size;
@@ -288,6 +289,11 @@ void qdev_prop_set_defaults(DeviceState *dev, Property *props);
 void qdev_prop_register_global_list(GlobalProperty *props);
 void qdev_prop_set_globals(DeviceState *dev);
 
+static inline const char *qdev_fw_name(DeviceState *dev)
+{
+    return dev->info->fw_name ? : dev->info->alias ? : dev->info->name;
+}
+
 /* This is a nasty hack to allow passing a NULL bus to qdev_create.  */
 extern struct BusInfo system_bus_info;
 
diff --git a/hw/usb-hub.c b/hw/usb-hub.c
index 2a1edfc..8e3a96b 100644
--- a/hw/usb-hub.c
+++ b/hw/usb-hub.c
@@ -545,6 +545,7 @@ static int usb_hub_initfn(USBDevice *dev)
 static struct USBDeviceInfo hub_info = {
     .product_desc   = "QEMU USB Hub",
     .qdev.name      = "usb-hub",
+    .qdev.fw_name    = "hub",
     .qdev.size      = sizeof(USBHubState),
     .init           = usb_hub_initfn,
     .handle_packet  = usb_hub_handle_packet,
diff --git a/hw/usb-net.c b/hw/usb-net.c
index 70f9263..2287ee1 100644
--- a/hw/usb-net.c
+++ b/hw/usb-net.c
@@ -1496,6 +1496,7 @@ static USBDevice *usb_net_init(const char *cmdline)
 static struct USBDeviceInfo net_info = {
     .product_desc   = "QEMU USB Network Interface",
     .qdev.name      = "usb-net",
+    .qdev.fw_name    = "network",
     .qdev.size      = sizeof(USBNetState),
     .init           = usb_net_initfn,
     .handle_packet  = usb_generic_handle_packet,
diff --git a/hw/virtio-pci.c b/hw/virtio-pci.c
index 2d78ca6..7435cb1 100644
--- a/hw/virtio-pci.c
+++ b/hw/virtio-pci.c
@@ -769,6 +769,7 @@ static int virtio_9p_init_pci(PCIDevice *pci_dev)
 static PCIDeviceInfo virtio_info[] = {
     {
         .qdev.name = "virtio-blk-pci",
+        .qdev.alias = "virtio-blk",
         .qdev.size = sizeof(VirtIOPCIProxy),
         .init      = virtio_blk_init_pci,
         .exit      = virtio_blk_exit_pci,
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCHv3 02/14] Introduce new BusInfo callback get_fw_dev_path.
  2010-11-10 17:14 [Qemu-devel] [PATCHv3 00/14] boot order specification Gleb Natapov
  2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 01/14] Introduce fw_name field to DeviceInfo structure Gleb Natapov
@ 2010-11-10 17:14 ` Gleb Natapov
  2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 03/14] Keep track of ISA ports ISA device is using in qdev Gleb Natapov
                   ` (13 subsequent siblings)
  15 siblings, 0 replies; 42+ messages in thread
From: Gleb Natapov @ 2010-11-10 17:14 UTC (permalink / raw)
  To: qemu-devel; +Cc: blauwirbel, alex.williamson, armbru, kvm, mst

New get_fw_dev_path callback will be used for build device path usable
by firmware in contrast to qdev qemu internal device path.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
 hw/qdev.h |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/hw/qdev.h b/hw/qdev.h
index 9f90efe..dc669b3 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -49,12 +49,14 @@ struct DeviceState {
 
 typedef void (*bus_dev_printfn)(Monitor *mon, DeviceState *dev, int indent);
 typedef char *(*bus_get_dev_path)(DeviceState *dev);
+typedef char *(*bus_get_fw_dev_path)(DeviceState *dev);
 
 struct BusInfo {
     const char *name;
     size_t size;
     bus_dev_printfn print_dev;
     bus_get_dev_path get_dev_path;
+    bus_get_fw_dev_path get_fw_dev_path;
     Property *props;
 };
 
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCHv3 03/14] Keep track of ISA ports ISA device is using in qdev.
  2010-11-10 17:14 [Qemu-devel] [PATCHv3 00/14] boot order specification Gleb Natapov
  2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 01/14] Introduce fw_name field to DeviceInfo structure Gleb Natapov
  2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 02/14] Introduce new BusInfo callback get_fw_dev_path Gleb Natapov
@ 2010-11-10 17:14 ` Gleb Natapov
  2010-11-11 10:14   ` [Qemu-devel] " Gerd Hoffmann
  2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 04/14] Add get_fw_dev_path callback to ISA bus " Gleb Natapov
                   ` (12 subsequent siblings)
  15 siblings, 1 reply; 42+ messages in thread
From: Gleb Natapov @ 2010-11-10 17:14 UTC (permalink / raw)
  To: qemu-devel; +Cc: blauwirbel, alex.williamson, armbru, kvm, mst

Store all io ports used by device in ISADevice structure.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
 hw/cs4231a.c     |    1 +
 hw/fdc.c         |    3 +++
 hw/gus.c         |    4 ++++
 hw/ide/isa.c     |    2 ++
 hw/isa-bus.c     |   25 +++++++++++++++++++++++++
 hw/isa.h         |    4 ++++
 hw/m48t59.c      |    1 +
 hw/mc146818rtc.c |    1 +
 hw/ne2000-isa.c  |    3 +++
 hw/parallel.c    |    5 +++++
 hw/pckbd.c       |    3 +++
 hw/sb16.c        |    4 ++++
 hw/serial.c      |    1 +
 13 files changed, 57 insertions(+), 0 deletions(-)

diff --git a/hw/cs4231a.c b/hw/cs4231a.c
index 4d5ce5c..598f032 100644
--- a/hw/cs4231a.c
+++ b/hw/cs4231a.c
@@ -645,6 +645,7 @@ static int cs4231a_initfn (ISADevice *dev)
     isa_init_irq (dev, &s->pic, s->irq);
 
     for (i = 0; i < 4; i++) {
+        isa_init_ioport(dev, i);
         register_ioport_write (s->port + i, 1, 1, cs_write, s);
         register_ioport_read (s->port + i, 1, 1, cs_read, s);
     }
diff --git a/hw/fdc.c b/hw/fdc.c
index a467c4b..5ab754b 100644
--- a/hw/fdc.c
+++ b/hw/fdc.c
@@ -1983,6 +1983,9 @@ static int isabus_fdc_init1(ISADevice *dev)
                           &fdctrl_write_port, fdctrl);
     register_ioport_write(iobase + 0x07, 1, 1,
                           &fdctrl_write_port, fdctrl);
+    isa_init_ioport_range(dev, iobase + 1, 5);
+    isa_init_ioport(dev, iobase + 7);
+
     isa_init_irq(&isa->busdev, &fdctrl->irq, isairq);
     fdctrl->dma_chann = dma_chann;
 
diff --git a/hw/gus.c b/hw/gus.c
index e9016d8..ff9e7c7 100644
--- a/hw/gus.c
+++ b/hw/gus.c
@@ -264,20 +264,24 @@ static int gus_initfn (ISADevice *dev)
 
     register_ioport_write (s->port, 1, 1, gus_writeb, s);
     register_ioport_write (s->port, 1, 2, gus_writew, s);
+    isa_init_ioport_range(dev, s->port, 2);
 
     register_ioport_read ((s->port + 0x100) & 0xf00, 1, 1, gus_readb, s);
     register_ioport_read ((s->port + 0x100) & 0xf00, 1, 2, gus_readw, s);
+    isa_init_ioport_range(dev, (s->port + 0x100) & 0xf00, 2);
 
     register_ioport_write (s->port + 6, 10, 1, gus_writeb, s);
     register_ioport_write (s->port + 6, 10, 2, gus_writew, s);
     register_ioport_read (s->port + 6, 10, 1, gus_readb, s);
     register_ioport_read (s->port + 6, 10, 2, gus_readw, s);
+    isa_init_ioport_range(dev, s->port + 6, 10);
 
 
     register_ioport_write (s->port + 0x100, 8, 1, gus_writeb, s);
     register_ioport_write (s->port + 0x100, 8, 2, gus_writew, s);
     register_ioport_read (s->port + 0x100, 8, 1, gus_readb, s);
     register_ioport_read (s->port + 0x100, 8, 2, gus_readw, s);
+    isa_init_ioport_range(dev, s->port + 0x100, 8);
 
     DMA_register_channel (s->emu.gusdma, GUS_read_DMA, s);
     s->emu.himemaddr = s->himem;
diff --git a/hw/ide/isa.c b/hw/ide/isa.c
index 9856435..4206afd 100644
--- a/hw/ide/isa.c
+++ b/hw/ide/isa.c
@@ -70,6 +70,8 @@ static int isa_ide_initfn(ISADevice *dev)
     ide_bus_new(&s->bus, &s->dev.qdev);
     ide_init_ioport(&s->bus, s->iobase, s->iobase2);
     isa_init_irq(dev, &s->irq, s->isairq);
+    isa_init_ioport_range(dev, s->iobase, 8);
+    isa_init_ioport(dev, s->iobase2);
     ide_init2(&s->bus, s->irq);
     vmstate_register(&dev->qdev, 0, &vmstate_ide_isa, s);
     return 0;
diff --git a/hw/isa-bus.c b/hw/isa-bus.c
index 26036e0..c0ac7e9 100644
--- a/hw/isa-bus.c
+++ b/hw/isa-bus.c
@@ -92,6 +92,31 @@ void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq)
     dev->nirqs++;
 }
 
+static void isa_init_ioport_one(ISADevice *dev, uint16_t ioport)
+{
+    assert(dev->nioports < ARRAY_SIZE(dev->ioports));
+    dev->ioports[dev->nioports++] = ioport;
+}
+
+static int isa_cmp_ports(const void *p1, const void *p2)
+{
+    return *(uint16_t*)p1 - *(uint16_t*)p2;
+}
+
+void isa_init_ioport_range(ISADevice *dev, uint16_t start, uint16_t length)
+{
+    int i;
+    for (i = start; i < start + length; i++) {
+        isa_init_ioport_one(dev, i);
+    }
+    qsort(dev->ioports, dev->nioports, sizeof(dev->ioports[0]), isa_cmp_ports);
+}
+
+void isa_init_ioport(ISADevice *dev, uint16_t ioport)
+{
+    isa_init_ioport_range(dev, ioport, 1);
+}
+
 static int isa_qdev_init(DeviceState *qdev, DeviceInfo *base)
 {
     ISADevice *dev = DO_UPCAST(ISADevice, qdev, qdev);
diff --git a/hw/isa.h b/hw/isa.h
index aaf0272..4794b76 100644
--- a/hw/isa.h
+++ b/hw/isa.h
@@ -14,6 +14,8 @@ struct ISADevice {
     DeviceState qdev;
     uint32_t isairq[2];
     int nirqs;
+    uint16_t ioports[32];
+    int nioports;
 };
 
 typedef int (*isa_qdev_initfn)(ISADevice *dev);
@@ -26,6 +28,8 @@ ISABus *isa_bus_new(DeviceState *dev);
 void isa_bus_irqs(qemu_irq *irqs);
 qemu_irq isa_reserve_irq(int isairq);
 void isa_init_irq(ISADevice *dev, qemu_irq *p, int isairq);
+void isa_init_ioport(ISADevice *dev, uint16_t ioport);
+void isa_init_ioport_range(ISADevice *dev, uint16_t start, uint16_t length);
 void isa_qdev_register(ISADeviceInfo *info);
 ISADevice *isa_create(const char *name);
 ISADevice *isa_create_simple(const char *name);
diff --git a/hw/m48t59.c b/hw/m48t59.c
index c7492a6..75a94e1 100644
--- a/hw/m48t59.c
+++ b/hw/m48t59.c
@@ -680,6 +680,7 @@ M48t59State *m48t59_init_isa(uint32_t io_base, uint16_t size, int type)
     if (io_base != 0) {
         register_ioport_read(io_base, 0x04, 1, NVRAM_readb, s);
         register_ioport_write(io_base, 0x04, 1, NVRAM_writeb, s);
+        isa_init_ioport_range(dev, io_base, 4);
     }
 
     return s;
diff --git a/hw/mc146818rtc.c b/hw/mc146818rtc.c
index 2b91fa8..6466aff 100644
--- a/hw/mc146818rtc.c
+++ b/hw/mc146818rtc.c
@@ -605,6 +605,7 @@ static int rtc_initfn(ISADevice *dev)
 
     register_ioport_write(base, 2, 1, cmos_ioport_write, s);
     register_ioport_read(base, 2, 1, cmos_ioport_read, s);
+    isa_init_ioport_range(dev, base, 2);
 
     qdev_set_legacy_instance_id(&dev->qdev, base, 2);
     qemu_register_reset(rtc_reset, s);
diff --git a/hw/ne2000-isa.c b/hw/ne2000-isa.c
index 03a5a1f..3ff0d89 100644
--- a/hw/ne2000-isa.c
+++ b/hw/ne2000-isa.c
@@ -68,14 +68,17 @@ static int isa_ne2000_initfn(ISADevice *dev)
 
     register_ioport_write(isa->iobase, 16, 1, ne2000_ioport_write, s);
     register_ioport_read(isa->iobase, 16, 1, ne2000_ioport_read, s);
+    isa_init_ioport_range(dev, isa->iobase, 16);
 
     register_ioport_write(isa->iobase + 0x10, 1, 1, ne2000_asic_ioport_write, s);
     register_ioport_read(isa->iobase + 0x10, 1, 1, ne2000_asic_ioport_read, s);
     register_ioport_write(isa->iobase + 0x10, 2, 2, ne2000_asic_ioport_write, s);
     register_ioport_read(isa->iobase + 0x10, 2, 2, ne2000_asic_ioport_read, s);
+    isa_init_ioport_range(dev, isa->iobase + 0x10, 2);
 
     register_ioport_write(isa->iobase + 0x1f, 1, 1, ne2000_reset_ioport_write, s);
     register_ioport_read(isa->iobase + 0x1f, 1, 1, ne2000_reset_ioport_read, s);
+    isa_init_ioport(dev, isa->iobase + 0x1f);
 
     isa_init_irq(dev, &s->irq, isa->isairq);
 
diff --git a/hw/parallel.c b/hw/parallel.c
index 6b11672..6270b53 100644
--- a/hw/parallel.c
+++ b/hw/parallel.c
@@ -481,16 +481,21 @@ static int parallel_isa_initfn(ISADevice *dev)
     if (s->hw_driver) {
         register_ioport_write(base, 8, 1, parallel_ioport_write_hw, s);
         register_ioport_read(base, 8, 1, parallel_ioport_read_hw, s);
+        isa_init_ioport_range(dev, base, 8);
+
         register_ioport_write(base+4, 1, 2, parallel_ioport_eppdata_write_hw2, s);
         register_ioport_read(base+4, 1, 2, parallel_ioport_eppdata_read_hw2, s);
         register_ioport_write(base+4, 1, 4, parallel_ioport_eppdata_write_hw4, s);
         register_ioport_read(base+4, 1, 4, parallel_ioport_eppdata_read_hw4, s);
+        isa_init_ioport(dev, base+4);
         register_ioport_write(base+0x400, 8, 1, parallel_ioport_ecp_write, s);
         register_ioport_read(base+0x400, 8, 1, parallel_ioport_ecp_read, s);
+        isa_init_ioport_range(dev, base+0x400, 8);
     }
     else {
         register_ioport_write(base, 8, 1, parallel_ioport_write_sw, s);
         register_ioport_read(base, 8, 1, parallel_ioport_read_sw, s);
+        isa_init_ioport_range(dev, base, 8);
     }
     return 0;
 }
diff --git a/hw/pckbd.c b/hw/pckbd.c
index 6e4e406..e736505 100644
--- a/hw/pckbd.c
+++ b/hw/pckbd.c
@@ -484,10 +484,13 @@ static int i8042_initfn(ISADevice *dev)
 
     register_ioport_read(0x60, 1, 1, kbd_read_data, s);
     register_ioport_write(0x60, 1, 1, kbd_write_data, s);
+    isa_init_ioport(dev, 0x60);
     register_ioport_read(0x64, 1, 1, kbd_read_status, s);
     register_ioport_write(0x64, 1, 1, kbd_write_command, s);
+    isa_init_ioport(dev, 0x64);
     register_ioport_read(0x92, 1, 1, ioport92_read, s);
     register_ioport_write(0x92, 1, 1, ioport92_write, s);
+    isa_init_ioport(dev, 0x92);
 
     s->kbd = ps2_kbd_init(kbd_update_kbd_irq, s);
     s->mouse = ps2_mouse_init(kbd_update_aux_irq, s);
diff --git a/hw/sb16.c b/hw/sb16.c
index 78590a7..c9d37ad 100644
--- a/hw/sb16.c
+++ b/hw/sb16.c
@@ -1368,16 +1368,20 @@ static int sb16_initfn (ISADevice *dev)
 
     for (i = 0; i < ARRAY_SIZE (dsp_write_ports); i++) {
         register_ioport_write (s->port + dsp_write_ports[i], 1, 1, dsp_write, s);
+        isa_init_ioport(dev, s->port + dsp_write_ports[i]);
     }
 
     for (i = 0; i < ARRAY_SIZE (dsp_read_ports); i++) {
         register_ioport_read (s->port + dsp_read_ports[i], 1, 1, dsp_read, s);
+        isa_init_ioport(dev, s->port + dsp_read_ports[i]);
     }
 
     register_ioport_write (s->port + 0x4, 1, 1, mixer_write_indexb, s);
     register_ioport_write (s->port + 0x4, 1, 2, mixer_write_indexw, s);
+    isa_init_ioport(dev, s->port + 0x4);
     register_ioport_read (s->port + 0x5, 1, 1, mixer_read, s);
     register_ioport_write (s->port + 0x5, 1, 1, mixer_write_datab, s);
+    isa_init_ioport(dev, s->port + 0x5);
 
     DMA_register_channel (s->hdma, SB_read_DMA, s);
     DMA_register_channel (s->dma, SB_read_DMA, s);
diff --git a/hw/serial.c b/hw/serial.c
index 9ebc452..20902ae 100644
--- a/hw/serial.c
+++ b/hw/serial.c
@@ -778,6 +778,7 @@ static int serial_isa_initfn(ISADevice *dev)
 
     register_ioport_write(isa->iobase, 8, 1, serial_ioport_write, s);
     register_ioport_read(isa->iobase, 8, 1, serial_ioport_read, s);
+    isa_init_ioport_range(dev, isa->iobase, 8);
     return 0;
 }
 
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCHv3 04/14] Add get_fw_dev_path callback to ISA bus in qdev.
  2010-11-10 17:14 [Qemu-devel] [PATCHv3 00/14] boot order specification Gleb Natapov
                   ` (2 preceding siblings ...)
  2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 03/14] Keep track of ISA ports ISA device is using in qdev Gleb Natapov
@ 2010-11-10 17:14 ` Gleb Natapov
  2010-11-10 18:34   ` [Qemu-devel] " Blue Swirl
  2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 05/14] Store IDE bus id in IDEBus structure for easy access Gleb Natapov
                   ` (11 subsequent siblings)
  15 siblings, 1 reply; 42+ messages in thread
From: Gleb Natapov @ 2010-11-10 17:14 UTC (permalink / raw)
  To: qemu-devel; +Cc: blauwirbel, alex.williamson, armbru, kvm, mst

Use device ioports to create unique device path.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
 hw/isa-bus.c |   15 +++++++++++++++
 1 files changed, 15 insertions(+), 0 deletions(-)

diff --git a/hw/isa-bus.c b/hw/isa-bus.c
index c0ac7e9..741d28e 100644
--- a/hw/isa-bus.c
+++ b/hw/isa-bus.c
@@ -31,11 +31,13 @@ static ISABus *isabus;
 target_phys_addr_t isa_mem_base = 0;
 
 static void isabus_dev_print(Monitor *mon, DeviceState *dev, int indent);
+static char *isabus_get_fw_dev_path(DeviceState *dev);
 
 static struct BusInfo isa_bus_info = {
     .name      = "ISA",
     .size      = sizeof(ISABus),
     .print_dev = isabus_dev_print,
+    .get_fw_dev_path = isabus_get_fw_dev_path,
 };
 
 ISABus *isa_bus_new(DeviceState *dev)
@@ -188,4 +190,17 @@ static void isabus_register_devices(void)
     sysbus_register_withprop(&isabus_bridge_info);
 }
 
+static char *isabus_get_fw_dev_path(DeviceState *dev)
+{
+    ISADevice *d = (ISADevice*)dev;
+    char path[40];
+    int off;
+
+    off = snprintf(path, sizeof(path), "%s", qdev_fw_name(dev));
+    if (d->nioports)
+        snprintf(path + off, sizeof(path) - off, "@%04x", d->ioports[0]);
+
+    return strdup(path);
+}
+
 device_init(isabus_register_devices)
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCHv3 05/14] Store IDE bus id in IDEBus structure for easy access.
  2010-11-10 17:14 [Qemu-devel] [PATCHv3 00/14] boot order specification Gleb Natapov
                   ` (3 preceding siblings ...)
  2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 04/14] Add get_fw_dev_path callback to ISA bus " Gleb Natapov
@ 2010-11-10 17:14 ` Gleb Natapov
  2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 06/14] Add get_fw_dev_path callback to IDE bus Gleb Natapov
                   ` (10 subsequent siblings)
  15 siblings, 0 replies; 42+ messages in thread
From: Gleb Natapov @ 2010-11-10 17:14 UTC (permalink / raw)
  To: qemu-devel; +Cc: blauwirbel, alex.williamson, armbru, kvm, mst


Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
 hw/ide/cmd646.c   |    4 ++--
 hw/ide/internal.h |    3 ++-
 hw/ide/isa.c      |    2 +-
 hw/ide/piix.c     |    4 ++--
 hw/ide/qdev.c     |    3 ++-
 hw/ide/via.c      |    4 ++--
 6 files changed, 11 insertions(+), 9 deletions(-)

diff --git a/hw/ide/cmd646.c b/hw/ide/cmd646.c
index ff80dd5..b2cbdbc 100644
--- a/hw/ide/cmd646.c
+++ b/hw/ide/cmd646.c
@@ -257,8 +257,8 @@ static int pci_cmd646_ide_initfn(PCIDevice *dev)
     pci_conf[PCI_INTERRUPT_PIN] = 0x01; // interrupt on pin 1
 
     irq = qemu_allocate_irqs(cmd646_set_irq, d, 2);
-    ide_bus_new(&d->bus[0], &d->dev.qdev);
-    ide_bus_new(&d->bus[1], &d->dev.qdev);
+    ide_bus_new(&d->bus[0], &d->dev.qdev, 0);
+    ide_bus_new(&d->bus[1], &d->dev.qdev, 1);
     ide_init2(&d->bus[0], irq[0]);
     ide_init2(&d->bus[1], irq[1]);
 
diff --git a/hw/ide/internal.h b/hw/ide/internal.h
index d652e06..c0a1abc 100644
--- a/hw/ide/internal.h
+++ b/hw/ide/internal.h
@@ -448,6 +448,7 @@ struct IDEBus {
     IDEDevice *slave;
     BMDMAState *bmdma;
     IDEState ifs[2];
+    int bus_id;
     uint8_t unit;
     uint8_t cmd;
     qemu_irq irq;
@@ -565,7 +566,7 @@ void ide_init2_with_non_qdev_drives(IDEBus *bus, DriveInfo *hd0,
 void ide_init_ioport(IDEBus *bus, int iobase, int iobase2);
 
 /* hw/ide/qdev.c */
-void ide_bus_new(IDEBus *idebus, DeviceState *dev);
+void ide_bus_new(IDEBus *idebus, DeviceState *dev, int bus_id);
 IDEDevice *ide_create_drive(IDEBus *bus, int unit, DriveInfo *drive);
 
 #endif /* HW_IDE_INTERNAL_H */
diff --git a/hw/ide/isa.c b/hw/ide/isa.c
index 4206afd..8c59c5a 100644
--- a/hw/ide/isa.c
+++ b/hw/ide/isa.c
@@ -67,7 +67,7 @@ static int isa_ide_initfn(ISADevice *dev)
 {
     ISAIDEState *s = DO_UPCAST(ISAIDEState, dev, dev);
 
-    ide_bus_new(&s->bus, &s->dev.qdev);
+    ide_bus_new(&s->bus, &s->dev.qdev, 0);
     ide_init_ioport(&s->bus, s->iobase, s->iobase2);
     isa_init_irq(dev, &s->irq, s->isairq);
     isa_init_ioport_range(dev, s->iobase, 8);
diff --git a/hw/ide/piix.c b/hw/ide/piix.c
index 07483e8..d0b04a3 100644
--- a/hw/ide/piix.c
+++ b/hw/ide/piix.c
@@ -129,8 +129,8 @@ static int pci_piix_ide_initfn(PCIIDEState *d)
 
     vmstate_register(&d->dev.qdev, 0, &vmstate_ide_pci, d);
 
-    ide_bus_new(&d->bus[0], &d->dev.qdev);
-    ide_bus_new(&d->bus[1], &d->dev.qdev);
+    ide_bus_new(&d->bus[0], &d->dev.qdev, 0);
+    ide_bus_new(&d->bus[1], &d->dev.qdev, 1);
     ide_init_ioport(&d->bus[0], 0x1f0, 0x3f6);
     ide_init_ioport(&d->bus[1], 0x170, 0x376);
 
diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
index 6d27b60..88ff657 100644
--- a/hw/ide/qdev.c
+++ b/hw/ide/qdev.c
@@ -29,9 +29,10 @@ static struct BusInfo ide_bus_info = {
     .size  = sizeof(IDEBus),
 };
 
-void ide_bus_new(IDEBus *idebus, DeviceState *dev)
+void ide_bus_new(IDEBus *idebus, DeviceState *dev, int bus_id)
 {
     qbus_create_inplace(&idebus->qbus, &ide_bus_info, dev, NULL);
+    idebus->bus_id = bus_id;
 }
 
 static int ide_qdev_init(DeviceState *qdev, DeviceInfo *base)
diff --git a/hw/ide/via.c b/hw/ide/via.c
index b2c7cad..cc48b2b 100644
--- a/hw/ide/via.c
+++ b/hw/ide/via.c
@@ -158,8 +158,8 @@ static int vt82c686b_ide_initfn(PCIDevice *dev)
 
     vmstate_register(&dev->qdev, 0, &vmstate_ide_pci, d);
 
-    ide_bus_new(&d->bus[0], &d->dev.qdev);
-    ide_bus_new(&d->bus[1], &d->dev.qdev);
+    ide_bus_new(&d->bus[0], &d->dev.qdev, 0);
+    ide_bus_new(&d->bus[1], &d->dev.qdev, 1);
     ide_init2(&d->bus[0], isa_reserve_irq(14));
     ide_init2(&d->bus[1], isa_reserve_irq(15));
     ide_init_ioport(&d->bus[0], 0x1f0, 0x3f6);
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCHv3 06/14] Add get_fw_dev_path callback to IDE bus.
  2010-11-10 17:14 [Qemu-devel] [PATCHv3 00/14] boot order specification Gleb Natapov
                   ` (4 preceding siblings ...)
  2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 05/14] Store IDE bus id in IDEBus structure for easy access Gleb Natapov
@ 2010-11-10 17:14 ` Gleb Natapov
  2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 07/14] Add get_dev_path callback for system bus Gleb Natapov
                   ` (9 subsequent siblings)
  15 siblings, 0 replies; 42+ messages in thread
From: Gleb Natapov @ 2010-11-10 17:14 UTC (permalink / raw)
  To: qemu-devel; +Cc: blauwirbel, alex.williamson, armbru, kvm, mst


Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
 hw/ide/qdev.c |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)

diff --git a/hw/ide/qdev.c b/hw/ide/qdev.c
index 88ff657..01a181b 100644
--- a/hw/ide/qdev.c
+++ b/hw/ide/qdev.c
@@ -24,9 +24,12 @@
 
 /* --------------------------------- */
 
+static char *idebus_get_fw_dev_path(DeviceState *dev);
+
 static struct BusInfo ide_bus_info = {
     .name  = "IDE",
     .size  = sizeof(IDEBus),
+    .get_fw_dev_path = idebus_get_fw_dev_path,
 };
 
 void ide_bus_new(IDEBus *idebus, DeviceState *dev, int bus_id)
@@ -35,6 +38,16 @@ void ide_bus_new(IDEBus *idebus, DeviceState *dev, int bus_id)
     idebus->bus_id = bus_id;
 }
 
+static char *idebus_get_fw_dev_path(DeviceState *dev)
+{
+    char path[30];
+
+    snprintf(path, sizeof(path), "%s@%d", qdev_fw_name(dev),
+             ((IDEBus*)dev->parent_bus)->bus_id);
+
+    return strdup(path);
+}
+
 static int ide_qdev_init(DeviceState *qdev, DeviceInfo *base)
 {
     IDEDevice *dev = DO_UPCAST(IDEDevice, qdev, qdev);
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCHv3 07/14] Add get_dev_path callback for system bus.
  2010-11-10 17:14 [Qemu-devel] [PATCHv3 00/14] boot order specification Gleb Natapov
                   ` (5 preceding siblings ...)
  2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 06/14] Add get_fw_dev_path callback to IDE bus Gleb Natapov
@ 2010-11-10 17:14 ` Gleb Natapov
  2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 08/14] Add get_fw_dev_path callback for pci bus Gleb Natapov
                   ` (8 subsequent siblings)
  15 siblings, 0 replies; 42+ messages in thread
From: Gleb Natapov @ 2010-11-10 17:14 UTC (permalink / raw)
  To: qemu-devel; +Cc: blauwirbel, alex.williamson, armbru, kvm, mst

Prints out mmio or pio used to access child device.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
 hw/pci_host.c |    2 ++
 hw/sysbus.c   |   30 ++++++++++++++++++++++++++++++
 hw/sysbus.h   |    4 ++++
 3 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/hw/pci_host.c b/hw/pci_host.c
index bc5b771..28d45bf 100644
--- a/hw/pci_host.c
+++ b/hw/pci_host.c
@@ -197,6 +197,7 @@ void pci_host_conf_register_ioport(pio_addr_t ioport, PCIHostState *s)
 {
     pci_host_init(s);
     register_ioport_simple(&s->conf_noswap_handler, ioport, 4, 4);
+    sysbus_init_ioports(&s->busdev, ioport, 4);
 }
 
 int pci_host_data_register_mmio(PCIHostState *s, int swap)
@@ -215,4 +216,5 @@ void pci_host_data_register_ioport(pio_addr_t ioport, PCIHostState *s)
     register_ioport_simple(&s->data_noswap_handler, ioport, 4, 1);
     register_ioport_simple(&s->data_noswap_handler, ioport, 4, 2);
     register_ioport_simple(&s->data_noswap_handler, ioport, 4, 4);
+    sysbus_init_ioports(&s->busdev, ioport, 4);
 }
diff --git a/hw/sysbus.c b/hw/sysbus.c
index d817721..1583bd8 100644
--- a/hw/sysbus.c
+++ b/hw/sysbus.c
@@ -22,11 +22,13 @@
 #include "monitor.h"
 
 static void sysbus_dev_print(Monitor *mon, DeviceState *dev, int indent);
+static char *sysbus_get_fw_dev_path(DeviceState *dev);
 
 struct BusInfo system_bus_info = {
     .name       = "System",
     .size       = sizeof(BusState),
     .print_dev  = sysbus_dev_print,
+    .get_fw_dev_path = sysbus_get_fw_dev_path,
 };
 
 void sysbus_connect_irq(SysBusDevice *dev, int n, qemu_irq irq)
@@ -106,6 +108,16 @@ void sysbus_init_mmio_cb(SysBusDevice *dev, target_phys_addr_t size,
     dev->mmio[n].cb = cb;
 }
 
+void sysbus_init_ioports(SysBusDevice *dev, pio_addr_t ioport, pio_addr_t size)
+{
+    pio_addr_t i;
+
+    for (i = 0; i < size; i++) {
+        assert(dev->num_pio < QDEV_MAX_PIO);
+        dev->pio[dev->num_pio++] = ioport++;
+    }
+}
+
 static int sysbus_device_init(DeviceState *dev, DeviceInfo *base)
 {
     SysBusDeviceInfo *info = container_of(base, SysBusDeviceInfo, qdev);
@@ -171,3 +183,21 @@ static void sysbus_dev_print(Monitor *mon, DeviceState *dev, int indent)
                        indent, "", s->mmio[i].addr, s->mmio[i].size);
     }
 }
+
+static char *sysbus_get_fw_dev_path(DeviceState *dev)
+{
+    SysBusDevice *s = sysbus_from_qdev(dev);
+    char path[40];
+    int off;
+
+    off = snprintf(path, sizeof(path), "%s", qdev_fw_name(dev));
+
+    if (s->num_mmio) {
+        snprintf(path + off, sizeof(path) - off, "@"TARGET_FMT_plx,
+                 s->mmio[0].addr);
+    } else if (s->num_pio) {
+        snprintf(path + off, sizeof(path) - off, "@i%04x", s->pio[0]);
+    }
+
+    return strdup(path);
+}
diff --git a/hw/sysbus.h b/hw/sysbus.h
index 5980901..e9eb618 100644
--- a/hw/sysbus.h
+++ b/hw/sysbus.h
@@ -6,6 +6,7 @@
 #include "qdev.h"
 
 #define QDEV_MAX_MMIO 32
+#define QDEV_MAX_PIO 32
 #define QDEV_MAX_IRQ 256
 
 typedef struct SysBusDevice SysBusDevice;
@@ -23,6 +24,8 @@ struct SysBusDevice {
         mmio_mapfunc cb;
         ram_addr_t iofunc;
     } mmio[QDEV_MAX_MMIO];
+    int num_pio;
+    pio_addr_t pio[QDEV_MAX_PIO];
 };
 
 typedef int (*sysbus_initfn)(SysBusDevice *dev);
@@ -45,6 +48,7 @@ void sysbus_init_mmio_cb(SysBusDevice *dev, target_phys_addr_t size,
                             mmio_mapfunc cb);
 void sysbus_init_irq(SysBusDevice *dev, qemu_irq *p);
 void sysbus_pass_irq(SysBusDevice *dev, SysBusDevice *target);
+void sysbus_init_ioports(SysBusDevice *dev, pio_addr_t ioport, pio_addr_t size);
 
 
 void sysbus_connect_irq(SysBusDevice *dev, int n, qemu_irq irq);
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCHv3 08/14] Add get_fw_dev_path callback for pci bus.
  2010-11-10 17:14 [Qemu-devel] [PATCHv3 00/14] boot order specification Gleb Natapov
                   ` (6 preceding siblings ...)
  2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 07/14] Add get_dev_path callback for system bus Gleb Natapov
@ 2010-11-10 17:14 ` Gleb Natapov
  2010-11-10 17:34   ` [Qemu-devel] " Michael S. Tsirkin
  2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 09/14] Record which USBDevice USBPort belongs too Gleb Natapov
                   ` (7 subsequent siblings)
  15 siblings, 1 reply; 42+ messages in thread
From: Gleb Natapov @ 2010-11-10 17:14 UTC (permalink / raw)
  To: qemu-devel; +Cc: blauwirbel, alex.williamson, armbru, kvm, mst


Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
 hw/pci.c |   54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 54 insertions(+), 0 deletions(-)

diff --git a/hw/pci.c b/hw/pci.c
index 92aaa85..ab0399c 100644
--- a/hw/pci.c
+++ b/hw/pci.c
@@ -63,12 +63,14 @@ struct PCIBus {
 
 static void pcibus_dev_print(Monitor *mon, DeviceState *dev, int indent);
 static char *pcibus_get_dev_path(DeviceState *dev);
+static char *pcibus_get_fw_dev_path(DeviceState *dev);
 
 static struct BusInfo pci_bus_info = {
     .name       = "PCI",
     .size       = sizeof(PCIBus),
     .print_dev  = pcibus_dev_print,
     .get_dev_path = pcibus_get_dev_path,
+    .get_fw_dev_path = pcibus_get_fw_dev_path,
     .props      = (Property[]) {
         DEFINE_PROP_PCI_DEVFN("addr", PCIDevice, devfn, -1),
         DEFINE_PROP_STRING("romfile", PCIDevice, romfile),
@@ -2135,6 +2137,58 @@ static void pcibus_dev_print(Monitor *mon, DeviceState *dev, int indent)
     }
 }
 
+static char *pci_dev_fw_name(DeviceState *dev, char *buf, int len)
+{
+    PCIDevice *d = (PCIDevice *)dev;
+    const char *name = NULL;
+
+#define E(R, N) case R: name = N; break;
+
+    /* names taken from pci binding for open firmware */
+    switch (pci_get_word(d->config + PCI_CLASS_DEVICE)) {
+        E(0x0001, "display"); E(0x0100, "scsi"); E(0x0101, "ide");
+        E(0x0102, "fdc"); E(0x0103, "ipi"); E(0x0104, "raid");
+        E(0x0200, "ethernet"); E(0x0201, "token-ring");  E(0x0202, "fddi");
+        E(0x0203, "atm"); E(0x0300 ... 0x03ff, "display"); E(0x0400, "video");
+        E(0x0401, "sound"); E(0x0500, "memory"); E(0x0501, "flash");
+        E(0x0600, "host"); E(0x0601, "isa"); E(0x0602, "eisa");
+        E(0x0603, "mca"); E(0x0604, "pci"); E(0x0605, "pcmcia");
+        E(0x0606, "nubus"); E(0x0607, "cardbus"); E(0x0700, "serial");
+        E(0x0701, "parallel"); E(0x0800, "interrupt-controller");
+        E(0x0801, "dma-controller"); E(0x0802, "timer");
+        E(0x0803, "rtc"); E(0x0900, "keyboard"); E(0x0901, "pen");
+        E(0x0902, "mouse"); E(0x0a00 ... 0x0aff, "dock");
+        E(0x0b00 ... 0x0bff, "cpu"); E(0x0c00, "fireware");
+        E(0x0c01, "access-bus"); E(0x0c02, "ssa"); E(0x0c03, "usb");
+        E(0x0c04, "fibre-channel");
+    }
+#undef E
+
+    if (name) {
+        pstrcpy(buf, len, name);
+    } else {
+        snprintf(buf, len, "pci%04x,%04x",
+                 pci_get_word(d->config + PCI_VENDOR_ID),
+                 pci_get_word(d->config + PCI_DEVICE_ID));
+    }
+
+    return buf;
+}
+
+static char *pcibus_get_fw_dev_path(DeviceState *dev)
+{
+    PCIDevice *d = (PCIDevice *)dev;
+    char path[50], name[33];
+    int off;
+
+    off = snprintf(path, sizeof(path), "%s@%x",
+                   pci_dev_fw_name(dev, name, sizeof name),
+                   PCI_SLOT(d->devfn));
+    if (PCI_FUNC(d->devfn))
+        snprintf(path + off, sizeof(path) + off, ",%x", PCI_FUNC(d->devfn));
+    return strdup(path);
+}
+
 static char *pcibus_get_dev_path(DeviceState *dev)
 {
     PCIDevice *d = (PCIDevice *)dev;
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCHv3 09/14] Record which USBDevice USBPort belongs too.
  2010-11-10 17:14 [Qemu-devel] [PATCHv3 00/14] boot order specification Gleb Natapov
                   ` (7 preceding siblings ...)
  2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 08/14] Add get_fw_dev_path callback for pci bus Gleb Natapov
@ 2010-11-10 17:14 ` Gleb Natapov
  2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 10/14] Add get_dev_path callback for usb bus Gleb Natapov
                   ` (6 subsequent siblings)
  15 siblings, 0 replies; 42+ messages in thread
From: Gleb Natapov @ 2010-11-10 17:14 UTC (permalink / raw)
  To: qemu-devel; +Cc: blauwirbel, alex.williamson, armbru, kvm, mst

Ports on root hub will have NULL here. This is needed to reconstruct
path from device to its root hub to build device path.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
 hw/usb-bus.c  |    3 ++-
 hw/usb-hub.c  |    2 +-
 hw/usb-musb.c |    2 +-
 hw/usb-ohci.c |    2 +-
 hw/usb-uhci.c |    2 +-
 hw/usb.h      |    3 ++-
 6 files changed, 8 insertions(+), 6 deletions(-)

diff --git a/hw/usb-bus.c b/hw/usb-bus.c
index b692503..256b881 100644
--- a/hw/usb-bus.c
+++ b/hw/usb-bus.c
@@ -110,11 +110,12 @@ USBDevice *usb_create_simple(USBBus *bus, const char *name)
 }
 
 void usb_register_port(USBBus *bus, USBPort *port, void *opaque, int index,
-                       usb_attachfn attach)
+                       USBDevice *pdev, usb_attachfn attach)
 {
     port->opaque = opaque;
     port->index = index;
     port->attach = attach;
+    port->pdev = pdev;
     QTAILQ_INSERT_TAIL(&bus->free, port, next);
     bus->nfree++;
 }
diff --git a/hw/usb-hub.c b/hw/usb-hub.c
index 8e3a96b..8a3f829 100644
--- a/hw/usb-hub.c
+++ b/hw/usb-hub.c
@@ -535,7 +535,7 @@ static int usb_hub_initfn(USBDevice *dev)
     for (i = 0; i < s->nb_ports; i++) {
         port = &s->ports[i];
         usb_register_port(usb_bus_from_device(dev),
-                          &port->port, s, i, usb_hub_attach);
+                          &port->port, s, i, &s->dev, usb_hub_attach);
         port->wPortStatus = PORT_STAT_POWER;
         port->wPortChange = 0;
     }
diff --git a/hw/usb-musb.c b/hw/usb-musb.c
index 7f15842..9efe7a6 100644
--- a/hw/usb-musb.c
+++ b/hw/usb-musb.c
@@ -343,7 +343,7 @@ struct MUSBState {
     }
 
     usb_bus_new(&s->bus, NULL /* FIXME */);
-    usb_register_port(&s->bus, &s->port, s, 0, musb_attach);
+    usb_register_port(&s->bus, &s->port, s, 0, NULL, musb_attach);
 
     return s;
 }
diff --git a/hw/usb-ohci.c b/hw/usb-ohci.c
index c60fd8d..59604cf 100644
--- a/hw/usb-ohci.c
+++ b/hw/usb-ohci.c
@@ -1705,7 +1705,7 @@ static void usb_ohci_init(OHCIState *ohci, DeviceState *dev,
     usb_bus_new(&ohci->bus, dev);
     ohci->num_ports = num_ports;
     for (i = 0; i < num_ports; i++) {
-        usb_register_port(&ohci->bus, &ohci->rhport[i].port, ohci, i, ohci_attach);
+        usb_register_port(&ohci->bus, &ohci->rhport[i].port, ohci, i, NULL, ohci_attach);
     }
 
     ohci->async_td = 0;
diff --git a/hw/usb-uhci.c b/hw/usb-uhci.c
index 1d83400..b9b822f 100644
--- a/hw/usb-uhci.c
+++ b/hw/usb-uhci.c
@@ -1115,7 +1115,7 @@ static int usb_uhci_common_initfn(UHCIState *s)
 
     usb_bus_new(&s->bus, &s->dev.qdev);
     for(i = 0; i < NB_PORTS; i++) {
-        usb_register_port(&s->bus, &s->ports[i].port, s, i, uhci_attach);
+        usb_register_port(&s->bus, &s->ports[i].port, s, i, NULL, uhci_attach);
     }
     s->frame_timer = qemu_new_timer(vm_clock, uhci_frame_timer, s);
     s->expire_time = qemu_get_clock(vm_clock) +
diff --git a/hw/usb.h b/hw/usb.h
index 00d2802..0b32d77 100644
--- a/hw/usb.h
+++ b/hw/usb.h
@@ -203,6 +203,7 @@ struct USBPort {
     USBDevice *dev;
     usb_attachfn attach;
     void *opaque;
+    USBDevice *pdev;
     int index; /* internal port index, may be used with the opaque */
     QTAILQ_ENTRY(USBPort) next;
 };
@@ -312,7 +313,7 @@ USBDevice *usb_create(USBBus *bus, const char *name);
 USBDevice *usb_create_simple(USBBus *bus, const char *name);
 USBDevice *usbdevice_create(const char *cmdline);
 void usb_register_port(USBBus *bus, USBPort *port, void *opaque, int index,
-                       usb_attachfn attach);
+                       USBDevice *pdev, usb_attachfn attach);
 void usb_unregister_port(USBBus *bus, USBPort *port);
 int usb_device_attach(USBDevice *dev);
 int usb_device_detach(USBDevice *dev);
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCHv3 10/14] Add get_dev_path callback for usb bus.
  2010-11-10 17:14 [Qemu-devel] [PATCHv3 00/14] boot order specification Gleb Natapov
                   ` (8 preceding siblings ...)
  2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 09/14] Record which USBDevice USBPort belongs too Gleb Natapov
@ 2010-11-10 17:14 ` Gleb Natapov
  2010-11-10 18:37   ` [Qemu-devel] " Blue Swirl
  2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 11/14] Add bootindex parameter to net/block/fd device Gleb Natapov
                   ` (5 subsequent siblings)
  15 siblings, 1 reply; 42+ messages in thread
From: Gleb Natapov @ 2010-11-10 17:14 UTC (permalink / raw)
  To: qemu-devel; +Cc: blauwirbel, alex.williamson, armbru, kvm, mst


Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
 hw/usb-bus.c |   35 +++++++++++++++++++++++++++++++++++
 1 files changed, 35 insertions(+), 0 deletions(-)

diff --git a/hw/usb-bus.c b/hw/usb-bus.c
index 256b881..6292282 100644
--- a/hw/usb-bus.c
+++ b/hw/usb-bus.c
@@ -5,11 +5,13 @@
 #include "monitor.h"
 
 static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent);
+static char *usbbus_get_fw_dev_path(DeviceState *dev);
 
 static struct BusInfo usb_bus_info = {
     .name      = "USB",
     .size      = sizeof(USBBus),
     .print_dev = usb_bus_dev_print,
+    .get_fw_dev_path = usbbus_get_fw_dev_path,
 };
 static int next_usb_bus = 0;
 static QTAILQ_HEAD(, USBBus) busses = QTAILQ_HEAD_INITIALIZER(busses);
@@ -307,3 +309,36 @@ USBDevice *usbdevice_create(const char *cmdline)
     }
     return usb->usbdevice_init(params);
 }
+
+static int usbbus_get_fw_dev_path_helper(USBDevice *d, USBBus *bus, char *p,
+                                         int len)
+{
+    int l = 0;
+    USBPort *port;
+
+    QTAILQ_FOREACH(port, &bus->used, next) {
+        if (port->dev != d)
+            continue;
+
+        if (port->pdev) {
+            l = usbbus_get_fw_dev_path_helper(port->pdev, bus, p, len);
+        }
+        l += snprintf(p + l, len - l, "%s@%x/", qdev_fw_name(&d->qdev),
+                      port->index);
+        return l;
+    }
+    return 0;
+}
+
+static char *usbbus_get_fw_dev_path(DeviceState *dev)
+{
+    USBDevice *d = (USBDevice*)dev;
+    USBBus *bus = usb_bus_from_device(d);
+    char path[100];
+    int l;
+
+    l = usbbus_get_fw_dev_path_helper(d, bus, path, sizeof(path));
+    path[l-1] = '\0';
+
+    return strdup(path);
+}
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCHv3 11/14] Add bootindex parameter to net/block/fd device
  2010-11-10 17:14 [Qemu-devel] [PATCHv3 00/14] boot order specification Gleb Natapov
                   ` (9 preceding siblings ...)
  2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 10/14] Add get_dev_path callback for usb bus Gleb Natapov
@ 2010-11-10 17:14 ` Gleb Natapov
  2010-11-10 18:32   ` [Qemu-devel] " Blue Swirl
  2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 12/14] Add bootindex parameter to pci assigned device Gleb Natapov
                   ` (4 subsequent siblings)
  15 siblings, 1 reply; 42+ messages in thread
From: Gleb Natapov @ 2010-11-10 17:14 UTC (permalink / raw)
  To: qemu-devel; +Cc: blauwirbel, alex.williamson, armbru, kvm, mst

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/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-phy@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-phy@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, "floppy@0");
+    }
+
+    if (isa->bootindexB >= 0) {
+        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 01a181b..dcd49aa 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"
 
 /* --------------------------------- */
 
@@ -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 ? "disk@1" : "disk@0");
+    }
+
     return 0;
 }
 
diff --git a/hw/ne2000.c b/hw/ne2000.c
index 126e7cf..d0a0dc6 100644
--- a/hw/ne2000.c
+++ b/hw/ne2000.c
@@ -26,6 +26,7 @@
 #include "net.h"
 #include "ne2000.h"
 #include "loader.h"
+#include "sysemu.h"
 
 /* debug NE2000 card */
 //#define DEBUG_NE2000
@@ -746,6 +747,11 @@ static int pci_ne2000_init(PCIDevice *pci_dev)
         }
     }
 
+    if (s->c.bootindex >= 0) {
+        add_boot_device_path(s->c.bootindex, &pci_dev->qdev,
+                             "ethernet-phy@0");
+    }
+
     return 0;
 }
 
diff --git a/hw/pcnet.c b/hw/pcnet.c
index b52935a..93595cb 100644
--- a/hw/pcnet.c
+++ b/hw/pcnet.c
@@ -40,6 +40,7 @@
 #include "loader.h"
 #include "qemu-timer.h"
 #include "qemu_socket.h"
+#include "sysemu.h"
 
 #include "pcnet.h"
 
@@ -1898,6 +1899,11 @@ int pcnet_common_init(DeviceState *dev, PCNetState *s, NetClientInfo *info)
     qemu_macaddr_default_if_unset(&s->conf.macaddr);
     s->nic = qemu_new_nic(info, &s->conf, dev->info->name, dev->id, s);
     qemu_format_nic_info_str(&s->nic->nc, s->conf.macaddr.a);
+
+    if (s->conf.bootindex >= 0) {
+        add_boot_device_path(s->conf.bootindex, dev, "ethernet-phy@0");
+    }
+
     return 0;
 }
 
diff --git a/hw/qdev.c b/hw/qdev.c
index 35858cb..cc9bf43 100644
--- a/hw/qdev.c
+++ b/hw/qdev.c
@@ -820,3 +820,35 @@ int do_device_del(Monitor *mon, const QDict *qdict, QObject **ret_data)
     }
     return qdev_unplug(dev);
 }
+
+static int qdev_get_fw_dev_path_helper(DeviceState *dev, char *p, int size)
+{
+    int l = 0;
+
+    if (dev && dev->parent_bus) {
+        char *d;
+        l = qdev_get_fw_dev_path_helper(dev->parent_bus->parent, p, size);
+        if (dev->parent_bus->info->get_fw_dev_path) {
+            d = dev->parent_bus->info->get_fw_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_fw_dev_path(DeviceState *dev)
+{
+    char path[128];
+    int l;
+
+    l = qdev_get_fw_dev_path_helper(dev, path, 128);
+
+    path[l-1] = '\0';
+
+    return strdup(path);
+}
diff --git a/hw/qdev.h b/hw/qdev.h
index dc669b3..13f3597 100644
--- a/hw/qdev.h
+++ b/hw/qdev.h
@@ -296,6 +296,7 @@ static inline const char *qdev_fw_name(DeviceState *dev)
     return dev->info->fw_name ? : dev->info->alias ? : dev->info->name;
 }
 
+char *qdev_get_fw_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/rtl8139.c b/hw/rtl8139.c
index d92981d..56a3621 100644
--- a/hw/rtl8139.c
+++ b/hw/rtl8139.c
@@ -52,6 +52,7 @@
 #include "qemu-timer.h"
 #include "net.h"
 #include "loader.h"
+#include "sysemu.h"
 
 /* debug RTL8139 card */
 //#define DEBUG_RTL8139 1
@@ -3387,6 +3388,12 @@ static int pci_rtl8139_init(PCIDevice *dev)
     s->TimerExpire = 0;
     s->timer = qemu_new_timer(vm_clock, rtl8139_timer, s);
     rtl8139_set_next_tctr_time(s, qemu_get_clock(vm_clock));
+
+    if (s->conf.bootindex >= 0) {
+        add_boot_device_path(s->conf.bootindex, &dev->qdev,
+                             "ethernet-phy@0");
+    }
+
     return 0;
 }
 
diff --git a/hw/usb-net.c b/hw/usb-net.c
index 2287ee1..55d69f0 100644
--- a/hw/usb-net.c
+++ b/hw/usb-net.c
@@ -27,6 +27,7 @@
 #include "usb.h"
 #include "net.h"
 #include "qemu-queue.h"
+#include "sysemu.h"
 
 /*#define TRAFFIC_DEBUG*/
 /* Thanks to NetChip Technologies for donating this product ID.
@@ -1463,6 +1464,9 @@ static int usb_net_initfn(USBDevice *dev)
              s->conf.macaddr.a[4],
              s->conf.macaddr.a[5]);
 
+    if (s->conf.bootindex >= 0)
+        add_boot_device_path(s->conf.bootindex, &dev->qdev,
+                             "ethernet@0");
     return 0;
 }
 
diff --git a/hw/virtio-blk.c b/hw/virtio-blk.c
index dbe2070..c8f0843 100644
--- a/hw/virtio-blk.c
+++ b/hw/virtio-blk.c
@@ -548,6 +548,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) {
+        add_boot_device_path(conf->bootindex, dev, "disk@0");
+    }
+
     return &s->vdev;
 }
 
diff --git a/hw/virtio-net.c b/hw/virtio-net.c
index 7e1688c..69d48f4 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) {
+        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..6b85d86 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -193,4 +193,6 @@ void rtc_change_mon_event(struct tm *tm);
 
 void register_devices(void);
 
+void add_boot_device_path(int32_t bootindex, DeviceState *dev,
+                          const char *suffix);
 #endif
diff --git a/vl.c b/vl.c
index 4bad675..8edf27a 100644
--- a/vl.c
+++ b/vl.c
@@ -232,6 +232,17 @@ const char *prom_envs[MAX_PROM_ENVS];
 const char *nvram = NULL;
 int boot_menu;
 
+typedef struct FWBootEntry FWBootEntry;
+
+struct FWBootEntry {
+    QTAILQ_ENTRY(FWBootEntry) link;
+    int32_t bootindex;
+    DeviceState *dev;
+    char *suffix;
+};
+
+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];
@@ -696,6 +707,30 @@ static void restore_boot_devices(void *opaque)
     qemu_free(standard_boot_devices);
 }
 
+void add_boot_device_path(int32_t bootindex, DeviceState *dev,
+                          const char *suffix)
+{
+    FWBootEntry *node = qemu_mallocz(sizeof(FWBootEntry)), *i;
+
+    assert(dev != NULL || suffix != NULL);
+
+    node->bootindex = bootindex;
+    node->suffix = 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);
+}
+
 static void numa_add(const char *optarg)
 {
     char option[128];
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCHv3 12/14] Add bootindex parameter to pci assigned device.
  2010-11-10 17:14 [Qemu-devel] [PATCHv3 00/14] boot order specification Gleb Natapov
                   ` (10 preceding siblings ...)
  2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 11/14] Add bootindex parameter to net/block/fd device Gleb Natapov
@ 2010-11-10 17:14 ` Gleb Natapov
  2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 13/14] Add notifier that will be called when machine is fully created Gleb Natapov
                   ` (3 subsequent siblings)
  15 siblings, 0 replies; 42+ messages in thread
From: Gleb Natapov @ 2010-11-10 17:14 UTC (permalink / raw)
  To: qemu-devel; +Cc: blauwirbel, alex.williamson, armbru, kvm, mst


Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
 hw/device-assignment.c |    7 +++++++
 hw/device-assignment.h |    1 +
 2 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/hw/device-assignment.c b/hw/device-assignment.c
index bde231d..15c2b42 100644
--- a/hw/device-assignment.c
+++ b/hw/device-assignment.c
@@ -39,6 +39,7 @@
 #include "loader.h"
 #include "monitor.h"
 #include <pci/header.h>
+#include "sysemu.h"
 
 /* From linux/ioport.h */
 #define IORESOURCE_IO       0x00000100  /* Resource type */
@@ -1490,6 +1491,11 @@ static int assigned_initfn(struct PCIDevice *pci_dev)
 
     assigned_dev_load_option_rom(dev);
     QLIST_INSERT_HEAD(&devs, dev, next);
+
+    if (dev->bootindex >= 0) {
+        add_boot_device_path(dev->bootindex, &pci_dev->qdev, NULL);
+    }
+
     return 0;
 
 assigned_out:
@@ -1549,6 +1555,7 @@ static PCIDeviceInfo assign_info = {
                         ASSIGNED_DEVICE_USE_IOMMU_BIT, true),
         DEFINE_PROP_BIT("prefer_msi", AssignedDevice, features,
                         ASSIGNED_DEVICE_PREFER_MSI_BIT, true),
+        DEFINE_PROP_INT32("bootindex", AssignedDevice, bootindex, -1),
         DEFINE_PROP_STRING("configfd", AssignedDevice, configfd_name),
         DEFINE_PROP_END_OF_LIST(),
     },
diff --git a/hw/device-assignment.h b/hw/device-assignment.h
index c94a730..86af0a9 100644
--- a/hw/device-assignment.h
+++ b/hw/device-assignment.h
@@ -111,6 +111,7 @@ typedef struct AssignedDevice {
     int mmio_index;
     int need_emulate_cmd;
     char *configfd_name;
+    int32_t bootindex;
     QLIST_ENTRY(AssignedDevice) next;
 } AssignedDevice;
 
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCHv3 13/14] Add notifier that will be called when machine is fully created.
  2010-11-10 17:14 [Qemu-devel] [PATCHv3 00/14] boot order specification Gleb Natapov
                   ` (11 preceding siblings ...)
  2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 12/14] Add bootindex parameter to pci assigned device Gleb Natapov
@ 2010-11-10 17:14 ` Gleb Natapov
  2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 14/14] Pass boot device list to firmware Gleb Natapov
                   ` (2 subsequent siblings)
  15 siblings, 0 replies; 42+ messages in thread
From: Gleb Natapov @ 2010-11-10 17:14 UTC (permalink / raw)
  To: qemu-devel; +Cc: blauwirbel, alex.williamson, armbru, kvm, mst

Action that depends on fully initialized device model should register
with this notifier chain.

Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
 sysemu.h |    2 ++
 vl.c     |   15 +++++++++++++++
 2 files changed, 17 insertions(+), 0 deletions(-)

diff --git a/sysemu.h b/sysemu.h
index 6b85d86..46a588c 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -61,6 +61,8 @@ void qemu_system_reset(void);
 void qemu_add_exit_notifier(Notifier *notify);
 void qemu_remove_exit_notifier(Notifier *notify);
 
+void qemu_add_machine_init_done_notifier(Notifier *notify);
+
 void do_savevm(Monitor *mon, const QDict *qdict);
 int load_vmstate(const char *name);
 void do_delvm(Monitor *mon, const QDict *qdict);
diff --git a/vl.c b/vl.c
index 8edf27a..00ab2b4 100644
--- a/vl.c
+++ b/vl.c
@@ -257,6 +257,9 @@ static void *boot_set_opaque;
 static NotifierList exit_notifiers =
     NOTIFIER_LIST_INITIALIZER(exit_notifiers);
 
+static NotifierList machine_init_done_notifiers =
+    NOTIFIER_LIST_INITIALIZER(machine_init_done_notifiers);
+
 int kvm_allowed = 1;
 uint32_t xen_domid;
 enum xen_mode xen_mode = XEN_EMULATE;
@@ -1800,6 +1803,16 @@ static void qemu_run_exit_notifiers(void)
     notifier_list_notify(&exit_notifiers);
 }
 
+void qemu_add_machine_init_done_notifier(Notifier *notify)
+{
+    notifier_list_add(&machine_init_done_notifiers, notify);
+}
+
+static void qemu_run_machine_init_done_notifiers(void)
+{
+    notifier_list_notify(&machine_init_done_notifiers);
+}
+
 static const QEMUOption *lookup_opt(int argc, char **argv,
                                     const char **poptarg, int *poptind)
 {
@@ -3091,6 +3104,8 @@ int main(int argc, char **argv, char **envp)
         exit(1);
     }
 
+    qemu_run_machine_init_done_notifiers();
+
     qemu_system_reset();
     if (loadvm) {
         if (load_vmstate(loadvm) < 0) {
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] [PATCHv3 14/14] Pass boot device list to firmware.
  2010-11-10 17:14 [Qemu-devel] [PATCHv3 00/14] boot order specification Gleb Natapov
                   ` (12 preceding siblings ...)
  2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 13/14] Add notifier that will be called when machine is fully created Gleb Natapov
@ 2010-11-10 17:14 ` Gleb Natapov
  2010-11-10 18:50   ` [Qemu-devel] " Blue Swirl
  2010-11-10 19:11   ` Blue Swirl
  2010-11-10 18:08 ` [Qemu-devel] Re: [PATCHv3 00/14] boot order specification Blue Swirl
  2010-11-11 10:21 ` Gerd Hoffmann
  15 siblings, 2 replies; 42+ messages in thread
From: Gleb Natapov @ 2010-11-10 17:14 UTC (permalink / raw)
  To: qemu-devel; +Cc: blauwirbel, alex.williamson, armbru, kvm, mst


Signed-off-by: Gleb Natapov <gleb@redhat.com>
---
 hw/fw_cfg.h |    1 +
 hw/pc.c     |   19 +++++++++++++++++++
 sysemu.h    |    1 +
 vl.c        |   40 ++++++++++++++++++++++++++++++++++++++++
 4 files changed, 61 insertions(+), 0 deletions(-)

diff --git a/hw/fw_cfg.h b/hw/fw_cfg.h
index 4d13a4f..bfbf1f9 100644
--- a/hw/fw_cfg.h
+++ b/hw/fw_cfg.h
@@ -31,6 +31,7 @@
 #define FW_CFG_FILE_FIRST       0x20
 #define FW_CFG_FILE_SLOTS       0x10
 #define FW_CFG_MAX_ENTRY        (FW_CFG_FILE_FIRST+FW_CFG_FILE_SLOTS)
+#define FW_CFG_BOOTINDEX        (FW_CFG_MAX_ENTRY + 1)
 
 #define FW_CFG_WRITE_CHANNEL    0x4000
 #define FW_CFG_ARCH_LOCAL       0x8000
diff --git a/hw/pc.c b/hw/pc.c
index 3bf3862..e51f8ba 100644
--- a/hw/pc.c
+++ b/hw/pc.c
@@ -883,6 +883,21 @@ void pc_cpus_init(const char *cpu_model)
     }
 }
 
+static struct machine_ready_notify {
+    Notifier n;
+    void *fw_cfg;
+} machine_ready;
+
+
+static void pc_fw_register_bootindex(struct Notifier* n)
+{
+    uint32_t len;
+    char *bootindex = get_boot_devices_list(&len);
+
+    fw_cfg_add_bytes(machine_ready.fw_cfg, FW_CFG_BOOTINDEX,
+                     (uint8_t*)bootindex, len);
+}
+
 void pc_memory_init(ram_addr_t ram_size,
                     const char *kernel_filename,
                     const char *kernel_cmdline,
@@ -982,6 +997,10 @@ void pc_memory_init(ram_addr_t ram_size,
     for (i = 0; i < nb_option_roms; i++) {
         rom_add_option(option_rom[i]);
     }
+
+    machine_ready.n.notify = pc_fw_register_bootindex;
+    machine_ready.fw_cfg = fw_cfg;
+    qemu_add_machine_init_done_notifier(&machine_ready.n);
 }
 
 qemu_irq *pc_allocate_cpu_irq(void)
diff --git a/sysemu.h b/sysemu.h
index 46a588c..bac2df1 100644
--- a/sysemu.h
+++ b/sysemu.h
@@ -197,4 +197,5 @@ void register_devices(void);
 
 void add_boot_device_path(int32_t bootindex, DeviceState *dev,
                           const char *suffix);
+char *get_boot_devices_list(uint32_t *size);
 #endif
diff --git a/vl.c b/vl.c
index 00ab2b4..4b1a406 100644
--- a/vl.c
+++ b/vl.c
@@ -734,6 +734,46 @@ void add_boot_device_path(int32_t bootindex, DeviceState *dev,
     QTAILQ_INSERT_TAIL(&fw_boot_order, node, link);
 }
 
+char *get_boot_devices_list(uint32_t *size)
+{
+    FWBootEntry *i;
+    uint32_t total = 1, c = 0;
+    char *list = qemu_malloc(1);
+
+    QTAILQ_FOREACH(i, &fw_boot_order, link) {
+        char *devpath = NULL, *bootpath;
+        int len;
+
+        if (i->dev) {
+            devpath = qdev_get_fw_dev_path(i->dev);
+            assert(devpath);
+        }
+
+        if (i->suffix && devpath) {
+            bootpath = qemu_malloc(strlen(devpath) + strlen(i->suffix) + 2);
+            sprintf(bootpath, "%s/%s", devpath, i->suffix);
+            qemu_free(devpath);
+        } else if (devpath) {
+            bootpath = devpath;
+        } else {
+            bootpath = strdup(i->suffix);
+        }
+
+        len = strlen(bootpath);
+        list = qemu_realloc(list, total + len + 1);
+        list[total++] = len;
+        memcpy(&list[total], bootpath, len);
+        total += len;
+        c++;
+        qemu_free(bootpath);
+    }
+
+    list[0] = c;
+    *size = total;
+
+    return list;
+}
+
 static void numa_add(const char *optarg)
 {
     char option[128];
-- 
1.7.1

^ permalink raw reply related	[flat|nested] 42+ messages in thread

* [Qemu-devel] Re: [PATCHv3 08/14] Add get_fw_dev_path callback for pci bus.
  2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 08/14] Add get_fw_dev_path callback for pci bus Gleb Natapov
@ 2010-11-10 17:34   ` Michael S. Tsirkin
  2010-11-10 18:02     ` Gleb Natapov
  2010-11-11 10:07     ` Gerd Hoffmann
  0 siblings, 2 replies; 42+ messages in thread
From: Michael S. Tsirkin @ 2010-11-10 17:34 UTC (permalink / raw)
  To: Gleb Natapov; +Cc: blauwirbel, alex.williamson, qemu-devel, kvm, armbru

On Wed, Nov 10, 2010 at 07:14:15PM +0200, Gleb Natapov wrote:
> 
> Signed-off-by: Gleb Natapov <gleb@redhat.com>

Good stuff. We should also consider using this for
CLI and monitor. Some comments below.

> ---
>  hw/pci.c |   54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>  1 files changed, 54 insertions(+), 0 deletions(-)
> 
> diff --git a/hw/pci.c b/hw/pci.c
> index 92aaa85..ab0399c 100644
> --- a/hw/pci.c
> +++ b/hw/pci.c
> @@ -63,12 +63,14 @@ struct PCIBus {
>  
>  static void pcibus_dev_print(Monitor *mon, DeviceState *dev, int indent);
>  static char *pcibus_get_dev_path(DeviceState *dev);
> +static char *pcibus_get_fw_dev_path(DeviceState *dev);
>  
>  static struct BusInfo pci_bus_info = {
>      .name       = "PCI",
>      .size       = sizeof(PCIBus),
>      .print_dev  = pcibus_dev_print,
>      .get_dev_path = pcibus_get_dev_path,
> +    .get_fw_dev_path = pcibus_get_fw_dev_path,
>      .props      = (Property[]) {
>          DEFINE_PROP_PCI_DEVFN("addr", PCIDevice, devfn, -1),
>          DEFINE_PROP_STRING("romfile", PCIDevice, romfile),
> @@ -2135,6 +2137,58 @@ static void pcibus_dev_print(Monitor *mon, DeviceState *dev, int indent)
>      }
>  }
>  
> +static char *pci_dev_fw_name(DeviceState *dev, char *buf, int len)
> +{
> +    PCIDevice *d = (PCIDevice *)dev;
> +    const char *name = NULL;
> +
> +#define E(R, N) case R: name = N; break;

Straight from underhanded C contest :).
Does this macro really buy us all that much?
Split this switch to an inline function, we'll get
	case 0x0600:  return "host";
and then we won't need the macro.

> +
> +    /* names taken from pci binding for open firmware */
> +    switch (pci_get_word(d->config + PCI_CLASS_DEVICE)) {
> +        E(0x0001, "display"); E(0x0100, "scsi"); E(0x0101, "ide");
> +        E(0x0102, "fdc"); E(0x0103, "ipi"); E(0x0104, "raid");
> +        E(0x0200, "ethernet"); E(0x0201, "token-ring");  E(0x0202, "fddi");
> +        E(0x0203, "atm"); E(0x0300 ... 0x03ff, "display"); E(0x0400, "video");
> +        E(0x0401, "sound"); E(0x0500, "memory"); E(0x0501, "flash");
> +        E(0x0600, "host"); E(0x0601, "isa"); E(0x0602, "eisa");
> +        E(0x0603, "mca"); E(0x0604, "pci"); E(0x0605, "pcmcia");
> +        E(0x0606, "nubus"); E(0x0607, "cardbus"); E(0x0700, "serial");
> +        E(0x0701, "parallel"); E(0x0800, "interrupt-controller");
> +        E(0x0801, "dma-controller"); E(0x0802, "timer");
> +        E(0x0803, "rtc"); E(0x0900, "keyboard"); E(0x0901, "pen");
> +        E(0x0902, "mouse"); E(0x0a00 ... 0x0aff, "dock");
> +        E(0x0b00 ... 0x0bff, "cpu"); E(0x0c00, "fireware");
> +        E(0x0c01, "access-bus"); E(0x0c02, "ssa"); E(0x0c03, "usb");
> +        E(0x0c04, "fibre-channel");

Please use constants from
hw/pci_ids.h


> +    }
> +#undef E
> +
> +    if (name) {
> +        pstrcpy(buf, len, name);
> +    } else {
> +        snprintf(buf, len, "pci%04x,%04x",
> +                 pci_get_word(d->config + PCI_VENDOR_ID),
> +                 pci_get_word(d->config + PCI_DEVICE_ID));
> +    }
> +
> +    return buf;
> +}
> +
> +static char *pcibus_get_fw_dev_path(DeviceState *dev)
> +{
> +    PCIDevice *d = (PCIDevice *)dev;
> +    char path[50], name[33];
> +    int off;
> +
> +    off = snprintf(path, sizeof(path), "%s@%x",
> +                   pci_dev_fw_name(dev, name, sizeof name),
> +                   PCI_SLOT(d->devfn));
> +    if (PCI_FUNC(d->devfn))
> +        snprintf(path + off, sizeof(path) + off, ",%x", PCI_FUNC(d->devfn));
> +    return strdup(path);
> +}
> +
>  static char *pcibus_get_dev_path(DeviceState *dev)
>  {
>      PCIDevice *d = (PCIDevice *)dev;
> -- 
> 1.7.1

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Qemu-devel] Re: [PATCHv3 08/14] Add get_fw_dev_path callback for pci bus.
  2010-11-10 17:34   ` [Qemu-devel] " Michael S. Tsirkin
@ 2010-11-10 18:02     ` Gleb Natapov
  2010-11-10 18:21       ` Michael S. Tsirkin
  2010-11-11 10:07     ` Gerd Hoffmann
  1 sibling, 1 reply; 42+ messages in thread
From: Gleb Natapov @ 2010-11-10 18:02 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: blauwirbel, alex.williamson, qemu-devel, kvm, armbru

On Wed, Nov 10, 2010 at 07:34:12PM +0200, Michael S. Tsirkin wrote:
> On Wed, Nov 10, 2010 at 07:14:15PM +0200, Gleb Natapov wrote:
> > 
> > Signed-off-by: Gleb Natapov <gleb@redhat.com>
> 
> Good stuff. We should also consider using this for
> CLI and monitor. Some comments below.
> 
> > ---
> >  hw/pci.c |   54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
> >  1 files changed, 54 insertions(+), 0 deletions(-)
> > 
> > diff --git a/hw/pci.c b/hw/pci.c
> > index 92aaa85..ab0399c 100644
> > --- a/hw/pci.c
> > +++ b/hw/pci.c
> > @@ -63,12 +63,14 @@ struct PCIBus {
> >  
> >  static void pcibus_dev_print(Monitor *mon, DeviceState *dev, int indent);
> >  static char *pcibus_get_dev_path(DeviceState *dev);
> > +static char *pcibus_get_fw_dev_path(DeviceState *dev);
> >  
> >  static struct BusInfo pci_bus_info = {
> >      .name       = "PCI",
> >      .size       = sizeof(PCIBus),
> >      .print_dev  = pcibus_dev_print,
> >      .get_dev_path = pcibus_get_dev_path,
> > +    .get_fw_dev_path = pcibus_get_fw_dev_path,
> >      .props      = (Property[]) {
> >          DEFINE_PROP_PCI_DEVFN("addr", PCIDevice, devfn, -1),
> >          DEFINE_PROP_STRING("romfile", PCIDevice, romfile),
> > @@ -2135,6 +2137,58 @@ static void pcibus_dev_print(Monitor *mon, DeviceState *dev, int indent)
> >      }
> >  }
> >  
> > +static char *pci_dev_fw_name(DeviceState *dev, char *buf, int len)
> > +{
> > +    PCIDevice *d = (PCIDevice *)dev;
> > +    const char *name = NULL;
> > +
> > +#define E(R, N) case R: name = N; break;
> 
> Straight from underhanded C contest :).
> Does this macro really buy us all that much?
Easy typing.

> Split this switch to an inline function, we'll get
> 	case 0x0600:  return "host";
> and then we won't need the macro.
> 
> > +
> > +    /* names taken from pci binding for open firmware */
> > +    switch (pci_get_word(d->config + PCI_CLASS_DEVICE)) {
> > +        E(0x0001, "display"); E(0x0100, "scsi"); E(0x0101, "ide");
> > +        E(0x0102, "fdc"); E(0x0103, "ipi"); E(0x0104, "raid");
> > +        E(0x0200, "ethernet"); E(0x0201, "token-ring");  E(0x0202, "fddi");
> > +        E(0x0203, "atm"); E(0x0300 ... 0x03ff, "display"); E(0x0400, "video");
> > +        E(0x0401, "sound"); E(0x0500, "memory"); E(0x0501, "flash");
> > +        E(0x0600, "host"); E(0x0601, "isa"); E(0x0602, "eisa");
> > +        E(0x0603, "mca"); E(0x0604, "pci"); E(0x0605, "pcmcia");
> > +        E(0x0606, "nubus"); E(0x0607, "cardbus"); E(0x0700, "serial");
> > +        E(0x0701, "parallel"); E(0x0800, "interrupt-controller");
> > +        E(0x0801, "dma-controller"); E(0x0802, "timer");
> > +        E(0x0803, "rtc"); E(0x0900, "keyboard"); E(0x0901, "pen");
> > +        E(0x0902, "mouse"); E(0x0a00 ... 0x0aff, "dock");
> > +        E(0x0b00 ... 0x0bff, "cpu"); E(0x0c00, "fireware");
> > +        E(0x0c01, "access-bus"); E(0x0c02, "ssa"); E(0x0c03, "usb");
> > +        E(0x0c04, "fibre-channel");
> 
> Please use constants from
> hw/pci_ids.h
OK. But this will make macro even more handy :) Are all classes defined there? 

> 
> 
> > +    }
> > +#undef E
> > +
> > +    if (name) {
> > +        pstrcpy(buf, len, name);
> > +    } else {
> > +        snprintf(buf, len, "pci%04x,%04x",
> > +                 pci_get_word(d->config + PCI_VENDOR_ID),
> > +                 pci_get_word(d->config + PCI_DEVICE_ID));
> > +    }
> > +
> > +    return buf;
> > +}
> > +
> > +static char *pcibus_get_fw_dev_path(DeviceState *dev)
> > +{
> > +    PCIDevice *d = (PCIDevice *)dev;
> > +    char path[50], name[33];
> > +    int off;
> > +
> > +    off = snprintf(path, sizeof(path), "%s@%x",
> > +                   pci_dev_fw_name(dev, name, sizeof name),
> > +                   PCI_SLOT(d->devfn));
> > +    if (PCI_FUNC(d->devfn))
> > +        snprintf(path + off, sizeof(path) + off, ",%x", PCI_FUNC(d->devfn));
> > +    return strdup(path);
> > +}
> > +
> >  static char *pcibus_get_dev_path(DeviceState *dev)
> >  {
> >      PCIDevice *d = (PCIDevice *)dev;
> > -- 
> > 1.7.1

--
			Gleb.

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Qemu-devel] Re: [PATCHv3 00/14] boot order specification
  2010-11-10 17:14 [Qemu-devel] [PATCHv3 00/14] boot order specification Gleb Natapov
                   ` (13 preceding siblings ...)
  2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 14/14] Pass boot device list to firmware Gleb Natapov
@ 2010-11-10 18:08 ` Blue Swirl
  2010-11-10 18:19   ` Gleb Natapov
  2010-11-11 10:21 ` Gerd Hoffmann
  15 siblings, 1 reply; 42+ messages in thread
From: Blue Swirl @ 2010-11-10 18:08 UTC (permalink / raw)
  To: Gleb Natapov; +Cc: alex.williamson, mst, qemu-devel, kvm, armbru

On Wed, Nov 10, 2010 at 5:14 PM, Gleb Natapov <gleb@redhat.com> wrote:
> This is current sate of the patch series for people to comment on.
> I am using open firmware naming scheme to specify device path names.
>
> Names look like this on pci machine:
> /pci@i0cf8/ide@1,1/drive@1/disk@0
> /pci@i0cf8/isa@1/fdc@03f1/floppy@1
> /pci@i0cf8/isa@1/fdc@03f1/floppy@0
> /pci@i0cf8/ide@1,1/drive@1/disk@1
> /pci@i0cf8/ide@1,1/drive@0/disk@0
> /pci@i0cf8/scsi@3/disk@0
> /pci@i0cf8/ethernet@4/ethernet-phy@0
> /pci@i0cf8/ethernet@5/ethernet-phy@0
> /pci@i0cf8/ide@1,1/drive@0/disk@1
> /pci@i0cf8/isa@1/ide@01e8/drive@0/disk@0
> /pci@i0cf8/usb@1,2/network@0/ethernet@0
> /pci@i0cf8/usb@1,2/hub@1/network@0/ethernet@0
>
> and on isa machine:
> /isa/ide@0170/drive@0/disk@0
> /isa/fdc@03f1/floppy@1
> /isa/fdc@03f1/floppy@0
> /isa/ide@0170/drive@0/disk@1
>
>
> Instead of using get_dev_path() callback I introduces another one
> get_fw_dev_path. Unfortunately the way get_dev_path() callback is used
> in migration code makes it hard to reuse it for other purposes. First
> of all it is not called recursively so caller expects it to provide
> unique name by itself. Device path though is inherently recursive. Each
> individual element may not be unique, but the whole path will be. On
> the other hand to call get_dev_path() recursively in migration code we
> should implement it for all possible buses first. Other problem is
> compatibility. If we change get_dev_path() output format now we will not
> be able to migrate from old qemu to new one without some additional
> compatibility layer.
>
> Gleb Natapov (14):
>  Introduce fw_name field to DeviceInfo structure.
>  Introduce new BusInfo callback get_fw_dev_path.
>  Keep track of ISA ports ISA device is using in qdev.
>  Add get_fw_dev_path callback to ISA bus in qdev.
>  Store IDE bus id in IDEBus structure for easy access.
>  Add get_fw_dev_path callback to IDE bus.
>  Add get_dev_path callback for system bus.
>  Add get_fw_dev_path callback for pci bus.
>  Record which USBDevice USBPort belongs too.
>  Add get_dev_path callback for usb bus.
>  Add bootindex parameter to net/block/fd device
>  Add bootindex parameter to pci assigned device.
>  Add notifier that will be called when machine is fully created.
>  Pass boot device list to firmware.

Nice, but the patches don't apply, for example
hw/device-assingment.[ch] do not exist.

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Qemu-devel] Re: [PATCHv3 00/14] boot order specification
  2010-11-10 18:08 ` [Qemu-devel] Re: [PATCHv3 00/14] boot order specification Blue Swirl
@ 2010-11-10 18:19   ` Gleb Natapov
  0 siblings, 0 replies; 42+ messages in thread
From: Gleb Natapov @ 2010-11-10 18:19 UTC (permalink / raw)
  To: Blue Swirl; +Cc: alex.williamson, mst, qemu-devel, kvm, armbru

On Wed, Nov 10, 2010 at 06:08:56PM +0000, Blue Swirl wrote:
> On Wed, Nov 10, 2010 at 5:14 PM, Gleb Natapov <gleb@redhat.com> wrote:
> > This is current sate of the patch series for people to comment on.
> > I am using open firmware naming scheme to specify device path names.
> >
> > Names look like this on pci machine:
> > /pci@i0cf8/ide@1,1/drive@1/disk@0
> > /pci@i0cf8/isa@1/fdc@03f1/floppy@1
> > /pci@i0cf8/isa@1/fdc@03f1/floppy@0
> > /pci@i0cf8/ide@1,1/drive@1/disk@1
> > /pci@i0cf8/ide@1,1/drive@0/disk@0
> > /pci@i0cf8/scsi@3/disk@0
> > /pci@i0cf8/ethernet@4/ethernet-phy@0
> > /pci@i0cf8/ethernet@5/ethernet-phy@0
> > /pci@i0cf8/ide@1,1/drive@0/disk@1
> > /pci@i0cf8/isa@1/ide@01e8/drive@0/disk@0
> > /pci@i0cf8/usb@1,2/network@0/ethernet@0
> > /pci@i0cf8/usb@1,2/hub@1/network@0/ethernet@0
> >
> > and on isa machine:
> > /isa/ide@0170/drive@0/disk@0
> > /isa/fdc@03f1/floppy@1
> > /isa/fdc@03f1/floppy@0
> > /isa/ide@0170/drive@0/disk@1
> >
> >
> > Instead of using get_dev_path() callback I introduces another one
> > get_fw_dev_path. Unfortunately the way get_dev_path() callback is used
> > in migration code makes it hard to reuse it for other purposes. First
> > of all it is not called recursively so caller expects it to provide
> > unique name by itself. Device path though is inherently recursive. Each
> > individual element may not be unique, but the whole path will be. On
> > the other hand to call get_dev_path() recursively in migration code we
> > should implement it for all possible buses first. Other problem is
> > compatibility. If we change get_dev_path() output format now we will not
> > be able to migrate from old qemu to new one without some additional
> > compatibility layer.
> >
> > Gleb Natapov (14):
> >  Introduce fw_name field to DeviceInfo structure.
> >  Introduce new BusInfo callback get_fw_dev_path.
> >  Keep track of ISA ports ISA device is using in qdev.
> >  Add get_fw_dev_path callback to ISA bus in qdev.
> >  Store IDE bus id in IDEBus structure for easy access.
> >  Add get_fw_dev_path callback to IDE bus.
> >  Add get_dev_path callback for system bus.
> >  Add get_fw_dev_path callback for pci bus.
> >  Record which USBDevice USBPort belongs too.
> >  Add get_dev_path callback for usb bus.
> >  Add bootindex parameter to net/block/fd device
> >  Add bootindex parameter to pci assigned device.
> >  Add notifier that will be called when machine is fully created.
> >  Pass boot device list to firmware.
> 
> Nice, but the patches don't apply, for example
> hw/device-assingment.[ch] do not exist.
Device assignment one is for qemu-kvm. That is why I
made it separate and didn't fold into patch 11. Just drop it.

--
			Gleb.

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Qemu-devel] Re: [PATCHv3 08/14] Add get_fw_dev_path callback for pci bus.
  2010-11-10 18:02     ` Gleb Natapov
@ 2010-11-10 18:21       ` Michael S. Tsirkin
  2010-11-10 18:25         ` Blue Swirl
  2010-11-10 18:33         ` Gleb Natapov
  0 siblings, 2 replies; 42+ messages in thread
From: Michael S. Tsirkin @ 2010-11-10 18:21 UTC (permalink / raw)
  To: Gleb Natapov; +Cc: blauwirbel, alex.williamson, qemu-devel, kvm, armbru

On Wed, Nov 10, 2010 at 08:02:12PM +0200, Gleb Natapov wrote:
> On Wed, Nov 10, 2010 at 07:34:12PM +0200, Michael S. Tsirkin wrote:
> > On Wed, Nov 10, 2010 at 07:14:15PM +0200, Gleb Natapov wrote:
> > > 
> > > Signed-off-by: Gleb Natapov <gleb@redhat.com>
> > 
> > Good stuff. We should also consider using this for
> > CLI and monitor. Some comments below.
> > 
> > > ---
> > >  hw/pci.c |   54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
> > >  1 files changed, 54 insertions(+), 0 deletions(-)
> > > 
> > > diff --git a/hw/pci.c b/hw/pci.c
> > > index 92aaa85..ab0399c 100644
> > > --- a/hw/pci.c
> > > +++ b/hw/pci.c
> > > @@ -63,12 +63,14 @@ struct PCIBus {
> > >  
> > >  static void pcibus_dev_print(Monitor *mon, DeviceState *dev, int indent);
> > >  static char *pcibus_get_dev_path(DeviceState *dev);
> > > +static char *pcibus_get_fw_dev_path(DeviceState *dev);
> > >  
> > >  static struct BusInfo pci_bus_info = {
> > >      .name       = "PCI",
> > >      .size       = sizeof(PCIBus),
> > >      .print_dev  = pcibus_dev_print,
> > >      .get_dev_path = pcibus_get_dev_path,
> > > +    .get_fw_dev_path = pcibus_get_fw_dev_path,
> > >      .props      = (Property[]) {
> > >          DEFINE_PROP_PCI_DEVFN("addr", PCIDevice, devfn, -1),
> > >          DEFINE_PROP_STRING("romfile", PCIDevice, romfile),
> > > @@ -2135,6 +2137,58 @@ static void pcibus_dev_print(Monitor *mon, DeviceState *dev, int indent)
> > >      }
> > >  }
> > >  
> > > +static char *pci_dev_fw_name(DeviceState *dev, char *buf, int len)
> > > +{
> > > +    PCIDevice *d = (PCIDevice *)dev;
> > > +    const char *name = NULL;
> > > +
> > > +#define E(R, N) case R: name = N; break;
> > 
> > Straight from underhanded C contest :).
> > Does this macro really buy us all that much?
> Easy typing.

I am serious about underhanded C. Macros like this one are their tool
of choice.

> > Split this switch to an inline function, we'll get
> > 	case 0x0600:  return "host";
> > and then we won't need the macro.
> > 
> > > +
> > > +    /* names taken from pci binding for open firmware */
> > > +    switch (pci_get_word(d->config + PCI_CLASS_DEVICE)) {
> > > +        E(0x0001, "display"); E(0x0100, "scsi"); E(0x0101, "ide");
> > > +        E(0x0102, "fdc"); E(0x0103, "ipi"); E(0x0104, "raid");
> > > +        E(0x0200, "ethernet"); E(0x0201, "token-ring");  E(0x0202, "fddi");
> > > +        E(0x0203, "atm"); E(0x0300 ... 0x03ff, "display"); E(0x0400, "video");
> > > +        E(0x0401, "sound"); E(0x0500, "memory"); E(0x0501, "flash");
> > > +        E(0x0600, "host"); E(0x0601, "isa"); E(0x0602, "eisa");
> > > +        E(0x0603, "mca"); E(0x0604, "pci"); E(0x0605, "pcmcia");
> > > +        E(0x0606, "nubus"); E(0x0607, "cardbus"); E(0x0700, "serial");
> > > +        E(0x0701, "parallel"); E(0x0800, "interrupt-controller");
> > > +        E(0x0801, "dma-controller"); E(0x0802, "timer");
> > > +        E(0x0803, "rtc"); E(0x0900, "keyboard"); E(0x0901, "pen");
> > > +        E(0x0902, "mouse"); E(0x0a00 ... 0x0aff, "dock");
> > > +        E(0x0b00 ... 0x0bff, "cpu"); E(0x0c00, "fireware");
> > > +        E(0x0c01, "access-bus"); E(0x0c02, "ssa"); E(0x0c03, "usb");
> > > +        E(0x0c04, "fibre-channel");
> > 
> > Please use constants from
> > hw/pci_ids.h
> OK. But this will make macro even more handy :) Are all classes defined there? 

Not in qemu, but the linux pci_ids has them all I think.
So just add stuff from there to qemu.

> > 
> > 
> > > +    }
> > > +#undef E
> > > +
> > > +    if (name) {
> > > +        pstrcpy(buf, len, name);
> > > +    } else {
> > > +        snprintf(buf, len, "pci%04x,%04x",
> > > +                 pci_get_word(d->config + PCI_VENDOR_ID),
> > > +                 pci_get_word(d->config + PCI_DEVICE_ID));
> > > +    }
> > > +
> > > +    return buf;
> > > +}
> > > +
> > > +static char *pcibus_get_fw_dev_path(DeviceState *dev)
> > > +{
> > > +    PCIDevice *d = (PCIDevice *)dev;
> > > +    char path[50], name[33];
> > > +    int off;
> > > +
> > > +    off = snprintf(path, sizeof(path), "%s@%x",
> > > +                   pci_dev_fw_name(dev, name, sizeof name),
> > > +                   PCI_SLOT(d->devfn));
> > > +    if (PCI_FUNC(d->devfn))
> > > +        snprintf(path + off, sizeof(path) + off, ",%x", PCI_FUNC(d->devfn));
> > > +    return strdup(path);
> > > +}
> > > +
> > >  static char *pcibus_get_dev_path(DeviceState *dev)
> > >  {
> > >      PCIDevice *d = (PCIDevice *)dev;
> > > -- 
> > > 1.7.1
> 
> --
> 			Gleb.

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Qemu-devel] Re: [PATCHv3 08/14] Add get_fw_dev_path callback for pci bus.
  2010-11-10 18:21       ` Michael S. Tsirkin
@ 2010-11-10 18:25         ` Blue Swirl
  2010-11-10 18:33         ` Gleb Natapov
  1 sibling, 0 replies; 42+ messages in thread
From: Blue Swirl @ 2010-11-10 18:25 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: armbru, alex.williamson, qemu-devel, Gleb Natapov, kvm

On Wed, Nov 10, 2010 at 6:21 PM, Michael S. Tsirkin <mst@redhat.com> wrote:
> On Wed, Nov 10, 2010 at 08:02:12PM +0200, Gleb Natapov wrote:
>> On Wed, Nov 10, 2010 at 07:34:12PM +0200, Michael S. Tsirkin wrote:
>> > On Wed, Nov 10, 2010 at 07:14:15PM +0200, Gleb Natapov wrote:
>> > >
>> > > Signed-off-by: Gleb Natapov <gleb@redhat.com>
>> >
>> > Good stuff. We should also consider using this for
>> > CLI and monitor. Some comments below.
>> >
>> > > ---
>> > >  hw/pci.c |   54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
>> > >  1 files changed, 54 insertions(+), 0 deletions(-)
>> > >
>> > > diff --git a/hw/pci.c b/hw/pci.c
>> > > index 92aaa85..ab0399c 100644
>> > > --- a/hw/pci.c
>> > > +++ b/hw/pci.c
>> > > @@ -63,12 +63,14 @@ struct PCIBus {
>> > >
>> > >  static void pcibus_dev_print(Monitor *mon, DeviceState *dev, int indent);
>> > >  static char *pcibus_get_dev_path(DeviceState *dev);
>> > > +static char *pcibus_get_fw_dev_path(DeviceState *dev);
>> > >
>> > >  static struct BusInfo pci_bus_info = {
>> > >      .name       = "PCI",
>> > >      .size       = sizeof(PCIBus),
>> > >      .print_dev  = pcibus_dev_print,
>> > >      .get_dev_path = pcibus_get_dev_path,
>> > > +    .get_fw_dev_path = pcibus_get_fw_dev_path,
>> > >      .props      = (Property[]) {
>> > >          DEFINE_PROP_PCI_DEVFN("addr", PCIDevice, devfn, -1),
>> > >          DEFINE_PROP_STRING("romfile", PCIDevice, romfile),
>> > > @@ -2135,6 +2137,58 @@ static void pcibus_dev_print(Monitor *mon, DeviceState *dev, int indent)
>> > >      }
>> > >  }
>> > >
>> > > +static char *pci_dev_fw_name(DeviceState *dev, char *buf, int len)
>> > > +{
>> > > +    PCIDevice *d = (PCIDevice *)dev;
>> > > +    const char *name = NULL;
>> > > +
>> > > +#define E(R, N) case R: name = N; break;
>> >
>> > Straight from underhanded C contest :).
>> > Does this macro really buy us all that much?
>> Easy typing.
>
> I am serious about underhanded C. Macros like this one are their tool
> of choice.
>
>> > Split this switch to an inline function, we'll get
>> >     case 0x0600:  return "host";
>> > and then we won't need the macro.
>> >
>> > > +
>> > > +    /* names taken from pci binding for open firmware */
>> > > +    switch (pci_get_word(d->config + PCI_CLASS_DEVICE)) {
>> > > +        E(0x0001, "display"); E(0x0100, "scsi"); E(0x0101, "ide");
>> > > +        E(0x0102, "fdc"); E(0x0103, "ipi"); E(0x0104, "raid");
>> > > +        E(0x0200, "ethernet"); E(0x0201, "token-ring");  E(0x0202, "fddi");
>> > > +        E(0x0203, "atm"); E(0x0300 ... 0x03ff, "display"); E(0x0400, "video");
>> > > +        E(0x0401, "sound"); E(0x0500, "memory"); E(0x0501, "flash");
>> > > +        E(0x0600, "host"); E(0x0601, "isa"); E(0x0602, "eisa");
>> > > +        E(0x0603, "mca"); E(0x0604, "pci"); E(0x0605, "pcmcia");
>> > > +        E(0x0606, "nubus"); E(0x0607, "cardbus"); E(0x0700, "serial");
>> > > +        E(0x0701, "parallel"); E(0x0800, "interrupt-controller");
>> > > +        E(0x0801, "dma-controller"); E(0x0802, "timer");
>> > > +        E(0x0803, "rtc"); E(0x0900, "keyboard"); E(0x0901, "pen");
>> > > +        E(0x0902, "mouse"); E(0x0a00 ... 0x0aff, "dock");
>> > > +        E(0x0b00 ... 0x0bff, "cpu"); E(0x0c00, "fireware");
>> > > +        E(0x0c01, "access-bus"); E(0x0c02, "ssa"); E(0x0c03, "usb");
>> > > +        E(0x0c04, "fibre-channel");
>> >
>> > Please use constants from
>> > hw/pci_ids.h
>> OK. But this will make macro even more handy :) Are all classes defined there?
>
> Not in qemu, but the linux pci_ids has them all I think.
> So just add stuff from there to qemu.

The PCI database in OpenBIOS may also be handy:
http://tracker.coreboot.org/trac/openbios/browser/trunk/openbios-devel/drivers/pci_database.c

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Qemu-devel] Re: [PATCHv3 11/14] Add bootindex parameter to net/block/fd device
  2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 11/14] Add bootindex parameter to net/block/fd device Gleb Natapov
@ 2010-11-10 18:32   ` Blue Swirl
  2010-11-10 18:48     ` Gleb Natapov
  0 siblings, 1 reply; 42+ messages in thread
From: Blue Swirl @ 2010-11-10 18:32 UTC (permalink / raw)
  To: Gleb Natapov; +Cc: alex.williamson, mst, qemu-devel, kvm, armbru

On Wed, Nov 10, 2010 at 5:14 PM, Gleb Natapov <gleb@redhat.com> 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 <gleb@redhat.com>
> ---
>  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.

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Qemu-devel] Re: [PATCHv3 08/14] Add get_fw_dev_path callback for pci bus.
  2010-11-10 18:21       ` Michael S. Tsirkin
  2010-11-10 18:25         ` Blue Swirl
@ 2010-11-10 18:33         ` Gleb Natapov
  1 sibling, 0 replies; 42+ messages in thread
From: Gleb Natapov @ 2010-11-10 18:33 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: blauwirbel, alex.williamson, qemu-devel, kvm, armbru

On Wed, Nov 10, 2010 at 08:21:55PM +0200, Michael S. Tsirkin wrote:
> On Wed, Nov 10, 2010 at 08:02:12PM +0200, Gleb Natapov wrote:
> > On Wed, Nov 10, 2010 at 07:34:12PM +0200, Michael S. Tsirkin wrote:
> > > On Wed, Nov 10, 2010 at 07:14:15PM +0200, Gleb Natapov wrote:
> > > > 
> > > > Signed-off-by: Gleb Natapov <gleb@redhat.com>
> > > 
> > > Good stuff. We should also consider using this for
> > > CLI and monitor. Some comments below.
> > > 
> > > > ---
> > > >  hw/pci.c |   54 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
> > > >  1 files changed, 54 insertions(+), 0 deletions(-)
> > > > 
> > > > diff --git a/hw/pci.c b/hw/pci.c
> > > > index 92aaa85..ab0399c 100644
> > > > --- a/hw/pci.c
> > > > +++ b/hw/pci.c
> > > > @@ -63,12 +63,14 @@ struct PCIBus {
> > > >  
> > > >  static void pcibus_dev_print(Monitor *mon, DeviceState *dev, int indent);
> > > >  static char *pcibus_get_dev_path(DeviceState *dev);
> > > > +static char *pcibus_get_fw_dev_path(DeviceState *dev);
> > > >  
> > > >  static struct BusInfo pci_bus_info = {
> > > >      .name       = "PCI",
> > > >      .size       = sizeof(PCIBus),
> > > >      .print_dev  = pcibus_dev_print,
> > > >      .get_dev_path = pcibus_get_dev_path,
> > > > +    .get_fw_dev_path = pcibus_get_fw_dev_path,
> > > >      .props      = (Property[]) {
> > > >          DEFINE_PROP_PCI_DEVFN("addr", PCIDevice, devfn, -1),
> > > >          DEFINE_PROP_STRING("romfile", PCIDevice, romfile),
> > > > @@ -2135,6 +2137,58 @@ static void pcibus_dev_print(Monitor *mon, DeviceState *dev, int indent)
> > > >      }
> > > >  }
> > > >  
> > > > +static char *pci_dev_fw_name(DeviceState *dev, char *buf, int len)
> > > > +{
> > > > +    PCIDevice *d = (PCIDevice *)dev;
> > > > +    const char *name = NULL;
> > > > +
> > > > +#define E(R, N) case R: name = N; break;
> > > 
> > > Straight from underhanded C contest :).
> > > Does this macro really buy us all that much?
> > Easy typing.
> 
> I am serious about underhanded C. Macros like this one are their tool
> of choice.
> 
Oh, come on. It is not even try to obfuscate anything. There are plenty
of places in kernel where we define macro to simplify table creation.
This is not a new trick.

> > > Split this switch to an inline function, we'll get
> > > 	case 0x0600:  return "host";
> > > and then we won't need the macro.
> > > 
> > > > +
> > > > +    /* names taken from pci binding for open firmware */
> > > > +    switch (pci_get_word(d->config + PCI_CLASS_DEVICE)) {
> > > > +        E(0x0001, "display"); E(0x0100, "scsi"); E(0x0101, "ide");
> > > > +        E(0x0102, "fdc"); E(0x0103, "ipi"); E(0x0104, "raid");
> > > > +        E(0x0200, "ethernet"); E(0x0201, "token-ring");  E(0x0202, "fddi");
> > > > +        E(0x0203, "atm"); E(0x0300 ... 0x03ff, "display"); E(0x0400, "video");
> > > > +        E(0x0401, "sound"); E(0x0500, "memory"); E(0x0501, "flash");
> > > > +        E(0x0600, "host"); E(0x0601, "isa"); E(0x0602, "eisa");
> > > > +        E(0x0603, "mca"); E(0x0604, "pci"); E(0x0605, "pcmcia");
> > > > +        E(0x0606, "nubus"); E(0x0607, "cardbus"); E(0x0700, "serial");
> > > > +        E(0x0701, "parallel"); E(0x0800, "interrupt-controller");
> > > > +        E(0x0801, "dma-controller"); E(0x0802, "timer");
> > > > +        E(0x0803, "rtc"); E(0x0900, "keyboard"); E(0x0901, "pen");
> > > > +        E(0x0902, "mouse"); E(0x0a00 ... 0x0aff, "dock");
> > > > +        E(0x0b00 ... 0x0bff, "cpu"); E(0x0c00, "fireware");
> > > > +        E(0x0c01, "access-bus"); E(0x0c02, "ssa"); E(0x0c03, "usb");
> > > > +        E(0x0c04, "fibre-channel");
> > > 
> > > Please use constants from
> > > hw/pci_ids.h
> > OK. But this will make macro even more handy :) Are all classes defined there? 
> 
> Not in qemu, but the linux pci_ids has them all I think.
> So just add stuff from there to qemu.
> 
OK.

> > > 
> > > 
> > > > +    }
> > > > +#undef E
> > > > +
> > > > +    if (name) {
> > > > +        pstrcpy(buf, len, name);
> > > > +    } else {
> > > > +        snprintf(buf, len, "pci%04x,%04x",
> > > > +                 pci_get_word(d->config + PCI_VENDOR_ID),
> > > > +                 pci_get_word(d->config + PCI_DEVICE_ID));
> > > > +    }
> > > > +
> > > > +    return buf;
> > > > +}
> > > > +
> > > > +static char *pcibus_get_fw_dev_path(DeviceState *dev)
> > > > +{
> > > > +    PCIDevice *d = (PCIDevice *)dev;
> > > > +    char path[50], name[33];
> > > > +    int off;
> > > > +
> > > > +    off = snprintf(path, sizeof(path), "%s@%x",
> > > > +                   pci_dev_fw_name(dev, name, sizeof name),
> > > > +                   PCI_SLOT(d->devfn));
> > > > +    if (PCI_FUNC(d->devfn))
> > > > +        snprintf(path + off, sizeof(path) + off, ",%x", PCI_FUNC(d->devfn));
> > > > +    return strdup(path);
> > > > +}
> > > > +
> > > >  static char *pcibus_get_dev_path(DeviceState *dev)
> > > >  {
> > > >      PCIDevice *d = (PCIDevice *)dev;
> > > > -- 
> > > > 1.7.1
> > 
> > --
> > 			Gleb.

--
			Gleb.

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Qemu-devel] Re: [PATCHv3 04/14] Add get_fw_dev_path callback to ISA bus in qdev.
  2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 04/14] Add get_fw_dev_path callback to ISA bus " Gleb Natapov
@ 2010-11-10 18:34   ` Blue Swirl
  0 siblings, 0 replies; 42+ messages in thread
From: Blue Swirl @ 2010-11-10 18:34 UTC (permalink / raw)
  To: Gleb Natapov; +Cc: alex.williamson, mst, qemu-devel, kvm, armbru

On Wed, Nov 10, 2010 at 5:14 PM, Gleb Natapov <gleb@redhat.com> wrote:
> Use device ioports to create unique device path.
>
> Signed-off-by: Gleb Natapov <gleb@redhat.com>
> ---
>  hw/isa-bus.c |   15 +++++++++++++++
>  1 files changed, 15 insertions(+), 0 deletions(-)
>
> diff --git a/hw/isa-bus.c b/hw/isa-bus.c
> index c0ac7e9..741d28e 100644
> --- a/hw/isa-bus.c
> +++ b/hw/isa-bus.c
> @@ -31,11 +31,13 @@ static ISABus *isabus;
>  target_phys_addr_t isa_mem_base = 0;
>
>  static void isabus_dev_print(Monitor *mon, DeviceState *dev, int indent);
> +static char *isabus_get_fw_dev_path(DeviceState *dev);
>
>  static struct BusInfo isa_bus_info = {
>     .name      = "ISA",
>     .size      = sizeof(ISABus),
>     .print_dev = isabus_dev_print,
> +    .get_fw_dev_path = isabus_get_fw_dev_path,
>  };
>
>  ISABus *isa_bus_new(DeviceState *dev)
> @@ -188,4 +190,17 @@ static void isabus_register_devices(void)
>     sysbus_register_withprop(&isabus_bridge_info);
>  }
>
> +static char *isabus_get_fw_dev_path(DeviceState *dev)
> +{
> +    ISADevice *d = (ISADevice*)dev;
> +    char path[40];
> +    int off;
> +
> +    off = snprintf(path, sizeof(path), "%s", qdev_fw_name(dev));
> +    if (d->nioports)

Braces.

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Qemu-devel] Re: [PATCHv3 10/14] Add get_dev_path callback for usb bus.
  2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 10/14] Add get_dev_path callback for usb bus Gleb Natapov
@ 2010-11-10 18:37   ` Blue Swirl
  2010-11-10 19:11     ` Gleb Natapov
  0 siblings, 1 reply; 42+ messages in thread
From: Blue Swirl @ 2010-11-10 18:37 UTC (permalink / raw)
  To: Gleb Natapov; +Cc: alex.williamson, mst, qemu-devel, kvm, armbru

On Wed, Nov 10, 2010 at 5:14 PM, Gleb Natapov <gleb@redhat.com> wrote:
>
> Signed-off-by: Gleb Natapov <gleb@redhat.com>
> ---
>  hw/usb-bus.c |   35 +++++++++++++++++++++++++++++++++++
>  1 files changed, 35 insertions(+), 0 deletions(-)
>
> diff --git a/hw/usb-bus.c b/hw/usb-bus.c
> index 256b881..6292282 100644
> --- a/hw/usb-bus.c
> +++ b/hw/usb-bus.c
> @@ -5,11 +5,13 @@
>  #include "monitor.h"
>
>  static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent);
> +static char *usbbus_get_fw_dev_path(DeviceState *dev);
>
>  static struct BusInfo usb_bus_info = {
>     .name      = "USB",
>     .size      = sizeof(USBBus),
>     .print_dev = usb_bus_dev_print,
> +    .get_fw_dev_path = usbbus_get_fw_dev_path,
>  };
>  static int next_usb_bus = 0;
>  static QTAILQ_HEAD(, USBBus) busses = QTAILQ_HEAD_INITIALIZER(busses);
> @@ -307,3 +309,36 @@ USBDevice *usbdevice_create(const char *cmdline)
>     }
>     return usb->usbdevice_init(params);
>  }
> +
> +static int usbbus_get_fw_dev_path_helper(USBDevice *d, USBBus *bus, char *p,
> +                                         int len)
> +{
> +    int l = 0;
> +    USBPort *port;
> +
> +    QTAILQ_FOREACH(port, &bus->used, next) {
> +        if (port->dev != d)

Braces.

> +            continue;
> +
> +        if (port->pdev) {
> +            l = usbbus_get_fw_dev_path_helper(port->pdev, bus, p, len);
> +        }
> +        l += snprintf(p + l, len - l, "%s@%x/", qdev_fw_name(&d->qdev),
> +                      port->index);
> +        return l;
> +    }
> +    return 0;

With this return value...

> +}
> +
> +static char *usbbus_get_fw_dev_path(DeviceState *dev)
> +{
> +    USBDevice *d = (USBDevice*)dev;
> +    USBBus *bus = usb_bus_from_device(d);
> +    char path[100];
> +    int l;
> +
> +    l = usbbus_get_fw_dev_path_helper(d, bus, path, sizeof(path));
> +    path[l-1] = '\0';

...this statement will have undesirable effects...

> +
> +    return strdup(path);

...like this.

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Qemu-devel] Re: [PATCHv3 11/14] Add bootindex parameter to net/block/fd device
  2010-11-10 18:32   ` [Qemu-devel] " Blue Swirl
@ 2010-11-10 18:48     ` Gleb Natapov
  0 siblings, 0 replies; 42+ messages in thread
From: Gleb Natapov @ 2010-11-10 18:48 UTC (permalink / raw)
  To: Blue Swirl; +Cc: alex.williamson, mst, qemu-devel, kvm, armbru

On Wed, Nov 10, 2010 at 06:32:54PM +0000, Blue Swirl wrote:
> On Wed, Nov 10, 2010 at 5:14 PM, Gleb Natapov <gleb@redhat.com> 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 <gleb@redhat.com>
> > ---
> >  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.

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Qemu-devel] Re: [PATCHv3 14/14] Pass boot device list to firmware.
  2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 14/14] Pass boot device list to firmware Gleb Natapov
@ 2010-11-10 18:50   ` Blue Swirl
  2010-11-10 19:11   ` Blue Swirl
  1 sibling, 0 replies; 42+ messages in thread
From: Blue Swirl @ 2010-11-10 18:50 UTC (permalink / raw)
  To: Gleb Natapov; +Cc: alex.williamson, mst, qemu-devel, kvm, armbru

On Wed, Nov 10, 2010 at 5:14 PM, Gleb Natapov <gleb@redhat.com> wrote:
>
> Signed-off-by: Gleb Natapov <gleb@redhat.com>
> ---
>  hw/fw_cfg.h |    1 +
>  hw/pc.c     |   19 +++++++++++++++++++
>  sysemu.h    |    1 +
>  vl.c        |   40 ++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 61 insertions(+), 0 deletions(-)
>
> diff --git a/hw/fw_cfg.h b/hw/fw_cfg.h
> index 4d13a4f..bfbf1f9 100644
> --- a/hw/fw_cfg.h
> +++ b/hw/fw_cfg.h
> @@ -31,6 +31,7 @@
>  #define FW_CFG_FILE_FIRST       0x20
>  #define FW_CFG_FILE_SLOTS       0x10
>  #define FW_CFG_MAX_ENTRY        (FW_CFG_FILE_FIRST+FW_CFG_FILE_SLOTS)
> +#define FW_CFG_BOOTINDEX        (FW_CFG_MAX_ENTRY + 1)

You should bump FW_CFG_MAX_ENTRY instead.

>  #define FW_CFG_WRITE_CHANNEL    0x4000
>  #define FW_CFG_ARCH_LOCAL       0x8000
> diff --git a/hw/pc.c b/hw/pc.c
> index 3bf3862..e51f8ba 100644
> --- a/hw/pc.c
> +++ b/hw/pc.c
> @@ -883,6 +883,21 @@ void pc_cpus_init(const char *cpu_model)
>     }
>  }
>
> +static struct machine_ready_notify {
> +    Notifier n;
> +    void *fw_cfg;
> +} machine_ready;
> +
> +
> +static void pc_fw_register_bootindex(struct Notifier* n)
> +{
> +    uint32_t len;
> +    char *bootindex = get_boot_devices_list(&len);
> +
> +    fw_cfg_add_bytes(machine_ready.fw_cfg, FW_CFG_BOOTINDEX,
> +                     (uint8_t*)bootindex, len);
> +}
> +
>  void pc_memory_init(ram_addr_t ram_size,
>                     const char *kernel_filename,
>                     const char *kernel_cmdline,
> @@ -982,6 +997,10 @@ void pc_memory_init(ram_addr_t ram_size,
>     for (i = 0; i < nb_option_roms; i++) {
>         rom_add_option(option_rom[i]);
>     }
> +
> +    machine_ready.n.notify = pc_fw_register_bootindex;
> +    machine_ready.fw_cfg = fw_cfg;
> +    qemu_add_machine_init_done_notifier(&machine_ready.n);
>  }
>
>  qemu_irq *pc_allocate_cpu_irq(void)
> diff --git a/sysemu.h b/sysemu.h
> index 46a588c..bac2df1 100644
> --- a/sysemu.h
> +++ b/sysemu.h
> @@ -197,4 +197,5 @@ void register_devices(void);
>
>  void add_boot_device_path(int32_t bootindex, DeviceState *dev,
>                           const char *suffix);
> +char *get_boot_devices_list(uint32_t *size);
>  #endif
> diff --git a/vl.c b/vl.c
> index 00ab2b4..4b1a406 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -734,6 +734,46 @@ void add_boot_device_path(int32_t bootindex, DeviceState *dev,
>     QTAILQ_INSERT_TAIL(&fw_boot_order, node, link);
>  }
>
> +char *get_boot_devices_list(uint32_t *size)
> +{
> +    FWBootEntry *i;
> +    uint32_t total = 1, c = 0;
> +    char *list = qemu_malloc(1);
> +
> +    QTAILQ_FOREACH(i, &fw_boot_order, link) {
> +        char *devpath = NULL, *bootpath;
> +        int len;
> +
> +        if (i->dev) {
> +            devpath = qdev_get_fw_dev_path(i->dev);
> +            assert(devpath);
> +        }
> +
> +        if (i->suffix && devpath) {
> +            bootpath = qemu_malloc(strlen(devpath) + strlen(i->suffix) + 2);
> +            sprintf(bootpath, "%s/%s", devpath, i->suffix);
> +            qemu_free(devpath);
> +        } else if (devpath) {
> +            bootpath = devpath;
> +        } else {
> +            bootpath = strdup(i->suffix);
> +        }
> +
> +        len = strlen(bootpath);
> +        list = qemu_realloc(list, total + len + 1);
> +        list[total++] = len;
> +        memcpy(&list[total], bootpath, len);
> +        total += len;
> +        c++;
> +        qemu_free(bootpath);
> +    }
> +
> +    list[0] = c;
> +    *size = total;
> +
> +    return list;
> +}

The format of the list should be documented, it wasn't immediately
obvious where '1' comes from in qemu_malloc(1).

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Qemu-devel] Re: [PATCHv3 10/14] Add get_dev_path callback for usb bus.
  2010-11-10 18:37   ` [Qemu-devel] " Blue Swirl
@ 2010-11-10 19:11     ` Gleb Natapov
  0 siblings, 0 replies; 42+ messages in thread
From: Gleb Natapov @ 2010-11-10 19:11 UTC (permalink / raw)
  To: Blue Swirl; +Cc: alex.williamson, mst, qemu-devel, kvm, armbru

On Wed, Nov 10, 2010 at 06:37:45PM +0000, Blue Swirl wrote:
> On Wed, Nov 10, 2010 at 5:14 PM, Gleb Natapov <gleb@redhat.com> wrote:
> >
> > Signed-off-by: Gleb Natapov <gleb@redhat.com>
> > ---
> >  hw/usb-bus.c |   35 +++++++++++++++++++++++++++++++++++
> >  1 files changed, 35 insertions(+), 0 deletions(-)
> >
> > diff --git a/hw/usb-bus.c b/hw/usb-bus.c
> > index 256b881..6292282 100644
> > --- a/hw/usb-bus.c
> > +++ b/hw/usb-bus.c
> > @@ -5,11 +5,13 @@
> >  #include "monitor.h"
> >
> >  static void usb_bus_dev_print(Monitor *mon, DeviceState *qdev, int indent);
> > +static char *usbbus_get_fw_dev_path(DeviceState *dev);
> >
> >  static struct BusInfo usb_bus_info = {
> >     .name      = "USB",
> >     .size      = sizeof(USBBus),
> >     .print_dev = usb_bus_dev_print,
> > +    .get_fw_dev_path = usbbus_get_fw_dev_path,
> >  };
> >  static int next_usb_bus = 0;
> >  static QTAILQ_HEAD(, USBBus) busses = QTAILQ_HEAD_INITIALIZER(busses);
> > @@ -307,3 +309,36 @@ USBDevice *usbdevice_create(const char *cmdline)
> >     }
> >     return usb->usbdevice_init(params);
> >  }
> > +
> > +static int usbbus_get_fw_dev_path_helper(USBDevice *d, USBBus *bus, char *p,
> > +                                         int len)
> > +{
> > +    int l = 0;
> > +    USBPort *port;
> > +
> > +    QTAILQ_FOREACH(port, &bus->used, next) {
> > +        if (port->dev != d)
> 
> Braces.
> 
> > +            continue;
> > +
> > +        if (port->pdev) {
> > +            l = usbbus_get_fw_dev_path_helper(port->pdev, bus, p, len);
> > +        }
> > +        l += snprintf(p + l, len - l, "%s@%x/", qdev_fw_name(&d->qdev),
> > +                      port->index);
> > +        return l;
> > +    }
> > +    return 0;
> 
> With this return value...
> 
> > +}
This can only happen if device is not attached to parent bus, so we
should never get here I think. I do not know USB bus enough to be sure.
May be we should abort here.

> > +
> > +static char *usbbus_get_fw_dev_path(DeviceState *dev)
> > +{
> > +    USBDevice *d = (USBDevice*)dev;
> > +    USBBus *bus = usb_bus_from_device(d);
> > +    char path[100];
> > +    int l;
> > +
> > +    l = usbbus_get_fw_dev_path_helper(d, bus, path, sizeof(path));
> > +    path[l-1] = '\0';
> 
> ...this statement will have undesirable effects...
> 
> > +
> > +    return strdup(path);
> 
> ...like this.

--
			Gleb.

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Qemu-devel] Re: [PATCHv3 14/14] Pass boot device list to firmware.
  2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 14/14] Pass boot device list to firmware Gleb Natapov
  2010-11-10 18:50   ` [Qemu-devel] " Blue Swirl
@ 2010-11-10 19:11   ` Blue Swirl
  2010-11-10 19:16     ` Gleb Natapov
  1 sibling, 1 reply; 42+ messages in thread
From: Blue Swirl @ 2010-11-10 19:11 UTC (permalink / raw)
  To: Gleb Natapov; +Cc: alex.williamson, mst, qemu-devel, kvm, armbru

On Wed, Nov 10, 2010 at 5:14 PM, Gleb Natapov <gleb@redhat.com> wrote:
>
> Signed-off-by: Gleb Natapov <gleb@redhat.com>
> ---
>  hw/fw_cfg.h |    1 +
>  hw/pc.c     |   19 +++++++++++++++++++
>  sysemu.h    |    1 +
>  vl.c        |   40 ++++++++++++++++++++++++++++++++++++++++
>  4 files changed, 61 insertions(+), 0 deletions(-)
>
> diff --git a/hw/fw_cfg.h b/hw/fw_cfg.h
> index 4d13a4f..bfbf1f9 100644
> --- a/hw/fw_cfg.h
> +++ b/hw/fw_cfg.h
> @@ -31,6 +31,7 @@
>  #define FW_CFG_FILE_FIRST       0x20
>  #define FW_CFG_FILE_SLOTS       0x10
>  #define FW_CFG_MAX_ENTRY        (FW_CFG_FILE_FIRST+FW_CFG_FILE_SLOTS)
> +#define FW_CFG_BOOTINDEX        (FW_CFG_MAX_ENTRY + 1)
>
>  #define FW_CFG_WRITE_CHANNEL    0x4000
>  #define FW_CFG_ARCH_LOCAL       0x8000
> diff --git a/hw/pc.c b/hw/pc.c
> index 3bf3862..e51f8ba 100644
> --- a/hw/pc.c
> +++ b/hw/pc.c
> @@ -883,6 +883,21 @@ void pc_cpus_init(const char *cpu_model)
>     }
>  }
>
> +static struct machine_ready_notify {
> +    Notifier n;
> +    void *fw_cfg;
> +} machine_ready;
> +
> +
> +static void pc_fw_register_bootindex(struct Notifier* n)
> +{
> +    uint32_t len;
> +    char *bootindex = get_boot_devices_list(&len);
> +
> +    fw_cfg_add_bytes(machine_ready.fw_cfg, FW_CFG_BOOTINDEX,
> +                     (uint8_t*)bootindex, len);
> +}
> +
>  void pc_memory_init(ram_addr_t ram_size,
>                     const char *kernel_filename,
>                     const char *kernel_cmdline,
> @@ -982,6 +997,10 @@ void pc_memory_init(ram_addr_t ram_size,
>     for (i = 0; i < nb_option_roms; i++) {
>         rom_add_option(option_rom[i]);
>     }
> +
> +    machine_ready.n.notify = pc_fw_register_bootindex;
> +    machine_ready.fw_cfg = fw_cfg;
> +    qemu_add_machine_init_done_notifier(&machine_ready.n);

Actually this and the above should be moved to generic code, like
vl.c. I doubt this would be any different for other platforms.

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Qemu-devel] Re: [PATCHv3 14/14] Pass boot device list to firmware.
  2010-11-10 19:11   ` Blue Swirl
@ 2010-11-10 19:16     ` Gleb Natapov
  2010-11-10 19:20       ` Blue Swirl
  0 siblings, 1 reply; 42+ messages in thread
From: Gleb Natapov @ 2010-11-10 19:16 UTC (permalink / raw)
  To: Blue Swirl; +Cc: alex.williamson, mst, qemu-devel, kvm, armbru

On Wed, Nov 10, 2010 at 07:11:54PM +0000, Blue Swirl wrote:
> On Wed, Nov 10, 2010 at 5:14 PM, Gleb Natapov <gleb@redhat.com> wrote:
> >
> > Signed-off-by: Gleb Natapov <gleb@redhat.com>
> > ---
> >  hw/fw_cfg.h |    1 +
> >  hw/pc.c     |   19 +++++++++++++++++++
> >  sysemu.h    |    1 +
> >  vl.c        |   40 ++++++++++++++++++++++++++++++++++++++++
> >  4 files changed, 61 insertions(+), 0 deletions(-)
> >
> > diff --git a/hw/fw_cfg.h b/hw/fw_cfg.h
> > index 4d13a4f..bfbf1f9 100644
> > --- a/hw/fw_cfg.h
> > +++ b/hw/fw_cfg.h
> > @@ -31,6 +31,7 @@
> >  #define FW_CFG_FILE_FIRST       0x20
> >  #define FW_CFG_FILE_SLOTS       0x10
> >  #define FW_CFG_MAX_ENTRY        (FW_CFG_FILE_FIRST+FW_CFG_FILE_SLOTS)
> > +#define FW_CFG_BOOTINDEX        (FW_CFG_MAX_ENTRY + 1)
> >
> >  #define FW_CFG_WRITE_CHANNEL    0x4000
> >  #define FW_CFG_ARCH_LOCAL       0x8000
> > diff --git a/hw/pc.c b/hw/pc.c
> > index 3bf3862..e51f8ba 100644
> > --- a/hw/pc.c
> > +++ b/hw/pc.c
> > @@ -883,6 +883,21 @@ void pc_cpus_init(const char *cpu_model)
> >     }
> >  }
> >
> > +static struct machine_ready_notify {
> > +    Notifier n;
> > +    void *fw_cfg;
> > +} machine_ready;
> > +
> > +
> > +static void pc_fw_register_bootindex(struct Notifier* n)
> > +{
> > +    uint32_t len;
> > +    char *bootindex = get_boot_devices_list(&len);
> > +
> > +    fw_cfg_add_bytes(machine_ready.fw_cfg, FW_CFG_BOOTINDEX,
> > +                     (uint8_t*)bootindex, len);
> > +}
> > +
> >  void pc_memory_init(ram_addr_t ram_size,
> >                     const char *kernel_filename,
> >                     const char *kernel_cmdline,
> > @@ -982,6 +997,10 @@ void pc_memory_init(ram_addr_t ram_size,
> >     for (i = 0; i < nb_option_roms; i++) {
> >         rom_add_option(option_rom[i]);
> >     }
> > +
> > +    machine_ready.n.notify = pc_fw_register_bootindex;
> > +    machine_ready.fw_cfg = fw_cfg;
> > +    qemu_add_machine_init_done_notifier(&machine_ready.n);
> 
> Actually this and the above should be moved to generic code, like
> vl.c. I doubt this would be any different for other platforms.
Agree, but we do not have reference to fw_cfg in generic code.

--
			Gleb.

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Qemu-devel] Re: [PATCHv3 14/14] Pass boot device list to firmware.
  2010-11-10 19:16     ` Gleb Natapov
@ 2010-11-10 19:20       ` Blue Swirl
  2010-11-11  7:03         ` Gleb Natapov
  0 siblings, 1 reply; 42+ messages in thread
From: Blue Swirl @ 2010-11-10 19:20 UTC (permalink / raw)
  To: Gleb Natapov; +Cc: alex.williamson, mst, qemu-devel, kvm, armbru

2010/11/10 Gleb Natapov <gleb@redhat.com>:
> On Wed, Nov 10, 2010 at 07:11:54PM +0000, Blue Swirl wrote:
>> On Wed, Nov 10, 2010 at 5:14 PM, Gleb Natapov <gleb@redhat.com> wrote:
>> >
>> > Signed-off-by: Gleb Natapov <gleb@redhat.com>
>> > ---
>> >  hw/fw_cfg.h |    1 +
>> >  hw/pc.c     |   19 +++++++++++++++++++
>> >  sysemu.h    |    1 +
>> >  vl.c        |   40 ++++++++++++++++++++++++++++++++++++++++
>> >  4 files changed, 61 insertions(+), 0 deletions(-)
>> >
>> > diff --git a/hw/fw_cfg.h b/hw/fw_cfg.h
>> > index 4d13a4f..bfbf1f9 100644
>> > --- a/hw/fw_cfg.h
>> > +++ b/hw/fw_cfg.h
>> > @@ -31,6 +31,7 @@
>> >  #define FW_CFG_FILE_FIRST       0x20
>> >  #define FW_CFG_FILE_SLOTS       0x10
>> >  #define FW_CFG_MAX_ENTRY        (FW_CFG_FILE_FIRST+FW_CFG_FILE_SLOTS)
>> > +#define FW_CFG_BOOTINDEX        (FW_CFG_MAX_ENTRY + 1)
>> >
>> >  #define FW_CFG_WRITE_CHANNEL    0x4000
>> >  #define FW_CFG_ARCH_LOCAL       0x8000
>> > diff --git a/hw/pc.c b/hw/pc.c
>> > index 3bf3862..e51f8ba 100644
>> > --- a/hw/pc.c
>> > +++ b/hw/pc.c
>> > @@ -883,6 +883,21 @@ void pc_cpus_init(const char *cpu_model)
>> >     }
>> >  }
>> >
>> > +static struct machine_ready_notify {
>> > +    Notifier n;
>> > +    void *fw_cfg;
>> > +} machine_ready;
>> > +
>> > +
>> > +static void pc_fw_register_bootindex(struct Notifier* n)
>> > +{
>> > +    uint32_t len;
>> > +    char *bootindex = get_boot_devices_list(&len);
>> > +
>> > +    fw_cfg_add_bytes(machine_ready.fw_cfg, FW_CFG_BOOTINDEX,
>> > +                     (uint8_t*)bootindex, len);
>> > +}
>> > +
>> >  void pc_memory_init(ram_addr_t ram_size,
>> >                     const char *kernel_filename,
>> >                     const char *kernel_cmdline,
>> > @@ -982,6 +997,10 @@ void pc_memory_init(ram_addr_t ram_size,
>> >     for (i = 0; i < nb_option_roms; i++) {
>> >         rom_add_option(option_rom[i]);
>> >     }
>> > +
>> > +    machine_ready.n.notify = pc_fw_register_bootindex;
>> > +    machine_ready.fw_cfg = fw_cfg;
>> > +    qemu_add_machine_init_done_notifier(&machine_ready.n);
>>
>> Actually this and the above should be moved to generic code, like
>> vl.c. I doubt this would be any different for other platforms.
> Agree, but we do not have reference to fw_cfg in generic code.

How about inside fw_cfg.c then?

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Qemu-devel] Re: [PATCHv3 14/14] Pass boot device list to firmware.
  2010-11-10 19:20       ` Blue Swirl
@ 2010-11-11  7:03         ` Gleb Natapov
  0 siblings, 0 replies; 42+ messages in thread
From: Gleb Natapov @ 2010-11-11  7:03 UTC (permalink / raw)
  To: Blue Swirl; +Cc: alex.williamson, mst, qemu-devel, kvm, armbru

On Wed, Nov 10, 2010 at 07:20:51PM +0000, Blue Swirl wrote:
> 2010/11/10 Gleb Natapov <gleb@redhat.com>:
> > On Wed, Nov 10, 2010 at 07:11:54PM +0000, Blue Swirl wrote:
> >> On Wed, Nov 10, 2010 at 5:14 PM, Gleb Natapov <gleb@redhat.com> wrote:
> >> >
> >> > Signed-off-by: Gleb Natapov <gleb@redhat.com>
> >> > ---
> >> >  hw/fw_cfg.h |    1 +
> >> >  hw/pc.c     |   19 +++++++++++++++++++
> >> >  sysemu.h    |    1 +
> >> >  vl.c        |   40 ++++++++++++++++++++++++++++++++++++++++
> >> >  4 files changed, 61 insertions(+), 0 deletions(-)
> >> >
> >> > diff --git a/hw/fw_cfg.h b/hw/fw_cfg.h
> >> > index 4d13a4f..bfbf1f9 100644
> >> > --- a/hw/fw_cfg.h
> >> > +++ b/hw/fw_cfg.h
> >> > @@ -31,6 +31,7 @@
> >> >  #define FW_CFG_FILE_FIRST       0x20
> >> >  #define FW_CFG_FILE_SLOTS       0x10
> >> >  #define FW_CFG_MAX_ENTRY        (FW_CFG_FILE_FIRST+FW_CFG_FILE_SLOTS)
> >> > +#define FW_CFG_BOOTINDEX        (FW_CFG_MAX_ENTRY + 1)
> >> >
> >> >  #define FW_CFG_WRITE_CHANNEL    0x4000
> >> >  #define FW_CFG_ARCH_LOCAL       0x8000
> >> > diff --git a/hw/pc.c b/hw/pc.c
> >> > index 3bf3862..e51f8ba 100644
> >> > --- a/hw/pc.c
> >> > +++ b/hw/pc.c
> >> > @@ -883,6 +883,21 @@ void pc_cpus_init(const char *cpu_model)
> >> >     }
> >> >  }
> >> >
> >> > +static struct machine_ready_notify {
> >> > +    Notifier n;
> >> > +    void *fw_cfg;
> >> > +} machine_ready;
> >> > +
> >> > +
> >> > +static void pc_fw_register_bootindex(struct Notifier* n)
> >> > +{
> >> > +    uint32_t len;
> >> > +    char *bootindex = get_boot_devices_list(&len);
> >> > +
> >> > +    fw_cfg_add_bytes(machine_ready.fw_cfg, FW_CFG_BOOTINDEX,
> >> > +                     (uint8_t*)bootindex, len);
> >> > +}
> >> > +
> >> >  void pc_memory_init(ram_addr_t ram_size,
> >> >                     const char *kernel_filename,
> >> >                     const char *kernel_cmdline,
> >> > @@ -982,6 +997,10 @@ void pc_memory_init(ram_addr_t ram_size,
> >> >     for (i = 0; i < nb_option_roms; i++) {
> >> >         rom_add_option(option_rom[i]);
> >> >     }
> >> > +
> >> > +    machine_ready.n.notify = pc_fw_register_bootindex;
> >> > +    machine_ready.fw_cfg = fw_cfg;
> >> > +    qemu_add_machine_init_done_notifier(&machine_ready.n);
> >>
> >> Actually this and the above should be moved to generic code, like
> >> vl.c. I doubt this would be any different for other platforms.
> > Agree, but we do not have reference to fw_cfg in generic code.
> 
> How about inside fw_cfg.c then?
Will move it there.

--
			Gleb.

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Qemu-devel] Re: [PATCHv3 08/14] Add get_fw_dev_path callback for pci bus.
  2010-11-10 17:34   ` [Qemu-devel] " Michael S. Tsirkin
  2010-11-10 18:02     ` Gleb Natapov
@ 2010-11-11 10:07     ` Gerd Hoffmann
  2010-11-11 10:17       ` Gleb Natapov
  2010-11-11 15:05       ` Michael S. Tsirkin
  1 sibling, 2 replies; 42+ messages in thread
From: Gerd Hoffmann @ 2010-11-11 10:07 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: kvm, Gleb Natapov, armbru, qemu-devel, blauwirbel,
	alex.williamson

On 11/10/10 18:34, Michael S. Tsirkin wrote:
> On Wed, Nov 10, 2010 at 07:14:15PM +0200, Gleb Natapov wrote:
>>
>> Signed-off-by: Gleb Natapov<gleb@redhat.com>
>
> Good stuff. We should also consider using this for
> CLI and monitor. Some comments below.

Oh, we already have a table to map pci classes to descriptions for 'info 
pci'.  I'd strongly suggest to just add the fw names to that table 
instead of creating a second one ...

cheers,
   Gerd

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Qemu-devel] Re: [PATCHv3 03/14] Keep track of ISA ports ISA device is using in qdev.
  2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 03/14] Keep track of ISA ports ISA device is using in qdev Gleb Natapov
@ 2010-11-11 10:14   ` Gerd Hoffmann
  2010-11-11 10:22     ` Gleb Natapov
  0 siblings, 1 reply; 42+ messages in thread
From: Gerd Hoffmann @ 2010-11-11 10:14 UTC (permalink / raw)
  To: Gleb Natapov; +Cc: kvm, mst, qemu-devel, armbru, blauwirbel, alex.williamson

   Hi,

>       register_ioport_write (s->port, 1, 1, gus_writeb, s);
>       register_ioport_write (s->port, 1, 2, gus_writew, s);
> +    isa_init_ioport_range(dev, s->port, 2);
>
>       register_ioport_read ((s->port + 0x100)&  0xf00, 1, 1, gus_readb, s);
>       register_ioport_read ((s->port + 0x100)&  0xf00, 1, 2, gus_readw, s);
> +    isa_init_ioport_range(dev, (s->port + 0x100)&  0xf00, 2);
>
>       register_ioport_write (s->port + 6, 10, 1, gus_writeb, s);
>       register_ioport_write (s->port + 6, 10, 2, gus_writew, s);
>       register_ioport_read (s->port + 6, 10, 1, gus_readb, s);
>       register_ioport_read (s->port + 6, 10, 2, gus_readw, s);
> +    isa_init_ioport_range(dev, s->port + 6, 10);
>
>
>       register_ioport_write (s->port + 0x100, 8, 1, gus_writeb, s);
>       register_ioport_write (s->port + 0x100, 8, 2, gus_writew, s);
>       register_ioport_read (s->port + 0x100, 8, 1, gus_readb, s);
>       register_ioport_read (s->port + 0x100, 8, 2, gus_readw, s);
> +    isa_init_ioport_range(dev, s->port + 0x100, 8);

Seeing all the duplication here and elsewhere ...

How about moving the register_ioport_{read,write} calls into 
isa_init_ioport_range() ?

cheers,
   Gerd

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Qemu-devel] Re: [PATCHv3 08/14] Add get_fw_dev_path callback for pci bus.
  2010-11-11 10:07     ` Gerd Hoffmann
@ 2010-11-11 10:17       ` Gleb Natapov
  2010-11-11 11:00         ` Gerd Hoffmann
  2010-11-11 15:05       ` Michael S. Tsirkin
  1 sibling, 1 reply; 42+ messages in thread
From: Gleb Natapov @ 2010-11-11 10:17 UTC (permalink / raw)
  To: Gerd Hoffmann
  Cc: kvm, Michael S. Tsirkin, armbru, qemu-devel, blauwirbel,
	alex.williamson

On Thu, Nov 11, 2010 at 11:07:01AM +0100, Gerd Hoffmann wrote:
> On 11/10/10 18:34, Michael S. Tsirkin wrote:
> >On Wed, Nov 10, 2010 at 07:14:15PM +0200, Gleb Natapov wrote:
> >>
> >>Signed-off-by: Gleb Natapov<gleb@redhat.com>
> >
> >Good stuff. We should also consider using this for
> >CLI and monitor. Some comments below.
> 
> Oh, we already have a table to map pci classes to descriptions for
> 'info pci'.  I'd strongly suggest to just add the fw names to that
> table instead of creating a second one ...
> 
Do you mean pci_class_descriptions? For some classes open firmware spec
defines single name for all subclasses. For instance all 0Axx should be
called "dock" no matter what xx is. This can't be encoded in a simple
table.

--
			Gleb.

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Qemu-devel] Re: [PATCHv3 00/14] boot order specification
  2010-11-10 17:14 [Qemu-devel] [PATCHv3 00/14] boot order specification Gleb Natapov
                   ` (14 preceding siblings ...)
  2010-11-10 18:08 ` [Qemu-devel] Re: [PATCHv3 00/14] boot order specification Blue Swirl
@ 2010-11-11 10:21 ` Gerd Hoffmann
  2010-11-11 18:41   ` Blue Swirl
  15 siblings, 1 reply; 42+ messages in thread
From: Gerd Hoffmann @ 2010-11-11 10:21 UTC (permalink / raw)
  To: Gleb Natapov; +Cc: kvm, mst, qemu-devel, armbru, blauwirbel, alex.williamson

On 11/10/10 18:14, Gleb Natapov wrote:
> This is current sate of the patch series for people to comment on.
> I am using open firmware naming scheme to specify device path names.
>
> Names look like this on pci machine:
> /pci@i0cf8/ide@1,1/drive@1/disk@0
> /pci@i0cf8/isa@1/fdc@03f1/floppy@1
> /pci@i0cf8/isa@1/fdc@03f1/floppy@0
> /pci@i0cf8/ide@1,1/drive@1/disk@1
> /pci@i0cf8/ide@1,1/drive@0/disk@0
> /pci@i0cf8/scsi@3/disk@0
> /pci@i0cf8/ethernet@4/ethernet-phy@0
> /pci@i0cf8/ethernet@5/ethernet-phy@0
> /pci@i0cf8/ide@1,1/drive@0/disk@1
> /pci@i0cf8/isa@1/ide@01e8/drive@0/disk@0
> /pci@i0cf8/usb@1,2/network@0/ethernet@0
> /pci@i0cf8/usb@1,2/hub@1/network@0/ethernet@0

Good stuff overall, but see replies to patches for some nits.

IIRC some powerpc (+sparc?) boards pass a device tree to the guest.  So 
with this (and maybe some more bits) we might be able to dynamically 
generate a device tree from our qdev tree?  Any comments from the 
ppc/sparc folks on this?

cheers,
   Gerd

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Qemu-devel] Re: [PATCHv3 03/14] Keep track of ISA ports ISA device is using in qdev.
  2010-11-11 10:14   ` [Qemu-devel] " Gerd Hoffmann
@ 2010-11-11 10:22     ` Gleb Natapov
  0 siblings, 0 replies; 42+ messages in thread
From: Gleb Natapov @ 2010-11-11 10:22 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: kvm, mst, qemu-devel, armbru, blauwirbel, alex.williamson

On Thu, Nov 11, 2010 at 11:14:42AM +0100, Gerd Hoffmann wrote:
>   Hi,
> 
> >      register_ioport_write (s->port, 1, 1, gus_writeb, s);
> >      register_ioport_write (s->port, 1, 2, gus_writew, s);
> >+    isa_init_ioport_range(dev, s->port, 2);
> >
> >      register_ioport_read ((s->port + 0x100)&  0xf00, 1, 1, gus_readb, s);
> >      register_ioport_read ((s->port + 0x100)&  0xf00, 1, 2, gus_readw, s);
> >+    isa_init_ioport_range(dev, (s->port + 0x100)&  0xf00, 2);
> >
> >      register_ioport_write (s->port + 6, 10, 1, gus_writeb, s);
> >      register_ioport_write (s->port + 6, 10, 2, gus_writew, s);
> >      register_ioport_read (s->port + 6, 10, 1, gus_readb, s);
> >      register_ioport_read (s->port + 6, 10, 2, gus_readw, s);
> >+    isa_init_ioport_range(dev, s->port + 6, 10);
> >
> >
> >      register_ioport_write (s->port + 0x100, 8, 1, gus_writeb, s);
> >      register_ioport_write (s->port + 0x100, 8, 2, gus_writew, s);
> >      register_ioport_read (s->port + 0x100, 8, 1, gus_readb, s);
> >      register_ioport_read (s->port + 0x100, 8, 2, gus_readw, s);
> >+    isa_init_ioport_range(dev, s->port + 0x100, 8);
> 
> Seeing all the duplication here and elsewhere ...
> 
> How about moving the register_ioport_{read,write} calls into
> isa_init_ioport_range() ?
> 
I am waiting for Avi's "Type-safe ioport callbacks" series to be applied
before cleaning this up. With that patch what you propose will come
naturally.

--
			Gleb.

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Qemu-devel] Re: [PATCHv3 08/14] Add get_fw_dev_path callback for pci bus.
  2010-11-11 10:17       ` Gleb Natapov
@ 2010-11-11 11:00         ` Gerd Hoffmann
  0 siblings, 0 replies; 42+ messages in thread
From: Gerd Hoffmann @ 2010-11-11 11:00 UTC (permalink / raw)
  To: Gleb Natapov
  Cc: kvm, Michael S. Tsirkin, armbru, qemu-devel, blauwirbel,
	alex.williamson

>> Oh, we already have a table to map pci classes to descriptions for
>> 'info pci'.  I'd strongly suggest to just add the fw names to that
>> table instead of creating a second one ...
>>
> Do you mean pci_class_descriptions?

Exactly.

> For some classes open firmware spec
> defines single name for all subclasses. For instance all 0Axx should be
> called "dock" no matter what xx is. This can't be encoded in a simple
> table.

Well, actually it is a list not a table.  Should be easy to extend, like 
adding a mask, so you can have { .class = 0xa000, .mask = 0xff00,
.fw_name = "dock", .desc = "whatever" } to match 0xA0xx ...

cheers,
   Gerd

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Qemu-devel] Re: [PATCHv3 08/14] Add get_fw_dev_path callback for pci bus.
  2010-11-11 10:07     ` Gerd Hoffmann
  2010-11-11 10:17       ` Gleb Natapov
@ 2010-11-11 15:05       ` Michael S. Tsirkin
  2010-11-11 16:07         ` Gleb Natapov
  1 sibling, 1 reply; 42+ messages in thread
From: Michael S. Tsirkin @ 2010-11-11 15:05 UTC (permalink / raw)
  To: Gerd Hoffmann
  Cc: kvm, Gleb Natapov, armbru, qemu-devel, blauwirbel,
	alex.williamson

On Thu, Nov 11, 2010 at 11:07:01AM +0100, Gerd Hoffmann wrote:
> On 11/10/10 18:34, Michael S. Tsirkin wrote:
> >On Wed, Nov 10, 2010 at 07:14:15PM +0200, Gleb Natapov wrote:
> >>
> >>Signed-off-by: Gleb Natapov<gleb@redhat.com>
> >
> >Good stuff. We should also consider using this for
> >CLI and monitor. Some comments below.
> 
> Oh, we already have a table to map pci classes to descriptions for
> 'info pci'.

You remind me, that one must be fixed to use names from
pci_ids.h

>  I'd strongly suggest to just add the fw names to that
> table instead of creating a second one ...
> 
> cheers,
>   Gerd

No, I mean the path.

We are currently passing domain:bus:slot.function
to point at a device and we know it's broken for
nested bridges and kind of broken for multiple domains.
It's a bug that we must fix.

Class names aren't that interesting to me,
and I'd be just as happy with packing these into 2 tables as a single
one personally, it all seems to be a matter of style.
-- 
MST

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Qemu-devel] Re: [PATCHv3 08/14] Add get_fw_dev_path callback for pci bus.
  2010-11-11 15:05       ` Michael S. Tsirkin
@ 2010-11-11 16:07         ` Gleb Natapov
  2010-11-11 17:14           ` Michael S. Tsirkin
  0 siblings, 1 reply; 42+ messages in thread
From: Gleb Natapov @ 2010-11-11 16:07 UTC (permalink / raw)
  To: Michael S. Tsirkin
  Cc: kvm, armbru, qemu-devel, blauwirbel, alex.williamson,
	Gerd Hoffmann

On Thu, Nov 11, 2010 at 05:05:11PM +0200, Michael S. Tsirkin wrote:
> On Thu, Nov 11, 2010 at 11:07:01AM +0100, Gerd Hoffmann wrote:
> > On 11/10/10 18:34, Michael S. Tsirkin wrote:
> > >On Wed, Nov 10, 2010 at 07:14:15PM +0200, Gleb Natapov wrote:
> > >>
> > >>Signed-off-by: Gleb Natapov<gleb@redhat.com>
> > >
> > >Good stuff. We should also consider using this for
> > >CLI and monitor. Some comments below.
> > 
> > Oh, we already have a table to map pci classes to descriptions for
> > 'info pci'.
> 
> You remind me, that one must be fixed to use names from
> pci_ids.h
> 
For now I used numbers like other elements of the table. If I
would do the conversion I would use convenience marcros to not have
names like PCI_CLASS_NETWORK_TOKEN_RING all over the table :)

--
			Gleb.

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Qemu-devel] Re: [PATCHv3 08/14] Add get_fw_dev_path callback for pci bus.
  2010-11-11 16:07         ` Gleb Natapov
@ 2010-11-11 17:14           ` Michael S. Tsirkin
  0 siblings, 0 replies; 42+ messages in thread
From: Michael S. Tsirkin @ 2010-11-11 17:14 UTC (permalink / raw)
  To: Gleb Natapov
  Cc: kvm, armbru, qemu-devel, blauwirbel, alex.williamson,
	Gerd Hoffmann

On Thu, Nov 11, 2010 at 06:07:53PM +0200, Gleb Natapov wrote:
> On Thu, Nov 11, 2010 at 05:05:11PM +0200, Michael S. Tsirkin wrote:
> > On Thu, Nov 11, 2010 at 11:07:01AM +0100, Gerd Hoffmann wrote:
> > > On 11/10/10 18:34, Michael S. Tsirkin wrote:
> > > >On Wed, Nov 10, 2010 at 07:14:15PM +0200, Gleb Natapov wrote:
> > > >>
> > > >>Signed-off-by: Gleb Natapov<gleb@redhat.com>
> > > >
> > > >Good stuff. We should also consider using this for
> > > >CLI and monitor. Some comments below.
> > > 
> > > Oh, we already have a table to map pci classes to descriptions for
> > > 'info pci'.
> > 
> > You remind me, that one must be fixed to use names from
> > pci_ids.h
> > 
> For now I used numbers like other elements of the table.

Fair enough.

> If I
> would do the conversion I would use convenience marcros to not have
> names like PCI_CLASS_NETWORK_TOKEN_RING all over the table :)
> 
> --
> 			Gleb.

I'd prefer to keep it simple :)

-- 
MST

^ permalink raw reply	[flat|nested] 42+ messages in thread

* [Qemu-devel] Re: [PATCHv3 00/14] boot order specification
  2010-11-11 10:21 ` Gerd Hoffmann
@ 2010-11-11 18:41   ` Blue Swirl
  0 siblings, 0 replies; 42+ messages in thread
From: Blue Swirl @ 2010-11-11 18:41 UTC (permalink / raw)
  To: Gerd Hoffmann; +Cc: kvm, Gleb Natapov, mst, armbru, qemu-devel, alex.williamson

On Thu, Nov 11, 2010 at 10:21 AM, Gerd Hoffmann <kraxel@redhat.com> wrote:
> On 11/10/10 18:14, Gleb Natapov wrote:
>>
>> This is current sate of the patch series for people to comment on.
>> I am using open firmware naming scheme to specify device path names.
>>
>> Names look like this on pci machine:
>> /pci@i0cf8/ide@1,1/drive@1/disk@0
>> /pci@i0cf8/isa@1/fdc@03f1/floppy@1
>> /pci@i0cf8/isa@1/fdc@03f1/floppy@0
>> /pci@i0cf8/ide@1,1/drive@1/disk@1
>> /pci@i0cf8/ide@1,1/drive@0/disk@0
>> /pci@i0cf8/scsi@3/disk@0
>> /pci@i0cf8/ethernet@4/ethernet-phy@0
>> /pci@i0cf8/ethernet@5/ethernet-phy@0
>> /pci@i0cf8/ide@1,1/drive@0/disk@1
>> /pci@i0cf8/isa@1/ide@01e8/drive@0/disk@0
>> /pci@i0cf8/usb@1,2/network@0/ethernet@0
>> /pci@i0cf8/usb@1,2/hub@1/network@0/ethernet@0
>
> Good stuff overall, but see replies to patches for some nits.
>
> IIRC some powerpc (+sparc?) boards pass a device tree to the guest.  So with
> this (and maybe some more bits) we might be able to dynamically generate a
> device tree from our qdev tree?  Any comments from the ppc/sparc folks on
> this?

Sparc does not use the device tree in real life, except a binary
machine description is used by Sun4v hypervisor. But using a device
tree could simplify how OpenBIOS (for both Sparc and PPC) supports
different machine types.

Device tree is already used by for example Bamboo (PPC) and Petalogix
(Microblaze) boards.

^ permalink raw reply	[flat|nested] 42+ messages in thread

end of thread, other threads:[~2010-11-11 18:41 UTC | newest]

Thread overview: 42+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-11-10 17:14 [Qemu-devel] [PATCHv3 00/14] boot order specification Gleb Natapov
2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 01/14] Introduce fw_name field to DeviceInfo structure Gleb Natapov
2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 02/14] Introduce new BusInfo callback get_fw_dev_path Gleb Natapov
2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 03/14] Keep track of ISA ports ISA device is using in qdev Gleb Natapov
2010-11-11 10:14   ` [Qemu-devel] " Gerd Hoffmann
2010-11-11 10:22     ` Gleb Natapov
2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 04/14] Add get_fw_dev_path callback to ISA bus " Gleb Natapov
2010-11-10 18:34   ` [Qemu-devel] " Blue Swirl
2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 05/14] Store IDE bus id in IDEBus structure for easy access Gleb Natapov
2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 06/14] Add get_fw_dev_path callback to IDE bus Gleb Natapov
2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 07/14] Add get_dev_path callback for system bus Gleb Natapov
2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 08/14] Add get_fw_dev_path callback for pci bus Gleb Natapov
2010-11-10 17:34   ` [Qemu-devel] " Michael S. Tsirkin
2010-11-10 18:02     ` Gleb Natapov
2010-11-10 18:21       ` Michael S. Tsirkin
2010-11-10 18:25         ` Blue Swirl
2010-11-10 18:33         ` Gleb Natapov
2010-11-11 10:07     ` Gerd Hoffmann
2010-11-11 10:17       ` Gleb Natapov
2010-11-11 11:00         ` Gerd Hoffmann
2010-11-11 15:05       ` Michael S. Tsirkin
2010-11-11 16:07         ` Gleb Natapov
2010-11-11 17:14           ` Michael S. Tsirkin
2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 09/14] Record which USBDevice USBPort belongs too Gleb Natapov
2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 10/14] Add get_dev_path callback for usb bus Gleb Natapov
2010-11-10 18:37   ` [Qemu-devel] " Blue Swirl
2010-11-10 19:11     ` Gleb Natapov
2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 11/14] Add bootindex parameter to net/block/fd device Gleb Natapov
2010-11-10 18:32   ` [Qemu-devel] " Blue Swirl
2010-11-10 18:48     ` Gleb Natapov
2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 12/14] Add bootindex parameter to pci assigned device Gleb Natapov
2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 13/14] Add notifier that will be called when machine is fully created Gleb Natapov
2010-11-10 17:14 ` [Qemu-devel] [PATCHv3 14/14] Pass boot device list to firmware Gleb Natapov
2010-11-10 18:50   ` [Qemu-devel] " Blue Swirl
2010-11-10 19:11   ` Blue Swirl
2010-11-10 19:16     ` Gleb Natapov
2010-11-10 19:20       ` Blue Swirl
2010-11-11  7:03         ` Gleb Natapov
2010-11-10 18:08 ` [Qemu-devel] Re: [PATCHv3 00/14] boot order specification Blue Swirl
2010-11-10 18:19   ` Gleb Natapov
2010-11-11 10:21 ` Gerd Hoffmann
2010-11-11 18:41   ` Blue Swirl

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).