From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:56915) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sfejr-0005c8-8V for qemu-devel@nongnu.org; Fri, 15 Jun 2012 18:11:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Sfejp-0005We-AK for qemu-devel@nongnu.org; Fri, 15 Jun 2012 18:11:30 -0400 Received: from mx1.redhat.com ([209.132.183.28]:50351) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Sfejp-0005WO-1o for qemu-devel@nongnu.org; Fri, 15 Jun 2012 18:11:29 -0400 Message-ID: <4FDBB309.1050704@redhat.com> Date: Fri, 15 Jun 2012 16:11:21 -0600 From: Eric Blake MIME-Version: 1.0 References: <20120615204648.9853.1225.sendpatchset@skannery.in.ibm.com> <20120615204800.9853.19740.sendpatchset@skannery.in.ibm.com> In-Reply-To: <20120615204800.9853.19740.sendpatchset@skannery.in.ibm.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enigAA61273C1A369A17722B697D" Subject: Re: [Qemu-devel] [v1 Patch 5/10]Qemu: raw-posix image file reopen List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Supriya Kannery Cc: Kevin Wolf , Shrinidhi Joshi , Stefan Hajnoczi , Jeff Cody , qemu-devel@nongnu.org, Luiz Capitulino , Christoph Hellwig This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enigAA61273C1A369A17722B697D Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 06/15/2012 02:48 PM, Supriya Kannery wrote: > raw-posix driver changes for bdrv_reopen_xx functions to > safely reopen image files. Reopening of image files while=20 > changing hostcache dynamically is handled here. >=20 > Signed-off-by: Supriya Kannery >=20 > =20 > +static int raw_reopen_prepare(BlockDriverState *bs, BDRVReopenState **= prs, > + int flags) > +{ > + BDRVRawReopenState *raw_rs =3D g_malloc0(sizeof(BDRVRawReopenState= )); > + BDRVRawState *s =3D bs->opaque; > + int ret =3D 0; > + > + raw_rs->reopen_state.bs =3D bs; > + > + /* stash state before reopen */ > + raw_rs->stash_s =3D g_malloc0(sizeof(BDRVRawState)); > +/* memcpy(raw_rs->stash_s, s, sizeof(BDRVRawState)); */ Why the comment? > + raw_stash_state(raw_rs->stash_s, s); > + s->fd =3D dup(raw_rs->stash_s->fd); Needs to handle O_CLOEXEC open flag, which means using fcntl(F_DUPFD_CLOEXEC) when available for atomic support, and a fallback to fcntl(F_GETFD/F_SETFD) if not. > + > + *prs =3D &(raw_rs->reopen_state); > + > + /* Flags that can be set using fcntl */ > + int fcntl_flags =3D BDRV_O_NOCACHE; > + > + if ((bs->open_flags & ~fcntl_flags) =3D=3D (flags & ~fcntl_flags))= { > + if ((flags & BDRV_O_NOCACHE)) { > + s->open_flags |=3D O_DIRECT; > + } else { > + s->open_flags &=3D ~O_DIRECT; > + } > + ret =3D fcntl_setfl(s->fd, s->open_flags); > + } else { > + > + /* close and reopen using new flags */ > + bs->drv->bdrv_close(bs); > + ret =3D bs->drv->bdrv_file_open(bs, bs->filename, flags); Is this a case where Paolo's proposed bdrv_swap command would be useful? > + /* revert to stashed state */ > + if (s->fd !=3D -1) { > + close(s->fd); > + } > +/* memcpy(s, raw_rs->stash_s, sizeof(BDRVRawState)); */ Why the comment? --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enigAA61273C1A369A17722B697D 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://enigmail.mozdev.org/ iQEcBAEBCAAGBQJP27MJAAoJEKeha0olJ0NqVKkH/iKc8EpHpx/zCsyk6mgspeXw J2uMy+Odg18YzaTBkAm1CzVnlx2cUDl4pJPo0V74j7HcdrWOvkezZ8rnq1/SSwsw 5aORq25Y119H4FRLVUUNa/00VVw2kPjNydyV7tTUnORWIbJjh7dR3c68ewPEkyuM a+thJ3glTuj6dUIKudYdJxDsieOnMDDVmQeJjIuXoox1WN4oMcIg773nsYkCdg2W f2fsmv74P36olZ5GlpKhYHAxLc+T/FDOEItytmWcK2SHjrRrfoBmKsxBIwSf4Ysw AJtEO+C9/tBRik5q7c/+kEIK2ea/7DiwHadaqhbmkgSg1cqkst3ZD4HQW84gM7A= =jNxW -----END PGP SIGNATURE----- --------------enigAA61273C1A369A17722B697D--