From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([208.118.235.92]:39227) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SfebJ-0004SW-10 for qemu-devel@nongnu.org; Fri, 15 Jun 2012 18:02:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SfebH-00035a-0b for qemu-devel@nongnu.org; Fri, 15 Jun 2012 18:02:40 -0400 Received: from mx1.redhat.com ([209.132.183.28]:8902) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SfebG-00035M-OH for qemu-devel@nongnu.org; Fri, 15 Jun 2012 18:02:38 -0400 Message-ID: <4FDBB0F6.6000407@redhat.com> Date: Fri, 15 Jun 2012 16:02:30 -0600 From: Eric Blake MIME-Version: 1.0 References: <20120615204648.9853.1225.sendpatchset@skannery.in.ibm.com> <20120615204744.9853.62830.sendpatchset@skannery.in.ibm.com> In-Reply-To: <20120615204744.9853.62830.sendpatchset@skannery.in.ibm.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="------------enigCFE6200C16F66C9486220079" Subject: Re: [Qemu-devel] [v1 Patch 4/10]Qemu: Framework for reopening image files safely 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) --------------enigCFE6200C16F66C9486220079 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 06/15/2012 02:47 PM, Supriya Kannery wrote: > Struct BDRVReopenState along with three reopen related functions > introduced for handling reopening of images safely. This can be > extended by each of the block drivers to reopen respective > image files. >=20 > Signed-off-by: Supriya Kannery >=20 > + /* Use driver specific reopen() if available */ > + if (drv->bdrv_reopen_prepare) { > + ret =3D bdrv_reopen_prepare(bs, &reopen_state, bdrv_flags); > + if (ret < 0) { > + bdrv_reopen_abort(bs, reopen_state); > + qerror_report(QERR_OPEN_FILE_FAILED, bs->filename); > + return ret; > + } > + > + bdrv_reopen_commit(bs, reopen_state); > + bs->open_flags =3D bdrv_flags; Good. > + > + } else { > + > + /* Try reopening the image using protocol or directly */ > + if (bs->file) { > + open_flags =3D bs->open_flags; > + drv->bdrv_close(bs); > + if (drv->bdrv_file_open) { > + ret =3D drv->bdrv_file_open(bs, bs->filename, bdrv_fla= gs); Not so good. Are we sure we can't flush all data, so that we can then attempt the open before the close, and avoid losing the original file on error? > + } else { > + ret =3D bdrv_file_open(&bs->file, bs->filename, bdrv_f= lags); > + } > + if (ret < 0) { > + /* Reopen failed. Try to open with original flags */ > + qerror_report(QERR_OPEN_FILE_FAILED, bs->filename); > + if (drv->bdrv_file_open) { > + ret =3D drv->bdrv_file_open(bs, bs->filename, open= _flags); > + } else { > + ret =3D bdrv_file_open(&bs->file, bs->filename, op= en_flags); > + } > + if (ret < 0) { > + /* Reopen failed with orig and modified flags */ > + bdrv_delete(bs->file); > + bs->drv =3D NULL; You dropped the abort() here, but now the device is silently gone. But since the error of QERR_OPEN_FILE_FAILED is the same as in the safe case, how does the management app know that things were corrupted? --=20 Eric Blake eblake@redhat.com +1-919-301-3266 Libvirt virtualization library http://libvirt.org --------------enigCFE6200C16F66C9486220079 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/ iQEcBAEBCAAGBQJP27D2AAoJEKeha0olJ0Nq6WEH/jRYjPpcCzqae9E42AHpqWC3 jHkfhwWZe9U0afu7AMM9xjwdPbnTD7i7Sl3/ZBIDdZ+4oeMB83l3aBlNrXxWWPm6 J58nzhduYoa05fw0HKFcB5TkCDdSwoDp/nEbwsejBurQ/KLBIgezVWmcrKoqPLNp DXnJbpmDhY4660i5iUpwCg5lRzjhEjIh3b5LNyEJTi1QR+6u/ZF2dPvop1KP0Sru AKu5vO1oAFznrjySYTdIhptm4W6sib/30rVX3BxsiFVYRM/bwA1QL9K6ix46ueRm 50Fq7hNpQW1jiaKORgML2irgYp+H4GwT03Ioq8HXDrFFQyfBhwNlG+UthN+CnzE= =1+4z -----END PGP SIGNATURE----- --------------enigCFE6200C16F66C9486220079--