Skip to content

Commit dee2848

Browse files
XanClicmdroth
authored andcommitted
block: Check create_opts before image creation
If a driver supports image creation, it needs to set the .create_opts field. We can use that to make sure .create_opts for both drivers involved is not NULL in bdrv_img_create(), which is important so that the create_opts pointer in that function is not NULL after the qemu_opts_append() calls and when going into qemu_opts_create(). 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 c614972) Signed-off-by: Michael Roth <[email protected]>
1 parent ad0983b commit dee2848

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

block.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5528,6 +5528,18 @@ void bdrv_img_create(const char *filename, const char *fmt,
55285528
return;
55295529
}
55305530

5531+
if (!drv->create_opts) {
5532+
error_setg(errp, "Format driver '%s' does not support image creation",
5533+
drv->format_name);
5534+
return;
5535+
}
5536+
5537+
if (!proto_drv->create_opts) {
5538+
error_setg(errp, "Protocol driver '%s' does not support image creation",
5539+
proto_drv->format_name);
5540+
return;
5541+
}
5542+
55315543
create_opts = qemu_opts_append(create_opts, drv->create_opts);
55325544
create_opts = qemu_opts_append(create_opts, proto_drv->create_opts);
55335545

0 commit comments

Comments
 (0)