qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] [PATCH v3 01/26] blockdev: Introduce a default machine


From: Markus Armbruster
Subject: Re: [Qemu-devel] [PATCH v3 01/26] blockdev: Introduce a default machine blockdev interface field, QEMUMachine->mach_if
Date: Fri, 26 Oct 2012 12:28:45 +0200
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/24.1 (gnu/linux)

Jason Baron <address@hidden> writes:

> On Wed, Oct 24, 2012 at 03:12:36PM +0200, Markus Armbruster wrote:
>> Jason Baron <address@hidden> writes:
>> 
>> > From: Jason Baron <address@hidden>
>> >
>> > The current QEMUMachine definition has a 'use_scsi' field to indicate if a
>> > machine type should use scsi by default. However, Q35 wants to use ahci by
>> > default. Thus, introdue a new field in the QEMUMachine defintion, mach_if.
>> 
>> Even though q35's desire to default to IF_AHCI is driving this patch,
>> generalizing the default interface type makes sense on its own.  Even if
>> we IF_AHCI should turn out to need more discussion.
>> 
>> > This field should be initialized by the machine type to the default 
>> > interface
>> > type which it wants to use (IF_SCSI, IF_AHCI, etc.). If no mach_if is 
>> > defined,
>> > or it is set to 'IF_DEFAULT' or 'IF_NONE', we currently assume IF_IDE.
>> >
>> > Please use 'static inline int get_mach_if(int mach_if)', when accesssing 
>> > the
>> > new mach_if field.
>> >
>> > Reviewed-by: Paolo Bonzini <address@hidden>
>> > Signed-off-by: Jason Baron <address@hidden>
>> > ---
>> >  blockdev.c          |    4 ++--
>> >  blockdev.h          |   19 +++++++++++++++++++
>> >  hw/boards.h         |    2 +-
>> >  hw/device-hotplug.c |    2 +-
>> >  hw/highbank.c       |    2 +-
>> >  hw/leon3.c          |    2 +-
>> >  hw/mips_jazz.c      |    4 ++--
>> >  hw/pc_sysfw.c       |    2 +-
>> >  hw/puv3.c           |    2 +-
>> >  hw/realview.c       |    6 +++---
>> >  hw/spapr.c          |    2 +-
>> >  hw/sun4m.c          |   24 ++++++++++++------------
>> >  hw/versatilepb.c    |    4 ++--
>> >  hw/vexpress.c       |    4 ++--
>> >  hw/xilinx_zynq.c    |    2 +-
>> >  vl.c                |   20 +++++++++++---------
>> >  16 files changed, 61 insertions(+), 40 deletions(-)
>> >
>> > diff --git a/blockdev.c b/blockdev.c
>> > index 99828ad..c9a49c8 100644
>> > --- a/blockdev.c
>> > +++ b/blockdev.c
>> > @@ -275,7 +275,7 @@ static bool do_check_io_limits(BlockIOLimit *io_limits)
>> >      return true;
>> >  }
>> >  
>> > -DriveInfo *drive_init(QemuOpts *opts, int default_to_scsi)
>> > +DriveInfo *drive_init(QemuOpts *opts, int mach_if)
>> 
>> BlockInterfaceType mach_if
>> 
>> Suggest to rename mach_if to something more descriptive.  Kevin's
>> default_drive_if works for me.
>> 
>
> ok.
>
>> 
>> >  {
>> >      const char *buf;
>> >      const char *file = NULL;
>> > @@ -325,7 +325,7 @@ DriveInfo *drive_init(QemuOpts *opts, int 
>> > default_to_scsi)
>> >              return NULL;
>> >    }
>> >      } else {
>> > -        type = default_to_scsi ? IF_SCSI : IF_IDE;
>> > +        type = get_mach_if(mach_if);
>> >      }
>> >  
>> >      max_devs = if_max_devs[type];
>> > diff --git a/blockdev.h b/blockdev.h
>> > index 5f27b64..8b126ad 100644
>> > --- a/blockdev.h
>> > +++ b/blockdev.h
>> > @@ -40,6 +40,22 @@ struct DriveInfo {
>> >      int refcount;
>> >  };
>> >  
>> > +/*
>> > + * Each qemu machine type defines a mach_if field for its default
>> > + * interface type. If its unspecified, we set it to IF_IDE.
>> > + */
>> > +static inline int get_mach_if(int mach_if)
>> 
>> BlockInterfaceType mach_if, and return type.
>> 
>> > +{
>> > +    assert(mach_if < IF_COUNT);
>> > +    assert(mach_if >= IF_DEFAULT);
>> > +
>> > +    if ((mach_if == IF_NONE) || (mach_if == IF_DEFAULT)) {
>> > +        return IF_IDE;
>> > +    }
>> > +
>> > +    return mach_if;
>> > +}
>> > +
>> 
>> I'm not sure we should map IF_NONE to IF_IDE.
>> 
>> get_mach_if() should return an interface type the board supports.  In
>> theory, we could have a board that doesn't define any controllers, but
>> still lets the user define some with -device (say because the board
>> sports a PCI bus).  Then IF_NONE would be the only interface type that
>> makes any sense, and therefore the only sensible value of get_mach_if().
>> 
>
> Ok, but no boards use IF_NONE in that sense currently. But planning for
> the future is good :)
>
>> If we drop the magic mapping of IF_NONE, only IF_DEFAULT is left, and
>> that one's clearly marked "for use with drive_add() only".  No real need
>> for magic mapping then.  Could drop get_mach_if() and use mach_if
>> directly.
>
> Meaning explicity set mach_if or default_drive_if to IF_IDE for all
> machine types that are currently either IF_NONE, IF_DEFAULT, or not
> explicitly defined?

Yes.

I count 97 machine types.  24 have .use_scsi = 1.  Two have explicit
.use_scsi = 0, and the remaining 71 have it implicitly.  I very much
doubt these 73 all sport IDE controllers.  Last time I checked[*], 41
machine types supported CD-ROM drives.  Makes me estimate we have ~55
machine types that have neither onboard SCSI nor IDE.

What happens when .use_scsi = 0 and the board doesn't provide IDE?
-drive without if= defines a block backend, but no frontend.  Just like
if=none, except for the (misleading) default ID.  Likewise, when
.use_scsi = 1 and the board doesn't provide SCSI.

You convert the 24 .use_scsi = 1 to .mach_if = IF_SCSI.  Fair enough.
But I think it should be changed to a more suitable value for machine
types that don't actually provide SCSI.  Suspect highbank is an example.
Can be done as followup patch; your choice.

You convert the two explicit .use_scsi = 0 (leon3_generic and puv3.c) to
IF_DEFAULT, effectively IF_IDE.  In both cases, the machine doesn't
actually provide an IDE controller as far as I can tell.  Again,
changing it to a more suitable value would make sense.  Followup patch,
or drop the .use_scsi = 0 in a preparatory patch, or convert to "no
initializer" to fold this case into the next one, or whatever else works
for you.

You leave the 71 without a .use_scsi initializer alone, which results in
IF_NONE, effectively IF_IDE.  Fair enough.  Again, it should be changed
to a more suitable value for the machine types that don't provide IDE.
If you drop the magic mapping, IF_NONE means IF_NONE, which may be a
more suitable value for the ones that don't provide IDE.  So you'd have
to add .mach_if = IF_IDE only to the minority that does provide IDE, and
leave the remaining ~55 ones alone.

Not so bad, isn't it?

[*] http://lists.nongnu.org/archive/html/qemu-devel/2012-08/msg02993.html



reply via email to

[Prev in Thread] Current Thread [Next in Thread]