]> git.ipfire.org Git - thirdparty/qemu.git/commitdiff
block: Emit modules in bdrv_iterate_format()
authorMax Reitz <mreitz@redhat.com>
Wed, 12 Oct 2016 20:49:06 +0000 (22:49 +0200)
committerMax Reitz <mreitz@redhat.com>
Fri, 11 Nov 2016 14:56:22 +0000 (15:56 +0100)
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 <mreitz@redhat.com>
Message-id: 20161012204907.25941-3-mreitz@redhat.com
Reviewed-by: Eric Blake <eblake@redhat.com>
Signed-off-by: Max Reitz <mreitz@redhat.com>
block.c

diff --git a/block.c b/block.c
index 67c70c10102d3c9ae5e6121af90f1886f62a6277..39ddea34111d390daffd8f75cb164fe42e2271f0 100644 (file)
--- 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++) {