From nobody Fri May 3 11:05:54 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.zoho.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 1491918383444201.04264180516236; Tue, 11 Apr 2017 06:46:23 -0700 (PDT) Received: from localhost ([::1]:39388 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxw7h-0000WW-NR for importer@patchew.org; Tue, 11 Apr 2017 09:46:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59732) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxw6D-0007w7-Lh for qemu-devel@nongnu.org; Tue, 11 Apr 2017 09:44:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cxw6C-0002a4-GQ for qemu-devel@nongnu.org; Tue, 11 Apr 2017 09:44:49 -0400 Received: from mx1.redhat.com ([209.132.183.28]:34066) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cxw64-0002Wv-TI; Tue, 11 Apr 2017 09:44:41 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id A8C178046C; Tue, 11 Apr 2017 13:44:39 +0000 (UTC) Received: from localhost (ovpn-204-201.brq.redhat.com [10.40.204.201]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 30ECE18ED2; Tue, 11 Apr 2017 13:44:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com A8C178046C Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx04.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mreitz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com A8C178046C From: Max Reitz To: qemu-block@nongnu.org Date: Tue, 11 Apr 2017 15:44:33 +0200 Message-Id: <20170411134435.27271-2-mreitz@redhat.com> In-Reply-To: <20170411134435.27271-1-mreitz@redhat.com> References: <20170411134435.27271-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Tue, 11 Apr 2017 13:44:39 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 1/3] block: pass the right options for BlockDriver.bdrv_open() 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: Peter Maydell , qemu-devel@nongnu.org, Max Reitz 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: Dong Jia Shi raw_open() expects the caller always passing in the right actual @options parameter. But when trying to applying snapshot on a RBD image, bdrv_snapshot_goto() calls raw_open() (by calling the bdrv_open callback on the BlockDriver) with a NULL @options, and that will result in a Segmentation fault. For the other non-raw format drivers, it also makes sense to passing in the actual options, althought they don't trigger the problem so far. Let's prepare a @options by adding the "file" key-value pair to a copy of the actual options that were given for the node (i.e. bs->options), and pass it to the callback. BlockDriver.bdrv_open() expects bs->file to be NULL and just overwrites it with the result from bdrv_open_child(). That means we should actually make sure it's NULL because otherwise the child BDS will have a reference count that is 1 too high. So we unconditionally invoke bdrv_unref_child() before calling BlockDriver.bdrv_open(), and we wrap everything in bdrv_ref()/bdrv_unref() so the BDS isn't deleted in the meantime. Suggested-by: Max Reitz Signed-off-by: Dong Jia Shi Message-id: 20170405091909.36357-2-bjsdjshi@linux.vnet.ibm.com Signed-off-by: Max Reitz --- block/snapshot.c | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/block/snapshot.c b/block/snapshot.c index bf5c2ca5e1..06b1185d27 100644 --- a/block/snapshot.c +++ b/block/snapshot.c @@ -27,6 +27,7 @@ #include "block/block_int.h" #include "qapi/error.h" #include "qapi/qmp/qerror.h" +#include "qapi/qmp/qstring.h" =20 QemuOptsList internal_snapshot_opts =3D { .name =3D "snapshot", @@ -189,14 +190,33 @@ int bdrv_snapshot_goto(BlockDriverState *bs, } =20 if (bs->file) { + BlockDriverState *file; + QDict *options =3D qdict_clone_shallow(bs->options); + QDict *file_options; + + file =3D bs->file->bs; + /* Prevent it from getting deleted when detached from bs */ + bdrv_ref(file); + + qdict_extract_subqdict(options, &file_options, "file."); + QDECREF(file_options); + qdict_put(options, "file", qstring_from_str(bdrv_get_node_name(fil= e))); + drv->bdrv_close(bs); - ret =3D bdrv_snapshot_goto(bs->file->bs, snapshot_id); - open_ret =3D drv->bdrv_open(bs, NULL, bs->open_flags, NULL); + bdrv_unref_child(bs, bs->file); + bs->file =3D NULL; + + ret =3D bdrv_snapshot_goto(file, snapshot_id); + open_ret =3D drv->bdrv_open(bs, options, bs->open_flags, NULL); + QDECREF(options); if (open_ret < 0) { - bdrv_unref(bs->file->bs); + bdrv_unref(file); bs->drv =3D NULL; return open_ret; } + + assert(bs->file->bs =3D=3D file); + bdrv_unref(file); return ret; } =20 --=20 2.12.2 From nobody Fri May 3 11:05:54 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.zoho.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 1491918380944717.4549078455705; Tue, 11 Apr 2017 06:46:20 -0700 (PDT) Received: from localhost ([::1]:39387 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxw7f-0000U9-6D for importer@patchew.org; Tue, 11 Apr 2017 09:46:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59716) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxw6B-0007uL-Fu for qemu-devel@nongnu.org; Tue, 11 Apr 2017 09:44:48 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cxw6A-0002Z9-6x for qemu-devel@nongnu.org; Tue, 11 Apr 2017 09:44:47 -0400 Received: from mx1.redhat.com ([209.132.183.28]:35760) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cxw67-0002Xf-3C; Tue, 11 Apr 2017 09:44:43 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F0AD1C04B94E; Tue, 11 Apr 2017 13:44:41 +0000 (UTC) Received: from localhost (ovpn-204-201.brq.redhat.com [10.40.204.201]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8529C62923; Tue, 11 Apr 2017 13:44:41 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com F0AD1C04B94E Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx07.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mreitz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com F0AD1C04B94E From: Max Reitz To: qemu-block@nongnu.org Date: Tue, 11 Apr 2017 15:44:34 +0200 Message-Id: <20170411134435.27271-3-mreitz@redhat.com> In-Reply-To: <20170411134435.27271-1-mreitz@redhat.com> References: <20170411134435.27271-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Tue, 11 Apr 2017 13:44:42 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 2/3] throttle: Remove block from group on hot-unplug 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: Peter Maydell , qemu-devel@nongnu.org, Max Reitz 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: Eric Blake When a block device that is part of a throttle group is hot-unplugged, we forgot to remove it from the throttle group. This leaves stale memory around, and causes an easily reproducible crash: $ ./x86_64-softmmu/qemu-system-x86_64 -nodefaults -nographic -qmp stdio \ -device virtio-scsi-pci,bus=3Dpci.0 -drive \ id=3Ddrive_image2,if=3Dnone,format=3Draw,file=3Dfile2,bps=3D512000,iops=3D1= 00,group=3Dfoo \ -device scsi-hd,id=3Dimage2,drive=3Ddrive_image2 -drive \ id=3Ddrive_image3,if=3Dnone,format=3Draw,file=3Dfile3,bps=3D512000,iops=3D1= 00,group=3Dfoo \ -device scsi-hd,id=3Dimage3,drive=3Ddrive_image3 {'execute':'qmp_capabilities'} {'execute':'device_del','arguments':{'id':'image3'}} {'execute':'system_reset'} Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=3D1428810 Suggested-by: Alberto Garcia Signed-off-by: Eric Blake Message-id: 20170406190847.29347-1-eblake@redhat.com Reviewed-by: Stefan Hajnoczi Signed-off-by: Max Reitz --- block/block-backend.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/block/block-backend.c b/block/block-backend.c index a8f2b3440f..7405024e08 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -231,6 +231,9 @@ static void blk_delete(BlockBackend *blk) assert(!blk->refcnt); assert(!blk->name); assert(!blk->dev); + if (blk->public.throttle_state) { + blk_io_limits_disable(blk); + } if (blk->root) { blk_remove_bs(blk); } --=20 2.12.2 From nobody Fri May 3 11:05:54 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.zoho.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 1491918395161982.4535077720502; Tue, 11 Apr 2017 06:46:35 -0700 (PDT) Received: from localhost ([::1]:39389 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxw7t-0000ib-Rd for importer@patchew.org; Tue, 11 Apr 2017 09:46:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59778) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cxw6K-00083j-0g for qemu-devel@nongnu.org; Tue, 11 Apr 2017 09:45:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cxw6J-0002fW-6J for qemu-devel@nongnu.org; Tue, 11 Apr 2017 09:44:56 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48624) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cxw69-0002YO-BE; Tue, 11 Apr 2017 09:44:45 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 574E4A2892; Tue, 11 Apr 2017 13:44:44 +0000 (UTC) Received: from localhost (ovpn-204-201.brq.redhat.com [10.40.204.201]) by smtp.corp.redhat.com (Postfix) with ESMTPS id CEF51BA011; Tue, 11 Apr 2017 13:44:43 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 574E4A2892 Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=mreitz@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 574E4A2892 From: Max Reitz To: qemu-block@nongnu.org Date: Tue, 11 Apr 2017 15:44:35 +0200 Message-Id: <20170411134435.27271-4-mreitz@redhat.com> In-Reply-To: <20170411134435.27271-1-mreitz@redhat.com> References: <20170411134435.27271-1-mreitz@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 11 Apr 2017 13:44:44 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PULL 3/3] iscsi: Fix iscsi_create 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: Peter Maydell , qemu-devel@nongnu.org, Max Reitz 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: Fam Zheng Since d5895fcb (iscsi: Split URL into individual options), creating qcow2 image on an iscsi LUN fails: qemu-img create -f qcow2 iscsi://$SERVER/$IQN/0 1G qemu-img: iscsi://$SERVER/$IQN/0: Could not create image: Invalid argument The problem is iscsi_open now expects that transport_name, portal and target are already parsed into structured options by iscsi_parse_filename, but it is not called in iscsi_create. Signed-off-by: Fam Zheng Message-id: 20170410075451.21329-1-famz@redhat.com Reviewed-by: Eric Blake [mreitz: Dropped now superfluous qdict_put(bs_options, "filename", ...)] Signed-off-by: Max Reitz --- block/iscsi.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/block/iscsi.c b/block/iscsi.c index 716e74abba..42fb0b019c 100644 --- a/block/iscsi.c +++ b/block/iscsi.c @@ -2092,6 +2092,7 @@ static int iscsi_create(const char *filename, QemuOpt= s *opts, Error **errp) BlockDriverState *bs; IscsiLun *iscsilun =3D NULL; QDict *bs_options; + Error *local_err =3D NULL; =20 bs =3D bdrv_new(); =20 @@ -2102,8 +2103,13 @@ static int iscsi_create(const char *filename, QemuOp= ts *opts, Error **errp) iscsilun =3D bs->opaque; =20 bs_options =3D qdict_new(); - qdict_put(bs_options, "filename", qstring_from_str(filename)); - ret =3D iscsi_open(bs, bs_options, 0, NULL); + iscsi_parse_filename(filename, bs_options, &local_err); + if (local_err) { + error_propagate(errp, local_err); + ret =3D -EINVAL; + } else { + ret =3D iscsi_open(bs, bs_options, 0, NULL); + } QDECREF(bs_options); =20 if (ret !=3D 0) { --=20 2.12.2