From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:45496) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1aiUFP-0008PS-Vs for qemu-devel@nongnu.org; Tue, 22 Mar 2016 17:53:56 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1aiUFO-0005EX-Rv for qemu-devel@nongnu.org; Tue, 22 Mar 2016 17:53:55 -0400 References: <1458660792-3035-1-git-send-email-kwolf@redhat.com> <1458660792-3035-4-git-send-email-kwolf@redhat.com> From: Eric Blake Message-ID: <56F1BEEE.5010307@redhat.com> Date: Tue, 22 Mar 2016 15:53:50 -0600 MIME-Version: 1.0 In-Reply-To: <1458660792-3035-4-git-send-email-kwolf@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="xDeT2eP6suEQXTvSpaoS1utXpDihA6JJD" Subject: Re: [Qemu-devel] [PATCH 03/12] block: Introduce BlockBackendPublic List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Kevin Wolf , qemu-block@nongnu.org Cc: berto@igalia.com, qemu-devel@nongnu.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --xDeT2eP6suEQXTvSpaoS1utXpDihA6JJD Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable 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. >=20 > Signed-off-by: Kevin Wolf > --- > block/block-backend.c | 17 +++++++++++++++++ > include/sysemu/block-backend.h | 9 +++++++++ > 2 files changed, 26 insertions(+) >=20 > 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_back= ends */ > + BlockBackendPublic public; Any reason to not put the public struct at offset 0? > + > +/* > + * 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 co= ntains > + * fields that must be public. This is in particular for QLIST_ENTRY()= and > + * friends so that BlockBackends can be kept in lists outside block-ba= ckend.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? --=20 Eric Blake eblake redhat com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --xDeT2eP6suEQXTvSpaoS1utXpDihA6JJD Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iQEcBAEBCAAGBQJW8b7uAAoJEKeha0olJ0NqF/0H/1fzo0hBHfP43SN2LcjSQk3J v/OyWNKWQu42WqlNgQ6wraWldDUojfeJzDSvzK3ZQtUVkkkHQtv5193mMCBMVuSC WZQ31a4zNrNARjUaaH1E2tCZGsCxpPC4QhvtSsJDd2agvjeKPigtWTCWv9MhcS29 vd3AssQw+dOytaUTNGlNO3cTjpGKlkKFpEjV8NrAxR7Izgay+XxvZKqXs3v/WY3D Ofcrs5oQUUtum8maMs3TDxo7Mf3TypzmVnRmMGa0LAwup3V06AWeedHmmfIgO4DP gUSFcG/cQKHjkYGzhP8/OhXWQPEn9mFgQDlgJz9UdAW+FZfjUPtexBQLtAQeC8U= =x5Cu -----END PGP SIGNATURE----- --xDeT2eP6suEQXTvSpaoS1utXpDihA6JJD--