Skip to contentSkip to conversation

Fix some quorum nits after merge

PATCH Superseded Benoît Canet 3 participants 10 messages Feb 22, 2014 Block layer

v2 of 3 Superseded Latest is v3 →

lore
Share & tools
lore
#6 lore raw

PATCH v2 3/3 qemu-io-test: Disable Quorum test when not compiled in.

In reply to Benoît Canet

Quorum is not compiled by default: make the quorum 081 test aware of this.

---
 tests/qemu-iotests/081 | 3 +++
 1 file changed, 3 insertions(+)
tests/qemu-iotests/081 +3 -0
index f053f11..c1078f6 100755
@@ -56,6 +56,9 @@ function run_qemu()
     do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qmp | _filter_qemu_io
 }
 
+test_quorum=$(qemu-img --help|grep quorum)
+[ "$test_quorum" = "" ] && _supported_fmt quorum
+
 quorum="file.driver=quorum,file.children.0.file.filename=$TEST_DIR/1.raw"
 quorum="$quorum,file.children.1.file.filename=$TEST_DIR/2.raw"
 quorum="$quorum,file.children.2.file.filename=$TEST_DIR/3.raw,file.vote-threshold=2"
Signature · 1 line
1.8.3.2
#1 lore raw

PATCH v2 1/3 qmp: Fix BlockdevOptionQuorum.

In reply to Benoît Canet

Fix some nits before QEMU 2.0 freeze.

---
 qapi-schema.json | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
qapi-schema.json +3 -2
index fcb22800..ab5cdde 100644
@@ -4437,10 +4437,11 @@
 # Driver specific block device options for Quorum
 #
 # @blkverify:      #optional true if the driver must print content mismatch
+#                  set to false by default
 #
-# @children:       the children block device to use
+# @children:       the children block devices to use
 #
-# @vote_threshold: the vote limit under which a read will fail
+# @vote-threshold: the vote limit under which a read will fail
 #
 # Since: 2.0
 ##
Signature · 1 line
1.8.3.2
#2 lore raw

PATCH v2 2/3 qmp: Make Quorum error events more palatable.

In reply to Benoît Canet

Insert quorum QMP events documentation alphabetically.

Also change the "ret" errno value by an optional "error" being an strerror(-ret) in the QUORUM_REPORT_BAD qmp event.

---
 block/quorum.c             |  9 ++++--
 docs/qmp/qmp-events.txt    | 75 ++++++++++++++++++++++++----------------------
 tests/qemu-iotests/081.out |  2 +-
 3 files changed, 46 insertions(+), 40 deletions(-)
block/quorum.c +6 -3
index 6c28239..bd997b7 100644
@@ -200,11 +200,14 @@ static void quorum_report_bad(QuorumAIOCB *acb, char *node_name, int ret)
 {
     QObject *data;
     assert(node_name);
-    data = qobject_from_jsonf("{ 'ret': %d"
-                              ", 'node-name': %s"
+    data = qobject_from_jsonf("{ 'node-name': %s"
                               ", 'sector-num': %" PRId64
                               ", 'sectors-count': %d }",
-                              ret, node_name, acb->sector_num, acb->nb_sectors);
+                              node_name, acb->sector_num, acb->nb_sectors);
+    if (ret < 0) {
+        QDict *dict = qobject_to_qdict(data);
+        qdict_put(dict, "error", qstring_from_str(strerror(-ret)));
+    }
     monitor_protocol_event(QEVENT_QUORUM_REPORT_BAD, data);
     qobject_decref(data);
 }
docs/qmp/qmp-events.txt +39 -36

84 lines not on this page · raw message

tests/qemu-iotests/081.out +1 -1
index 4fe2f95..84aeb0c 100644
@@ -30,7 +30,7 @@ Testing: -drive file=TEST_DIR/2.IMGFMT,format=IMGFMT,if=none,id=drive2
 QMP_VERSION
 {"return": {}}
 {"return": {}}
-{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "QUORUM_REPORT_BAD", "data": {"node-name": "", "ret": 0, "sectors-count": 20480, "sector-num": 0}}
+{"timestamp": {"seconds":  TIMESTAMP, "microseconds":  TIMESTAMP}, "event": "QUORUM_REPORT_BAD", "data": {"node-name": "", "sectors-count": 20480, "sector-num": 0}}
 read 10485760/10485760 bytes at offset 0
 10 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec)
 {"return": ""}
Signature · 1 line
1.8.3.2
#0 lore raw

v2 cover Fix some quorum nits after merge

in v2:

make error optional and return strerror(-ret) [Eric] better documentation of the error string [Eric] apply Eric reviewed by

