From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:42098) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TE5Dq-00005a-QM for qemu-devel@nongnu.org; Tue, 18 Sep 2012 17:20:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1TE5Dp-0007YY-Bs for qemu-devel@nongnu.org; Tue, 18 Sep 2012 17:20:46 -0400 Received: from mx1.redhat.com ([209.132.183.28]:11377) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1TE5Dp-0007YS-24 for qemu-devel@nongnu.org; Tue, 18 Sep 2012 17:20:45 -0400 Message-ID: <5058E5A4.5000704@redhat.com> Date: Tue, 18 Sep 2012 15:20:36 -0600 From: Eric Blake MIME-Version: 1.0 References: <4feab4ab212834c55707c0690d8efcb4f3662b1c.1347993885.git.jcody@redhat.com> In-Reply-To: <4feab4ab212834c55707c0690d8efcb4f3662b1c.1347993885.git.jcody@redhat.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enigB2F845A6C4C0A81DA42AF1F3" Subject: Re: [Qemu-devel] [PATCH v3 09/19] block: raw-posix image file reopen List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Jeff Cody Cc: kwolf@redhat.com, pbonzini@redhat.com, stefanha@gmail.com, qemu-devel@nongnu.org, supriyak@linux.vnet.ibm.com This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigB2F845A6C4C0A81DA42AF1F3 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 09/18/2012 12:53 PM, Jeff Cody wrote: > This is derived from the Supriya Kannery's reopen patches. >=20 > This contains the raw-posix driver changes for the bdrv_reopen_* > functions. All changes are staged into a temporary scratch buffer > during the prepare() stage, and copied over to the live structure > during commit(). Upon abort(), all changes are abandoned, and the > live structures are unmodified. >=20 > The _prepare() will create an extra fd - either by means of a dup, > if possible, or opening a new fd if not (for instance, access > control changes). Upon _commit(), the original fd is closed and > the new fd is used. Upon _abort(), the duplicate/new fd is closed. >=20 > Signed-off-by: Jeff Cody > --- > block/raw-posix.c | 99 +++++++++++++++++++++++++++++++++++++++++++++++= ++++++++ > 1 file changed, 99 insertions(+) >=20 > diff --git a/block/raw-posix.c b/block/raw-posix.c > index 6bf5480..edd1eca 100644 > --- a/block/raw-posix.c > +++ b/block/raw-posix.c > @@ -138,6 +138,15 @@ typedef struct BDRVRawState { > #endif > } BDRVRawState; > =20 > +typedef struct BDRVRawReopenState { > + int fd; > + int open_flags; > +#ifdef CONFIG_LINUX_AIO > + int use_aio; > + void *aio_ctx; > +#endif These members are conditional... > +static int raw_reopen_prepare(BDRVReopenState *state, > + BlockReopenQueue *queue, Error **errp) > +{ > + BDRVRawState *s; > + BDRVRawReopenState *raw_s; > + int ret =3D 0; > + > + assert(state !=3D NULL); > + assert(state->bs !=3D NULL); > + > + s =3D state->bs->opaque; > + > + state->opaque =3D g_malloc0(sizeof(BDRVRawReopenState)); > + raw_s =3D state->opaque; > + raw_s->use_aio =3D s->use_aio; > + raw_s->aio_ctx =3D s->aio_ctx; =2E..but you are unconditionally assigning into them. This will introduc= e compile failures on other platforms. > + if ((raw_s->open_flags & ~fcntl_flags) =3D=3D (s->open_flags & ~fc= ntl_flags)) { > + /* dup the original fd */ > + /* TODO: use qemu fcntl wrapper */ > + raw_s->fd =3D fcntl(s->fd, F_DUPFD_CLOEXEC, 0); F_DUPFD_CLOEXEC is not defined everywhere yet; you still need to address your TODO. > + > + /* If we cannot use fctnl, or fcntl failed, fall back to qemu_open= () */ s/fctnl/fcntl/ > +static void raw_reopen_commit(BDRVReopenState *state) > +{ > + BDRVRawReopenState *raw_s =3D state->opaque; > + BDRVRawState *s =3D state->bs->opaque; > + > + s->open_flags =3D raw_s->open_flags; > + > + qemu_close(s->fd); > + s->fd =3D raw_s->fd; > + s->use_aio =3D raw_s->use_aio; > + s->aio_ctx =3D raw_s->aio_ctx; Again, more unconditional use of conditional members. --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enigB2F845A6C4C0A81DA42AF1F3 Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.12 (GNU/Linux) Comment: Public key at http://people.redhat.com/eblake/eblake.gpg Comment: Using GnuPG with Mozilla - http://www.enigmail.net/ iQEcBAEBCAAGBQJQWOWlAAoJEKeha0olJ0Nq8oAH/2eE0xmU5TxZEMlBJE377xLV UF4d+TLNswZ6mKhCpwGVGCcoFHtAKIfoJDEbmcAz69AZkt/gM2fIperH09ilbqD6 x/u+HTX+MoJjttKT7RGP5iEkuASwORiNF9anA5O4RMfdWW1CLiCaahVE8FYqRoaA zhPwB/wgVNgNNOmk41D7P/NAN5hI9LDNoOj6iOWyqGBt86vQr+buJa5mk+A7Jcto Q1JbsMNrZKPaYH/pw3zGoP/HllCnwHINo5UUtjGRtkMTWL/mFYwpyCr/Tx6ZKP5W goaeb+qrAdQEw86QiA7qI+aN2KAhdM3bPzxAolHKOJ4p/Akm/2hlKl9amtfgwl0= =6E0j -----END PGP SIGNATURE----- --------------enigB2F845A6C4C0A81DA42AF1F3--