[Qemu-devel] [RFC v2 for-2.9 09/10] squash! nbd: Tidy up blockdev-add interface

Markus Armbruster posted 10 patches 8 years, 10 months ago
There is a newer version of this series
[Qemu-devel] [RFC v2 for-2.9 09/10] squash! nbd: Tidy up blockdev-add interface
Posted by Markus Armbruster 8 years, 10 months ago
Drop backward -drive server.data.* compatibility gunk.  On squash,
replace commit message's last paragraph "Unfortunately, SocketAddress
is also visible..." by:

Unfortunately, SocketAddress is also visible in -drive since 2.8:

    -drive if=none,driver=nbd,server.type=inet,server.data.host=127.0.0.1,server.data.port=12345

Nobody should be using it, as it's fairly new and has never been
documented, so adding still more compatibility gunk to keep it working
isn't worth the trouble.  You now have to use

    -drive if=none,driver=nbd,server.type=inet,server.host=127.0.0.1,server.port=12345

Signed-off-by: Markus Armbruster <armbru@redhat.com>
---
 block/nbd.c | 41 +----------------------------------------
 1 file changed, 1 insertion(+), 40 deletions(-)

diff --git a/block/nbd.c b/block/nbd.c
index ea9d8dc..8bb29a9 100644
--- a/block/nbd.c
+++ b/block/nbd.c
@@ -223,51 +223,12 @@ static bool nbd_process_legacy_socket_options(QDict *output_options,
     const char *path = qemu_opt_get(legacy_opts, "path");
     const char *host = qemu_opt_get(legacy_opts, "host");
     const char *port = qemu_opt_get(legacy_opts, "port");
-    const char *sd_path = qdict_get_try_str(output_options,
-                                            "server.data.path");
-    const char *sd_host = qdict_get_try_str(output_options,
-                                            "server.data.host");
-    const char *sd_port = qdict_get_try_str(output_options,
-                                            "server.data.port");
-    bool bare = path || host || port;
-    bool server_data = sd_path || sd_host || sd_port;
-    QObject *val;
     const QDictEntry *e;
 
-    if (!bare && !server_data) {
+    if (!path && !host && !port) {
         return true;
     }
 
-    if (bare && server_data) {
-        error_setg(errp, "Cannot use 'server' and path/host/port at the "
-                   "same time");
-        return false;
-    }
-
-    if (server_data) {
-        if (sd_host) {
-            val = qdict_get(output_options, "server.data.host");
-            qobject_incref(val);
-            qdict_put_obj(output_options, "server.host", val);
-            qdict_del(output_options, "server.data.host");
-        }
-        if (sd_port) {
-            val = qdict_get(output_options, "server.data.port");
-            qobject_incref(val);
-            qdict_put_obj(output_options, "server.port", val);
-            qdict_del(output_options, "server.data.port");
-        }
-        if (sd_path) {
-            val = qdict_get(output_options, "server.data.path");
-            qobject_incref(val);
-            qdict_put_obj(output_options, "server.path", val);
-            qdict_del(output_options, "server.data.path");
-        }
-        return true;
-    }
-
-    assert(bare);
-
     for (e = qdict_first(output_options); e; e = qdict_next(output_options, e))
     {
         if (strstart(e->key, "server.", NULL)) {
-- 
2.7.4


Re: [Qemu-devel] [RFC v2 for-2.9 09/10] squash! nbd: Tidy up blockdev-add interface
Posted by Eric Blake 8 years, 10 months ago
On 03/30/2017 08:15 AM, Markus Armbruster wrote:
> Drop backward -drive server.data.* compatibility gunk.  On squash,
> replace commit message's last paragraph "Unfortunately, SocketAddress
> is also visible..." by:

Maybe I should glance at the whole thread before reviewing without
realizing what is coming later ;)

> 
> Unfortunately, SocketAddress is also visible in -drive since 2.8:
> 
>     -drive if=none,driver=nbd,server.type=inet,server.data.host=127.0.0.1,server.data.port=12345
> 
> Nobody should be using it, as it's fairly new and has never been
> documented, so adding still more compatibility gunk to keep it working
> isn't worth the trouble.  You now have to use
> 
>     -drive if=none,driver=nbd,server.type=inet,server.host=127.0.0.1,server.port=12345

As pointed out on 8/10, it might be worth documenting that while legacy
'port' is optional, the new 'server.port' is mandatory.

> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  block/nbd.c | 41 +----------------------------------------
>  1 file changed, 1 insertion(+), 40 deletions(-)
> 

When squashed with 8/10, it does make that patch more palatable (all the
concerns I expressed there were ripped out here).  So if no one else has
a strong argument for keeping 'server.data.*' back-compat, then the
squash of 8+9 together can have:

Reviewed-by: Eric Blake <eblake@redhat.com>

-- 
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

Re: [Qemu-devel] [RFC v2 for-2.9 09/10] squash! nbd: Tidy up blockdev-add interface
Posted by Max Reitz 8 years, 10 months ago
On 30.03.2017 15:15, Markus Armbruster wrote:
> Drop backward -drive server.data.* compatibility gunk.  On squash,
> replace commit message's last paragraph "Unfortunately, SocketAddress
> is also visible..." by:
> 
> Unfortunately, SocketAddress is also visible in -drive since 2.8:
> 
>     -drive if=none,driver=nbd,server.type=inet,server.data.host=127.0.0.1,server.data.port=12345
> 
> Nobody should be using it, as it's fairly new and has never been
> documented, so adding still more compatibility gunk to keep it working
> isn't worth the trouble.  You now have to use
> 
>     -drive if=none,driver=nbd,server.type=inet,server.host=127.0.0.1,server.port=12345
> 
> Signed-off-by: Markus Armbruster <armbru@redhat.com>
> ---
>  block/nbd.c | 41 +----------------------------------------
>  1 file changed, 1 insertion(+), 40 deletions(-)

(Very-happily-)Reviewed-by: Max Reitz <mreitz@redhat.com>