From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54492) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1evLrw-00060M-BU for qemu-devel@nongnu.org; Mon, 12 Mar 2018 07:43:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1evLrv-0001ds-E5 for qemu-devel@nongnu.org; Mon, 12 Mar 2018 07:43:56 -0400 Date: Mon, 12 Mar 2018 12:43:47 +0100 From: Kevin Wolf Message-ID: <20180312114347.GA31537@localhost.localdomain> References: <20180309172713.26318-1-kwolf@redhat.com> <20180309172713.26318-2-kwolf@redhat.com> <20180312113526.GH3493@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline In-Reply-To: <20180312113526.GH3493@redhat.com> Content-Transfer-Encoding: quoted-printable Subject: Re: [Qemu-devel] [PATCH 1/6] luks: Separate image file creation from formatting List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Daniel =?iso-8859-1?Q?P=2E_Berrang=E9?= Cc: qemu-block@nongnu.org, mreitz@redhat.com, eblake@redhat.com, qemu-devel@nongnu.org Am 12.03.2018 um 12:35 hat Daniel P. Berrang=E9 geschrieben: > On Fri, Mar 09, 2018 at 06:27:08PM +0100, Kevin Wolf wrote: > > The crypto driver used to create the image file in a callback from th= e > > crypto subsystem. If we want to implement .bdrv_co_create, this needs= to > > go away because that callback will get a reference to an already > > existing block node. > >=20 > > Move the image file creation to block_crypto_create_generic(). > >=20 > > Signed-off-by: Kevin Wolf > > --- > > block/crypto.c | 37 +++++++++++++++++-------------------- > > 1 file changed, 17 insertions(+), 20 deletions(-) > >=20 > > diff --git a/block/crypto.c b/block/crypto.c > > index e6095e7807..77871640cc 100644 > > --- a/block/crypto.c > > +++ b/block/crypto.c > > @@ -71,8 +71,6 @@ static ssize_t block_crypto_read_func(QCryptoBlock = *block, > > =20 > > =20 > > struct BlockCryptoCreateData { > > - const char *filename; > > - QemuOpts *opts; > > BlockBackend *blk; > > uint64_t size; > > }; > > @@ -103,27 +101,13 @@ static ssize_t block_crypto_init_func(QCryptoBl= ock *block, > > Error **errp) > > { > > struct BlockCryptoCreateData *data =3D opaque; > > - int ret; > > =20 > > /* User provided size should reflect amount of space made > > * available to the guest, so we must take account of that > > * which will be used by the crypto header > > */ > > - data->size +=3D headerlen; > > - > > - qemu_opt_set_number(data->opts, BLOCK_OPT_SIZE, data->size, &err= or_abort); > > - ret =3D bdrv_create_file(data->filename, data->opts, errp); > > - if (ret < 0) { > > - return -1; > > - } > > - > > - data->blk =3D blk_new_open(data->filename, NULL, NULL, > > - BDRV_O_RDWR | BDRV_O_PROTOCOL, errp); > > - if (!data->blk) { > > - return -1; > > - } > > - > > - return 0; > > + return blk_truncate(data->blk, data->size + headerlen, PREALLOC_= MODE_OFF, > > + errp); > > } >=20 > I wonder if we should pass in the value of the PREALLOC_MODE from the > block_crypto_create_generic() function via BlockCryptoCreateData, so > that we honour it. By using PREALLOC_MODE_OFF here, all LUKS volumes > created with PREALLOC_MODE_FULL are going to have several MB of > unallocated extents at the end of the file. That would be an easy way to implement preallocation support. But you can't create LUKS volumes with PREALLOC_MODE_FULL today because it doesn't support preallocation at all (there's no option for it in &block_crypto_create_opts_luks), so implementing that is matter for a different patch. Kevin