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: Jason Baron
Subject: Re: [Qemu-devel] [PATCH v3 01/26] blockdev: Introduce a default machine blockdev interface field, QEMUMachine->mach_if
Date: Wed, 24 Oct 2012 15:41:53 -0400
User-agent: Mutt/1.5.20 (2009-12-10)

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?

Thanks,

-Jason



reply via email to

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