Skip to contentSkip to conversation

Live block optional disable

PATCH In review Jeff Cody 6 participants 14 messages Aug 30, 2017 – Sep 6, 2017

lore
Share & tools
lore

Jeff Cody

author
#0 lore raw

v2 cover Live block optional disable

This series adds a configurable option to disable live block operations.

The default is that live block operations are 'enabled'.

Jeffrey Cody (3):
configure: Add option in configure to disable live block ops
block-jobs: Optionally unregister live block operations
hmp: Optionally disable live block operations in HMP monitor

 configure            | 11 +++++++++++
 hmp-commands-info.hx |  4 ++++
 hmp-commands.hx      | 12 ++++++++++++
 hmp.c                | 12 ++++++++++++
 monitor.c            | 16 ++++++++++++++++
 5 files changed, 55 insertions(+)
Signature · 1 line
2.9.5
author
#1 lore raw

PATCH v2 1/3 configure: Add option in configure to disable live block ops

From: Jeffrey Cody <[email protected]>

This adds in the option to disable the live block operations. The resultant config option is not checked until subsequent patches.

---
 configure | 11 +++++++++++
 1 file changed, 11 insertions(+)
configure +11 -0
index dd73cce..24bde07 100755
@@ -400,6 +400,7 @@ virglrenderer=""
 tpm="yes"
 libssh2=""
 live_block_migration="yes"
+live_block_ops="yes"
 numa=""
 tcmalloc="no"
 jemalloc="no"
@@ -1263,6 +1264,10 @@ for opt do
   ;;
   --enable-live-block-migration) live_block_migration="yes"
   ;;
+  --disable-live-block-ops) live_block_ops="no"
+  ;;
+  --enable-live-block-ops) live_block_ops="yes"
+  ;;
   --disable-numa) numa="no"
   ;;
   --enable-numa) numa="yes"
@@ -1513,6 +1518,7 @@ disabled with --disable-FEATURE, default is enabled if available:
   smartcard       smartcard support (libcacard)
   libusb          libusb (for usb passthrough)
   live-block-migration   Block migration in the main migration stream
+  live-block-ops  live block operations support
   usb-redir       usb network redirection support
   lzo             support of lzo compression library
   snappy          support of snappy compression library
@@ -5398,6 +5404,7 @@ echo "libssh2 support   $libssh2"
 echo "TPM passthrough   $tpm_passthrough"
 echo "QOM debugging     $qom_cast_debug"
 echo "Live block migration $live_block_migration"
+echo "Live block ops    $live_block_ops"
 echo "lzo support       $lzo"
 echo "snappy support    $snappy"
 echo "bzip2 support     $bzip2"
@@ -5976,6 +5983,10 @@ if test "$live_block_migration" = "yes" ; then
   echo "CONFIG_LIVE_BLOCK_MIGRATION=y" >> $config_host_mak
 fi
 
+if test "$live_block_ops" = "yes" ; then
+  echo "CONFIG_LIVE_BLOCK_OPS=y" >> $config_host_mak
+fi
+
 # USB host support
 if test "$libusb" = "yes"; then
   echo "HOST_USB=libusb legacy" >> $config_host_mak
Signature · 1 line
2.9.5
author
#2 lore raw

PATCH v2 2/3 block-jobs: Optionally unregister live block operations

In reply to Jeff Cody

From: Jeffrey Cody <[email protected]>

If configured without live block operations enabled, unregister the live block operation commands.

---
 monitor.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
monitor.c +16 -0
index e0f8801..de0a70e 100644
@@ -998,6 +998,22 @@ static void qmp_unregister_commands_hack(void)
     && !defined(TARGET_S390X)
     qmp_unregister_command(&qmp_commands, "query-cpu-definitions");
 #endif
