Skip to contentSkip to conversation

Block patches for 2.12-rc2

GIT PULL Applied Jeff Cody 2 participants 5 messages Apr 3, 2018 – Apr 4, 2018 Block layer

lore
Share & tools
lore

Jeff Cody

author
#0 lore raw

The following changes since commit f184de7553272223d6af731d7d623a7cebf710b5:

Merge remote-tracking branch 'remotes/riscv/tags/riscv-qemu-2.12-critical-fixes' into staging (2018-03-31 09:42:33 +0100)

are available in the git repository at:

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

for you to fetch changes up to 9dae635afa98f83688806861cefe77ff1b4d76a8:

gluster: Fix blockdev-add with server.N.type=unix (2018-04-03 09:57:14 -0400)

----------------------------------------------------------------
Blockjob and Gluster patches
----------------------------------------------------------------

Kevin Wolf (1):
gluster: Fix blockdev-add with server.N.type=unix

Marc-André Lureau (2):
blockjob: leak fix, remove from txn when failing early
blockjob: use qapi enum helpers

 block/gluster.c | 21 +++++++++++++++++----
 blockjob.c      | 28 +++++++++++++++++-----------
 2 files changed, 34 insertions(+), 15 deletions(-)
Signature · 1 line
2.13.6
author
#1 lore raw

[Qemu-devel] [PULL 2/3] blockjob: use qapi enum helpers

From: Marc-André Lureau <[email protected]>

QAPI generator provide #define helpers for looking up enum string.

Message-id: [email protected]

---
 blockjob.c | 14 +++++---------
 1 file changed, 5 insertions(+), 9 deletions(-)
blockjob.c +5 -9
index c510a9fde5..27f957e571 100644
@@ -75,10 +75,8 @@ static void block_job_state_transition(BlockJob *job, BlockJobStatus s1)
     assert(s1 >= 0 && s1 <= BLOCK_JOB_STATUS__MAX);
     trace_block_job_state_transition(job, job->ret, BlockJobSTT[s0][s1] ?
                                      "allowed" : "disallowed",
-                                     qapi_enum_lookup(&BlockJobStatus_lookup,
-                                                      s0),
-                                     qapi_enum_lookup(&BlockJobStatus_lookup,
-                                                      s1));
+                                     BlockJobStatus_str(s0),
+                                     BlockJobStatus_str(s1));
     assert(BlockJobSTT[s0][s1]);
     job->status = s1;
 }
@@ -86,17 +84,15 @@ static void block_job_state_transition(BlockJob *job, BlockJobStatus s1)
 static int block_job_apply_verb(BlockJob *job, BlockJobVerb bv, Error **errp)
 {
     assert(bv >= 0 && bv <= BLOCK_JOB_VERB__MAX);
-    trace_block_job_apply_verb(job, qapi_enum_lookup(&BlockJobStatus_lookup,
-                                                     job->status),
-                               qapi_enum_lookup(&BlockJobVerb_lookup, bv),
+    trace_block_job_apply_verb(job, BlockJobStatus_str(job->status),
+                               BlockJobVerb_str(bv),
                                BlockJobVerbTable[bv][job->status] ?
                                "allowed" : "prohibited");
     if (BlockJobVerbTable[bv][job->status]) {
         return 0;
     }
     error_setg(errp, "Job '%s' in state '%s' cannot accept command verb '%s'",
-               job->id, qapi_enum_lookup(&BlockJobStatus_lookup, job->status),
-               qapi_enum_lookup(&BlockJobVerb_lookup, bv));
+               job->id, BlockJobStatus_str(job->status), BlockJobVerb_str(bv));
     return -EPERM;
 }
 
Signature · 1 line
2.13.6
author
#2 lore raw

[Qemu-devel] [PULL 1/3] blockjob: leak fix, remove from txn when failing early

In reply to Jeff Cody

From: Marc-André Lureau <[email protected]>

This fixes leaks found by ASAN such as:
GTESTER tests/test-blockjob
=================================================================
==31442==ERROR: LeakSanitizer: detected memory leaks

