All of lore.kernel.org
 help / color / mirror / Atom feed
From: Markus Armbruster <armbru@redhat.com>
To: John Snow <jsnow@redhat.com>
Cc: kwolf@redhat.com, qemu-devel@nongnu.org, stefanha@redhat.com,
	mst@redhat.com
Subject: Re: [Qemu-devel] [PATCH 2/6] blockdev: Allow overriding if_max_dev property
Date: Wed, 24 Sep 2014 16:10:14 +0200	[thread overview]
Message-ID: <87vbodp0s9.fsf@blackfin.pond.sub.org> (raw)
In-Reply-To: <1411490885-29782-3-git-send-email-jsnow@redhat.com> (John Snow's message of "Tue, 23 Sep 2014 12:48:01 -0400")

John Snow <jsnow@redhat.com> writes:

> The if_max_devs table as in the past been an immutable
> default that controls the mapping of index => (bus,unit)
> for all boards and all HBAs for each interface type.
>
> Since adding this mapping information to the HBA device
> itself is currently unwieldly from the perspective of
> retrieving this information at option parsing time
> (e.g, within drive_new), we consider the alternative
> of marking the if_max_devs table mutable so that
> later configuration and initialization can adjust the
> mapping at will, but only up until a drive is added,
> at which point the mapping is finalized.
>
> Signed-off-by: John Snow <jsnow@redhat.com>
> ---
>  blockdev.c                | 35 ++++++++++++++++++++++++++++++++++-
>  include/sysemu/blockdev.h |  3 +++
>  2 files changed, 37 insertions(+), 1 deletion(-)
>
> diff --git a/blockdev.c b/blockdev.c
> index 81398e7..94562e9 100644
> --- a/blockdev.c
> +++ b/blockdev.c
> @@ -60,7 +60,7 @@ static const char *const if_name[IF_COUNT] = {
>      [IF_XEN] = "xen",
>  };
>  
> -static const int if_max_devs[IF_COUNT] = {
> +static int if_max_devs[IF_COUNT] = {
>      /*
>       * Do not change these numbers!  They govern how drive option
>       * index maps to unit and bus.  That mapping is ABI.
> @@ -79,6 +79,30 @@ static const int if_max_devs[IF_COUNT] = {
>      [IF_SCSI] = 7,
>  };
>  
> +/**
> + * Boards may call this to offer board-by-board overrides
> + * of the default, global values.
> + */
> +void override_max_devs(BlockInterfaceType type, int max_devs)
> +{
> +    DriveInfo *dinfo;
> +
> +    if (max_devs <= 0) {
> +        return;
> +    }
> +
> +    QTAILQ_FOREACH(dinfo, &drives, next) {
> +        if (dinfo->type == type) {
> +            fprintf(stderr, "Warning: Cannot override units-per-bus property of"
> +                    " the %s interface, because a drive of that type has"
> +                    " already been added.\n", if_name[type]);

Isn't this a programming error?  If yes: assert().

> +            return;
> +        }
> +    }
> +
> +    if_max_devs[type] = max_devs;
> +}
> +
>  /*
>   * We automatically delete the drive when a device using it gets
>   * unplugged.  Questionable feature, but we can't just drop it.
> @@ -111,6 +135,15 @@ void blockdev_auto_del(BlockDriverState *bs)
>      }
>  }
>  
> +int if_get_max_devs(BlockInterfaceType type)
> +{
> +    if (type >= IF_IDE && type < IF_COUNT) {
> +        return if_max_devs[type];
> +    }
> +
> +    return 0;
> +}
> +

The need for if_get_max_devs() isn't clear at this point.

>  static int drive_index_to_bus_id(BlockInterfaceType type, int index)
>  {
>      int max_devs = if_max_devs[type];
> diff --git a/include/sysemu/blockdev.h b/include/sysemu/blockdev.h
> index 80f768d..10719d5 100644
> --- a/include/sysemu/blockdev.h
> +++ b/include/sysemu/blockdev.h
> @@ -46,10 +46,13 @@ struct DriveInfo {
>      QTAILQ_ENTRY(DriveInfo) next;
>  };
>  
> +void override_max_devs(BlockInterfaceType type, int max_devs);
> +
>  DriveInfo *drive_get(BlockInterfaceType type, int bus, int unit);
>  bool drive_check_orphaned(void);
>  DriveInfo *drive_get_by_index(BlockInterfaceType type, int index);
>  int drive_get_max_bus(BlockInterfaceType type);
> +int if_get_max_devs(BlockInterfaceType type);
>  DriveInfo *drive_get_next(BlockInterfaceType type);
>  DriveInfo *drive_get_by_blockdev(BlockDriverState *bs);

  reply	other threads:[~2014-09-24 14:10 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-09-23 16:47 [Qemu-devel] [PATCH 0/6] Q35: Implement -cdrom/-hda sugar John Snow
2014-09-23 16:48 ` [Qemu-devel] [PATCH 1/6] blockdev: Orphaned drive search John Snow
2014-09-24 14:06   ` Markus Armbruster
2014-09-24 22:36     ` John Snow
2014-09-23 16:48 ` [Qemu-devel] [PATCH 2/6] blockdev: Allow overriding if_max_dev property John Snow
2014-09-24 14:10   ` Markus Armbruster [this message]
2014-09-23 16:48 ` [Qemu-devel] [PATCH 3/6] pc/vl: Add units-per-default-bus property John Snow
2014-09-24 14:25   ` Markus Armbruster
2014-09-23 16:48 ` [Qemu-devel] [PATCH 4/6] ide: Update ide_drive_get to be HBA agnostic John Snow
2014-09-24 14:35   ` Markus Armbruster
2014-09-24 16:49     ` John Snow
2014-09-25  6:13       ` Markus Armbruster
2014-09-26 16:34         ` John Snow
2014-09-27  8:41           ` Markus Armbruster
2014-09-23 16:48 ` [Qemu-devel] [PATCH 5/6] qtest/bios-tables: Correct Q35 command line John Snow
2014-09-23 16:48 ` [Qemu-devel] [PATCH 6/6] q35/ahci: Pick up -cdrom and -hda options John Snow
2014-09-24 15:08   ` Markus Armbruster
2014-09-24 15:30     ` Markus Armbruster
2014-09-24 15:32 ` [Qemu-devel] [PATCH 0/6] Q35: Implement -cdrom/-hda sugar Markus Armbruster

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87vbodp0s9.fsf@blackfin.pond.sub.org \
    --to=armbru@redhat.com \
    --cc=jsnow@redhat.com \
    --cc=kwolf@redhat.com \
    --cc=mst@redhat.com \
    --cc=qemu-devel@nongnu.org \
    --cc=stefanha@redhat.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.