+#ifndef CONFIG_LIVE_BLOCK_OPS
+    qmp_unregister_command(&qmp_commands, "block-stream");
+    qmp_unregister_command(&qmp_commands, "block-commit");
+    qmp_unregister_command(&qmp_commands, "drive-mirror");
+    qmp_unregister_command(&qmp_commands, "blockdev-mirror");
+    qmp_unregister_command(&qmp_commands, "drive-backup");
+    qmp_unregister_command(&qmp_commands, "blockdev-backup");
+    qmp_unregister_command(&qmp_commands, "blockdev-snapshot");
+    qmp_unregister_command(&qmp_commands, "blockdev-snapshot-sync");
+    qmp_unregister_command(&qmp_commands, "block-job-set-speed");
+    qmp_unregister_command(&qmp_commands, "block-job-cancel");
+    qmp_unregister_command(&qmp_commands, "block-job-pause");
+    qmp_unregister_command(&qmp_commands, "block-job-resume");
+    qmp_unregister_command(&qmp_commands, "block-job-complete");
+    qmp_unregister_command(&qmp_commands, "query-block-jobs");
+#endif
 }
 
 void monitor_init_qmp_commands(void)
Signature · 1 line
2.9.5
#3 lore raw

Re: [Qemu-devel] [PATCH v2 2/3] block-jobs: Optionally unregister live block operations

Quoted 24 lines · Jeff Cody

From: Jeffrey Cody <[email protected]>

If configured without live block operations enabled, unregister the live block operation commands.

---
 monitor.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
monitor.c +6 -0
index e0f8801..de0a70e 100644
@@ -998,6 +998,22 @@ static void qmp_unregister_commands_hack(void)
     && !defined(TARGET_S390X)
     qmp_unregister_command(&qmp_commands, "query-cpu-definitions");
 #endif
+#ifndef CONFIG_LIVE_BLOCK_OPS
+    qmp_unregister_command(&qmp_commands, "block-stream");
+    qmp_unregister_command(&qmp_commands, "block-commit");
+    qmp_unregister_command(&qmp_commands, "drive-mirror");
+    qmp_unregister_command(&qmp_commands, "blockdev-mirror");
+    qmp_unregister_command(&qmp_commands, "drive-backup");

monitor.c static void qmp_unregister_commands_hack(void) · line 1016

Quoted 10 lines
monitor.c +10 -0
+    qmp_unregister_command(&qmp_commands, "blockdev-backup");
+    qmp_unregister_command(&qmp_commands, "blockdev-snapshot");
+    qmp_unregister_command(&qmp_commands, "blockdev-snapshot-sync");
+    qmp_unregister_command(&qmp_commands, "block-job-set-speed");
+    qmp_unregister_command(&qmp_commands, "block-job-cancel");
+    qmp_unregister_command(&qmp_commands, "block-job-pause");
+    qmp_unregister_command(&qmp_commands, "block-job-resume");
+    qmp_unregister_command(&qmp_commands, "block-job-complete");
+    qmp_unregister_command(&qmp_commands, "query-block-jobs");
+#endif

I suggest using the new mechanisms added by:

[PATCH 00/26] qapi: add #if pre-processor conditions to generated code

Signature · 1 line
Eduardo
#4 lore raw

Re: [Qemu-devel] [PATCH v2 2/3] block-jobs: Optionally unregister live block operations

Quoted 13 lines · Eduardo Habkost
Quoted 10 lines · Jeff Cody

From: Jeffrey Cody <[email protected]>

If configured without live block operations enabled, unregister the live block operation commands.

---
 monitor.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
Quoted 3 lines

I suggest using the new mechanisms added by:

[PATCH 00/26] qapi: add #if pre-processor conditions to generated code

Those haven't landed yet, but as both series are proposed for 2.11, I indeed agree that basing this series on top of that one will be a bit cleaner.

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

Re: [Qemu-devel] [PATCH v2 2/3] block-jobs: Optionally unregister live block operations

Quoted 14 lines · Eric Blake
Quoted 13 lines · Eduardo Habkost
Quoted 10 lines · Jeff Cody

