Received: from eggs.gnu.org ([2001:4830:134:3::10]:59496) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c5F6x-0006Rx-Kf for qemu-devel@nongnu.org; Fri, 11 Nov 2016 11:55:32 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c5F6w-0002fd-RU for qemu-devel@nongnu.org; Fri, 11 Nov 2016 11:55:31 -0500 From: Kevin Wolf Date: Fri, 11 Nov 2016 17:55:08 +0100 Message-Id: <1478883311-24052-10-git-send-email-kwolf@redhat.com> In-Reply-To: <1478883311-24052-1-git-send-email-kwolf@redhat.com> References: <1478883311-24052-1-git-send-email-kwolf@redhat.com> Subject: [Qemu-devel] [PULL 09/12] block: Emit modules in bdrv_iterate_format() List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-block@nongnu.org Cc: kwolf@redhat.com, stefanha@redhat.com, qemu-devel@nongnu.org From: Max Reitz Some block drivers may not be loaded yet, but qemu supports them nonetheless. bdrv_iterate_format() should report them, too. Signed-off-by: Max Reitz Message-id: 20161012204907.25941-3-mreitz@redhat.com Reviewed-by: Eric Blake Signed-off-by: Max Reitz --- block.c | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/block.c b/block.c index 67c70c1..39ddea3 100644 --- a/block.c +++ b/block.c @@ -2822,6 +2822,24 @@ void bdrv_iterate_format(void (*it)(void *opaque, const char *name), } } + for (i = 0; i < (int)ARRAY_SIZE(block_driver_modules); i++) { + const char *format_name = block_driver_modules[i].format_name; + + if (format_name) { + bool found = false; + int j = count; + + while (formats && j && !found) { + found = !strcmp(formats[--j], format_name); + } + + if (!found) { + formats = g_renew(const char *, formats, count + 1); + formats[count++] = format_name; + } + } + } + qsort(formats, count, sizeof(formats[0]), qsort_strcmp); for (i = 0; i < count; i++) { -- 1.8.3.1