Skip to contentSkip to conversation

block-commit: speed is an optional parameter

PATCH Applied Max Reitz 4 participants 4 messages Apr 10, 2014 – Apr 11, 2014

lore
Share & tools
lore

Max Reitz

author
#0 lore raw

PATCH 1/1 block-commit: speed is an optional parameter

As speed is an optional parameter for the QMP block-commit command, it should be set to 0 if not given (as it is undefined if has_speed is false), that is, the speed should not be limited.

---
This patch was previously part of the "qemu-img: Implement commit like QMP" series, but as this is a general bugfix, it has been separated.

---
 blockdev.c | 4 ++++
 1 file changed, 4 insertions(+)
blockdev.c +4 -0
index c3422a1..5dd01ea 100644
@@ -1876,6 +1876,10 @@ void qmp_block_commit(const char *device,
      */
     BlockdevOnError on_error = BLOCKDEV_ON_ERROR_REPORT;
 
+    if (!has_speed) {
+        speed = 0;
+    }
+
     /* drain all i/o before commits */
     bdrv_drain_all();
 
Signature · 1 line
1.9.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 10 lines · Max Reitz

As speed is an optional parameter for the QMP block-commit command, it should be set to 0 if not given (as it is undefined if has_speed is false), that is, the speed should not be limited.

---
This patch was previously part of the "qemu-img: Implement commit like QMP" series, but as this is a general bugfix, it has been separated.
---

The (generated) caller qmp_marshal_input_block_commit() actually leaves speed uninitialized, so we're not safe without this patch:

int qmp_marshal_input_block_commit(Monitor *mon, const QDict *qdict, QObject **ret)

{
    Error *local_err = NULL;
    Error **errp = &local_err;
    QDict *args = (QDict *)qdict;
    QmpInputVisitor *mi;
    QapiDeallocVisitor *md;
    Visitor *v;
    char * device = NULL;
    bool has_base = false;
    char * base = NULL;
    char * top = NULL;
    bool has_speed = false;
    int64_t speed;

I'm wondering what the reason is to initialize pointers (like base and device) while leaving int64_t values uninitilized in the code generator?

Fam

Quoted 22 lines
 blockdev.c | 4 ++++
 1 file changed, 4 insertions(+)
blockdev.c +4 -0
index c3422a1..5dd01ea 100644
@@ -1876,6 +1876,10 @@ void qmp_block_commit(const char *device,
      */
     BlockdevOnError on_error = BLOCKDEV_ON_ERROR_REPORT;
 
+    if (!has_speed) {
+        speed = 0;
+    }
+
     /* drain all i/o before commits */
     bdrv_drain_all();
 
Signature · 1 line
1.9.1
#2 lore raw
Quoted 12 lines · Fam Zheng
Quoted 10 lines · Max Reitz

As speed is an optional parameter for the QMP block-commit command, it should be set to 0 if not given (as it is undefined if has_speed is false), that is, the speed should not be limited.

---
This patch was previously part of the "qemu-img: Implement commit like QMP" series, but as this is a general bugfix, it has been separated.
---

Quoted 7 lines

The (generated) caller qmp_marshal_input_block_commit() actually leaves speed uninitialized, so we're not safe without this patch:

I'm wondering what the reason is to initialize pointers (like base and device) while leaving int64_t values uninitilized in the code generator?

Because no one has applied this patch yet:

https://lists.gnu.org/archive/html/qemu-devel/2014-03/msg04224.html

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
Applied
#3 lore raw
In reply to Max Reitz

Am 10.04.2014 um 19:36 hat Max Reitz geschrieben:

Quoted 9 lines

As speed is an optional parameter for the QMP block-commit command, it should be set to 0 if not given (as it is undefined if has_speed is false), that is, the speed should not be limited.

---
This patch was previously part of the "qemu-img: Implement commit like QMP" series, but as this is a general bugfix, it has been separated.

Thanks, applied to the block branch.

In future patches, please add an explicit 'Cc: [email protected]' line to the commit message so that the stable maintainers can grep in git log for candidates. I added it manually while applying.

Kevin