Skip to content

Commit ad0983b

Browse files
XanClicmdroth
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: [email protected] Signed-off-by: Max Reitz <[email protected]> Reviewed-by: Kevin Wolf <[email protected]> Signed-off-by: Kevin Wolf <[email protected]> (cherry picked from commit fd75280) Signed-off-by: Michael Roth <[email protected]>
1 parent b3729b2 commit ad0983b

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
@@ -401,6 +401,19 @@ static int nfs_file_open(BlockDriverState *bs, QDict *options, int flags,
401401
return 0;
402402
}
403403

404+
static QemuOptsList nfs_create_opts = {
405+
.name = "nfs-create-opts",
406+
.head = QTAILQ_HEAD_INITIALIZER(nfs_create_opts.head),
407+
.desc = {
408+
{
409+
.name = BLOCK_OPT_SIZE,
410+
.type = QEMU_OPT_SIZE,
411+
.help = "Virtual disk size"
412+
},
413+
{ /* end of list */ }
414+
}
415+
};
416+
404417
static int nfs_file_create(const char *url, QemuOpts *opts, Error **errp)
405418
{
406419
int ret = 0;
@@ -461,6 +474,8 @@ static BlockDriver bdrv_nfs = {
461474

462475
.instance_size = sizeof(NFSClient),
463476
.bdrv_needs_filename = true,
477+
.create_opts = &nfs_create_opts,
478+
464479
.bdrv_has_zero_init = nfs_has_zero_init,
465480
.bdrv_get_allocated_file_size = nfs_get_allocated_file_size,
466481
.bdrv_truncate = nfs_file_truncate,

0 commit comments

Comments
 (0)