diff mbox

block: Add bdrv_runtime_opts to query-command-line-options

Message ID 1475746836-16162-1-git-send-email-kwolf@redhat.com
State New
Headers show

Commit Message

Kevin Wolf Oct. 6, 2016, 9:40 a.m. UTC
Recently we moved a few options from QemuOptsLists in blockdev.c to
bdrv_runtime_opts in block.c in order to make them accissble using
blockdev-add. However, this has the side effect that these options are
missing from query-command-line-options now, and libvirt consequently
disables the corresponding feature.

This problem was reported as a regression for the 'discard' option,
introduced in commit 818584a4. However, it is more general than that.

Fix it by adding bdrv_runtime_opts to the list of QemuOptsLists that are
returned in query-command-line-options. For the future, libvirt is
advised to use QMP schema introspection for block device options.

Reported-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 block.c                 | 2 +-
 include/sysemu/sysemu.h | 1 +
 util/qemu-config.c      | 2 +-
 vl.c                    | 1 +
 4 files changed, 4 insertions(+), 2 deletions(-)

Comments

Michal Prívozník Oct. 6, 2016, 10:01 a.m. UTC | #1
On 06.10.2016 11:40, Kevin Wolf wrote:
> Recently we moved a few options from QemuOptsLists in blockdev.c to
> bdrv_runtime_opts in block.c in order to make them accissble using
> blockdev-add. However, this has the side effect that these options are
> missing from query-command-line-options now, and libvirt consequently
> disables the corresponding feature.
> 
> This problem was reported as a regression for the 'discard' option,
> introduced in commit 818584a4. However, it is more general than that.
> 
> Fix it by adding bdrv_runtime_opts to the list of QemuOptsLists that are
> returned in query-command-line-options. For the future, libvirt is
> advised to use QMP schema introspection for block device options.
> 
> Reported-by: Michal Privoznik <mprivozn@redhat.com>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>

Tested-by: Michal Privoznik <mprivozn@redhat.com>

Thank you for such a prompt fix!