Benoît Canet (3):
qmp: Fix BlockdevOptionQuorum.
qmp: Make Quorum error events more palatable.
qemu-io-test: Disable Quorum test when not compiled in.

 block/quorum.c             |  9 ++++--
 docs/qmp/qmp-events.txt    | 75 ++++++++++++++++++++++++----------------------
 qapi-schema.json           |  5 ++--
 tests/qemu-iotests/081     |  3 ++
 tests/qemu-iotests/081.out |  2 +-
 5 files changed, 52 insertions(+), 42 deletions(-)
Signature · 1 line
1.8.3.2
#3 lore raw

Re: [Qemu-devel] [PATCH V2 2/3] qmp: Make Quorum error events more palatable.

In reply to Benoît Canet
Quoted 10 lines · Benoît Canet

Insert quorum QMP events documentation alphabetically.

Also change the "ret" errno value by an optional "error" being an strerror(-ret) in the QUORUM_REPORT_BAD qmp event.

---

     assert(node_name);
block/quorum.c +0 -1
-    data = qobject_from_jsonf("{ 'ret': %d"

block/quorum.c static void quorum_report_bad(QuorumAIOCB *acb, char *node_name, int ret) · line 210

Quoted 10 lines
block/quorum.c +6 -2
-                              ", 'node-name': %s"
+    data = qobject_from_jsonf("{ 'node-name': %s"
                               ", 'sector-num': %" PRId64
                               ", 'sectors-count': %d }",
-                              ret, node_name, acb->sector_num, acb->nb_sectors);
+                              node_name, acb->sector_num, acb->nb_sectors);
+    if (ret < 0) {
+        QDict *dict = qobject_to_qdict(data);
+        qdict_put(dict, "error", qstring_from_str(strerror(-ret)));
+    }

This puts it in dict, but never modifies data...

Quoted 1 line
     monitor_protocol_event(QEVENT_QUORUM_REPORT_BAD, data);

...but you send data, not dict, over the wire.

It might be easier to do something like...

char *str = NULL;
if (ret < 0)

    str = strerror(-ret);
data = qobject_from_jsonf("{ 'node-name': %s"
                          "%s%s%s"
                          ", 'sector-num': %" PRId64
                          ", 'sectors-cont': %d }",
                          node_name,
                          str ? ", 'error': \"" : "", str ? str : "",
                          str ? "\"" : "",

...);

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#4 lore raw

Re: [Qemu-devel] [PATCH V2 2/3] qmp: Make Quorum error events more palatable.

Quoted 22 lines · Eric Blake
Quoted 10 lines · Benoît Canet

Insert quorum QMP events documentation alphabetically.

Also change the "ret" errno value by an optional "error" being an strerror(-ret) in the QUORUM_REPORT_BAD qmp event.

---

     assert(node_name);
block/quorum.c +0 -1
-    data = qobject_from_jsonf("{ 'ret': %d"

block/quorum.c static void quorum_report_bad(QuorumAIOCB *acb, char *node_name, int ret) · line 210

Quoted 10 lines
block/quorum.c +6 -2
-                              ", 'node-name': %s"
+    data = qobject_from_jsonf("{ 'node-name': %s"
                               ", 'sector-num': %" PRId64
                               ", 'sectors-count': %d }",
-                              ret, node_name, acb->sector_num, acb->nb_sectors);
+                              node_name, acb->sector_num, acb->nb_sectors);
+    if (ret < 0) {
+        QDict *dict = qobject_to_qdict(data);
+        qdict_put(dict, "error", qstring_from_str(strerror(-ret)));
+    }
Quoted 1 line

This puts it in dict, but never modifies data...

qobject_to_qdict is an enhanced cast.

/**
* qobject_to_qdict(): Convert a QObject into a QDict */
QDict *qobject_to_qdict(const QObject *obj)

{
    if (qobject_type(obj) != QTYPE_QDICT)
        return NULL;

    return container_of(obj, QDict, base);
}

Also I took this snippet of code from what you pointed me as an example for the error handling.

Best regards

Benoît

Quoted 23 lines
Quoted 2 lines
     monitor_protocol_event(QEVENT_QUORUM_REPORT_BAD, data);

...but you send data, not dict, over the wire.

It might be easier to do something like...

char *str = NULL;
if (ret < 0)

    str = strerror(-ret);
data = qobject_from_jsonf("{ 'node-name': %s"
                          "%s%s%s"
                          ", 'sector-num': %" PRId64
                          ", 'sectors-cont': %d }",
                          node_name,
                          str ? ", 'error': \"" : "", str ? str : "",
                          str ? "\"" : "",

...);

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

Reviewed-by
#5 lore raw

