qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Kevin Wolf <kwolf@redhat.com>
To: Eric Blake <eblake@redhat.com>
Cc: berto@igalia.com, qemu-devel@nongnu.org, qemu-block@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 03/12] block: Introduce BlockBackendPublic
Date: Wed, 23 Mar 2016 10:09:44 +0100	[thread overview]
Message-ID: <20160323090944.GB4126@noname.redhat.com> (raw)
In-Reply-To: <56F1BEEE.5010307@redhat.com>

[-- Attachment #1: Type: text/plain, Size: 2526 bytes --]

Am 22.03.2016 um 22:53 hat Eric Blake geschrieben:
> On 03/22/2016 09:33 AM, Kevin Wolf wrote:
> > Some features, like I/O throttling, are implemented outside
> > block-backend.c, but still want to keep BlockBackends in a list. In
> > order to avoid exposing the whole struct layout in the public header
> > file, this patch introduces an embedded public struct where list entry
> > structs can be added and a pair of functions to convert between
> > BlockBackend and BlockBackendPublic.
> > 
> > Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> > ---
> >  block/block-backend.c          | 17 +++++++++++++++++
> >  include/sysemu/block-backend.h |  9 +++++++++
> >  2 files changed, 26 insertions(+)
> > 
> > diff --git a/block/block-backend.c b/block/block-backend.c
> > index df8f717..4394950 100644
> > --- a/block/block-backend.c
> > +++ b/block/block-backend.c
> > @@ -33,6 +33,7 @@ struct BlockBackend {
> >      DriveInfo *legacy_dinfo;    /* null unless created by drive_new() */
> >      QTAILQ_ENTRY(BlockBackend) link;         /* for block_backends */
> >      QTAILQ_ENTRY(BlockBackend) monitor_link; /* for monitor_block_backends */
> > +    BlockBackendPublic public;
> 
> Any reason to not put the public struct at offset 0?

No, but also no reason to put it there. :-)

> > +
> > +/*
> > + * Returns a BlockBackend given the associated @public fields.
> > + */
> > +BlockBackend *blk_by_public(BlockBackendPublic *public)
> > +{
> > +    return container_of(public, BlockBackend, public);
> > +}
> 
> At least container_of() doesn't care, so I guess it doesn't matter.
> 
> > +/* This struct is embedded in (the private) BlockBackend struct and contains
> > + * fields that must be public. This is in particular for QLIST_ENTRY() and
> > + * friends so that BlockBackends can be kept in lists outside block-backend.c */
> > +typedef struct BlockBackendPublic {
> > +} BlockBackendPublic;
> 
> No fields?  So really all we need this for is so that we can have an
> address of a member of the larger struct, so that we can do list
> operations based on that address?

Well, a list still needs a QLIST_ENTRY, otherwise I could have directly
used BlockBackend. I just tried to keep the introduction of .public
separate from the addition of a specific list.

I think it's strictly speaking invalid C to have an empty struct, but
gcc compiles it and so I thought it should be acceptable to have one for
a single commit until something is added there.

Kevin

[-- Attachment #2: Type: application/pgp-signature, Size: 836 bytes --]

  reply	other threads:[~2016-03-23  9:10 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-22 15:33 [Qemu-devel] [PATCH 00/12] block: Move I/O throttling to BlockBackend Kevin Wolf
2016-03-22 15:33 ` [Qemu-devel] [PATCH 01/12] block: Don't disable I/O throttling on sync requests Kevin Wolf
2016-03-22 21:40   ` Eric Blake
2016-03-22 15:33 ` [Qemu-devel] [PATCH 02/12] block: Make sure throttled BDSes always have a BB Kevin Wolf
2016-03-22 21:46   ` Eric Blake
2016-03-22 15:33 ` [Qemu-devel] [PATCH 03/12] block: Introduce BlockBackendPublic Kevin Wolf
2016-03-22 21:53   ` Eric Blake
2016-03-23  9:09     ` Kevin Wolf [this message]
2016-03-23 21:35       ` Eric Blake
2016-03-24  8:06         ` Kevin Wolf
2016-03-22 15:33 ` [Qemu-devel] [PATCH 04/12] block: throttle-groups: Use BlockBackend pointers internally Kevin Wolf
2016-03-22 15:33 ` [Qemu-devel] [PATCH 05/12] block: Convert throttle_group_get_name() to BlockBackend Kevin Wolf
2016-03-22 15:33 ` [Qemu-devel] [PATCH 06/12] block: Move throttling fields from BDS to BB Kevin Wolf
2016-03-22 15:33 ` [Qemu-devel] [PATCH 07/12] block: Move actual I/O throttling to BlockBackend Kevin Wolf
2016-03-22 15:33 ` [Qemu-devel] [PATCH 08/12] block: Move I/O throttling configuration functions " Kevin Wolf
2016-03-22 15:33 ` [Qemu-devel] [PATCH 09/12] block: Introduce BdrvChild.opaque Kevin Wolf
2016-03-22 15:33 ` [Qemu-devel] [PATCH 10/12] block: Drain throttling queue with BdrvChild callback Kevin Wolf
2016-03-23 21:29   ` Paolo Bonzini
2016-03-24  8:25     ` Kevin Wolf
2016-03-24  9:32       ` Paolo Bonzini
2016-03-22 15:33 ` [Qemu-devel] [PATCH 11/12] block: Decouple throttling from BlockDriverState Kevin Wolf
2016-03-22 15:33 ` [Qemu-devel] [PATCH 12/12] block: Don't check throttled reqs in bdrv_requests_pending() Kevin Wolf
2016-03-22 21:33 ` [Qemu-devel] [PATCH 00/12] block: Move I/O throttling to BlockBackend Paolo Bonzini
2016-03-23  9:03   ` Kevin Wolf
2016-03-23  9:28     ` Paolo Bonzini
2016-03-23 10:02       ` Kevin Wolf
2016-03-23 10:05     ` Alberto Garcia

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=20160323090944.GB4126@noname.redhat.com \
    --to=kwolf@redhat.com \
    --cc=berto@igalia.com \
    --cc=eblake@redhat.com \
    --cc=qemu-block@nongnu.org \
    --cc=qemu-devel@nongnu.org \
    /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 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).