From nobody Thu May 2 19:41:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) by mx.zohomail.com with SMTPS id 1522772178986550.3537108221923; Tue, 3 Apr 2018 09:16:18 -0700 (PDT) Received: from localhost ([::1]:46091 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f3Oba-0005p3-3A for importer@patchew.org; Tue, 03 Apr 2018 12:16:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50260) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f3OZ5-00044J-Vp for qemu-devel@nongnu.org; Tue, 03 Apr 2018 12:13:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f3OZ4-0005Fe-Va for qemu-devel@nongnu.org; Tue, 03 Apr 2018 12:13:43 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:45748 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f3OZ0-0005BZ-8F; Tue, 03 Apr 2018 12:13:38 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 2B118EB700; Tue, 3 Apr 2018 16:13:37 +0000 (UTC) Received: from localhost (ovpn-121-230.rdu2.redhat.com [10.10.121.230]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8D08C7C52; Tue, 3 Apr 2018 16:13:34 +0000 (UTC) From: Jeff Cody To: qemu-block@nongnu.org Date: Tue, 3 Apr 2018 12:13:22 -0400 Message-Id: <20180403161324.24514-2-jcody@redhat.com> In-Reply-To: <20180403161324.24514-1-jcody@redhat.com> References: <20180403161324.24514-1-jcody@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 03 Apr 2018 16:13:37 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 03 Apr 2018 16:13:37 +0000 (UTC) for IP:'10.11.54.5' DOMAIN:'int-mx05.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jcody@redhat.com' RCPT:'' Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 1/3] blockjob: leak fix, remove from txn when failing early X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , peter.maydell@linaro.org, jcody@redhat.com, qemu-devel@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Marc-Andr=C3=A9 Lureau This fixes leaks found by ASAN such as: GTESTER tests/test-blockjob =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D =3D=3D31442=3D=3DERROR: 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-block= job.c:57 #7 0x5584d270b65c in test_job_ids /home/elmarco/src/qemu/tests/test-blo= ckjob.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:23= 51 #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] Signed-off-by: Marc-Andr=C3=A9 Lureau Signed-off-by: Jeff Cody --- blockjob.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/blockjob.c b/blockjob.c index ef3ed69ff1..c510a9fde5 100644 --- a/blockjob.c +++ b/blockjob.c @@ -204,6 +204,15 @@ void block_job_txn_add_job(BlockJobTxn *txn, BlockJob = *job) block_job_txn_ref(txn); } =20 +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 =3D NULL; + } +} + static void block_job_pause(BlockJob *job) { job->pause_count++; @@ -232,6 +241,7 @@ void block_job_unref(BlockJob *job) { if (--job->refcnt =3D=3D 0) { assert(job->status =3D=3D BLOCK_JOB_STATUS_NULL); + assert(!job->txn); BlockDriverState *bs =3D blk_bs(job->blk); QLIST_REMOVE(job, job_list); bs->job =3D NULL; @@ -392,6 +402,7 @@ static void block_job_decommission(BlockJob *job) job->busy =3D false; job->paused =3D false; job->deferred_to_main_loop =3D 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) } } =20 - QLIST_REMOVE(job, txn_list); - block_job_txn_unref(job->txn); + block_job_txn_del_job(job); block_job_conclude(job); return 0; } --=20 2.13.6 From nobody Thu May 2 19:41:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1522772155939629.0391683976131; Tue, 3 Apr 2018 09:15:55 -0700 (PDT) Received: from localhost ([::1]:46087 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f3Ob6-0005Q2-ME for importer@patchew.org; Tue, 03 Apr 2018 12:15:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50254) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f3OZ5-00043p-Lk for qemu-devel@nongnu.org; Tue, 03 Apr 2018 12:13:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f3OZ4-0005FZ-Ra for qemu-devel@nongnu.org; Tue, 03 Apr 2018 12:13:43 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:45752 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f3OZ0-0005Ba-8K; Tue, 03 Apr 2018 12:13:38 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B659CEBFF0; Tue, 3 Apr 2018 16:13:37 +0000 (UTC) Received: from localhost (ovpn-121-230.rdu2.redhat.com [10.10.121.230]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 977132024CA1; Tue, 3 Apr 2018 16:13:37 +0000 (UTC) From: Jeff Cody To: qemu-block@nongnu.org Date: Tue, 3 Apr 2018 12:13:23 -0400 Message-Id: <20180403161324.24514-3-jcody@redhat.com> In-Reply-To: <20180403161324.24514-1-jcody@redhat.com> References: <20180403161324.24514-1-jcody@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 03 Apr 2018 16:13:37 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 03 Apr 2018 16:13:37 +0000 (UTC) for IP:'10.11.54.4' DOMAIN:'int-mx04.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jcody@redhat.com' RCPT:'' Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 2/3] blockjob: use qapi enum helpers X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , peter.maydell@linaro.org, jcody@redhat.com, qemu-devel@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" From: Marc-Andr=C3=A9 Lureau QAPI generator provide #define helpers for looking up enum string. Signed-off-by: Marc-Andr=C3=A9 Lureau Reviewed-by: John Snow Message-id: 20180327153011.29569-1-marcandre.lureau@redhat.com Signed-off-by: Jeff Cody --- blockjob.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/blockjob.c b/blockjob.c index c510a9fde5..27f957e571 100644 --- a/blockjob.c +++ b/blockjob.c @@ -75,10 +75,8 @@ static void block_job_state_transition(BlockJob *job, Bl= ockJobStatus s1) assert(s1 >=3D 0 && s1 <=3D BLOCK_JOB_STATUS__MAX); trace_block_job_state_transition(job, job->ret, BlockJobSTT[s0][s1] ? "allowed" : "disallowed", - qapi_enum_lookup(&BlockJobStatus_look= up, - s0), - qapi_enum_lookup(&BlockJobStatus_look= up, - s1)); + BlockJobStatus_str(s0), + BlockJobStatus_str(s1)); assert(BlockJobSTT[s0][s1]); job->status =3D s1; } @@ -86,17 +84,15 @@ static void block_job_state_transition(BlockJob *job, B= lockJobStatus s1) static int block_job_apply_verb(BlockJob *job, BlockJobVerb bv, Error **er= rp) { assert(bv >=3D 0 && bv <=3D BLOCK_JOB_VERB__MAX); - trace_block_job_apply_verb(job, qapi_enum_lookup(&BlockJobStatus_looku= p, - 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->stat= us), - qapi_enum_lookup(&BlockJobVerb_lookup, bv)); + job->id, BlockJobStatus_str(job->status), BlockJobVerb_str(= bv)); return -EPERM; } =20 --=20 2.13.6 From nobody Thu May 2 19:41:58 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) client-ip=208.118.235.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 208.118.235.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (208.118.235.17 [208.118.235.17]) by mx.zohomail.com with SMTPS id 1522772156657233.19264747365207; Tue, 3 Apr 2018 09:15:56 -0700 (PDT) Received: from localhost ([::1]:46089 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f3ObD-0005XH-K9 for importer@patchew.org; Tue, 03 Apr 2018 12:15:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:50270) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f3OZ6-00044b-B3 for qemu-devel@nongnu.org; Tue, 03 Apr 2018 12:13:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f3OZ5-0005Fr-B1 for qemu-devel@nongnu.org; Tue, 03 Apr 2018 12:13:44 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:45756 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1f3OZ0-0005DJ-Ve; Tue, 03 Apr 2018 12:13:39 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 9D217EB700; Tue, 3 Apr 2018 16:13:38 +0000 (UTC) Received: from localhost (ovpn-121-230.rdu2.redhat.com [10.10.121.230]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 29971215CDAF; Tue, 3 Apr 2018 16:13:38 +0000 (UTC) From: Jeff Cody To: qemu-block@nongnu.org Date: Tue, 3 Apr 2018 12:13:24 -0400 Message-Id: <20180403161324.24514-4-jcody@redhat.com> In-Reply-To: <20180403161324.24514-1-jcody@redhat.com> References: <20180403161324.24514-1-jcody@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 03 Apr 2018 16:13:38 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.11.55.1]); Tue, 03 Apr 2018 16:13:38 +0000 (UTC) for IP:'10.11.54.6' DOMAIN:'int-mx06.intmail.prod.int.rdu2.redhat.com' HELO:'smtp.corp.redhat.com' FROM:'jcody@redhat.com' RCPT:'' X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 66.187.233.73 Subject: [Qemu-devel] [PULL 3/3] gluster: Fix blockdev-add with server.N.type=unix X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Kevin Wolf , peter.maydell@linaro.org, jcody@redhat.com, qemu-stable@nongnu.org, qemu-devel@nongnu.org, =?UTF-8?q?Marc-Andr=C3=A9=20Lureau?= Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" From: Kevin Wolf 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=3D1545155 Cc: qemu-stable@nongnu.org Signed-off-by: Kevin Wolf Message-id: 20180403110810.25624-1-kwolf@redhat.com Signed-off-by: Jeff Cody --- block/gluster.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/block/gluster.c b/block/gluster.c index 296e036b3d..4adc1a875b 100644 --- a/block/gluster.c +++ b/block/gluster.c @@ -167,7 +167,12 @@ static QemuOptsList runtime_unix_opts =3D { { .name =3D GLUSTER_OPT_SOCKET, .type =3D QEMU_OPT_STRING, - .help =3D "socket file path)", + .help =3D "socket file path (legacy)", + }, + { + .name =3D GLUSTER_OPT_PATH, + .type =3D QEMU_OPT_STRING, + .help =3D "socket file path (QAPI)", }, { /* end of list */ } }, @@ -615,10 +620,18 @@ static int qemu_gluster_parse_json(BlockdevOptionsGlu= ster *gconf, goto out; } =20 - ptr =3D qemu_opt_get(opts, GLUSTER_OPT_SOCKET); + ptr =3D qemu_opt_get(opts, GLUSTER_OPT_PATH); + if (!ptr) { + ptr =3D 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 *g= conf, "file.server.0.host=3D1.2.3.4," "file.server.0.port=3D24007," "file.server.1.transport=3Dunix," - "file.server.1.socket=3D/var/run/glusterd.soc= ket ..." + "file.server.1.path=3D/var/run/glusterd.socke= t ..." "\n"); return ret; } --=20 2.13.6