From: Jeffrey Cody <[email protected]>

If configured without live block operations enabled, unregister the live block operation commands.

---
 monitor.c | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)
Quoted 7 lines
Quoted 3 lines

I suggest using the new mechanisms added by:

[PATCH 00/26] qapi: add #if pre-processor conditions to generated code

Those haven't landed yet, but as both series are proposed for 2.11, I indeed agree that basing this series on top of that one will be a bit cleaner.

Rebasing shouldn't be hard. However, we then have to hold it until the QAPI series lands. I don't think holding is necessary, as the conflicts between the two are obvious, and should be straightforward to resolve.

#6 lore raw

Re: [Qemu-devel] [Qemu-block] [PATCH v2 2/3] block-jobs: Optionally unregister live block operations

In reply to Jeff Cody

Am 30.08.2017 um 19:01 hat Jeff Cody geschrieben:

Quoted 6 lines

From: Jeffrey Cody <[email protected]>

If configured without live block operations enabled, unregister the live block operation commands.

How sure are we that libvirt will like a qemu that advertises these commands in the schema, but doesn't actually provide them?

Kevin

#7 lore raw

Re: [Qemu-devel] [Qemu-block] [PATCH v2 2/3] block-jobs: Optionally unregister live block operations

Quoted 10 lines · Kevin Wolf

Am 30.08.2017 um 19:01 hat Jeff Cody geschrieben:

Quoted 6 lines

From: Jeffrey Cody <[email protected]>

If configured without live block operations enabled, unregister the live block operation commands.

How sure are we that libvirt will like a qemu that advertises these commands in the schema, but doesn't actually provide them?

If libvirt wants to know if a command is available, it uses 'query-commands', not 'query-qmp-schema'.

The only query-qmp-schema elements used by latest libvirt are gluster-related blockdev-add options (see libvirt/src/qemu/qemu_capabilities.c:virQEMUCapsQMPSchemaQueries]]).

Signature · 1 line
Eduardo
#8 lore raw

Re: [Qemu-devel] [Qemu-block] [PATCH v2 2/3] block-jobs: Optionally unregister live block operations

Quoted 12 lines · Eduardo Habkost
Quoted 10 lines · Kevin Wolf

Am 30.08.2017 um 19:01 hat Jeff Cody geschrieben:

Quoted 6 lines

From: Jeffrey Cody <[email protected]>

If configured without live block operations enabled, unregister the live block operation commands.

How sure are we that libvirt will like a qemu that advertises these commands in the schema, but doesn't actually provide them?

Quoted 6 lines

If libvirt wants to know if a command is available, it uses 'query-commands', not 'query-qmp-schema'.

The only query-qmp-schema elements used by latest libvirt are gluster-related blockdev-add options (see libvirt/src/qemu/qemu_capabilities.c:virQEMUCapsQMPSchemaQueries]]).

Indeed, libvirt is currently just fine with the fact that query-commands introspection hides disabled commands, even if they are still leaked in query-qmp-schema. Besides, Marc-Andre's work on adding #if support to QAPI should probably also land in 2.11, at which point the hack goes away (because then we ARE properly hiding things from the schema introspection).

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

PATCH v2 3/3 hmp: Optionally disable live block operations in HMP monitor

In reply to Jeff Cody

From: Jeffrey Cody <[email protected]>

If live block operations are disabled, disable the corresponding HMP commands.

---
 hmp-commands-info.hx |  4 ++++
 hmp-commands.hx      | 12 ++++++++++++
 hmp.c                | 12 ++++++++++++
 3 files changed, 28 insertions(+)
hmp-commands-info.hx +4 -0
index d9df238..0967e41 100644
@@ -84,6 +84,8 @@ STEXI
 Show block device statistics.
 ETEXI
 
