From: Denis V. Lunev <[email protected]> mkimg() takes megabytes, which is all its callers have needed so far. ide-test wants an image whose length is an exact multiple of its CHS geometry, 130 * 16 * 63 sectors, and that is not a whole number of megabytes. Add mkimg_bytes() and let mkimg() go through it.
Cc: John Snow <[email protected]> Cc: Thomas Huth <[email protected]> Signed-off-by: Denis V. Lunev <[email protected]> --- tests/qtest/libqtest.c | 9 +++++++-- tests/qtest/libqtest.h | 12 ++++++++++++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/tests/qtest/libqtest.c b/tests/qtest/libqtest.c index bec37c71b8..1ae004e6f3 100644 --- a/tests/qtest/libqtest.c +++ b/tests/qtest/libqtest.c @@ -2115,6 +2115,11 @@ bool have_qemu_img(void) } bool mkimg(const char *file, const char *fmt, unsigned size_mb) +{ + return mkimg_bytes(file, fmt, (uint64_t)size_mb * 1024 * 1024); +} + +bool mkimg_bytes(const char *file, const char *fmt, uint64_t size) { gchar *cli; bool ret; @@ -2133,8 +2138,8 @@ bool mkimg(const char *file, const char *fmt, unsigned size_mb) return false; } - cli = g_strdup_printf("%s create -f %s %s %uM", qemu_img_abs_path, - fmt, file, size_mb); + cli = g_strdup_printf("%s create -f %s %s %" PRIu64, qemu_img_abs_path, + fmt, file, size); ret = g_spawn_command_line_sync(cli, &out, &out2, &rc, &err); if (err || !g_spawn_check_exit_status(rc, &err)) { fprintf(stderr, "%s\n", err->message); diff --git a/tests/qtest/libqtest.h b/tests/qtest/libqtest.h index 45217fb8dc..6720ca2de2 100644 --- a/tests/qtest/libqtest.h +++ b/tests/qtest/libqtest.h @@ -1186,6 +1186,18 @@ bool have_qemu_img(void); */ bool mkimg(const char *file, const char *fmt, unsigned size_mb); +/** + * mkimg_bytes: + * @file: File name of the image that should be created + * @fmt: Format, e.g. "qcow2" or "raw" + * @size: Size of the image in bytes + * + * As mkimg(), for images whose size is not a whole number of megabytes. + * + * Returns: true if the image has been created successfully. + */ +bool mkimg_bytes(const char *file, const char *fmt, uint64_t size); + /** * qtest_verbose: * @domain: The logging domain -- 2.53.0