Direct leak of 24 byte(s) in 1 object(s) allocated from:

    #0 0x7f88483cba38 in __interceptor_calloc (/lib64/libasan.so.4+0xdea38)
    #1 0x7f8845e1bd77 in g_malloc0 ../glib/gmem.c:129
    #2 0x7f8845e1c04b in g_malloc0_n ../glib/gmem.c:360
    #3 0x5584d2732498 in block_job_txn_new /home/elmarco/src/qemu/blockjob.c:172
    #4 0x5584d2739b28 in block_job_create /home/elmarco/src/qemu/blockjob.c:973
    #5 0x5584d270ae31 in mk_job /home/elmarco/src/qemu/tests/test-blockjob.c:34
    #6 0x5584d270b1c1 in do_test_id /home/elmarco/src/qemu/tests/test-blockjob.c:57
    #7 0x5584d270b65c in test_job_ids /home/elmarco/src/qemu/tests/test-blockjob.c:118
    #8 0x7f8845e40b69 in test_case_run ../glib/gtestutils.c:2255
    #9 0x7f8845e40f29 in g_test_run_suite_internal ../glib/gtestutils.c:2339
    #10 0x7f8845e40fd2 in g_test_run_suite_internal ../glib/gtestutils.c:2351
    #11 0x7f8845e411e9 in g_test_run_suite ../glib/gtestutils.c:2426
    #12 0x7f8845e3fe72 in g_test_run ../glib/gtestutils.c:1692
    #13 0x5584d270d6e2 in main /home/elmarco/src/qemu/tests/test-blockjob.c:377
    #14 0x7f8843641f29 in __libc_start_main (/lib64/libc.so.6+0x20f29)

Add an assert to make sure that the job doesn't have associated txn before free().

[Jeff Cody: N.B., used updated patch provided by John Snow]

---
 blockjob.c | 14 ++++++++++++--
 1 file changed, 12 insertions(+), 2 deletions(-)
blockjob.c +12 -2
index ef3ed69ff1..c510a9fde5 100644
@@ -204,6 +204,15 @@ void block_job_txn_add_job(BlockJobTxn *txn, BlockJob *job)
     block_job_txn_ref(txn);
 }
 
+static void block_job_txn_del_job(BlockJob *job)
+{
+    if (job->txn) {
+        QLIST_REMOVE(job, txn_list);
+        block_job_txn_unref(job->txn);
+        job->txn = NULL;
+    }
+}
+
 static void block_job_pause(BlockJob *job)
 {
     job->pause_count++;
@@ -232,6 +241,7 @@ void block_job_unref(BlockJob *job)
 {
     if (--job->refcnt == 0) {
         assert(job->status == BLOCK_JOB_STATUS_NULL);
+        assert(!job->txn);
         BlockDriverState *bs = blk_bs(job->blk);
         QLIST_REMOVE(job, job_list);
         bs->job = NULL;
@@ -392,6 +402,7 @@ static void block_job_decommission(BlockJob *job)
     job->busy = false;
     job->paused = false;
     job->deferred_to_main_loop = true;
+    block_job_txn_del_job(job);
     block_job_state_transition(job, BLOCK_JOB_STATUS_NULL);
     block_job_unref(job);
 }
@@ -481,8 +492,7 @@ static int block_job_finalize_single(BlockJob *job)
         }
     }
 
-    QLIST_REMOVE(job, txn_list);
-    block_job_txn_unref(job->txn);
+    block_job_txn_del_job(job);
     block_job_conclude(job);
     return 0;
 }
Signature · 1 line
2.13.6
author
#3 lore raw

[Qemu-devel] [PULL 3/3] gluster: Fix blockdev-add with server.N.type=unix

In reply to Jeff Cody

From: Kevin Wolf <[email protected]>

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

Message-id: [email protected]

---
 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
#4 lore raw
In reply to Jeff Cody
Quoted 19 lines · Jeff Cody

The following changes since commit f184de7553272223d6af731d7d623a7cebf710b5:

Merge remote-tracking branch 'remotes/riscv/tags/riscv-qemu-2.12-critical-fixes' into staging (2018-03-31 09:42:33 +0100)

are available in the git repository at:

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

for you to fetch changes up to 9dae635afa98f83688806861cefe77ff1b4d76a8:

gluster: Fix blockdev-add with server.N.type=unix (2018-04-03 09:57:14 -0400)

----------------------------------------------------------------
Blockjob and Gluster patches
----------------------------------------------------------------

Kevin Wolf (1):
gluster: Fix blockdev-add with server.N.type=unix

Quoted 7 lines

Marc-André Lureau (2):
blockjob: leak fix, remove from txn when failing early
blockjob: use qapi enum helpers

 block/gluster.c | 21 +++++++++++++++++----
 blockjob.c      | 28 +++++++++++++++++-----------
 2 files changed, 34 insertions(+), 15 deletions(-)

Applied, thanks.

-- PMM