Skip to content

Commit fd75280

Browse files
XanClickevmw
authored andcommitted
block/nfs: Add create_opts
The nfs protocol driver is capable of creating images, but did not specify any creation options. Fix it. A way to test this issue is the following: $ qemu-img create -f nfs nfs://127.0.0.1/foo.qcow2 64M Without this patch, it segfaults. With this patch, it does not. However, this is not something that should really work; qemu-img should check whether the parameter for the -f option (and -O for convert) is indeed a format, and error out if it is not. Therefore, I am not making it an iotest. Cc: qemu-stable@nongnu.org Signed-off-by: Max Reitz <mreitz@redhat.com> Reviewed-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
1 parent 1bcb15c commit fd75280

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

block/nfs.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -409,6 +409,19 @@ static int nfs_file_open(BlockDriverState *bs, QDict *options, int flags,
409409
return ret;
410410
}
411411

412+
static QemuOptsList nfs_create_opts = {
413+
.name = "nfs-create-opts",
414+
.head = QTAILQ_HEAD_INITIALIZER(nfs_create_opts.head),
415+
.desc = {
416+
{
417+
.name = BLOCK_OPT_SIZE,
418+
.type = QEMU_OPT_SIZE,
419+
.help = "Virtual disk size"
420+
},
421+
{ /* end of list */ }
422+
}
423+
};
424+
412425
static int nfs_file_create(const char *url, QemuOpts *opts, Error **errp)
413426
{
414427
int ret = 0;
@@ -470,6 +483,8 @@ static BlockDriver bdrv_nfs = {
470483

471484
.instance_size = sizeof(NFSClient),
472485
.bdrv_needs_filename = true,
486+
.create_opts = &nfs_create_opts,
487+
473488
.bdrv_has_zero_init = nfs_has_zero_init,
474489
.bdrv_get_allocated_file_size = nfs_get_allocated_file_size,
475490
.bdrv_truncate = nfs_file_truncate,

0 commit comments

Comments
 (0)