From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:54915) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VPa92-0006Cu-Vs for qemu-devel@nongnu.org; Fri, 27 Sep 2013 11:39:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VPa8x-0007P3-T1 for qemu-devel@nongnu.org; Fri, 27 Sep 2013 11:39:52 -0400 Received: from mx1.redhat.com ([209.132.183.28]:24906) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VPa8x-0007Oy-Kv for qemu-devel@nongnu.org; Fri, 27 Sep 2013 11:39:47 -0400 From: Kevin Wolf Date: Fri, 27 Sep 2013 17:39:10 +0200 Message-Id: <1380296370-14523-11-git-send-email-kwolf@redhat.com> In-Reply-To: <1380296370-14523-1-git-send-email-kwolf@redhat.com> References: <1380296370-14523-1-git-send-email-kwolf@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Subject: [Qemu-devel] [PULL 10/30] block: introduce BlockDriver.bdrv_needs_filename to enable some drivers. List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: anthony@codemonkey.ws Cc: kwolf@redhat.com, qemu-devel@nongnu.org From: Beno=C3=AEt Canet Some drivers will have driver specifics options but no filename. This new bool allow the block layer to treat them correctly. The .bdrv_needs_filename is set in drivers not having .bdrv_parse_filenam= e and not having .bdrv_open. The first exception to this rule will be the quorum driver. Signed-off-by: Benoit Canet Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf --- block.c | 4 ++-- block/gluster.c | 4 ++++ block/iscsi.c | 1 + block/raw-posix.c | 5 +++++ block/raw-win32.c | 2 ++ block/rbd.c | 1 + block/sheepdog.c | 3 +++ include/block/block_int.h | 6 ++++++ 8 files changed, 24 insertions(+), 2 deletions(-) diff --git a/block.c b/block.c index 3366017..4a98250 100644 --- a/block.c +++ b/block.c @@ -792,7 +792,7 @@ static int bdrv_open_common(BlockDriverState *bs, Blo= ckDriverState *file, /* Open the image, either directly or using a protocol */ if (drv->bdrv_file_open) { assert(file =3D=3D NULL); - assert(drv->bdrv_parse_filename || filename !=3D NULL); + assert(!drv->bdrv_needs_filename || filename !=3D NULL); ret =3D drv->bdrv_file_open(bs, options, open_flags, &local_err)= ; } else { if (file =3D=3D NULL) { @@ -911,7 +911,7 @@ int bdrv_file_open(BlockDriverState **pbs, const char= *filename, goto fail; } qdict_del(options, "filename"); - } else if (!drv->bdrv_parse_filename && !filename) { + } else if (drv->bdrv_needs_filename && !filename) { error_setg(errp, "The '%s' block driver requires a file name", drv->format_name); ret =3D -EINVAL; diff --git a/block/gluster.c b/block/gluster.c index 256de10..877686a 100644 --- a/block/gluster.c +++ b/block/gluster.c @@ -611,6 +611,7 @@ static BlockDriver bdrv_gluster =3D { .format_name =3D "gluster", .protocol_name =3D "gluster", .instance_size =3D sizeof(BDRVGlusterState), + .bdrv_needs_filename =3D true, .bdrv_file_open =3D qemu_gluster_open, .bdrv_close =3D qemu_gluster_close, .bdrv_create =3D qemu_gluster_create, @@ -631,6 +632,7 @@ static BlockDriver bdrv_gluster_tcp =3D { .format_name =3D "gluster", .protocol_name =3D "gluster+tcp", .instance_size =3D sizeof(BDRVGlusterState), + .bdrv_needs_filename =3D true, .bdrv_file_open =3D qemu_gluster_open, .bdrv_close =3D qemu_gluster_close, .bdrv_create =3D qemu_gluster_create, @@ -651,6 +653,7 @@ static BlockDriver bdrv_gluster_unix =3D { .format_name =3D "gluster", .protocol_name =3D "gluster+unix", .instance_size =3D sizeof(BDRVGlusterState), + .bdrv_needs_filename =3D true, .bdrv_file_open =3D qemu_gluster_open, .bdrv_close =3D qemu_gluster_close, .bdrv_create =3D qemu_gluster_create, @@ -671,6 +674,7 @@ static BlockDriver bdrv_gluster_rdma =3D { .format_name =3D "gluster", .protocol_name =3D "gluster+rdma", .instance_size =3D sizeof(BDRVGlusterState), + .bdrv_needs_filename =3D true, .bdrv_file_open =3D qemu_gluster_open, .bdrv_close =3D qemu_gluster_close, .bdrv_create =3D qemu_gluster_create, diff --git a/block/iscsi.c b/block/iscsi.c index 4460382..6152ef1 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -1520,6 +1520,7 @@ static BlockDriver bdrv_iscsi =3D { .protocol_name =3D "iscsi", =20 .instance_size =3D sizeof(IscsiLun), + .bdrv_needs_filename =3D true, .bdrv_file_open =3D iscsi_open, .bdrv_close =3D iscsi_close, .bdrv_create =3D iscsi_create, diff --git a/block/raw-posix.c b/block/raw-posix.c index 3ee5b62..f7f102d 100644 --- a/block/raw-posix.c +++ b/block/raw-posix.c @@ -1200,6 +1200,7 @@ static BlockDriver bdrv_file =3D { .format_name =3D "file", .protocol_name =3D "file", .instance_size =3D sizeof(BDRVRawState), + .bdrv_needs_filename =3D true, .bdrv_probe =3D NULL, /* no probe for protocols */ .bdrv_file_open =3D raw_open, .bdrv_reopen_prepare =3D raw_reopen_prepare, @@ -1542,6 +1543,7 @@ static BlockDriver bdrv_host_device =3D { .format_name =3D "host_device", .protocol_name =3D "host_device", .instance_size =3D sizeof(BDRVRawState), + .bdrv_needs_filename =3D true, .bdrv_probe_device =3D hdev_probe_device, .bdrv_file_open =3D hdev_open, .bdrv_close =3D raw_close, @@ -1667,6 +1669,7 @@ static BlockDriver bdrv_host_floppy =3D { .format_name =3D "host_floppy", .protocol_name =3D "host_floppy", .instance_size =3D sizeof(BDRVRawState), + .bdrv_needs_filename =3D true, .bdrv_probe_device =3D floppy_probe_device, .bdrv_file_open =3D floppy_open, .bdrv_close =3D raw_close, @@ -1769,6 +1772,7 @@ static BlockDriver bdrv_host_cdrom =3D { .format_name =3D "host_cdrom", .protocol_name =3D "host_cdrom", .instance_size =3D sizeof(BDRVRawState), + .bdrv_needs_filename =3D true, .bdrv_probe_device =3D cdrom_probe_device, .bdrv_file_open =3D cdrom_open, .bdrv_close =3D raw_close, @@ -1890,6 +1894,7 @@ static BlockDriver bdrv_host_cdrom =3D { .format_name =3D "host_cdrom", .protocol_name =3D "host_cdrom", .instance_size =3D sizeof(BDRVRawState), + .bdrv_needs_filename =3D true, .bdrv_probe_device =3D cdrom_probe_device, .bdrv_file_open =3D cdrom_open, .bdrv_close =3D raw_close, diff --git a/block/raw-win32.c b/block/raw-win32.c index 1e7651b..6ef320f 100644 --- a/block/raw-win32.c +++ b/block/raw-win32.c @@ -459,6 +459,7 @@ static BlockDriver bdrv_file =3D { .format_name =3D "file", .protocol_name =3D "file", .instance_size =3D sizeof(BDRVRawState), + .bdrv_needs_filename =3D true, .bdrv_file_open =3D raw_open, .bdrv_close =3D raw_close, .bdrv_create =3D raw_create, @@ -601,6 +602,7 @@ static BlockDriver bdrv_host_device =3D { .format_name =3D "host_device", .protocol_name =3D "host_device", .instance_size =3D sizeof(BDRVRawState), + .bdrv_needs_filename =3D true, .bdrv_probe_device =3D hdev_probe_device, .bdrv_file_open =3D hdev_open, .bdrv_close =3D raw_close, diff --git a/block/rbd.c b/block/rbd.c index 11086c3..f6d3237 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -1002,6 +1002,7 @@ static QEMUOptionParameter qemu_rbd_create_options[= ] =3D { static BlockDriver bdrv_rbd =3D { .format_name =3D "rbd", .instance_size =3D sizeof(BDRVRBDState), + .bdrv_needs_filename =3D true, .bdrv_file_open =3D qemu_rbd_open, .bdrv_close =3D qemu_rbd_close, .bdrv_create =3D qemu_rbd_create, diff --git a/block/sheepdog.c b/block/sheepdog.c index 38fb629..5f81c93 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -2338,6 +2338,7 @@ static BlockDriver bdrv_sheepdog =3D { .format_name =3D "sheepdog", .protocol_name =3D "sheepdog", .instance_size =3D sizeof(BDRVSheepdogState), + .bdrv_needs_filename =3D true, .bdrv_file_open =3D sd_open, .bdrv_close =3D sd_close, .bdrv_create =3D sd_create, @@ -2366,6 +2367,7 @@ static BlockDriver bdrv_sheepdog_tcp =3D { .format_name =3D "sheepdog", .protocol_name =3D "sheepdog+tcp", .instance_size =3D sizeof(BDRVSheepdogState), + .bdrv_needs_filename =3D true, .bdrv_file_open =3D sd_open, .bdrv_close =3D sd_close, .bdrv_create =3D sd_create, @@ -2394,6 +2396,7 @@ static BlockDriver bdrv_sheepdog_unix =3D { .format_name =3D "sheepdog", .protocol_name =3D "sheepdog+unix", .instance_size =3D sizeof(BDRVSheepdogState), + .bdrv_needs_filename =3D true, .bdrv_file_open =3D sd_open, .bdrv_close =3D sd_close, .bdrv_create =3D sd_create, diff --git a/include/block/block_int.h b/include/block/block_int.h index 3eeb6fe..211087a 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -73,6 +73,12 @@ struct BlockDriver { /* Any driver implementing this callback is expected to be able to h= andle * NULL file names in its .bdrv_open() implementation */ void (*bdrv_parse_filename)(const char *filename, QDict *options, Er= ror **errp); + /* Drivers not implementing bdrv_parse_filename nor bdrv_open should= have + * this field set to true, except ones that are defined only by thei= r + * child's bs. + * An example of the last type will be the quorum block driver. + */ + bool bdrv_needs_filename; =20 /* For handling image reopen for split or non-split files */ int (*bdrv_reopen_prepare)(BDRVReopenState *reopen_state, --=20 1.8.1.4