Skip to contentSkip to conversation

gluster: Fix blockdev-add with server.N.type=unix

PATCH Applied Kevin Wolf 4 participants 9 messages Apr 3, 2018 – Apr 4, 2018 Block layer

lore
Share & tools
lore

Kevin Wolf

author
#0 lore raw

PATCH 1/1 gluster: Fix blockdev-add with server.N.type=unix

The legacy command line interface gets the socket path from an option called 'socket'. QAPI in contract uses SocketAddress, where the corresponding option is called 'path'.

Fix the gluster block driver to accept both 'socket' and 'path', with 'path' being the preferred syntax.

https://bugzilla.redhat.com/show_bug.cgi?id=1545155

---
 block/gluster.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)
block/gluster.c +17 -4
index 296e036b3d..4adc1a875b 100644
@@ -167,7 +167,12 @@ static QemuOptsList runtime_unix_opts = {
         {
             .name = GLUSTER_OPT_SOCKET,
             .type = QEMU_OPT_STRING,
-            .help = "socket file path)",
+            .help = "socket file path (legacy)",
+        },
+        {
+            .name = GLUSTER_OPT_PATH,
+            .type = QEMU_OPT_STRING,
+            .help = "socket file path (QAPI)",
         },
         { /* end of list */ }
     },
@@ -615,10 +620,18 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf,
                 goto out;
             }
 
-            ptr = qemu_opt_get(opts, GLUSTER_OPT_SOCKET);
+            ptr = qemu_opt_get(opts, GLUSTER_OPT_PATH);
+            if (!ptr) {
+                ptr = qemu_opt_get(opts, GLUSTER_OPT_SOCKET);
+            } else if (qemu_opt_get(opts, GLUSTER_OPT_SOCKET)) {
+                error_setg(&local_err,
+                           "Conflicting parameters 'path' and 'socket'");
+                error_append_hint(&local_err, GERR_INDEX_HINT, i);
+                goto out;
+            }
             if (!ptr) {
                 error_setg(&local_err, QERR_MISSING_PARAMETER,
-                           GLUSTER_OPT_SOCKET);
+                           GLUSTER_OPT_PATH);
                 error_append_hint(&local_err, GERR_INDEX_HINT, i);
                 goto out;
             }
@@ -684,7 +697,7 @@ static int qemu_gluster_parse(BlockdevOptionsGluster *gconf,
                              "file.server.0.host=1.2.3.4,"
                              "file.server.0.port=24007,"
                              "file.server.1.transport=unix,"
-                             "file.server.1.socket=/var/run/glusterd.socket ..."
+                             "file.server.1.path=/var/run/glusterd.socket ..."
                              "\n");
             return ret;
         }
Signature · 1 line
2.13.6
Reviewed-by on v1 1/1
#1 lore raw
Quoted 7 lines · Kevin Wolf

The legacy command line interface gets the socket path from an option called 'socket'. QAPI in contract uses SocketAddress, where the corresponding option is called 'path'.

Fix the gluster block driver to accept both 'socket' and 'path', with 'path' being the preferred syntax.

Quoted 7 lines

https://bugzilla.redhat.com/show_bug.cgi?id=1545155

---
 block/gluster.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

Should we also add a deprecation warning for 'socket' and update the deprecation documentation, so we can start the clock ticking on getting rid of maintaining the back-compat glue forever?

block/gluster.c static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf, · line 625

Quoted 8 lines
block/gluster.c +3 -1
@@ -615,10 +620,18 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf,
                 goto out;
             }
 
-            ptr = qemu_opt_get(opts, GLUSTER_OPT_SOCKET);
+            ptr = qemu_opt_get(opts, GLUSTER_OPT_PATH);
+            if (!ptr) {
+                ptr = qemu_opt_get(opts, GLUSTER_OPT_SOCKET);

Here's where we'd warn, if we want to deprecate things.

Quoted 7 lines
block/gluster.c +6 -0
+            } else if (qemu_opt_get(opts, GLUSTER_OPT_SOCKET)) {
+                error_setg(&local_err,
+                           "Conflicting parameters 'path' and 'socket'");
+                error_append_hint(&local_err, GERR_INDEX_HINT, i);
+                goto out;
+            }
             if (!ptr) {
Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#2 lore raw
Quoted 8 lines · Eric Blake
Quoted 7 lines · Kevin Wolf

The legacy command line interface gets the socket path from an option called 'socket'. QAPI in contract uses SocketAddress, where the corresponding option is called 'path'.

Fix the gluster block driver to accept both 'socket' and 'path', with 'path' being the preferred syntax.

Quoted 7 lines
Quoted 7 lines

https://bugzilla.redhat.com/show_bug.cgi?id=1545155

---
 block/gluster.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)

Thanks for fixing this. I'm using the new syntax in the -blockdev code in libvirt and since I'm qapi- schema-checking the results, it would not be possible to use the legacy approach.

Quoted 6 lines

Should we also add a deprecation warning for 'socket' and update the deprecation documentation, so we can start the clock ticking on getting rid of maintaining the back-compat glue forever?