+#ifdef CONFIG_LIVE_BLOCK_OPS
+
     {
         .name       = "block-jobs",
         .args_type  = "",
@@ -98,6 +100,8 @@ STEXI
 Show progress of ongoing block device operations.
 ETEXI
 
+#endif /* CONFIG_LIVE_BLOCK_OPS */
+
     {
         .name       = "registers",
         .args_type  = "cpustate_all:-a",
hmp-commands.hx +12 -0
index 1941e19..2d137a1 100644
@@ -73,6 +73,8 @@ but should be used with extreme caution.  Note that this command only
 resizes image files, it can not resize block devices like LVM volumes.
 ETEXI
 
+#ifdef CONFIG_LIVE_BLOCK_OPS
+
     {
         .name       = "block_stream",
         .args_type  = "device:B,speed:o?,base:s?",
@@ -159,6 +161,8 @@ STEXI
 Resume a paused block streaming operation.
 ETEXI
 
+#endif /* CONFIG_LIVE_BLOCK_OPS */
+
     {
         .name       = "eject",
         .args_type  = "force:-f,device:B",
@@ -1169,6 +1173,8 @@ STEXI
 Enables or disables migration mode.
 ETEXI
 
+#ifdef CONFIG_LIVE_BLOCK_OPS
+
     {
         .name       = "snapshot_blkdev",
         .args_type  = "reuse:-n,device:B,snapshot-file:s?,format:s?",
@@ -1190,6 +1196,8 @@ STEXI
 Snapshot device, using snapshot file as target if provided
 ETEXI
 
+#endif /* CONFIG_LIVE_BLOCK_OPS */
+
     {
         .name       = "snapshot_blkdev_internal",
         .args_type  = "device:B,name:s",
@@ -1224,6 +1232,8 @@ STEXI
 Delete an internal snapshot on device if it support
 ETEXI
 
+#ifdef CONFIG_LIVE_BLOCK_OPS
+
     {
         .name       = "drive_mirror",
         .args_type  = "reuse:-n,full:-f,device:B,target:s,format:s?",
@@ -1267,6 +1277,8 @@ STEXI
 Start a point-in-time copy of a block device to a specificed target.
 ETEXI
 
+#endif /* CONFIG_LIVE_BLOCK_OPS */
+
     {
         .name       = "drive_add",
         .args_type  = "node:-n,pci_addr:s,opts:s",
hmp.c +12 -0
index fd80dce..ab985c6 100644
@@ -951,6 +951,8 @@ void hmp_info_pci(Monitor *mon, const QDict *qdict)
     qapi_free_PciInfoList(info_list);
 }
 
+#ifdef CONFIG_LIVE_BLOCK_OPS
+
 void hmp_info_block_jobs(Monitor *mon, const QDict *qdict)
 {
     BlockJobInfoList *list;
@@ -989,6 +991,8 @@ void hmp_info_block_jobs(Monitor *mon, const QDict *qdict)
     qapi_free_BlockJobInfoList(list);
 }
 
+#endif /* CONFIG_LIVE_BLOCK_OPS */
+
 void hmp_info_tpm(Monitor *mon, const QDict *qdict)
 {
     TPMInfoList *info_list, *info;
@@ -1197,6 +1201,8 @@ void hmp_block_resize(Monitor *mon, const QDict *qdict)
     hmp_handle_error(mon, &err);
 }
 
+#ifdef CONFIG_LIVE_BLOCK_OPS
+
 void hmp_drive_mirror(Monitor *mon, const QDict *qdict)
 {
     const char *filename = qdict_get_str(qdict, "target");
@@ -1280,6 +1286,8 @@ void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)
     hmp_handle_error(mon, &err);
 }
 
+#endif /* CONFIG_LIVE_BLOCK_OPS */
+
 void hmp_snapshot_blkdev_internal(Monitor *mon, const QDict *qdict)
 {
     const char *device = qdict_get_str(qdict, "device");
@@ -1776,6 +1784,8 @@ void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict)
     hmp_handle_error(mon, &err);
 }
 
+#ifdef CONFIG_LIVE_BLOCK_OPS
+
 void hmp_block_stream(Monitor *mon, const QDict *qdict)
 {
     Error *error = NULL;
@@ -1842,6 +1852,8 @@ void hmp_block_job_complete(Monitor *mon, const QDict *qdict)
     hmp_handle_error(mon, &error);
 }
 
+#endif /* CONFIG_LIVE_BLOCK_OPS */
+
 typedef struct HMPMigrationStatus
 {
     QEMUTimer *timer;
Signature · 1 line
2.9.5
#10 lore raw

Re: [Qemu-devel] [PATCH v2 3/3] hmp: Optionally disable live block operations in HMP monitor

Quoted 6 lines · * Jeff Cody ([email protected]) wrote:

From: Jeffrey Cody <[email protected]>

If live block operations are disabled, disable the corresponding HMP commands.

OK from HMP side, although perhaps it's worth squashing some of the commands so they're adjacent in the files.

Dave

Quoted 147 lines
---
 hmp-commands-info.hx |  4 ++++
 hmp-commands.hx      | 12 ++++++++++++
 hmp.c                | 12 ++++++++++++
 3 files changed, 28 insertions(+)
hmp-commands-info.hx +4 -0
index d9df238..0967e41 100644
@@ -84,6 +84,8 @@ STEXI
 Show block device statistics.
 ETEXI
 
+#ifdef CONFIG_LIVE_BLOCK_OPS
+
     {
         .name       = "block-jobs",
         .args_type  = "",
@@ -98,6 +100,8 @@ STEXI
 Show progress of ongoing block device operations.
 ETEXI
 
+#endif /* CONFIG_LIVE_BLOCK_OPS */
+
     {
         .name       = "registers",
         .args_type  = "cpustate_all:-a",
hmp-commands.hx +12 -0
index 1941e19..2d137a1 100644
@@ -73,6 +73,8 @@ but should be used with extreme caution.  Note that this command only
 resizes image files, it can not resize block devices like LVM volumes.
 ETEXI
 
+#ifdef CONFIG_LIVE_BLOCK_OPS
+
     {
         .name       = "block_stream",
         .args_type  = "device:B,speed:o?,base:s?",
@@ -159,6 +161,8 @@ STEXI
 Resume a paused block streaming operation.
 ETEXI
 
+#endif /* CONFIG_LIVE_BLOCK_OPS */
+
     {
         .name       = "eject",
         .args_type  = "force:-f,device:B",
@@ -1169,6 +1173,8 @@ STEXI
 Enables or disables migration mode.
 ETEXI
 
+#ifdef CONFIG_LIVE_BLOCK_OPS
+
     {
         .name       = "snapshot_blkdev",
         .args_type  = "reuse:-n,device:B,snapshot-file:s?,format:s?",
@@ -1190,6 +1196,8 @@ STEXI
 Snapshot device, using snapshot file as target if provided
 ETEXI
 
+#endif /* CONFIG_LIVE_BLOCK_OPS */
+
     {
         .name       = "snapshot_blkdev_internal",
         .args_type  = "device:B,name:s",
@@ -1224,6 +1232,8 @@ STEXI
 Delete an internal snapshot on device if it support
 ETEXI
 
+#ifdef CONFIG_LIVE_BLOCK_OPS
+
     {
         .name       = "drive_mirror",
         .args_type  = "reuse:-n,full:-f,device:B,target:s,format:s?",
@@ -1267,6 +1277,8 @@ STEXI
 Start a point-in-time copy of a block device to a specificed target.
 ETEXI
 
+#endif /* CONFIG_LIVE_BLOCK_OPS */
+
     {
         .name       = "drive_add",
         .args_type  = "node:-n,pci_addr:s,opts:s",
hmp.c +12 -0
index fd80dce..ab985c6 100644
@@ -951,6 +951,8 @@ void hmp_info_pci(Monitor *mon, const QDict *qdict)
     qapi_free_PciInfoList(info_list);
 }
 
+#ifdef CONFIG_LIVE_BLOCK_OPS
+
 void hmp_info_block_jobs(Monitor *mon, const QDict *qdict)
 {
     BlockJobInfoList *list;
@@ -989,6 +991,8 @@ void hmp_info_block_jobs(Monitor *mon, const QDict *qdict)
     qapi_free_BlockJobInfoList(list);
 }
 
+#endif /* CONFIG_LIVE_BLOCK_OPS */
+
 void hmp_info_tpm(Monitor *mon, const QDict *qdict)
 {
     TPMInfoList *info_list, *info;
@@ -1197,6 +1201,8 @@ void hmp_block_resize(Monitor *mon, const QDict *qdict)
     hmp_handle_error(mon, &err);
 }
 
+#ifdef CONFIG_LIVE_BLOCK_OPS
+
 void hmp_drive_mirror(Monitor *mon, const QDict *qdict)
 {
     const char *filename = qdict_get_str(qdict, "target");
@@ -1280,6 +1286,8 @@ void hmp_snapshot_blkdev(Monitor *mon, const QDict *qdict)
     hmp_handle_error(mon, &err);
 }
 
+#endif /* CONFIG_LIVE_BLOCK_OPS */
+
 void hmp_snapshot_blkdev_internal(Monitor *mon, const QDict *qdict)
 {
     const char *device = qdict_get_str(qdict, "device");
@@ -1776,6 +1784,8 @@ void hmp_block_set_io_throttle(Monitor *mon, const QDict *qdict)
     hmp_handle_error(mon, &err);
 }
 
+#ifdef CONFIG_LIVE_BLOCK_OPS
+
 void hmp_block_stream(Monitor *mon, const QDict *qdict)
 {
     Error *error = NULL;
@@ -1842,6 +1852,8 @@ void hmp_block_job_complete(Monitor *mon, const QDict *qdict)
     hmp_handle_error(mon, &error);
 }
 
+#endif /* CONFIG_LIVE_BLOCK_OPS */
+
 typedef struct HMPMigrationStatus
 {
     QEMUTimer *timer;
Signature · 1 line
2.9.5

--
Dr. David Alan Gilbert / [email protected] / Manchester, UK

#11 lore raw
In reply to Jeff Cody
Quoted 8 lines · Jeff Cody

This series adds a configurable option to disable live block operations.

The default is that live block operations are 'enabled'.

Jeffrey Cody (3):
configure: Add option in configure to disable live block ops
block-jobs: Optionally unregister live block operations
hmp: Optionally disable live block operations in HMP monitor

That doesn't match the spelling you've used on other contributions (see:
git shortlog --author=Cody | grep -v "^ "
for a demonstration); is it intentional, and do you want a .mailmap entry to merge your contributions under a preferred name?

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
Reviewed-by on the v2 series
#12 lore raw
In reply to Jeff Cody
Quoted 8 lines · Jeff Cody

This series adds a configurable option to disable live block operations.

The default is that live block operations are 'enabled'.

Jeffrey Cody (3):
configure: Add option in configure to disable live block ops
block-jobs: Optionally unregister live block operations
hmp: Optionally disable live block operations in HMP monitor

Series:

However, per the discussion on 2/3, you probably want a v2 of this series after we land conditional QAPI support first.

Signature · 3 lines
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3266
Virtualization:  qemu.org | libvirt.org
#13 lore raw
In reply to Jeff Cody

Am 30.08.2017 um 19:01 hat Jeff Cody geschrieben:

Quoted 3 lines

This series adds a configurable option to disable live block operations.

The default is that live block operations are 'enabled'.

Let me play dumb: Who would ever want to disable these? Is there a legitimate reason to do this except artificially making qemu less capable than it really is?

Kevin