From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=54151 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PAjag-00016M-GM for qemu-devel@nongnu.org; Tue, 26 Oct 2010 09:29:27 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PAjaf-0001NI-0B for qemu-devel@nongnu.org; Tue, 26 Oct 2010 09:29:26 -0400 Received: from mail-qy0-f180.google.com ([209.85.216.180]:46377) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PAjae-0001N7-Rh for qemu-devel@nongnu.org; Tue, 26 Oct 2010 09:29:24 -0400 Received: by qyk8 with SMTP id 8so3003411qyk.4 for ; Tue, 26 Oct 2010 06:29:24 -0700 (PDT) Message-ID: <4CC6D7B1.5010400@codemonkey.ws> Date: Tue, 26 Oct 2010 08:29:21 -0500 From: Anthony Liguori MIME-Version: 1.0 Subject: Re: [Qemu-devel] [PATCH 5/5] Add bootindex parameter to net/block/fd device References: <1288090091-25874-1-git-send-email-gleb@redhat.com> <1288090091-25874-6-git-send-email-gleb@redhat.com> In-Reply-To: <1288090091-25874-6-git-send-email-gleb@redhat.com> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Gleb Natapov Cc: qemu-devel@nongnu.org On 10/26/2010 05:48 AM, Gleb Natapov wrote: > If bootindex is specified on command line a string that describes device > in firmware readable way is added into sorted list. Later this list will > be passed into firmware to control boot order. > > Signed-off-by: Gleb Natapov > --- > block_int.h | 4 +++- > hw/fdc.c | 36 ++++++++++++++++++++++++++++++++++++ > hw/ide/qdev.c | 24 ++++++++++++++++++++++++ > hw/virtio-blk.c | 20 ++++++++++++++++++++ > hw/virtio-net.c | 20 ++++++++++++++++++++ > net.h | 4 +++- > sysemu.h | 9 +++++++++ > vl.c | 24 ++++++++++++++++++++++++ > 8 files changed, 139 insertions(+), 2 deletions(-) > > diff --git a/block_int.h b/block_int.h > index e8e7156..60e7be2 100644 > --- a/block_int.h > +++ b/block_int.h > @@ -225,6 +225,7 @@ typedef struct BlockConf { > uint16_t logical_block_size; > uint16_t min_io_size; > uint32_t opt_io_size; > + int32_t bootindex; > } BlockConf; > > static inline unsigned int get_physical_block_exp(BlockConf *conf) > @@ -247,6 +248,7 @@ static inline unsigned int get_physical_block_exp(BlockConf *conf) > DEFINE_PROP_UINT16("physical_block_size", _state, \ > _conf.physical_block_size, 512), \ > DEFINE_PROP_UINT16("min_io_size", _state, _conf.min_io_size, 0), \ > - DEFINE_PROP_UINT32("opt_io_size", _state, _conf.opt_io_size, 0) > + DEFINE_PROP_UINT32("opt_io_size", _state, _conf.opt_io_size, 0), \ > + DEFINE_PROP_INT32("bootindex", _state, _conf.bootindex, -1) \ > > #endif /* BLOCK_INT_H */ > diff --git a/hw/fdc.c b/hw/fdc.c > index 1f38d0d..9d0dff5 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) > @@ -1974,6 +1977,7 @@ static int isabus_fdc_init1(ISADevice *dev) > int isairq = 6; > int dma_chann = 2; > int ret; > + char devpath[30], *bus_name; > > register_ioport_read(iobase + 0x01, 5, 1, > &fdctrl_read_port, fdctrl); > @@ -1992,6 +1996,36 @@ static int isabus_fdc_init1(ISADevice *dev) > qdev_set_legacy_instance_id(&dev->qdev, iobase, 2); > ret = fdctrl_init_common(fdctrl); > > + if (ret) { > + return ret; > + } > + > + if (isa->bootindexA< 0&& isa->bootindexB< 0) { > + return 0; > + } > + > + if (!dev->qdev.parent_bus->info->get_dev_path) { > + fprintf(stderr, "Can't create device path for floppy\n"); > + return 0; > + } > + > + bus_name = dev->qdev.parent_bus->info->get_dev_path(&dev->qdev); > + > + if (isa->bootindexA>= 0) { > + snprintf(devpath, sizeof(devpath), "%s@%s/fd@a", > + dev->qdev.parent_bus->info->name, bus_name); > + > + add_boot_device_path(isa->bootindexA, strdup(devpath)); > + } > Even if we're passing a string to SeaBIOS, we should probably keep the components structured. Looks like there's four pieces of data: 1) a bus name 2) a bus path 3) a device name 4) a device path. We derive (1) from the qdev structure, why don't we derive (3) too? Regards, Anthony Liguori