On 8/13/20 11:29 AM, Kevin Wolf wrote:
With this change, NBD exports are only created through the BlockExport
interface any more. This allows us finally to move things from the NBD

s/are only/are now only/; s/any more //

layer to the BlockExport layer if they make sense for other export
types, too.

blk_exp_add() returns only a weak reference, so the explicit
nbd_export_put() goes away.

Feel free to rename get/put to ref/unref in your series if that makes life any easier.


Signed-off-by: Kevin Wolf <kw...@redhat.com>
---

@@ -1050,9 +1050,27 @@ int main(int argc, char **argv)
bs->detect_zeroes = detect_zeroes; - export = nbd_export_new(bs, export_name,
-                            export_description, bitmap, readonly, shared > 1,
-                            writethrough, &error_fatal);
+    nbd_server_is_qemu_nbd(true);

Feels a bit like a backdoor hack, but gets the job done (and as you said, we had quite an IRC conversation about what it would take to get socket activation working, so leaving that in qemu-nbd for now is reasonable for the first patch series).

+
+    export_opts = g_new(BlockExportOptions, 1);
+    *export_opts = (BlockExportOptions) {
+        .type               = BLOCK_EXPORT_TYPE_NBD,
+        .has_writethrough   = true,
+        .writethrough       = writethrough,
+        .u.nbd = {
+            .device             = g_strdup(bdrv_get_node_name(bs)),
+            .has_name           = true,
+            .name               = g_strdup(export_name),
+            .has_description    = !!export_description,
+            .description        = g_strdup(export_description),
+            .has_writable       = true,
+            .writable           = !readonly,
+            .has_bitmap         = !!bitmap,
+            .bitmap             = g_strdup(bitmap),
+        },
+    };
+    blk_exp_add(export_opts, &error_fatal);
+    qapi_free_BlockExportOptions(export_opts);

Looks sane.

--
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org


Reply via email to