Skip to content

Commit 2fbad1f

Browse files
XanClicmdroth
authored andcommitted
qemu-img: 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 for the target image in qemu-img convert, which is important so that the create_opts pointer in img_convert() 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 f75613c) Signed-off-by: Michael Roth <[email protected]>
1 parent dee2848 commit 2fbad1f

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

qemu-img.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1378,6 +1378,20 @@ static int img_convert(int argc, char **argv)
13781378
goto out;
13791379
}
13801380

1381+
if (!drv->create_opts) {
1382+
error_report("Format driver '%s' does not support image creation",
1383+
drv->format_name);
1384+
ret = -1;
1385+
goto out;
1386+
}
1387+
1388+
if (!proto_drv->create_opts) {
1389+
error_report("Protocol driver '%s' does not support image creation",
1390+
proto_drv->format_name);
1391+
ret = -1;
1392+
goto out;
1393+
}
1394+
13811395
create_opts = qemu_opts_append(create_opts, drv->create_opts);
13821396
create_opts = qemu_opts_append(create_opts, proto_drv->create_opts);
13831397

0 commit comments

Comments
 (0)