Well, that won't be as easy. Since there is at least one qemu release which declared this in the QAPI schema but did not support using it it's hard for libvirt to detect that this was fixed, and thus we can't infer a capability which would be used to switch to the new-syntax only.

author
#3 lore raw

Am 04.04.2018 um 17:41 hat Peter Krempa geschrieben:

Quoted 17 lines · Eric Blake
Quoted 8 lines · Kevin Wolf
Quoted 7 lines

The legacy command line interface gets the socket path from an option called 'socket'. QAPI in contract uses SocketAddress, where the corresponding option is called 'path'.

Fix the gluster block driver to accept both 'socket' and 'path', with 'path' being the preferred syntax.

Quoted 7 lines
Quoted 7 lines

https://bugzilla.redhat.com/show_bug.cgi?id=1545155

---
 block/gluster.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)
Quoted 3 lines

Thanks for fixing this. I'm using the new syntax in the -blockdev code in libvirt and since I'm qapi- schema-checking the results, it would not be possible to use the legacy approach.

-blockdev is validated against the schema on the QEMU side, too. The legacy option can only be used with -drive.

Quoted 10 lines
Quoted 5 lines

Should we also add a deprecation warning for 'socket' and update the deprecation documentation, so we can start the clock ticking on getting rid of maintaining the back-compat glue forever?

Well, that won't be as easy. Since there is at least one qemu release which declared this in the QAPI schema but did not support using it it's hard for libvirt to detect that this was fixed, and thus we can't infer a capability which would be used to switch to the new-syntax only.

Markus wanted to add some way to declare capabilities for a command in the schema that could be queried with schema introspection and would cover such cases. I think we even discussed this with you at KVM Forum?

Eric, do you happen to know if there were any patches on the list related to this?

Kevin

#4 lore raw
Quoted 9 lines · Kevin Wolf
Quoted 8 lines
Quoted 3 lines

Should we also add a deprecation warning for 'socket' and update the deprecation documentation, so we can start the clock ticking on getting rid of maintaining the back-compat glue forever?

Well, that won't be as easy. Since there is at least one qemu release which declared this in the QAPI schema but did not support using it it's hard for libvirt to detect that this was fixed, and thus we can't infer a capability which would be used to switch to the new-syntax only.

Quoted 6 lines

Markus wanted to add some way to declare capabilities for a command in the schema that could be queried with schema introspection and would cover such cases. I think we even discussed this with you at KVM Forum?

Eric, do you happen to know if there were any patches on the list related to this?

I don't recall seeing any patches from Markus before his leave, and doubt anyone else has tackled anything along these lines. It's too late for 2.12, at any rate, so even if we had such a feature implemented in time for 2.13, it won't help introspecting the 2.12 release.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
author
#5 lore raw

Am 04.04.2018 um 20:16 hat Eric Blake geschrieben:

Quoted 15 lines · Kevin Wolf
Quoted 14 lines
Quoted 9 lines
Quoted 4 lines

Should we also add a deprecation warning for 'socket' and update the deprecation documentation, so we can start the clock ticking on getting rid of maintaining the back-compat glue forever?

Well, that won't be as easy. Since there is at least one qemu release which declared this in the QAPI schema but did not support using it it's hard for libvirt to detect that this was fixed, and thus we can't infer a capability which would be used to switch to the new-syntax only.

Markus wanted to add some way to declare capabilities for a command in the schema that could be queried with schema introspection and would cover such cases. I think we even discussed this with you at KVM Forum?

Quoted 7 lines
Quoted 2 lines

Eric, do you happen to know if there were any patches on the list related to this?

I don't recall seeing any patches from Markus before his leave, and doubt anyone else has tackled anything along these lines. It's too late for 2.12, at any rate, so even if we had such a feature implemented in time for 2.13, it won't help introspecting the 2.12 release.

We only strictly need it in introspection at the time when we remove the old option. But maybe it would be nicer to wait with the deprecation error_report() until libvirt has a chance to avoid the warning.

Kevin

#6 lore raw
Quoted 11 lines · Kevin Wolf

Am 04.04.2018 um 20:16 hat Eric Blake geschrieben:

Quoted 6 lines · Kevin Wolf
Quoted 5 lines
Quoted 5 lines
Quoted 4 lines

Should we also add a deprecation warning for 'socket' and update the deprecation documentation, so we can start the clock ticking on getting rid of maintaining the back-compat glue forever?

We only strictly need it in introspection at the time when we remove the old option. But maybe it would be nicer to wait with the deprecation error_report() until libvirt has a chance to avoid the warning.

Makes sense - so no deprecation warning for 2.12, and the timeline for performing a deprecation is shifted by a couple of releases after the first time we introduce proper introspection support. Which makes this patch fine as-is.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
Reviewed-by on v1 1/1
#7 lore raw
In reply to Kevin Wolf
Quoted 11 lines · Kevin Wolf

The legacy command line interface gets the socket path from an option called 'socket'. QAPI in contract uses SocketAddress, where the corresponding option is called 'path'.

