qemu-block
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [RFC PATCH 11/22] qemu-nbd: Use blk_exp_add() to create the export


From: Eric Blake
Subject: Re: [RFC PATCH 11/22] qemu-nbd: Use blk_exp_add() to create the export
Date: Wed, 19 Aug 2020 15:35:33 -0500
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.11.0

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 <kwolf@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

[Prev in Thread] Current Thread [Next in Thread]