Re: [Qemu-devel] [PATCH V2 2/3] qmp: Make Quorum error events more palatable.

Quoted 20 lines · Benoît Canet
Quoted 6 lines

block/quorum.c static void quorum_report_bad(QuorumAIOCB *acb, char *node_name, int ret) · line 210

Quoted 4 lines
block/quorum.c +4 -0
+    if (ret < 0) {
+        QDict *dict = qobject_to_qdict(data);
+        qdict_put(dict, "error", qstring_from_str(strerror(-ret)));
+    }

This puts it in dict, but never modifies data...

qobject_to_qdict is an enhanced cast.

/**
* qobject_to_qdict(): Convert a QObject into a QDict */
QDict *qobject_to_qdict(const QObject *obj)

{
    if (qobject_type(obj) != QTYPE_QDICT)
        return NULL;

    return container_of(obj, QDict, base);
}
Quoted 2 lines

Also I took this snippet of code from what you pointed me as an example for the error handling.

Oh - now I see. Slick. In that case,

I'll let Kevin review 3/3.

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#7 lore raw

Re: [Qemu-devel] [PATCH V2 3/3] qemu-io-test: Disable Quorum test when not compiled in.

In reply to Benoît Canet
Quoted 12 lines · Benoît Canet

Quorum is not compiled by default: make the quorum 081 test aware of this.

---
 tests/qemu-iotests/081 | 3 +++
 1 file changed, 3 insertions(+)
tests/qemu-iotests/081 +0 -0
index f053f11..c1078f6 100755

tests/qemu-iotests/081 function run_qemu() · line 61

Quoted 6 lines
tests/qemu-iotests/081 +3 -0
@@ -56,6 +56,9 @@ function run_qemu()
     do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qmp | _filter_qemu_io
 }
 
+test_quorum=$(qemu-img --help|grep quorum)
+[ "$test_quorum" = "" ] && _supported_fmt quorum
+

How does this disable the test? When quorum is not compiled, the two lines are no-op. Did you test it?

qemu-img should be $QEMU_IMG.

I think you mean this:

    $QEMU_IMG --help | grep -q quorum && _not_run "quorum is not compiled"

Thanks,
Fam

#8 lore raw

Re: [Qemu-devel] [PATCH V2 3/3] qemu-io-test: Disable Quorum test when not compiled in.

Quoted 16 lines · Fam Zheng
Quoted 15 lines · Benoît Canet

Quorum is not compiled by default: make the quorum 081 test aware of this.

---
 tests/qemu-iotests/081 | 3 +++
 1 file changed, 3 insertions(+)
tests/qemu-iotests/081 +0 -0
index f053f11..c1078f6 100755
@@ -56,6 +56,9 @@ function run_qemu()
     do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qmp | _filter_qemu_io
 }
 
Quoted 6 lines

tests/qemu-iotests/081 function run_qemu() · line 61

Quoted 3 lines
tests/qemu-iotests/081 +3 -0
+test_quorum=$(qemu-img --help|grep quorum)
+[ "$test_quorum" = "" ] && _supported_fmt quorum
+

How does this disable the test? When quorum is not compiled, the two lines are no-op. Did you test it?

Yes I did test it. It works.

Quoted 9 lines

qemu-img should be $QEMU_IMG.

I think you mean this:

    $QEMU_IMG --help | grep -q quorum && _not_run "quorum is not compiled"

Thanks,
Fam

#9 lore raw

Re: [Qemu-devel] [PATCH V2 3/3] qemu-io-test: Disable Quorum test when not compiled in.

Quoted 17 lines · Benoît Canet
Quoted 16 lines · Fam Zheng
Quoted 15 lines · Benoît Canet

Quorum is not compiled by default: make the quorum 081 test aware of this.

---
 tests/qemu-iotests/081 | 3 +++
 1 file changed, 3 insertions(+)
tests/qemu-iotests/081 +0 -0
index f053f11..c1078f6 100755
@@ -56,6 +56,9 @@ function run_qemu()
     do_run_qemu "$@" 2>&1 | _filter_testdir | _filter_qmp | _filter_qemu_io
 }
 
Quoted 9 lines
Quoted 6 lines

tests/qemu-iotests/081 function run_qemu() · line 61

Quoted 3 lines
tests/qemu-iotests/081 +3 -0
+test_quorum=$(qemu-img --help|grep quorum)
+[ "$test_quorum" = "" ] && _supported_fmt quorum
+

How does this disable the test? When quorum is not compiled, the two lines are no-op. Did you test it?

Yes I did test it. It works.

Yes, I read it wrong, it should overwrite raw with quorum, so it works.

Still, qemu-img should be written $QEMU_IMG.

Thanks,
Fam