Fix the gluster block driver to accept both 'socket' and 'path', with 'path' being the preferred syntax.

https://bugzilla.redhat.com/show_bug.cgi?id=1545155

Quoted 55 lines
---
 block/gluster.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)
block/gluster.c +17 -4
index 296e036b3d..4adc1a875b 100644
@@ -167,7 +167,12 @@ static QemuOptsList runtime_unix_opts = {
         {
             .name = GLUSTER_OPT_SOCKET,
             .type = QEMU_OPT_STRING,
-            .help = "socket file path)",
+            .help = "socket file path (legacy)",
+        },
+        {
+            .name = GLUSTER_OPT_PATH,
+            .type = QEMU_OPT_STRING,
+            .help = "socket file path (QAPI)",
         },
         { /* end of list */ }
     },
@@ -615,10 +620,18 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf,
                 goto out;
             }
 
-            ptr = qemu_opt_get(opts, GLUSTER_OPT_SOCKET);
+            ptr = qemu_opt_get(opts, GLUSTER_OPT_PATH);
+            if (!ptr) {
+                ptr = qemu_opt_get(opts, GLUSTER_OPT_SOCKET);
+            } else if (qemu_opt_get(opts, GLUSTER_OPT_SOCKET)) {
+                error_setg(&local_err,
+                           "Conflicting parameters 'path' and 'socket'");
+                error_append_hint(&local_err, GERR_INDEX_HINT, i);
+                goto out;
+            }
             if (!ptr) {
                 error_setg(&local_err, QERR_MISSING_PARAMETER,
-                           GLUSTER_OPT_SOCKET);
+                           GLUSTER_OPT_PATH);
                 error_append_hint(&local_err, GERR_INDEX_HINT, i);
                 goto out;
             }
@@ -684,7 +697,7 @@ static int qemu_gluster_parse(BlockdevOptionsGluster *gconf,
                              "file.server.0.host=1.2.3.4,"
                              "file.server.0.port=24007,"
                              "file.server.1.transport=unix,"
-                             "file.server.1.socket=/var/run/glusterd.socket ..."
+                             "file.server.1.path=/var/run/glusterd.socket ..."
                              "\n");
             return ret;
         }
Signature · 1 line
2.13.6
Applied
#8 lore raw
In reply to Kevin Wolf
Quoted 66 lines · Kevin Wolf

The legacy command line interface gets the socket path from an option called 'socket'. QAPI in contract uses SocketAddress, where the corresponding option is called 'path'.

Fix the gluster block driver to accept both 'socket' and 'path', with 'path' being the preferred syntax.

https://bugzilla.redhat.com/show_bug.cgi?id=1545155

---
 block/gluster.c | 21 +++++++++++++++++----
 1 file changed, 17 insertions(+), 4 deletions(-)
block/gluster.c +17 -4
index 296e036b3d..4adc1a875b 100644
@@ -167,7 +167,12 @@ static QemuOptsList runtime_unix_opts = {
         {
             .name = GLUSTER_OPT_SOCKET,
             .type = QEMU_OPT_STRING,
-            .help = "socket file path)",
+            .help = "socket file path (legacy)",
+        },
+        {
+            .name = GLUSTER_OPT_PATH,
+            .type = QEMU_OPT_STRING,
+            .help = "socket file path (QAPI)",
         },
         { /* end of list */ }
     },
@@ -615,10 +620,18 @@ static int qemu_gluster_parse_json(BlockdevOptionsGluster *gconf,
                 goto out;
             }
 
-            ptr = qemu_opt_get(opts, GLUSTER_OPT_SOCKET);
+            ptr = qemu_opt_get(opts, GLUSTER_OPT_PATH);
+            if (!ptr) {
+                ptr = qemu_opt_get(opts, GLUSTER_OPT_SOCKET);
+            } else if (qemu_opt_get(opts, GLUSTER_OPT_SOCKET)) {
+                error_setg(&local_err,
+                           "Conflicting parameters 'path' and 'socket'");
+                error_append_hint(&local_err, GERR_INDEX_HINT, i);
+                goto out;
+            }
             if (!ptr) {
                 error_setg(&local_err, QERR_MISSING_PARAMETER,
-                           GLUSTER_OPT_SOCKET);
+                           GLUSTER_OPT_PATH);
                 error_append_hint(&local_err, GERR_INDEX_HINT, i);
                 goto out;
             }
@@ -684,7 +697,7 @@ static int qemu_gluster_parse(BlockdevOptionsGluster *gconf,
                              "file.server.0.host=1.2.3.4,"
                              "file.server.0.port=24007,"
                              "file.server.1.transport=unix,"
-                             "file.server.1.socket=/var/run/glusterd.socket ..."
+                             "file.server.1.path=/var/run/glusterd.socket ..."
                              "\n");
             return ret;
         }
Signature · 1 line
2.13.6

Thanks,

Applied to my block branch:

git://github.com/codyprime/qemu-kvm-jtc block

-Jeff