Michal
Martin Kletzander Oct. 6, 2016, 10:58 a.m. UTC | #2
On Thu, Oct 06, 2016 at 11:40:36AM +0200, Kevin Wolf wrote:
>Recently we moved a few options from QemuOptsLists in blockdev.c to
>bdrv_runtime_opts in block.c in order to make them accissble using
>blockdev-add. However, this has the side effect that these options are
>missing from query-command-line-options now, and libvirt consequently
>disables the corresponding feature.
>
>This problem was reported as a regression for the 'discard' option,
>introduced in commit 818584a4. However, it is more general than that.
>
>Fix it by adding bdrv_runtime_opts to the list of QemuOptsLists that are
>returned in query-command-line-options. For the future, libvirt is
>advised to use QMP schema introspection for block device options.
>
>Reported-by: Michal Privoznik <mprivozn@redhat.com>
>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
>---
> block.c                 | 2 +-
> include/sysemu/sysemu.h | 1 +
> util/qemu-config.c      | 2 +-
> vl.c                    | 1 +
> 4 files changed, 4 insertions(+), 2 deletions(-)
>
>diff --git a/block.c b/block.c
>index bb1f1ec..40eb570 100644
>--- a/block.c
>+++ b/block.c
>@@ -926,7 +926,7 @@ out:
>     g_free(gen_node_name);
> }
>
>-static QemuOptsList bdrv_runtime_opts = {
>+QemuOptsList bdrv_runtime_opts = {
>     .name = "bdrv_common",
>     .head = QTAILQ_HEAD_INITIALIZER(bdrv_runtime_opts.head),
>     .desc = {
>diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
>index ef2c50b..b668833 100644
>--- a/include/sysemu/sysemu.h
>+++ b/include/sysemu/sysemu.h
>@@ -235,6 +235,7 @@ bool defaults_enabled(void);
> extern QemuOptsList qemu_legacy_drive_opts;
> extern QemuOptsList qemu_common_drive_opts;
> extern QemuOptsList qemu_drive_opts;
>+extern QemuOptsList bdrv_runtime_opts;
> extern QemuOptsList qemu_chardev_opts;
> extern QemuOptsList qemu_device_opts;
> extern QemuOptsList qemu_netdev_opts;
>diff --git a/util/qemu-config.c b/util/qemu-config.c
>index fb97307..5527100 100644
>--- a/util/qemu-config.c
>+++ b/util/qemu-config.c
>@@ -6,7 +6,7 @@
> #include "qmp-commands.h"
>
> static QemuOptsList *vm_config_groups[48];
>-static QemuOptsList *drive_config_groups[4];
>+static QemuOptsList *drive_config_groups[5];
>
> static QemuOptsList *find_list(QemuOptsList **lists, const char *group,
>                                Error **errp)
>diff --git a/vl.c b/vl.c
>index f3abd99..9a2e7d5 100644
>--- a/vl.c
>+++ b/vl.c
>@@ -3035,6 +3035,7 @@ int main(int argc, char **argv, char **envp)
>     qemu_add_drive_opts(&qemu_legacy_drive_opts);
>     qemu_add_drive_opts(&qemu_common_drive_opts);

I'm guessing this doesn't pose a problem with e.g.g "detect-zeroes"
which is in this (&qemu_common_drive_opts) as well as

>     qemu_add_drive_opts(&qemu_drive_opts);
>+    qemu_add_drive_opts(&bdrv_runtime_opts);

here ^^, right?  Just wanted to make sure ;)  Thanks for the fix.

>     qemu_add_opts(&qemu_chardev_opts);
>     qemu_add_opts(&qemu_device_opts);
>     qemu_add_opts(&qemu_netdev_opts);
>--
>1.8.3.1
>
Kevin Wolf Oct. 6, 2016, 11:11 a.m. UTC | #3
Am 06.10.2016 um 12:58 hat Martin Kletzander geschrieben:
> On Thu, Oct 06, 2016 at 11:40:36AM +0200, Kevin Wolf wrote:
> >Recently we moved a few options from QemuOptsLists in blockdev.c to
> >bdrv_runtime_opts in block.c in order to make them accissble using
> >blockdev-add. However, this has the side effect that these options are
> >missing from query-command-line-options now, and libvirt consequently
> >disables the corresponding feature.
> >
> >This problem was reported as a regression for the 'discard' option,
> >introduced in commit 818584a4. However, it is more general than that.
> >
> >Fix it by adding bdrv_runtime_opts to the list of QemuOptsLists that are
> >returned in query-command-line-options. For the future, libvirt is
> >advised to use QMP schema introspection for block device options.
> >
> >Reported-by: Michal Privoznik <mprivozn@redhat.com>
> >Signed-off-by: Kevin Wolf <kwolf@redhat.com>
> >---
> >block.c                 | 2 +-
> >include/sysemu/sysemu.h | 1 +
> >util/qemu-config.c      | 2 +-
> >vl.c                    | 1 +
> >4 files changed, 4 insertions(+), 2 deletions(-)
> >
> >diff --git a/block.c b/block.c
> >index bb1f1ec..40eb570 100644
> >--- a/block.c
> >+++ b/block.c
> >@@ -926,7 +926,7 @@ out:
> >    g_free(gen_node_name);
> >}
> >
> >-static QemuOptsList bdrv_runtime_opts = {
> >+QemuOptsList bdrv_runtime_opts = {
> >    .name = "bdrv_common",
> >    .head = QTAILQ_HEAD_INITIALIZER(bdrv_runtime_opts.head),
> >    .desc = {
> >diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
> >index ef2c50b..b668833 100644
> >--- a/include/sysemu/sysemu.h
> >+++ b/include/sysemu/sysemu.h
> >@@ -235,6 +235,7 @@ bool defaults_enabled(void);
> >extern QemuOptsList qemu_legacy_drive_opts;
> >extern QemuOptsList qemu_common_drive_opts;
> >extern QemuOptsList qemu_drive_opts;
> >+extern QemuOptsList bdrv_runtime_opts;
> >extern QemuOptsList qemu_chardev_opts;
> >extern QemuOptsList qemu_device_opts;
> >extern QemuOptsList qemu_netdev_opts;
> >diff --git a/util/qemu-config.c b/util/qemu-config.c
> >index fb97307..5527100 100644
> >--- a/util/qemu-config.c
> >+++ b/util/qemu-config.c
> >@@ -6,7 +6,7 @@
> >#include "qmp-commands.h"
> >
> >static QemuOptsList *vm_config_groups[48];
> >-static QemuOptsList *drive_config_groups[4];
> >+static QemuOptsList *drive_config_groups[5];
> >
> >static QemuOptsList *find_list(QemuOptsList **lists, const char *group,
> >                               Error **errp)
> >diff --git a/vl.c b/vl.c
> >index f3abd99..9a2e7d5 100644
> >--- a/vl.c
> >+++ b/vl.c
> >@@ -3035,6 +3035,7 @@ int main(int argc, char **argv, char **envp)
> >    qemu_add_drive_opts(&qemu_legacy_drive_opts);
> >    qemu_add_drive_opts(&qemu_common_drive_opts);
> 
> I'm guessing this doesn't pose a problem with e.g.g "detect-zeroes"
> which is in this (&qemu_common_drive_opts) as well as
> 
> >    qemu_add_drive_opts(&qemu_drive_opts);
> >+    qemu_add_drive_opts(&bdrv_runtime_opts);
> 
> here ^^, right?  Just wanted to make sure ;)  Thanks for the fix.

Yes, cleanup_infolist() removes duplicates before they are sent to the
client.

Kevin
Gerd Hoffmann Oct. 7, 2016, 10:49 a.m. UTC | #4
On Do, 2016-10-06 at 11:40 +0200, Kevin Wolf wrote:
> Recently we moved a few options from QemuOptsLists in blockdev.c to
> bdrv_runtime_opts in block.c in order to make them accissble using
> blockdev-add. However, this has the side effect that these options are
> missing from query-command-line-options now, and libvirt consequently
> disables the corresponding feature.
> 
> This problem was reported as a regression for the 'discard' option,
> introduced in commit 818584a4. However, it is more general than that.
> 
> Fix it by adding bdrv_runtime_opts to the list of QemuOptsLists that are
> returned in query-command-line-options. For the future, libvirt is
> advised to use QMP schema introspection for block device options.
> 
> Reported-by: Michal Privoznik <mprivozn@redhat.com>
> Signed-off-by: Kevin Wolf <kwolf@redhat.com>

Tested-by: Gerd Hoffmann <kraxel@redhat.com>

> ---
>  block.c                 | 2 +-
>  include/sysemu/sysemu.h | 1 +
>  util/qemu-config.c      | 2 +-
>  vl.c                    | 1 +
>  4 files changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/block.c b/block.c
> index bb1f1ec..40eb570 100644
> --- a/block.c
> +++ b/block.c
> @@ -926,7 +926,7 @@ out:
>      g_free(gen_node_name);
>  }
>  
> -static QemuOptsList bdrv_runtime_opts = {
> +QemuOptsList bdrv_runtime_opts = {
>      .name = "bdrv_common",
>      .head = QTAILQ_HEAD_INITIALIZER(bdrv_runtime_opts.head),
>      .desc = {
> diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
> index ef2c50b..b668833 100644
> --- a/include/sysemu/sysemu.h
> +++ b/include/sysemu/sysemu.h
> @@ -235,6 +235,7 @@ bool defaults_enabled(void);
>  extern QemuOptsList qemu_legacy_drive_opts;
>  extern QemuOptsList qemu_common_drive_opts;
>  extern QemuOptsList qemu_drive_opts;
> +extern QemuOptsList bdrv_runtime_opts;
>  extern QemuOptsList qemu_chardev_opts;
>  extern QemuOptsList qemu_device_opts;
>  extern QemuOptsList qemu_netdev_opts;
> diff --git a/util/qemu-config.c b/util/qemu-config.c
> index fb97307..5527100 100644
> --- a/util/qemu-config.c
> +++ b/util/qemu-config.c
> @@ -6,7 +6,7 @@
>  #include "qmp-commands.h"
>  
>  static QemuOptsList *vm_config_groups[48];
> -static QemuOptsList *drive_config_groups[4];
> +static QemuOptsList *drive_config_groups[5];
>  
>  static QemuOptsList *find_list(QemuOptsList **lists, const char *group,
>                                 Error **errp)
> diff --git a/vl.c b/vl.c
> index f3abd99..9a2e7d5 100644
> --- a/vl.c
> +++ b/vl.c
> @@ -3035,6 +3035,7 @@ int main(int argc, char **argv, char **envp)
>      qemu_add_drive_opts(&qemu_legacy_drive_opts);
>      qemu_add_drive_opts(&qemu_common_drive_opts);
>      qemu_add_drive_opts(&qemu_drive_opts);
> +    qemu_add_drive_opts(&bdrv_runtime_opts);
>      qemu_add_opts(&qemu_chardev_opts);
>      qemu_add_opts(&qemu_device_opts);
>      qemu_add_opts(&qemu_netdev_opts);
diff mbox

Patch

diff --git a/block.c b/block.c
index bb1f1ec..40eb570 100644
--- a/block.c
+++ b/block.c
@@ -926,7 +926,7 @@  out:
     g_free(gen_node_name);
 }
 
-static QemuOptsList bdrv_runtime_opts = {
+QemuOptsList bdrv_runtime_opts = {
     .name = "bdrv_common",
     .head = QTAILQ_HEAD_INITIALIZER(bdrv_runtime_opts.head),
     .desc = {
diff --git a/include/sysemu/sysemu.h b/include/sysemu/sysemu.h
index ef2c50b..b668833 100644
--- a/include/sysemu/sysemu.h
+++ b/include/sysemu/sysemu.h
@@ -235,6 +235,7 @@  bool defaults_enabled(void);
 extern QemuOptsList qemu_legacy_drive_opts;
 extern QemuOptsList qemu_common_drive_opts;
 extern QemuOptsList qemu_drive_opts;
+extern QemuOptsList bdrv_runtime_opts;
 extern QemuOptsList qemu_chardev_opts;
 extern QemuOptsList qemu_device_opts;
 extern QemuOptsList qemu_netdev_opts;
diff --git a/util/qemu-config.c b/util/qemu-config.c
index fb97307..5527100 100644
--- a/util/qemu-config.c
+++ b/util/qemu-config.c
@@ -6,7 +6,7 @@ 
 #include "qmp-commands.h"
 
 static QemuOptsList *vm_config_groups[48];
-static QemuOptsList *drive_config_groups[4];
+static QemuOptsList *drive_config_groups[5];
 
 static QemuOptsList *find_list(QemuOptsList **lists, const char *group,
                                Error **errp)
diff --git a/vl.c b/vl.c
index f3abd99..9a2e7d5 100644
--- a/vl.c
+++ b/vl.c
@@ -3035,6 +3035,7 @@  int main(int argc, char **argv, char **envp)
     qemu_add_drive_opts(&qemu_legacy_drive_opts);
     qemu_add_drive_opts(&qemu_common_drive_opts);
     qemu_add_drive_opts(&qemu_drive_opts);
+    qemu_add_drive_opts(&bdrv_runtime_opts);
     qemu_add_opts(&qemu_chardev_opts);
     qemu_add_opts(&qemu_device_opts);
     qemu_add_opts(&qemu_netdev_opts);