From patchwork Tue Aug 29 00:13:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806824 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh8cb4kGKz9sNc for ; Tue, 29 Aug 2017 10:28:15 +1000 (AEST) Received: from localhost ([::1]:41945 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUO5-0003UA-Dt for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:28:13 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47551) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCD-0000vq-Ee for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:58 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCA-0005BC-6t for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:57 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:52537 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUC9-0005An-TR for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:53 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0E9EW081566 for ; Mon, 28 Aug 2017 20:15:53 -0400 Received: from e14.ny.us.ibm.com (e14.ny.us.ibm.com [129.33.205.204]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmurncr89-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:15:53 -0400 Received: from localhost by e14.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 20:15:52 -0400 Received: from b01cxnp23032.gho.pok.ibm.com (9.57.198.27) by e14.ny.us.ibm.com (146.89.104.201) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 20:15:50 -0400 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0FnGs25821362; Tue, 29 Aug 2017 00:15:49 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D32E1B2050; Mon, 28 Aug 2017 20:13:13 -0400 (EDT) Received: from localhost (unknown [9.80.85.217]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP id 9AD1FB2046; Mon, 28 Aug 2017 20:13:13 -0400 (EDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:13:36 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0052-0000-0000-00000257332C X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:15:51 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0053-0000-0000-000051D1D922 Message-Id: <1503965694-10794-2-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 01/79] qga-win: Enable 'can-offline' field in 'guest-get-vcpus' reply 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: Sameeh Jubran , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Sameeh Jubran The QGA schema states: @can-offline: Whether offlining the VCPU is possible. This member is always filled in by the guest agent when the structure is returned, and always ignored on input (hence it can be omitted then). Currently 'can-offline' is missing entirely from the reply. This causes errors in libvirt which is expecting the reply to be compliant with the schema docs. BZ#1438735: https://bugzilla.redhat.com/show_bug.cgi?id=1438735 Signed-off-by: Sameeh Jubran Reviewed-by: Eric Blake Cc: qemu-stable@nongnu.org Signed-off-by: Michael Roth (cherry picked from commit 54858553def1879a3b0781529fb12a028ba36713) Signed-off-by: Michael Roth --- qga/commands-win32.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/qga/commands-win32.c b/qga/commands-win32.c index 19d72b2..f0d72a0 100644 --- a/qga/commands-win32.c +++ b/qga/commands-win32.c @@ -1344,7 +1344,7 @@ GuestLogicalProcessorList *qmp_guest_get_vcpus(Error **errp) vcpu = g_malloc0(sizeof *vcpu); vcpu->logical_id = current++; vcpu->online = true; - vcpu->has_can_offline = false; + vcpu->has_can_offline = true; entry = g_malloc0(sizeof *entry); entry->value = vcpu; From patchwork Tue Aug 29 00:13:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806822 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh8Zl17CZz9s65 for ; Tue, 29 Aug 2017 10:26:39 +1000 (AEST) Received: from localhost ([::1]:41935 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUMW-00027z-V7 for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:26:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47898) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCO-0001An-F5 for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCL-0005Od-B4 for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:08 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:56042) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCL-0005Ni-2o for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:05 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0EBYL042759 for ; Mon, 28 Aug 2017 20:16:04 -0400 Received: from e19.ny.us.ibm.com (e19.ny.us.ibm.com [129.33.205.209]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmr8neywe-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:04 -0400 Received: from localhost by e19.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 20:16:02 -0400 Received: from b01cxnp22034.gho.pok.ibm.com (9.57.198.24) by e19.ny.us.ibm.com (146.89.104.206) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 20:15:59 -0400 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp22034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0FwZH21758018; Tue, 29 Aug 2017 00:15:58 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9680CB204D; Mon, 28 Aug 2017 20:13:22 -0400 (EDT) Received: from localhost (unknown [9.80.85.217]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP id 5E0C4B2050; Mon, 28 Aug 2017 20:13:22 -0400 (EDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:13:37 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0056-0000-0000-000003BDDBC5 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909027; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:01 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0057-0000-0000-000007F40C6E Message-Id: <1503965694-10794-3-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 02/79] dirty-bitmap: Report BlockDirtyInfo.count in bytes, as documented 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 , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Eric Blake We've been documenting the value in bytes since its introduction in commit b9a9b3a4 (v1.3), where it was actually reported in bytes. Commit e4654d2 (v2.0) then removed things from block/qapi.c, in preparation for a rewrite to a list of dirty sectors in the next commit 21b5683 in block.c, but the new code mistakenly started reporting in sectors. Fixes: https://bugzilla.redhat.com/1441460 CC: qemu-stable@nongnu.org Signed-off-by: Eric Blake Reviewed-by: John Snow Reviewed-by: Stefan Hajnoczi Signed-off-by: Kevin Wolf (cherry picked from commit 6c98c57af3f4fab85bdf5f01616c91322bd4312a) Signed-off-by: Michael Roth --- block/dirty-bitmap.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/dirty-bitmap.c b/block/dirty-bitmap.c index 519737c..6d8ce5f 100644 --- a/block/dirty-bitmap.c +++ b/block/dirty-bitmap.c @@ -345,7 +345,7 @@ BlockDirtyInfoList *bdrv_query_dirty_bitmaps(BlockDriverState *bs) QLIST_FOREACH(bm, &bs->dirty_bitmaps, list) { BlockDirtyInfo *info = g_new0(BlockDirtyInfo, 1); BlockDirtyInfoList *entry = g_new0(BlockDirtyInfoList, 1); - info->count = bdrv_get_dirty_count(bm); + info->count = bdrv_get_dirty_count(bm) << BDRV_SECTOR_BITS; info->granularity = bdrv_dirty_bitmap_granularity(bm); info->has_name = !!bm->name; info->name = g_strdup(bm->name); From patchwork Tue Aug 29 00:13:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806852 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh91F42wJz9s7M for ; Tue, 29 Aug 2017 10:46:09 +1000 (AEST) Received: from localhost ([::1]:42054 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUfP-0002wU-Ce for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:46:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48049) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCT-0001HZ-Ap for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCQ-0005Sd-6C for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:13 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:53228 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCQ-0005S2-1O for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:10 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0EAXM081588 for ; Mon, 28 Aug 2017 20:16:09 -0400 Received: from e14.ny.us.ibm.com (e14.ny.us.ibm.com [129.33.205.204]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmurncrm7-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:09 -0400 Received: from localhost by e14.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 20:16:08 -0400 Received: from b01cxnp22033.gho.pok.ibm.com (9.57.198.23) by e14.ny.us.ibm.com (146.89.104.201) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 20:16:07 -0400 Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0G6vo24182832; Tue, 29 Aug 2017 00:16:07 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 45D28124044; Mon, 28 Aug 2017 20:13:27 -0400 (EDT) Received: from localhost (unknown [9.80.85.217]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTP id 0E920124035; Mon, 28 Aug 2017 20:13:27 -0400 (EDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:13:38 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 17082900-0052-0000-0000-000002573357 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:08 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0053-0000-0000-000051D1D963 Message-Id: <1503965694-10794-4-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-MIME-Autoconverted: from 8bit to quoted-printable by mx0a-001b2d01.pphosted.com id v7T0EAXM081588 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 03/79] qemu-img/convert: Always set ret < 0 on error 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: qemu-stable@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Max Reitz Otherwise the qemu-img process will exit with EXIT_SUCCESS instead of EXIT_FAILURE. Cc: qemu-stable Signed-off-by: Max Reitz Reviewed-by: Eric Blake Reviewed-by: Philippe Mathieu-Daudé * applied directly to stable, upstream code has issue fixed via a refactoring introduced by 9fd77f9, which isn't targetted for stable Signed-off-by: Michael Roth --- qemu-img.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/qemu-img.c b/qemu-img.c index b220cf7..9aa7823 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -2069,6 +2069,7 @@ static int img_convert(int argc, char **argv) opts = qemu_opts_parse_noisily(&qemu_object_opts, optarg, true); if (!opts) { + ret = -1; goto fail_getopt; } break; @@ -2081,6 +2082,7 @@ static int img_convert(int argc, char **argv) if (qemu_opts_foreach(&qemu_object_opts, user_creatable_add_opts_foreach, NULL, NULL)) { + ret = -1; goto fail_getopt; } From patchwork Tue Aug 29 00:13:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806851 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh90W0Z0pz9s7M for ; Tue, 29 Aug 2017 10:45:31 +1000 (AEST) Received: from localhost ([::1]:42044 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUem-00023U-Uv for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:45:28 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48422) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCe-0001Ul-MW for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCb-0005kg-Fw for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:24 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:34977) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCb-0005jC-6o for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:21 -0400 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0F3Fr052211 for ; Mon, 28 Aug 2017 20:16:20 -0400 Received: from e14.ny.us.ibm.com (e14.ny.us.ibm.com [129.33.205.204]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmwga06ku-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:20 -0400 Received: from localhost by e14.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 20:16:18 -0400 Received: from b01cxnp23033.gho.pok.ibm.com (9.57.198.28) by e14.ny.us.ibm.com (146.89.104.201) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 20:16:16 -0400 Received: from b01ledav001.gho.pok.ibm.com (b01ledav001.gho.pok.ibm.com [9.57.199.106]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0GFar55116004; Tue, 29 Aug 2017 00:16:15 GMT Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 1991928046; Mon, 28 Aug 2017 20:16:09 -0400 (EDT) Received: from localhost (unknown [9.80.85.217]) by b01ledav001.gho.pok.ibm.com (Postfix) with ESMTP id D6C6D2804A; Mon, 28 Aug 2017 20:16:08 -0400 (EDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:13:39 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0052-0000-0000-000002573367 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:17 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0053-0000-0000-000051D1D987 Message-Id: <1503965694-10794-5-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 04/79] qemu-img/convert: Use @opts for one thing only 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: qemu-stable@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Max Reitz After storing the creation options for the new image into @opts, we fetch some things for our own information, like the backing file name, or whether to use encryption or preallocation. With the -n parameter, there will not be any creation options; this is not too bad because this just means that querying a NULL @opts will always return the default value. However, we also use @opts for the --object options. Therefore, @opts is not necessarily NULL if -n was specified; instead, it may contain those options. In practice, this probably does not cause any problems because there most likely is no object that supports any of the parameters we query here, but this is neither something we should rely on nor does this variable reuse make the code very nice to read. Therefore, just use an own variable for the --object options. Cc: qemu-stable Signed-off-by: Max Reitz Reviewed-by: Eric Blake * applied patch from v1 of series as suggested by author Signed-off-by: Michael Roth --- qemu-img.c | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index 9aa7823..cfc3bc3 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -2065,14 +2065,16 @@ static int img_convert(int argc, char **argv) case 'W': wr_in_order = false; break; - case OPTION_OBJECT: - opts = qemu_opts_parse_noisily(&qemu_object_opts, - optarg, true); - if (!opts) { + case OPTION_OBJECT: { + QemuOpts *object_opts; + object_opts = qemu_opts_parse_noisily(&qemu_object_opts, + optarg, true); + if (!object_opts) { ret = -1; goto fail_getopt; } break; + } case OPTION_IMAGE_OPTS: image_opts = true; break; From patchwork Tue Aug 29 00:13:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806867 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh9HM5yjlz9s7g for ; Tue, 29 Aug 2017 10:58:23 +1000 (AEST) Received: from localhost ([::1]:42118 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUrF-00053Z-KG for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:58:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48723) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCm-0001dx-Pk for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCj-000603-IX for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:32 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:35078 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCj-0005zQ-DQ for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:29 -0400 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0E8qJ017779 for ; Mon, 28 Aug 2017 20:16:29 -0400 Received: from e34.co.us.ibm.com (e34.co.us.ibm.com [32.97.110.152]) by mx0b-001b2d01.pphosted.com with ESMTP id 2cmub2ww78-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:28 -0400 Received: from localhost by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 18:16:28 -0600 Received: from b03cxnp08027.gho.boulder.ibm.com (9.17.130.19) by e34.co.us.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 18:16:24 -0600 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0GO3962128192; Mon, 28 Aug 2017 17:16:24 -0700 Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2C3D6C6042; Mon, 28 Aug 2017 18:16:24 -0600 (MDT) Received: from localhost (unknown [9.80.85.217]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP id ED29EC6037; Mon, 28 Aug 2017 18:16:23 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:13:40 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0016-0000-0000-0000076EE829 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:26 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0017-0000-0000-00003B3F1B41 Message-Id: <1503965694-10794-6-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 05/79] qemu-img/convert: Move bs_n > 1 && -B check down 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: qemu-stable@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Max Reitz It does not make much sense to use a backing image for the target when you concatenate multiple images (because then there is no correspondence between the source images' backing files and the target's); but it was still possible to give one by using -o backing_file=X instead of -B X. Fix this by moving the check. (Also, change the error message because -B is not the only way to specify the backing file, evidently.) Cc: qemu-stable Signed-off-by: Max Reitz Reviewed-by: Eric Blake * applied patch from v1 of series as suggested by author Signed-off-by: Michael Roth --- qemu-img.c | 14 +++++++------- tests/qemu-iotests/122.out | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index cfc3bc3..4b2d59a 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -2113,13 +2113,6 @@ static int img_convert(int argc, char **argv) } - if (bs_n > 1 && out_baseimg) { - error_report("-B makes no sense when concatenating multiple input " - "images"); - ret = -1; - goto out; - } - src_flags = 0; ret = bdrv_parse_cache_mode(src_cache, &src_flags, &src_writethrough); if (ret < 0) { @@ -2229,6 +2222,13 @@ static int img_convert(int argc, char **argv) out_baseimg = out_baseimg_param; } + if (bs_n > 1 && out_baseimg) { + error_report("Having a backing file for the target makes no sense when " + "concatenating multiple input images"); + ret = -1; + goto out; + } + /* Check if compression is supported */ if (compress) { bool encryption = diff --git a/tests/qemu-iotests/122.out b/tests/qemu-iotests/122.out index 98814de..9317d80 100644 --- a/tests/qemu-iotests/122.out +++ b/tests/qemu-iotests/122.out @@ -61,8 +61,8 @@ read 65536/65536 bytes at offset 4194304 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) read 65536/65536 bytes at offset 8388608 64 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) -qemu-img: -B makes no sense when concatenating multiple input images -qemu-img: -B makes no sense when concatenating multiple input images +qemu-img: Having a backing file for the target makes no sense when concatenating multiple input images +qemu-img: Having a backing file for the target makes no sense when concatenating multiple input images === Compression with misaligned allocations and image sizes === From patchwork Tue Aug 29 00:13:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806888 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh9Zx1b3Yz9sP5 for ; Tue, 29 Aug 2017 11:11:53 +1000 (AEST) Received: from localhost ([::1]:42203 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmV4J-00008Y-0U for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 21:11:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48988) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCu-0001pm-Fx for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCr-0006H2-9z for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:40 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:35344 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCr-0006GL-3j for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:37 -0400 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0E9cj017824 for ; Mon, 28 Aug 2017 20:16:36 -0400 Received: from e18.ny.us.ibm.com (e18.ny.us.ibm.com [129.33.205.208]) by mx0b-001b2d01.pphosted.com with ESMTP id 2cmub2wwbx-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:36 -0400 Received: from localhost by e18.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 20:16:36 -0400 Received: from b01cxnp22033.gho.pok.ibm.com (9.57.198.23) by e18.ny.us.ibm.com (146.89.104.205) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 20:16:32 -0400 Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0GUlD23396510; Tue, 29 Aug 2017 00:16:32 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6BD1012403D; Mon, 28 Aug 2017 20:13:52 -0400 (EDT) Received: from localhost (unknown [9.80.85.217]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTP id 32A8B124044; Mon, 28 Aug 2017 20:13:52 -0400 (EDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:13:41 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 17082900-0044-0000-0000-000003847099 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:34 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0045-0000-0000-000007B28906 Message-Id: <1503965694-10794-7-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-MIME-Autoconverted: from 8bit to quoted-printable by mx0b-001b2d01.pphosted.com id v7T0E9cj017824 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 06/79] block: An empty filename counts as no filename 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 , qemu-stable@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Max Reitz Reproducer: $ ./qemu-img info '' qemu-img: ./block.c:1008: bdrv_open_driver: Assertion `!drv->bdrv_needs_filename || bs->filename[0]' failed. [1] 26105 abort (core dumped) ./qemu-img info '' This patch fixes this to be: $ ./qemu-img info '' qemu-img: Could not open '': The 'file' block driver requires a file name Cc: qemu-stable Signed-off-by: Max Reitz Reviewed-by: Eric Blake Reviewed-by: Fam Zheng Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Kevin Wolf (cherry picked from commit 4a0082401a770261b85625a41eef4a4e89ad7a74) Signed-off-by: Michael Roth --- block.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block.c b/block.c index 1fbbb8d..46da908 100644 --- a/block.c +++ b/block.c @@ -1167,7 +1167,7 @@ static int bdrv_open_common(BlockDriverState *bs, BlockBackend *file, filename = qdict_get_try_str(options, "filename"); } - if (drv->bdrv_needs_filename && !filename) { + if (drv->bdrv_needs_filename && (!filename || !filename[0])) { error_setg(errp, "The '%s' block driver requires a file name", drv->format_name); ret = -EINVAL; From patchwork Tue Aug 29 00:13:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806895 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh9mk5rRPz9s7m for ; Tue, 29 Aug 2017 11:20:22 +1000 (AEST) Received: from localhost ([::1]:42258 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmVCW-0007sj-Ls for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 21:20:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49280) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUD2-000269-Rk for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:51 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCz-0006PJ-CY for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:48 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:34611 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCz-0006Oi-4e for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:45 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0E7ZK043799 for ; Mon, 28 Aug 2017 20:16:44 -0400 Received: from e16.ny.us.ibm.com (e16.ny.us.ibm.com [129.33.205.206]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmu3kpf0j-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:44 -0400 Received: from localhost by e16.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 20:16:44 -0400 Received: from b01cxnp22034.gho.pok.ibm.com (9.57.198.24) by e16.ny.us.ibm.com (146.89.104.203) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 20:16:40 -0400 Received: from b01ledav001.gho.pok.ibm.com (b01ledav001.gho.pok.ibm.com [9.57.199.106]) by b01cxnp22034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0Ge2A23068786; Tue, 29 Aug 2017 00:16:40 GMT Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id ACB1728048; Mon, 28 Aug 2017 20:16:33 -0400 (EDT) Received: from localhost (unknown [9.80.85.217]) by b01ledav001.gho.pok.ibm.com (Postfix) with ESMTP id 74FEC2803D; Mon, 28 Aug 2017 20:16:33 -0400 (EDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:13:42 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0024-0000-0000-000002C6D2E9 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:42 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0025-0000-0000-0000453E639A Message-Id: <1503965694-10794-8-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 07/79] iotests/051: Add test for empty filename 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 , qemu-stable@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Max Reitz Signed-off-by: Max Reitz Reviewed-by: Eric Blake Reviewed-by: Fam Zheng Signed-off-by: Kevin Wolf (cherry picked from commit 42dc10f17a7f1754d419e715114c37f5c5fde12f) Signed-off-by: Michael Roth --- tests/qemu-iotests/051 | 1 + tests/qemu-iotests/051.out | 3 +++ tests/qemu-iotests/051.pc.out | 3 +++ 3 files changed, 7 insertions(+) diff --git a/tests/qemu-iotests/051 b/tests/qemu-iotests/051 index 630cb7a..4fe6760 100755 --- a/tests/qemu-iotests/051 +++ b/tests/qemu-iotests/051 @@ -231,6 +231,7 @@ echo === Leaving out required options === echo run_qemu -drive driver=file +run_qemu -drive driver=file,filename= run_qemu -drive driver=nbd run_qemu -drive driver=raw run_qemu -drive file.driver=file diff --git a/tests/qemu-iotests/051.out b/tests/qemu-iotests/051.out index 7524c62..57bee08 100644 --- a/tests/qemu-iotests/051.out +++ b/tests/qemu-iotests/051.out @@ -221,6 +221,9 @@ QEMU X.Y.Z monitor - type 'help' for more information Testing: -drive driver=file QEMU_PROG: -drive driver=file: The 'file' block driver requires a file name +Testing: -drive driver=file,filename= +QEMU_PROG: -drive driver=file,filename=: The 'file' block driver requires a file name + Testing: -drive driver=nbd QEMU_PROG: -drive driver=nbd: NBD server address missing diff --git a/tests/qemu-iotests/051.pc.out b/tests/qemu-iotests/051.pc.out index c6f4eef..19426e5 100644 --- a/tests/qemu-iotests/051.pc.out +++ b/tests/qemu-iotests/051.pc.out @@ -319,6 +319,9 @@ QEMU X.Y.Z monitor - type 'help' for more information Testing: -drive driver=file QEMU_PROG: -drive driver=file: The 'file' block driver requires a file name +Testing: -drive driver=file,filename= +QEMU_PROG: -drive driver=file,filename=: The 'file' block driver requires a file name + Testing: -drive driver=nbd QEMU_PROG: -drive driver=nbd: NBD server address missing From patchwork Tue Aug 29 00:13:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806892 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh9fw3Fbmz9sP5 for ; Tue, 29 Aug 2017 11:15:20 +1000 (AEST) Received: from localhost ([::1]:42224 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmV7e-0003T6-AP for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 21:15:18 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49228) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUD1-00020W-1O for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCx-0006Nm-Rq for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:46 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:58369 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCx-0006NS-Ke for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:43 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0E8J5099513 for ; Mon, 28 Aug 2017 20:16:43 -0400 Received: from e16.ny.us.ibm.com (e16.ny.us.ibm.com [129.33.205.206]) by mx0b-001b2d01.pphosted.com with ESMTP id 2cmr22ykuc-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:43 -0400 Received: from localhost by e16.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 20:16:42 -0400 Received: from b01cxnp22035.gho.pok.ibm.com (9.57.198.25) by e16.ny.us.ibm.com (146.89.104.203) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 20:16:41 -0400 Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0GdYZ32309280; Tue, 29 Aug 2017 00:16:40 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id F0BE712404E; Mon, 28 Aug 2017 20:14:00 -0400 (EDT) Received: from localhost (unknown [9.80.85.217]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTP id C3276124044; Mon, 28 Aug 2017 20:14:00 -0400 (EDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:13:43 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0024-0000-0000-000002C6D2EA X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:42 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0025-0000-0000-0000453E639C Message-Id: <1503965694-10794-9-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 08/79] migration: setup bi-directional I/O channel for exec: protocol 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: qemu-stable@nongnu.org, Juan Quintela Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: "Daniel P. Berrange" Historically the migration data channel has only needed to be unidirectional. Thus the 'exec:' protocol was requesting an I/O channel with O_RDONLY on incoming side, and O_WRONLY on the outgoing side. This is fine for classic migration, but if you then try to run TLS over it, this fails because the TLS handshake requires a bi-directional channel. Signed-off-by: Daniel P. Berrange Reviewed-by: Juan Quintela Signed-off-by: Juan Quintela (cherry picked from commit 062d81f0e968fe1597474735f3ea038065027372) Signed-off-by: Michael Roth --- migration/exec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/migration/exec.c b/migration/exec.c index 9157721..aba9089 100644 --- a/migration/exec.c +++ b/migration/exec.c @@ -32,7 +32,7 @@ void exec_start_outgoing_migration(MigrationState *s, const char *command, Error trace_migration_exec_outgoing(command); ioc = QIO_CHANNEL(qio_channel_command_new_spawn(argv, - O_WRONLY, + O_RDWR, errp)); if (!ioc) { return; @@ -59,7 +59,7 @@ void exec_start_incoming_migration(const char *command, Error **errp) trace_migration_exec_incoming(command); ioc = QIO_CHANNEL(qio_channel_command_new_spawn(argv, - O_RDONLY, + O_RDWR, errp)); if (!ioc) { return; From patchwork Tue Aug 29 00:13:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806812 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh8QZ4B8Zz9s7v for ; Tue, 29 Aug 2017 10:19:34 +1000 (AEST) Received: from localhost ([::1]:41889 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUFg-0003no-Bf for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:19:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47263) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUC4-0000po-7V for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUC1-000530-7F for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:48 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:50441) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUC0-00052Q-SD for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:45 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0E868077501 for ; Mon, 28 Aug 2017 20:15:42 -0400 Received: from e33.co.us.ibm.com (e33.co.us.ibm.com [32.97.110.151]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmnx0yuam-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:15:42 -0400 Received: from localhost by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 18:15:42 -0600 Received: from b03cxnp08025.gho.boulder.ibm.com (9.17.130.17) by e33.co.us.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 18:15:38 -0600 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0FcnM65863700; Mon, 28 Aug 2017 17:15:38 -0700 Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E194CBE047; Mon, 28 Aug 2017 18:15:37 -0600 (MDT) Received: from localhost (unknown [9.80.85.217]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP id B84C0BE038; Mon, 28 Aug 2017 18:15:37 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:13:44 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0008-0000-0000-0000087D3848 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:15:40 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0009-0000-0000-000043C0468A Message-Id: <1503965694-10794-10-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 09/79] pci: deassert intx when pci device unrealize 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: "Michael S . Tsirkin" , qemu-stable@nongnu.org, "Herongguang \(Stephen\)" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: "Herongguang (Stephen)" If a pci device is not reset by VM (by writing into config space) and unplugged by VM, after that when VM reboots, qemu may assert: pcibus_reset: Assertion `bus->irq_count[i] == 0' failed Cc: qemu-stable@nongnu.org Signed-off-by: herongguang Reviewed-by: Marcel Apfelbaum Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin (cherry picked from commit 3936161f1fd72d1dfa577aaba910819c5e873260) Signed-off-by: Michael Roth --- hw/pci/pci.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/pci/pci.c b/hw/pci/pci.c index 259483b..98ccc27 100644 --- a/hw/pci/pci.c +++ b/hw/pci/pci.c @@ -1083,6 +1083,7 @@ static void pci_qdev_unrealize(DeviceState *dev, Error **errp) pc->exit(pci_dev); } + pci_device_deassert_intx(pci_dev); do_pci_unregister_device(pci_dev); } From patchwork Tue Aug 29 00:13:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806808 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh8ML591Xz9rxl for ; Tue, 29 Aug 2017 10:16:46 +1000 (AEST) Received: from localhost ([::1]:41876 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCy-0000sT-FK for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:16:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47244) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUC3-0000oo-6K for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUBz-00052H-W7 for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:47 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:40825 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUBz-00051Z-Q8 for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:43 -0400 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0EEWB019727 for ; Mon, 28 Aug 2017 20:15:42 -0400 Received: from e32.co.us.ibm.com (e32.co.us.ibm.com [32.97.110.150]) by mx0b-001b2d01.pphosted.com with ESMTP id 2cmsfn2vqc-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:15:41 -0400 Received: from localhost by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 18:15:41 -0600 Received: from b03cxnp07028.gho.boulder.ibm.com (9.17.130.15) by e32.co.us.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 18:15:39 -0600 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0FcMM852374; Mon, 28 Aug 2017 17:15:39 -0700 Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D7EEEC603C; Mon, 28 Aug 2017 18:15:38 -0600 (MDT) Received: from localhost (unknown [9.80.85.217]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP id A438CC6042; Mon, 28 Aug 2017 18:15:38 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:13:45 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0004-0000-0000-000012D6D507 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909027; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:15:40 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0005-0000-0000-000080E59E37 Message-Id: <1503965694-10794-11-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 10/79] block: Do not unref bs->file on error in BD's 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: Kevin Wolf , qemu-stable@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Max Reitz The block layer takes care of removing the bs->file child if the block driver's bdrv_open()/bdrv_file_open() implementation fails. The block driver therefore does not need to do so, and indeed should not unless it sets bs->file to NULL afterwards -- because if this is not done, the bdrv_unref_child() in bdrv_open_inherit() will dereference the freed memory block at bs->file afterwards, which is not good. We can now decide whether to add a "bs->file = NULL;" after each of the offending bdrv_unref_child() invocations, or just drop them altogether. The latter is simpler, so let's do that. Cc: qemu-stable Signed-off-by: Max Reitz Reviewed-by: Eric Blake Reviewed-by: Stefan Hajnoczi Signed-off-by: Kevin Wolf (cherry picked from commit de234897b60e034ba94b307fc289e2dc692c9251) Signed-off-by: Michael Roth --- block/blkdebug.c | 4 +--- block/blkreplay.c | 3 --- block/blkverify.c | 3 --- 3 files changed, 1 insertion(+), 9 deletions(-) diff --git a/block/blkdebug.c b/block/blkdebug.c index 67e8024..cc4a146 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -389,14 +389,12 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags, } else if (align) { error_setg(errp, "Invalid alignment"); ret = -EINVAL; - goto fail_unref; + goto out; } ret = 0; goto out; -fail_unref: - bdrv_unref_child(bs, bs->file); out: if (ret < 0) { g_free(s->config_file); diff --git a/block/blkreplay.c b/block/blkreplay.c index e110211..6aa5fd4 100755 --- a/block/blkreplay.c +++ b/block/blkreplay.c @@ -37,9 +37,6 @@ static int blkreplay_open(BlockDriverState *bs, QDict *options, int flags, ret = 0; fail: - if (ret < 0) { - bdrv_unref_child(bs, bs->file); - } return ret; } diff --git a/block/blkverify.c b/block/blkverify.c index 9a1e21c..af23281 100644 --- a/block/blkverify.c +++ b/block/blkverify.c @@ -142,9 +142,6 @@ static int blkverify_open(BlockDriverState *bs, QDict *options, int flags, ret = 0; fail: - if (ret < 0) { - bdrv_unref_child(bs, bs->file); - } qemu_opts_del(opts); return ret; } From patchwork Tue Aug 29 00:13:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806811 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh8PZ371Gz9s7v for ; Tue, 29 Aug 2017 10:18:42 +1000 (AEST) Received: from localhost ([::1]:41885 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUEq-000371-6X for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:18:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47342) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUC6-0000r2-GK for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUC2-00053w-3p for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:50 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:37381) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUC1-000535-Rt for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:46 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0EDJ6090293 for ; Mon, 28 Aug 2017 20:15:45 -0400 Received: from e14.ny.us.ibm.com (e14.ny.us.ibm.com [129.33.205.204]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmvyehjxw-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:15:44 -0400 Received: from localhost by e14.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 20:15:43 -0400 Received: from b01cxnp23034.gho.pok.ibm.com (9.57.198.29) by e14.ny.us.ibm.com (146.89.104.201) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 20:15:40 -0400 Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0Ferg25231586; Tue, 29 Aug 2017 00:15:40 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 602B8124035; Mon, 28 Aug 2017 20:13:00 -0400 (EDT) Received: from localhost (unknown [9.80.85.217]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTP id 32E7F12403F; Mon, 28 Aug 2017 20:13:00 -0400 (EDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:13:46 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0052-0000-0000-00000257331B X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:15:42 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0053-0000-0000-000051D1D903 Message-Id: <1503965694-10794-12-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 11/79] ACPI: don't call acpi_pcihp_device_plug_cb on xen 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: "Michael S . Tsirkin" , qemu-stable@nongnu.org, Bruce Rogers Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Bruce Rogers Commit f0c9d64a exposed the issue that with a xenfv machine using pci passthrough, acpi pci hotplug code was being executed by mistake. Guard calls to acpi_pcihp_device_plug_cb (and corresponding acpi_pcihp_device_unplug_cb) with a check for xen_enabled(). Without this check I am seeing an error that the bus doesn't have the acpi-pcihp-bsel property set. Signed-off-by: Bruce Rogers Reviewed-by: Igor Mammedov Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin (cherry picked from commit 153eba4726dfa1bdfc31d1fe973b2a61b9035492) Signed-off-by: Michael Roth --- hw/acpi/piix4.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c index a553a7e..c409374 100644 --- a/hw/acpi/piix4.c +++ b/hw/acpi/piix4.c @@ -385,7 +385,10 @@ static void piix4_device_plug_cb(HotplugHandler *hotplug_dev, dev, errp); } } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { - acpi_pcihp_device_plug_cb(hotplug_dev, &s->acpi_pci_hotplug, dev, errp); + if (!xen_enabled()) { + acpi_pcihp_device_plug_cb(hotplug_dev, &s->acpi_pci_hotplug, dev, + errp); + } } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU)) { if (s->cpu_hotplug_legacy) { legacy_acpi_cpu_plug_cb(hotplug_dev, &s->gpe_cpu, dev, errp); @@ -408,8 +411,10 @@ static void piix4_device_unplug_request_cb(HotplugHandler *hotplug_dev, acpi_memory_unplug_request_cb(hotplug_dev, &s->acpi_memory_hotplug, dev, errp); } else if (object_dynamic_cast(OBJECT(dev), TYPE_PCI_DEVICE)) { - acpi_pcihp_device_unplug_cb(hotplug_dev, &s->acpi_pci_hotplug, dev, - errp); + if (!xen_enabled()) { + acpi_pcihp_device_unplug_cb(hotplug_dev, &s->acpi_pci_hotplug, dev, + errp); + } } else if (object_dynamic_cast(OBJECT(dev), TYPE_CPU) && !s->cpu_hotplug_legacy) { acpi_cpu_unplug_request_cb(hotplug_dev, &s->cpuhp_state, dev, errp); From patchwork Tue Aug 29 00:13:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806815 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh8Sb4dlhz9s65 for ; Tue, 29 Aug 2017 10:21:19 +1000 (AEST) Received: from localhost ([::1]:41903 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUHN-0005co-CS for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:21:17 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47291) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUC5-0000qE-0B for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUC1-00053G-Aq for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:48 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:33132 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUC1-00052v-6A for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:45 -0400 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0E8D3017766 for ; Mon, 28 Aug 2017 20:15:44 -0400 Received: from e17.ny.us.ibm.com (e17.ny.us.ibm.com [129.33.205.207]) by mx0b-001b2d01.pphosted.com with ESMTP id 2cmub2wv93-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:15:44 -0400 Received: from localhost by e17.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 20:15:44 -0400 Received: from b01cxnp23033.gho.pok.ibm.com (9.57.198.28) by e17.ny.us.ibm.com (146.89.104.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 20:15:41 -0400 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0FfNs3539374; Tue, 29 Aug 2017 00:15:41 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EDCC5B2052; Mon, 28 Aug 2017 20:13:04 -0400 (EDT) Received: from localhost (unknown [9.80.85.217]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP id B5D4FB204E; Mon, 28 Aug 2017 20:13:04 -0400 (EDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:13:47 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0040-0000-0000-00000396DE98 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:15:42 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0041-0000-0000-0000078B101A Message-Id: <1503965694-10794-13-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 12/79] replication: Make --disable-replication compile again 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: qemu-stable@nongnu.org, Stefan Hajnoczi , Markus Armbruster Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Markus Armbruster Broken in commit daa33c5. Cc: qemu-stable@nongnu.org Signed-off-by: Markus Armbruster Reviewed-by: Eric Blake Reviewed-by: Zhang Chen Message-id: 1493298053-17140-1-git-send-email-armbru@redhat.com Signed-off-by: Stefan Hajnoczi (cherry picked from commit 38bb54f323bf7c83496b6a044cfd28896e997a00) Signed-off-by: Michael Roth --- migration/colo.c | 12 ++++++++++++ monitor.c | 5 +++++ 2 files changed, 17 insertions(+) diff --git a/migration/colo.c b/migration/colo.c index c19eb3f..963c802 100644 --- a/migration/colo.c +++ b/migration/colo.c @@ -153,6 +153,7 @@ void qmp_xen_set_replication(bool enable, bool primary, bool has_failover, bool failover, Error **errp) { +#ifdef CONFIG_REPLICATION ReplicationMode mode = primary ? REPLICATION_MODE_PRIMARY : REPLICATION_MODE_SECONDARY; @@ -171,10 +172,14 @@ void qmp_xen_set_replication(bool enable, bool primary, } replication_stop_all(failover, failover ? NULL : errp); } +#else + abort(); +#endif } ReplicationStatus *qmp_query_xen_replication_status(Error **errp) { +#ifdef CONFIG_REPLICATION Error *err = NULL; ReplicationStatus *s = g_new0(ReplicationStatus, 1); @@ -189,11 +194,18 @@ ReplicationStatus *qmp_query_xen_replication_status(Error **errp) error_free(err); return s; +#else + abort(); +#endif } void qmp_xen_colo_do_checkpoint(Error **errp) { +#ifdef CONFIG_REPLICATION replication_do_checkpoint_all(errp); +#else + abort(); +#endif } static void colo_send_message(QEMUFile *f, COLOMessage msg, diff --git a/monitor.c b/monitor.c index be282ec..2799a37 100644 --- a/monitor.c +++ b/monitor.c @@ -974,6 +974,11 @@ static void qmp_unregister_commands_hack(void) #ifndef CONFIG_SPICE qmp_unregister_command(&qmp_commands, "query-spice"); #endif +#ifndef CONFIG_REPLICATION + qmp_unregister_command(&qmp_commands, "xen-set-replication"); + qmp_unregister_command(&qmp_commands, "query-xen-replication-status"); + qmp_unregister_command(&qmp_commands, "xen-colo-do-checkpoint"); +#endif #ifndef TARGET_I386 qmp_unregister_command(&qmp_commands, "rtc-reset-reinjection"); #endif From patchwork Tue Aug 29 00:13:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806818 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh8WY6Dwbz9s65 for ; Tue, 29 Aug 2017 10:23:53 +1000 (AEST) Received: from localhost ([::1]:41918 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUJr-0007mv-KF for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:23:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47374) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUC7-0000r8-5L for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUC3-000553-7O for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:51 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:50495) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUC2-00054A-Uq for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:47 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0EDPc077706 for ; Mon, 28 Aug 2017 20:15:46 -0400 Received: from e14.ny.us.ibm.com (e14.ny.us.ibm.com [129.33.205.204]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmnx0yuc7-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:15:45 -0400 Received: from localhost by e14.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 20:15:44 -0400 Received: from b01cxnp22036.gho.pok.ibm.com (9.57.198.26) by e14.ny.us.ibm.com (146.89.104.201) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 20:15:42 -0400 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0FfC331457484; Tue, 29 Aug 2017 00:15:41 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DF05111204B; Mon, 28 Aug 2017 20:15:27 -0400 (EDT) Received: from localhost (unknown [9.80.85.217]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP id B0C1D112034; Mon, 28 Aug 2017 20:15:27 -0400 (EDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:13:48 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0052-0000-0000-00000257331C X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:15:43 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0053-0000-0000-000051D1D909 Message-Id: <1503965694-10794-14-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 13/79] 9pfs: local: fix unlink of alien files in mapped-file mode 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: qemu-stable@nongnu.org, Greg Kurz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Greg Kurz When trying to remove a file from a directory, both created in non-mapped mode, the file remains and EBADF is returned to the guest. This is a regression introduced by commit "df4938a6651b 9pfs: local: unlinkat: don't follow symlinks" when fixing CVE-2016-9602. It changed the way we unlink the metadata file from ret = remove("$dir/.virtfs_metadata/$name"); if (ret < 0 && errno != ENOENT) { /* Error out */ } /* Ignore absence of metadata */ to fd = openat("$dir/.virtfs_metadata") unlinkat(fd, "$name") if (ret < 0 && errno != ENOENT) { /* Error out */ } /* Ignore absence of metadata */ If $dir was created in non-mapped mode, openat() fails with ENOENT and we pass -1 to unlinkat(), which fails in turn with EBADF. We just need to check the return of openat() and ignore ENOENT, in order to restore the behaviour we had with remove(). Signed-off-by: Greg Kurz Reviewed-by: Eric Blake [groug: rewrote the comments as suggested by Eric] (cherry picked from commit 6a87e7929f97b86c5823d4616fa1aa7636b2f116) Signed-off-by: Michael Roth --- hw/9pfs/9p-local.c | 34 +++++++++++++++------------------- 1 file changed, 15 insertions(+), 19 deletions(-) diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index f3ebca4..7a0c383 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -957,6 +957,14 @@ static int local_unlinkat_common(FsContext *ctx, int dirfd, const char *name, if (ctx->export_flags & V9FS_SM_MAPPED_FILE) { int map_dirfd; + /* We need to remove the metadata as well: + * - the metadata directory if we're removing a directory + * - the metadata file in the parent's metadata directory + * + * If any of these are missing (ie, ENOENT) then we're probably + * trying to remove something that wasn't created in mapped-file + * mode. We just ignore the error. + */ if (flags == AT_REMOVEDIR) { int fd; @@ -964,32 +972,20 @@ static int local_unlinkat_common(FsContext *ctx, int dirfd, const char *name, if (fd == -1) { goto err_out; } - /* - * If directory remove .virtfs_metadata contained in the - * directory - */ ret = unlinkat(fd, VIRTFS_META_DIR, AT_REMOVEDIR); close_preserve_errno(fd); if (ret < 0 && errno != ENOENT) { - /* - * We didn't had the .virtfs_metadata file. May be file created - * in non-mapped mode ?. Ignore ENOENT. - */ goto err_out; } } - /* - * Now remove the name from parent directory - * .virtfs_metadata directory. - */ map_dirfd = openat_dir(dirfd, VIRTFS_META_DIR); - ret = unlinkat(map_dirfd, name, 0); - close_preserve_errno(map_dirfd); - if (ret < 0 && errno != ENOENT) { - /* - * We didn't had the .virtfs_metadata file. May be file created - * in non-mapped mode ?. Ignore ENOENT. - */ + if (map_dirfd != -1) { + ret = unlinkat(map_dirfd, name, 0); + close_preserve_errno(map_dirfd); + if (ret < 0 && errno != ENOENT) { + goto err_out; + } + } else if (errno != ENOENT) { goto err_out; } } From patchwork Tue Aug 29 00:13:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806813 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh8Rj3SLgz9s7v for ; Tue, 29 Aug 2017 10:20:33 +1000 (AEST) Received: from localhost ([::1]:41894 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUGd-0004kj-1l for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:20:31 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47362) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUC6-0000r4-Tq for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUC2-00054q-Rn for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:50 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:33186 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUC2-00054O-ML for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:46 -0400 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0EAuo017896 for ; Mon, 28 Aug 2017 20:15:46 -0400 Received: from e12.ny.us.ibm.com (e12.ny.us.ibm.com [129.33.205.202]) by mx0b-001b2d01.pphosted.com with ESMTP id 2cmub2wv9w-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:15:46 -0400 Received: from localhost by e12.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 20:15:45 -0400 Received: from b01cxnp22034.gho.pok.ibm.com (9.57.198.24) by e12.ny.us.ibm.com (146.89.104.199) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 20:15:43 -0400 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp22034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0FVf923068900; Tue, 29 Aug 2017 00:15:43 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9973FAE043; Mon, 28 Aug 2017 20:16:06 -0400 (EDT) Received: from localhost (unknown [9.80.85.217]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTP id 3BB91AE03B; Mon, 28 Aug 2017 20:16:06 -0400 (EDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:13:49 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0048-0000-0000-000001DAEA20 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:15:44 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0049-0000-0000-00004261937D Message-Id: <1503965694-10794-15-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 14/79] coccinelle: Add script to remove useless QObject casts 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: qemu-stable@nongnu.org, Markus Armbruster Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Eric Blake We have macros in place to make it less verbose to add a subtype of QObject to both QDict and QList. While we have made cleanups like this in the past (see commit fcfcd8ffc, for example), having it be automated by Coccinelle makes it easier to maintain. The script is separate from the cleanups, for ease of review and backporting. A later patch will then add further possible cleanups. Signed-off-by: Eric Blake Reviewed-by: Markus Armbruster Message-Id: <20170427215821.19397-4-eblake@redhat.com> Signed-off-by: Markus Armbruster (cherry picked from commit a2f3453ebc64b1ebe094aeaf83f9e67896f90ac3) Signed-off-by: Michael Roth --- MAINTAINERS | 1 + scripts/coccinelle/qobject.cocci | 13 +++++++++++++ 2 files changed, 14 insertions(+) create mode 100644 scripts/coccinelle/qobject.cocci diff --git a/MAINTAINERS b/MAINTAINERS index c60235e..430efb0 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -1395,6 +1395,7 @@ S: Supported F: qobject/ F: include/qapi/qmp/ X: include/qapi/qmp/dispatch.h +F: scripts/coccinelle/qobject.cocci F: tests/check-qdict.c F: tests/check-qfloat.c F: tests/check-qint.c diff --git a/scripts/coccinelle/qobject.cocci b/scripts/coccinelle/qobject.cocci new file mode 100644 index 0000000..aa899e2 --- /dev/null +++ b/scripts/coccinelle/qobject.cocci @@ -0,0 +1,13 @@ +// Use QDict macros where they make sense +@@ +expression Obj, Key, E; +@@ +- qdict_put_obj(Obj, Key, QOBJECT(E)); ++ qdict_put(Obj, Key, E); + +// Use QList macros where they make sense +@@ +expression Obj, E; +@@ +- qlist_append_obj(Obj, QOBJECT(E)); ++ qlist_append(Obj, E); From patchwork Tue Aug 29 00:13:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806820 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh8YG6z2Cz9s65 for ; Tue, 29 Aug 2017 10:25:22 +1000 (AEST) Received: from localhost ([::1]:41923 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmULI-0000dk-Pp for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:25:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47386) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUC7-0000r9-K3 for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUC4-000561-2I for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:51 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:37138 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUC3-00055T-Ra for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:47 -0400 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0EWZq065802 for ; Mon, 28 Aug 2017 20:15:47 -0400 Received: from e38.co.us.ibm.com (e38.co.us.ibm.com [32.97.110.159]) by mx0b-001b2d01.pphosted.com with ESMTP id 2cmq0jay4q-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:15:47 -0400 Received: from localhost by e38.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 18:15:46 -0600 Received: from b03cxnp07028.gho.boulder.ibm.com (9.17.130.15) by e38.co.us.ibm.com (192.168.1.138) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 18:15:44 -0600 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0Firi000408; Mon, 28 Aug 2017 17:15:44 -0700 Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 333D813603A; Mon, 28 Aug 2017 18:15:44 -0600 (MDT) Received: from localhost (unknown [9.80.85.217]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP id CC15813603C; Mon, 28 Aug 2017 18:15:43 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:13:50 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0028-0000-0000-00000846DB1F X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:15:46 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0029-0000-0000-000037553106 Message-Id: <1503965694-10794-16-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 15/79] qobject: Drop useless QObject casts 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: qemu-stable@nongnu.org, Markus Armbruster Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Eric Blake We have macros in place to make it less verbose to add a subtype of QObject to both QDict and QList. While we have made cleanups like this in the past (see commit fcfcd8ffc, for example), having it be automated by Coccinelle makes it easier to maintain. Patch created mechanically via: spatch --sp-file scripts/coccinelle/qobject.cocci \ --macro-file scripts/cocci-macro-file.h --dir . --in-place then I verified that no manual touchups were required. Signed-off-by: Eric Blake Reviewed-by: Stefan Hajnoczi Reviewed-by: Alberto Garcia Reviewed-by: Markus Armbruster Message-Id: <20170427215821.19397-5-eblake@redhat.com> Signed-off-by: Markus Armbruster (cherry picked from commit de6e7951fe66053dfeaac1a237f7aceb9e079619) Signed-off-by: Michael Roth --- block.c | 12 ++++-------- block/blkdebug.c | 4 ++-- block/blkverify.c | 7 +++---- block/file-posix.c | 6 +++--- block/file-win32.c | 4 ++-- block/quorum.c | 16 ++++++---------- tests/check-qdict.c | 20 ++++++++++---------- tests/test-qmp-commands.c | 24 ++++++++++++------------ 8 files changed, 42 insertions(+), 51 deletions(-) diff --git a/block.c b/block.c index 46da908..f156348 100644 --- a/block.c +++ b/block.c @@ -4674,11 +4674,9 @@ void bdrv_refresh_filename(BlockDriverState *bs) * contain a representation of the filename, therefore the following * suffices without querying the (exact_)filename of this BDS. */ if (bs->file->bs->full_open_options) { - qdict_put_obj(opts, "driver", - QOBJECT(qstring_from_str(drv->format_name))); + qdict_put(opts, "driver", qstring_from_str(drv->format_name)); QINCREF(bs->file->bs->full_open_options); - qdict_put_obj(opts, "file", - QOBJECT(bs->file->bs->full_open_options)); + qdict_put(opts, "file", bs->file->bs->full_open_options); bs->full_open_options = opts; } else { @@ -4694,8 +4692,7 @@ void bdrv_refresh_filename(BlockDriverState *bs) opts = qdict_new(); append_open_options(opts, bs); - qdict_put_obj(opts, "driver", - QOBJECT(qstring_from_str(drv->format_name))); + qdict_put(opts, "driver", qstring_from_str(drv->format_name)); if (bs->exact_filename[0]) { /* This may not work for all block protocol drivers (some may @@ -4705,8 +4702,7 @@ void bdrv_refresh_filename(BlockDriverState *bs) * needs some special format of the options QDict, it needs to * implement the driver-specific bdrv_refresh_filename() function. */ - qdict_put_obj(opts, "filename", - QOBJECT(qstring_from_str(bs->exact_filename))); + qdict_put(opts, "filename", qstring_from_str(bs->exact_filename)); } bs->full_open_options = opts; diff --git a/block/blkdebug.c b/block/blkdebug.c index cc4a146..42b8d80 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -693,10 +693,10 @@ static void blkdebug_refresh_filename(BlockDriverState *bs, QDict *options) } opts = qdict_new(); - qdict_put_obj(opts, "driver", QOBJECT(qstring_from_str("blkdebug"))); + qdict_put(opts, "driver", qstring_from_str("blkdebug")); QINCREF(bs->file->bs->full_open_options); - qdict_put_obj(opts, "image", QOBJECT(bs->file->bs->full_open_options)); + qdict_put(opts, "image", bs->file->bs->full_open_options); for (e = qdict_first(options); e; e = qdict_next(options, e)) { if (strcmp(qdict_entry_key(e), "x-image")) { diff --git a/block/blkverify.c b/block/blkverify.c index af23281..cc29cd2 100644 --- a/block/blkverify.c +++ b/block/blkverify.c @@ -288,13 +288,12 @@ static void blkverify_refresh_filename(BlockDriverState *bs, QDict *options) && s->test_file->bs->full_open_options) { QDict *opts = qdict_new(); - qdict_put_obj(opts, "driver", QOBJECT(qstring_from_str("blkverify"))); + qdict_put(opts, "driver", qstring_from_str("blkverify")); QINCREF(bs->file->bs->full_open_options); - qdict_put_obj(opts, "raw", QOBJECT(bs->file->bs->full_open_options)); + qdict_put(opts, "raw", bs->file->bs->full_open_options); QINCREF(s->test_file->bs->full_open_options); - qdict_put_obj(opts, "test", - QOBJECT(s->test_file->bs->full_open_options)); + qdict_put(opts, "test", s->test_file->bs->full_open_options); bs->full_open_options = opts; } diff --git a/block/file-posix.c b/block/file-posix.c index 0c48968..5370ba0 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -377,7 +377,7 @@ static void raw_parse_filename(const char *filename, QDict *options, * function call can be ignored. */ strstart(filename, "file:", &filename); - qdict_put_obj(options, "filename", QOBJECT(qstring_from_str(filename))); + qdict_put(options, "filename", qstring_from_str(filename)); } static QemuOptsList raw_runtime_opts = { @@ -2150,7 +2150,7 @@ static void hdev_parse_filename(const char *filename, QDict *options, /* The prefix is optional, just as for "file". */ strstart(filename, "host_device:", &filename); - qdict_put_obj(options, "filename", QOBJECT(qstring_from_str(filename))); + qdict_put(options, "filename", qstring_from_str(filename)); } static bool hdev_is_sg(BlockDriverState *bs) @@ -2449,7 +2449,7 @@ static void cdrom_parse_filename(const char *filename, QDict *options, /* The prefix is optional, just as for "file". */ strstart(filename, "host_cdrom:", &filename); - qdict_put_obj(options, "filename", QOBJECT(qstring_from_str(filename))); + qdict_put(options, "filename", qstring_from_str(filename)); } #endif diff --git a/block/file-win32.c b/block/file-win32.c index 800fabd..57c4a78 100644 --- a/block/file-win32.c +++ b/block/file-win32.c @@ -282,7 +282,7 @@ static void raw_parse_filename(const char *filename, QDict *options, * function call can be ignored. */ strstart(filename, "file:", &filename); - qdict_put_obj(options, "filename", QOBJECT(qstring_from_str(filename))); + qdict_put(options, "filename", qstring_from_str(filename)); } static QemuOptsList raw_runtime_opts = { @@ -669,7 +669,7 @@ static void hdev_parse_filename(const char *filename, QDict *options, /* The prefix is optional, just as for "file". */ strstart(filename, "host_device:", &filename); - qdict_put_obj(options, "filename", QOBJECT(qstring_from_str(filename))); + qdict_put(options, "filename", qstring_from_str(filename)); } static int hdev_open(BlockDriverState *bs, QDict *options, int flags, diff --git a/block/quorum.c b/block/quorum.c index 40205fb..f7949e2 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -1096,19 +1096,15 @@ static void quorum_refresh_filename(BlockDriverState *bs, QDict *options) children = qlist_new(); for (i = 0; i < s->num_children; i++) { QINCREF(s->children[i]->bs->full_open_options); - qlist_append_obj(children, - QOBJECT(s->children[i]->bs->full_open_options)); + qlist_append(children, s->children[i]->bs->full_open_options); } opts = qdict_new(); - qdict_put_obj(opts, "driver", QOBJECT(qstring_from_str("quorum"))); - qdict_put_obj(opts, QUORUM_OPT_VOTE_THRESHOLD, - QOBJECT(qint_from_int(s->threshold))); - qdict_put_obj(opts, QUORUM_OPT_BLKVERIFY, - QOBJECT(qbool_from_bool(s->is_blkverify))); - qdict_put_obj(opts, QUORUM_OPT_REWRITE, - QOBJECT(qbool_from_bool(s->rewrite_corrupted))); - qdict_put_obj(opts, "children", QOBJECT(children)); + qdict_put(opts, "driver", qstring_from_str("quorum")); + qdict_put(opts, QUORUM_OPT_VOTE_THRESHOLD, qint_from_int(s->threshold)); + qdict_put(opts, QUORUM_OPT_BLKVERIFY, qbool_from_bool(s->is_blkverify)); + qdict_put(opts, QUORUM_OPT_REWRITE, qbool_from_bool(s->rewrite_corrupted)); + qdict_put(opts, "children", children); bs->full_open_options = opts; } diff --git a/tests/check-qdict.c b/tests/check-qdict.c index 81162ee..9cdc985 100644 --- a/tests/check-qdict.c +++ b/tests/check-qdict.c @@ -47,7 +47,7 @@ static void qdict_put_obj_test(void) qdict = qdict_new(); // key "" will have tdb hash 12345 - qdict_put_obj(qdict, "", QOBJECT(qint_from_int(num))); + qdict_put(qdict, "", qint_from_int(num)); g_assert(qdict_size(qdict) == 1); ent = QLIST_FIRST(&qdict->table[12345 % QDICT_BUCKET_MAX]); @@ -66,8 +66,8 @@ static void qdict_destroy_simple_test(void) QDict *qdict; qdict = qdict_new(); - qdict_put_obj(qdict, "num", QOBJECT(qint_from_int(0))); - qdict_put_obj(qdict, "str", QOBJECT(qstring_from_str("foo"))); + qdict_put(qdict, "num", qint_from_int(0)); + qdict_put(qdict, "str", qstring_from_str("foo")); QDECREF(qdict); } @@ -297,16 +297,16 @@ static void qdict_flatten_test(void) qdict_put(dict1, "a", qint_from_int(0)); qdict_put(dict1, "b", qint_from_int(1)); - qlist_append_obj(list1, QOBJECT(qint_from_int(23))); - qlist_append_obj(list1, QOBJECT(qint_from_int(66))); - qlist_append_obj(list1, QOBJECT(dict1)); - qlist_append_obj(list2, QOBJECT(qint_from_int(42))); - qlist_append_obj(list2, QOBJECT(list1)); + qlist_append(list1, qint_from_int(23)); + qlist_append(list1, qint_from_int(66)); + qlist_append(list1, dict1); + qlist_append(list2, qint_from_int(42)); + qlist_append(list2, list1); qdict_put(dict2, "c", qint_from_int(2)); qdict_put(dict2, "d", qint_from_int(3)); - qdict_put_obj(dict3, "e", QOBJECT(list2)); - qdict_put_obj(dict3, "f", QOBJECT(dict2)); + qdict_put(dict3, "e", list2); + qdict_put(dict3, "f", dict2); qdict_put(dict3, "g", qint_from_int(4)); qdict_flatten(dict3); diff --git a/tests/test-qmp-commands.c b/tests/test-qmp-commands.c index 0f81a98..ac3fd03 100644 --- a/tests/test-qmp-commands.c +++ b/tests/test-qmp-commands.c @@ -94,7 +94,7 @@ static void test_dispatch_cmd(void) QDict *req = qdict_new(); QObject *resp; - qdict_put_obj(req, "execute", QOBJECT(qstring_from_str("user_def_cmd"))); + qdict_put(req, "execute", qstring_from_str("user_def_cmd")); resp = qmp_dispatch(&qmp_commands, QOBJECT(req)); assert(resp != NULL); @@ -111,7 +111,7 @@ static void test_dispatch_cmd_failure(void) QDict *args = qdict_new(); QObject *resp; - qdict_put_obj(req, "execute", QOBJECT(qstring_from_str("user_def_cmd2"))); + qdict_put(req, "execute", qstring_from_str("user_def_cmd2")); resp = qmp_dispatch(&qmp_commands, QOBJECT(req)); assert(resp != NULL); @@ -125,7 +125,7 @@ static void test_dispatch_cmd_failure(void) qdict_put(args, "a", qint_from_int(66)); qdict_put(req, "arguments", args); - qdict_put_obj(req, "execute", QOBJECT(qstring_from_str("user_def_cmd"))); + qdict_put(req, "execute", qstring_from_str("user_def_cmd")); resp = qmp_dispatch(&qmp_commands, QOBJECT(req)); assert(resp != NULL); @@ -164,14 +164,14 @@ static void test_dispatch_cmd_io(void) QDict *ret_dict_dict2, *ret_dict_dict2_userdef; QInt *ret3; - qdict_put_obj(ud1a, "integer", QOBJECT(qint_from_int(42))); - qdict_put_obj(ud1a, "string", QOBJECT(qstring_from_str("hello"))); - qdict_put_obj(ud1b, "integer", QOBJECT(qint_from_int(422))); - qdict_put_obj(ud1b, "string", QOBJECT(qstring_from_str("hello2"))); - qdict_put_obj(args, "ud1a", QOBJECT(ud1a)); - qdict_put_obj(args, "ud1b", QOBJECT(ud1b)); - qdict_put_obj(req, "arguments", QOBJECT(args)); - qdict_put_obj(req, "execute", QOBJECT(qstring_from_str("user_def_cmd2"))); + qdict_put(ud1a, "integer", qint_from_int(42)); + qdict_put(ud1a, "string", qstring_from_str("hello")); + qdict_put(ud1b, "integer", qint_from_int(422)); + qdict_put(ud1b, "string", qstring_from_str("hello2")); + qdict_put(args, "ud1a", ud1a); + qdict_put(args, "ud1b", ud1b); + qdict_put(req, "arguments", args); + qdict_put(req, "execute", qstring_from_str("user_def_cmd2")); ret = qobject_to_qdict(test_qmp_dispatch(req)); @@ -244,7 +244,7 @@ static void test_dealloc_partial(void) Visitor *v; ud2_dict = qdict_new(); - qdict_put_obj(ud2_dict, "string0", QOBJECT(qstring_from_str(text))); + qdict_put(ud2_dict, "string0", qstring_from_str(text)); v = qobject_input_visitor_new(QOBJECT(ud2_dict)); visit_type_UserDefTwo(v, NULL, &ud2, &err); From patchwork Tue Aug 29 00:13:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806816 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh8Tv2fNYz9s65 for ; Tue, 29 Aug 2017 10:22:27 +1000 (AEST) Received: from localhost ([::1]:41908 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUIT-0006aL-6E for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:22:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47419) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUC8-0000rC-B8 for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUC5-00056t-4n for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:52 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:60523 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUC4-00056H-N8 for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:48 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0E7Yu043799 for ; Mon, 28 Aug 2017 20:15:48 -0400 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmu3kpdsm-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:15:48 -0400 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 18:15:47 -0600 Received: from b03cxnp08025.gho.boulder.ibm.com (9.17.130.17) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 18:15:46 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0FjTg66519206; Mon, 28 Aug 2017 17:15:45 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7EF2B78047; Mon, 28 Aug 2017 18:15:45 -0600 (MDT) Received: from localhost (unknown [9.80.85.217]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP id 48BEA7803F; Mon, 28 Aug 2017 18:15:45 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:13:51 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-8235-0000-0000-00000C2FE79F X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:15:47 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-8236-0000-0000-00003D6C06C6 Message-Id: <1503965694-10794-17-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 16/79] qobject: Add helper macros for common scalar insertions 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: qemu-stable@nongnu.org, Markus Armbruster Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Eric Blake Rather than making lots of callers wrap a scalar in a QInt, QString, or QBool, provide helper macros that do the wrapping automatically. Update the Coccinelle script to make mass conversions easy, although the conversion itself will be done as a separate patches to ease review and backport efforts. Signed-off-by: Eric Blake Reviewed-by: Markus Armbruster Message-Id: <20170427215821.19397-6-eblake@redhat.com> Signed-off-by: Markus Armbruster (cherry picked from commit a92c21591b5bb9543996538f14854ca6b528318b) Signed-off-by: Michael Roth --- include/qapi/qmp/qdict.h | 8 ++++++++ include/qapi/qmp/qlist.h | 8 ++++++++ scripts/coccinelle/qobject.cocci | 22 ++++++++++++++++++++++ 3 files changed, 38 insertions(+) diff --git a/include/qapi/qmp/qdict.h b/include/qapi/qmp/qdict.h index fe9a4c5..188440a 100644 --- a/include/qapi/qmp/qdict.h +++ b/include/qapi/qmp/qdict.h @@ -52,6 +52,14 @@ void qdict_destroy_obj(QObject *obj); #define qdict_put(qdict, key, obj) \ qdict_put_obj(qdict, key, QOBJECT(obj)) +/* Helpers for int, bool, and string */ +#define qdict_put_int(qdict, key, value) \ + qdict_put(qdict, key, qint_from_int(value)) +#define qdict_put_bool(qdict, key, value) \ + qdict_put(qdict, key, qbool_from_bool(value)) +#define qdict_put_str(qdict, key, value) \ + qdict_put(qdict, key, qstring_from_str(value)) + /* High level helpers */ double qdict_get_double(const QDict *qdict, const char *key); int64_t qdict_get_int(const QDict *qdict, const char *key); diff --git a/include/qapi/qmp/qlist.h b/include/qapi/qmp/qlist.h index a84117e..5dc4ed9 100644 --- a/include/qapi/qmp/qlist.h +++ b/include/qapi/qmp/qlist.h @@ -29,6 +29,14 @@ typedef struct QList { #define qlist_append(qlist, obj) \ qlist_append_obj(qlist, QOBJECT(obj)) +/* Helpers for int, bool, and string */ +#define qlist_append_int(qlist, value) \ + qlist_append(qlist, qint_from_int(value)) +#define qlist_append_bool(qlist, value) \ + qlist_append(qlist, qbool_from_bool(value)) +#define qlist_append_str(qlist, value) \ + qlist_append(qlist, qstring_from_str(value)) + #define QLIST_FOREACH_ENTRY(qlist, var) \ for ((var) = ((qlist)->head.tqh_first); \ (var); \ diff --git a/scripts/coccinelle/qobject.cocci b/scripts/coccinelle/qobject.cocci index aa899e2..97703a4 100644 --- a/scripts/coccinelle/qobject.cocci +++ b/scripts/coccinelle/qobject.cocci @@ -2,12 +2,34 @@ @@ expression Obj, Key, E; @@ +( - qdict_put_obj(Obj, Key, QOBJECT(E)); + qdict_put(Obj, Key, E); +| +- qdict_put(Obj, Key, qint_from_int(E)); ++ qdict_put_int(Obj, Key, E); +| +- qdict_put(Obj, Key, qbool_from_bool(E)); ++ qdict_put_bool(Obj, Key, E); +| +- qdict_put(Obj, Key, qstring_from_str(E)); ++ qdict_put_str(Obj, Key, E); +) // Use QList macros where they make sense @@ expression Obj, E; @@ +( - qlist_append_obj(Obj, QOBJECT(E)); + qlist_append(Obj, E); +| +- qlist_append(Obj, qint_from_int(E)); ++ qlist_append_int(Obj, E); +| +- qlist_append(Obj, qbool_from_bool(E)); ++ qlist_append_bool(Obj, E); +| +- qlist_append(Obj, qstring_from_str(E)); ++ qlist_append_str(Obj, E); +) From patchwork Tue Aug 29 00:13:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806810 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh8NG1syxz9s7v for ; Tue, 29 Aug 2017 10:17:34 +1000 (AEST) Received: from localhost ([::1]:41881 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUDk-00021n-1y for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:17:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47479) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCA-0000sv-Fh for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:57 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUC7-00058n-7D for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:54 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:52440 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUC6-000585-Sp for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:51 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0E9l5081535 for ; Mon, 28 Aug 2017 20:15:50 -0400 Received: from e37.co.us.ibm.com (e37.co.us.ibm.com [32.97.110.158]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmurncr6b-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:15:50 -0400 Received: from localhost by e37.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 18:15:49 -0600 Received: from b03cxnp07029.gho.boulder.ibm.com (9.17.130.16) by e37.co.us.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 18:15:47 -0600 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0FkKr9568640; Mon, 28 Aug 2017 17:15:46 -0700 Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C48E4BE03B; Mon, 28 Aug 2017 18:15:46 -0600 (MDT) Received: from localhost (unknown [9.80.85.217]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP id 90B61BE03A; Mon, 28 Aug 2017 18:15:46 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:13:52 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 17082900-0024-0000-0000-0000171CE4AB X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909027; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:15:49 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0025-0000-0000-00004C7F0500 Message-Id: <1503965694-10794-18-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-MIME-Autoconverted: from 8bit to quoted-printable by mx0a-001b2d01.pphosted.com id v7T0E9l5081535 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 17/79] s390x: Drop useless casts 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: Cornelia Huck , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Eric Blake An upcoming Coccinelle cleanup script wanted to reformat the casts present in this file - but on closer look, we don't need the casts at all because C automatically converts void* to any other pointer. Signed-off-by: Eric Blake Message-Id: <20170405194741.18956-4-eblake@redhat.com> Reviewed-by: Philippe Mathieu-Daudé Signed-off-by: Cornelia Huck (cherry picked from commit cb55c19a26d6928b445f1bd9394843c9eb60f8ab) * prereq for 46f5ac2 Signed-off-by: Michael Roth --- target/s390x/cpu_models.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index 1434d15..ce461cc 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -376,12 +376,12 @@ static void cpu_model_from_info(S390CPUModel *model, const CpuModelInfo *info, static void qdict_add_disabled_feat(const char *name, void *opaque) { - qdict_put((QDict *) opaque, name, qbool_from_bool(false)); + qdict_put(opaque, name, qbool_from_bool(false)); } static void qdict_add_enabled_feat(const char *name, void *opaque) { - qdict_put((QDict *) opaque, name, qbool_from_bool(true)); + qdict_put(opaque, name, qbool_from_bool(true)); } /* convert S390CPUDef into a static CpuModelInfo */ From patchwork Tue Aug 29 00:13:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806828 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh8gV5Sllz9s65 for ; Tue, 29 Aug 2017 10:30:46 +1000 (AEST) Received: from localhost ([::1]:41960 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUQW-0005tc-GT for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:30:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47671) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCG-00010G-Mx for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUC9-0005AE-0g for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:00 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:37698) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUC8-00059R-Gm for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:52 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0E71g090081 for ; Mon, 28 Aug 2017 20:15:51 -0400 Received: from e38.co.us.ibm.com (e38.co.us.ibm.com [32.97.110.159]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmvyehk3e-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:15:51 -0400 Received: from localhost by e38.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 18:15:50 -0600 Received: from b03cxnp08026.gho.boulder.ibm.com (9.17.130.18) by e38.co.us.ibm.com (192.168.1.138) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 18:15:48 -0600 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0Fl5G63438862; Mon, 28 Aug 2017 17:15:47 -0700 Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C9896C6042; Mon, 28 Aug 2017 18:15:47 -0600 (MDT) Received: from localhost (unknown [9.80.85.217]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP id 7AA7EC6037; Mon, 28 Aug 2017 18:15:47 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:13:53 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0028-0000-0000-00000846DB21 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:15:50 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0029-0000-0000-000037553110 Message-Id: <1503965694-10794-19-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=4 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 18/79] qobject: Use simpler QDict/QList scalar insertion macros 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: qemu-stable@nongnu.org, Markus Armbruster Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Eric Blake We now have macros in place to make it less verbose to add a scalar to QDict and QList, so use them. Patch created mechanically via: spatch --sp-file scripts/coccinelle/qobject.cocci \ --macro-file scripts/cocci-macro-file.h --dir . --in-place then touched up manually to fix a couple of '?:' back to original spacing, as well as avoiding a long line in monitor.c. Signed-off-by: Eric Blake Reviewed-by: Markus Armbruster Message-Id: <20170427215821.19397-7-eblake@redhat.com> Reviewed-by: Stefan Hajnoczi Reviewed-by: Alberto Garcia Signed-off-by: Markus Armbruster (cherry picked from commit 46f5ac205a9dc5e2c24274c7df371509a286281f) * prereq for fc0932f Signed-off-by: Michael Roth --- block.c | 45 +++++------- block/blkdebug.c | 6 +- block/blkverify.c | 6 +- block/curl.c | 2 +- block/file-posix.c | 8 +-- block/file-win32.c | 4 +- block/nbd.c | 41 ++++++----- block/nfs.c | 43 +++++------- block/null.c | 2 +- block/qcow2.c | 4 +- block/quorum.c | 8 +-- block/rbd.c | 16 ++--- block/snapshot.c | 2 +- block/ssh.c | 16 ++--- block/vvfat.c | 10 +-- blockdev.c | 30 ++++---- hw/block/xen_disk.c | 2 +- hw/usb/xen-usb.c | 12 ++-- monitor.c | 23 +++---- qapi/qmp-event.c | 2 +- qemu-img.c | 6 +- qemu-io.c | 2 +- qemu-nbd.c | 2 +- qobject/qdict.c | 2 +- target/s390x/cpu_models.c | 4 +- tests/check-qdict.c | 134 ++++++++++++++++++------------------ tests/check-qlist.c | 4 +- tests/device-introspect-test.c | 4 +- tests/test-qemu-opts.c | 4 +- tests/test-qmp-commands.c | 24 +++---- tests/test-qmp-event.c | 30 ++++---- tests/test-qobject-output-visitor.c | 6 +- util/qemu-option.c | 2 +- 33 files changed, 241 insertions(+), 265 deletions(-) diff --git a/block.c b/block.c index f156348..513e6e5 100644 --- a/block.c +++ b/block.c @@ -937,16 +937,14 @@ static void update_flags_from_options(int *flags, QemuOpts *opts) static void update_options_from_flags(QDict *options, int flags) { if (!qdict_haskey(options, BDRV_OPT_CACHE_DIRECT)) { - qdict_put(options, BDRV_OPT_CACHE_DIRECT, - qbool_from_bool(flags & BDRV_O_NOCACHE)); + qdict_put_bool(options, BDRV_OPT_CACHE_DIRECT, flags & BDRV_O_NOCACHE); } if (!qdict_haskey(options, BDRV_OPT_CACHE_NO_FLUSH)) { - qdict_put(options, BDRV_OPT_CACHE_NO_FLUSH, - qbool_from_bool(flags & BDRV_O_NO_FLUSH)); + qdict_put_bool(options, BDRV_OPT_CACHE_NO_FLUSH, + flags & BDRV_O_NO_FLUSH); } if (!qdict_haskey(options, BDRV_OPT_READ_ONLY)) { - qdict_put(options, BDRV_OPT_READ_ONLY, - qbool_from_bool(!(flags & BDRV_O_RDWR))); + qdict_put_bool(options, BDRV_OPT_READ_ONLY, !(flags & BDRV_O_RDWR)); } } @@ -1362,7 +1360,7 @@ static int bdrv_fill_options(QDict **options, const char *filename, /* Fetch the file name from the options QDict if necessary */ if (protocol && filename) { if (!qdict_haskey(*options, "filename")) { - qdict_put(*options, "filename", qstring_from_str(filename)); + qdict_put_str(*options, "filename", filename); parse_filename = true; } else { error_setg(errp, "Can't specify 'file' and 'filename' options at " @@ -1383,7 +1381,7 @@ static int bdrv_fill_options(QDict **options, const char *filename, } drvname = drv->format_name; - qdict_put(*options, "driver", qstring_from_str(drvname)); + qdict_put_str(*options, "driver", drvname); } else { error_setg(errp, "Must specify either driver or file"); return -EINVAL; @@ -2038,7 +2036,7 @@ int bdrv_open_backing_file(BlockDriverState *bs, QDict *parent_options, } if (bs->backing_format[0] != '\0' && !qdict_haskey(options, "driver")) { - qdict_put(options, "driver", qstring_from_str(bs->backing_format)); + qdict_put_str(options, "driver", bs->backing_format); } backing_hd = bdrv_open_inherit(*backing_filename ? backing_filename : NULL, @@ -2193,12 +2191,9 @@ static BlockDriverState *bdrv_append_temp_snapshot(BlockDriverState *bs, } /* Prepare options QDict for the temporary file */ - qdict_put(snapshot_options, "file.driver", - qstring_from_str("file")); - qdict_put(snapshot_options, "file.filename", - qstring_from_str(tmp_filename)); - qdict_put(snapshot_options, "driver", - qstring_from_str("qcow2")); + qdict_put_str(snapshot_options, "file.driver", "file"); + qdict_put_str(snapshot_options, "file.filename", tmp_filename); + qdict_put_str(snapshot_options, "driver", "qcow2"); bs_snapshot = bdrv_open(NULL, NULL, snapshot_options, flags, errp); snapshot_options = NULL; @@ -2373,8 +2368,7 @@ static BlockDriverState *bdrv_open_inherit(const char *filename, goto fail; } - qdict_put(options, "file", - qstring_from_str(bdrv_get_node_name(file_bs))); + qdict_put_str(options, "file", bdrv_get_node_name(file_bs)); } } @@ -2396,8 +2390,8 @@ static BlockDriverState *bdrv_open_inherit(const char *filename, * sure to update both bs->options (which has the full effective * options for bs) and options (which has file.* already removed). */ - qdict_put(bs->options, "driver", qstring_from_str(drv->format_name)); - qdict_put(options, "driver", qstring_from_str(drv->format_name)); + qdict_put_str(bs->options, "driver", drv->format_name); + qdict_put_str(options, "driver", drv->format_name); } else if (!drv) { error_setg(errp, "Must specify either driver or file"); goto fail; @@ -2772,12 +2766,12 @@ int bdrv_reopen_prepare(BDRVReopenState *reopen_state, BlockReopenQueue *queue, * that they are checked at the end of this function. */ value = qemu_opt_get(opts, "node-name"); if (value) { - qdict_put(reopen_state->options, "node-name", qstring_from_str(value)); + qdict_put_str(reopen_state->options, "node-name", value); } value = qemu_opt_get(opts, "driver"); if (value) { - qdict_put(reopen_state->options, "driver", qstring_from_str(value)); + qdict_put_str(reopen_state->options, "driver", value); } /* if we are to stay read-only, do not allow permission change @@ -4268,8 +4262,7 @@ void bdrv_img_create(const char *filename, const char *fmt, if (backing_fmt) { backing_options = qdict_new(); - qdict_put(backing_options, "driver", - qstring_from_str(backing_fmt)); + qdict_put_str(backing_options, "driver", backing_fmt); } bs = bdrv_open(full_backing, NULL, backing_options, back_flags, @@ -4674,7 +4667,7 @@ void bdrv_refresh_filename(BlockDriverState *bs) * contain a representation of the filename, therefore the following * suffices without querying the (exact_)filename of this BDS. */ if (bs->file->bs->full_open_options) { - qdict_put(opts, "driver", qstring_from_str(drv->format_name)); + qdict_put_str(opts, "driver", drv->format_name); QINCREF(bs->file->bs->full_open_options); qdict_put(opts, "file", bs->file->bs->full_open_options); @@ -4692,7 +4685,7 @@ void bdrv_refresh_filename(BlockDriverState *bs) opts = qdict_new(); append_open_options(opts, bs); - qdict_put(opts, "driver", qstring_from_str(drv->format_name)); + qdict_put_str(opts, "driver", drv->format_name); if (bs->exact_filename[0]) { /* This may not work for all block protocol drivers (some may @@ -4702,7 +4695,7 @@ void bdrv_refresh_filename(BlockDriverState *bs) * needs some special format of the options QDict, it needs to * implement the driver-specific bdrv_refresh_filename() function. */ - qdict_put(opts, "filename", qstring_from_str(bs->exact_filename)); + qdict_put_str(opts, "filename", bs->exact_filename); } bs->full_open_options = opts; diff --git a/block/blkdebug.c b/block/blkdebug.c index 42b8d80..ffc6f1d 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -301,7 +301,7 @@ static void blkdebug_parse_filename(const char *filename, QDict *options, if (!strstart(filename, "blkdebug:", &filename)) { /* There was no prefix; therefore, all options have to be already present in the QDict (except for the filename) */ - qdict_put(options, "x-image", qstring_from_str(filename)); + qdict_put_str(options, "x-image", filename); return; } @@ -320,7 +320,7 @@ static void blkdebug_parse_filename(const char *filename, QDict *options, /* TODO Allow multi-level nesting and set file.filename here */ filename = c + 1; - qdict_put(options, "x-image", qstring_from_str(filename)); + qdict_put_str(options, "x-image", filename); } static QemuOptsList runtime_opts = { @@ -693,7 +693,7 @@ static void blkdebug_refresh_filename(BlockDriverState *bs, QDict *options) } opts = qdict_new(); - qdict_put(opts, "driver", qstring_from_str("blkdebug")); + qdict_put_str(opts, "driver", "blkdebug"); QINCREF(bs->file->bs->full_open_options); qdict_put(opts, "image", bs->file->bs->full_open_options); diff --git a/block/blkverify.c b/block/blkverify.c index cc29cd2..6b0a603 100644 --- a/block/blkverify.c +++ b/block/blkverify.c @@ -67,7 +67,7 @@ static void blkverify_parse_filename(const char *filename, QDict *options, if (!strstart(filename, "blkverify:", &filename)) { /* There was no prefix; therefore, all options have to be already present in the QDict (except for the filename) */ - qdict_put(options, "x-image", qstring_from_str(filename)); + qdict_put_str(options, "x-image", filename); return; } @@ -84,7 +84,7 @@ static void blkverify_parse_filename(const char *filename, QDict *options, /* TODO Allow multi-level nesting and set file.filename here */ filename = c + 1; - qdict_put(options, "x-image", qstring_from_str(filename)); + qdict_put_str(options, "x-image", filename); } static QemuOptsList runtime_opts = { @@ -288,7 +288,7 @@ static void blkverify_refresh_filename(BlockDriverState *bs, QDict *options) && s->test_file->bs->full_open_options) { QDict *opts = qdict_new(); - qdict_put(opts, "driver", qstring_from_str("blkverify")); + qdict_put_str(opts, "driver", "blkverify"); QINCREF(bs->file->bs->full_open_options); qdict_put(opts, "raw", bs->file->bs->full_open_options); diff --git a/block/curl.c b/block/curl.c index 2708d57..aa6e8cc 100644 --- a/block/curl.c +++ b/block/curl.c @@ -548,7 +548,7 @@ static void curl_clean_state(CURLState *s) static void curl_parse_filename(const char *filename, QDict *options, Error **errp) { - qdict_put(options, CURL_BLOCK_OPT_URL, qstring_from_str(filename)); + qdict_put_str(options, CURL_BLOCK_OPT_URL, filename); } static void curl_detach_aio_context(BlockDriverState *bs) diff --git a/block/file-posix.c b/block/file-posix.c index 5370ba0..9431ad1 100644 --- a/block/file-posix.c +++ b/block/file-posix.c @@ -377,7 +377,7 @@ static void raw_parse_filename(const char *filename, QDict *options, * function call can be ignored. */ strstart(filename, "file:", &filename); - qdict_put(options, "filename", qstring_from_str(filename)); + qdict_put_str(options, "filename", filename); } static QemuOptsList raw_runtime_opts = { @@ -2150,7 +2150,7 @@ static void hdev_parse_filename(const char *filename, QDict *options, /* The prefix is optional, just as for "file". */ strstart(filename, "host_device:", &filename); - qdict_put(options, "filename", qstring_from_str(filename)); + qdict_put_str(options, "filename", filename); } static bool hdev_is_sg(BlockDriverState *bs) @@ -2239,7 +2239,7 @@ static int hdev_open(BlockDriverState *bs, QDict *options, int flags, goto hdev_open_Mac_error; } - qdict_put(options, "filename", qstring_from_str(bsd_path)); + qdict_put_str(options, "filename", bsd_path); hdev_open_Mac_error: g_free(mediaType); @@ -2449,7 +2449,7 @@ static void cdrom_parse_filename(const char *filename, QDict *options, /* The prefix is optional, just as for "file". */ strstart(filename, "host_cdrom:", &filename); - qdict_put(options, "filename", qstring_from_str(filename)); + qdict_put_str(options, "filename", filename); } #endif diff --git a/block/file-win32.c b/block/file-win32.c index 57c4a78..0d455d1 100644 --- a/block/file-win32.c +++ b/block/file-win32.c @@ -282,7 +282,7 @@ static void raw_parse_filename(const char *filename, QDict *options, * function call can be ignored. */ strstart(filename, "file:", &filename); - qdict_put(options, "filename", qstring_from_str(filename)); + qdict_put_str(options, "filename", filename); } static QemuOptsList raw_runtime_opts = { @@ -669,7 +669,7 @@ static void hdev_parse_filename(const char *filename, QDict *options, /* The prefix is optional, just as for "file". */ strstart(filename, "host_device:", &filename); - qdict_put(options, "filename", qstring_from_str(filename)); + qdict_put_str(options, "filename", filename); } static int hdev_open(BlockDriverState *bs, QDict *options, int flags, diff --git a/block/nbd.c b/block/nbd.c index 814ab26d..b3545f5 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -79,7 +79,7 @@ static int nbd_parse_uri(const char *filename, QDict *options) p = uri->path ? uri->path : "/"; p += strspn(p, "/"); if (p[0]) { - qdict_put(options, "export", qstring_from_str(p)); + qdict_put_str(options, "export", p); } qp = query_params_parse(uri->query); @@ -94,9 +94,8 @@ static int nbd_parse_uri(const char *filename, QDict *options) ret = -EINVAL; goto out; } - qdict_put(options, "server.type", qstring_from_str("unix")); - qdict_put(options, "server.path", - qstring_from_str(qp->p[0].value)); + qdict_put_str(options, "server.type", "unix"); + qdict_put_str(options, "server.path", qp->p[0].value); } else { QString *host; char *port_str; @@ -115,11 +114,11 @@ static int nbd_parse_uri(const char *filename, QDict *options) host = qstring_from_str(uri->server); } - qdict_put(options, "server.type", qstring_from_str("inet")); + qdict_put_str(options, "server.type", "inet"); qdict_put(options, "server.host", host); port_str = g_strdup_printf("%d", uri->port ?: NBD_DEFAULT_PORT); - qdict_put(options, "server.port", qstring_from_str(port_str)); + qdict_put_str(options, "server.port", port_str); g_free(port_str); } @@ -181,7 +180,7 @@ static void nbd_parse_filename(const char *filename, QDict *options, export_name[0] = 0; /* truncate 'file' */ export_name += strlen(EN_OPTSTR); - qdict_put(options, "export", qstring_from_str(export_name)); + qdict_put_str(options, "export", export_name); } /* extract the host_spec - fail if it's not nbd:... */ @@ -196,8 +195,8 @@ static void nbd_parse_filename(const char *filename, QDict *options, /* are we a UNIX or TCP socket? */ if (strstart(host_spec, "unix:", &unixpath)) { - qdict_put(options, "server.type", qstring_from_str("unix")); - qdict_put(options, "server.path", qstring_from_str(unixpath)); + qdict_put_str(options, "server.type", "unix"); + qdict_put_str(options, "server.path", unixpath); } else { InetSocketAddress *addr = NULL; @@ -206,9 +205,9 @@ static void nbd_parse_filename(const char *filename, QDict *options, goto out; } - qdict_put(options, "server.type", qstring_from_str("inet")); - qdict_put(options, "server.host", qstring_from_str(addr->host)); - qdict_put(options, "server.port", qstring_from_str(addr->port)); + qdict_put_str(options, "server.type", "inet"); + qdict_put_str(options, "server.host", addr->host); + qdict_put_str(options, "server.port", addr->port); qapi_free_InetSocketAddress(addr); } @@ -247,13 +246,13 @@ static bool nbd_process_legacy_socket_options(QDict *output_options, return false; } - qdict_put(output_options, "server.type", qstring_from_str("unix")); - qdict_put(output_options, "server.path", qstring_from_str(path)); + qdict_put_str(output_options, "server.type", "unix"); + qdict_put_str(output_options, "server.path", path); } else if (host) { - qdict_put(output_options, "server.type", qstring_from_str("inet")); - qdict_put(output_options, "server.host", qstring_from_str(host)); - qdict_put(output_options, "server.port", - qstring_from_str(port ?: stringify(NBD_DEFAULT_PORT))); + qdict_put_str(output_options, "server.type", "inet"); + qdict_put_str(output_options, "server.host", host); + qdict_put_str(output_options, "server.port", + port ?: stringify(NBD_DEFAULT_PORT)); } return true; @@ -528,7 +527,7 @@ static void nbd_refresh_filename(BlockDriverState *bs, QDict *options) path = s->saddr->u.q_unix.path; } /* else can't represent as pseudo-filename */ - qdict_put(opts, "driver", qstring_from_str("nbd")); + qdict_put_str(opts, "driver", "nbd"); if (path && s->export) { snprintf(bs->exact_filename, sizeof(bs->exact_filename), @@ -551,10 +550,10 @@ static void nbd_refresh_filename(BlockDriverState *bs, QDict *options) qdict_put_obj(opts, "server", saddr_qdict); if (s->export) { - qdict_put(opts, "export", qstring_from_str(s->export)); + qdict_put_str(opts, "export", s->export); } if (s->tlscredsid) { - qdict_put(opts, "tls-creds", qstring_from_str(s->tlscredsid)); + qdict_put_str(opts, "tls-creds", s->tlscredsid); } qdict_flatten(opts); diff --git a/block/nfs.c b/block/nfs.c index 0816678..bfeebc1 100644 --- a/block/nfs.c +++ b/block/nfs.c @@ -104,9 +104,9 @@ static int nfs_parse_uri(const char *filename, QDict *options, Error **errp) goto out; } - qdict_put(options, "server.host", qstring_from_str(uri->server)); - qdict_put(options, "server.type", qstring_from_str("inet")); - qdict_put(options, "path", qstring_from_str(uri->path)); + qdict_put_str(options, "server.host", uri->server); + qdict_put_str(options, "server.type", "inet"); + qdict_put_str(options, "path", uri->path); for (i = 0; i < qp->n; i++) { unsigned long long val; @@ -121,23 +121,17 @@ static int nfs_parse_uri(const char *filename, QDict *options, Error **errp) goto out; } if (!strcmp(qp->p[i].name, "uid")) { - qdict_put(options, "user", - qstring_from_str(qp->p[i].value)); + qdict_put_str(options, "user", qp->p[i].value); } else if (!strcmp(qp->p[i].name, "gid")) { - qdict_put(options, "group", - qstring_from_str(qp->p[i].value)); + qdict_put_str(options, "group", qp->p[i].value); } else if (!strcmp(qp->p[i].name, "tcp-syncnt")) { - qdict_put(options, "tcp-syn-count", - qstring_from_str(qp->p[i].value)); + qdict_put_str(options, "tcp-syn-count", qp->p[i].value); } else if (!strcmp(qp->p[i].name, "readahead")) { - qdict_put(options, "readahead-size", - qstring_from_str(qp->p[i].value)); + qdict_put_str(options, "readahead-size", qp->p[i].value); } else if (!strcmp(qp->p[i].name, "pagecache")) { - qdict_put(options, "page-cache-size", - qstring_from_str(qp->p[i].value)); + qdict_put_str(options, "page-cache-size", qp->p[i].value); } else if (!strcmp(qp->p[i].name, "debug")) { - qdict_put(options, "debug", - qstring_from_str(qp->p[i].value)); + qdict_put_str(options, "debug", qp->p[i].value); } else { error_setg(errp, "Unknown NFS parameter name: %s", qp->p[i].name); @@ -811,7 +805,7 @@ static void nfs_refresh_filename(BlockDriverState *bs, QDict *options) QObject *server_qdict; Visitor *ov; - qdict_put(opts, "driver", qstring_from_str("nfs")); + qdict_put_str(opts, "driver", "nfs"); if (client->uid && !client->gid) { snprintf(bs->exact_filename, sizeof(bs->exact_filename), @@ -834,28 +828,25 @@ static void nfs_refresh_filename(BlockDriverState *bs, QDict *options) visit_type_NFSServer(ov, NULL, &client->server, &error_abort); visit_complete(ov, &server_qdict); qdict_put_obj(opts, "server", server_qdict); - qdict_put(opts, "path", qstring_from_str(client->path)); + qdict_put_str(opts, "path", client->path); if (client->uid) { - qdict_put(opts, "user", qint_from_int(client->uid)); + qdict_put_int(opts, "user", client->uid); } if (client->gid) { - qdict_put(opts, "group", qint_from_int(client->gid)); + qdict_put_int(opts, "group", client->gid); } if (client->tcp_syncnt) { - qdict_put(opts, "tcp-syn-cnt", - qint_from_int(client->tcp_syncnt)); + qdict_put_int(opts, "tcp-syn-cnt", client->tcp_syncnt); } if (client->readahead) { - qdict_put(opts, "readahead-size", - qint_from_int(client->readahead)); + qdict_put_int(opts, "readahead-size", client->readahead); } if (client->pagecache) { - qdict_put(opts, "page-cache-size", - qint_from_int(client->pagecache)); + qdict_put_int(opts, "page-cache-size", client->pagecache); } if (client->debug) { - qdict_put(opts, "debug", qint_from_int(client->debug)); + qdict_put_int(opts, "debug", client->debug); } visit_free(ov); diff --git a/block/null.c b/block/null.c index b300390..876f909 100644 --- a/block/null.c +++ b/block/null.c @@ -232,7 +232,7 @@ static void null_refresh_filename(BlockDriverState *bs, QDict *opts) bs->drv->format_name); } - qdict_put(opts, "driver", qstring_from_str(bs->drv->format_name)); + qdict_put_str(opts, "driver", bs->drv->format_name); bs->full_open_options = opts; } diff --git a/block/qcow2.c b/block/qcow2.c index 6a92d2e..49c737f 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2265,7 +2265,7 @@ static int qcow2_create2(const char *filename, int64_t total_size, * table) */ options = qdict_new(); - qdict_put(options, "driver", qstring_from_str("qcow2")); + qdict_put_str(options, "driver", "qcow2"); blk = blk_new_open(filename, NULL, options, BDRV_O_RDWR | BDRV_O_RESIZE | BDRV_O_NO_FLUSH, &local_err); @@ -2327,7 +2327,7 @@ static int qcow2_create2(const char *filename, int64_t total_size, /* Reopen the image without BDRV_O_NO_FLUSH to flush it before returning */ options = qdict_new(); - qdict_put(options, "driver", qstring_from_str("qcow2")); + qdict_put_str(options, "driver", "qcow2"); blk = blk_new_open(filename, NULL, options, BDRV_O_RDWR | BDRV_O_NO_BACKING, &local_err); if (blk == NULL) { diff --git a/block/quorum.c b/block/quorum.c index f7949e2..1b2a8c3 100644 --- a/block/quorum.c +++ b/block/quorum.c @@ -1100,10 +1100,10 @@ static void quorum_refresh_filename(BlockDriverState *bs, QDict *options) } opts = qdict_new(); - qdict_put(opts, "driver", qstring_from_str("quorum")); - qdict_put(opts, QUORUM_OPT_VOTE_THRESHOLD, qint_from_int(s->threshold)); - qdict_put(opts, QUORUM_OPT_BLKVERIFY, qbool_from_bool(s->is_blkverify)); - qdict_put(opts, QUORUM_OPT_REWRITE, qbool_from_bool(s->rewrite_corrupted)); + qdict_put_str(opts, "driver", "quorum"); + qdict_put_int(opts, QUORUM_OPT_VOTE_THRESHOLD, s->threshold); + qdict_put_bool(opts, QUORUM_OPT_BLKVERIFY, s->is_blkverify); + qdict_put_bool(opts, QUORUM_OPT_REWRITE, s->rewrite_corrupted); qdict_put(opts, "children", children); bs->full_open_options = opts; diff --git a/block/rbd.c b/block/rbd.c index 1ceeeb5..2354ffc 100644 --- a/block/rbd.c +++ b/block/rbd.c @@ -154,20 +154,20 @@ static void qemu_rbd_parse_filename(const char *filename, QDict *options, goto done; } qemu_rbd_unescape(found_str); - qdict_put(options, "pool", qstring_from_str(found_str)); + qdict_put_str(options, "pool", found_str); if (strchr(p, '@')) { found_str = qemu_rbd_next_tok(p, '@', &p); qemu_rbd_unescape(found_str); - qdict_put(options, "image", qstring_from_str(found_str)); + qdict_put_str(options, "image", found_str); found_str = qemu_rbd_next_tok(p, ':', &p); qemu_rbd_unescape(found_str); - qdict_put(options, "snapshot", qstring_from_str(found_str)); + qdict_put_str(options, "snapshot", found_str); } else { found_str = qemu_rbd_next_tok(p, ':', &p); qemu_rbd_unescape(found_str); - qdict_put(options, "image", qstring_from_str(found_str)); + qdict_put_str(options, "image", found_str); } if (!p) { goto done; @@ -189,9 +189,9 @@ static void qemu_rbd_parse_filename(const char *filename, QDict *options, qemu_rbd_unescape(value); if (!strcmp(name, "conf")) { - qdict_put(options, "conf", qstring_from_str(value)); + qdict_put_str(options, "conf", value); } else if (!strcmp(name, "id")) { - qdict_put(options, "user" , qstring_from_str(value)); + qdict_put_str(options, "user", value); } else { /* * We pass these internally to qemu_rbd_set_keypairs(), so @@ -204,8 +204,8 @@ static void qemu_rbd_parse_filename(const char *filename, QDict *options, if (!keypairs) { keypairs = qlist_new(); } - qlist_append(keypairs, qstring_from_str(name)); - qlist_append(keypairs, qstring_from_str(value)); + qlist_append_str(keypairs, name); + qlist_append_str(keypairs, value); } } diff --git a/block/snapshot.c b/block/snapshot.c index 06b1185..a46564e 100644 --- a/block/snapshot.c +++ b/block/snapshot.c @@ -200,7 +200,7 @@ int bdrv_snapshot_goto(BlockDriverState *bs, qdict_extract_subqdict(options, &file_options, "file."); QDECREF(file_options); - qdict_put(options, "file", qstring_from_str(bdrv_get_node_name(file))); + qdict_put_str(options, "file", bdrv_get_node_name(file)); drv->bdrv_close(bs); bdrv_unref_child(bs, bs->file); diff --git a/block/ssh.c b/block/ssh.c index 471ba8a..34a2f79 100644 --- a/block/ssh.c +++ b/block/ssh.c @@ -227,24 +227,23 @@ static int parse_uri(const char *filename, QDict *options, Error **errp) } if(uri->user && strcmp(uri->user, "") != 0) { - qdict_put(options, "user", qstring_from_str(uri->user)); + qdict_put_str(options, "user", uri->user); } - qdict_put(options, "server.host", qstring_from_str(uri->server)); + qdict_put_str(options, "server.host", uri->server); port_str = g_strdup_printf("%d", uri->port ?: 22); - qdict_put(options, "server.port", qstring_from_str(port_str)); + qdict_put_str(options, "server.port", port_str); g_free(port_str); - qdict_put(options, "path", qstring_from_str(uri->path)); + qdict_put_str(options, "path", uri->path); /* Pick out any query parameters that we understand, and ignore * the rest. */ for (i = 0; i < qp->n; ++i) { if (strcmp(qp->p[i].name, "host_key_check") == 0) { - qdict_put(options, "host_key_check", - qstring_from_str(qp->p[i].value)); + qdict_put_str(options, "host_key_check", qp->p[i].value); } } @@ -574,9 +573,8 @@ static bool ssh_process_legacy_socket_options(QDict *output_opts, } if (host) { - qdict_put(output_opts, "server.host", qstring_from_str(host)); - qdict_put(output_opts, "server.port", - qstring_from_str(port ?: stringify(22))); + qdict_put_str(output_opts, "server.host", host); + qdict_put_str(output_opts, "server.port", port ?: stringify(22)); } return true; diff --git a/block/vvfat.c b/block/vvfat.c index af5153d..8b4e4eb 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -1057,10 +1057,10 @@ static void vvfat_parse_filename(const char *filename, QDict *options, } /* Fill in the options QDict */ - qdict_put(options, "dir", qstring_from_str(filename)); - qdict_put(options, "fat-type", qint_from_int(fat_type)); - qdict_put(options, "floppy", qbool_from_bool(floppy)); - qdict_put(options, "rw", qbool_from_bool(rw)); + qdict_put_str(options, "dir", filename); + qdict_put_int(options, "fat-type", fat_type); + qdict_put_bool(options, "floppy", floppy); + qdict_put_bool(options, "rw", rw); } static int vvfat_open(BlockDriverState *bs, QDict *options, int flags, @@ -3040,7 +3040,7 @@ static int enable_write_target(BlockDriverState *bs, Error **errp) } options = qdict_new(); - qdict_put(options, "write-target.driver", qstring_from_str("qcow")); + qdict_put_str(options, "write-target.driver", "qcow"); s->qcow = bdrv_open_child(s->qcow_filename, options, "write-target", bs, &child_vvfat_qcow, false, errp); QDECREF(options); diff --git a/blockdev.c b/blockdev.c index 4927914..e2f9c1e 100644 --- a/blockdev.c +++ b/blockdev.c @@ -527,7 +527,7 @@ static BlockBackend *blockdev_init(const char *file, QDict *bs_opts, error_setg(errp, "Cannot specify both 'driver' and 'format'"); goto early_err; } - qdict_put(bs_opts, "driver", qstring_from_str(buf)); + qdict_put_str(bs_opts, "driver", buf); } on_write_error = BLOCKDEV_ON_ERROR_ENOSPC; @@ -903,10 +903,8 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type) copy_on_read = false; } - qdict_put(bs_opts, BDRV_OPT_READ_ONLY, - qstring_from_str(read_only ? "on" : "off")); - qdict_put(bs_opts, "copy-on-read", - qstring_from_str(copy_on_read ? "on" :"off")); + qdict_put_str(bs_opts, BDRV_OPT_READ_ONLY, read_only ? "on" : "off"); + qdict_put_str(bs_opts, "copy-on-read", copy_on_read ? "on" : "off"); /* Controller type */ value = qemu_opt_get(legacy_opts, "if"); @@ -1030,7 +1028,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type) new_id = g_strdup_printf("%s%s%i", if_name[type], mediastr, unit_id); } - qdict_put(bs_opts, "id", qstring_from_str(new_id)); + qdict_put_str(bs_opts, "id", new_id); g_free(new_id); } @@ -1067,7 +1065,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type) error_report("werror is not supported by this bus type"); goto fail; } - qdict_put(bs_opts, "werror", qstring_from_str(werror)); + qdict_put_str(bs_opts, "werror", werror); } rerror = qemu_opt_get(legacy_opts, "rerror"); @@ -1077,7 +1075,7 @@ DriveInfo *drive_new(QemuOpts *all_opts, BlockInterfaceType block_default_type) error_report("rerror is not supported by this bus type"); goto fail; } - qdict_put(bs_opts, "rerror", qstring_from_str(rerror)); + qdict_put_str(bs_opts, "rerror", rerror); } /* Actual block device init: Functionality shared with blockdev-add */ @@ -1737,10 +1735,9 @@ static void external_snapshot_prepare(BlkActionState *common, options = qdict_new(); if (s->has_snapshot_node_name) { - qdict_put(options, "node-name", - qstring_from_str(snapshot_node_name)); + qdict_put_str(options, "node-name", snapshot_node_name); } - qdict_put(options, "driver", qstring_from_str(format)); + qdict_put_str(options, "driver", format); flags |= BDRV_O_NO_BACKING; } @@ -2579,11 +2576,10 @@ void qmp_blockdev_change_medium(bool has_device, const char *device, options = qdict_new(); detect_zeroes = blk_get_detect_zeroes_from_root_state(blk); - qdict_put(options, "detect-zeroes", - qstring_from_str(detect_zeroes ? "on" : "off")); + qdict_put_str(options, "detect-zeroes", detect_zeroes ? "on" : "off"); if (has_format) { - qdict_put(options, "driver", qstring_from_str(format)); + qdict_put_str(options, "driver", format); } medium_bs = bdrv_open(filename, NULL, options, bdrv_flags, errp); @@ -3251,7 +3247,7 @@ static BlockJob *do_drive_backup(DriveBackup *backup, BlockJobTxn *txn, if (backup->format) { options = qdict_new(); - qdict_put(options, "driver", qstring_from_str(backup->format)); + qdict_put_str(options, "driver", backup->format); } target_bs = bdrv_open(backup->target, NULL, options, flags, errp); @@ -3555,10 +3551,10 @@ void qmp_drive_mirror(DriveMirror *arg, Error **errp) options = qdict_new(); if (arg->has_node_name) { - qdict_put(options, "node-name", qstring_from_str(arg->node_name)); + qdict_put_str(options, "node-name", arg->node_name); } if (format) { - qdict_put(options, "driver", qstring_from_str(format)); + qdict_put_str(options, "driver", format); } /* Mirroring takes care of copy-on-write using the source's backing diff --git a/hw/block/xen_disk.c b/hw/block/xen_disk.c index 456a2d5..47b2ca1 100644 --- a/hw/block/xen_disk.c +++ b/hw/block/xen_disk.c @@ -1082,7 +1082,7 @@ static int blk_connect(struct XenDevice *xendev) if (strcmp(blkdev->fileproto, "")) { options = qdict_new(); - qdict_put(options, "driver", qstring_from_str(blkdev->fileproto)); + qdict_put_str(options, "driver", blkdev->fileproto); } /* setup via xenbus -> create new block driver instance */ diff --git a/hw/usb/xen-usb.c b/hw/usb/xen-usb.c index 8e676e6..6659415 100644 --- a/hw/usb/xen-usb.c +++ b/hw/usb/xen-usb.c @@ -746,16 +746,16 @@ static void usbback_portid_add(struct usbback_info *usbif, unsigned port, portname++; qdict = qdict_new(); - qdict_put(qdict, "driver", qstring_from_str("usb-host")); + qdict_put_str(qdict, "driver", "usb-host"); tmp = g_strdup_printf("%s.0", usbif->xendev.qdev.id); - qdict_put(qdict, "bus", qstring_from_str(tmp)); + qdict_put_str(qdict, "bus", tmp); g_free(tmp); tmp = g_strdup_printf("%s-%u", usbif->xendev.qdev.id, port); - qdict_put(qdict, "id", qstring_from_str(tmp)); + qdict_put_str(qdict, "id", tmp); g_free(tmp); - qdict_put(qdict, "port", qint_from_int(port)); - qdict_put(qdict, "hostbus", qint_from_int(atoi(busid))); - qdict_put(qdict, "hostport", qstring_from_str(portname)); + qdict_put_int(qdict, "port", port); + qdict_put_int(qdict, "hostbus", atoi(busid)); + qdict_put_str(qdict, "hostport", portname); opts = qemu_opts_from_qdict(qemu_find_opts("device"), qdict, &local_err); if (local_err) { goto err; diff --git a/monitor.c b/monitor.c index 2799a37..957361c 100644 --- a/monitor.c +++ b/monitor.c @@ -2676,7 +2676,7 @@ static QDict *monitor_parse_arguments(Monitor *mon, } goto fail; } - qdict_put(qdict, key, qstring_from_str(buf)); + qdict_put_str(qdict, key, buf); } break; case 'O': @@ -2778,9 +2778,9 @@ static QDict *monitor_parse_arguments(Monitor *mon, size = -1; } } - qdict_put(qdict, "count", qint_from_int(count)); - qdict_put(qdict, "format", qint_from_int(format)); - qdict_put(qdict, "size", qint_from_int(size)); + qdict_put_int(qdict, "count", count); + qdict_put_int(qdict, "format", format); + qdict_put_int(qdict, "size", size); } break; case 'i': @@ -2823,7 +2823,7 @@ static QDict *monitor_parse_arguments(Monitor *mon, } val <<= 20; } - qdict_put(qdict, key, qint_from_int(val)); + qdict_put_int(qdict, key, val); } break; case 'o': @@ -2846,7 +2846,7 @@ static QDict *monitor_parse_arguments(Monitor *mon, monitor_printf(mon, "invalid size\n"); goto fail; } - qdict_put(qdict, key, qint_from_int(val)); + qdict_put_int(qdict, key, val); p = end; } break; @@ -2902,7 +2902,7 @@ static QDict *monitor_parse_arguments(Monitor *mon, monitor_printf(mon, "Expected 'on' or 'off'\n"); goto fail; } - qdict_put(qdict, key, qbool_from_bool(val)); + qdict_put_bool(qdict, key, val); } break; case '-': @@ -2933,7 +2933,7 @@ static QDict *monitor_parse_arguments(Monitor *mon, } else { /* has option */ p++; - qdict_put(qdict, key, qbool_from_bool(true)); + qdict_put_bool(qdict, key, true); } } } @@ -2959,7 +2959,7 @@ static QDict *monitor_parse_arguments(Monitor *mon, cmd->name); goto fail; } - qdict_put(qdict, key, qstring_from_str(p)); + qdict_put_str(qdict, key, p); p += len; } break; @@ -3738,9 +3738,8 @@ static void handle_qmp_command(JSONMessageParser *parser, GQueue *tokens) QapiErrorClass_lookup[ERROR_CLASS_COMMAND_NOT_FOUND])) { /* Provide a more useful error message */ qdict_del(qdict, "desc"); - qdict_put(qdict, "desc", - qstring_from_str("Expecting capabilities negotiation" - " with 'qmp_capabilities'")); + qdict_put_str(qdict, "desc", "Expecting capabilities negotiation" + " with 'qmp_capabilities'"); } } diff --git a/qapi/qmp-event.c b/qapi/qmp-event.c index 802ede4..ba3029c 100644 --- a/qapi/qmp-event.c +++ b/qapi/qmp-event.c @@ -51,7 +51,7 @@ static void timestamp_put(QDict *qdict) QDict *qmp_event_build_dict(const char *event_name) { QDict *dict = qdict_new(); - qdict_put(dict, "event", qstring_from_str(event_name)); + qdict_put_str(dict, "event", event_name); timestamp_put(dict); return dict; } diff --git a/qemu-img.c b/qemu-img.c index 4b2d59a..2e61561 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -313,7 +313,7 @@ static BlockBackend *img_open_file(const char *filename, if (fmt) { options = qdict_new(); - qdict_put(options, "driver", qstring_from_str(fmt)); + qdict_put_str(options, "driver", fmt); } blk = blk_new_open(filename, NULL, options, flags, &local_err); @@ -3162,7 +3162,7 @@ static int img_rebase(int argc, char **argv) if (bs->backing_format[0] != '\0') { options = qdict_new(); - qdict_put(options, "driver", qstring_from_str(bs->backing_format)); + qdict_put_str(options, "driver", bs->backing_format); } bdrv_get_backing_filename(bs, backing_name, sizeof(backing_name)); @@ -3179,7 +3179,7 @@ static int img_rebase(int argc, char **argv) if (out_baseimg[0]) { if (out_basefmt) { options = qdict_new(); - qdict_put(options, "driver", qstring_from_str(out_basefmt)); + qdict_put_str(options, "driver", out_basefmt); } else { options = NULL; } diff --git a/qemu-io.c b/qemu-io.c index 427cbae..ed0e2dc 100644 --- a/qemu-io.c +++ b/qemu-io.c @@ -601,7 +601,7 @@ int main(int argc, char **argv) } else { if (format) { opts = qdict_new(); - qdict_put(opts, "driver", qstring_from_str(format)); + qdict_put_str(opts, "driver", format); } if (openfile(argv[optind], flags, writethrough, opts)) { exit(1); diff --git a/qemu-nbd.c b/qemu-nbd.c index e080fb7..e4f00e2 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -959,7 +959,7 @@ int main(int argc, char **argv) } else { if (fmt) { options = qdict_new(); - qdict_put(options, "driver", qstring_from_str(fmt)); + qdict_put_str(options, "driver", fmt); } blk = blk_new_open(srcpath, NULL, options, flags, &local_err); } diff --git a/qobject/qdict.c b/qobject/qdict.c index 291eef1..88e2ecd 100644 --- a/qobject/qdict.c +++ b/qobject/qdict.c @@ -463,7 +463,7 @@ void qdict_set_default_str(QDict *dst, const char *key, const char *val) return; } - qdict_put(dst, key, qstring_from_str(val)); + qdict_put_str(dst, key, val); } static void qdict_flatten_qdict(QDict *qdict, QDict *target, diff --git a/target/s390x/cpu_models.c b/target/s390x/cpu_models.c index ce461cc..8d27363 100644 --- a/target/s390x/cpu_models.c +++ b/target/s390x/cpu_models.c @@ -376,12 +376,12 @@ static void cpu_model_from_info(S390CPUModel *model, const CpuModelInfo *info, static void qdict_add_disabled_feat(const char *name, void *opaque) { - qdict_put(opaque, name, qbool_from_bool(false)); + qdict_put_bool(opaque, name, false); } static void qdict_add_enabled_feat(const char *name, void *opaque) { - qdict_put(opaque, name, qbool_from_bool(true)); + qdict_put_bool(opaque, name, true); } /* convert S390CPUDef into a static CpuModelInfo */ diff --git a/tests/check-qdict.c b/tests/check-qdict.c index 9cdc985..3effca5 100644 --- a/tests/check-qdict.c +++ b/tests/check-qdict.c @@ -47,7 +47,7 @@ static void qdict_put_obj_test(void) qdict = qdict_new(); // key "" will have tdb hash 12345 - qdict_put(qdict, "", qint_from_int(num)); + qdict_put_int(qdict, "", num); g_assert(qdict_size(qdict) == 1); ent = QLIST_FIRST(&qdict->table[12345 % QDICT_BUCKET_MAX]); @@ -66,8 +66,8 @@ static void qdict_destroy_simple_test(void) QDict *qdict; qdict = qdict_new(); - qdict_put(qdict, "num", qint_from_int(0)); - qdict_put(qdict, "str", qstring_from_str("foo")); + qdict_put_int(qdict, "num", 0); + qdict_put_str(qdict, "str", "foo"); QDECREF(qdict); } @@ -80,7 +80,7 @@ static void qdict_get_test(void) const char *key = "test"; QDict *tests_dict = qdict_new(); - qdict_put(tests_dict, key, qint_from_int(value)); + qdict_put_int(tests_dict, key, value); obj = qdict_get(tests_dict, key); g_assert(obj != NULL); @@ -98,7 +98,7 @@ static void qdict_get_int_test(void) const char *key = "int"; QDict *tests_dict = qdict_new(); - qdict_put(tests_dict, key, qint_from_int(value)); + qdict_put_int(tests_dict, key, value); ret = qdict_get_int(tests_dict, key); g_assert(ret == value); @@ -113,7 +113,7 @@ static void qdict_get_try_int_test(void) const char *key = "int"; QDict *tests_dict = qdict_new(); - qdict_put(tests_dict, key, qint_from_int(value)); + qdict_put_int(tests_dict, key, value); ret = qdict_get_try_int(tests_dict, key, 0); g_assert(ret == value); @@ -128,7 +128,7 @@ static void qdict_get_str_test(void) const char *str = "string"; QDict *tests_dict = qdict_new(); - qdict_put(tests_dict, key, qstring_from_str(str)); + qdict_put_str(tests_dict, key, str); p = qdict_get_str(tests_dict, key); g_assert(p != NULL); @@ -144,7 +144,7 @@ static void qdict_get_try_str_test(void) const char *str = "string"; QDict *tests_dict = qdict_new(); - qdict_put(tests_dict, key, qstring_from_str(str)); + qdict_put_str(tests_dict, key, str); p = qdict_get_try_str(tests_dict, key); g_assert(p != NULL); @@ -188,7 +188,7 @@ static void qdict_haskey_test(void) const char *key = "test"; QDict *tests_dict = qdict_new(); - qdict_put(tests_dict, key, qint_from_int(0)); + qdict_put_int(tests_dict, key, 0); g_assert(qdict_haskey(tests_dict, key) == 1); QDECREF(tests_dict); @@ -199,7 +199,7 @@ static void qdict_del_test(void) const char *key = "key test"; QDict *tests_dict = qdict_new(); - qdict_put(tests_dict, key, qstring_from_str("foo")); + qdict_put_str(tests_dict, key, "foo"); g_assert(qdict_size(tests_dict) == 1); qdict_del(tests_dict, key); @@ -226,9 +226,9 @@ static void qdict_iterapi_test(void) g_assert(qdict_first(tests_dict) == NULL); - qdict_put(tests_dict, "key1", qint_from_int(1)); - qdict_put(tests_dict, "key2", qint_from_int(2)); - qdict_put(tests_dict, "key3", qint_from_int(3)); + qdict_put_int(tests_dict, "key1", 1); + qdict_put_int(tests_dict, "key2", 2); + qdict_put_int(tests_dict, "key3", 3); count = 0; for (ent = qdict_first(tests_dict); ent; ent = qdict_next(tests_dict, ent)){ @@ -294,20 +294,20 @@ static void qdict_flatten_test(void) * } */ - qdict_put(dict1, "a", qint_from_int(0)); - qdict_put(dict1, "b", qint_from_int(1)); + qdict_put_int(dict1, "a", 0); + qdict_put_int(dict1, "b", 1); - qlist_append(list1, qint_from_int(23)); - qlist_append(list1, qint_from_int(66)); + qlist_append_int(list1, 23); + qlist_append_int(list1, 66); qlist_append(list1, dict1); - qlist_append(list2, qint_from_int(42)); + qlist_append_int(list2, 42); qlist_append(list2, list1); - qdict_put(dict2, "c", qint_from_int(2)); - qdict_put(dict2, "d", qint_from_int(3)); + qdict_put_int(dict2, "c", 2); + qdict_put_int(dict2, "d", 3); qdict_put(dict3, "e", list2); qdict_put(dict3, "f", dict2); - qdict_put(dict3, "g", qint_from_int(4)); + qdict_put_int(dict3, "g", 4); qdict_flatten(dict3); @@ -369,12 +369,12 @@ static void qdict_array_split_test(void) * This example is given in the comment of qdict_array_split(). */ - qdict_put(test_dict, "1.x", qint_from_int(0)); - qdict_put(test_dict, "4.y", qint_from_int(1)); - qdict_put(test_dict, "0.a", qint_from_int(42)); - qdict_put(test_dict, "o.o", qint_from_int(7)); - qdict_put(test_dict, "0.b", qint_from_int(23)); - qdict_put(test_dict, "2", qint_from_int(66)); + qdict_put_int(test_dict, "1.x", 0); + qdict_put_int(test_dict, "4.y", 1); + qdict_put_int(test_dict, "0.a", 42); + qdict_put_int(test_dict, "o.o", 7); + qdict_put_int(test_dict, "0.b", 23); + qdict_put_int(test_dict, "2", 66); qdict_array_split(test_dict, &test_list); @@ -441,9 +441,9 @@ static void qdict_array_split_test(void) test_dict = qdict_new(); - qdict_put(test_dict, "0", qint_from_int(42)); - qdict_put(test_dict, "1", qint_from_int(23)); - qdict_put(test_dict, "1.x", qint_from_int(84)); + qdict_put_int(test_dict, "0", 42); + qdict_put_int(test_dict, "1", 23); + qdict_put_int(test_dict, "1.x", 84); qdict_array_split(test_dict, &test_list); @@ -472,38 +472,38 @@ static void qdict_array_entries_test(void) g_assert_cmpint(qdict_array_entries(dict, "foo."), ==, 0); - qdict_put(dict, "bar", qint_from_int(0)); - qdict_put(dict, "baz.0", qint_from_int(0)); + qdict_put_int(dict, "bar", 0); + qdict_put_int(dict, "baz.0", 0); g_assert_cmpint(qdict_array_entries(dict, "foo."), ==, 0); - qdict_put(dict, "foo.1", qint_from_int(0)); + qdict_put_int(dict, "foo.1", 0); g_assert_cmpint(qdict_array_entries(dict, "foo."), ==, -EINVAL); - qdict_put(dict, "foo.0", qint_from_int(0)); + qdict_put_int(dict, "foo.0", 0); g_assert_cmpint(qdict_array_entries(dict, "foo."), ==, 2); - qdict_put(dict, "foo.bar", qint_from_int(0)); + qdict_put_int(dict, "foo.bar", 0); g_assert_cmpint(qdict_array_entries(dict, "foo."), ==, -EINVAL); qdict_del(dict, "foo.bar"); - qdict_put(dict, "foo.2.a", qint_from_int(0)); - qdict_put(dict, "foo.2.b", qint_from_int(0)); - qdict_put(dict, "foo.2.c", qint_from_int(0)); + qdict_put_int(dict, "foo.2.a", 0); + qdict_put_int(dict, "foo.2.b", 0); + qdict_put_int(dict, "foo.2.c", 0); g_assert_cmpint(qdict_array_entries(dict, "foo."), ==, 3); g_assert_cmpint(qdict_array_entries(dict, ""), ==, -EINVAL); QDECREF(dict); dict = qdict_new(); - qdict_put(dict, "1", qint_from_int(0)); + qdict_put_int(dict, "1", 0); g_assert_cmpint(qdict_array_entries(dict, ""), ==, -EINVAL); - qdict_put(dict, "0", qint_from_int(0)); + qdict_put_int(dict, "0", 0); g_assert_cmpint(qdict_array_entries(dict, ""), ==, 2); - qdict_put(dict, "bar", qint_from_int(0)); + qdict_put_int(dict, "bar", 0); g_assert_cmpint(qdict_array_entries(dict, ""), ==, -EINVAL); qdict_del(dict, "bar"); - qdict_put(dict, "2.a", qint_from_int(0)); - qdict_put(dict, "2.b", qint_from_int(0)); - qdict_put(dict, "2.c", qint_from_int(0)); + qdict_put_int(dict, "2.a", 0); + qdict_put_int(dict, "2.b", 0); + qdict_put_int(dict, "2.c", 0); g_assert_cmpint(qdict_array_entries(dict, ""), ==, 3); QDECREF(dict); @@ -529,7 +529,7 @@ static void qdict_join_test(void) /* First iteration: Test movement */ /* Second iteration: Test empty source and non-empty destination */ - qdict_put(dict2, "foo", qint_from_int(42)); + qdict_put_int(dict2, "foo", 42); for (i = 0; i < 2; i++) { qdict_join(dict1, dict2, overwrite); @@ -541,7 +541,7 @@ static void qdict_join_test(void) } /* Test non-empty source and destination without conflict */ - qdict_put(dict2, "bar", qint_from_int(23)); + qdict_put_int(dict2, "bar", 23); qdict_join(dict1, dict2, overwrite); @@ -552,7 +552,7 @@ static void qdict_join_test(void) g_assert(qdict_get_int(dict1, "bar") == 23); /* Test conflict */ - qdict_put(dict2, "foo", qint_from_int(84)); + qdict_put_int(dict2, "foo", 84); qdict_join(dict1, dict2, overwrite); @@ -594,15 +594,15 @@ static void qdict_crumple_test_recursive(void) QList *rules; src = qdict_new(); - qdict_put(src, "vnc.listen.addr", qstring_from_str("127.0.0.1")); - qdict_put(src, "vnc.listen.port", qstring_from_str("5901")); - qdict_put(src, "vnc.acl.rules.0.match", qstring_from_str("fred")); - qdict_put(src, "vnc.acl.rules.0.policy", qstring_from_str("allow")); - qdict_put(src, "vnc.acl.rules.1.match", qstring_from_str("bob")); - qdict_put(src, "vnc.acl.rules.1.policy", qstring_from_str("deny")); - qdict_put(src, "vnc.acl.default", qstring_from_str("deny")); - qdict_put(src, "vnc.acl..name", qstring_from_str("acl0")); - qdict_put(src, "vnc.acl.rule..name", qstring_from_str("acl0")); + qdict_put_str(src, "vnc.listen.addr", "127.0.0.1"); + qdict_put_str(src, "vnc.listen.port", "5901"); + qdict_put_str(src, "vnc.acl.rules.0.match", "fred"); + qdict_put_str(src, "vnc.acl.rules.0.policy", "allow"); + qdict_put_str(src, "vnc.acl.rules.1.match", "bob"); + qdict_put_str(src, "vnc.acl.rules.1.policy", "deny"); + qdict_put_str(src, "vnc.acl.default", "deny"); + qdict_put_str(src, "vnc.acl..name", "acl0"); + qdict_put_str(src, "vnc.acl.rule..name", "acl0"); dst = qobject_to_qdict(qdict_crumple(src, &error_abort)); g_assert(dst); @@ -669,8 +669,8 @@ static void qdict_crumple_test_bad_inputs(void) src = qdict_new(); /* rule.0 can't be both a string and a dict */ - qdict_put(src, "rule.0", qstring_from_str("fred")); - qdict_put(src, "rule.0.policy", qstring_from_str("allow")); + qdict_put_str(src, "rule.0", "fred"); + qdict_put_str(src, "rule.0.policy", "allow"); g_assert(qdict_crumple(src, &error) == NULL); g_assert(error != NULL); @@ -680,8 +680,8 @@ static void qdict_crumple_test_bad_inputs(void) src = qdict_new(); /* rule can't be both a list and a dict */ - qdict_put(src, "rule.0", qstring_from_str("fred")); - qdict_put(src, "rule.a", qstring_from_str("allow")); + qdict_put_str(src, "rule.0", "fred"); + qdict_put_str(src, "rule.a", "allow"); g_assert(qdict_crumple(src, &error) == NULL); g_assert(error != NULL); @@ -692,7 +692,7 @@ static void qdict_crumple_test_bad_inputs(void) src = qdict_new(); /* The input should be flat, ie no dicts or lists */ qdict_put(src, "rule.a", qdict_new()); - qdict_put(src, "rule.b", qstring_from_str("allow")); + qdict_put_str(src, "rule.b", "allow"); g_assert(qdict_crumple(src, &error) == NULL); g_assert(error != NULL); @@ -702,8 +702,8 @@ static void qdict_crumple_test_bad_inputs(void) src = qdict_new(); /* List indexes must not have gaps */ - qdict_put(src, "rule.0", qstring_from_str("deny")); - qdict_put(src, "rule.3", qstring_from_str("allow")); + qdict_put_str(src, "rule.0", "deny"); + qdict_put_str(src, "rule.3", "allow"); g_assert(qdict_crumple(src, &error) == NULL); g_assert(error != NULL); @@ -713,8 +713,8 @@ static void qdict_crumple_test_bad_inputs(void) src = qdict_new(); /* List indexes must be in %zu format */ - qdict_put(src, "rule.0", qstring_from_str("deny")); - qdict_put(src, "rule.+1", qstring_from_str("allow")); + qdict_put_str(src, "rule.0", "deny"); + qdict_put_str(src, "rule.+1", "allow"); g_assert(qdict_crumple(src, &error) == NULL); g_assert(error != NULL); @@ -733,8 +733,8 @@ static void qdict_put_exists_test(void) const char *key = "exists"; QDict *tests_dict = qdict_new(); - qdict_put(tests_dict, key, qint_from_int(1)); - qdict_put(tests_dict, key, qint_from_int(2)); + qdict_put_int(tests_dict, key, 1); + qdict_put_int(tests_dict, key, 2); value = qdict_get_int(tests_dict, key); g_assert(value == 2); diff --git a/tests/check-qlist.c b/tests/check-qlist.c index e16da5e..4983867 100644 --- a/tests/check-qlist.c +++ b/tests/check-qlist.c @@ -74,7 +74,7 @@ static void qlist_destroy_test(void) qlist = qlist_new(); for (i = 0; i < 42; i++) - qlist_append(qlist, qint_from_int(i)); + qlist_append_int(qlist, i); QDECREF(qlist); } @@ -103,7 +103,7 @@ static void qlist_iter_test(void) qlist = qlist_new(); for (i = 0; i < iter_max; i++) - qlist_append(qlist, qint_from_int(i)); + qlist_append_int(qlist, i); iter_called = 0; qlist_iter(qlist, iter_func, NULL); diff --git a/tests/device-introspect-test.c b/tests/device-introspect-test.c index c5637cc..b1abb2a 100644 --- a/tests/device-introspect-test.c +++ b/tests/device-introspect-test.c @@ -32,9 +32,9 @@ static QList *qom_list_types(const char *implements, bool abstract) QList *ret; QDict *args = qdict_new(); - qdict_put(args, "abstract", qbool_from_bool(abstract)); + qdict_put_bool(args, "abstract", abstract); if (implements) { - qdict_put(args, "implements", qstring_from_str(implements)); + qdict_put_str(args, "implements", implements); } resp = qmp("{'execute': 'qom-list-types'," " 'arguments': %p }", args); diff --git a/tests/test-qemu-opts.c b/tests/test-qemu-opts.c index 0ad74b4..cc1bb1a 100644 --- a/tests/test-qemu-opts.c +++ b/tests/test-qemu-opts.c @@ -299,7 +299,7 @@ static void test_qemu_opt_get_size(void) dict = qdict_new(); g_assert(dict != NULL); - qdict_put(dict, "size1", qstring_from_str("10")); + qdict_put_str(dict, "size1", "10"); qemu_opts_absorb_qdict(opts, dict, &error_abort); g_assert(error_abort == NULL); @@ -309,7 +309,7 @@ static void test_qemu_opt_get_size(void) g_assert(opt == 10); /* reset value */ - qdict_put(dict, "size1", qstring_from_str("15")); + qdict_put_str(dict, "size1", "15"); qemu_opts_absorb_qdict(opts, dict, &error_abort); g_assert(error_abort == NULL); diff --git a/tests/test-qmp-commands.c b/tests/test-qmp-commands.c index ac3fd03..acdded4 100644 --- a/tests/test-qmp-commands.c +++ b/tests/test-qmp-commands.c @@ -94,7 +94,7 @@ static void test_dispatch_cmd(void) QDict *req = qdict_new(); QObject *resp; - qdict_put(req, "execute", qstring_from_str("user_def_cmd")); + qdict_put_str(req, "execute", "user_def_cmd"); resp = qmp_dispatch(&qmp_commands, QOBJECT(req)); assert(resp != NULL); @@ -111,7 +111,7 @@ static void test_dispatch_cmd_failure(void) QDict *args = qdict_new(); QObject *resp; - qdict_put(req, "execute", qstring_from_str("user_def_cmd2")); + qdict_put_str(req, "execute", "user_def_cmd2"); resp = qmp_dispatch(&qmp_commands, QOBJECT(req)); assert(resp != NULL); @@ -122,10 +122,10 @@ static void test_dispatch_cmd_failure(void) /* check that with extra arguments it throws an error */ req = qdict_new(); - qdict_put(args, "a", qint_from_int(66)); + qdict_put_int(args, "a", 66); qdict_put(req, "arguments", args); - qdict_put(req, "execute", qstring_from_str("user_def_cmd")); + qdict_put_str(req, "execute", "user_def_cmd"); resp = qmp_dispatch(&qmp_commands, QOBJECT(req)); assert(resp != NULL); @@ -164,14 +164,14 @@ static void test_dispatch_cmd_io(void) QDict *ret_dict_dict2, *ret_dict_dict2_userdef; QInt *ret3; - qdict_put(ud1a, "integer", qint_from_int(42)); - qdict_put(ud1a, "string", qstring_from_str("hello")); - qdict_put(ud1b, "integer", qint_from_int(422)); - qdict_put(ud1b, "string", qstring_from_str("hello2")); + qdict_put_int(ud1a, "integer", 42); + qdict_put_str(ud1a, "string", "hello"); + qdict_put_int(ud1b, "integer", 422); + qdict_put_str(ud1b, "string", "hello2"); qdict_put(args, "ud1a", ud1a); qdict_put(args, "ud1b", ud1b); qdict_put(req, "arguments", args); - qdict_put(req, "execute", qstring_from_str("user_def_cmd2")); + qdict_put_str(req, "execute", "user_def_cmd2"); ret = qobject_to_qdict(test_qmp_dispatch(req)); @@ -190,9 +190,9 @@ static void test_dispatch_cmd_io(void) assert(!strcmp(qdict_get_str(ret_dict_dict2, "string"), "blah4")); QDECREF(ret); - qdict_put(args3, "a", qint_from_int(66)); + qdict_put_int(args3, "a", 66); qdict_put(req, "arguments", args3); - qdict_put(req, "execute", qstring_from_str("guest-get-time")); + qdict_put_str(req, "execute", "guest-get-time"); ret3 = qobject_to_qint(test_qmp_dispatch(req)); assert(qint_get_int(ret3) == 66); @@ -244,7 +244,7 @@ static void test_dealloc_partial(void) Visitor *v; ud2_dict = qdict_new(); - qdict_put(ud2_dict, "string0", qstring_from_str(text)); + qdict_put_str(ud2_dict, "string0", text); v = qobject_input_visitor_new(QOBJECT(ud2_dict)); visit_type_UserDefTwo(v, NULL, &ud2, &err); diff --git a/tests/test-qmp-event.c b/tests/test-qmp-event.c index 7bb621b..4c0f096 100644 --- a/tests/test-qmp-event.c +++ b/tests/test-qmp-event.c @@ -153,7 +153,7 @@ static void test_event_a(TestEventData *data, { QDict *d; d = data->expect; - qdict_put(d, "event", qstring_from_str("EVENT_A")); + qdict_put_str(d, "event", "EVENT_A"); qapi_event_send_event_a(&error_abort); } @@ -162,7 +162,7 @@ static void test_event_b(TestEventData *data, { QDict *d; d = data->expect; - qdict_put(d, "event", qstring_from_str("EVENT_B")); + qdict_put_str(d, "event", "EVENT_B"); qapi_event_send_event_b(&error_abort); } @@ -177,16 +177,16 @@ static void test_event_c(TestEventData *data, b.has_enum1 = false; d_b = qdict_new(); - qdict_put(d_b, "integer", qint_from_int(2)); - qdict_put(d_b, "string", qstring_from_str("test1")); + qdict_put_int(d_b, "integer", 2); + qdict_put_str(d_b, "string", "test1"); d_data = qdict_new(); - qdict_put(d_data, "a", qint_from_int(1)); + qdict_put_int(d_data, "a", 1); qdict_put(d_data, "b", d_b); - qdict_put(d_data, "c", qstring_from_str("test2")); + qdict_put_str(d_data, "c", "test2"); d = data->expect; - qdict_put(d, "event", qstring_from_str("EVENT_C")); + qdict_put_str(d, "event", "EVENT_C"); qdict_put(d, "data", d_data); qapi_event_send_event_c(true, 1, true, &b, "test2", &error_abort); @@ -213,22 +213,22 @@ static void test_event_d(TestEventData *data, a.enum2 = ENUM_ONE_VALUE2; d_struct1 = qdict_new(); - qdict_put(d_struct1, "integer", qint_from_int(2)); - qdict_put(d_struct1, "string", qstring_from_str("test1")); - qdict_put(d_struct1, "enum1", qstring_from_str("value1")); + qdict_put_int(d_struct1, "integer", 2); + qdict_put_str(d_struct1, "string", "test1"); + qdict_put_str(d_struct1, "enum1", "value1"); d_a = qdict_new(); qdict_put(d_a, "struct1", d_struct1); - qdict_put(d_a, "string", qstring_from_str("test2")); - qdict_put(d_a, "enum2", qstring_from_str("value2")); + qdict_put_str(d_a, "string", "test2"); + qdict_put_str(d_a, "enum2", "value2"); d_data = qdict_new(); qdict_put(d_data, "a", d_a); - qdict_put(d_data, "b", qstring_from_str("test3")); - qdict_put(d_data, "enum3", qstring_from_str("value3")); + qdict_put_str(d_data, "b", "test3"); + qdict_put_str(d_data, "enum3", "value3"); d = data->expect; - qdict_put(d, "event", qstring_from_str("EVENT_D")); + qdict_put_str(d, "event", "EVENT_D"); qdict_put(d, "data", d_data); qapi_event_send_event_d(&a, "test3", false, NULL, true, ENUM_ONE_VALUE3, diff --git a/tests/test-qobject-output-visitor.c b/tests/test-qobject-output-visitor.c index c213fce..94b9518 100644 --- a/tests/test-qobject-output-visitor.c +++ b/tests/test-qobject-output-visitor.c @@ -343,9 +343,9 @@ static void test_visitor_out_any(TestOutputVisitorData *data, visitor_reset(data); qdict = qdict_new(); - qdict_put(qdict, "integer", qint_from_int(-42)); - qdict_put(qdict, "boolean", qbool_from_bool(true)); - qdict_put(qdict, "string", qstring_from_str("foo")); + qdict_put_int(qdict, "integer", -42); + qdict_put_bool(qdict, "boolean", true); + qdict_put_str(qdict, "string", "foo"); qobj = QOBJECT(qdict); visit_type_any(data->ov, NULL, &qobj, &error_abort); qobject_decref(qobj); diff --git a/util/qemu-option.c b/util/qemu-option.c index 5ce1b5c..a36cafa 100644 --- a/util/qemu-option.c +++ b/util/qemu-option.c @@ -1060,7 +1060,7 @@ QDict *qemu_opts_to_qdict(QemuOpts *opts, QDict *qdict) qdict = qdict_new(); } if (opts->id) { - qdict_put(qdict, "id", qstring_from_str(opts->id)); + qdict_put_str(qdict, "id", opts->id); } QTAILQ_FOREACH(opt, &opts->head, next) { val = QOBJECT(qstring_from_str(opt->str)); From patchwork Tue Aug 29 00:13:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806817 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh8W86y2wz9s65 for ; Tue, 29 Aug 2017 10:23:32 +1000 (AEST) Received: from localhost ([::1]:41914 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUJW-0007VT-LS for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:23:30 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47528) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCC-0000v0-IA for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCA-0005Bf-ET for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:56 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:48696) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCA-0005Af-3t for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:54 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0E85d005466 for ; Mon, 28 Aug 2017 20:15:53 -0400 Received: from e12.ny.us.ibm.com (e12.ny.us.ibm.com [129.33.205.202]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmvjejk4c-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:15:52 -0400 Received: from localhost by e12.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 20:15:51 -0400 Received: from b01cxnp22033.gho.pok.ibm.com (9.57.198.23) by e12.ny.us.ibm.com (146.89.104.199) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 20:15:49 -0400 Received: from b01ledav001.gho.pok.ibm.com (b01ledav001.gho.pok.ibm.com [9.57.199.106]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0FmuQ24182974; Tue, 29 Aug 2017 00:15:48 GMT Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 025E92803E; Mon, 28 Aug 2017 20:15:42 -0400 (EDT) Received: from localhost (unknown [9.80.85.217]) by b01ledav001.gho.pok.ibm.com (Postfix) with ESMTP id BE47C2803F; Mon, 28 Aug 2017 20:15:41 -0400 (EDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:13:54 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0048-0000-0000-000001DAEA2F X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:15:50 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0049-0000-0000-000042619399 Message-Id: <1503965694-10794-20-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 19/79] block: Reuse bs as backing hd for drive-backup sync=none 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 , Fam Zheng , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Fam Zheng Opening the backing image for the second time is bad, especially here when it is also in use as the active image as the source. The drive-backup job itself doesn't read from target->backing for COW, instead it gets data from the write notifier, so it's not a big problem. However, exporting the target to NBD etc. won't work, because of the likely stale metadata cache. Use BDRV_O_NO_BACKING in this case and manually set up the backing BdrvChild. Cc: qemu-stable@nongnu.org Signed-off-by: Fam Zheng Signed-off-by: Kevin Wolf (cherry picked from commit fc0932fdcfc3e5cafa3641e361b681c07f639812) Signed-off-by: Michael Roth --- blockdev.c | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/blockdev.c b/blockdev.c index e2f9c1e..841200e 100644 --- a/blockdev.c +++ b/blockdev.c @@ -3170,6 +3170,7 @@ static BlockJob *do_drive_backup(DriveBackup *backup, BlockJobTxn *txn, Error *local_err = NULL; int flags; int64_t size; + bool set_backing_hd = false; if (!backup->has_speed) { backup->speed = 0; @@ -3220,6 +3221,8 @@ static BlockJob *do_drive_backup(DriveBackup *backup, BlockJobTxn *txn, } if (backup->sync == MIRROR_SYNC_MODE_NONE) { source = bs; + flags |= BDRV_O_NO_BACKING; + set_backing_hd = true; } size = bdrv_getlength(bs); @@ -3246,7 +3249,9 @@ static BlockJob *do_drive_backup(DriveBackup *backup, BlockJobTxn *txn, } if (backup->format) { - options = qdict_new(); + if (!options) { + options = qdict_new(); + } qdict_put_str(options, "driver", backup->format); } @@ -3257,6 +3262,14 @@ static BlockJob *do_drive_backup(DriveBackup *backup, BlockJobTxn *txn, bdrv_set_aio_context(target_bs, aio_context); + if (set_backing_hd) { + bdrv_set_backing_hd(target_bs, source, &local_err); + if (local_err) { + bdrv_unref(target_bs); + goto out; + } + } + if (backup->has_bitmap) { bmap = bdrv_find_dirty_bitmap(bs, backup->bitmap); if (!bmap) { From patchwork Tue Aug 29 00:13:55 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806821 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh8ZR0FJsz9s65 for ; Tue, 29 Aug 2017 10:26:23 +1000 (AEST) Received: from localhost ([::1]:41933 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUMG-0001tH-QJ for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:26:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47548) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCD-0000vn-EE for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCA-0005BN-9N for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:57 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:60778 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUC9-0005Aq-UW for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:54 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0E7Lh043811 for ; Mon, 28 Aug 2017 20:15:53 -0400 Received: from e14.ny.us.ibm.com (e14.ny.us.ibm.com [129.33.205.204]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmu3kpdwp-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:15:53 -0400 Received: from localhost by e14.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 20:15:52 -0400 Received: from b01cxnp22033.gho.pok.ibm.com (9.57.198.23) by e14.ny.us.ibm.com (146.89.104.201) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 20:15:49 -0400 Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0FnZa24182982; Tue, 29 Aug 2017 00:15:49 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 473D4124047; Mon, 28 Aug 2017 20:13:09 -0400 (EDT) Received: from localhost (unknown [9.80.85.217]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTP id 1918E124035; Mon, 28 Aug 2017 20:13:09 -0400 (EDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:13:55 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 17082900-0052-0000-0000-00000257332A X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:15:51 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0053-0000-0000-000051D1D91D Message-Id: <1503965694-10794-21-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-MIME-Autoconverted: from 8bit to quoted-printable by mx0a-001b2d01.pphosted.com id v7T0E7Lh043811 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 20/79] hw/virtio: fix vhost user fails to startup when MQ 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: Zhiyong Yang , qemu-stable@nongnu.org, "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Zhiyong Yang Qemu2.7~2.9 and vhost user for dpdk 17.02 release work together to cause failures of new connection when negotiating to set MQ. (one queue pair works well). Because there exist some bugs in qemu code when introducing VHOST_USER_PROTOCOL_F_REPLY_ACK to qemu. When vhost_user_set_mem_table is invoked to deal with the vhost message VHOST_USER_SET_MEM_TABLE for the second time, qemu indeed doesn't send the messge (The message needs to be sent only once)but still will be waiting for dpdk's reply ack, then, qemu is always freezing, while DPDK is always waiting for next vhost message from qemu. The patch aims to fix the bug, MQ can work well. The same bug is found in function vhost_user_net_set_mtu, it is fixed at the same time. DPDK related patch is as following: http://www.dpdk.org/dev/patchwork/patch/23955/ Signed-off-by: Zhiyong Yang Cc: qemu-stable@nongnu.org Fixes: ca525ce5618b ("vhost-user: Introduce a new protocol feature REPLY_ACK.") Reviewed-by: Maxime Coquelin Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Tested-by: Jens Freimann Reviewed-by: Marc-André Lureau (cherry picked from commit 60cd11024f41cc73175e651a2dfe09a3cade56bb) Signed-off-by: Michael Roth --- hw/virtio/vhost-user.c | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/hw/virtio/vhost-user.c b/hw/virtio/vhost-user.c index 9334a8a..32a95a8c 100644 --- a/hw/virtio/vhost-user.c +++ b/hw/virtio/vhost-user.c @@ -163,22 +163,26 @@ fail: } static int process_message_reply(struct vhost_dev *dev, - VhostUserRequest request) + VhostUserMsg msg) { - VhostUserMsg msg; + VhostUserMsg msg_reply; - if (vhost_user_read(dev, &msg) < 0) { + if ((msg.flags & VHOST_USER_NEED_REPLY_MASK) == 0) { + return 0; + } + + if (vhost_user_read(dev, &msg_reply) < 0) { return -1; } - if (msg.request != request) { + if (msg_reply.request != msg.request) { error_report("Received unexpected msg type." "Expected %d received %d", - request, msg.request); + msg.request, msg_reply.request); return -1; } - return msg.payload.u64 ? -1 : 0; + return msg_reply.payload.u64 ? -1 : 0; } static bool vhost_user_one_time_request(VhostUserRequest request) @@ -208,6 +212,7 @@ static int vhost_user_write(struct vhost_dev *dev, VhostUserMsg *msg, * request, we just ignore it. */ if (vhost_user_one_time_request(msg->request) && dev->vq_index != 0) { + msg->flags &= ~VHOST_USER_NEED_REPLY_MASK; return 0; } @@ -320,7 +325,7 @@ static int vhost_user_set_mem_table(struct vhost_dev *dev, } if (reply_supported) { - return process_message_reply(dev, msg.request); + return process_message_reply(dev, msg); } return 0; @@ -712,7 +717,7 @@ static int vhost_user_net_set_mtu(struct vhost_dev *dev, uint16_t mtu) /* If reply_ack supported, slave has to ack specified MTU is valid */ if (reply_supported) { - return process_message_reply(dev, msg.request); + return process_message_reply(dev, msg); } return 0; From patchwork Tue Aug 29 00:13:56 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806827 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh8gR0mLyz9s65 for ; Tue, 29 Aug 2017 10:30:43 +1000 (AEST) Received: from localhost ([::1]:41963 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUQS-0005xK-Ue for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:30:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47575) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCE-0000wx-9Q for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:59 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCB-0005C4-21 for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:58 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:52595 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCA-0005Bu-Rt for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:54 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0E9gd081527 for ; Mon, 28 Aug 2017 20:15:54 -0400 Received: from e11.ny.us.ibm.com (e11.ny.us.ibm.com [129.33.205.201]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmurncr8y-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:15:54 -0400 Received: from localhost by e11.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 20:15:53 -0400 Received: from b01cxnp22034.gho.pok.ibm.com (9.57.198.24) by e11.ny.us.ibm.com (146.89.104.198) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 20:15:51 -0400 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0FoFS22544428; Tue, 29 Aug 2017 00:15:50 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C37A1112054; Mon, 28 Aug 2017 20:15:36 -0400 (EDT) Received: from localhost (unknown [9.80.85.217]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP id 9080A112051; Mon, 28 Aug 2017 20:15:36 -0400 (EDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:13:56 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-2213-0000-0000-00000210D341 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909027; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:15:52 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-2214-0000-0000-0000575DECBF Message-Id: <1503965694-10794-22-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 21/79] aio: add missing aio_notify() to aio_enable_external() 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: qemu-stable@nongnu.org, Stefan Hajnoczi Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Stefan Hajnoczi The main loop uses aio_disable_external()/aio_enable_external() to temporarily disable processing of external AioContext clients like device emulation. This allows monitor commands to quiesce I/O and prevent the guest from submitting new requests while a monitor command is in progress. The aio_enable_external() API is currently broken when an IOThread is in aio_poll() waiting for fd activity when the main loop re-enables external clients. Incrementing ctx->external_disable_cnt does not wake the IOThread from ppoll(2) so fd processing remains suspended and leads to unresponsive emulated devices. This patch adds an aio_notify() call to aio_enable_external() so the IOThread is kicked out of ppoll(2) and will re-arm the file descriptors. The bug can be reproduced as follows: $ qemu -M accel=kvm -m 1024 \ -object iothread,id=iothread0 \ -device virtio-scsi-pci,iothread=iothread0,id=virtio-scsi-pci0 \ -drive if=none,id=drive0,aio=native,cache=none,format=raw,file=test.img \ -device scsi-hd,id=scsi-hd0,drive=drive0 \ -qmp tcp::5555,server,nowait $ scripts/qmp/qmp-shell localhost:5555 (qemu) blockdev-snapshot-sync device=drive0 snapshot-file=sn1.qcow2 mode=absolute-paths format=qcow2 After blockdev-snapshot-sync completes the SCSI disk will be unresponsive. This leads to request timeouts inside the guest. Reported-by: Qianqian Zhu Reviewed-by: Fam Zheng Signed-off-by: Stefan Hajnoczi Message-id: 20170508180705.20609-1-stefanha@redhat.com Suggested-by: Fam Zheng Signed-off-by: Stefan Hajnoczi (cherry picked from commit 321d1dba8bef9676a77e9399484e3cd8bf2cf16a) Signed-off-by: Michael Roth --- include/block/aio.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/include/block/aio.h b/include/block/aio.h index 406e323..e9aeeae 100644 --- a/include/block/aio.h +++ b/include/block/aio.h @@ -454,8 +454,14 @@ static inline void aio_disable_external(AioContext *ctx) */ static inline void aio_enable_external(AioContext *ctx) { - assert(ctx->external_disable_cnt > 0); - atomic_dec(&ctx->external_disable_cnt); + int old; + + old = atomic_fetch_dec(&ctx->external_disable_cnt); + assert(old > 0); + if (old == 1) { + /* Kick event loop so it re-arms file descriptors */ + aio_notify(ctx); + } } /** From patchwork Tue Aug 29 00:13:57 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806823 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh8c21r9Wz9s65 for ; Tue, 29 Aug 2017 10:27:46 +1000 (AEST) Received: from localhost ([::1]:41940 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUNc-000346-3P for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:27:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47628) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCF-0000yq-L7 for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCC-0005DU-M7 for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:59 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:51083) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCC-0005Ca-BQ for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:56 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0Eesg078680 for ; Mon, 28 Aug 2017 20:15:55 -0400 Received: from e15.ny.us.ibm.com (e15.ny.us.ibm.com [129.33.205.205]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmnx0yuma-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:15:55 -0400 Received: from localhost by e15.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 20:15:53 -0400 Received: from b01cxnp23034.gho.pok.ibm.com (9.57.198.29) by e15.ny.us.ibm.com (146.89.104.202) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 20:15:51 -0400 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0FphI25362440; Tue, 29 Aug 2017 00:15:51 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C3349AE043; Mon, 28 Aug 2017 20:16:14 -0400 (EDT) Received: from localhost (unknown [9.80.85.217]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTP id 8BBB3AE057; Mon, 28 Aug 2017 20:16:14 -0400 (EDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:13:57 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0036-0000-0000-000002603F49 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909027; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:15:52 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0037-0000-0000-000041964A31 Message-Id: <1503965694-10794-23-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 22/79] qemu-img: wait for convert coroutines to complete 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 , Anton Nefedov , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Anton Nefedov On error path (like i/o error in one of the coroutines), it's required to - wait for coroutines completion before cleaning the common structures - reenter dependent coroutines so they ever finish Introduced in 2d9187bc65. Cc: qemu-stable@nongnu.org Signed-off-by: Anton Nefedov Reviewed-by: Peter Lieven Signed-off-by: Kevin Wolf (cherry picked from commit b91127edd0ff96f27f1e58e47f4e9f9d6a0fed02) Signed-off-by: Michael Roth --- qemu-img.c | 26 +++++++++++--------------- 1 file changed, 11 insertions(+), 15 deletions(-) diff --git a/qemu-img.c b/qemu-img.c index 2e61561..26ded22 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -1761,13 +1761,13 @@ static void coroutine_fn convert_co_do_copy(void *opaque) qemu_co_mutex_lock(&s->lock); if (s->ret != -EINPROGRESS || s->sector_num >= s->total_sectors) { qemu_co_mutex_unlock(&s->lock); - goto out; + break; } n = convert_iteration_sectors(s, s->sector_num); if (n < 0) { qemu_co_mutex_unlock(&s->lock); s->ret = n; - goto out; + break; } /* save current sector and allocation status to local variables */ sector_num = s->sector_num; @@ -1792,7 +1792,6 @@ static void coroutine_fn convert_co_do_copy(void *opaque) error_report("error while reading sector %" PRId64 ": %s", sector_num, strerror(-ret)); s->ret = ret; - goto out; } } else if (!s->min_sparse && status == BLK_ZERO) { status = BLK_DATA; @@ -1801,22 +1800,20 @@ static void coroutine_fn convert_co_do_copy(void *opaque) if (s->wr_in_order) { /* keep writes in order */ - while (s->wr_offs != sector_num) { - if (s->ret != -EINPROGRESS) { - goto out; - } + while (s->wr_offs != sector_num && s->ret == -EINPROGRESS) { s->wait_sector_num[index] = sector_num; qemu_coroutine_yield(); } s->wait_sector_num[index] = -1; } - ret = convert_co_write(s, sector_num, n, buf, status); - if (ret < 0) { - error_report("error while writing sector %" PRId64 - ": %s", sector_num, strerror(-ret)); - s->ret = ret; - goto out; + if (s->ret == -EINPROGRESS) { + ret = convert_co_write(s, sector_num, n, buf, status); + if (ret < 0) { + error_report("error while writing sector %" PRId64 + ": %s", sector_num, strerror(-ret)); + s->ret = ret; + } } if (s->wr_in_order) { @@ -1837,7 +1834,6 @@ static void coroutine_fn convert_co_do_copy(void *opaque) } } -out: qemu_vfree(buf); s->co[index] = NULL; s->running_coroutines--; @@ -1899,7 +1895,7 @@ static int convert_do_copy(ImgConvertState *s) qemu_coroutine_enter(s->co[i]); } - while (s->ret == -EINPROGRESS) { + while (s->running_coroutines) { main_loop_wait(false); } From patchwork Tue Aug 29 00:13:58 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806814 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh8SH5zsrz9sP5 for ; Tue, 29 Aug 2017 10:20:59 +1000 (AEST) Received: from localhost ([::1]:41902 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUH1-00059C-LP for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:20:55 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47641) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCF-0000zH-U5 for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:01 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCC-0005DX-KZ for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:59 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:54429 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCC-0005Cq-DT for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:56 -0400 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0EUPG087789 for ; Mon, 28 Aug 2017 20:15:56 -0400 Received: from e18.ny.us.ibm.com (e18.ny.us.ibm.com [129.33.205.208]) by mx0b-001b2d01.pphosted.com with ESMTP id 2cmvhgaqrq-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:15:55 -0400 Received: from localhost by e18.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 20:15:53 -0400 Received: from b01cxnp22033.gho.pok.ibm.com (9.57.198.23) by e18.ny.us.ibm.com (146.89.104.205) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 20:15:52 -0400 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0FpnK23920732; Tue, 29 Aug 2017 00:15:51 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id EDE8AAC03F; Mon, 28 Aug 2017 20:16:15 -0400 (EDT) Received: from localhost (unknown [9.80.85.217]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP id BCA07AC043; Mon, 28 Aug 2017 20:16:15 -0400 (EDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:13:58 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0044-0000-0000-000003847046 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:15:53 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0045-0000-0000-000007B288B9 Message-Id: <1503965694-10794-24-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 23/79] block/vhdx: Make vhdx_create() always set errp 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: qemu-stable@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Max Reitz This patch makes vhdx_create() always set errp in case of an error. It also adds errp parameters to vhdx_create_bat() and vhdx_create_new_region_table() so we can pass on the error object generated by blk_truncate() as of a future commit. Signed-off-by: Max Reitz Reviewed-by: Kevin Wolf Message-id: 20170328205129.15138-2-mreitz@redhat.com Reviewed-by: Stefan Hajnoczi Signed-off-by: Max Reitz (cherry picked from commit 55b9392b98e500399f2da1edc1d110bbfd40fb05) * prereq for 698bdfa Signed-off-by: Michael Roth --- block/vhdx.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/block/vhdx.c b/block/vhdx.c index 052a753..d25bcd9 100644 --- a/block/vhdx.c +++ b/block/vhdx.c @@ -1586,7 +1586,7 @@ exit: static int vhdx_create_bat(BlockBackend *blk, BDRVVHDXState *s, uint64_t image_size, VHDXImageType type, bool use_zero_blocks, uint64_t file_offset, - uint32_t length) + uint32_t length, Error **errp) { int ret = 0; uint64_t data_file_offset; @@ -1609,14 +1609,19 @@ static int vhdx_create_bat(BlockBackend *blk, BDRVVHDXState *s, * is the furthest thing we have written yet */ ret = blk_truncate(blk, data_file_offset); if (ret < 0) { + error_setg_errno(errp, -ret, + "Failed to resize the underlying file"); goto exit; } } else if (type == VHDX_TYPE_FIXED) { ret = blk_truncate(blk, data_file_offset + image_size); if (ret < 0) { + error_setg_errno(errp, -ret, + "Failed to resize the underlying file"); goto exit; } } else { + error_setg(errp, "Unsupported image type"); ret = -ENOTSUP; goto exit; } @@ -1627,6 +1632,7 @@ static int vhdx_create_bat(BlockBackend *blk, BDRVVHDXState *s, /* for a fixed file, the default BAT entry is not zero */ s->bat = g_try_malloc0(length); if (length && s->bat == NULL) { + error_setg(errp, "Failed to allocate memory for the BAT"); ret = -ENOMEM; goto exit; } @@ -1646,6 +1652,7 @@ static int vhdx_create_bat(BlockBackend *blk, BDRVVHDXState *s, } ret = blk_pwrite(blk, file_offset, s->bat, length, 0); if (ret < 0) { + error_setg_errno(errp, -ret, "Failed to write the BAT"); goto exit; } } @@ -1671,7 +1678,8 @@ static int vhdx_create_new_region_table(BlockBackend *blk, uint32_t log_size, bool use_zero_blocks, VHDXImageType type, - uint64_t *metadata_offset) + uint64_t *metadata_offset, + Error **errp) { int ret = 0; uint32_t offset = 0; @@ -1740,7 +1748,7 @@ static int vhdx_create_new_region_table(BlockBackend *blk, /* The region table gives us the data we need to create the BAT, * so do that now */ ret = vhdx_create_bat(blk, s, image_size, type, use_zero_blocks, - bat_file_offset, bat_length); + bat_file_offset, bat_length, errp); if (ret < 0) { goto exit; } @@ -1749,12 +1757,14 @@ static int vhdx_create_new_region_table(BlockBackend *blk, ret = blk_pwrite(blk, VHDX_REGION_TABLE_OFFSET, buffer, VHDX_HEADER_BLOCK_SIZE, 0); if (ret < 0) { + error_setg_errno(errp, -ret, "Failed to write first region table"); goto exit; } ret = blk_pwrite(blk, VHDX_REGION_TABLE2_OFFSET, buffer, VHDX_HEADER_BLOCK_SIZE, 0); if (ret < 0) { + error_setg_errno(errp, -ret, "Failed to write second region table"); goto exit; } @@ -1825,6 +1835,7 @@ static int vhdx_create(const char *filename, QemuOpts *opts, Error **errp) ret = -ENOTSUP; goto exit; } else { + error_setg(errp, "Invalid subformat '%s'", type); ret = -EINVAL; goto exit; } @@ -1879,12 +1890,14 @@ static int vhdx_create(const char *filename, QemuOpts *opts, Error **errp) ret = blk_pwrite(blk, VHDX_FILE_ID_OFFSET, &signature, sizeof(signature), 0); if (ret < 0) { + error_setg_errno(errp, -ret, "Failed to write file signature"); goto delete_and_exit; } if (creator) { ret = blk_pwrite(blk, VHDX_FILE_ID_OFFSET + sizeof(signature), creator, creator_items * sizeof(gunichar2), 0); if (ret < 0) { + error_setg_errno(errp, -ret, "Failed to write creator field"); goto delete_and_exit; } } @@ -1893,13 +1906,14 @@ static int vhdx_create(const char *filename, QemuOpts *opts, Error **errp) /* Creates (B),(C) */ ret = vhdx_create_new_headers(blk, image_size, log_size); if (ret < 0) { + error_setg_errno(errp, -ret, "Failed to write image headers"); goto delete_and_exit; } /* Creates (D),(E),(G) explicitly. (F) created as by-product */ ret = vhdx_create_new_region_table(blk, image_size, block_size, 512, log_size, use_zero_blocks, image_type, - &metadata_offset); + &metadata_offset, errp); if (ret < 0) { goto delete_and_exit; } @@ -1908,6 +1922,7 @@ static int vhdx_create(const char *filename, QemuOpts *opts, Error **errp) ret = vhdx_create_new_metadata(blk, image_size, block_size, 512, metadata_offset, image_type); if (ret < 0) { + error_setg_errno(errp, -ret, "Failed to initialize metadata"); goto delete_and_exit; } From patchwork Tue Aug 29 00:13:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806830 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh8jv1Hwkz9sNr for ; Tue, 29 Aug 2017 10:32:51 +1000 (AEST) Received: from localhost ([::1]:41972 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUSX-0007hc-1u for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:32:49 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47651) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCG-0000zo-6S for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:04 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCC-0005Dj-PF for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:00 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:37928) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCC-0005CX-Ak for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:56 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0EA1N090193 for ; Mon, 28 Aug 2017 20:15:55 -0400 Received: from e38.co.us.ibm.com (e38.co.us.ibm.com [32.97.110.159]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmvyehk6t-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:15:55 -0400 Received: from localhost by e38.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 18:15:54 -0600 Received: from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e38.co.us.ibm.com (192.168.1.138) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 18:15:53 -0600 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0Fqfi32178208; Mon, 28 Aug 2017 17:15:52 -0700 Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BA8246E040; Mon, 28 Aug 2017 18:15:52 -0600 (MDT) Received: from localhost (unknown [9.80.85.217]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP id 794B96E041; Mon, 28 Aug 2017 18:15:52 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:13:59 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0028-0000-0000-00000846DB25 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:15:54 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0029-0000-0000-000037553118 Message-Id: <1503965694-10794-25-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 24/79] block: Add errp to b{lk, drv}_truncate() 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: qemu-stable@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Max Reitz For one thing, this allows us to drop the error message generation from qemu-img.c and blockdev.c and instead have it unified in bdrv_truncate(). Signed-off-by: Max Reitz Message-id: 20170328205129.15138-3-mreitz@redhat.com Reviewed-by: Stefan Hajnoczi Signed-off-by: Max Reitz (cherry picked from commit ed3d2ec98a33fbdeabc471b11ff807075f07e996) * prereq for 698bdfa Signed-off-by: Michael Roth --- block.c | 16 ++++++++++++---- block/blkdebug.c | 2 +- block/block-backend.c | 5 +++-- block/commit.c | 5 +++-- block/crypto.c | 2 +- block/mirror.c | 2 +- block/parallels.c | 13 ++++++++----- block/qcow.c | 6 +++--- block/qcow2-refcount.c | 5 ++++- block/qcow2.c | 14 +++++++++----- block/qed.c | 2 +- block/raw-format.c | 2 +- block/vdi.c | 4 ++-- block/vhdx-log.c | 2 +- block/vhdx.c | 6 +++--- block/vmdk.c | 13 +++---------- block/vpc.c | 13 +++++++------ blockdev.c | 21 +-------------------- include/block/block.h | 2 +- include/sysemu/block-backend.h | 2 +- qemu-img.c | 17 ++++------------- qemu-io-cmds.c | 5 +++-- 22 files changed, 73 insertions(+), 86 deletions(-) diff --git a/block.c b/block.c index 513e6e5..21cb65e 100644 --- a/block.c +++ b/block.c @@ -3262,7 +3262,7 @@ exit: /** * Truncate file to 'offset' bytes (needed only for file protocols) */ -int bdrv_truncate(BdrvChild *child, int64_t offset) +int bdrv_truncate(BdrvChild *child, int64_t offset, Error **errp) { BlockDriverState *bs = child->bs; BlockDriver *drv = bs->drv; @@ -3274,12 +3274,18 @@ int bdrv_truncate(BdrvChild *child, int64_t offset) * cannot assert this permission in that case. */ // assert(child->perm & BLK_PERM_RESIZE); - if (!drv) + if (!drv) { + error_setg(errp, "No medium inserted"); return -ENOMEDIUM; - if (!drv->bdrv_truncate) + } + if (!drv->bdrv_truncate) { + error_setg(errp, "Image format driver does not support resize"); return -ENOTSUP; - if (bs->read_only) + } + if (bs->read_only) { + error_setg(errp, "Image is read-only"); return -EACCES; + } ret = drv->bdrv_truncate(bs, offset); if (ret == 0) { @@ -3287,6 +3293,8 @@ int bdrv_truncate(BdrvChild *child, int64_t offset) bdrv_dirty_bitmap_truncate(bs); bdrv_parent_cb_resize(bs); ++bs->write_gen; + } else { + error_setg_errno(errp, -ret, "Failed to resize image"); } return ret; } diff --git a/block/blkdebug.c b/block/blkdebug.c index ffc6f1d..46bd08a 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -661,7 +661,7 @@ static int64_t blkdebug_getlength(BlockDriverState *bs) static int blkdebug_truncate(BlockDriverState *bs, int64_t offset) { - return bdrv_truncate(bs->file, offset); + return bdrv_truncate(bs->file, offset, NULL); } static void blkdebug_refresh_filename(BlockDriverState *bs, QDict *options) diff --git a/block/block-backend.c b/block/block-backend.c index 7405024..1e70c4d 100644 --- a/block/block-backend.c +++ b/block/block-backend.c @@ -1746,13 +1746,14 @@ int blk_pwrite_compressed(BlockBackend *blk, int64_t offset, const void *buf, BDRV_REQ_WRITE_COMPRESSED); } -int blk_truncate(BlockBackend *blk, int64_t offset) +int blk_truncate(BlockBackend *blk, int64_t offset, Error **errp) { if (!blk_is_available(blk)) { + error_setg(errp, "No medium inserted"); return -ENOMEDIUM; } - return bdrv_truncate(blk->root, offset); + return bdrv_truncate(blk->root, offset, errp); } static void blk_pdiscard_entry(void *opaque) diff --git a/block/commit.c b/block/commit.c index 91d2c34..76a0d98 100644 --- a/block/commit.c +++ b/block/commit.c @@ -151,7 +151,7 @@ static void coroutine_fn commit_run(void *opaque) } if (base_len < s->common.len) { - ret = blk_truncate(s->base, s->common.len); + ret = blk_truncate(s->base, s->common.len, NULL); if (ret) { goto out; } @@ -511,8 +511,9 @@ int bdrv_commit(BlockDriverState *bs) * grow the backing file image if possible. If not possible, * we must return an error */ if (length > backing_length) { - ret = blk_truncate(backing, length); + ret = blk_truncate(backing, length, &local_err); if (ret < 0) { + error_report_err(local_err); goto ro_cleanup; } } diff --git a/block/crypto.c b/block/crypto.c index 4a20388..52e4f2b 100644 --- a/block/crypto.c +++ b/block/crypto.c @@ -389,7 +389,7 @@ static int block_crypto_truncate(BlockDriverState *bs, int64_t offset) offset += payload_offset; - return bdrv_truncate(bs->file, offset); + return bdrv_truncate(bs->file, offset, NULL); } static void block_crypto_close(BlockDriverState *bs) diff --git a/block/mirror.c b/block/mirror.c index 164438f..2173a2f 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -724,7 +724,7 @@ static void coroutine_fn mirror_run(void *opaque) } if (s->bdev_length > base_length) { - ret = blk_truncate(s->target, s->bdev_length); + ret = blk_truncate(s->target, s->bdev_length, NULL); if (ret < 0) { goto immediate_exit; } diff --git a/block/parallels.c b/block/parallels.c index 90acf79..8be46a7 100644 --- a/block/parallels.c +++ b/block/parallels.c @@ -223,7 +223,8 @@ static int64_t allocate_clusters(BlockDriverState *bs, int64_t sector_num, space << BDRV_SECTOR_BITS, 0); } else { ret = bdrv_truncate(bs->file, - (s->data_end + space) << BDRV_SECTOR_BITS); + (s->data_end + space) << BDRV_SECTOR_BITS, + NULL); } if (ret < 0) { return ret; @@ -456,8 +457,10 @@ static int parallels_check(BlockDriverState *bs, BdrvCheckResult *res, size - res->image_end_offset); res->leaks += count; if (fix & BDRV_FIX_LEAKS) { - ret = bdrv_truncate(bs->file, res->image_end_offset); + Error *local_err = NULL; + ret = bdrv_truncate(bs->file, res->image_end_offset, &local_err); if (ret < 0) { + error_report_err(local_err); res->check_errors++; return ret; } @@ -504,7 +507,7 @@ static int parallels_create(const char *filename, QemuOpts *opts, Error **errp) blk_set_allow_write_beyond_eof(file, true); - ret = blk_truncate(file, 0); + ret = blk_truncate(file, 0, errp); if (ret < 0) { goto exit; } @@ -696,7 +699,7 @@ static int parallels_open(BlockDriverState *bs, QDict *options, int flags, } if (!(flags & BDRV_O_RESIZE) || !bdrv_has_zero_init(bs->file->bs) || - bdrv_truncate(bs->file, bdrv_getlength(bs->file->bs)) != 0) { + bdrv_truncate(bs->file, bdrv_getlength(bs->file->bs), NULL) != 0) { s->prealloc_mode = PRL_PREALLOC_MODE_FALLOCATE; } @@ -739,7 +742,7 @@ static void parallels_close(BlockDriverState *bs) } if (bs->open_flags & BDRV_O_RDWR) { - bdrv_truncate(bs->file, s->data_end << BDRV_SECTOR_BITS); + bdrv_truncate(bs->file, s->data_end << BDRV_SECTOR_BITS, NULL); } g_free(s->bat_dirty_bmap); diff --git a/block/qcow.c b/block/qcow.c index 9d6ac83..5d147b9 100644 --- a/block/qcow.c +++ b/block/qcow.c @@ -473,7 +473,7 @@ static uint64_t get_cluster_offset(BlockDriverState *bs, /* round to cluster size */ cluster_offset = (cluster_offset + s->cluster_size - 1) & ~(s->cluster_size - 1); - bdrv_truncate(bs->file, cluster_offset + s->cluster_size); + bdrv_truncate(bs->file, cluster_offset + s->cluster_size, NULL); /* if encrypted, we must initialize the cluster content which won't be written */ if (bs->encrypted && @@ -833,7 +833,7 @@ static int qcow_create(const char *filename, QemuOpts *opts, Error **errp) blk_set_allow_write_beyond_eof(qcow_blk, true); - ret = blk_truncate(qcow_blk, 0); + ret = blk_truncate(qcow_blk, 0, errp); if (ret < 0) { goto exit; } @@ -916,7 +916,7 @@ static int qcow_make_empty(BlockDriverState *bs) if (bdrv_pwrite_sync(bs->file, s->l1_table_offset, s->l1_table, l1_length) < 0) return -1; - ret = bdrv_truncate(bs->file, s->l1_table_offset + l1_length); + ret = bdrv_truncate(bs->file, s->l1_table_offset + l1_length, NULL); if (ret < 0) return ret; diff --git a/block/qcow2-refcount.c b/block/qcow2-refcount.c index 9e96f64..4efca7e 100644 --- a/block/qcow2-refcount.c +++ b/block/qcow2-refcount.c @@ -1728,14 +1728,17 @@ static int check_refblocks(BlockDriverState *bs, BdrvCheckResult *res, if (fix & BDRV_FIX_ERRORS) { int64_t new_nb_clusters; + Error *local_err = NULL; if (offset > INT64_MAX - s->cluster_size) { ret = -EINVAL; goto resize_fail; } - ret = bdrv_truncate(bs->file, offset + s->cluster_size); + ret = bdrv_truncate(bs->file, offset + s->cluster_size, + &local_err); if (ret < 0) { + error_report_err(local_err); goto resize_fail; } size = bdrv_getlength(bs->file->bs); diff --git a/block/qcow2.c b/block/qcow2.c index 49c737f..0d7e9e4 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -2294,9 +2294,9 @@ static int qcow2_create2(const char *filename, int64_t total_size, } /* Okay, now that we have a valid image, let's give it the right size */ - ret = blk_truncate(blk, total_size); + ret = blk_truncate(blk, total_size, errp); if (ret < 0) { - error_setg_errno(errp, -ret, "Could not resize image"); + error_prepend(errp, "Could not resize image: "); goto out; } @@ -2584,7 +2584,7 @@ qcow2_co_pwritev_compressed(BlockDriverState *bs, uint64_t offset, /* align end of file to a sector boundary to ease reading with sector based I/Os */ cluster_offset = bdrv_getlength(bs->file->bs); - return bdrv_truncate(bs->file, cluster_offset); + return bdrv_truncate(bs->file, cluster_offset, NULL); } buf = qemu_blockalign(bs, s->cluster_size); @@ -2674,6 +2674,7 @@ fail: static int make_completely_empty(BlockDriverState *bs) { BDRVQcow2State *s = bs->opaque; + Error *local_err = NULL; int ret, l1_clusters; int64_t offset; uint64_t *new_reftable = NULL; @@ -2798,8 +2799,10 @@ static int make_completely_empty(BlockDriverState *bs) goto fail; } - ret = bdrv_truncate(bs->file, (3 + l1_clusters) * s->cluster_size); + ret = bdrv_truncate(bs->file, (3 + l1_clusters) * s->cluster_size, + &local_err); if (ret < 0) { + error_report_err(local_err); goto fail; } @@ -3273,9 +3276,10 @@ static int qcow2_amend_options(BlockDriverState *bs, QemuOpts *opts, return ret; } - ret = blk_truncate(blk, new_size); + ret = blk_truncate(blk, new_size, &local_err); blk_unref(blk); if (ret < 0) { + error_report_err(local_err); return ret; } } diff --git a/block/qed.c b/block/qed.c index 5ec7fd8..53199ac 100644 --- a/block/qed.c +++ b/block/qed.c @@ -635,7 +635,7 @@ static int qed_create(const char *filename, uint32_t cluster_size, blk_set_allow_write_beyond_eof(blk, true); /* File must start empty and grow, check truncate is supported */ - ret = blk_truncate(blk, 0); + ret = blk_truncate(blk, 0, errp); if (ret < 0) { goto out; } diff --git a/block/raw-format.c b/block/raw-format.c index 86fbc65..a800733 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -341,7 +341,7 @@ static int raw_truncate(BlockDriverState *bs, int64_t offset) s->size = offset; offset += s->offset; - return bdrv_truncate(bs->file, offset); + return bdrv_truncate(bs->file, offset, NULL); } static int raw_media_changed(BlockDriverState *bs) diff --git a/block/vdi.c b/block/vdi.c index 9b4f70e..d12d9cd 100644 --- a/block/vdi.c +++ b/block/vdi.c @@ -832,9 +832,9 @@ static int vdi_create(const char *filename, QemuOpts *opts, Error **errp) } if (image_type == VDI_TYPE_STATIC) { - ret = blk_truncate(blk, offset + blocks * block_size); + ret = blk_truncate(blk, offset + blocks * block_size, errp); if (ret < 0) { - error_setg(errp, "Failed to statically allocate %s", filename); + error_prepend(errp, "Failed to statically allocate %s", filename); goto exit; } } diff --git a/block/vhdx-log.c b/block/vhdx-log.c index 67a91c0..3f4c2aa 100644 --- a/block/vhdx-log.c +++ b/block/vhdx-log.c @@ -548,7 +548,7 @@ static int vhdx_log_flush(BlockDriverState *bs, BDRVVHDXState *s, if (new_file_size % (1024*1024)) { /* round up to nearest 1MB boundary */ new_file_size = ((new_file_size >> 20) + 1) << 20; - bdrv_truncate(bs->file, new_file_size); + bdrv_truncate(bs->file, new_file_size, NULL); } } qemu_vfree(desc_entries); diff --git a/block/vhdx.c b/block/vhdx.c index d25bcd9..0a38f77 100644 --- a/block/vhdx.c +++ b/block/vhdx.c @@ -1171,7 +1171,7 @@ static int vhdx_allocate_block(BlockDriverState *bs, BDRVVHDXState *s, /* per the spec, the address for a block is in units of 1MB */ *new_offset = ROUND_UP(*new_offset, 1024 * 1024); - return bdrv_truncate(bs->file, *new_offset + s->block_size); + return bdrv_truncate(bs->file, *new_offset + s->block_size, NULL); } /* @@ -1607,14 +1607,14 @@ static int vhdx_create_bat(BlockBackend *blk, BDRVVHDXState *s, if (type == VHDX_TYPE_DYNAMIC) { /* All zeroes, so we can just extend the file - the end of the BAT * is the furthest thing we have written yet */ - ret = blk_truncate(blk, data_file_offset); + ret = blk_truncate(blk, data_file_offset, errp); if (ret < 0) { error_setg_errno(errp, -ret, "Failed to resize the underlying file"); goto exit; } } else if (type == VHDX_TYPE_FIXED) { - ret = blk_truncate(blk, data_file_offset + image_size); + ret = blk_truncate(blk, data_file_offset + image_size, errp); if (ret < 0) { error_setg_errno(errp, -ret, "Failed to resize the underlying file"); diff --git a/block/vmdk.c b/block/vmdk.c index a9bd22b..c61b9cc 100644 --- a/block/vmdk.c +++ b/block/vmdk.c @@ -1714,10 +1714,7 @@ static int vmdk_create_extent(const char *filename, int64_t filesize, blk_set_allow_write_beyond_eof(blk, true); if (flat) { - ret = blk_truncate(blk, filesize); - if (ret < 0) { - error_setg_errno(errp, -ret, "Could not truncate file"); - } + ret = blk_truncate(blk, filesize, errp); goto exit; } magic = cpu_to_be32(VMDK4_MAGIC); @@ -1780,9 +1777,8 @@ static int vmdk_create_extent(const char *filename, int64_t filesize, goto exit; } - ret = blk_truncate(blk, le64_to_cpu(header.grain_offset) << 9); + ret = blk_truncate(blk, le64_to_cpu(header.grain_offset) << 9, errp); if (ret < 0) { - error_setg_errno(errp, -ret, "Could not truncate file"); goto exit; } @@ -2090,10 +2086,7 @@ static int vmdk_create(const char *filename, QemuOpts *opts, Error **errp) /* bdrv_pwrite write padding zeros to align to sector, we don't need that * for description file */ if (desc_offset == 0) { - ret = blk_truncate(new_blk, desc_len); - if (ret < 0) { - error_setg_errno(errp, -ret, "Could not truncate file"); - } + ret = blk_truncate(new_blk, desc_len, errp); } exit: if (new_blk) { diff --git a/block/vpc.c b/block/vpc.c index f591d4b..ecfee77 100644 --- a/block/vpc.c +++ b/block/vpc.c @@ -851,20 +851,21 @@ static int create_dynamic_disk(BlockBackend *blk, uint8_t *buf, } static int create_fixed_disk(BlockBackend *blk, uint8_t *buf, - int64_t total_size) + int64_t total_size, Error **errp) { int ret; /* Add footer to total size */ total_size += HEADER_SIZE; - ret = blk_truncate(blk, total_size); + ret = blk_truncate(blk, total_size, errp); if (ret < 0) { return ret; } ret = blk_pwrite(blk, total_size - HEADER_SIZE, buf, HEADER_SIZE, 0); if (ret < 0) { + error_setg_errno(errp, -ret, "Unable to write VHD header"); return ret; } @@ -996,11 +997,11 @@ static int vpc_create(const char *filename, QemuOpts *opts, Error **errp) if (disk_type == VHD_DYNAMIC) { ret = create_dynamic_disk(blk, buf, total_sectors); + if (ret < 0) { + error_setg(errp, "Unable to create or write VHD header"); + } } else { - ret = create_fixed_disk(blk, buf, total_size); - } - if (ret < 0) { - error_setg(errp, "Unable to create or write VHD header"); + ret = create_fixed_disk(blk, buf, total_size, errp); } out: diff --git a/blockdev.c b/blockdev.c index 841200e..78e1204 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2926,26 +2926,7 @@ void qmp_block_resize(bool has_device, const char *device, /* complete all in-flight operations before resizing the device */ bdrv_drain_all(); - ret = blk_truncate(blk, size); - switch (ret) { - case 0: - break; - case -ENOMEDIUM: - error_setg(errp, QERR_DEVICE_HAS_NO_MEDIUM, device); - break; - case -ENOTSUP: - error_setg(errp, QERR_UNSUPPORTED); - break; - case -EACCES: - error_setg(errp, "Device '%s' is read only", device); - break; - case -EBUSY: - error_setg(errp, QERR_DEVICE_IN_USE, device); - break; - default: - error_setg_errno(errp, -ret, "Could not resize"); - break; - } + ret = blk_truncate(blk, size, errp); out: blk_unref(blk); diff --git a/include/block/block.h b/include/block/block.h index 5ddc0cf..4bf4843 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -294,7 +294,7 @@ BlockDriverState *bdrv_find_backing_image(BlockDriverState *bs, const char *backing_file); int bdrv_get_backing_file_depth(BlockDriverState *bs); void bdrv_refresh_filename(BlockDriverState *bs); -int bdrv_truncate(BdrvChild *child, int64_t offset); +int bdrv_truncate(BdrvChild *child, int64_t offset, Error **errp); int64_t bdrv_nb_sectors(BlockDriverState *bs); int64_t bdrv_getlength(BlockDriverState *bs); int64_t bdrv_get_allocated_file_size(BlockDriverState *bs); diff --git a/include/sysemu/block-backend.h b/include/sysemu/block-backend.h index 7462228..0ba4e27 100644 --- a/include/sysemu/block-backend.h +++ b/include/sysemu/block-backend.h @@ -225,7 +225,7 @@ int coroutine_fn blk_co_pwrite_zeroes(BlockBackend *blk, int64_t offset, int count, BdrvRequestFlags flags); int blk_pwrite_compressed(BlockBackend *blk, int64_t offset, const void *buf, int count); -int blk_truncate(BlockBackend *blk, int64_t offset); +int blk_truncate(BlockBackend *blk, int64_t offset, Error **errp); int blk_pdiscard(BlockBackend *blk, int64_t offset, int count); int blk_save_vmstate(BlockBackend *blk, const uint8_t *buf, int64_t pos, int size); diff --git a/qemu-img.c b/qemu-img.c index 26ded22..e4a2686 100644 --- a/qemu-img.c +++ b/qemu-img.c @@ -3500,20 +3500,11 @@ static int img_resize(int argc, char **argv) goto out; } - ret = blk_truncate(blk, total_size); - switch (ret) { - case 0: + ret = blk_truncate(blk, total_size, &err); + if (!ret) { qprintf(quiet, "Image resized.\n"); - break; - case -ENOTSUP: - error_report("This image does not support resize"); - break; - case -EACCES: - error_report("Image is read-only"); - break; - default: - error_report("Error resizing image: %s", strerror(-ret)); - break; + } else { + error_report_err(err); } out: blk_unref(blk); diff --git a/qemu-io-cmds.c b/qemu-io-cmds.c index 312fc6d..21af9e6 100644 --- a/qemu-io-cmds.c +++ b/qemu-io-cmds.c @@ -1567,6 +1567,7 @@ static const cmdinfo_t flush_cmd = { static int truncate_f(BlockBackend *blk, int argc, char **argv) { + Error *local_err = NULL; int64_t offset; int ret; @@ -1576,9 +1577,9 @@ static int truncate_f(BlockBackend *blk, int argc, char **argv) return 0; } - ret = blk_truncate(blk, offset); + ret = blk_truncate(blk, offset, &local_err); if (ret < 0) { - printf("truncate: %s\n", strerror(-ret)); + error_report_err(local_err); return 0; } From patchwork Tue Aug 29 00:14:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806832 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh8lM2vPqz9s4s for ; Tue, 29 Aug 2017 10:34:07 +1000 (AEST) Received: from localhost ([::1]:41977 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUTl-0000Fk-7j for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:34:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47689) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCH-00010l-3P for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCD-0005EX-Nc for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:01 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:54473 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCD-0005E0-Gj for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:57 -0400 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0ES4f087643 for ; Mon, 28 Aug 2017 20:15:57 -0400 Received: from e36.co.us.ibm.com (e36.co.us.ibm.com [32.97.110.154]) by mx0b-001b2d01.pphosted.com with ESMTP id 2cmvhgaqte-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:15:56 -0400 Received: from localhost by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 18:15:56 -0600 Received: from b03cxnp08025.gho.boulder.ibm.com (9.17.130.17) by e36.co.us.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 18:15:54 -0600 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0Fri6065816; Mon, 28 Aug 2017 17:15:53 -0700 Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A64C9136046; Mon, 28 Aug 2017 18:15:53 -0600 (MDT) Received: from localhost (unknown [9.80.85.217]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP id 72DAF13603C; Mon, 28 Aug 2017 18:15:53 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:00 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0020-0000-0000-00000CA0E9BD X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:15:55 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0021-0000-0000-00005DE8918D Message-Id: <1503965694-10794-26-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 25/79] blockdev: use drained_begin/end for qmp_block_resize 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 , John Snow , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: John Snow Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1447551 If one tries to issue a block_resize while a guest is busy accessing the disk, it is possible that qemu may deadlock when invoking aio_poll from both the main loop and the iothread. Replace another instance of bdrv_drain_all that doesn't quite belong. Cc: qemu-stable@nongnu.org Suggested-by: Paolo Bonzini Signed-off-by: John Snow Reviewed-by: Eric Blake Reviewed-by: Paolo Bonzini Signed-off-by: Kevin Wolf (cherry picked from commit 698bdfa07d66b5ec218a60229e58eae1dcde00e5) Signed-off-by: Michael Roth --- blockdev.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/blockdev.c b/blockdev.c index 78e1204..e8a9a65 100644 --- a/blockdev.c +++ b/blockdev.c @@ -2923,10 +2923,9 @@ void qmp_block_resize(bool has_device, const char *device, goto out; } - /* complete all in-flight operations before resizing the device */ - bdrv_drain_all(); - + bdrv_drained_begin(bs); ret = blk_truncate(blk, size, errp); + bdrv_drained_end(bs); out: blk_unref(blk); From patchwork Tue Aug 29 00:14:01 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806826 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh8fs0QV4z9s65 for ; Tue, 29 Aug 2017 10:30:13 +1000 (AEST) Received: from localhost ([::1]:41957 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUPy-0005F0-RH for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:30:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47694) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCH-00010u-5x for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:02 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCD-0005Em-RT for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:01 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:52700 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCD-0005E4-JT for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:57 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0EBkT081939 for ; Mon, 28 Aug 2017 20:15:57 -0400 Received: from e36.co.us.ibm.com (e36.co.us.ibm.com [32.97.110.154]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmurncras-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:15:56 -0400 Received: from localhost by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 18:15:56 -0600 Received: from b03cxnp08027.gho.boulder.ibm.com (9.17.130.19) by e36.co.us.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 18:15:55 -0600 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0FsM163504516; Mon, 28 Aug 2017 17:15:54 -0700 Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8D66E6A047; Mon, 28 Aug 2017 18:15:54 -0600 (MDT) Received: from localhost (unknown [9.80.85.217]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP id 5A2916A03D; Mon, 28 Aug 2017 18:15:54 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:01 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0020-0000-0000-00000CA0E9BE X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:15:56 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0021-0000-0000-00005DE89191 Message-Id: <1503965694-10794-27-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 26/79] target/xtensa: fix mapping direction in read/write simcalls 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: Max Filippov , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Max Filippov Read and write simcalls map physical memory to access I/O buffers, but 'read' simcall need to map it for writing and 'write' simcall need to map it for reading, i.e. the opposite of what they do now. Fix that. Cc: qemu-stable@nongnu.org Signed-off-by: Max Filippov (cherry picked from commit 30c2afd151cbc38c012f7b441088980807183da6) Signed-off-by: Michael Roth --- target/xtensa/xtensa-semi.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/target/xtensa/xtensa-semi.c b/target/xtensa/xtensa-semi.c index a888a9d..98ae28c 100644 --- a/target/xtensa/xtensa-semi.c +++ b/target/xtensa/xtensa-semi.c @@ -173,7 +173,7 @@ void HELPER(simcall)(CPUXtensaState *env) TARGET_PAGE_SIZE - (vaddr & (TARGET_PAGE_SIZE - 1)); uint32_t io_sz = page_left < len ? page_left : len; hwaddr sz = io_sz; - void *buf = cpu_physical_memory_map(paddr, &sz, is_write); + void *buf = cpu_physical_memory_map(paddr, &sz, !is_write); if (buf) { vaddr += io_sz; @@ -182,7 +182,7 @@ void HELPER(simcall)(CPUXtensaState *env) write(fd, buf, io_sz) : read(fd, buf, io_sz); regs[3] = errno_h2g(errno); - cpu_physical_memory_unmap(buf, sz, is_write, sz); + cpu_physical_memory_unmap(buf, sz, !is_write, sz); if (regs[2] == -1) { break; } From patchwork Tue Aug 29 00:14:02 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806836 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh8nG0z80z9s4s for ; Tue, 29 Aug 2017 10:35:46 +1000 (AEST) Received: from localhost ([::1]:41986 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUVL-0001ls-Vo for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:35:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47727) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCI-00012i-Dq for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCF-0005Fl-54 for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:02 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:60942 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCE-0005FJ-UY for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:15:59 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0EAdl044225 for ; Mon, 28 Aug 2017 20:15:58 -0400 Received: from e36.co.us.ibm.com (e36.co.us.ibm.com [32.97.110.154]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmu3kpe19-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:15:58 -0400 Received: from localhost by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 18:15:57 -0600 Received: from b03cxnp08027.gho.boulder.ibm.com (9.17.130.19) by e36.co.us.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 18:15:55 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0Ft3B64421986; Mon, 28 Aug 2017 17:15:55 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5AB4A78038; Mon, 28 Aug 2017 18:15:55 -0600 (MDT) Received: from localhost (unknown [9.80.85.217]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP id 34FC778043; Mon, 28 Aug 2017 18:15:55 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:02 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0020-0000-0000-00000CA0E9C0 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:15:57 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0021-0000-0000-00005DE89193 Message-Id: <1503965694-10794-28-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 27/79] target/xtensa: fix return value of read/write simcalls 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: Max Filippov , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Max Filippov Return value of read/write simcalls is not calculated correctly in case of operations crossing page boundary and in case of short reads/writes. Read and write simcalls should return the size of data actually read/written or -1 in case of error. Cc: qemu-stable@nongnu.org Signed-off-by: Max Filippov (cherry picked from commit 347ec03093f9668a379ef6b7fa1feb332fff039c) Signed-off-by: Michael Roth --- target/xtensa/xtensa-semi.c | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) diff --git a/target/xtensa/xtensa-semi.c b/target/xtensa/xtensa-semi.c index 98ae28c..ffcaf8d 100644 --- a/target/xtensa/xtensa-semi.c +++ b/target/xtensa/xtensa-semi.c @@ -166,6 +166,7 @@ void HELPER(simcall)(CPUXtensaState *env) uint32_t fd = regs[3]; uint32_t vaddr = regs[4]; uint32_t len = regs[5]; + uint32_t len_done = 0; while (len > 0) { hwaddr paddr = cpu_get_phys_page_debug(cs, vaddr); @@ -174,24 +175,38 @@ void HELPER(simcall)(CPUXtensaState *env) uint32_t io_sz = page_left < len ? page_left : len; hwaddr sz = io_sz; void *buf = cpu_physical_memory_map(paddr, &sz, !is_write); + uint32_t io_done; + bool error = false; if (buf) { vaddr += io_sz; len -= io_sz; - regs[2] = is_write ? + io_done = is_write ? write(fd, buf, io_sz) : read(fd, buf, io_sz); regs[3] = errno_h2g(errno); - cpu_physical_memory_unmap(buf, sz, !is_write, sz); - if (regs[2] == -1) { - break; + if (io_done == -1) { + error = true; + io_done = 0; } + cpu_physical_memory_unmap(buf, sz, !is_write, io_done); } else { - regs[2] = -1; + error = true; regs[3] = TARGET_EINVAL; break; } + if (error) { + if (!len_done) { + len_done = -1; + } + break; + } + len_done += io_done; + if (io_done < io_sz) { + break; + } } + regs[2] = len_done; } break; From patchwork Tue Aug 29 00:14:03 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806841 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh8rG0F7Nz9s4s for ; Tue, 29 Aug 2017 10:38:22 +1000 (AEST) Received: from localhost ([::1]:42006 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUXr-00046x-S4 for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:38:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47732) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCI-00012r-Gr for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCH-0005I7-Fs for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:02 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:55885) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCH-0005Gu-6p for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:01 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0EBYH042759 for ; Mon, 28 Aug 2017 20:16:00 -0400 Received: from e36.co.us.ibm.com (e36.co.us.ibm.com [32.97.110.154]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmr8neytj-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:00 -0400 Received: from localhost by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 18:15:59 -0600 Received: from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e36.co.us.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 18:15:56 -0600 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0FsCW30408892; Mon, 28 Aug 2017 17:15:56 -0700 Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4AAF0BE040; Mon, 28 Aug 2017 18:15:56 -0600 (MDT) Received: from localhost (unknown [9.80.85.217]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP id 17121BE04F; Mon, 28 Aug 2017 18:15:56 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:03 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0020-0000-0000-00000CA0E9C1 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:15:58 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0021-0000-0000-00005DE89195 Message-Id: <1503965694-10794-29-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 28/79] curl: strengthen assertion in curl_clean_state 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: Paolo Bonzini , Jeff Cody , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Paolo Bonzini curl_clean_state should only be called after all AIOCBs have been completed. This is not so obvious for the call from curl_detach_aio_context, so assert that. Cc: qemu-stable@nongnu.org Reviewed-by: Jeff Cody Signed-off-by: Paolo Bonzini Reviewed-by: Max Reitz Message-id: 20170515100059.15795-2-pbonzini@redhat.com Signed-off-by: Jeff Cody (cherry picked from commit 675a775633e68bf8b426a896fea5b93a4f4ff1cc) Signed-off-by: Michael Roth --- block/curl.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/block/curl.c b/block/curl.c index aa6e8cc..c6dc4c0 100644 --- a/block/curl.c +++ b/block/curl.c @@ -532,6 +532,11 @@ static CURLState *curl_init_state(BlockDriverState *bs, BDRVCURLState *s) static void curl_clean_state(CURLState *s) { + int j; + for (j = 0; j < CURL_NUM_ACB; j++) { + assert(!s->acb[j]); + } + if (s->s->multi) curl_multi_remove_handle(s->s->multi, s->curl); From patchwork Tue Aug 29 00:14:04 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806838 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh8pX2DKzz9sNr for ; Tue, 29 Aug 2017 10:36:52 +1000 (AEST) Received: from localhost ([::1]:41997 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUWQ-0002qM-3r for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:36:50 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47804) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCL-000162-7n for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCI-0005J6-0I for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:05 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:32792 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCH-0005IC-PX for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:01 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0EBme044267 for ; Mon, 28 Aug 2017 20:16:01 -0400 Received: from e35.co.us.ibm.com (e35.co.us.ibm.com [32.97.110.153]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmu3kpe34-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:01 -0400 Received: from localhost by e35.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 18:16:00 -0600 Received: from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e35.co.us.ibm.com (192.168.1.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 18:15:57 -0600 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0FvpG32047138; Mon, 28 Aug 2017 17:15:57 -0700 Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3C34FC603C; Mon, 28 Aug 2017 18:15:57 -0600 (MDT) Received: from localhost (unknown [9.80.85.217]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP id 09073C6037; Mon, 28 Aug 2017 18:15:56 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:04 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0012-0000-0000-000014ECDC35 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909027; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:15:59 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0013-0000-0000-00004F43FAF5 Message-Id: <1503965694-10794-30-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 29/79] curl: never invoke callbacks with s->mutex held 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: Paolo Bonzini , Jeff Cody , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Paolo Bonzini All curl callbacks go through curl_multi_do, and hence are called with s->mutex held. Note that with comments, and make curl_read_cb drop the lock before invoking the callback. Likewise for curl_find_buf, where the callback can be invoked by the caller. Cc: qemu-stable@nongnu.org Reviewed-by: Jeff Cody Signed-off-by: Paolo Bonzini Reviewed-by: Max Reitz Message-id: 20170515100059.15795-3-pbonzini@redhat.com Signed-off-by: Jeff Cody (cherry picked from commit 34db05e7ffe8d61ca7288b9532ad6e8300853318) Signed-off-by: Michael Roth --- block/curl.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/block/curl.c b/block/curl.c index c6dc4c0..59e69c6 100644 --- a/block/curl.c +++ b/block/curl.c @@ -147,6 +147,7 @@ static void curl_multi_do(void *arg); static void curl_multi_read(void *arg); #ifdef NEED_CURL_TIMER_CALLBACK +/* Called from curl_multi_do_locked, with s->mutex held. */ static int curl_timer_cb(CURLM *multi, long timeout_ms, void *opaque) { BDRVCURLState *s = opaque; @@ -163,6 +164,7 @@ static int curl_timer_cb(CURLM *multi, long timeout_ms, void *opaque) } #endif +/* Called from curl_multi_do_locked, with s->mutex held. */ static int curl_sock_cb(CURL *curl, curl_socket_t fd, int action, void *userp, void *sp) { @@ -212,6 +214,7 @@ static int curl_sock_cb(CURL *curl, curl_socket_t fd, int action, return 0; } +/* Called from curl_multi_do_locked, with s->mutex held. */ static size_t curl_header_cb(void *ptr, size_t size, size_t nmemb, void *opaque) { BDRVCURLState *s = opaque; @@ -226,6 +229,7 @@ static size_t curl_header_cb(void *ptr, size_t size, size_t nmemb, void *opaque) return realsize; } +/* Called from curl_multi_do_locked, with s->mutex held. */ static size_t curl_read_cb(void *ptr, size_t size, size_t nmemb, void *opaque) { CURLState *s = ((CURLState*)opaque); @@ -264,7 +268,9 @@ static size_t curl_read_cb(void *ptr, size_t size, size_t nmemb, void *opaque) request_length - offset); } + qemu_mutex_unlock(&s->s->mutex); acb->common.cb(acb->common.opaque, 0); + qemu_mutex_lock(&s->s->mutex); qemu_aio_unref(acb); s->acb[i] = NULL; } @@ -305,8 +311,6 @@ static int curl_find_buf(BDRVCURLState *s, size_t start, size_t len, if (clamped_len < len) { qemu_iovec_memset(acb->qiov, clamped_len, 0, len - clamped_len); } - acb->common.cb(acb->common.opaque, 0); - return FIND_RET_OK; } @@ -832,8 +836,8 @@ static void curl_readv_bh_cb(void *p) // we can just call the callback and be done. switch (curl_find_buf(s, start, acb->nb_sectors * BDRV_SECTOR_SIZE, acb)) { case FIND_RET_OK: - qemu_aio_unref(acb); - // fall through + ret = 0; + goto out; case FIND_RET_WAIT: goto out; default: From patchwork Tue Aug 29 00:14:05 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806845 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh8vJ0zKjz9sNc for ; Tue, 29 Aug 2017 10:41:00 +1000 (AEST) Received: from localhost ([::1]:42019 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUaP-0006Oq-UC for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:40:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47834) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCM-00018X-RN for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCJ-0005M3-MV for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:06 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:57325) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCJ-0005Ku-Er for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:03 -0400 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0E8sW041493 for ; Mon, 28 Aug 2017 20:16:02 -0400 Received: from e14.ny.us.ibm.com (e14.ny.us.ibm.com [129.33.205.204]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmsrsj1fp-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:02 -0400 Received: from localhost by e14.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 20:16:01 -0400 Received: from b01cxnp23034.gho.pok.ibm.com (9.57.198.29) by e14.ny.us.ibm.com (146.89.104.201) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 20:15:58 -0400 Received: from b01ledav001.gho.pok.ibm.com (b01ledav001.gho.pok.ibm.com [9.57.199.106]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0Fw3w25952488; Tue, 29 Aug 2017 00:15:58 GMT Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6216B2804A; Mon, 28 Aug 2017 20:15:51 -0400 (EDT) Received: from localhost (unknown [9.80.85.217]) by b01ledav001.gho.pok.ibm.com (Postfix) with ESMTP id 298F928046; Mon, 28 Aug 2017 20:15:51 -0400 (EDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:05 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0052-0000-0000-000002573341 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:15:59 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0053-0000-0000-000051D1D941 Message-Id: <1503965694-10794-31-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 30/79] curl: avoid recursive locking of BDRVCURLState mutex 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: Paolo Bonzini , Jeff Cody , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Paolo Bonzini The curl driver has a ugly hack where, if it cannot find an empty CURLState, it just uses aio_poll to wait for one to be empty. This is probably buggy when used together with dataplane, and the simplest way to fix it is to use coroutines instead. A more immediate effect of the bug however is that it can cause a recursive call to curl_readv_bh_cb and recursively taking the BDRVCURLState mutex. This causes a deadlock. The fix is to unlock the mutex around aio_poll, but for cleanliness we should also take the mutex around all calls to curl_init_state, even if reaching the unlock/lock pair is impossible. The same is true for curl_clean_state. Reported-by: Kun Wei Tested-by: Richard W.M. Jones Reviewed-by: Max Reitz Reviewed-by: Jeff Cody Signed-off-by: Paolo Bonzini Message-id: 20170515100059.15795-4-pbonzini@redhat.com Cc: qemu-stable@nongnu.org Cc: Jeff Cody Signed-off-by: Paolo Bonzini Signed-off-by: Jeff Cody (cherry picked from commit 456af346297ebef86aa097b3609534d34f3d2f75) Signed-off-by: Michael Roth --- block/curl.c | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/block/curl.c b/block/curl.c index 59e69c6..dddf5ef 100644 --- a/block/curl.c +++ b/block/curl.c @@ -281,6 +281,7 @@ read_end: return size * nmemb; } +/* Called with s->mutex held. */ static int curl_find_buf(BDRVCURLState *s, size_t start, size_t len, CURLAIOCB *acb) { @@ -453,6 +454,7 @@ static void curl_multi_timeout_do(void *arg) #endif } +/* Called with s->mutex held. */ static CURLState *curl_init_state(BlockDriverState *bs, BDRVCURLState *s) { CURLState *state = NULL; @@ -471,7 +473,9 @@ static CURLState *curl_init_state(BlockDriverState *bs, BDRVCURLState *s) break; } if (!state) { + qemu_mutex_unlock(&s->mutex); aio_poll(bdrv_get_aio_context(bs), true); + qemu_mutex_lock(&s->mutex); } } while(!state); @@ -534,6 +538,7 @@ static CURLState *curl_init_state(BlockDriverState *bs, BDRVCURLState *s) return state; } +/* Called with s->mutex held. */ static void curl_clean_state(CURLState *s) { int j; @@ -565,6 +570,7 @@ static void curl_detach_aio_context(BlockDriverState *bs) BDRVCURLState *s = bs->opaque; int i; + qemu_mutex_lock(&s->mutex); for (i = 0; i < CURL_NUM_STATES; i++) { if (s->states[i].in_use) { curl_clean_state(&s->states[i]); @@ -580,6 +586,7 @@ static void curl_detach_aio_context(BlockDriverState *bs) curl_multi_cleanup(s->multi); s->multi = NULL; } + qemu_mutex_unlock(&s->mutex); timer_del(&s->timer); } @@ -677,6 +684,7 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags, return -EROFS; } + qemu_mutex_init(&s->mutex); opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(opts, options, &local_err); if (local_err) { @@ -747,7 +755,9 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags, DPRINTF("CURL: Opening %s\n", file); s->aio_context = bdrv_get_aio_context(bs); s->url = g_strdup(file); + qemu_mutex_lock(&s->mutex); state = curl_init_state(bs, s); + qemu_mutex_unlock(&s->mutex); if (!state) goto out_noclean; @@ -791,11 +801,12 @@ static int curl_open(BlockDriverState *bs, QDict *options, int flags, } DPRINTF("CURL: Size = %zd\n", s->len); + qemu_mutex_lock(&s->mutex); curl_clean_state(state); + qemu_mutex_unlock(&s->mutex); curl_easy_cleanup(state->curl); state->curl = NULL; - qemu_mutex_init(&s->mutex); curl_attach_aio_context(bs, bdrv_get_aio_context(bs)); qemu_opts_del(opts); @@ -806,6 +817,7 @@ out: curl_easy_cleanup(state->curl); state->curl = NULL; out_noclean: + qemu_mutex_destroy(&s->mutex); g_free(s->cookie); g_free(s->url); qemu_opts_del(opts); From patchwork Tue Aug 29 00:14:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806843 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh8sw41XMz9s4s for ; Tue, 29 Aug 2017 10:39:48 +1000 (AEST) Received: from localhost ([::1]:42012 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUZG-0005JJ-BW for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:39:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47855) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCN-00019U-Gp for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCK-0005NU-Bf for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:07 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:51467) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCK-0005La-39 for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:04 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0E9WX077591 for ; Mon, 28 Aug 2017 20:16:03 -0400 Received: from e17.ny.us.ibm.com (e17.ny.us.ibm.com [129.33.205.207]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmnx0yuu0-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:03 -0400 Received: from localhost by e17.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 20:16:01 -0400 Received: from b01cxnp23033.gho.pok.ibm.com (9.57.198.28) by e17.ny.us.ibm.com (146.89.104.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 20:15:59 -0400 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0FxFu3277170; Tue, 29 Aug 2017 00:15:59 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 8B67511205F; Mon, 28 Aug 2017 20:15:45 -0400 (EDT) Received: from localhost (unknown [9.80.85.217]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP id 52528112047; Mon, 28 Aug 2017 20:15:45 -0400 (EDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:06 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0040-0000-0000-00000396DEC3 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:00 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0041-0000-0000-0000078B1046 Message-Id: <1503965694-10794-32-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 31/79] stream: fix crash in stream_start() when block_job_create() fails 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 , Alberto Garcia , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Alberto Garcia The code that tries to reopen a BlockDriverState in stream_start() when the creation of a new block job fails crashes because it attempts to dereference a pointer that is known to be NULL. This is a regression introduced in a170a91fd3eab6155da39e740381867e, likely because the code was copied from stream_complete(). Cc: qemu-stable@nongnu.org Reported-by: Kashyap Chamarthy Signed-off-by: Alberto Garcia Tested-by: Kashyap Chamarthy Signed-off-by: Kevin Wolf (cherry picked from commit 525989a50a70ea0ffa2b1cdf56279765bb2b7de0) Signed-off-by: Michael Roth --- block/stream.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/block/stream.c b/block/stream.c index 0113710..52d329f 100644 --- a/block/stream.c +++ b/block/stream.c @@ -280,6 +280,6 @@ void stream_start(const char *job_id, BlockDriverState *bs, fail: if (orig_bs_flags != bdrv_get_flags(bs)) { - bdrv_reopen(bs, s->bs_flags, NULL); + bdrv_reopen(bs, orig_bs_flags, NULL); } } From patchwork Tue Aug 29 00:14:07 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806850 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh8zZ4RfTz9sNr for ; Tue, 29 Aug 2017 10:44:42 +1000 (AEST) Received: from localhost ([::1]:42040 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUe0-0001Nc-Cv for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:44:40 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47859) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCN-00019q-Kg for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCK-0005Nr-Ff for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:07 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:41680 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCK-0005Mx-AK for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:04 -0400 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0EBJ4019642 for ; Mon, 28 Aug 2017 20:16:03 -0400 Received: from e18.ny.us.ibm.com (e18.ny.us.ibm.com [129.33.205.208]) by mx0b-001b2d01.pphosted.com with ESMTP id 2cmsfn2w69-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:03 -0400 Received: from localhost by e18.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 20:16:03 -0400 Received: from b01cxnp23032.gho.pok.ibm.com (9.57.198.27) by e18.ny.us.ibm.com (146.89.104.205) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 20:16:00 -0400 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0FxZE23920652; Tue, 29 Aug 2017 00:15:59 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7EE8DAE03C; Mon, 28 Aug 2017 20:16:23 -0400 (EDT) Received: from localhost (unknown [9.80.85.217]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTP id 4718BAE034; Mon, 28 Aug 2017 20:16:23 -0400 (EDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:07 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 17082900-0044-0000-0000-000003847056 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:01 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0045-0000-0000-000007B288C9 Message-Id: <1503965694-10794-33-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-MIME-Autoconverted: from 8bit to quoted-printable by mx0b-001b2d01.pphosted.com id v7T0EBJ4019642 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 32/79] vvfat: fix qemu-img map and qemu-img convert 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 , =?utf-8?q?Herv=C3=A9_Poussineau?= , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Hervé Poussineau - bs->total_sectors is the number of sectors of the whole disk - s->sector_count is the number of sectors of the FAT partition This fixes the following assert in qemu-img map: qemu-img.c:2641: get_block_status: Assertion `nb_sectors' failed. This also fixes an infinite loop in qemu-img convert. Fixes: 4480e0f924a42e1db8b8cfcac4d0634dd1bb27a0 Fixes: https://bugs.launchpad.net/qemu/+bug/1599539 Cc: qemu-stable@nongnu.org Signed-off-by: Hervé Poussineau Reviewed-by: Eric Blake Signed-off-by: Kevin Wolf (cherry picked from commit 139921aaa77c435104308ad53b631a00c3b65ae8) Signed-off-by: Michael Roth --- block/vvfat.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/block/vvfat.c b/block/vvfat.c index 8b4e4eb..7d08f65 100644 --- a/block/vvfat.c +++ b/block/vvfat.c @@ -2958,8 +2958,7 @@ vvfat_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, static int64_t coroutine_fn vvfat_co_get_block_status(BlockDriverState *bs, int64_t sector_num, int nb_sectors, int *n, BlockDriverState **file) { - BDRVVVFATState* s = bs->opaque; - *n = s->sector_count - sector_num; + *n = bs->total_sectors - sector_num; if (*n > nb_sectors) { *n = nb_sectors; } else if (*n < 0) { From patchwork Tue Aug 29 00:14:08 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806819 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh8Ww5c6sz9s7v for ; Tue, 29 Aug 2017 10:24:12 +1000 (AEST) Received: from localhost ([::1]:41919 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUKA-00084S-Kr for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:24:10 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47893) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCO-0001Aj-DT for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCM-0005PD-FM for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:08 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:57452) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCM-0005Ok-79 for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:06 -0400 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0ECLT041673 for ; Mon, 28 Aug 2017 20:16:05 -0400 Received: from e16.ny.us.ibm.com (e16.ny.us.ibm.com [129.33.205.206]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmsrsj1hu-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:05 -0400 Received: from localhost by e16.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 20:16:03 -0400 Received: from b01cxnp22034.gho.pok.ibm.com (9.57.198.24) by e16.ny.us.ibm.com (146.89.104.203) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 20:16:01 -0400 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp22034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0G0bI20971546; Tue, 29 Aug 2017 00:16:00 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id AB7CCAC041; Mon, 28 Aug 2017 20:16:24 -0400 (EDT) Received: from localhost (unknown [9.80.85.217]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP id 73DE3AC03A; Mon, 28 Aug 2017 20:16:24 -0400 (EDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:08 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0024-0000-0000-000002C6D29E X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:02 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0025-0000-0000-0000453E6316 Message-Id: <1503965694-10794-34-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 33/79] virtio: allow broken device to notify guest 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: "Michael S . Tsirkin" , qemu-stable@nongnu.org, Greg Kurz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Greg Kurz According to section 2.1.2 of the virtio-1 specification: "The device SHOULD set DEVICE_NEEDS_RESET when it enters an error state that a reset is needed. If DRIVER_OK is set, after it sets DEVICE_NEEDS_RESET, the device MUST send a device configuration change notification to the driver." Commit "f5ed36635d8f virtio: stop virtqueue processing if device is broken" introduced a virtio_error() call that just does that: - internally mark the device as broken - set the DEVICE_NEEDS_RESET bit in the status - send a configuration change notification Unfortunately, virtio_notify_vector(), called by virtio_notify_config(), returns right away when the device is marked as broken and the notification isn't sent in this case. The spec doesn't say whether a broken device can send notifications in other situations or not. But since the driver isn't supposed to do anything but to reset the device, it makes sense to keep the check in virtio_notify_config(). Marking the device as broken AFTER the configuration change notification was sent is enough to fix the issue. Signed-off-by: Greg Kurz Reviewed-by: Cornelia Huck Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Stefan Hajnoczi (cherry picked from commit 66453cff9e5e75344c601cd7674c8ef5fefee8a6) Signed-off-by: Michael Roth --- hw/virtio/virtio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/virtio/virtio.c b/hw/virtio/virtio.c index 03592c5..890b4d7 100644 --- a/hw/virtio/virtio.c +++ b/hw/virtio/virtio.c @@ -2451,12 +2451,12 @@ void GCC_FMT_ATTR(2, 3) virtio_error(VirtIODevice *vdev, const char *fmt, ...) error_vreport(fmt, ap); va_end(ap); - vdev->broken = true; - if (virtio_vdev_has_feature(vdev, VIRTIO_F_VERSION_1)) { virtio_set_status(vdev, vdev->status | VIRTIO_CONFIG_S_NEEDS_RESET); virtio_notify_config(vdev); } + + vdev->broken = true; } static void virtio_memory_listener_commit(MemoryListener *listener) From patchwork Tue Aug 29 00:14:09 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806853 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh92f6Bflz9s7M for ; Tue, 29 Aug 2017 10:47:22 +1000 (AEST) Received: from localhost ([::1]:42057 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUga-0003ub-MK for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:47:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47962) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCQ-0001Dx-Lz for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:11 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCN-0005Po-Ek for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:10 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:41806 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCN-0005PV-9L for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:07 -0400 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0E8Bm019422 for ; Mon, 28 Aug 2017 20:16:06 -0400 Received: from e33.co.us.ibm.com (e33.co.us.ibm.com [32.97.110.151]) by mx0b-001b2d01.pphosted.com with ESMTP id 2cmsfn2w86-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:06 -0400 Received: from localhost by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 18:16:06 -0600 Received: from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e33.co.us.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 18:16:01 -0600 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0G1RP30408896; Mon, 28 Aug 2017 17:16:01 -0700 Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 46EB26E040; Mon, 28 Aug 2017 18:16:01 -0600 (MDT) Received: from localhost (unknown [9.80.85.217]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP id 1E0496E03D; Mon, 28 Aug 2017 18:16:01 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:09 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0008-0000-0000-0000087D385B X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:04 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0009-0000-0000-000043C046C3 Message-Id: <1503965694-10794-35-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 34/79] virtio-scsi: Unset hotplug handler when unrealize 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: Paolo Bonzini , Fam Zheng , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Fam Zheng This matches the qbus_set_hotplug_handler in realize, and it releases the final reference to the embedded VirtIODevice so that it is properly finalized. A use-after-free is fixed with this patch, indirectly: virtio_device_instance_finalize wasn't called at hot-unplug, and the vdev->listener would be a dangling pointer in the global and the per address space listener list. See also RHBZ 1449031. Cc: qemu-stable@nongnu.org Signed-off-by: Fam Zheng Message-Id: <20170518102808.30046-1-famz@redhat.com> Signed-off-by: Paolo Bonzini (cherry picked from commit 2cbe2de5454cf9af44b620b2b40d56361a12a45f) Signed-off-by: Michael Roth --- hw/scsi/virtio-scsi.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index bd62d08..cb1c123 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -915,6 +915,9 @@ void virtio_scsi_common_unrealize(DeviceState *dev, Error **errp) static void virtio_scsi_device_unrealize(DeviceState *dev, Error **errp) { + VirtIOSCSI *s = VIRTIO_SCSI(dev); + + qbus_set_hotplug_handler(BUS(&s->bus), NULL, &error_abort); virtio_scsi_common_unrealize(dev, errp); } From patchwork Tue Aug 29 00:14:10 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806848 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh8xt03G7z9s7M for ; Tue, 29 Aug 2017 10:43:14 +1000 (AEST) Received: from localhost ([::1]:42029 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUcZ-0008Ux-QF for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:43:11 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47970) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCQ-0001EN-U5 for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCN-0005QF-MP for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:10 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:56940 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCN-0005Pj-Gs for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:07 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0ED4s099779 for ; Mon, 28 Aug 2017 20:16:07 -0400 Received: from e33.co.us.ibm.com (e33.co.us.ibm.com [32.97.110.151]) by mx0b-001b2d01.pphosted.com with ESMTP id 2cmr22yk3y-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:06 -0400 Received: from localhost by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 18:16:06 -0600 Received: from b03cxnp08027.gho.boulder.ibm.com (9.17.130.19) by e33.co.us.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 18:16:02 -0600 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0G2F056623330; Mon, 28 Aug 2017 17:16:02 -0700 Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3DE8813603C; Mon, 28 Aug 2017 18:16:02 -0600 (MDT) Received: from localhost (unknown [9.80.85.217]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP id 0AED9136040; Mon, 28 Aug 2017 18:16:01 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:10 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0008-0000-0000-0000087D385C X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:04 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0009-0000-0000-000043C046C5 Message-Id: <1503965694-10794-36-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 35/79] e1000e: Fix ICR "Other" causes clear logic 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: Sameeh Jubran , Jason Wang , Sameeh Jubran , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Sameeh Jubran This commit fixes a bug which causes the guest to hang. The bug was observed upon a "receive overrun" (bit #6 of the ICR register) interrupt which could be triggered post migration in a heavy traffic environment. Even though the "receive overrun" bit (#6) is masked out by the IMS register (refer to the log below) the driver still receives an interrupt as the "receive overrun" bit (#6) causes the "Other" - bit #24 of the ICR register - bit to be set as documented below. The driver handles the interrupt and clears the "Other" bit (#24) but doesn't clear the "receive overrun" bit (#6) which leads to an infinite loop. Apparently the Windows driver expects that the "receive overrun" bit and other ones - documented below - to be cleared when the "Other" bit (#24) is cleared. So to sum that up: 1. Bit #6 of the ICR register is set by heavy traffic 2. As a results of setting bit #6, bit #24 is set 3. The driver receives an interrupt for bit 24 (it doesn't receieve an interrupt for bit #6 as it is masked out by IMS) 4. The driver handles and clears the interrupt of bit #24 5. Bit #6 is still set. 6. 2 happens all over again The Interrupt Cause Read - ICR register: The ICR has the "Other" bit - bit #24 - that is set when one or more of the following ICR register's bits are set: LSC - bit #2, RXO - bit #6, MDAC - bit #9, SRPD - bit #16, ACK - bit #17, MNG - bit #18 This bug can occur with any of these bits depending on the driver's behaviour and the way it configures the device. However, trying to reproduce it with any bit other than RX0 is challenging and came to failure as the drivers don't implement most of these bits, trying to reproduce it with LSC (Link Status Change - bit #2) bit didn't succeed too as it seems that Windows handles this bit differently. Log sample of the storm: 27563@1494850819.411877:e1000e_irq_pending_interrupts ICR PENDING: 0x1000000 (ICR: 0x815000c2, IMS: 0x1a00004) 27563@1494850819.411900:e1000e_irq_pending_interrupts ICR PENDING: 0x0 (ICR: 0x815000c2, IMS: 0xa00004) 27563@1494850819.411915:e1000e_irq_pending_interrupts ICR PENDING: 0x0 (ICR: 0x815000c2, IMS: 0xa00004) 27563@1494850819.412380:e1000e_irq_pending_interrupts ICR PENDING: 0x0 (ICR: 0x815000c2, IMS: 0xa00004) 27563@1494850819.412395:e1000e_irq_pending_interrupts ICR PENDING: 0x0 (ICR: 0x815000c2, IMS: 0xa00004) 27563@1494850819.412436:e1000e_irq_pending_interrupts ICR PENDING: 0x0 (ICR: 0x815000c2, IMS: 0xa00004) 27563@1494850819.412441:e1000e_irq_pending_interrupts ICR PENDING: 0x0 (ICR: 0x815000c2, IMS: 0xa00004) 27563@1494850819.412998:e1000e_irq_pending_interrupts ICR PENDING: 0x1000000 (ICR: 0x815000c2, IMS: 0x1a00004) * This bug behaviour wasn't observed with the Linux driver. This commit solves: https://bugzilla.redhat.com/show_bug.cgi?id=1447935 https://bugzilla.redhat.com/show_bug.cgi?id=1449490 Cc: qemu-stable@nongnu.org Signed-off-by: Sameeh Jubran Signed-off-by: Jason Wang (cherry picked from commit 82342e91b60a4a078811df4e1a545e57abffa11d) Signed-off-by: Michael Roth --- hw/net/e1000e_core.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/hw/net/e1000e_core.c b/hw/net/e1000e_core.c index 28c5be1..8140564 100644 --- a/hw/net/e1000e_core.c +++ b/hw/net/e1000e_core.c @@ -2454,14 +2454,20 @@ e1000e_set_ics(E1000ECore *core, int index, uint32_t val) static void e1000e_set_icr(E1000ECore *core, int index, uint32_t val) { + uint32_t icr = 0; if ((core->mac[ICR] & E1000_ICR_ASSERTED) && (core->mac[CTRL_EXT] & E1000_CTRL_EXT_IAME)) { trace_e1000e_irq_icr_process_iame(); e1000e_clear_ims_bits(core, core->mac[IAM]); } - trace_e1000e_irq_icr_write(val, core->mac[ICR], core->mac[ICR] & ~val); - core->mac[ICR] &= ~val; + icr = core->mac[ICR] & ~val; + /* Windows driver expects that the "receive overrun" bit and other + * ones to be cleared when the "Other" bit (#24) is cleared. + */ + icr = (val & E1000_ICR_OTHER) ? (icr & ~E1000_ICR_OTHER_CAUSES) : icr; + trace_e1000e_irq_icr_write(val, core->mac[ICR], icr); + core->mac[ICR] = icr; e1000e_update_interrupt_state(core); } From patchwork Tue Aug 29 00:14:11 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806858 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh96k17gSz9s7M for ; Tue, 29 Aug 2017 10:50:54 +1000 (AEST) Received: from localhost ([::1]:42081 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUjz-0006mk-CJ for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:50:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47983) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCR-0001F9-A3 for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCO-0005Qa-26 for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:11 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:44213) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCN-0005PX-Pm for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:07 -0400 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0FlUN045002 for ; Mon, 28 Aug 2017 20:16:07 -0400 Received: from e33.co.us.ibm.com (e33.co.us.ibm.com [32.97.110.151]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmur4vpmu-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:06 -0400 Received: from localhost by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 18:16:06 -0600 Received: from b03cxnp07028.gho.boulder.ibm.com (9.17.130.15) by e33.co.us.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 18:16:03 -0600 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0G3oU2687396; Mon, 28 Aug 2017 17:16:03 -0700 Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2454D6A03C; Mon, 28 Aug 2017 18:16:03 -0600 (MDT) Received: from localhost (unknown [9.80.85.217]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP id EF6E46A03D; Mon, 28 Aug 2017 18:16:02 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:11 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0008-0000-0000-0000087D385D X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:05 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0009-0000-0000-000043C046CF Message-Id: <1503965694-10794-37-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 36/79] s390x/css: catch section mismatch on load 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: Christian Borntraeger , Halil Pasic , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Halil Pasic Prior to the virtio-ccw-2.7 machine (and commit 2a79eb1a), our virtio devices residing under the virtual-css bus do not have qdev_path based migration stream identifiers (because their qdev_path is NULL). The ids are instead generated when the device is registered as a composition of the so called idstr, which takes the vmsd name as its value, and an instance_id, which is which is calculated as a maximal instance_id registered with the same idstr plus one, or zero (if none was registered previously). That means, under certain circumstances, one device might try, and even succeed, to load the state of a different device. This can lead to trouble. Let us fail the migration if the above problem is detected during load. How to reproduce the problem: 1) start qemu-system-s390x making sure you have the following devices defined on your command line: -device virtio-rng-ccw,id=rng1,devno=fe.0.0001 -device virtio-rng-ccw,id=rng2,devno=fe.0.0002 2) detach the devices and reattach in reverse order using the monitor: (qemu) device_del rng1 (qemu) device_del rng2 (qemu) device_add virtio-rng-ccw,id=rng2,devno=fe.0.0002 (qemu) device_add virtio-rng-ccw,id=rng1,devno=fe.0.0001 3) save the state of the vm into a temporary file and quit QEMU: (qemu) migrate "exec:gzip -c > /tmp/tmp_vmstate.gz" (qemu) q 4) use your command line from step 1 with -incoming "exec:gzip -c -d /tmp/tmp_vmstate.gz" appended to reproduce the problem (while trying to to load the saved vm) CC: qemu-stable@nongnu.org Signed-off-by: Halil Pasic Reviewed-by: Dong Jia Shi Reviewed-by: Cornelia Huck Message-Id: <20170518111405.56947-1-pasic@linux.vnet.ibm.com> Signed-off-by: Christian Borntraeger (cherry picked from commit 8ed179c937830143dc0e03daac30a55272ed89e3) * removed context dep on d8d98db5 Signed-off-by: Michael Roth --- hw/s390x/css.c | 14 ++++++++++++++ hw/s390x/virtio-ccw.c | 6 +++++- 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/hw/s390x/css.c b/hw/s390x/css.c index 37caa98..b24e8b7 100644 --- a/hw/s390x/css.c +++ b/hw/s390x/css.c @@ -14,6 +14,7 @@ #include "qapi/visitor.h" #include "hw/qdev.h" #include "qemu/bitops.h" +#include "qemu/error-report.h" #include "exec/address-spaces.h" #include "cpu.h" #include "hw/s390x/ioinst.h" @@ -1676,13 +1677,26 @@ void subch_device_save(SubchDev *s, QEMUFile *f) int subch_device_load(SubchDev *s, QEMUFile *f) { SubchDev *old_s; + Error *err = NULL; uint16_t old_schid = s->schid; + uint16_t old_devno = s->devno; int i; s->cssid = qemu_get_byte(f); s->ssid = qemu_get_byte(f); s->schid = qemu_get_be16(f); s->devno = qemu_get_be16(f); + if (s->devno != old_devno) { + /* Only possible if machine < 2.7 (no css_dev_path) */ + + error_setg(&err, "%x != %x", old_devno, s->devno); + error_append_hint(&err, "Devno mismatch, tried to load wrong section!" + " Likely reason: some sequences of plug and unplug" + " can break migration for machine versions prior to" + " 2.7 (known design flaw).\n"); + error_report_err(err); + return -EINVAL; + } /* Re-assign subch. */ if (old_schid != s->schid) { old_s = channel_subsys.css[s->cssid]->sch_set[s->ssid]->sch[old_schid]; diff --git a/hw/s390x/virtio-ccw.c b/hw/s390x/virtio-ccw.c index 00b3bde..c0c1db8 100644 --- a/hw/s390x/virtio-ccw.c +++ b/hw/s390x/virtio-ccw.c @@ -1264,9 +1264,13 @@ static int virtio_ccw_load_config(DeviceState *d, QEMUFile *f) SubchDev *s = ccw_dev->sch; VirtIODevice *vdev = virtio_ccw_get_vdev(s); int len; + int ret; s->driver_data = dev; - subch_device_load(s, f); + ret = subch_device_load(s, f); + if (ret) { + return ret; + } len = qemu_get_be32(f); if (len != 0) { dev->indicators = get_indicator(qemu_get_be64(f), len); From patchwork Tue Aug 29 00:14:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806829 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh8hY47LQz9sNc for ; Tue, 29 Aug 2017 10:31:41 +1000 (AEST) Received: from localhost ([::1]:41969 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmURP-0006ls-Cj for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:31:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:47982) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCR-0001F7-9e for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCO-0005Qp-4O for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:11 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:34164 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCN-0005QP-Vr for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:08 -0400 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0E7iZ017707 for ; Mon, 28 Aug 2017 20:16:07 -0400 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0b-001b2d01.pphosted.com with ESMTP id 2cmub2wvrt-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:07 -0400 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 18:16:06 -0600 Received: from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 18:16:04 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0G4Po30998654; Mon, 28 Aug 2017 17:16:04 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0367F78043; Mon, 28 Aug 2017 18:16:04 -0600 (MDT) Received: from localhost (unknown [9.80.85.217]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP id C76677804D; Mon, 28 Aug 2017 18:16:03 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:12 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-8235-0000-0000-00000C2FE7AB X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:06 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-8236-0000-0000-00003D6C06F9 Message-Id: <1503965694-10794-38-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 37/79] virtio-net: fix wild pointer when remove virtio-net queues 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: Jason Wang , Yunjian Wang , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Yunjian Wang The tx_bh or tx_timer will free in virtio_net_del_queue() function, when removing virtio-net queues if the guest doesn't support multiqueue. But it might be still referenced by virtio_net_set_status(), which needs to be set NULL. And also the tx_waiting needs to be set zero to prevent virtio_net_set_status() accessing tx_bh or tx_timer. Cc: qemu-stable@nongnu.org Signed-off-by: Yunjian Wang Signed-off-by: Jason Wang (cherry picked from commit f989c30cf834ba8625e98b808eac30e4e7ec5008) Signed-off-by: Michael Roth --- hw/net/virtio-net.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 7d091c9..98bd683 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -1522,9 +1522,12 @@ static void virtio_net_del_queue(VirtIONet *n, int index) if (q->tx_timer) { timer_del(q->tx_timer); timer_free(q->tx_timer); + q->tx_timer = NULL; } else { qemu_bh_delete(q->tx_bh); + q->tx_bh = NULL; } + q->tx_waiting = 0; virtio_del_queue(vdev, index * 2 + 1); } From patchwork Tue Aug 29 00:14:13 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806862 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh9BJ0gCdz9s7M for ; Tue, 29 Aug 2017 10:54:00 +1000 (AEST) Received: from localhost ([::1]:42095 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUmz-00013l-SU for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:53:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48055) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCT-0001Hl-Hl for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:16 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCQ-0005Sl-BP for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:13 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:53239 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCQ-0005SD-5r for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:10 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0E9gi081527 for ; Mon, 28 Aug 2017 20:16:09 -0400 Received: from e37.co.us.ibm.com (e37.co.us.ibm.com [32.97.110.158]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmurncrm9-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:09 -0400 Received: from localhost by e37.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 18:16:08 -0600 Received: from b03cxnp08026.gho.boulder.ibm.com (9.17.130.18) by e37.co.us.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 18:16:05 -0600 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0G5L762849082; Mon, 28 Aug 2017 17:16:05 -0700 Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DCBE7BE040; Mon, 28 Aug 2017 18:16:04 -0600 (MDT) Received: from localhost (unknown [9.80.85.217]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP id A9C12BE038; Mon, 28 Aug 2017 18:16:04 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:13 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0024-0000-0000-0000171CE4B8 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:07 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0025-0000-0000-00004C7F0529 Message-Id: <1503965694-10794-39-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 38/79] blkdebug: Sanity check block layer guarantees 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: qemu-stable@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Eric Blake Commits 04ed95f4 and 1a62d0ac updated the block layer to auto-fragment any I/O to fit within device boundaries. Additionally, when using a minimum alignment of 4k, we want to ensure the block layer does proper read-modify-write rather than requesting I/O on a slice of a sector. Let's enforce that the contract is obeyed when using blkdebug. For now, blkdebug only allows alignment overrides, and just inherits other limits from whatever device it is wrapping, but a future patch will further enhance things. Signed-off-by: Eric Blake Reviewed-by: Kevin Wolf Reviewed-by: Max Reitz Message-id: 20170429191419.30051-5-eblake@redhat.com Signed-off-by: Max Reitz (cherry picked from commit e0ef439588ce1ede747f82b77d893190c1cc9f4d) * prereq for 81c219a Signed-off-by: Michael Roth --- block/blkdebug.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/block/blkdebug.c b/block/blkdebug.c index 46bd08a..b2cee0c 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -429,6 +429,13 @@ blkdebug_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, BDRVBlkdebugState *s = bs->opaque; BlkdebugRule *rule = NULL; + /* Sanity check block layer guarantees */ + assert(QEMU_IS_ALIGNED(offset, bs->bl.request_alignment)); + assert(QEMU_IS_ALIGNED(bytes, bs->bl.request_alignment)); + if (bs->bl.max_transfer) { + assert(bytes <= bs->bl.max_transfer); + } + QSIMPLEQ_FOREACH(rule, &s->active_rules, active_next) { uint64_t inject_offset = rule->options.inject.offset; @@ -453,6 +460,13 @@ blkdebug_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, BDRVBlkdebugState *s = bs->opaque; BlkdebugRule *rule = NULL; + /* Sanity check block layer guarantees */ + assert(QEMU_IS_ALIGNED(offset, bs->bl.request_alignment)); + assert(QEMU_IS_ALIGNED(bytes, bs->bl.request_alignment)); + if (bs->bl.max_transfer) { + assert(bytes <= bs->bl.max_transfer); + } + QSIMPLEQ_FOREACH(rule, &s->active_rules, active_next) { uint64_t inject_offset = rule->options.inject.offset; From patchwork Tue Aug 29 00:14:14 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806825 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh8dZ6dwCz9s65 for ; Tue, 29 Aug 2017 10:29:06 +1000 (AEST) Received: from localhost ([::1]:41952 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUOu-0004F6-O1 for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:29:04 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48056) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCT-0001Hn-IR for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:14 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCQ-0005Su-L8 for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:13 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:34328 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCQ-0005Sh-F5 for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:10 -0400 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0E8S7017789 for ; Mon, 28 Aug 2017 20:16:10 -0400 Received: from e37.co.us.ibm.com (e37.co.us.ibm.com [32.97.110.158]) by mx0b-001b2d01.pphosted.com with ESMTP id 2cmub2wvt6-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:09 -0400 Received: from localhost by e37.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 18:16:08 -0600 Received: from b03cxnp08026.gho.boulder.ibm.com (9.17.130.18) by e37.co.us.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 18:16:06 -0600 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0G5dT62849094; Mon, 28 Aug 2017 17:16:05 -0700 Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C6DE0C6059; Mon, 28 Aug 2017 18:16:05 -0600 (MDT) Received: from localhost (unknown [9.80.85.217]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP id 914BBC604A; Mon, 28 Aug 2017 18:16:05 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:14 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0024-0000-0000-0000171CE4B9 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:08 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0025-0000-0000-00004C7F052C Message-Id: <1503965694-10794-40-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 39/79] blkdebug: Refactor error injection 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: qemu-stable@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Eric Blake Rather than repeat the logic at each caller of checking if a Rule exists that warrants an error injection, fold that logic into inject_error(); and rename it to rule_check() for legibility. This will help the next patch, which adds two more callers that need to check rules for the potential of injecting errors. Signed-off-by: Eric Blake Reviewed-by: Max Reitz Message-id: 20170429191419.30051-6-eblake@redhat.com Signed-off-by: Max Reitz (cherry picked from commit d157ed5f7235f3d2d5596a514ad7507b18e24b88) * prereq for 81c219a Signed-off-by: Michael Roth --- block/blkdebug.c | 74 +++++++++++++++++++++++++------------------------------- 1 file changed, 33 insertions(+), 41 deletions(-) diff --git a/block/blkdebug.c b/block/blkdebug.c index b2cee0c..c5d2edb 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -403,11 +403,30 @@ out: return ret; } -static int inject_error(BlockDriverState *bs, BlkdebugRule *rule) +static int rule_check(BlockDriverState *bs, uint64_t offset, uint64_t bytes) { BDRVBlkdebugState *s = bs->opaque; - int error = rule->options.inject.error; - bool immediately = rule->options.inject.immediately; + BlkdebugRule *rule = NULL; + int error; + bool immediately; + + QSIMPLEQ_FOREACH(rule, &s->active_rules, active_next) { + uint64_t inject_offset = rule->options.inject.offset; + + if (inject_offset == -1 || + (bytes && inject_offset >= offset && + inject_offset < offset + bytes)) + { + break; + } + } + + if (!rule || !rule->options.inject.error) { + return 0; + } + + immediately = rule->options.inject.immediately; + error = rule->options.inject.error; if (rule->options.inject.once) { QSIMPLEQ_REMOVE(&s->active_rules, rule, BlkdebugRule, active_next); @@ -426,8 +445,7 @@ static int coroutine_fn blkdebug_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags) { - BDRVBlkdebugState *s = bs->opaque; - BlkdebugRule *rule = NULL; + int err; /* Sanity check block layer guarantees */ assert(QEMU_IS_ALIGNED(offset, bs->bl.request_alignment)); @@ -436,18 +454,9 @@ blkdebug_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes, assert(bytes <= bs->bl.max_transfer); } - QSIMPLEQ_FOREACH(rule, &s->active_rules, active_next) { - uint64_t inject_offset = rule->options.inject.offset; - - if (inject_offset == -1 || - (inject_offset >= offset && inject_offset < offset + bytes)) - { - break; - } - } - - if (rule && rule->options.inject.error) { - return inject_error(bs, rule); + err = rule_check(bs, offset, bytes); + if (err) { + return err; } return bdrv_co_preadv(bs->file, offset, bytes, qiov, flags); @@ -457,8 +466,7 @@ static int coroutine_fn blkdebug_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, QEMUIOVector *qiov, int flags) { - BDRVBlkdebugState *s = bs->opaque; - BlkdebugRule *rule = NULL; + int err; /* Sanity check block layer guarantees */ assert(QEMU_IS_ALIGNED(offset, bs->bl.request_alignment)); @@ -467,18 +475,9 @@ blkdebug_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, assert(bytes <= bs->bl.max_transfer); } - QSIMPLEQ_FOREACH(rule, &s->active_rules, active_next) { - uint64_t inject_offset = rule->options.inject.offset; - - if (inject_offset == -1 || - (inject_offset >= offset && inject_offset < offset + bytes)) - { - break; - } - } - - if (rule && rule->options.inject.error) { - return inject_error(bs, rule); + err = rule_check(bs, offset, bytes); + if (err) { + return err; } return bdrv_co_pwritev(bs->file, offset, bytes, qiov, flags); @@ -486,17 +485,10 @@ blkdebug_co_pwritev(BlockDriverState *bs, uint64_t offset, uint64_t bytes, static int blkdebug_co_flush(BlockDriverState *bs) { - BDRVBlkdebugState *s = bs->opaque; - BlkdebugRule *rule = NULL; - - QSIMPLEQ_FOREACH(rule, &s->active_rules, active_next) { - if (rule->options.inject.offset == -1) { - break; - } - } + int err = rule_check(bs, 0, 0); - if (rule && rule->options.inject.error) { - return inject_error(bs, rule); + if (err) { + return err; } return bdrv_co_flush(bs->file->bs); From patchwork Tue Aug 29 00:14:15 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806866 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh9FG0qjtz9s7M for ; Tue, 29 Aug 2017 10:56:34 +1000 (AEST) Received: from localhost ([::1]:42110 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUpU-0003ZV-0O for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:56:32 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48114) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCV-0001KK-HJ for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCS-0005V2-Id for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:15 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:56461) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCS-0005U3-9h for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:12 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0EA97042733 for ; Mon, 28 Aug 2017 20:16:11 -0400 Received: from e15.ny.us.ibm.com (e15.ny.us.ibm.com [129.33.205.205]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmr8nf038-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:11 -0400 Received: from localhost by e15.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 20:16:09 -0400 Received: from b01cxnp23033.gho.pok.ibm.com (9.57.198.28) by e15.ny.us.ibm.com (146.89.104.202) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 20:16:07 -0400 Received: from b01ledav001.gho.pok.ibm.com (b01ledav001.gho.pok.ibm.com [9.57.199.106]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0G6v22752814; Tue, 29 Aug 2017 00:16:06 GMT Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E262D28056; Mon, 28 Aug 2017 20:15:59 -0400 (EDT) Received: from localhost (unknown [9.80.85.217]) by b01ledav001.gho.pok.ibm.com (Postfix) with ESMTP id B449F2803E; Mon, 28 Aug 2017 20:15:59 -0400 (EDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:15 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0036-0000-0000-000002603F70 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909027; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:08 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0037-0000-0000-000041964A75 Message-Id: <1503965694-10794-41-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 40/79] blkdebug: Add pass-through write_zero and discard support 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: qemu-stable@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Eric Blake In order to test the effects of artificial geometry constraints on operations like write zero or discard, we first need blkdebug to manage these actions. It also allows us to inject errors on those operations, just like we can for read/write/flush. We can also test the contract promised by the block layer; namely, if a device has specified limits on alignment or maximum size, then those limits must be obeyed (for now, the blkdebug driver merely inherits limits from whatever it is wrapping, but the next patch will further enhance it to allow specific limit overrides). This patch intentionally refuses to service requests smaller than the requested alignments; this is because an upcoming patch adds a qemu-iotest to prove that the block layer is correctly handling fragmentation, but the test only works if there is a way to tell the difference at artificial alignment boundaries when blkdebug is using a larger-than-default alignment. If we let the blkdebug layer always defer to the underlying layer, which potentially has a smaller granularity, the iotest will be thwarted. Tested by setting up an NBD server with export 'foo', then invoking: $ ./qemu-io qemu-io> open -o driver=blkdebug blkdebug::nbd://localhost:10809/foo qemu-io> d 0 15M qemu-io> w -z 0 15M Pre-patch, the server never sees the discard (it was silently eaten by the block layer); post-patch it is passed across the wire. Likewise, pre-patch the write is always passed with NBD_WRITE (with 15M of zeroes on the wire), while post-patch it can utilize NBD_WRITE_ZEROES (for less traffic). Signed-off-by: Eric Blake Reviewed-by: Max Reitz Message-id: 20170429191419.30051-7-eblake@redhat.com Signed-off-by: Max Reitz (cherry picked from commit 63188c245013dbe383e8b031e665f813e2452ea5) * prereq for 81c219a Signed-off-by: Michael Roth --- block/blkdebug.c | 74 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 74 insertions(+) diff --git a/block/blkdebug.c b/block/blkdebug.c index c5d2edb..a3dc5f6 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -1,6 +1,7 @@ /* * Block protocol for I/O error injection * + * Copyright (C) 2016-2017 Red Hat, Inc. * Copyright (c) 2010 Kevin Wolf * * Permission is hereby granted, free of charge, to any person obtaining a copy @@ -382,6 +383,11 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags, goto out; } + bs->supported_write_flags = BDRV_REQ_FUA & + bs->file->bs->supported_write_flags; + bs->supported_zero_flags = (BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP) & + bs->file->bs->supported_zero_flags; + /* Set request alignment */ align = qemu_opt_get_size(opts, "align", 0); if (align < INT_MAX && is_power_of_2(align)) { @@ -494,6 +500,72 @@ static int blkdebug_co_flush(BlockDriverState *bs) return bdrv_co_flush(bs->file->bs); } +static int coroutine_fn blkdebug_co_pwrite_zeroes(BlockDriverState *bs, + int64_t offset, int count, + BdrvRequestFlags flags) +{ + uint32_t align = MAX(bs->bl.request_alignment, + bs->bl.pwrite_zeroes_alignment); + int err; + + /* Only pass through requests that are larger than requested + * preferred alignment (so that we test the fallback to writes on + * unaligned portions), and check that the block layer never hands + * us anything unaligned that crosses an alignment boundary. */ + if (count < align) { + assert(QEMU_IS_ALIGNED(offset, align) || + QEMU_IS_ALIGNED(offset + count, align) || + DIV_ROUND_UP(offset, align) == + DIV_ROUND_UP(offset + count, align)); + return -ENOTSUP; + } + assert(QEMU_IS_ALIGNED(offset, align)); + assert(QEMU_IS_ALIGNED(count, align)); + if (bs->bl.max_pwrite_zeroes) { + assert(count <= bs->bl.max_pwrite_zeroes); + } + + err = rule_check(bs, offset, count); + if (err) { + return err; + } + + return bdrv_co_pwrite_zeroes(bs->file, offset, count, flags); +} + +static int coroutine_fn blkdebug_co_pdiscard(BlockDriverState *bs, + int64_t offset, int count) +{ + uint32_t align = bs->bl.pdiscard_alignment; + int err; + + /* Only pass through requests that are larger than requested + * minimum alignment, and ensure that unaligned requests do not + * cross optimum discard boundaries. */ + if (count < bs->bl.request_alignment) { + assert(QEMU_IS_ALIGNED(offset, align) || + QEMU_IS_ALIGNED(offset + count, align) || + DIV_ROUND_UP(offset, align) == + DIV_ROUND_UP(offset + count, align)); + return -ENOTSUP; + } + assert(QEMU_IS_ALIGNED(offset, bs->bl.request_alignment)); + assert(QEMU_IS_ALIGNED(count, bs->bl.request_alignment)); + if (align && count >= align) { + assert(QEMU_IS_ALIGNED(offset, align)); + assert(QEMU_IS_ALIGNED(count, align)); + } + if (bs->bl.max_pdiscard) { + assert(count <= bs->bl.max_pdiscard); + } + + err = rule_check(bs, offset, count); + if (err) { + return err; + } + + return bdrv_co_pdiscard(bs->file->bs, offset, count); +} static void blkdebug_close(BlockDriverState *bs) { @@ -748,6 +820,8 @@ static BlockDriver bdrv_blkdebug = { .bdrv_co_preadv = blkdebug_co_preadv, .bdrv_co_pwritev = blkdebug_co_pwritev, .bdrv_co_flush_to_disk = blkdebug_co_flush, + .bdrv_co_pwrite_zeroes = blkdebug_co_pwrite_zeroes, + .bdrv_co_pdiscard = blkdebug_co_pdiscard, .bdrv_debug_event = blkdebug_debug_event, .bdrv_debug_breakpoint = blkdebug_debug_breakpoint, From patchwork Tue Aug 29 00:14:16 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806842 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh8rK3xvJz9s4s for ; Tue, 29 Aug 2017 10:38:25 +1000 (AEST) Received: from localhost ([::1]:42007 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUXv-00049m-9y for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:38:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48134) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCV-0001Ku-Sq for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCS-0005VD-LI for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:15 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:53332 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCS-0005Ue-GS for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:12 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0E9gk081527 for ; Mon, 28 Aug 2017 20:16:12 -0400 Received: from e11.ny.us.ibm.com (e11.ny.us.ibm.com [129.33.205.201]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmurncrp0-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:11 -0400 Received: from localhost by e11.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 20:16:11 -0400 Received: from b01cxnp22033.gho.pok.ibm.com (9.57.198.23) by e11.ny.us.ibm.com (146.89.104.198) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 20:16:08 -0400 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0G7ap12976144; Tue, 29 Aug 2017 00:16:07 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id C6DB2B2052; Mon, 28 Aug 2017 20:13:31 -0400 (EDT) Received: from localhost (unknown [9.80.85.217]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP id 8F952B204E; Mon, 28 Aug 2017 20:13:31 -0400 (EDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:16 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-2213-0000-0000-00000210D364 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909027; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:10 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-2214-0000-0000-0000575DED06 Message-Id: <1503965694-10794-42-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 41/79] blkdebug: Simplify override logic 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: qemu-stable@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Eric Blake Rather than store into a local variable, then copy to the struct if the value is valid, then reporting errors otherwise, it is simpler to just store into the struct and report errors if the value is invalid. This however requires that the struct store a 64-bit number, rather than a narrower type. Likewise, setting a sane errno value in ret prior to the sequence of parsing and jumping to out: on error makes it easier for the next patch to add a chain of similar checks. Signed-off-by: Eric Blake Message-id: 20170429191419.30051-8-eblake@redhat.com Reviewed-by: Max Reitz Signed-off-by: Max Reitz (cherry picked from commit 3dc834f8795a46f919d90b1e5369308628858601) * prereq for 81c219a Signed-off-by: Michael Roth --- block/blkdebug.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/block/blkdebug.c b/block/blkdebug.c index a3dc5f6..2b934ef 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -38,7 +38,7 @@ typedef struct BDRVBlkdebugState { int state; int new_state; - int align; + uint64_t align; /* For blkdebug_refresh_filename() */ char *config_file; @@ -353,7 +353,6 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags, BDRVBlkdebugState *s = bs->opaque; QemuOpts *opts; Error *local_err = NULL; - uint64_t align; int ret; opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); @@ -387,20 +386,17 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags, bs->file->bs->supported_write_flags; bs->supported_zero_flags = (BDRV_REQ_FUA | BDRV_REQ_MAY_UNMAP) & bs->file->bs->supported_zero_flags; + ret = -EINVAL; /* Set request alignment */ - align = qemu_opt_get_size(opts, "align", 0); - if (align < INT_MAX && is_power_of_2(align)) { - s->align = align; - } else if (align) { - error_setg(errp, "Invalid alignment"); - ret = -EINVAL; + s->align = qemu_opt_get_size(opts, "align", 0); + if (s->align && (s->align >= INT_MAX || !is_power_of_2(s->align))) { + error_setg(errp, "Cannot meet constraints with align %" PRIu64, + s->align); goto out; } ret = 0; - goto out; - out: if (ret < 0) { g_free(s->config_file); From patchwork Tue Aug 29 00:14:17 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806835 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh8mT18p2z9s4s for ; Tue, 29 Aug 2017 10:35:05 +1000 (AEST) Received: from localhost ([::1]:41982 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUUh-0000zz-0t for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:35:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48115) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCV-0001KN-Hd for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:18 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCT-0005VW-0C for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:15 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:57214 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCS-0005V6-Qx for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:12 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0E9EA099569 for ; Mon, 28 Aug 2017 20:16:12 -0400 Received: from e15.ny.us.ibm.com (e15.ny.us.ibm.com [129.33.205.205]) by mx0b-001b2d01.pphosted.com with ESMTP id 2cmr22yk7w-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:12 -0400 Received: from localhost by e15.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 20:16:11 -0400 Received: from b01cxnp22033.gho.pok.ibm.com (9.57.198.23) by e15.ny.us.ibm.com (146.89.104.202) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 20:16:08 -0400 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0G75f23593076; Tue, 29 Aug 2017 00:16:08 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id BD70C112056; Mon, 28 Aug 2017 20:15:54 -0400 (EDT) Received: from localhost (unknown [9.80.85.217]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP id 843BA112054; Mon, 28 Aug 2017 20:15:54 -0400 (EDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:17 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0036-0000-0000-000002603F74 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909027; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:10 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0037-0000-0000-000041964A7C Message-Id: <1503965694-10794-43-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 42/79] blkdebug: Add ability to override unmap geometries 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: qemu-stable@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Eric Blake Make it easier to simulate various unusual hardware setups (for example, recent commits 3482b9b and b8d0a98 affect the Dell Equallogic iSCSI with its 15M preferred and maximum unmap and write zero sizing, or b2f95fe deals with the Linux loopback block device having a max_transfer of 64k), by allowing blkdebug to wrap any other device with further restrictions on various alignments. Signed-off-by: Eric Blake Reviewed-by: Max Reitz Message-id: 20170429191419.30051-9-eblake@redhat.com Signed-off-by: Max Reitz (cherry picked from commit 430b26a82da61876c4eaf559ae02332582968043) * prereq for 81c219a Signed-off-by: Michael Roth --- block/blkdebug.c | 96 +++++++++++++++++++++++++++++++++++++++++++++++++++- qapi/block-core.json | 33 ++++++++++++++++-- 2 files changed, 125 insertions(+), 4 deletions(-) diff --git a/block/blkdebug.c b/block/blkdebug.c index 2b934ef..5ccb9ce 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -39,6 +39,11 @@ typedef struct BDRVBlkdebugState { int state; int new_state; uint64_t align; + uint64_t max_transfer; + uint64_t opt_write_zero; + uint64_t max_write_zero; + uint64_t opt_discard; + uint64_t max_discard; /* For blkdebug_refresh_filename() */ char *config_file; @@ -343,6 +348,31 @@ static QemuOptsList runtime_opts = { .type = QEMU_OPT_SIZE, .help = "Required alignment in bytes", }, + { + .name = "max-transfer", + .type = QEMU_OPT_SIZE, + .help = "Maximum transfer size in bytes", + }, + { + .name = "opt-write-zero", + .type = QEMU_OPT_SIZE, + .help = "Optimum write zero alignment in bytes", + }, + { + .name = "max-write-zero", + .type = QEMU_OPT_SIZE, + .help = "Maximum write zero size in bytes", + }, + { + .name = "opt-discard", + .type = QEMU_OPT_SIZE, + .help = "Optimum discard alignment in bytes", + }, + { + .name = "max-discard", + .type = QEMU_OPT_SIZE, + .help = "Maximum discard size in bytes", + }, { /* end of list */ } }, }; @@ -354,6 +384,7 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags, QemuOpts *opts; Error *local_err = NULL; int ret; + uint64_t align; opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(opts, options, &local_err); @@ -388,13 +419,61 @@ static int blkdebug_open(BlockDriverState *bs, QDict *options, int flags, bs->file->bs->supported_zero_flags; ret = -EINVAL; - /* Set request alignment */ + /* Set alignment overrides */ s->align = qemu_opt_get_size(opts, "align", 0); if (s->align && (s->align >= INT_MAX || !is_power_of_2(s->align))) { error_setg(errp, "Cannot meet constraints with align %" PRIu64, s->align); goto out; } + align = MAX(s->align, bs->file->bs->bl.request_alignment); + + s->max_transfer = qemu_opt_get_size(opts, "max-transfer", 0); + if (s->max_transfer && + (s->max_transfer >= INT_MAX || + !QEMU_IS_ALIGNED(s->max_transfer, align))) { + error_setg(errp, "Cannot meet constraints with max-transfer %" PRIu64, + s->max_transfer); + goto out; + } + + s->opt_write_zero = qemu_opt_get_size(opts, "opt-write-zero", 0); + if (s->opt_write_zero && + (s->opt_write_zero >= INT_MAX || + !QEMU_IS_ALIGNED(s->opt_write_zero, align))) { + error_setg(errp, "Cannot meet constraints with opt-write-zero %" PRIu64, + s->opt_write_zero); + goto out; + } + + s->max_write_zero = qemu_opt_get_size(opts, "max-write-zero", 0); + if (s->max_write_zero && + (s->max_write_zero >= INT_MAX || + !QEMU_IS_ALIGNED(s->max_write_zero, + MAX(s->opt_write_zero, align)))) { + error_setg(errp, "Cannot meet constraints with max-write-zero %" PRIu64, + s->max_write_zero); + goto out; + } + + s->opt_discard = qemu_opt_get_size(opts, "opt-discard", 0); + if (s->opt_discard && + (s->opt_discard >= INT_MAX || + !QEMU_IS_ALIGNED(s->opt_discard, align))) { + error_setg(errp, "Cannot meet constraints with opt-discard %" PRIu64, + s->opt_discard); + goto out; + } + + s->max_discard = qemu_opt_get_size(opts, "max-discard", 0); + if (s->max_discard && + (s->max_discard >= INT_MAX || + !QEMU_IS_ALIGNED(s->max_discard, + MAX(s->opt_discard, align)))) { + error_setg(errp, "Cannot meet constraints with max-discard %" PRIu64, + s->max_discard); + goto out; + } ret = 0; out: @@ -789,6 +868,21 @@ static void blkdebug_refresh_limits(BlockDriverState *bs, Error **errp) if (s->align) { bs->bl.request_alignment = s->align; } + if (s->max_transfer) { + bs->bl.max_transfer = s->max_transfer; + } + if (s->opt_write_zero) { + bs->bl.pwrite_zeroes_alignment = s->opt_write_zero; + } + if (s->max_write_zero) { + bs->bl.max_pwrite_zeroes = s->max_write_zero; + } + if (s->opt_discard) { + bs->bl.pdiscard_alignment = s->opt_discard; + } + if (s->max_discard) { + bs->bl.max_pdiscard = s->max_discard; + } } static int blkdebug_reopen_prepare(BDRVReopenState *reopen_state, diff --git a/qapi/block-core.json b/qapi/block-core.json index 033457c..38edada 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -2428,8 +2428,33 @@ # # @config: filename of the configuration file # -# @align: required alignment for requests in bytes, -# must be power of 2, or 0 for default +# @align: required alignment for requests in bytes, must be +# positive power of 2, or 0 for default +# +# @max-transfer: maximum size for I/O transfers in bytes, must be +# positive multiple of @align and of the underlying +# file's request alignment (but need not be a power of +# 2), or 0 for default (since 2.10) +# +# @opt-write-zero: preferred alignment for write zero requests in bytes, +# must be positive multiple of @align and of the +# underlying file's request alignment (but need not be a +# power of 2), or 0 for default (since 2.10) +# +# @max-write-zero: maximum size for write zero requests in bytes, must be +# positive multiple of @align, of @opt-write-zero, and of +# the underlying file's request alignment (but need not +# be a power of 2), or 0 for default (since 2.10) +# +# @opt-discard: preferred alignment for discard requests in bytes, must +# be positive multiple of @align and of the underlying +# file's request alignment (but need not be a power of +# 2), or 0 for default (since 2.10) +# +# @max-discard: maximum size for discard requests in bytes, must be +# positive multiple of @align, of @opt-discard, and of +# the underlying file's request alignment (but need not +# be a power of 2), or 0 for default (since 2.10) # # @inject-error: array of error injection descriptions # @@ -2440,7 +2465,9 @@ { 'struct': 'BlockdevOptionsBlkdebug', 'data': { 'image': 'BlockdevRef', '*config': 'str', - '*align': 'int', + '*align': 'int', '*max-transfer': 'int32', + '*opt-write-zero': 'int32', '*max-write-zero': 'int32', + '*opt-discard': 'int32', '*max-discard': 'int32', '*inject-error': ['BlkdebugInjectErrorOptions'], '*set-state': ['BlkdebugSetStateOptions'] } } From patchwork Tue Aug 29 00:14:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806856 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh95s30Chz9s7M for ; Tue, 29 Aug 2017 10:50:09 +1000 (AEST) Received: from localhost ([::1]:42074 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUjH-00067s-8H for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:50:07 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48183) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCX-0001NO-MB for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCU-0005Xm-Cv for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:17 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:57759) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCU-0005WE-3I for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:14 -0400 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0E8Mc041503 for ; Mon, 28 Aug 2017 20:16:13 -0400 Received: from e16.ny.us.ibm.com (e16.ny.us.ibm.com [129.33.205.206]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmsrsj1q9-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:13 -0400 Received: from localhost by e16.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 20:16:11 -0400 Received: from b01cxnp23034.gho.pok.ibm.com (9.57.198.29) by e16.ny.us.ibm.com (146.89.104.203) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 20:16:09 -0400 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0G9v723331044; Tue, 29 Aug 2017 00:16:09 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A5DB1AE04E; Mon, 28 Aug 2017 20:16:32 -0400 (EDT) Received: from localhost (unknown [9.80.85.217]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTP id 783F9AE034; Mon, 28 Aug 2017 20:16:32 -0400 (EDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:18 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0024-0000-0000-000002C6D2AE X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:11 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0025-0000-0000-0000453E6332 Message-Id: <1503965694-10794-44-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 43/79] tests: Add coverage for recent block geometry fixes 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: qemu-stable@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Eric Blake Use blkdebug's new geometry constraints to emulate setups that have needed past regression fixes: write zeroes asserting when running through a loopback block device with max-transfer smaller than cluster size, and discard rounding away portions of requests not aligned to preferred boundaries. Also, add coverage that the block layer is honoring max transfer limits. For now, a single iotest performs all actions, with the idea that we can add future blkdebug constraint test cases in the same file; but it can be split into multiple iotests if we find reason to run one portion of the test in more setups than what are possible in the other. For reference, the final portion of the test (checking whether discard passes as much as possible to the lowest layers of the stack) works as follows: qemu-io: discard 30M at 80000001, passed to blkdebug blkdebug: discard 511 bytes at 80000001, -ENOTSUP (smaller than blkdebug's 512 align) blkdebug: discard 14371328 bytes at 80000512, passed to qcow2 qcow2: discard 739840 bytes at 80000512, -ENOTSUP (smaller than qcow2's 1M align) qcow2: discard 13M bytes at 77M, succeeds blkdebug: discard 15M bytes at 90M, passed to qcow2 qcow2: discard 15M bytes at 90M, succeeds blkdebug: discard 1356800 bytes at 105M, passed to qcow2 qcow2: discard 1M at 105M, succeeds qcow2: discard 308224 bytes at 106M, -ENOTSUP (smaller than qcow2's 1M align) blkdebug: discard 1 byte at 111457280, -ENOTSUP (smaller than blkdebug's 512 align) Signed-off-by: Eric Blake Reviewed-by: Max Reitz Message-id: 20170429191419.30051-10-eblake@redhat.com [mreitz: For cooperation with image locking, add -r to the qemu-io invocation which verifies the image content] Signed-off-by: Max Reitz (cherry picked from commit 40812d937392fddc11f72a668aef251039cc15ce) Conflicts: tests/qemu-iotests/group * dropped context dependency on other test groups * prereq for 81c219a Signed-off-by: Michael Roth --- tests/qemu-iotests/177 | 114 +++++++++++++++++++++++++++++++++++++++++++++ tests/qemu-iotests/177.out | 49 +++++++++++++++++++ tests/qemu-iotests/group | 1 + 3 files changed, 164 insertions(+) create mode 100755 tests/qemu-iotests/177 create mode 100644 tests/qemu-iotests/177.out diff --git a/tests/qemu-iotests/177 b/tests/qemu-iotests/177 new file mode 100755 index 0000000..2005c17 --- /dev/null +++ b/tests/qemu-iotests/177 @@ -0,0 +1,114 @@ +#!/bin/bash +# +# Test corner cases with unusual block geometries +# +# Copyright (C) 2016-2017 Red Hat, Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . +# + +# creator +owner=eblake@redhat.com + +seq=`basename $0` +echo "QA output created by $seq" + +here=`pwd` +status=1 # failure is the default! + +_cleanup() +{ + _cleanup_test_img +} +trap "_cleanup; exit \$status" 0 1 2 3 15 + +# get standard environment, filters and checks +. ./common.rc +. ./common.filter + +_supported_fmt qcow2 +_supported_proto file + +CLUSTER_SIZE=1M +size=128M +options=driver=blkdebug,image.driver=qcow2 + +echo +echo "== setting up files ==" + +TEST_IMG="$TEST_IMG.base" _make_test_img $size +$QEMU_IO -c "write -P 11 0 $size" "$TEST_IMG.base" | _filter_qemu_io +_make_test_img -b "$TEST_IMG.base" +$QEMU_IO -c "write -P 22 0 $size" "$TEST_IMG" | _filter_qemu_io + +# Limited to 64k max-transfer +echo +echo "== constrained alignment and max-transfer ==" +limits=align=4k,max-transfer=64k +$QEMU_IO -c "open -o $options,$limits blkdebug::$TEST_IMG" \ + -c "write -P 33 1000 128k" -c "read -P 33 1000 128k" | _filter_qemu_io + +echo +echo "== write zero with constrained max-transfer ==" +limits=align=512,max-transfer=64k,opt-write-zero=$CLUSTER_SIZE +$QEMU_IO -c "open -o $options,$limits blkdebug::$TEST_IMG" \ + -c "write -z 8003584 2093056" | _filter_qemu_io + +# non-power-of-2 write-zero/discard alignments +echo +echo "== non-power-of-2 write zeroes limits ==" + +limits=align=512,opt-write-zero=15M,max-write-zero=15M,opt-discard=15M,max-discard=15M +$QEMU_IO -c "open -o $options,$limits blkdebug::$TEST_IMG" \ + -c "write -z 32M 32M" | _filter_qemu_io + +echo +echo "== non-power-of-2 discard limits ==" + +limits=align=512,opt-write-zero=15M,max-write-zero=15M,opt-discard=15M,max-discard=15M +$QEMU_IO -c "open -o $options,$limits blkdebug::$TEST_IMG" \ + -c "discard 80000001 30M" | _filter_qemu_io + +echo +echo "== verify image content ==" + +function verify_io() +{ + if ($QEMU_IMG info -f "$IMGFMT" "$TEST_IMG" | + grep "compat: 0.10" > /dev/null); then + # For v2 images, discarded clusters are read from the backing file + discarded=11 + else + # Discarded clusters are zeroed for v3 or later + discarded=0 + fi + + echo read -P 22 0 1000 + echo read -P 33 1000 128k + echo read -P 22 132072 7871512 + echo read -P 0 8003584 2093056 + echo read -P 22 10096640 23457792 + echo read -P 0 32M 32M + echo read -P 22 64M 13M + echo read -P $discarded 77M 29M + echo read -P 22 106M 22M +} + +verify_io | $QEMU_IO -r "$TEST_IMG" | _filter_qemu_io + +_check_test_img + +# success, all done +echo "*** done" +status=0 diff --git a/tests/qemu-iotests/177.out b/tests/qemu-iotests/177.out new file mode 100644 index 0000000..e887542 --- /dev/null +++ b/tests/qemu-iotests/177.out @@ -0,0 +1,49 @@ +QA output created by 177 + +== setting up files == +Formatting 'TEST_DIR/t.IMGFMT.base', fmt=IMGFMT size=134217728 +wrote 134217728/134217728 bytes at offset 0 +128 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +Formatting 'TEST_DIR/t.IMGFMT', fmt=IMGFMT size=134217728 backing_file=TEST_DIR/t.IMGFMT.base +wrote 134217728/134217728 bytes at offset 0 +128 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +== constrained alignment and max-transfer == +wrote 131072/131072 bytes at offset 1000 +128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 131072/131072 bytes at offset 1000 +128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +== write zero with constrained max-transfer == +wrote 2093056/2093056 bytes at offset 8003584 +1.996 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +== non-power-of-2 write zeroes limits == +wrote 33554432/33554432 bytes at offset 33554432 +32 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +== non-power-of-2 discard limits == +discard 31457280/31457280 bytes at offset 80000001 +30 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) + +== verify image content == +read 1000/1000 bytes at offset 0 +1000 bytes, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 131072/131072 bytes at offset 1000 +128 KiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 7871512/7871512 bytes at offset 132072 +7.507 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 2093056/2093056 bytes at offset 8003584 +1.996 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 23457792/23457792 bytes at offset 10096640 +22.371 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 33554432/33554432 bytes at offset 33554432 +32 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 13631488/13631488 bytes at offset 67108864 +13 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 30408704/30408704 bytes at offset 80740352 +29 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +read 23068672/23068672 bytes at offset 111149056 +22 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +No errors were found on the image. +*** done diff --git a/tests/qemu-iotests/group b/tests/qemu-iotests/group index 43142dd..a513ec7 100644 --- a/tests/qemu-iotests/group +++ b/tests/qemu-iotests/group @@ -169,3 +169,4 @@ 174 auto 175 auto quick 176 rw auto backing +177 rw auto quick From patchwork Tue Aug 29 00:14:19 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806833 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh8m45H05z9sNc for ; Tue, 29 Aug 2017 10:34:44 +1000 (AEST) Received: from localhost ([::1]:41981 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUUM-0000jO-I5 for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:34:42 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48215) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCY-0001OO-G6 for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:19 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCV-0005bq-QC for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:18 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:38739) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCV-0005Yy-FY for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:15 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0E68p090042 for ; Mon, 28 Aug 2017 20:16:14 -0400 Received: from e14.ny.us.ibm.com (e14.ny.us.ibm.com [129.33.205.204]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmvyehkkn-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:14 -0400 Received: from localhost by e14.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 20:16:12 -0400 Received: from b01cxnp22033.gho.pok.ibm.com (9.57.198.23) by e14.ny.us.ibm.com (146.89.104.201) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 20:16:10 -0400 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0G9uf23920796; Tue, 29 Aug 2017 00:16:09 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DD042AC03F; Mon, 28 Aug 2017 20:16:33 -0400 (EDT) Received: from localhost (unknown [9.80.85.217]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP id A5271AC04A; Mon, 28 Aug 2017 20:16:33 -0400 (EDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:19 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0052-0000-0000-00000257335F X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:11 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0053-0000-0000-000051D1D973 Message-Id: <1503965694-10794-45-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 44/79] block: Simplify BDRV_BLOCK_RAW recursion 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: qemu-stable@nongnu.org, Stefan Hajnoczi Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Eric Blake Since we are already in coroutine context during the body of bdrv_co_get_block_status(), we can shave off a few layers of wrappers when recursing to query the protocol when a format driver returned BDRV_BLOCK_RAW. Note that we are already using the correct recursion later on in the same function, when probing whether the protocol layer is sparse in order to find out if we can add BDRV_BLOCK_ZERO to an existing BDRV_BLOCK_DATA|BDRV_BLOCK_OFFSET_VALID. Signed-off-by: Eric Blake Reviewed-by: Max Reitz Reviewed-by: Fam Zheng Message-id: 20170504173745.27414-1-eblake@redhat.com Signed-off-by: Stefan Hajnoczi (cherry picked from commit ee29d6adefcca7e76abb124183814ed3acc74fac) * prereq for 81c219a Signed-off-by: Michael Roth --- block/io.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/io.c b/block/io.c index a7142e0..fe0c867 100644 --- a/block/io.c +++ b/block/io.c @@ -1792,8 +1792,8 @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs, if (ret & BDRV_BLOCK_RAW) { assert(ret & BDRV_BLOCK_OFFSET_VALID); - ret = bdrv_get_block_status(*file, ret >> BDRV_SECTOR_BITS, - *pnum, pnum, file); + ret = bdrv_co_get_block_status(*file, ret >> BDRV_SECTOR_BITS, + *pnum, pnum, file); goto out; } From patchwork Tue Aug 29 00:14:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806870 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh9LQ5rChz9sP5 for ; Tue, 29 Aug 2017 11:01:02 +1000 (AEST) Received: from localhost ([::1]:42137 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUto-0007Mf-KS for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 21:01:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48241) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCZ-0001PX-9o for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCW-0005cX-0Z for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:19 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:49574) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCV-0005ZP-LV for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:15 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0FxG6009445 for ; Mon, 28 Aug 2017 20:16:14 -0400 Received: from e38.co.us.ibm.com (e38.co.us.ibm.com [32.97.110.159]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmvjejkke-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:14 -0400 Received: from localhost by e38.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 18:16:13 -0600 Received: from b03cxnp07029.gho.boulder.ibm.com (9.17.130.16) by e38.co.us.ibm.com (192.168.1.138) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 18:16:11 -0600 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0GAhC7733724; Mon, 28 Aug 2017 17:16:10 -0700 Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 816766E038; Mon, 28 Aug 2017 18:16:10 -0600 (MDT) Received: from localhost (unknown [9.80.85.217]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP id 4EE596E041; Mon, 28 Aug 2017 18:16:10 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:20 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0028-0000-0000-00000846DB3A X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:12 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0029-0000-0000-000037553151 Message-Id: <1503965694-10794-46-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 45/79] block: Guarantee that *file is set on bdrv_get_block_status() 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 , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Eric Blake We document that *file is valid if the return is not an error and includes BDRV_BLOCK_OFFSET_VALID, but forgot to obey this contract when a driver (such as blkdebug) lacks a callback. Messed up in commit 67a0fd2 (v2.6), when we added the file parameter. Enhance qemu-iotest 177 to cover this, using a sequence that would print garbage or even SEGV, because it was dererefencing through uninitialized memory. [The resulting test output shows that we have less-than-ideal block status from the blkdebug driver, but that's a separate fix coming up soon.] Setting *file on all paths that return BDRV_BLOCK_OFFSET_VALID is enough to fix the crash, but we can go one step further: always setting *file, even on error, means that a broken caller that blindly dereferences file without checking for error is now more likely to get a reliable SEGV instead of randomly acting on garbage, making it easier to diagnose such buggy callers. Adding an assertion that file is set where expected doesn't hurt either. CC: qemu-stable@nongnu.org Signed-off-by: Eric Blake Reviewed-by: Fam Zheng Reviewed-by: Max Reitz Reviewed-by: John Snow Signed-off-by: Kevin Wolf (cherry picked from commit 81c219ac6ce0d6182e35f3976f2caa4cefcaf9f0) Signed-off-by: Michael Roth --- block/io.c | 5 +++-- tests/qemu-iotests/177 | 3 +++ tests/qemu-iotests/177.out | 2 ++ 3 files changed, 8 insertions(+), 2 deletions(-) diff --git a/block/io.c b/block/io.c index fe0c867..a8589ee 100644 --- a/block/io.c +++ b/block/io.c @@ -1757,6 +1757,7 @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs, int64_t n; int64_t ret, ret2; + *file = NULL; total_sectors = bdrv_nb_sectors(bs); if (total_sectors < 0) { return total_sectors; @@ -1777,11 +1778,11 @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs, ret = BDRV_BLOCK_DATA | BDRV_BLOCK_ALLOCATED; if (bs->drv->protocol_name) { ret |= BDRV_BLOCK_OFFSET_VALID | (sector_num * BDRV_SECTOR_SIZE); + *file = bs; } return ret; } - *file = NULL; bdrv_inc_in_flight(bs); ret = bs->drv->bdrv_co_get_block_status(bs, sector_num, nb_sectors, pnum, file); @@ -1791,7 +1792,7 @@ static int64_t coroutine_fn bdrv_co_get_block_status(BlockDriverState *bs, } if (ret & BDRV_BLOCK_RAW) { - assert(ret & BDRV_BLOCK_OFFSET_VALID); + assert(ret & BDRV_BLOCK_OFFSET_VALID && *file); ret = bdrv_co_get_block_status(*file, ret >> BDRV_SECTOR_BITS, *pnum, pnum, file); goto out; diff --git a/tests/qemu-iotests/177 b/tests/qemu-iotests/177 index 2005c17..f8ed8fb 100755 --- a/tests/qemu-iotests/177 +++ b/tests/qemu-iotests/177 @@ -43,6 +43,7 @@ _supported_proto file CLUSTER_SIZE=1M size=128M options=driver=blkdebug,image.driver=qcow2 +nested_opts=image.file.driver=file,image.file.filename=$TEST_IMG echo echo "== setting up files ==" @@ -106,6 +107,8 @@ function verify_io() } verify_io | $QEMU_IO -r "$TEST_IMG" | _filter_qemu_io +$QEMU_IMG map --image-opts "$options,$nested_opts,align=4k" \ + | _filter_qemu_img_map _check_test_img diff --git a/tests/qemu-iotests/177.out b/tests/qemu-iotests/177.out index e887542..fcfbfa3 100644 --- a/tests/qemu-iotests/177.out +++ b/tests/qemu-iotests/177.out @@ -45,5 +45,7 @@ read 30408704/30408704 bytes at offset 80740352 29 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) read 23068672/23068672 bytes at offset 111149056 22 MiB, X ops; XX:XX:XX.X (XXX YYY/sec and XXX ops/sec) +Offset Length File +0 0x8000000 json:{"image": {"driver": "IMGFMT", "file": {"driver": "file", "filename": "TEST_DIR/t.IMGFMT"}}, "driver": "blkdebug", "align": "4k"} No errors were found on the image. *** done From patchwork Tue Aug 29 00:14:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806846 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh8vL51mpz9s4s for ; Tue, 29 Aug 2017 10:41:02 +1000 (AEST) Received: from localhost ([::1]:42020 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUaS-0006SU-HM for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:41:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48245) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCZ-0001Pw-Hy for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:20 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCW-0005eD-SP for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:19 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:52122) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCW-0005c8-H8 for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:16 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0FNJl080780 for ; Mon, 28 Aug 2017 20:16:15 -0400 Received: from e38.co.us.ibm.com (e38.co.us.ibm.com [32.97.110.159]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmnx0yv53-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:15 -0400 Received: from localhost by e38.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 18:16:14 -0600 Received: from b03cxnp08025.gho.boulder.ibm.com (9.17.130.17) by e38.co.us.ibm.com (192.168.1.138) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 18:16:11 -0600 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0GBUt524716; Mon, 28 Aug 2017 17:16:11 -0700 Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6B53113603C; Mon, 28 Aug 2017 18:16:11 -0600 (MDT) Received: from localhost (unknown [9.80.85.217]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP id 37B5613603A; Mon, 28 Aug 2017 18:16:11 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:21 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0028-0000-0000-00000846DB3B X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:13 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0029-0000-0000-000037553153 Message-Id: <1503965694-10794-47-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 46/79] mirror: Drop permissions on s->target on completion 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 , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Kevin Wolf This fixes an assertion failure that was triggered by qemu-iotests 129 on some CI host, while the same test case didn't seem to fail on other hosts. Essentially the problem is that the blk_unref(s->target) in mirror_exit() doesn't necessarily mean that the BlockBackend goes away immediately. It is possible that the job completion was triggered nested in mirror_drain(), which looks like this: BlockBackend *target = s->target; blk_ref(target); blk_drain(target); blk_unref(target); In this case, the write permissions for s->target are retained until after blk_drain(), which makes removing mirror_top_bs fail for the active commit case (can't have a writable backing file in the chain without the filter driver). Explicitly dropping the permissions first means that the additional reference doesn't hurt and the job can complete successfully even if called from the nested blk_drain(). Cc: qemu-stable@nongnu.org Signed-off-by: Kevin Wolf Acked-by: Paolo Bonzini Reviewed-by: Max Reitz (cherry picked from commit 63c8ef289087a225d445319d047501d4fe593687) Signed-off-by: Michael Roth --- block/mirror.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/block/mirror.c b/block/mirror.c index 2173a2f..4e8f124 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -514,7 +514,12 @@ static void mirror_exit(BlockJob *job, void *opaque) /* Remove target parent that still uses BLK_PERM_WRITE/RESIZE before * inserting target_bs at s->to_replace, where we might not be able to get - * these permissions. */ + * these permissions. + * + * Note that blk_unref() alone doesn't necessarily drop permissions because + * we might be running nested inside mirror_drain(), which takes an extra + * reference, so use an explicit blk_set_perm() first. */ + blk_set_perm(s->target, 0, BLK_PERM_ALL, &error_abort); blk_unref(s->target); s->target = NULL; From patchwork Tue Aug 29 00:14:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806839 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh8qT4Bw8z9sNc for ; Tue, 29 Aug 2017 10:37:41 +1000 (AEST) Received: from localhost ([::1]:42001 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUXD-0003Xc-7P for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:37:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48266) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCa-0001Qm-7a for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCW-0005dq-LA for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:20 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:49611) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCW-0005bN-9Z for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:16 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0E8hL005492 for ; Mon, 28 Aug 2017 20:16:15 -0400 Received: from e35.co.us.ibm.com (e35.co.us.ibm.com [32.97.110.153]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmvjejkm8-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:15 -0400 Received: from localhost by e35.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 18:16:14 -0600 Received: from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e35.co.us.ibm.com (192.168.1.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 18:16:12 -0600 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0GCKA32112770; Mon, 28 Aug 2017 17:16:12 -0700 Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4CAC46A042; Mon, 28 Aug 2017 18:16:12 -0600 (MDT) Received: from localhost (unknown [9.80.85.217]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP id 1A6B76A03D; Mon, 28 Aug 2017 18:16:12 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:22 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0012-0000-0000-000014ECDC48 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909027; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:14 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0013-0000-0000-00004F43FB3A Message-Id: <1503965694-10794-48-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 47/79] virtio-serial-bus: Unset hotplug handler when unrealize 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: Ladi Prosek , qemu-stable@nongnu.org, "Michael S . Tsirkin" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Ladi Prosek Virtio serial device controls the lifetime of virtio-serial-bus and virtio-serial-bus links back to the device via its hotplug-handler property. This extra ref-count prevents the device from getting finalized, leaving the VirtIODevice memory listener registered and leading to use-after-free later on. This patch addresses the same issue as Fam Zheng's "virtio-scsi: Unset hotplug handler when unrealize" only for a different virtio device. Cc: qemu-stable@nongnu.org Signed-off-by: Ladi Prosek Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin Reviewed-by: Paolo Bonzini Reviewed-by: Fam Zheng (cherry picked from commit f811f97040a48358b456b46ecbc9167f0131034f) Signed-off-by: Michael Roth --- hw/char/virtio-serial-bus.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/hw/char/virtio-serial-bus.c b/hw/char/virtio-serial-bus.c index d797a67..aa9c11a 100644 --- a/hw/char/virtio-serial-bus.c +++ b/hw/char/virtio-serial-bus.c @@ -1121,6 +1121,9 @@ static void virtio_serial_device_unrealize(DeviceState *dev, Error **errp) timer_free(vser->post_load->timer); g_free(vser->post_load); } + + qbus_set_hotplug_handler(BUS(&vser->bus), NULL, errp); + virtio_cleanup(vdev); } From patchwork Tue Aug 29 00:14:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806844 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh8tQ3c0Yz9s4s for ; Tue, 29 Aug 2017 10:40:14 +1000 (AEST) Received: from localhost ([::1]:42013 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUZg-0005gF-Ap for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:40:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48271) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCa-0001Qq-AW for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:23 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCX-0005eV-1b for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:20 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:53503 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCW-0005dX-NY for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:16 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0EDYV082024 for ; Mon, 28 Aug 2017 20:16:16 -0400 Received: from e32.co.us.ibm.com (e32.co.us.ibm.com [32.97.110.150]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmurncrrp-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:16 -0400 Received: from localhost by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 18:16:15 -0600 Received: from b03cxnp07028.gho.boulder.ibm.com (9.17.130.15) by e32.co.us.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 18:16:13 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0GDYa3735844; Mon, 28 Aug 2017 17:16:13 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 2224F78043; Mon, 28 Aug 2017 18:16:13 -0600 (MDT) Received: from localhost (unknown [9.80.85.217]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP id E6A507803F; Mon, 28 Aug 2017 18:16:12 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:23 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0004-0000-0000-000012D6D51B X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:14 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0005-0000-0000-000080E59E90 Message-Id: <1503965694-10794-49-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 48/79] linuxboot_dma: compile for i486 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: Paolo Bonzini , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Paolo Bonzini The ROM uses the cmovne instruction, which is new in Pentium Pro and does not work when running QEMU with "-cpu 486". Avoid producing that instruction. Suggested-by: Richard W.M. Jones Suggested-by: Thomas Huth Reported-by: Rob Landley Cc: qemu-stable@nongnu.org Signed-off-by: Paolo Bonzini (cherry picked from commit 7e018385103cd7a571b9ea0d6f994af6b1129fe7) Signed-off-by: Michael Roth --- pc-bios/linuxboot_dma.bin | Bin 1536 -> 1536 bytes pc-bios/optionrom/Makefile | 1 + 2 files changed, 1 insertion(+) diff --git a/pc-bios/linuxboot_dma.bin b/pc-bios/linuxboot_dma.bin index 218d3ab4a29bfb5ab7125ec7a4d29dad1860c673..d176f62797813e4b926dca9dfce7ce554dc1a4d6 100644 GIT binary patch literal 1536 zcmeHFL2J`s82-{_T52KL%w~}udiW-YBE*9t=s~ClrIm^s9^6H6Pf%onr07*+kWd=L zpW)d<4G1ZESU1FyUDSCf^YYaxioy<}t?!rmu^#*f?mHxJo;-Qp_kHp#Je^o$|2##; zYs)n)qh6k7XI07O)9TW>>H@3WSgzkI-MW44`qG_Jxhgq7fAt@+rpuZy7{g_FpG^eo zuoD<7Fjn!zK~Uydy3X@Fj1CnQuA}{tXz$^z=7>a?#S!%6CsARNbiO)h=v+Q~y@5O1 ze8y7!akTy&-YXMV@p3Es`0q*km+)Mtxe(3DE2)a5;c%$H0|Yu~mbnR0C7dKHR7Zsr zmrccq5lm%U=wXc39gV6@%Jl!9^%vQ9V0A-7aUkNnpxu8npp2ruY0}SsKn=BiGN9Y; L*>&K*abWuoMsO(* literal 1536 zcmeHF&ubGw6rN4Dn#RCxYN|nUh%gpJFME=L9)#^}1F5!ps0f07iy|#(O1W^nf~VP8b!3b3v@l;?V$SuIwL6uYt5>dGyH&BPBIn1?(K>6@S?eidI1hgSZ^wky zNA%Hz@f^krJcQTH!Ptb+b>Z7QOZy_v)9!Gc_A*CUnxyOgP~7<9qN#In@`mGjfw=z$ z*1p4gW?~r|cz_FdqLT)y8y*s0Z-)z#_;!*cE?PD>cN4CX-n&AUsLGXj9UuS(2NP%(`OENoGw|EGqnf#7ASHq-k?KrExJ~ z^CHnSr*VvZO%mMQmY+taei4m+{T$|c^(w4)XlpT*^|#=^eK`aF_0%gE_5j9w)aV=c zk7$UtO_Fkt>S!)b5N*mx5@orPY(na#Hj4MfwIDj65ohT<|dXkK7E?qHJ9XdoKqMjysh NXm9N~@Si)N{RVuA8xQ~h diff --git a/pc-bios/optionrom/Makefile b/pc-bios/optionrom/Makefile index fa53d9e..a9a9e5e 100644 --- a/pc-bios/optionrom/Makefile +++ b/pc-bios/optionrom/Makefile @@ -13,6 +13,7 @@ $(call set-vpath, $(SRC_PATH)/pc-bios/optionrom) ifeq ($(lastword $(filter -O%, -O0 $(CFLAGS))),-O0) override CFLAGS += -O2 endif +override CFLAGS += -march=i486 # Drop -fstack-protector and the like QEMU_CFLAGS := $(filter -W%, $(QEMU_CFLAGS)) $(CFLAGS_NOPIE) -ffreestanding From patchwork Tue Aug 29 00:14:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806847 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh8xQ1bMbz9s7M for ; Tue, 29 Aug 2017 10:42:50 +1000 (AEST) Received: from localhost ([::1]:42027 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUcC-00085H-3H for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:42:48 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48399) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCe-0001Tk-0P for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCb-0005kE-8C for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:23 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:53635 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCa-0005jW-Va for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:21 -0400 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0E9w6081539 for ; Mon, 28 Aug 2017 20:16:20 -0400 Received: from e37.co.us.ibm.com (e37.co.us.ibm.com [32.97.110.158]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmurncru1-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:20 -0400 Received: from localhost by e37.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 18:16:19 -0600 Received: from b03cxnp08025.gho.boulder.ibm.com (9.17.130.17) by e37.co.us.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 18:16:14 -0600 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0GEWb62718104; Mon, 28 Aug 2017 17:16:14 -0700 Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 092F2BE038; Mon, 28 Aug 2017 18:16:14 -0600 (MDT) Received: from localhost (unknown [9.80.85.217]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP id C9923BE039; Mon, 28 Aug 2017 18:16:13 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:24 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0024-0000-0000-0000171CE4CB X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:17 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0025-0000-0000-00004C7F054C Message-Id: <1503965694-10794-50-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 49/79] tests: check-qom-proplist: add checks for cmdline-created objects 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: Markus Armbruster , qemu-stable@nongnu.org, "Dr. David Alan Gilbert" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" check-qom-proplist originally added tests for verifying that object-creation helpers object_new_with_{props,propv} behaved in similar fashion to the "traditional" method involving setting each individual property separately after object creation rather than via a single call. Another similar "helper" for creating Objects exists in the form of objects specified via -object command-line parameters. By that rationale, we extend check-qom-proplist to include similar checks for command-line-created objects by employing the same qemu_opts_parse()-based parsing the vl.c employs. This parser has a side-effect of parsing the object's options into a QemuOpt structure and registering this in the global QemuOptsList using the Object's ID. This can conflict with future Object instances that attempt to use the same ID if we don't ensure this is cleaned up as part of Object finalization, so we include a FIXME stub to test for this case, which will then be resolved in a subsequent patch. Suggested-by: Daniel Berrange Cc: "Dr. David Alan Gilbert" Cc: Markus Armbruster Cc: Eric Blake Cc: Daniel Berrange Cc: qemu-stable@nongnu.org Signed-off-by: Michael Roth Reviewed-by: Markus Armbruster Message-Id: <1496531612-22166-2-git-send-email-mdroth@linux.vnet.ibm.com> [Comment formatting tidied up] Signed-off-by: Markus Armbruster (cherry picked from commit a1af255f065ccf3f47a7bfe88f1dbc9eeca36935) Signed-off-by: Michael Roth --- tests/check-qom-proplist.c | 56 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/tests/check-qom-proplist.c b/tests/check-qom-proplist.c index a16cefc..e3b3ae4 100644 --- a/tests/check-qom-proplist.c +++ b/tests/check-qom-proplist.c @@ -23,6 +23,9 @@ #include "qapi/error.h" #include "qom/object.h" #include "qemu/module.h" +#include "qemu/option.h" +#include "qemu/config-file.h" +#include "qom/object_interfaces.h" #define TYPE_DUMMY "qemu-dummy" @@ -162,6 +165,10 @@ static const TypeInfo dummy_info = { .instance_finalize = dummy_finalize, .class_size = sizeof(DummyObjectClass), .class_init = dummy_class_init, + .interfaces = (InterfaceInfo[]) { + { TYPE_USER_CREATABLE }, + { } + } }; @@ -320,6 +327,14 @@ static const TypeInfo dummy_backend_info = { .class_size = sizeof(DummyBackendClass), }; +static QemuOptsList qemu_object_opts = { + .name = "object", + .implied_opt_name = "qom-type", + .head = QTAILQ_HEAD_INITIALIZER(qemu_object_opts.head), + .desc = { + { } + }, +}; static void test_dummy_createv(void) @@ -388,6 +403,46 @@ static void test_dummy_createlist(void) object_unparent(OBJECT(dobj)); } +static void test_dummy_createcmdl(void) +{ + QemuOpts *opts; + DummyObject *dobj; + Error *err = NULL; + const char *params = TYPE_DUMMY \ + ",id=dev0," \ + "bv=yes,sv=Hiss hiss hiss,av=platypus"; + + qemu_add_opts(&qemu_object_opts); + opts = qemu_opts_parse(&qemu_object_opts, params, true, &err); + g_assert(err == NULL); + g_assert(opts); + + dobj = DUMMY_OBJECT(user_creatable_add_opts(opts, &err)); + g_assert(err == NULL); + g_assert(dobj); + g_assert_cmpstr(dobj->sv, ==, "Hiss hiss hiss"); + g_assert(dobj->bv == true); + g_assert(dobj->av == DUMMY_PLATYPUS); + + user_creatable_del("dev0", &err); + g_assert(err == NULL); + error_free(err); + + /* + * cmdline-parsing via qemu_opts_parse() results in a QemuOpts entry + * corresponding to the Object's ID to be added to the QemuOptsList + * for objects. To avoid having this entry conflict with future + * Objects using the same ID (which can happen in cases where + * qemu_opts_parse() is used to parse the object params, such as + * with hmp_object_add() at the time of this comment), we need to + * check for this in user_creatable_del() and remove the QemuOpts if + * it is present. + * + * FIXME: add an assert to verify that the QemuOpts is cleaned up + * once the corresponding cleanup code is added. + */ +} + static void test_dummy_badenum(void) { Error *err = NULL; @@ -525,6 +580,7 @@ int main(int argc, char **argv) g_test_add_func("/qom/proplist/createlist", test_dummy_createlist); g_test_add_func("/qom/proplist/createv", test_dummy_createv); + g_test_add_func("/qom/proplist/createcmdline", test_dummy_createcmdl); g_test_add_func("/qom/proplist/badenum", test_dummy_badenum); g_test_add_func("/qom/proplist/getenum", test_dummy_getenum); g_test_add_func("/qom/proplist/iterator", test_dummy_iterator); From patchwork Tue Aug 29 00:14:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806849 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh8zR0qvQz9s7M for ; Tue, 29 Aug 2017 10:44:35 +1000 (AEST) Received: from localhost ([::1]:42039 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUdt-0001Il-0m for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:44:33 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48367) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCc-0001Sx-Tu for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCZ-0005hh-P7 for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:22 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:55491 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCZ-0005h1-K6 for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:19 -0400 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0EUPM087789 for ; Mon, 28 Aug 2017 20:16:19 -0400 Received: from e34.co.us.ibm.com (e34.co.us.ibm.com [32.97.110.152]) by mx0b-001b2d01.pphosted.com with ESMTP id 2cmvhgar8s-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:18 -0400 Received: from localhost by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 18:16:18 -0600 Received: from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e34.co.us.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 18:16:15 -0600 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0GFBE31391998; Mon, 28 Aug 2017 17:16:15 -0700 Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E8167C603C; Mon, 28 Aug 2017 18:16:14 -0600 (MDT) Received: from localhost (unknown [9.80.85.217]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP id B49B6C603E; Mon, 28 Aug 2017 18:16:14 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:25 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0016-0000-0000-0000076EE821 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:17 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0017-0000-0000-00003B3F1B2F Message-Id: <1503965694-10794-51-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 50/79] monitor: fix object_del for command-line-created objects 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: Markus Armbruster , qemu-stable@nongnu.org, "Dr. David Alan Gilbert" Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Currently objects specified on the command-line are only partially cleaned up when 'object_del' is issued in either HMP or QMP: the object itself is fully finalized, but the QemuOpts are not removed. This results in the following behavior: x86_64-softmmu/qemu-system-x86_64 -monitor stdio \ -object memory-backend-ram,id=ram1,size=256M QEMU 2.7.91 monitor - type 'help' for more information (qemu) object_del ram1 (qemu) object_del ram1 object 'ram1' not found (qemu) object_add memory-backend-ram,id=ram1,size=256M Duplicate ID 'ram1' for object Try "help object_add" for more information which can be an issue for use-cases like memory hotplug. This happens on the HMP side because hmp_object_add() attempts to create a temporary QemuOpts entry with ID 'ram1', which ends up conflicting with the command-line-created entry, since it was never cleaned up during the previous hmp_object_del() call. We address this by adding a check in user_creatable_del(), which is called by both qmp_object_del() and hmp_object_del() to handle the actual object cleanup, to determine whether an option group entry matching the object's ID is present and removing it if it is. Note that qmp_object_add() never attempts to create a temporary QemuOpts entry, so it does not encounter the duplicate ID error, which is why this isn't generally visible in libvirt. Cc: "Dr. David Alan Gilbert" Cc: Markus Armbruster Cc: Eric Blake Cc: Daniel Berrange Cc: qemu-stable@nongnu.org Signed-off-by: Michael Roth Reviewed-by: Daniel P. Berrange Reviewed-by: Markus Armbruster Message-Id: <1496531612-22166-3-git-send-email-mdroth@linux.vnet.ibm.com> Signed-off-by: Markus Armbruster (cherry picked from commit c645d5acee0ae022534cb609184277ec2b4a8577) Signed-off-by: Michael Roth --- qom/object_interfaces.c | 9 +++++++++ tests/check-qom-proplist.c | 4 ++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/qom/object_interfaces.c b/qom/object_interfaces.c index d4253a8..ff27e06 100644 --- a/qom/object_interfaces.c +++ b/qom/object_interfaces.c @@ -4,6 +4,7 @@ #include "qemu/module.h" #include "qapi-visit.h" #include "qapi/opts-visitor.h" +#include "qemu/config-file.h" void user_creatable_complete(Object *obj, Error **errp) { @@ -181,6 +182,14 @@ void user_creatable_del(const char *id, Error **errp) error_setg(errp, "object '%s' is in use, can not be deleted", id); return; } + + /* + * if object was defined on the command-line, remove its corresponding + * option group entry + */ + qemu_opts_del(qemu_opts_find(qemu_find_opts_err("object", &error_abort), + id)); + object_unparent(obj); } diff --git a/tests/check-qom-proplist.c b/tests/check-qom-proplist.c index e3b3ae4..8e432e9 100644 --- a/tests/check-qom-proplist.c +++ b/tests/check-qom-proplist.c @@ -438,9 +438,9 @@ static void test_dummy_createcmdl(void) * check for this in user_creatable_del() and remove the QemuOpts if * it is present. * - * FIXME: add an assert to verify that the QemuOpts is cleaned up - * once the corresponding cleanup code is added. + * The below check ensures this works as expected. */ + g_assert_null(qemu_opts_find(&qemu_object_opts, "dev0")); } static void test_dummy_badenum(void) From patchwork Tue Aug 29 00:14:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806861 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh99g28ctz9s7M for ; Tue, 29 Aug 2017 10:53:27 +1000 (AEST) Received: from localhost ([::1]:42093 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUmT-0000dR-4I for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:53:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48433) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCe-0001V1-VC for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCb-0005kv-JP for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:24 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:58074) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCb-0005jZ-AK for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:21 -0400 Received: from pps.filterd (m0098394.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0FKh1044218 for ; Mon, 28 Aug 2017 20:16:20 -0400 Received: from e15.ny.us.ibm.com (e15.ny.us.ibm.com [129.33.205.205]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmsrsj1vk-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:20 -0400 Received: from localhost by e15.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 20:16:19 -0400 Received: from b01cxnp22036.gho.pok.ibm.com (9.57.198.26) by e15.ny.us.ibm.com (146.89.104.202) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 20:16:16 -0400 Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0GGNN30015690; Tue, 29 Aug 2017 00:16:16 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 66DDF124050; Mon, 28 Aug 2017 20:13:36 -0400 (EDT) Received: from localhost (unknown [9.80.85.217]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTP id 2FBBD124035; Mon, 28 Aug 2017 20:13:36 -0400 (EDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:26 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0036-0000-0000-000002603F83 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909027; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:18 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0037-0000-0000-000041964A96 Message-Id: <1503965694-10794-52-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 51/79] pc: Use "min-[x]level" on compat_props 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: qemu-stable@nongnu.org, Eduardo Habkost Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Eduardo Habkost Since the automatic cpuid-level code was introduced in commit c39c0edf9bb3b968ba95484465a50c7b19f4aa3a ("target-i386: Automatically set level/xlevel/xlevel2 when needed"), the CPU model tables just define the default CPUID level code (set using "min-level"). Setting "[x]level" forces CPUID level to a specific value and disable the automatic-level logic. But the PC compat code was not updated and the existing "[x]level" compat properties broke compatibility for people using features that triggered the auto-level code. To keep previous behavior, we should set "min-[x]level" instead of "[x]level" on compat_props. This was not a problem for most cases, because old machine-types don't have full-cpuid-auto-level enabled. The only common use case it broke was the CPUID[7] auto-level code, that was already enabled since the first CPUID[7] feature was introduced (in QEMU 1.4.0). This causes the regression reported at: https://bugzilla.redhat.com/show_bug.cgi?id=1454641 Change the PC compat code to use "min-[x]level" instead of "[x]level" on compat_props, and add new test cases to ensure we don't break this again. Reported-by: "Guo, Zhiyi" Fixes: c39c0edf9bb ("target-i386: Automatically set level/xlevel/xlevel2 when needed") Cc: qemu-stable@nongnu.org Acked-by: Michael S. Tsirkin Signed-off-by: Eduardo Habkost (cherry picked from commit 1f43571604da85c62f25f3ba6d275b1b5ea76ca2) Signed-off-by: Michael Roth --- include/hw/i386/pc.h | 42 +++++++++++++++++++++--------------------- tests/test-x86-cpuid-compat.c | 38 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 59 insertions(+), 21 deletions(-) diff --git a/include/hw/i386/pc.h b/include/hw/i386/pc.h index f278b3a..564486f 100644 --- a/include/hw/i386/pc.h +++ b/include/hw/i386/pc.h @@ -558,75 +558,75 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *); .value = "off",\ },{\ .driver = "qemu64" "-" TYPE_X86_CPU,\ - .property = "level",\ + .property = "min-level",\ .value = stringify(4),\ },{\ .driver = "kvm64" "-" TYPE_X86_CPU,\ - .property = "level",\ + .property = "min-level",\ .value = stringify(5),\ },{\ .driver = "pentium3" "-" TYPE_X86_CPU,\ - .property = "level",\ + .property = "min-level",\ .value = stringify(2),\ },{\ .driver = "n270" "-" TYPE_X86_CPU,\ - .property = "level",\ + .property = "min-level",\ .value = stringify(5),\ },{\ .driver = "Conroe" "-" TYPE_X86_CPU,\ - .property = "level",\ + .property = "min-level",\ .value = stringify(4),\ },{\ .driver = "Penryn" "-" TYPE_X86_CPU,\ - .property = "level",\ + .property = "min-level",\ .value = stringify(4),\ },{\ .driver = "Nehalem" "-" TYPE_X86_CPU,\ - .property = "level",\ + .property = "min-level",\ .value = stringify(4),\ },{\ .driver = "n270" "-" TYPE_X86_CPU,\ - .property = "xlevel",\ + .property = "min-xlevel",\ .value = stringify(0x8000000a),\ },{\ .driver = "Penryn" "-" TYPE_X86_CPU,\ - .property = "xlevel",\ + .property = "min-xlevel",\ .value = stringify(0x8000000a),\ },{\ .driver = "Conroe" "-" TYPE_X86_CPU,\ - .property = "xlevel",\ + .property = "min-xlevel",\ .value = stringify(0x8000000a),\ },{\ .driver = "Nehalem" "-" TYPE_X86_CPU,\ - .property = "xlevel",\ + .property = "min-xlevel",\ .value = stringify(0x8000000a),\ },{\ .driver = "Westmere" "-" TYPE_X86_CPU,\ - .property = "xlevel",\ + .property = "min-xlevel",\ .value = stringify(0x8000000a),\ },{\ .driver = "SandyBridge" "-" TYPE_X86_CPU,\ - .property = "xlevel",\ + .property = "min-xlevel",\ .value = stringify(0x8000000a),\ },{\ .driver = "IvyBridge" "-" TYPE_X86_CPU,\ - .property = "xlevel",\ + .property = "min-xlevel",\ .value = stringify(0x8000000a),\ },{\ .driver = "Haswell" "-" TYPE_X86_CPU,\ - .property = "xlevel",\ + .property = "min-xlevel",\ .value = stringify(0x8000000a),\ },{\ .driver = "Haswell-noTSX" "-" TYPE_X86_CPU,\ - .property = "xlevel",\ + .property = "min-xlevel",\ .value = stringify(0x8000000a),\ },{\ .driver = "Broadwell" "-" TYPE_X86_CPU,\ - .property = "xlevel",\ + .property = "min-xlevel",\ .value = stringify(0x8000000a),\ },{\ .driver = "Broadwell-noTSX" "-" TYPE_X86_CPU,\ - .property = "xlevel",\ + .property = "min-xlevel",\ .value = stringify(0x8000000a),\ },{\ .driver = TYPE_X86_CPU,\ @@ -852,7 +852,7 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *); .value = stringify(2),\ },{\ .driver = "Conroe-" TYPE_X86_CPU,\ - .property = "level",\ + .property = "min-level",\ .value = stringify(2),\ },{\ .driver = "Penryn-" TYPE_X86_CPU,\ @@ -860,7 +860,7 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *); .value = stringify(2),\ },{\ .driver = "Penryn-" TYPE_X86_CPU,\ - .property = "level",\ + .property = "min-level",\ .value = stringify(2),\ },{\ .driver = "Nehalem-" TYPE_X86_CPU,\ @@ -868,7 +868,7 @@ bool e820_get_entry(int, uint32_t, uint64_t *, uint64_t *); .value = stringify(2),\ },{\ .driver = "Nehalem-" TYPE_X86_CPU,\ - .property = "level",\ + .property = "min-level",\ .value = stringify(2),\ },{\ .driver = "virtio-net-pci",\ diff --git a/tests/test-x86-cpuid-compat.c b/tests/test-x86-cpuid-compat.c index 79a2e69..b449f54 100644 --- a/tests/test-x86-cpuid-compat.c +++ b/tests/test-x86-cpuid-compat.c @@ -228,6 +228,44 @@ int main(int argc, char **argv) add_cpuid_test("x86/cpuid/auto-xlevel2/pc-2.7", "-machine pc-i440fx-2.7 -cpu 486,+xstore", "xlevel2", 0); + /* + * QEMU 1.4.0 had auto-level enabled for CPUID[7], already, + * and the compat code that sets default level shouldn't + * disable the auto-level=7 code: + */ + add_cpuid_test("x86/cpuid/auto-level7/pc-i440fx-1.4/off", + "-machine pc-i440fx-1.4 -cpu Nehalem", + "level", 2); + add_cpuid_test("x86/cpuid/auto-level7/pc-i440fx-1.5/on", + "-machine pc-i440fx-1.4 -cpu Nehalem,+smap", + "level", 7); + add_cpuid_test("x86/cpuid/auto-level7/pc-i440fx-2.3/off", + "-machine pc-i440fx-2.3 -cpu Penryn", + "level", 4); + add_cpuid_test("x86/cpuid/auto-level7/pc-i440fx-2.3/on", + "-machine pc-i440fx-2.3 -cpu Penryn,+erms", + "level", 7); + add_cpuid_test("x86/cpuid/auto-level7/pc-i440fx-2.9/off", + "-machine pc-i440fx-2.9 -cpu Conroe", + "level", 10); + add_cpuid_test("x86/cpuid/auto-level7/pc-i440fx-2.9/on", + "-machine pc-i440fx-2.9 -cpu Conroe,+erms", + "level", 10); + + /* + * xlevel doesn't have any feature that triggers auto-level + * code on old machine-types. Just check that the compat code + * is working correctly: + */ + add_cpuid_test("x86/cpuid/xlevel-compat/pc-i440fx-2.3", + "-machine pc-i440fx-2.3 -cpu SandyBridge", + "xlevel", 0x8000000a); + add_cpuid_test("x86/cpuid/xlevel-compat/pc-i440fx-2.4/npt-off", + "-machine pc-i440fx-2.4 -cpu SandyBridge,", + "xlevel", 0x80000008); + add_cpuid_test("x86/cpuid/xlevel-compat/pc-i440fx-2.4/npt-on", + "-machine pc-i440fx-2.4 -cpu SandyBridge,+npt", + "xlevel", 0x80000008); return g_test_run(); } From patchwork Tue Aug 29 00:14:27 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806854 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh92z2hYfz9s7M for ; Tue, 29 Aug 2017 10:47:39 +1000 (AEST) Received: from localhost ([::1]:42061 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUgr-00046a-6V for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:47:37 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48418) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCe-0001UU-IM for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCb-0005kQ-AL for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:24 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:57531 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCb-0005jh-0a for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:21 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0E8JH099546 for ; Mon, 28 Aug 2017 20:16:20 -0400 Received: from e16.ny.us.ibm.com (e16.ny.us.ibm.com [129.33.205.206]) by mx0b-001b2d01.pphosted.com with ESMTP id 2cmr22ykdk-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:20 -0400 Received: from localhost by e16.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 20:16:19 -0400 Received: from b01cxnp22036.gho.pok.ibm.com (9.57.198.26) by e16.ny.us.ibm.com (146.89.104.203) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 20:16:17 -0400 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0GHfV30146814; Tue, 29 Aug 2017 00:16:17 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E8460B2054; Mon, 28 Aug 2017 20:13:40 -0400 (EDT) Received: from localhost (unknown [9.80.85.217]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP id B0516B2052; Mon, 28 Aug 2017 20:13:40 -0400 (EDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:27 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 17082900-0024-0000-0000-000002C6D2BB X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:18 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0025-0000-0000-0000453E634B Message-Id: <1503965694-10794-53-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-MIME-Autoconverted: from 8bit to quoted-printable by mx0b-001b2d01.pphosted.com id v7T0E8JH099546 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 52/79] target/ppc: pass const string to kvmppc_is_mem_backend_page_size_ok() 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: David Gibson , qemu-stable@nongnu.org, Greg Kurz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Greg Kurz This function has three implementations. Two are stubs that do nothing and the third one only passes the obj_path argument to: Object *object_resolve_path(const char *path, bool *ambiguous); Signed-off-by: Greg Kurz Reviewed-by: Philippe Mathieu-Daudé Reviewed-by: Thomas Huth Signed-off-by: David Gibson (cherry picked from commit ec69355beffe138c0f97306e65410e5dbc605554) Signed-off-by: Michael Roth --- target/ppc/kvm.c | 4 ++-- target/ppc/kvm_ppc.h | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 9f1f132..89f3586 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -415,7 +415,7 @@ static void kvm_fixup_page_sizes(PowerPCCPU *cpu) } } -bool kvmppc_is_mem_backend_page_size_ok(char *obj_path) +bool kvmppc_is_mem_backend_page_size_ok(const char *obj_path) { Object *mem_obj = object_resolve_path(obj_path, NULL); char *mempath = object_property_get_str(mem_obj, "mem-path", NULL); @@ -436,7 +436,7 @@ static inline void kvm_fixup_page_sizes(PowerPCCPU *cpu) { } -bool kvmppc_is_mem_backend_page_size_ok(char *obj_path) +bool kvmppc_is_mem_backend_page_size_ok(const char *obj_path) { return true; } diff --git a/target/ppc/kvm_ppc.h b/target/ppc/kvm_ppc.h index 8e9f42d..eec5cca 100644 --- a/target/ppc/kvm_ppc.h +++ b/target/ppc/kvm_ppc.h @@ -57,7 +57,7 @@ int kvmppc_enable_hwrng(void); int kvmppc_put_books_sregs(PowerPCCPU *cpu); PowerPCCPUClass *kvm_ppc_get_host_cpu_class(void); -bool kvmppc_is_mem_backend_page_size_ok(char *obj_path); +bool kvmppc_is_mem_backend_page_size_ok(const char *obj_path); #else @@ -191,7 +191,7 @@ static inline uint64_t kvmppc_rma_size(uint64_t current_size, return ram_size; } -static inline bool kvmppc_is_mem_backend_page_size_ok(char *obj_path) +static inline bool kvmppc_is_mem_backend_page_size_ok(const char *obj_path) { return true; } From patchwork Tue Aug 29 00:14:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806855 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh94P4RJLz9s7M for ; Tue, 29 Aug 2017 10:48:53 +1000 (AEST) Received: from localhost ([::1]:42066 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUi3-00057U-CH for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:48:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48466) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCf-0001Vs-E0 for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCc-0005ld-84 for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:25 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:55591 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCc-0005l8-36 for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:22 -0400 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0ERDK087587 for ; Mon, 28 Aug 2017 20:16:21 -0400 Received: from e14.ny.us.ibm.com (e14.ny.us.ibm.com [129.33.205.204]) by mx0b-001b2d01.pphosted.com with ESMTP id 2cmvhgaraa-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:21 -0400 Received: from localhost by e14.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 20:16:21 -0400 Received: from b01cxnp22034.gho.pok.ibm.com (9.57.198.24) by e14.ny.us.ibm.com (146.89.104.201) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 20:16:18 -0400 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0GHeV21561582; Tue, 29 Aug 2017 00:16:17 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D4FD711204B; Mon, 28 Aug 2017 20:16:03 -0400 (EDT) Received: from localhost (unknown [9.80.85.217]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP id A612F112047; Mon, 28 Aug 2017 20:16:03 -0400 (EDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:28 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0052-0000-0000-00000257336C X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:19 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0053-0000-0000-000051D1D990 Message-Id: <1503965694-10794-54-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 53/79] target/ppc: fix memory leak in kvmppc_is_mem_backend_page_size_ok() 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: David Gibson , qemu-stable@nongnu.org, Greg Kurz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Greg Kurz The string returned by object_property_get_str() is dynamically allocated. Signed-off-by: Greg Kurz Reviewed-by: Thomas Huth Signed-off-by: David Gibson (cherry picked from commit 2d3e302ec2246d703ffa8d8f8769a3fa448d8145) Signed-off-by: Michael Roth --- target/ppc/kvm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/target/ppc/kvm.c b/target/ppc/kvm.c index 89f3586..b1dd41c 100644 --- a/target/ppc/kvm.c +++ b/target/ppc/kvm.c @@ -423,6 +423,7 @@ bool kvmppc_is_mem_backend_page_size_ok(const char *obj_path) if (mempath) { pagesize = qemu_mempath_getpagesize(mempath); + g_free(mempath); } else { pagesize = getpagesize(); } From patchwork Tue Aug 29 00:14:29 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806865 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh9F71HNsz9s7M for ; Tue, 29 Aug 2017 10:56:27 +1000 (AEST) Received: from localhost ([::1]:42109 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUpN-0003Tn-2T for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:56:25 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48506) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCg-0001Xu-Mf for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:30 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCe-0005pK-8t for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:26 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:56881) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCd-0005mu-W7 for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:24 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0ECuc042865 for ; Mon, 28 Aug 2017 20:16:23 -0400 Received: from e17.ny.us.ibm.com (e17.ny.us.ibm.com [129.33.205.207]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmr8nf0bu-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:22 -0400 Received: from localhost by e17.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 20:16:21 -0400 Received: from b01cxnp23032.gho.pok.ibm.com (9.57.198.27) by e17.ny.us.ibm.com (146.89.104.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 20:16:18 -0400 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0GIGf26083402; Tue, 29 Aug 2017 00:16:18 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CA33CAE034; Mon, 28 Aug 2017 20:16:41 -0400 (EDT) Received: from localhost (unknown [9.80.85.217]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTP id 9C883AE03B; Mon, 28 Aug 2017 20:16:41 -0400 (EDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:29 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0040-0000-0000-00000396DEFA X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:19 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0041-0000-0000-0000078B107C Message-Id: <1503965694-10794-55-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 54/79] spapr: add pre_plug function for memory 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: Laurent Vivier , qemu-stable@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Laurent Vivier This allows to manage errors before the memory has started to be hotplugged. We already have the function for the CPU cores. Signed-off-by: Laurent Vivier Reviewed-by: Greg Kurz [dwg: Fixed a couple of style nits] Signed-off-by: David Gibson (cherry picked from commit c871bc70bb22d1d70451bc813ecb008fe98cc92b) Signed-off-by: Michael Roth --- hw/ppc/spapr.c | 41 ++++++++++++++++++++++++++--------------- 1 file changed, 26 insertions(+), 15 deletions(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 35db949..5564f78 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2508,20 +2508,6 @@ static void spapr_memory_plug(HotplugHandler *hotplug_dev, DeviceState *dev, uint64_t align = memory_region_get_alignment(mr); uint64_t size = memory_region_size(mr); uint64_t addr; - char *mem_dev; - - if (size % SPAPR_MEMORY_BLOCK_SIZE) { - error_setg(&local_err, "Hotplugged memory size must be a multiple of " - "%lld MB", SPAPR_MEMORY_BLOCK_SIZE/M_BYTE); - goto out; - } - - mem_dev = object_property_get_str(OBJECT(dimm), PC_DIMM_MEMDEV_PROP, NULL); - if (mem_dev && !kvmppc_is_mem_backend_page_size_ok(mem_dev)) { - error_setg(&local_err, "Memory backend has bad page size. " - "Use 'memory-backend-file' with correct mem-path."); - goto out; - } pc_dimm_memory_plug(dev, &ms->hotplug_memory, mr, align, &local_err); if (local_err) { @@ -2542,6 +2528,29 @@ out: error_propagate(errp, local_err); } +static void spapr_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, + Error **errp) +{ + PCDIMMDevice *dimm = PC_DIMM(dev); + PCDIMMDeviceClass *ddc = PC_DIMM_GET_CLASS(dimm); + MemoryRegion *mr = ddc->get_memory_region(dimm); + uint64_t size = memory_region_size(mr); + char *mem_dev; + + if (size % SPAPR_MEMORY_BLOCK_SIZE) { + error_setg(errp, "Hotplugged memory size must be a multiple of " + "%lld MB", SPAPR_MEMORY_BLOCK_SIZE / M_BYTE); + return; + } + + mem_dev = object_property_get_str(OBJECT(dimm), PC_DIMM_MEMDEV_PROP, NULL); + if (mem_dev && !kvmppc_is_mem_backend_page_size_ok(mem_dev)) { + error_setg(errp, "Memory backend has bad page size. " + "Use 'memory-backend-file' with correct mem-path."); + return; + } +} + typedef struct sPAPRDIMMState { uint32_t nr_lmbs; } sPAPRDIMMState; @@ -2912,7 +2921,9 @@ static void spapr_machine_device_unplug_request(HotplugHandler *hotplug_dev, static void spapr_machine_device_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, Error **errp) { - if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_CPU_CORE)) { + if (object_dynamic_cast(OBJECT(dev), TYPE_PC_DIMM)) { + spapr_memory_pre_plug(hotplug_dev, dev, errp); + } else if (object_dynamic_cast(OBJECT(dev), TYPE_SPAPR_CPU_CORE)) { spapr_core_pre_plug(hotplug_dev, dev, errp); } } From patchwork Tue Aug 29 00:14:30 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806859 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh97c1qkfz9s7M for ; Tue, 29 Aug 2017 10:51:40 +1000 (AEST) Received: from localhost ([::1]:42086 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUkk-0007XL-3Y for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:51:38 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48549) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCi-0001YZ-0e for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCe-0005p3-6b for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:27 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:56880) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCd-0005mg-SS for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:24 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0EBXv042798 for ; Mon, 28 Aug 2017 20:16:23 -0400 Received: from e12.ny.us.ibm.com (e12.ny.us.ibm.com [129.33.205.202]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmr8nf0br-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:22 -0400 Received: from localhost by e12.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 20:16:21 -0400 Received: from b01cxnp23032.gho.pok.ibm.com (9.57.198.27) by e12.ny.us.ibm.com (146.89.104.199) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 20:16:19 -0400 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0GIli25559198; Tue, 29 Aug 2017 00:16:18 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 01428AC03F; Mon, 28 Aug 2017 20:16:43 -0400 (EDT) Received: from localhost (unknown [9.80.85.217]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP id C8140AC043; Mon, 28 Aug 2017 20:16:42 -0400 (EDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:30 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0048-0000-0000-000001DAEA7D X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:20 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0049-0000-0000-00004261942A Message-Id: <1503965694-10794-56-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 55/79] spapr: fix memory leak in spapr_memory_pre_plug() 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: David Gibson , qemu-stable@nongnu.org, Greg Kurz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Greg Kurz The string returned by object_property_get_str() is dynamically allocated. (Spotted by Coverity, CID 1375942) Signed-off-by: Greg Kurz Signed-off-by: David Gibson (cherry picked from commit 8a9e0e7b890b2598da94646bf6a7272f3d3924de) Signed-off-by: Michael Roth --- hw/ppc/spapr.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 5564f78..58c15ef 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2547,8 +2547,11 @@ static void spapr_memory_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, if (mem_dev && !kvmppc_is_mem_backend_page_size_ok(mem_dev)) { error_setg(errp, "Memory backend has bad page size. " "Use 'memory-backend-file' with correct mem-path."); - return; + goto out; } + +out: + g_free(mem_dev); } typedef struct sPAPRDIMMState { From patchwork Tue Aug 29 00:14:31 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806863 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh9CB52GZz9s7M for ; Tue, 29 Aug 2017 10:54:46 +1000 (AEST) Received: from localhost ([::1]:42098 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUnk-0001h1-Ey for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:54:44 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48523) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCh-0001YO-Aq for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCe-0005oO-2M for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:27 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:39029) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCd-0005mC-Mf for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:23 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0E70K090091 for ; Mon, 28 Aug 2017 20:16:22 -0400 Received: from e36.co.us.ibm.com (e36.co.us.ibm.com [32.97.110.154]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmvyehksk-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:22 -0400 Received: from localhost by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 18:16:21 -0600 Received: from b03cxnp08026.gho.boulder.ibm.com (9.17.130.18) by e36.co.us.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 18:16:20 -0600 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0GJsq63438938; Mon, 28 Aug 2017 17:16:19 -0700 Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A2EC36E045; Mon, 28 Aug 2017 18:16:19 -0600 (MDT) Received: from localhost (unknown [9.80.85.217]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP id 7A5FA6E041; Mon, 28 Aug 2017 18:16:19 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:31 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0020-0000-0000-00000CA0E9D9 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:21 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0021-0000-0000-00005DE891D5 Message-Id: <1503965694-10794-57-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 56/79] target/xtensa: handle unknown registers in gdbstub 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: Max Filippov , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Max Filippov Xtensa cores may have registers of types/sizes not supported by the gdbstub accessors. Ignore writes to such registers and return zero on read, but always return correct register size, so that gdb on the other side is able to access all registers in the packet holding unsupported registers in the middle. This fixes gdb interaction with cores that have vector/custom TIE registers. Cc: qemu-stable@nongnu.org Signed-off-by: Max Filippov (cherry picked from commit dd7b952b793e341c905355581a21cdbaa8b13c31) Signed-off-by: Michael Roth --- target/xtensa/gdbstub.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/target/xtensa/gdbstub.c b/target/xtensa/gdbstub.c index fa5469a..da131ae 100644 --- a/target/xtensa/gdbstub.c +++ b/target/xtensa/gdbstub.c @@ -58,7 +58,10 @@ int xtensa_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) case 8: return gdb_get_reg64(mem_buf, float64_val(env->fregs[i].f64)); default: - return 0; + qemu_log_mask(LOG_UNIMP, "%s from reg %d of unsupported size %d\n", + __func__, n, reg->size); + memset(mem_buf, 0, reg->size); + return reg->size; } case 8: /*a*/ @@ -67,6 +70,8 @@ int xtensa_cpu_gdb_read_register(CPUState *cs, uint8_t *mem_buf, int n) default: qemu_log_mask(LOG_UNIMP, "%s from reg %d of unsupported type %d\n", __func__, n, reg->type); + memset(mem_buf, 0, reg->size); + return reg->size; return 0; } } @@ -111,7 +116,9 @@ int xtensa_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) env->fregs[reg->targno & 0x0f].f64 = make_float64(tmp); return 8; default: - return 0; + qemu_log_mask(LOG_UNIMP, "%s to reg %d of unsupported size %d\n", + __func__, n, reg->size); + return reg->size; } case 8: /*a*/ @@ -121,7 +128,7 @@ int xtensa_cpu_gdb_write_register(CPUState *cs, uint8_t *mem_buf, int n) default: qemu_log_mask(LOG_UNIMP, "%s to reg %d of unsupported type %d\n", __func__, n, reg->type); - return 0; + return reg->size; } return 4; From patchwork Tue Aug 29 00:14:32 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806857 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh9670vJ8z9s7M for ; Tue, 29 Aug 2017 10:50:23 +1000 (AEST) Received: from localhost ([::1]:42077 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUjU-0006KB-W9 for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:50:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48544) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCh-0001YY-Qp for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:31 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCe-0005oz-5j for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:27 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:42402 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCd-0005nj-Vf for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:24 -0400 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0EBJ8019642 for ; Mon, 28 Aug 2017 20:16:23 -0400 Received: from e35.co.us.ibm.com (e35.co.us.ibm.com [32.97.110.153]) by mx0b-001b2d01.pphosted.com with ESMTP id 2cmsfn2wme-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:23 -0400 Received: from localhost by e35.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 18:16:22 -0600 Received: from b03cxnp08027.gho.boulder.ibm.com (9.17.130.19) by e35.co.us.ibm.com (192.168.1.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 18:16:21 -0600 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0GKCL64880854; Mon, 28 Aug 2017 17:16:20 -0700 Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 98A3E136040; Mon, 28 Aug 2017 18:16:20 -0600 (MDT) Received: from localhost (unknown [9.80.85.217]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP id 6588713603C; Mon, 28 Aug 2017 18:16:20 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:32 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0012-0000-0000-000014ECDC52 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:22 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0013-0000-0000-00004F43FB4E Message-Id: <1503965694-10794-58-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 57/79] commit: Fix use after free in completion 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 , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Kevin Wolf The final bdrv_set_backing_hd() could be working on already freed nodes because the commit job drops its references (through BlockBackends) to both overlay_bs and top already a bit earlier. One way to trigger the bug is hot unplugging a disk for which blockdev_mark_auto_del() cancels the block job. Fix this by taking BDS-level references while we're still using the nodes. Cc: qemu-stable@nongnu.org Signed-off-by: Kevin Wolf Reviewed-by: John Snow (cherry picked from commit 19ebd13ed45ad5d5f277f5914d55b83f13eb09eb) Signed-off-by: Michael Roth --- block/commit.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/block/commit.c b/block/commit.c index 76a0d98..3bae46e 100644 --- a/block/commit.c +++ b/block/commit.c @@ -89,6 +89,10 @@ static void commit_complete(BlockJob *job, void *opaque) int ret = data->ret; bool remove_commit_top_bs = false; + /* Make sure overlay_bs and top stay around until bdrv_set_backing_hd() */ + bdrv_ref(top); + bdrv_ref(overlay_bs); + /* Remove base node parent that still uses BLK_PERM_WRITE/RESIZE before * the normal backing chain can be restored. */ blk_unref(s->base); @@ -124,6 +128,9 @@ static void commit_complete(BlockJob *job, void *opaque) if (remove_commit_top_bs) { bdrv_set_backing_hd(overlay_bs, top, &error_abort); } + + bdrv_unref(overlay_bs); + bdrv_unref(top); } static void coroutine_fn commit_run(void *opaque) From patchwork Tue Aug 29 00:14:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806869 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh9KN1RMzz9sRV for ; Tue, 29 Aug 2017 11:00:08 +1000 (AEST) Received: from localhost ([::1]:42129 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUsv-0006TD-Fz for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 21:00:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48652) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCk-0001as-NQ for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:34 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCh-0005vY-AH for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:30 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:34974 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCh-0005uM-3J for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:27 -0400 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0EBKE017922 for ; Mon, 28 Aug 2017 20:16:26 -0400 Received: from e37.co.us.ibm.com (e37.co.us.ibm.com [32.97.110.158]) by mx0b-001b2d01.pphosted.com with ESMTP id 2cmub2ww5p-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:26 -0400 Received: from localhost by e37.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 18:16:25 -0600 Received: from b03cxnp08027.gho.boulder.ibm.com (9.17.130.19) by e37.co.us.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 18:16:22 -0600 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0GLNP65208422; Mon, 28 Aug 2017 17:16:21 -0700 Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7F09F6A03C; Mon, 28 Aug 2017 18:16:21 -0600 (MDT) Received: from localhost (unknown [9.80.85.217]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP id 4B8216A03D; Mon, 28 Aug 2017 18:16:21 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:33 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0024-0000-0000-0000171CE4D5 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:24 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0025-0000-0000-00004C7F0560 Message-Id: <1503965694-10794-59-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 58/79] nbd: Fully initialize client in case of failed negotiation 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: Paolo Bonzini , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Eric Blake If a non-NBD client connects to qemu-nbd, we would end up with a SIGSEGV in nbd_client_put() because we were trying to unregister the client's association to the export, even though we skipped inserting the client into that list. Easy trigger in two terminals: $ qemu-nbd -p 30001 --format=raw file $ nmap 127.0.0.1 -p 30001 nmap claims that it thinks it connected to a pago-services1 server (which probably means nmap could be updated to learn the NBD protocol and give a more accurate diagnosis of the open port - but that's not our problem), then terminates immediately, so our call to nbd_negotiate() fails. The fix is to reorder nbd_co_client_start() to ensure that all initialization occurs before we ever try talking to a client in nbd_negotiate(), so that the teardown sequence on negotiation failure doesn't fault while dereferencing a half-initialized object. While debugging this, I also noticed that nbd_update_server_watch() called by nbd_client_closed() was still adding a channel to accept the next client, even when the state was no longer RUNNING. That is fixed by making nbd_can_accept() pay attention to the current state. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1451614 Signed-off-by: Eric Blake Message-Id: <20170527030421.28366-1-eblake@redhat.com> Signed-off-by: Paolo Bonzini (cherry picked from commit df8ad9f128c15aa0a0ebc7b24e9a22c9775b67af) Signed-off-by: Michael Roth --- nbd/server.c | 8 +++----- qemu-nbd.c | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/nbd/server.c b/nbd/server.c index 924a1fe..edfda84 100644 --- a/nbd/server.c +++ b/nbd/server.c @@ -1376,16 +1376,14 @@ static coroutine_fn void nbd_co_client_start(void *opaque) if (exp) { nbd_export_get(exp); + QTAILQ_INSERT_TAIL(&exp->clients, client, next); } + qemu_co_mutex_init(&client->send_lock); + if (nbd_negotiate(data)) { client_close(client); goto out; } - qemu_co_mutex_init(&client->send_lock); - - if (exp) { - QTAILQ_INSERT_TAIL(&exp->clients, client, next); - } nbd_client_receive_next_request(client); diff --git a/qemu-nbd.c b/qemu-nbd.c index e4f00e2..14e7947 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -324,7 +324,7 @@ out: static int nbd_can_accept(void) { - return nb_fds < shared; + return state == RUNNING && nb_fds < shared; } static void nbd_export_closed(NBDExport *exp) From patchwork Tue Aug 29 00:14:34 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806860 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh99H4X8vz9s7M for ; Tue, 29 Aug 2017 10:53:07 +1000 (AEST) Received: from localhost ([::1]:42092 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUm9-0000NL-Fv for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:53:05 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48658) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCk-0001bD-SI for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCh-0005vc-Af for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:30 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:38793 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCh-0005uP-3F for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:27 -0400 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0EYVN065932 for ; Mon, 28 Aug 2017 20:16:26 -0400 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0b-001b2d01.pphosted.com with ESMTP id 2cmq0jb00j-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:26 -0400 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 18:16:25 -0600 Received: from b03cxnp07029.gho.boulder.ibm.com (9.17.130.16) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 18:16:22 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0GMtn7537104; Mon, 28 Aug 2017 17:16:22 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5F1E278043; Mon, 28 Aug 2017 18:16:22 -0600 (MDT) Received: from localhost (unknown [9.80.85.217]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP id 254A278047; Mon, 28 Aug 2017 18:16:22 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:34 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-8235-0000-0000-00000C2FE7C6 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:24 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-8236-0000-0000-00003D6C072F Message-Id: <1503965694-10794-60-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 59/79] nbd: Fix regression on resiliency to port scan 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: Paolo Bonzini , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Eric Blake Back in qemu 2.5, qemu-nbd was immune to port probes (a transient server would not quit, regardless of how many probe connections came and went, until a connection actually negotiated). But we broke that in commit ee7d7aa when removing the return value to nbd_client_new(), although that patch also introduced a bug causing an assertion failure on a client that fails negotiation. We then made it worse during refactoring in commit 1a6245a (a segfault before we could even assert); the (masked) assertion was cleaned up in d3780c2 (still in 2.6), and just recently we finally fixed the segfault ("nbd: Fully intialize client in case of failed negotiation"). But that still means that ever since we added TLS support to qemu-nbd, we have been vulnerable to an ill-timed port-scan being able to cause a denial of service by taking down qemu-nbd before a real client has a chance to connect. Since negotiation is now handled asynchronously via coroutines, we no longer have a synchronous point of return by re-adding a return value to nbd_client_new(). So this patch instead wires things up to pass the negotiation status through the close_fn callback function. Simple test across two terminals: $ qemu-nbd -f raw -p 30001 file $ nmap 127.0.0.1 -p 30001 && \ qemu-io -c 'r 0 512' -f raw nbd://localhost:30001 Note that this patch does not change what constitutes successful negotiation (thus, a client must enter transmission phase before that client can be considered as a reason to terminate the server when the connection ends). Perhaps we may want to tweak things in a later patch to also treat a client that uses NBD_OPT_ABORT as being a 'successful' negotiation (the client correctly talked the NBD protocol, and informed us it was not going to use our export after all), but that's a discussion for another day. Fixes: https://bugzilla.redhat.com/show_bug.cgi?id=1451614 Signed-off-by: Eric Blake Message-Id: <20170608222617.20376-1-eblake@redhat.com> Signed-off-by: Paolo Bonzini (cherry picked from commit 0c9390d978cbf61e8f16c9f580fa96b305c43568) Signed-off-by: Michael Roth --- blockdev-nbd.c | 6 +++++- include/block/nbd.h | 2 +- nbd/server.c | 24 +++++++++++++++--------- qemu-nbd.c | 4 ++-- 4 files changed, 23 insertions(+), 13 deletions(-) diff --git a/blockdev-nbd.c b/blockdev-nbd.c index 8a11807..8d7284a 100644 --- a/blockdev-nbd.c +++ b/blockdev-nbd.c @@ -27,6 +27,10 @@ typedef struct NBDServerData { static NBDServerData *nbd_server; +static void nbd_blockdev_client_closed(NBDClient *client, bool ignored) +{ + nbd_client_put(client); +} static gboolean nbd_accept(QIOChannel *ioc, GIOCondition condition, gpointer opaque) @@ -46,7 +50,7 @@ static gboolean nbd_accept(QIOChannel *ioc, GIOCondition condition, qio_channel_set_name(QIO_CHANNEL(cioc), "nbd-server"); nbd_client_new(NULL, cioc, nbd_server->tlscreds, NULL, - nbd_client_put); + nbd_blockdev_client_closed); object_unref(OBJECT(cioc)); return TRUE; } diff --git a/include/block/nbd.h b/include/block/nbd.h index 3e373f0..b69c30d 100644 --- a/include/block/nbd.h +++ b/include/block/nbd.h @@ -160,7 +160,7 @@ void nbd_client_new(NBDExport *exp, QIOChannelSocket *sioc, QCryptoTLSCreds *tlscreds, const char *tlsaclname, - void (*close)(NBDClient *)); + void (*close_fn)(NBDClient *, bool)); void nbd_client_get(NBDClient *client); void nbd_client_put(NBDClient *client); diff --git a/nbd/server.c b/nbd/server.c index edfda84..a98bb21 100644 --- a/nbd/server.c +++ b/nbd/server.c @@ -81,7 +81,7 @@ static QTAILQ_HEAD(, NBDExport) exports = QTAILQ_HEAD_INITIALIZER(exports); struct NBDClient { int refcount; - void (*close)(NBDClient *client); + void (*close_fn)(NBDClient *client, bool negotiated); bool no_zeroes; NBDExport *exp; @@ -796,7 +796,7 @@ void nbd_client_put(NBDClient *client) } } -static void client_close(NBDClient *client) +static void client_close(NBDClient *client, bool negotiated) { if (client->closing) { return; @@ -811,8 +811,8 @@ static void client_close(NBDClient *client) NULL); /* Also tell the client, so that they release their reference. */ - if (client->close) { - client->close(client); + if (client->close_fn) { + client->close_fn(client, negotiated); } } @@ -993,7 +993,7 @@ void nbd_export_close(NBDExport *exp) nbd_export_get(exp); QTAILQ_FOREACH_SAFE(client, &exp->clients, next, next) { - client_close(client); + client_close(client, true); } nbd_export_set_name(exp, NULL); nbd_export_set_description(exp, NULL); @@ -1355,7 +1355,7 @@ done: out: nbd_request_put(req); - client_close(client); + client_close(client, true); nbd_client_put(client); } @@ -1381,7 +1381,7 @@ static coroutine_fn void nbd_co_client_start(void *opaque) qemu_co_mutex_init(&client->send_lock); if (nbd_negotiate(data)) { - client_close(client); + client_close(client, false); goto out; } @@ -1391,11 +1391,17 @@ out: g_free(data); } +/* + * Create a new client listener on the given export @exp, using the + * given channel @sioc. Begin servicing it in a coroutine. When the + * connection closes, call @close_fn with an indication of whether the + * client completed negotiation. + */ void nbd_client_new(NBDExport *exp, QIOChannelSocket *sioc, QCryptoTLSCreds *tlscreds, const char *tlsaclname, - void (*close_fn)(NBDClient *)) + void (*close_fn)(NBDClient *, bool)) { NBDClient *client; NBDClientNewData *data = g_new(NBDClientNewData, 1); @@ -1412,7 +1418,7 @@ void nbd_client_new(NBDExport *exp, object_ref(OBJECT(client->sioc)); client->ioc = QIO_CHANNEL(sioc); object_ref(OBJECT(client->ioc)); - client->close = close_fn; + client->close_fn = close_fn; data->client = client; data->co = qemu_coroutine_create(nbd_co_client_start, data); diff --git a/qemu-nbd.c b/qemu-nbd.c index 14e7947..3b55ffa 100644 --- a/qemu-nbd.c +++ b/qemu-nbd.c @@ -335,10 +335,10 @@ static void nbd_export_closed(NBDExport *exp) static void nbd_update_server_watch(void); -static void nbd_client_closed(NBDClient *client) +static void nbd_client_closed(NBDClient *client, bool negotiated) { nb_fds--; - if (nb_fds == 0 && !persistent && state == RUNNING) { + if (negotiated && nb_fds == 0 && !persistent && state == RUNNING) { state = TERMINATE; } nbd_update_server_watch(); From patchwork Tue Aug 29 00:14:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806874 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh9QQ0pvZz9sP5 for ; Tue, 29 Aug 2017 11:04:30 +1000 (AEST) Received: from localhost ([::1]:42155 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUx9-0001rG-Qg for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 21:04:27 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48632) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCk-0001aI-8Y for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCg-0005un-Uo for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:30 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:57765 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCg-0005tX-O6 for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:26 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0E8F3099488 for ; Mon, 28 Aug 2017 20:16:26 -0400 Received: from e35.co.us.ibm.com (e35.co.us.ibm.com [32.97.110.153]) by mx0b-001b2d01.pphosted.com with ESMTP id 2cmr22ykgq-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:26 -0400 Received: from localhost by e35.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 18:16:25 -0600 Received: from b03cxnp08025.gho.boulder.ibm.com (9.17.130.17) by e35.co.us.ibm.com (192.168.1.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 18:16:23 -0600 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0GN7F66519040; Mon, 28 Aug 2017 17:16:23 -0700 Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 43649BE039; Mon, 28 Aug 2017 18:16:23 -0600 (MDT) Received: from localhost (unknown [9.80.85.217]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP id 0FFF9BE038; Mon, 28 Aug 2017 18:16:23 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:35 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0012-0000-0000-000014ECDC53 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:25 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0013-0000-0000-00004F43FB53 Message-Id: <1503965694-10794-61-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 60/79] commit: Fix completion with extra reference 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 , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Kevin Wolf commit_complete() can't assume that after its block_job_completed() the job is actually immediately freed; someone else may still be holding references. In this case, the op blockers on the intermediate nodes make the graph reconfiguration in the completion code fail. Call block_job_remove_all_bdrv() manually so that we know for sure that any blockers on intermediate nodes are given up. Cc: qemu-stable@nongnu.org Signed-off-by: Kevin Wolf Reviewed-by: Eric Blake Reviewed-by: Max Reitz (cherry picked from commit 4f78a16fee462471416dc49b409d57b2071cf3d9) Signed-off-by: Michael Roth --- block/commit.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/block/commit.c b/block/commit.c index 3bae46e..fba25e2 100644 --- a/block/commit.c +++ b/block/commit.c @@ -119,6 +119,13 @@ static void commit_complete(BlockJob *job, void *opaque) } g_free(s->backing_file_str); blk_unref(s->top); + + /* If there is more than one reference to the job (e.g. if called from + * block_job_finish_sync()), block_job_completed() won't free it and + * therefore the blockers on the intermediate nodes remain. This would + * cause bdrv_set_backing_hd() to fail. */ + block_job_remove_all_bdrv(job); + block_job_completed(&s->common, ret); g_free(data); From patchwork Tue Aug 29 00:14:36 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806873 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh9P80Rzzz9sRV for ; Tue, 29 Aug 2017 11:03:24 +1000 (AEST) Received: from localhost ([::1]:42151 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUw6-0000xh-01 for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 21:03:22 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48732) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCn-0001eM-0l for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:36 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCj-000615-RU for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:32 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:35092 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCj-0005zs-MG for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:29 -0400 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0EBKF017922 for ; Mon, 28 Aug 2017 20:16:29 -0400 Received: from e11.ny.us.ibm.com (e11.ny.us.ibm.com [129.33.205.201]) by mx0b-001b2d01.pphosted.com with ESMTP id 2cmub2ww7j-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:29 -0400 Received: from localhost by e11.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 20:16:28 -0400 Received: from b01cxnp22034.gho.pok.ibm.com (9.57.198.24) by e11.ny.us.ibm.com (146.89.104.198) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 20:16:25 -0400 Received: from b01ledav002.gho.pok.ibm.com (b01ledav002.gho.pok.ibm.com [9.57.199.107]) by b01cxnp22034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0GOTV21102718; Tue, 29 Aug 2017 00:16:24 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 04674124037; Mon, 28 Aug 2017 20:13:45 -0400 (EDT) Received: from localhost (unknown [9.80.85.217]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTP id C0720124035; Mon, 28 Aug 2017 20:13:44 -0400 (EDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:36 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-2213-0000-0000-00000210D382 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:27 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-2214-0000-0000-0000575DED35 Message-Id: <1503965694-10794-62-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 61/79] blkdebug: Catch bs->exact_filename overflow 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: qemu-stable@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Max Reitz The bs->exact_filename field may not be sufficient to store the full blkdebug node filename. In this case, we should not generate a filename at all instead of an unusable one. Cc: qemu-stable@nongnu.org Reported-by: Qu Wenruo Signed-off-by: Max Reitz Message-id: 20170613172006.19685-2-mreitz@redhat.com Reviewed-by: Alberto Garcia Reviewed-by: Stefan Hajnoczi Signed-off-by: Max Reitz (cherry picked from commit de81d72d3d13a19edf4d461be3b0f5a877be0234) Signed-off-by: Michael Roth --- block/blkdebug.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/block/blkdebug.c b/block/blkdebug.c index 5ccb9ce..63bc5d4 100644 --- a/block/blkdebug.c +++ b/block/blkdebug.c @@ -840,9 +840,13 @@ static void blkdebug_refresh_filename(BlockDriverState *bs, QDict *options) } if (!force_json && bs->file->bs->exact_filename[0]) { - snprintf(bs->exact_filename, sizeof(bs->exact_filename), - "blkdebug:%s:%s", s->config_file ?: "", - bs->file->bs->exact_filename); + int ret = snprintf(bs->exact_filename, sizeof(bs->exact_filename), + "blkdebug:%s:%s", s->config_file ?: "", + bs->file->bs->exact_filename); + if (ret >= sizeof(bs->exact_filename)) { + /* An overflow makes the filename unusable, so do not report any */ + bs->exact_filename[0] = 0; + } } opts = qdict_new(); From patchwork Tue Aug 29 00:14:37 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806880 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh9VX0hfBz9sP5 for ; Tue, 29 Aug 2017 11:08:04 +1000 (AEST) Received: from localhost ([::1]:42180 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmV0b-000552-TE for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 21:08:01 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48775) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCo-0001fm-4Q for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCk-00064C-NF for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:34 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:35113 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCk-000632-G4 for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:30 -0400 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0E8qK017779 for ; Mon, 28 Aug 2017 20:16:30 -0400 Received: from e14.ny.us.ibm.com (e14.ny.us.ibm.com [129.33.205.204]) by mx0b-001b2d01.pphosted.com with ESMTP id 2cmub2ww7t-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:29 -0400 Received: from localhost by e14.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 20:16:29 -0400 Received: from b01cxnp23034.gho.pok.ibm.com (9.57.198.29) by e14.ny.us.ibm.com (146.89.104.201) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 20:16:26 -0400 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0GPqd22675642; Tue, 29 Aug 2017 00:16:25 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7AD9FB2058; Mon, 28 Aug 2017 20:13:49 -0400 (EDT) Received: from localhost (unknown [9.80.85.217]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP id 4D5DAB2046; Mon, 28 Aug 2017 20:13:49 -0400 (EDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:37 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0052-0000-0000-00000257337D X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:27 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0053-0000-0000-000051D1D9B3 Message-Id: <1503965694-10794-63-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 62/79] blkverify: Catch bs->exact_filename overflow 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: qemu-stable@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Max Reitz The bs->exact_filename field may not be sufficient to store the full blkverify node filename. In this case, we should not generate a filename at all instead of an unusable one. Cc: qemu-stable@nongnu.org Reported-by: Qu Wenruo Signed-off-by: Max Reitz Message-id: 20170613172006.19685-3-mreitz@redhat.com Reviewed-by: Alberto Garcia Reviewed-by: Stefan Hajnoczi Signed-off-by: Max Reitz (cherry picked from commit 05cc758a3dfc79488d0a8eb7f5830a41871e78d0) Signed-off-by: Michael Roth --- block/blkverify.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/block/blkverify.c b/block/blkverify.c index 6b0a603..06369f9 100644 --- a/block/blkverify.c +++ b/block/blkverify.c @@ -301,10 +301,14 @@ static void blkverify_refresh_filename(BlockDriverState *bs, QDict *options) if (bs->file->bs->exact_filename[0] && s->test_file->bs->exact_filename[0]) { - snprintf(bs->exact_filename, sizeof(bs->exact_filename), - "blkverify:%s:%s", - bs->file->bs->exact_filename, - s->test_file->bs->exact_filename); + int ret = snprintf(bs->exact_filename, sizeof(bs->exact_filename), + "blkverify:%s:%s", + bs->file->bs->exact_filename, + s->test_file->bs->exact_filename); + if (ret >= sizeof(bs->exact_filename)) { + /* An overflow makes the filename unusable, so do not report any */ + bs->exact_filename[0] = 0; + } } } From patchwork Tue Aug 29 00:14:38 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806864 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh9DM5316z9s7M for ; Tue, 29 Aug 2017 10:55:47 +1000 (AEST) Received: from localhost ([::1]:42102 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUoj-0002dO-Jo for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:55:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48796) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCo-0001hA-H9 for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:35 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCl-00065C-03 for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:34 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:42607 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCk-00063u-Rv for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:30 -0400 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0E8cC019427 for ; Mon, 28 Aug 2017 20:16:30 -0400 Received: from e18.ny.us.ibm.com (e18.ny.us.ibm.com [129.33.205.208]) by mx0b-001b2d01.pphosted.com with ESMTP id 2cmsfn2wr4-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:30 -0400 Received: from localhost by e18.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 20:16:29 -0400 Received: from b01cxnp22036.gho.pok.ibm.com (9.57.198.26) by e18.ny.us.ibm.com (146.89.104.205) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 20:16:26 -0400 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0GQhX31522884; Tue, 29 Aug 2017 00:16:26 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6E12D112047; Mon, 28 Aug 2017 20:16:12 -0400 (EDT) Received: from localhost (unknown [9.80.85.217]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP id 40D97112054; Mon, 28 Aug 2017 20:16:12 -0400 (EDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:38 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0044-0000-0000-000003847087 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:27 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0045-0000-0000-000007B288FA Message-Id: <1503965694-10794-64-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 63/79] nbd: fix NBD over TLS 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: Paolo Bonzini , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Paolo Bonzini When attaching the NBD QIOChannel to an AioContext, the TLS channel should be used, not the underlying socket channel. This is because, trivially, the TLS channel will be the one that we read/write to and thus the one that will get the qio_channel_yield() call. Fixes: ff82911cd3f69f028f2537825c9720ff78bc3f19 Cc: qemu-stable@nongnu.org Reviewed-by: Stefan Hajnoczi Reviewed-by: Daniel P. Berrange Tested-by: Daniel P. Berrange Signed-off-by: Paolo Bonzini (cherry picked from commit 96d06835dc40007673cdfab6322e9042c4077113) Signed-off-by: Michael Roth --- block/nbd-client.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/block/nbd-client.c b/block/nbd-client.c index 1e2952f..56eb0e2 100644 --- a/block/nbd-client.c +++ b/block/nbd-client.c @@ -352,14 +352,14 @@ int nbd_client_co_pdiscard(BlockDriverState *bs, int64_t offset, int count) void nbd_client_detach_aio_context(BlockDriverState *bs) { NBDClientSession *client = nbd_get_client_session(bs); - qio_channel_detach_aio_context(QIO_CHANNEL(client->sioc)); + qio_channel_detach_aio_context(QIO_CHANNEL(client->ioc)); } void nbd_client_attach_aio_context(BlockDriverState *bs, AioContext *new_context) { NBDClientSession *client = nbd_get_client_session(bs); - qio_channel_attach_aio_context(QIO_CHANNEL(client->sioc), new_context); + qio_channel_attach_aio_context(QIO_CHANNEL(client->ioc), new_context); aio_co_schedule(new_context, client->read_reply_co); } From patchwork Tue Aug 29 00:14:39 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806872 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh9MK03jPz9s7h for ; Tue, 29 Aug 2017 11:01:49 +1000 (AEST) Received: from localhost ([::1]:42145 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUuY-00089Y-RW for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 21:01:46 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48765) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCn-0001fP-SJ for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:37 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCk-000644-Lc for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:33 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:38913 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCk-00062v-Ev for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:30 -0400 Received: from pps.filterd (m0098416.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0EWxq065758 for ; Mon, 28 Aug 2017 20:16:30 -0400 Received: from e16.ny.us.ibm.com (e16.ny.us.ibm.com [129.33.205.206]) by mx0b-001b2d01.pphosted.com with ESMTP id 2cmq0jb031-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:29 -0400 Received: from localhost by e16.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 20:16:29 -0400 Received: from b01cxnp23034.gho.pok.ibm.com (9.57.198.29) by e16.ny.us.ibm.com (146.89.104.203) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 20:16:27 -0400 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp23034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0GQ8v24903800; Tue, 29 Aug 2017 00:16:26 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6DB34AE04E; Mon, 28 Aug 2017 20:16:50 -0400 (EDT) Received: from localhost (unknown [9.80.85.217]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTP id 3B59EAE03C; Mon, 28 Aug 2017 20:16:50 -0400 (EDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:39 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0024-0000-0000-000002C6D2D1 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:28 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0025-0000-0000-0000453E636E Message-Id: <1503965694-10794-65-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 64/79] block: Do not strcmp() with NULL uri->scheme 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: qemu-stable@nongnu.org, Max Reitz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Max Reitz uri_parse(...)->scheme may be NULL. In fact, probably every field may be NULL, and the callers do test this for all of the other fields but not for scheme (except for block/gluster.c; block/vxhs.c does not access that field at all). We can easily fix this by using g_strcmp0() instead of strcmp(). Cc: qemu-stable@nongnu.org Signed-off-by: Max Reitz Message-id: 20170613205726.13544-1-mreitz@redhat.com Reviewed-by: Stefan Hajnoczi Signed-off-by: Max Reitz (cherry picked from commit f69165a8feca055cf4a37d13ab0fc5beec3cb372) Signed-off-by: Michael Roth --- block/nbd.c | 6 +++--- block/nfs.c | 2 +- block/sheepdog.c | 6 +++--- block/ssh.c | 2 +- 4 files changed, 8 insertions(+), 8 deletions(-) diff --git a/block/nbd.c b/block/nbd.c index b3545f5..9a54edf 100644 --- a/block/nbd.c +++ b/block/nbd.c @@ -65,11 +65,11 @@ static int nbd_parse_uri(const char *filename, QDict *options) } /* transport */ - if (!strcmp(uri->scheme, "nbd")) { + if (!g_strcmp0(uri->scheme, "nbd")) { is_unix = false; - } else if (!strcmp(uri->scheme, "nbd+tcp")) { + } else if (!g_strcmp0(uri->scheme, "nbd+tcp")) { is_unix = false; - } else if (!strcmp(uri->scheme, "nbd+unix")) { + } else if (!g_strcmp0(uri->scheme, "nbd+unix")) { is_unix = true; } else { ret = -EINVAL; diff --git a/block/nfs.c b/block/nfs.c index bfeebc1..344186f 100644 --- a/block/nfs.c +++ b/block/nfs.c @@ -83,7 +83,7 @@ static int nfs_parse_uri(const char *filename, QDict *options, Error **errp) error_setg(errp, "Invalid URI specified"); goto out; } - if (strcmp(uri->scheme, "nfs") != 0) { + if (g_strcmp0(uri->scheme, "nfs") != 0) { error_setg(errp, "URI scheme must be 'nfs'"); goto out; } diff --git a/block/sheepdog.c b/block/sheepdog.c index fb9203e..2d8d8c8 100644 --- a/block/sheepdog.c +++ b/block/sheepdog.c @@ -1052,11 +1052,11 @@ static void sd_parse_uri(SheepdogConfig *cfg, const char *filename, } /* transport */ - if (!strcmp(uri->scheme, "sheepdog")) { + if (!g_strcmp0(uri->scheme, "sheepdog")) { is_unix = false; - } else if (!strcmp(uri->scheme, "sheepdog+tcp")) { + } else if (!g_strcmp0(uri->scheme, "sheepdog+tcp")) { is_unix = false; - } else if (!strcmp(uri->scheme, "sheepdog+unix")) { + } else if (!g_strcmp0(uri->scheme, "sheepdog+unix")) { is_unix = true; } else { error_setg(&err, "URI scheme must be 'sheepdog', 'sheepdog+tcp'," diff --git a/block/ssh.c b/block/ssh.c index 34a2f79..139b05d 100644 --- a/block/ssh.c +++ b/block/ssh.c @@ -205,7 +205,7 @@ static int parse_uri(const char *filename, QDict *options, Error **errp) return -EINVAL; } - if (strcmp(uri->scheme, "ssh") != 0) { + if (g_strcmp0(uri->scheme, "ssh") != 0) { error_setg(errp, "URI scheme must be 'ssh'"); goto err; } From patchwork Tue Aug 29 00:14:40 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806876 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh9Qg2SYHz9sP5 for ; Tue, 29 Aug 2017 11:04:43 +1000 (AEST) Received: from localhost ([::1]:42157 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUxN-00022l-5B for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 21:04:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48878) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCr-0001lC-7V for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:38 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCn-0006AN-SD for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:37 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:52787) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCn-00067g-GV for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:33 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0E8eG077484 for ; Mon, 28 Aug 2017 20:16:32 -0400 Received: from e18.ny.us.ibm.com (e18.ny.us.ibm.com [129.33.205.208]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmnx0yvga-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:32 -0400 Received: from localhost by e18.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 20:16:31 -0400 Received: from b01cxnp22036.gho.pok.ibm.com (9.57.198.26) by e18.ny.us.ibm.com (146.89.104.205) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 20:16:28 -0400 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0GR3b31588378; Tue, 29 Aug 2017 00:16:27 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A4E9CAC041; Mon, 28 Aug 2017 20:16:51 -0400 (EDT) Received: from localhost (unknown [9.80.85.217]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP id 6BD31AC046; Mon, 28 Aug 2017 20:16:51 -0400 (EDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:40 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0044-0000-0000-00000384708B X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:29 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0045-0000-0000-000007B288FD Message-Id: <1503965694-10794-66-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 65/79] 9pfs: local: remove: use correct path component 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: Greg Kurz , qemu-stable@nongnu.org, Bruce Rogers Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Bruce Rogers Commit a0e640a8 introduced a path processing error. Pass fstatat the dirpath based path component instead of the entire path. Signed-off-by: Bruce Rogers Signed-off-by: Greg Kurz (cherry picked from commit 790db7efdbe1536acf1c4f4f95a0316dbda59433) Signed-off-by: Michael Roth --- hw/9pfs/9p-local.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index 7a0c383..b13ff21 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -1009,7 +1009,7 @@ static int local_remove(FsContext *ctx, const char *path) goto out; } - if (fstatat(dirfd, path, &stbuf, AT_SYMLINK_NOFOLLOW) < 0) { + if (fstatat(dirfd, name, &stbuf, AT_SYMLINK_NOFOLLOW) < 0) { goto err_out; } From patchwork Tue Aug 29 00:14:41 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806871 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh9Lp433Yz9sP5 for ; Tue, 29 Aug 2017 11:01:22 +1000 (AEST) Received: from localhost ([::1]:42139 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUu8-0007gE-FJ for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 21:01:20 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48866) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCq-0001kl-VN for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:40 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCn-0006A3-OJ for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:36 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:45217) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCn-00067V-El for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:33 -0400 Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0E8Wc041818 for ; Mon, 28 Aug 2017 20:16:32 -0400 Received: from e32.co.us.ibm.com (e32.co.us.ibm.com [32.97.110.150]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmur4vq5b-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:32 -0400 Received: from localhost by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 18:16:31 -0600 Received: from b03cxnp07028.gho.boulder.ibm.com (9.17.130.15) by e32.co.us.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 18:16:28 -0600 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0GSLn4129216; Mon, 28 Aug 2017 17:16:28 -0700 Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4B5306E03F; Mon, 28 Aug 2017 18:16:28 -0600 (MDT) Received: from localhost (unknown [9.80.85.217]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP id 18BA86E03D; Mon, 28 Aug 2017 18:16:28 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:41 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0004-0000-0000-000012D6D52D X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:30 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0005-0000-0000-000080E59EB7 Message-Id: <1503965694-10794-67-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 66/79] hid: Reset kbd modifiers on reset 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: Gerd Hoffmann , qemu-stable@nongnu.org, Alexander Graf Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Alexander Graf When resetting the keyboard, we need to reset not just the pending keystrokes, but also any pending modifiers. Otherwise there's a race when we're getting reset while running an escape sequence (modifier 0x100). Cc: qemu-stable@nongnu.org Signed-off-by: Alexander Graf Message-id: 1498117295-162030-1-git-send-email-agraf@suse.de Signed-off-by: Gerd Hoffmann (cherry picked from commit 51dbea77a29ea46173373a6dad4ebd95d4661f42) Signed-off-by: Michael Roth --- hw/input/hid.c | 1 + 1 file changed, 1 insertion(+) diff --git a/hw/input/hid.c b/hw/input/hid.c index fa9cc4c..a0892e8 100644 --- a/hw/input/hid.c +++ b/hw/input/hid.c @@ -483,6 +483,7 @@ void hid_reset(HIDState *hs) memset(hs->kbd.keycodes, 0, sizeof(hs->kbd.keycodes)); memset(hs->kbd.key, 0, sizeof(hs->kbd.key)); hs->kbd.keys = 0; + hs->kbd.modifiers = 0; break; case HID_MOUSE: case HID_TABLET: From patchwork Tue Aug 29 00:14:42 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806868 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh9Hl4Kyjz9s7g for ; Tue, 29 Aug 2017 10:58:43 +1000 (AEST) Received: from localhost ([::1]:42120 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUrZ-0005Ig-GO for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 20:58:41 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48862) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCq-0001jz-Fy for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCn-000698-AY for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:36 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:35200 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCn-00067v-64 for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:33 -0400 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0E8CG017802 for ; Mon, 28 Aug 2017 20:16:32 -0400 Received: from e36.co.us.ibm.com (e36.co.us.ibm.com [32.97.110.154]) by mx0b-001b2d01.pphosted.com with ESMTP id 2cmub2ww9f-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:32 -0400 Received: from localhost by e36.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 18:16:31 -0600 Received: from b03cxnp07029.gho.boulder.ibm.com (9.17.130.16) by e36.co.us.ibm.com (192.168.1.136) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 18:16:29 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp07029.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0GTwk8323330; Mon, 28 Aug 2017 17:16:29 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 217C67803F; Mon, 28 Aug 2017 18:16:29 -0600 (MDT) Received: from localhost (unknown [9.80.85.217]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP id E530C78037; Mon, 28 Aug 2017 18:16:28 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:42 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0020-0000-0000-00000CA0E9E3 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:31 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0021-0000-0000-00005DE891EC Message-Id: <1503965694-10794-68-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 67/79] spapr: fix migration to pseries machine < 2.8 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: Laurent Vivier , qemu-stable@nongnu.org, David Gibson Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Laurent Vivier since commit 5c4537bd ("spapr: Fix 2.7<->2.8 migration of PCI host bridge"), some migration fields are forged from the new ones in spapr_pci_pre_save(). It works well, except when the number of MSI devices is 0, because in this case the function exits immediately. This fix moves the migration code before the exit code. The problem can be reproduced with these commands: source qemu-2.9: qemu-system-ppc64 -monitor stdio -M pseries-2.6 -nodefaults -S destination qemu-2.6: qemu-system-ppc64 -monitor stdio -M pseries-2.6 -nodefaults \ -incoming tcp:0:4444 on the source: migrate tcp:localhost:4444 Destination fails with the following error: qemu-system-ppc64: error while loading state for instance 0x0 of device 'spapr_pci' qemu-system-ppc64: load of migration failed: Invalid argument Signed-off-by: Laurent Vivier Reviewed-by: Greg Kurz Signed-off-by: David Gibson (cherry picked from commit e806b4db1477a1c6bfda7bba28c7f26c47f18e1e) Signed-off-by: Michael Roth --- hw/ppc/spapr_pci.c | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/hw/ppc/spapr_pci.c b/hw/ppc/spapr_pci.c index 98c52e4..ecfbf01 100644 --- a/hw/ppc/spapr_pci.c +++ b/hw/ppc/spapr_pci.c @@ -1893,20 +1893,6 @@ static void spapr_pci_pre_save(void *opaque) gpointer key, value; int i; - g_free(sphb->msi_devs); - sphb->msi_devs = NULL; - sphb->msi_devs_num = g_hash_table_size(sphb->msi); - if (!sphb->msi_devs_num) { - return; - } - sphb->msi_devs = g_malloc(sphb->msi_devs_num * sizeof(spapr_pci_msi_mig)); - - g_hash_table_iter_init(&iter, sphb->msi); - for (i = 0; g_hash_table_iter_next(&iter, &key, &value); ++i) { - sphb->msi_devs[i].key = *(uint32_t *) key; - sphb->msi_devs[i].value = *(spapr_pci_msi *) value; - } - if (sphb->pre_2_8_migration) { sphb->mig_liobn = sphb->dma_liobn[0]; sphb->mig_mem_win_addr = sphb->mem_win_addr; @@ -1920,6 +1906,20 @@ static void spapr_pci_pre_save(void *opaque) sphb->mig_mem_win_size += sphb->mem64_win_size; } } + + g_free(sphb->msi_devs); + sphb->msi_devs = NULL; + sphb->msi_devs_num = g_hash_table_size(sphb->msi); + if (!sphb->msi_devs_num) { + return; + } + sphb->msi_devs = g_malloc(sphb->msi_devs_num * sizeof(spapr_pci_msi_mig)); + + g_hash_table_iter_init(&iter, sphb->msi); + for (i = 0; g_hash_table_iter_next(&iter, &key, &value); ++i) { + sphb->msi_devs[i].key = *(uint32_t *) key; + sphb->msi_devs[i].value = *(spapr_pci_msi *) value; + } } static int spapr_pci_post_load(void *opaque, int version_id) From patchwork Tue Aug 29 00:14:43 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806877 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh9TN4Dwrz9sP5 for ; Tue, 29 Aug 2017 11:07:03 +1000 (AEST) Received: from localhost ([::1]:42172 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUzc-00049p-SX for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 21:07:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48941) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCs-0001nT-Qa for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCp-0006FF-NW for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:38 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:52864) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCp-0006D8-Fo for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:35 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0GFQg082669 for ; Mon, 28 Aug 2017 20:16:34 -0400 Received: from e37.co.us.ibm.com (e37.co.us.ibm.com [32.97.110.158]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmnx0yvhs-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:34 -0400 Received: from localhost by e37.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 18:16:33 -0600 Received: from b03cxnp08027.gho.boulder.ibm.com (9.17.130.19) by e37.co.us.ibm.com (192.168.1.137) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 18:16:30 -0600 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp08027.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0GUoB64618746; Mon, 28 Aug 2017 17:16:30 -0700 Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0993EBE038; Mon, 28 Aug 2017 18:16:30 -0600 (MDT) Received: from localhost (unknown [9.80.85.217]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP id C7AD9BE03E; Mon, 28 Aug 2017 18:16:29 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:43 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0024-0000-0000-0000171CE4DD X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:32 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0025-0000-0000-00004C7F0576 Message-Id: <1503965694-10794-69-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 68/79] virtio-scsi: finalize IOMMU support 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: Paolo Bonzini , Jason Wang , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Jason Wang After converting to use DMA api for virtio devices, we should use dma_as instead of address_space_memory. Otherwise it won't work if IOMMU is enabled. Fixes: commit 8607f5c3072c ("virtio: convert to use DMA api") Cc: qemu-stable@nongnu.org Signed-off-by: Jason Wang Message-Id: <1499170866-9068-1-git-send-email-jasowang@redhat.com> Signed-off-by: Paolo Bonzini (cherry picked from commit 025bdeab3c163aee9604a60b2332a5fcbcc00f8d) Signed-off-by: Michael Roth --- hw/scsi/virtio-scsi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/hw/scsi/virtio-scsi.c b/hw/scsi/virtio-scsi.c index cb1c123..3915c2e 100644 --- a/hw/scsi/virtio-scsi.c +++ b/hw/scsi/virtio-scsi.c @@ -43,12 +43,13 @@ static inline SCSIDevice *virtio_scsi_device_find(VirtIOSCSI *s, uint8_t *lun) void virtio_scsi_init_req(VirtIOSCSI *s, VirtQueue *vq, VirtIOSCSIReq *req) { + VirtIODevice *vdev = VIRTIO_DEVICE(s); const size_t zero_skip = offsetof(VirtIOSCSIReq, resp_iov) + sizeof(req->resp_iov); req->vq = vq; req->dev = s; - qemu_sglist_init(&req->qsgl, DEVICE(s), 8, &address_space_memory); + qemu_sglist_init(&req->qsgl, DEVICE(s), 8, vdev->dma_as); qemu_iovec_init(&req->resp_iov, 1); memset((uint8_t *)req + zero_skip, 0, sizeof(*req) - zero_skip); } From patchwork Tue Aug 29 00:14:44 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806875 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh9Qd1kmZz9sP5 for ; Tue, 29 Aug 2017 11:04:41 +1000 (AEST) Received: from localhost ([::1]:42156 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUxL-00021Q-2w for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 21:04:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48936) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCs-0001nD-Lx for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:41 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCp-0006FP-RB for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:38 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:50424) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCp-0006DM-J2 for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:35 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0Eec3006452 for ; Mon, 28 Aug 2017 20:16:34 -0400 Received: from e38.co.us.ibm.com (e38.co.us.ibm.com [32.97.110.159]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmvjejm0n-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:34 -0400 Received: from localhost by e38.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 18:16:33 -0600 Received: from b03cxnp08026.gho.boulder.ibm.com (9.17.130.18) by e38.co.us.ibm.com (192.168.1.138) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 18:16:31 -0600 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0GVtp65405136; Mon, 28 Aug 2017 17:16:31 -0700 Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id E5681C603C; Mon, 28 Aug 2017 18:16:30 -0600 (MDT) Received: from localhost (unknown [9.80.85.217]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP id B1A3AC6037; Mon, 28 Aug 2017 18:16:30 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:44 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0028-0000-0000-00000846DB52 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:32 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0029-0000-0000-000037553189 Message-Id: <1503965694-10794-70-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 69/79] commit: Add NULL check for overlay_bs 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 , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Kevin Wolf I can't see how overlay_bs could become NULL with the current code, but other code in this function already checks it and we can make Coverity happy with this check, so let's add it. Cc: qemu-stable@nongnu.org Signed-off-by: Kevin Wolf Reviewed-by: Stefan Hajnoczi (cherry picked from commit b1e1fa0c3afc7f671fbc24645bdf67949a5657e5) Signed-off-by: Michael Roth --- block/commit.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/block/commit.c b/block/commit.c index fba25e2..66e3418 100644 --- a/block/commit.c +++ b/block/commit.c @@ -91,7 +91,9 @@ static void commit_complete(BlockJob *job, void *opaque) /* Make sure overlay_bs and top stay around until bdrv_set_backing_hd() */ bdrv_ref(top); - bdrv_ref(overlay_bs); + if (overlay_bs) { + bdrv_ref(overlay_bs); + } /* Remove base node parent that still uses BLK_PERM_WRITE/RESIZE before * the normal backing chain can be restored. */ From patchwork Tue Aug 29 00:14:45 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806879 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh9Tn238zz9sP5 for ; Tue, 29 Aug 2017 11:07:25 +1000 (AEST) Received: from localhost ([::1]:42176 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUzz-0004Ws-3E for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 21:07:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49010) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCv-0001rJ-A1 for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCs-0006I8-31 for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:41 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:39543) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCr-0006Gl-Q9 for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:37 -0400 Received: from pps.filterd (m0098409.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0E8mN090143 for ; Mon, 28 Aug 2017 20:16:36 -0400 Received: from e13.ny.us.ibm.com (e13.ny.us.ibm.com [129.33.205.203]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmvyehm20-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:36 -0400 Received: from localhost by e13.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 20:16:35 -0400 Received: from b01cxnp22035.gho.pok.ibm.com (9.57.198.25) by e13.ny.us.ibm.com (146.89.104.200) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 20:16:32 -0400 Received: from b01ledav001.gho.pok.ibm.com (b01ledav001.gho.pok.ibm.com [9.57.199.106]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0GVM631785008; Tue, 29 Aug 2017 00:16:31 GMT Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 0D34F28046; Mon, 28 Aug 2017 20:16:25 -0400 (EDT) Received: from localhost (unknown [9.80.85.217]) by b01ledav001.gho.pok.ibm.com (Postfix) with ESMTP id D261E28048; Mon, 28 Aug 2017 20:16:24 -0400 (EDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:45 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0008-0000-0000-00000275D33E X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:34 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0009-0000-0000-000036857B45 Message-Id: <1503965694-10794-71-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 70/79] spapr: fix memory leak in spapr_core_pre_plug() 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: David Gibson , qemu-stable@nongnu.org, Greg Kurz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Greg Kurz In case of error, we must ensure the dynamically allocated base_core_type is freed, like it is done everywhere else in this function. This is a regression introduced in QEMU 2.9 by commit 8149e2992f78. Signed-off-by: Greg Kurz Signed-off-by: David Gibson (cherry picked from commit df8658de43db242ea82183d75cc957c2b0fa013a) Conflicts: hw/ppc/spapr.c * fix context dep on 459264ef2 Signed-off-by: Michael Roth --- hw/ppc/spapr.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/ppc/spapr.c b/hw/ppc/spapr.c index 58c15ef..bda3854 100644 --- a/hw/ppc/spapr.c +++ b/hw/ppc/spapr.c @@ -2805,7 +2805,7 @@ static void spapr_core_pre_plug(HotplugHandler *hotplug_dev, DeviceState *dev, if (cc->nr_threads != smp_threads) { error_setg(errp, "invalid nr-threads %d, must be %d", cc->nr_threads, smp_threads); - return; + goto out; } core_slot = spapr_find_cpu_slot(MACHINE(hotplug_dev), cc->core_id, &index); From patchwork Tue Aug 29 00:14:46 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806881 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh9XP5hyMz9sP5 for ; Tue, 29 Aug 2017 11:09:41 +1000 (AEST) Received: from localhost ([::1]:42185 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmV2B-0006WV-L4 for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 21:09:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48997) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCu-0001qs-Ua for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCr-0006Ha-Ox for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:40 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:57409) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCr-0006GM-H8 for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:37 -0400 Received: from pps.filterd (m0098410.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0EBPK042816 for ; Mon, 28 Aug 2017 20:16:36 -0400 Received: from e15.ny.us.ibm.com (e15.ny.us.ibm.com [129.33.205.205]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmr8nf0mq-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:36 -0400 Received: from localhost by e15.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 20:16:35 -0400 Received: from b01cxnp23033.gho.pok.ibm.com (9.57.198.28) by e15.ny.us.ibm.com (146.89.104.202) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 20:16:33 -0400 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0GXQH3342772; Tue, 29 Aug 2017 00:16:33 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 4A261112051; Mon, 28 Aug 2017 20:16:19 -0400 (EDT) Received: from localhost (unknown [9.80.85.217]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP id 0FCA1112040; Mon, 28 Aug 2017 20:16:19 -0400 (EDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:46 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0036-0000-0000-000002603FA7 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909027; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:35 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0037-0000-0000-000041964AD0 Message-Id: <1503965694-10794-72-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 71/79] virtio-net: fix offload ctrl endian 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: Jason Wang , Dmitry Fleytman , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Jason Wang Spec said offloads should be le64, so use virtio_ldq_p() to guarantee valid endian. Fixes: 644c98587d4c ("virtio-net: dynamic network offloads configuration") Cc: qemu-stable@nongnu.org Cc: Dmitry Fleytman Signed-off-by: Jason Wang (cherry picked from commit 189ae6bb5ce1f5a322f8691d00fe942ba43dd601) Signed-off-by: Michael Roth --- hw/net/virtio-net.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/net/virtio-net.c b/hw/net/virtio-net.c index 98bd683..7695f75 100644 --- a/hw/net/virtio-net.c +++ b/hw/net/virtio-net.c @@ -723,6 +723,8 @@ static int virtio_net_handle_offloads(VirtIONet *n, uint8_t cmd, if (cmd == VIRTIO_NET_CTRL_GUEST_OFFLOADS_SET) { uint64_t supported_offloads; + offloads = virtio_ldq_p(vdev, &offloads); + if (!n->has_vnet_hdr) { return VIRTIO_NET_ERR; } From patchwork Tue Aug 29 00:14:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806882 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh9Xp2JLkz9sQl for ; Tue, 29 Aug 2017 11:10:02 +1000 (AEST) Received: from localhost ([::1]:42187 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmV2W-0006or-4q for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 21:10:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49079) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCx-0001u8-1M for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:44 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCt-0006JE-0f for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:43 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:35504 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCs-0006Id-Q0 for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:38 -0400 Received: from pps.filterd (m0098413.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0E8DR017766 for ; Mon, 28 Aug 2017 20:16:38 -0400 Received: from e13.ny.us.ibm.com (e13.ny.us.ibm.com [129.33.205.203]) by mx0b-001b2d01.pphosted.com with ESMTP id 2cmub2wwdp-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:38 -0400 Received: from localhost by e13.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 20:16:37 -0400 Received: from b01cxnp22036.gho.pok.ibm.com (9.57.198.26) by e13.ny.us.ibm.com (146.89.104.200) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 20:16:34 -0400 Received: from b01ledav005.gho.pok.ibm.com (b01ledav005.gho.pok.ibm.com [9.57.199.110]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0GXCn30867496; Tue, 29 Aug 2017 00:16:33 GMT Received: from b01ledav005.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 42161AE03C; Mon, 28 Aug 2017 20:16:57 -0400 (EDT) Received: from localhost (unknown [9.80.85.217]) by b01ledav005.gho.pok.ibm.com (Postfix) with ESMTP id 0A28EAE034; Mon, 28 Aug 2017 20:16:56 -0400 (EDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:47 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0008-0000-0000-00000275D344 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:36 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0009-0000-0000-000036857B51 Message-Id: <1503965694-10794-73-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 72/79] input: limit kbd queue depth 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: P J P , Huawei PSIRT , qemu-stable@nongnu.org, Gerd Hoffmann Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Gerd Hoffmann Apply a limit to the number of items we accept into the keyboard queue. Impact: Without this limit vnc clients can exhaust host memory by sending keyboard events faster than qemu feeds them to the guest. Fixes: CVE-2017-8379 Cc: P J P Cc: Huawei PSIRT Reported-by: jiangxin1@huawei.com Signed-off-by: Gerd Hoffmann Message-id: 20170428084237.23960-1-kraxel@redhat.com (cherry picked from commit fa18f36a461984eae50ab957e47ec78dae3c14fc) Signed-off-by: Michael Roth --- ui/input.c | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/ui/input.c b/ui/input.c index ed88cda..fb1f404 100644 --- a/ui/input.c +++ b/ui/input.c @@ -41,6 +41,8 @@ static QTAILQ_HEAD(QemuInputEventQueueHead, QemuInputEventQueue) kbd_queue = QTAILQ_HEAD_INITIALIZER(kbd_queue); static QEMUTimer *kbd_timer; static uint32_t kbd_default_delay_ms = 10; +static uint32_t queue_count; +static uint32_t queue_limit = 1024; QemuInputHandlerState *qemu_input_handler_register(DeviceState *dev, QemuInputHandler *handler) @@ -268,6 +270,7 @@ static void qemu_input_queue_process(void *opaque) break; } QTAILQ_REMOVE(queue, item, node); + queue_count--; g_free(item); } } @@ -282,6 +285,7 @@ static void qemu_input_queue_delay(struct QemuInputEventQueueHead *queue, item->delay_ms = delay_ms; item->timer = timer; QTAILQ_INSERT_TAIL(queue, item, node); + queue_count++; if (start_timer) { timer_mod(item->timer, qemu_clock_get_ms(QEMU_CLOCK_VIRTUAL) @@ -298,6 +302,7 @@ static void qemu_input_queue_event(struct QemuInputEventQueueHead *queue, item->src = src; item->evt = evt; QTAILQ_INSERT_TAIL(queue, item, node); + queue_count++; } static void qemu_input_queue_sync(struct QemuInputEventQueueHead *queue) @@ -306,6 +311,7 @@ static void qemu_input_queue_sync(struct QemuInputEventQueueHead *queue) item->type = QEMU_INPUT_QUEUE_SYNC; QTAILQ_INSERT_TAIL(queue, item, node); + queue_count++; } void qemu_input_event_send_impl(QemuConsole *src, InputEvent *evt) @@ -381,7 +387,7 @@ void qemu_input_event_send_key(QemuConsole *src, KeyValue *key, bool down) qemu_input_event_send(src, evt); qemu_input_event_sync(); qapi_free_InputEvent(evt); - } else { + } else if (queue_count < queue_limit) { qemu_input_queue_event(&kbd_queue, src, evt); qemu_input_queue_sync(&kbd_queue); } @@ -409,8 +415,10 @@ void qemu_input_event_send_key_delay(uint32_t delay_ms) kbd_timer = timer_new_ms(QEMU_CLOCK_VIRTUAL, qemu_input_queue_process, &kbd_queue); } - qemu_input_queue_delay(&kbd_queue, kbd_timer, - delay_ms ? delay_ms : kbd_default_delay_ms); + if (queue_count < queue_limit) { + qemu_input_queue_delay(&kbd_queue, kbd_timer, + delay_ms ? delay_ms : kbd_default_delay_ms); + } } InputEvent *qemu_input_event_new_btn(InputButton btn, bool down) From patchwork Tue Aug 29 00:14:48 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806878 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh9Tm1yLbz9sP5 for ; Tue, 29 Aug 2017 11:07:24 +1000 (AEST) Received: from localhost ([::1]:42175 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUzx-0004W3-SG for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 21:07:21 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49008) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCv-0001rH-8d for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:43 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCs-0006IA-2u for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:41 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:34270 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCr-0006HR-Tq for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:37 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0E8wK043828 for ; Mon, 28 Aug 2017 20:16:37 -0400 Received: from e17.ny.us.ibm.com (e17.ny.us.ibm.com [129.33.205.207]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmu3kpetr-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:37 -0400 Received: from localhost by e17.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 20:16:36 -0400 Received: from b01cxnp22033.gho.pok.ibm.com (9.57.198.23) by e17.ny.us.ibm.com (146.89.104.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 20:16:34 -0400 Received: from b01ledav006.gho.pok.ibm.com (b01ledav006.gho.pok.ibm.com [9.57.199.111]) by b01cxnp22033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0GYFj23593182; Tue, 29 Aug 2017 00:16:34 GMT Received: from b01ledav006.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 6F632AC03F; Mon, 28 Aug 2017 20:16:58 -0400 (EDT) Received: from localhost (unknown [9.80.85.217]) by b01ledav006.gho.pok.ibm.com (Postfix) with ESMTP id 373B4AC03A; Mon, 28 Aug 2017 20:16:58 -0400 (EDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:48 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0040-0000-0000-00000396DF12 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:35 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0041-0000-0000-0000078B1093 Message-Id: <1503965694-10794-74-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 73/79] input: Decrement queue count on kbd delay 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: Gerd Hoffmann , qemu-stable@nongnu.org, Alexander Graf Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Alexander Graf Delays in the input layer are special cased input events. Every input event is accounted for in a global intput queue count. The special cased delays however did not get removed from the queue, leading to queue overruns and thus silent key drops after typing quite a few characters. Signed-off-by: Alexander Graf Message-id: 1498117318-162102-1-git-send-email-agraf@suse.de Fixes: be1a7176 ("input: add support for kbd delays") Cc: qemu-stable@nongnu.org Signed-off-by: Gerd Hoffmann (cherry picked from commit 77b0359bf414ad666d1714dc9888f1017c08e283) Signed-off-by: Michael Roth --- ui/input.c | 1 + 1 file changed, 1 insertion(+) diff --git a/ui/input.c b/ui/input.c index fb1f404..94ba3d5 100644 --- a/ui/input.c +++ b/ui/input.c @@ -252,6 +252,7 @@ static void qemu_input_queue_process(void *opaque) item = QTAILQ_FIRST(queue); g_assert(item->type == QEMU_INPUT_QUEUE_DELAY); QTAILQ_REMOVE(queue, item, node); + queue_count--; g_free(item); while (!QTAILQ_EMPTY(queue)) { From patchwork Tue Aug 29 00:14:49 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806889 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh9bs2C4Tz9sP5 for ; Tue, 29 Aug 2017 11:12:41 +1000 (AEST) Received: from localhost ([::1]:42206 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmV55-00014b-3P for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 21:12:39 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49027) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCv-0001s8-TO for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:45 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCu-0006K8-4q for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:41 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:42917 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCt-0006Jg-V5 for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:40 -0400 Received: from pps.filterd (m0098414.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0EAbU019556 for ; Mon, 28 Aug 2017 20:16:39 -0400 Received: from e38.co.us.ibm.com (e38.co.us.ibm.com [32.97.110.159]) by mx0b-001b2d01.pphosted.com with ESMTP id 2cmsfn2wwu-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:39 -0400 Received: from localhost by e38.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 18:16:38 -0600 Received: from b03cxnp07028.gho.boulder.ibm.com (9.17.130.15) by e38.co.us.ibm.com (192.168.1.138) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 18:16:35 -0600 Received: from b03ledav001.gho.boulder.ibm.com (b03ledav001.gho.boulder.ibm.com [9.17.130.232]) by b03cxnp07028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0GZii4456708; Mon, 28 Aug 2017 17:16:35 -0700 Received: from b03ledav001.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 13AB46E038; Mon, 28 Aug 2017 18:16:35 -0600 (MDT) Received: from localhost (unknown [9.80.85.217]) by b03ledav001.gho.boulder.ibm.com (Postfix) with ESMTP id D56996E035; Mon, 28 Aug 2017 18:16:34 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:49 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0028-0000-0000-00000846DB56 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:37 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0029-0000-0000-00003755319A Message-Id: <1503965694-10794-75-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 74/79] qemu-iotests: Test automatic commit job cancel 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: Kevin Wolf , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Kevin Wolf Signed-off-by: Kevin Wolf Reviewed-by: John Snow (cherry picked from commit c3971b883a596abc6af45f53d2f43fb2f59ccd3b) *prereq for d3c8c674 Signed-off-by: Michael Roth --- tests/qemu-iotests/040 | 35 +++++++++++++++++++++++++++++++++-- tests/qemu-iotests/040.out | 4 ++-- 2 files changed, 35 insertions(+), 4 deletions(-) diff --git a/tests/qemu-iotests/040 b/tests/qemu-iotests/040 index 5bdaf3d..9d381d9 100755 --- a/tests/qemu-iotests/040 +++ b/tests/qemu-iotests/040 @@ -70,7 +70,9 @@ class ImageCommitTestCase(iotests.QMPTestCase): self.wait_for_complete() class TestSingleDrive(ImageCommitTestCase): - image_len = 1 * 1024 * 1024 + # Need some space after the copied data so that throttling is effective in + # tests that use it rather than just completing the job immediately + image_len = 2 * 1024 * 1024 test_len = 1 * 1024 * 256 def setUp(self): @@ -79,7 +81,9 @@ class TestSingleDrive(ImageCommitTestCase): qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % mid_img, test_img) qemu_io('-f', 'raw', '-c', 'write -P 0xab 0 524288', backing_img) qemu_io('-f', iotests.imgfmt, '-c', 'write -P 0xef 524288 524288', mid_img) - self.vm = iotests.VM().add_drive(test_img) + self.vm = iotests.VM().add_drive(test_img, interface="none") + self.vm.add_device("virtio-scsi-pci") + self.vm.add_device("scsi-hd,id=scsi0,drive=drive0") self.vm.launch() def tearDown(self): @@ -131,6 +135,33 @@ class TestSingleDrive(ImageCommitTestCase): self.assert_qmp(result, 'error/class', 'GenericError') self.assert_qmp(result, 'error/desc', 'Base \'%s\' not found' % mid_img) + # When the job is running on a BB that is automatically deleted on hot + # unplug, the job is cancelled when the device disappears + def test_hot_unplug(self): + if self.image_len == 0: + return + + self.assert_no_active_block_jobs() + result = self.vm.qmp('block-commit', device='drive0', top=mid_img, + base=backing_img, speed=(self.image_len / 4)) + self.assert_qmp(result, 'return', {}) + result = self.vm.qmp('device_del', id='scsi0') + self.assert_qmp(result, 'return', {}) + + cancelled = False + deleted = False + while not cancelled or not deleted: + for event in self.vm.get_qmp_events(wait=True): + if event['event'] == 'DEVICE_DELETED': + self.assert_qmp(event, 'data/device', 'scsi0') + deleted = True + elif event['event'] == 'BLOCK_JOB_CANCELLED': + self.assert_qmp(event, 'data/device', 'drive0') + cancelled = True + else: + self.fail("Unexpected event %s" % (event['event'])) + + self.assert_no_active_block_jobs() class TestRelativePaths(ImageCommitTestCase): image_len = 1 * 1024 * 1024 diff --git a/tests/qemu-iotests/040.out b/tests/qemu-iotests/040.out index 4fd1c2d..6d9bee1 100644 --- a/tests/qemu-iotests/040.out +++ b/tests/qemu-iotests/040.out @@ -1,5 +1,5 @@ -......................... +........................... ---------------------------------------------------------------------- -Ran 25 tests +Ran 27 tests OK From patchwork Tue Aug 29 00:14:50 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806891 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh9fP6n27z9sP5 for ; Tue, 29 Aug 2017 11:14:53 +1000 (AEST) Received: from localhost ([::1]:42221 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmV7D-00032n-Nm for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 21:14:51 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49088) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCx-0001uL-6i for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:46 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCt-0006JM-7y for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:43 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:56179 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCt-0006Is-0H for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:39 -0400 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0ESbC087634 for ; Mon, 28 Aug 2017 20:16:38 -0400 Received: from e32.co.us.ibm.com (e32.co.us.ibm.com [32.97.110.150]) by mx0b-001b2d01.pphosted.com with ESMTP id 2cmvhgarmn-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:38 -0400 Received: from localhost by e32.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 18:16:37 -0600 Received: from b03cxnp08026.gho.boulder.ibm.com (9.17.130.18) by e32.co.us.ibm.com (192.168.1.132) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 18:16:36 -0600 Received: from b03ledav002.gho.boulder.ibm.com (b03ledav002.gho.boulder.ibm.com [9.17.130.233]) by b03cxnp08026.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0GanL65208360; Mon, 28 Aug 2017 17:16:36 -0700 Received: from b03ledav002.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 07D71136040; Mon, 28 Aug 2017 18:16:36 -0600 (MDT) Received: from localhost (unknown [9.80.85.217]) by b03ledav002.gho.boulder.ibm.com (Postfix) with ESMTP id BEFFB13603A; Mon, 28 Aug 2017 18:16:35 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:50 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0004-0000-0000-000012D6D532 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:37 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0005-0000-0000-000080E59ECB Message-Id: <1503965694-10794-76-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 75/79] block: Skip implicit nodes in query-block/blockstats 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 , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Kevin Wolf Commits 0db832f and 6cdbceb introduced the automatic insertion of filter nodes above the top layer of mirror and commit block jobs. The assumption made there was that since libvirt doesn't do node-level management of the block layer yet, it shouldn't be affected by added nodes. This is true as far as commands issued by libvirt are concerned. It only uses BlockBackend names to address nodes, so any operations it performs still operate on the root of the tree as intended. However, the assumption breaks down when you consider query commands, which return data for the wrong node now. These commands also return information on some child nodes (bs->file and/or bs->backing), which libvirt does make use of, and which refer to the wrong nodes, too. One of the consequences is that oVirt gets wrong information about the image size and stops the VM in response as long as a mirror or commit job is running: https://bugzilla.redhat.com/show_bug.cgi?id=1470634 This patch fixes the problem by hiding the implicit nodes created automatically by the mirror and commit block jobs in the output of query-block and BlockBackend-based query-blockstats as long as the user doesn't indicate that they are aware of those nodes by providing a node name for them in the QMP command to start the block job. The node-based commands query-named-block-nodes and query-blockstats with query-nodes=true still show all nodes, including implicit ones. This ensures that users that are capable of node-level management can still access the full information; users that only know BlockBackends won't use these commands. Cc: qemu-stable@nongnu.org Signed-off-by: Kevin Wolf Reviewed-by: Peter Krempa Reviewed-by: Max Reitz Tested-by: Eric Blake (cherry picked from commit d3c8c67469ee70fcae116d5abc277a7ebc8a19fd) Conflicts: block/qapi.c include/block/block_int.h * fix context deps on 46eade7b and 5a9347c6 Signed-off-by: Michael Roth --- block.c | 13 ------------- block/commit.c | 3 +++ block/mirror.c | 3 +++ block/qapi.c | 34 ++++++++++++++++++++++++++++------ include/block/block.h | 1 - include/block/block_int.h | 1 + qapi/block-core.json | 6 ++++-- tests/qemu-iotests/040 | 30 +++++++++++++++++++++++++++++- tests/qemu-iotests/040.out | 4 ++-- tests/qemu-iotests/041 | 38 +++++++++++++++++++++++++++++++++++++- tests/qemu-iotests/041.out | 4 ++-- 11 files changed, 109 insertions(+), 28 deletions(-) diff --git a/block.c b/block.c index 21cb65e..46ea4a3 100644 --- a/block.c +++ b/block.c @@ -3863,19 +3863,6 @@ BlockDriverState *bdrv_find_backing_image(BlockDriverState *bs, return retval; } -int bdrv_get_backing_file_depth(BlockDriverState *bs) -{ - if (!bs->drv) { - return 0; - } - - if (!bs->backing) { - return 0; - } - - return 1 + bdrv_get_backing_file_depth(bs->backing->bs); -} - void bdrv_init(void) { module_call_init(MODULE_INIT_BLOCK); diff --git a/block/commit.c b/block/commit.c index 66e3418..b4c1be7 100644 --- a/block/commit.c +++ b/block/commit.c @@ -351,6 +351,9 @@ void commit_start(const char *job_id, BlockDriverState *bs, if (commit_top_bs == NULL) { goto fail; } + if (!filter_node_name) { + commit_top_bs->implicit = true; + } commit_top_bs->total_sectors = top->total_sectors; bdrv_set_aio_context(commit_top_bs, bdrv_get_aio_context(top)); diff --git a/block/mirror.c b/block/mirror.c index 4e8f124..9bf5f89 100644 --- a/block/mirror.c +++ b/block/mirror.c @@ -1152,6 +1152,9 @@ static void mirror_start_job(const char *job_id, BlockDriverState *bs, if (mirror_top_bs == NULL) { return; } + if (!filter_node_name) { + mirror_top_bs->implicit = true; + } mirror_top_bs->total_sectors = bs->total_sectors; bdrv_set_aio_context(mirror_top_bs, bdrv_get_aio_context(bs)); diff --git a/block/qapi.c b/block/qapi.c index a40922e..803205b 100644 --- a/block/qapi.c +++ b/block/qapi.c @@ -64,7 +64,6 @@ BlockDeviceInfo *bdrv_block_device_info(BlockBackend *blk, info->backing_file = g_strdup(bs->backing_file); } - info->backing_file_depth = bdrv_get_backing_file_depth(bs); info->detect_zeroes = bs->detect_zeroes; if (blk && blk_get_public(blk)->throttle_state) { @@ -125,6 +124,7 @@ BlockDeviceInfo *bdrv_block_device_info(BlockBackend *blk, bs0 = bs; p_image_info = &info->image; + info->backing_file_depth = 0; while (1) { Error *local_err = NULL; bdrv_query_image_info(bs0, p_image_info, &local_err); @@ -133,13 +133,21 @@ BlockDeviceInfo *bdrv_block_device_info(BlockBackend *blk, qapi_free_BlockDeviceInfo(info); return NULL; } + if (bs0->drv && bs0->backing) { + info->backing_file_depth++; bs0 = bs0->backing->bs; (*p_image_info)->has_backing_image = true; p_image_info = &((*p_image_info)->backing_image); } else { break; } + + /* Skip automatically inserted nodes that the user isn't aware of for + * query-block (blk != NULL), but not for query-named-block-nodes */ + while (blk && bs0 && bs0->drv && bs0->implicit) { + bs0 = backing_bs(bs0); + } } return info; @@ -322,6 +330,12 @@ static void bdrv_query_info(BlockBackend *blk, BlockInfo **p_info, { BlockInfo *info = g_malloc0(sizeof(*info)); BlockDriverState *bs = blk_bs(blk); + + /* Skip automatically inserted nodes that the user isn't aware of */ + while (bs && bs->drv && bs->implicit) { + bs = backing_bs(bs); + } + info->device = g_strdup(blk_name(blk)); info->type = g_strdup("unknown"); info->locked = blk_dev_is_medium_locked(blk); @@ -424,8 +438,8 @@ static void bdrv_query_blk_stats(BlockDeviceStats *ds, BlockBackend *blk) } } -static BlockStats *bdrv_query_bds_stats(const BlockDriverState *bs, - bool query_backing) +static BlockStats *bdrv_query_bds_stats(BlockDriverState *bs, + bool blk_level) { BlockStats *s = NULL; @@ -436,6 +450,14 @@ static BlockStats *bdrv_query_bds_stats(const BlockDriverState *bs, return s; } + /* Skip automatically inserted nodes that the user isn't aware of in + * a BlockBackend-level command. Stay at the exact node for a node-level + * command. */ + while (blk_level && bs->drv && bs->implicit) { + bs = backing_bs(bs); + assert(bs); + } + if (bdrv_get_node_name(bs)[0]) { s->has_node_name = true; s->node_name = g_strdup(bdrv_get_node_name(bs)); @@ -445,12 +467,12 @@ static BlockStats *bdrv_query_bds_stats(const BlockDriverState *bs, if (bs->file) { s->has_parent = true; - s->parent = bdrv_query_bds_stats(bs->file->bs, query_backing); + s->parent = bdrv_query_bds_stats(bs->file->bs, blk_level); } - if (query_backing && bs->backing) { + if (blk_level && bs->backing) { s->has_backing = true; - s->backing = bdrv_query_bds_stats(bs->backing->bs, query_backing); + s->backing = bdrv_query_bds_stats(bs->backing->bs, blk_level); } return s; diff --git a/include/block/block.h b/include/block/block.h index 4bf4843..060c08c 100644 --- a/include/block/block.h +++ b/include/block/block.h @@ -292,7 +292,6 @@ int coroutine_fn bdrv_co_pwrite_zeroes(BdrvChild *child, int64_t offset, int count, BdrvRequestFlags flags); BlockDriverState *bdrv_find_backing_image(BlockDriverState *bs, const char *backing_file); -int bdrv_get_backing_file_depth(BlockDriverState *bs); void bdrv_refresh_filename(BlockDriverState *bs); int bdrv_truncate(BdrvChild *child, int64_t offset, Error **errp); int64_t bdrv_nb_sectors(BlockDriverState *bs); diff --git a/include/block/block_int.h b/include/block/block_int.h index 59400bd..89d7b45 100644 --- a/include/block/block_int.h +++ b/include/block/block_int.h @@ -518,6 +518,7 @@ struct BlockDriverState { bool valid_key; /* if true, a valid encryption key has been set */ bool sg; /* if true, the device is a /dev/sg* */ bool probed; /* if true, format was probed rather than specified */ + bool implicit; /* if true, this filter node was automatically inserted */ BlockDriver *drv; /* NULL means no media */ void *opaque; diff --git a/qapi/block-core.json b/qapi/block-core.json index 38edada..7ce90ec 100644 --- a/qapi/block-core.json +++ b/qapi/block-core.json @@ -467,7 +467,8 @@ # # Get a list of BlockInfo for all virtual block devices. # -# Returns: a list of @BlockInfo describing each virtual block device +# Returns: a list of @BlockInfo describing each virtual block device. Filter +# nodes that were created implicitly are skipped over. # # Since: 0.14.0 # @@ -723,7 +724,8 @@ # information, but not "backing". # If false or omitted, the behavior is as before - query all the # device backends, recursively including their "parent" and -# "backing". (Since 2.3) +# "backing". Filter nodes that were created implicitly are +# skipped over in this mode. (Since 2.3) # # Returns: A list of @BlockStats for each virtual block devices. # diff --git a/tests/qemu-iotests/040 b/tests/qemu-iotests/040 index 9d381d9..95b7510 100755 --- a/tests/qemu-iotests/040 +++ b/tests/qemu-iotests/040 @@ -81,7 +81,7 @@ class TestSingleDrive(ImageCommitTestCase): qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % mid_img, test_img) qemu_io('-f', 'raw', '-c', 'write -P 0xab 0 524288', backing_img) qemu_io('-f', iotests.imgfmt, '-c', 'write -P 0xef 524288 524288', mid_img) - self.vm = iotests.VM().add_drive(test_img, interface="none") + self.vm = iotests.VM().add_drive(test_img, "node-name=top,backing.node-name=mid,backing.backing.node-name=base", interface="none") self.vm.add_device("virtio-scsi-pci") self.vm.add_device("scsi-hd,id=scsi0,drive=drive0") self.vm.launch() @@ -163,6 +163,34 @@ class TestSingleDrive(ImageCommitTestCase): self.assert_no_active_block_jobs() + # Tests that the insertion of the commit_top filter node doesn't make a + # difference to query-blockstat + def test_implicit_node(self): + if self.image_len == 0: + return + + self.assert_no_active_block_jobs() + result = self.vm.qmp('block-commit', device='drive0', top=mid_img, + base=backing_img, speed=(self.image_len / 4)) + self.assert_qmp(result, 'return', {}) + + result = self.vm.qmp('query-block') + self.assert_qmp(result, 'return[0]/inserted/file', test_img) + self.assert_qmp(result, 'return[0]/inserted/drv', iotests.imgfmt) + self.assert_qmp(result, 'return[0]/inserted/backing_file', mid_img) + self.assert_qmp(result, 'return[0]/inserted/backing_file_depth', 2) + self.assert_qmp(result, 'return[0]/inserted/image/filename', test_img) + self.assert_qmp(result, 'return[0]/inserted/image/backing-image/filename', mid_img) + self.assert_qmp(result, 'return[0]/inserted/image/backing-image/backing-image/filename', backing_img) + + result = self.vm.qmp('query-blockstats') + self.assert_qmp(result, 'return[0]/node-name', 'top') + self.assert_qmp(result, 'return[0]/backing/node-name', 'mid') + self.assert_qmp(result, 'return[0]/backing/backing/node-name', 'base') + + self.cancel_and_wait() + self.assert_no_active_block_jobs() + class TestRelativePaths(ImageCommitTestCase): image_len = 1 * 1024 * 1024 test_len = 1 * 1024 * 256 diff --git a/tests/qemu-iotests/040.out b/tests/qemu-iotests/040.out index 6d9bee1..e20a75c 100644 --- a/tests/qemu-iotests/040.out +++ b/tests/qemu-iotests/040.out @@ -1,5 +1,5 @@ -........................... +............................. ---------------------------------------------------------------------- -Ran 27 tests +Ran 29 tests OK diff --git a/tests/qemu-iotests/041 b/tests/qemu-iotests/041 index 2f54986..60f09cc 100755 --- a/tests/qemu-iotests/041 +++ b/tests/qemu-iotests/041 @@ -42,7 +42,7 @@ class TestSingleDrive(iotests.QMPTestCase): def setUp(self): iotests.create_image(backing_img, self.image_len) qemu_img('create', '-f', iotests.imgfmt, '-o', 'backing_file=%s' % backing_img, test_img) - self.vm = iotests.VM().add_drive(test_img) + self.vm = iotests.VM().add_drive(test_img, "node-name=top,backing.node-name=base") if iotests.qemu_default_machine == 'pc': self.vm.add_drive(None, 'media=cdrom', 'ide') self.vm.launch() @@ -169,6 +169,42 @@ class TestSingleDrive(iotests.QMPTestCase): self.assertTrue(iotests.compare_images(test_img, target_img), 'target image does not match source after mirroring') + # Tests that the insertion of the mirror_top filter node doesn't make a + # difference to query-block + def test_implicit_node(self): + self.assert_no_active_block_jobs() + + result = self.vm.qmp(self.qmp_cmd, device='drive0', sync='full', + target=self.qmp_target) + self.assert_qmp(result, 'return', {}) + + result = self.vm.qmp('query-block') + self.assert_qmp(result, 'return[0]/inserted/file', test_img) + self.assert_qmp(result, 'return[0]/inserted/drv', iotests.imgfmt) + self.assert_qmp(result, 'return[0]/inserted/backing_file', backing_img) + self.assert_qmp(result, 'return[0]/inserted/backing_file_depth', 1) + self.assert_qmp(result, 'return[0]/inserted/image/filename', test_img) + self.assert_qmp(result, 'return[0]/inserted/image/backing-image/filename', backing_img) + + result = self.vm.qmp('query-blockstats') + self.assert_qmp(result, 'return[0]/node-name', 'top') + self.assert_qmp(result, 'return[0]/backing/node-name', 'base') + + self.cancel_and_wait(force=True) + result = self.vm.qmp('query-block') + self.assert_qmp(result, 'return[0]/inserted/file', test_img) + self.assert_qmp(result, 'return[0]/inserted/drv', iotests.imgfmt) + self.assert_qmp(result, 'return[0]/inserted/backing_file', backing_img) + self.assert_qmp(result, 'return[0]/inserted/backing_file_depth', 1) + self.assert_qmp(result, 'return[0]/inserted/image/filename', test_img) + self.assert_qmp(result, 'return[0]/inserted/image/backing-image/filename', backing_img) + + result = self.vm.qmp('query-blockstats') + self.assert_qmp(result, 'return[0]/node-name', 'top') + self.assert_qmp(result, 'return[0]/backing/node-name', 'base') + + self.vm.shutdown() + def test_medium_not_found(self): if iotests.qemu_default_machine != 'pc': return diff --git a/tests/qemu-iotests/041.out b/tests/qemu-iotests/041.out index e30fd3b..c28b392 100644 --- a/tests/qemu-iotests/041.out +++ b/tests/qemu-iotests/041.out @@ -1,5 +1,5 @@ -............................................................................... +..................................................................................... ---------------------------------------------------------------------- -Ran 79 tests +Ran 85 tests OK From patchwork Tue Aug 29 00:14:51 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806890 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh9cG14mBz9sQl for ; Tue, 29 Aug 2017 11:13:02 +1000 (AEST) Received: from localhost ([::1]:42209 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmV5P-0001TP-UG for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 21:13:00 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49194) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUD0-0001zN-Bv for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:47 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCw-0006MK-Aa for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:46 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:34486 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCw-0006Lk-1m for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:42 -0400 Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0E83x043864 for ; Mon, 28 Aug 2017 20:16:41 -0400 Received: from e38.co.us.ibm.com (e38.co.us.ibm.com [32.97.110.159]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmu3kpexg-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:41 -0400 Received: from localhost by e38.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 18:16:40 -0600 Received: from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e38.co.us.ibm.com (192.168.1.138) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 18:16:37 -0600 Received: from b03ledav003.gho.boulder.ibm.com (b03ledav003.gho.boulder.ibm.com [9.17.130.234]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0GbH832637142; Mon, 28 Aug 2017 17:16:37 -0700 Received: from b03ledav003.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id DDF746A045; Mon, 28 Aug 2017 18:16:36 -0600 (MDT) Received: from localhost (unknown [9.80.85.217]) by b03ledav003.gho.boulder.ibm.com (Postfix) with ESMTP id AB6786A03C; Mon, 28 Aug 2017 18:16:36 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:51 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0028-0000-0000-00000846DB57 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:39 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0029-0000-0000-00003755319D Message-Id: <1503965694-10794-77-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 76/79] cpu: don't allow negative core id 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: Laurent Vivier , qemu-stable@nongnu.org, Eduardo Habkost Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Laurent Vivier With pseries machine type a negative core-id is not managed properly: -1 gives an inaccurate error message ("core -1 already populated"), -2 crashes QEMU (core dump) As it seems a negative value is invalid for any architecture, instead of checking this in spapr_core_pre_plug() I think it's better to check this in the generic part, core_prop_set_core_id() Signed-off-by: Laurent Vivier Message-Id: <20170802103259.25940-1-lvivier@redhat.com> Reviewed-by: Greg Kurz Reviewed-by: David Gibson Reviewed-by: Eduardo Habkost Signed-off-by: Eduardo Habkost (cherry picked from commit be2960baae07e5257cde8c814cbd91647e235147) Signed-off-by: Michael Roth --- hw/cpu/core.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/cpu/core.c b/hw/cpu/core.c index 2bf960d..bd578ab 100644 --- a/hw/cpu/core.c +++ b/hw/cpu/core.c @@ -33,6 +33,11 @@ static void core_prop_set_core_id(Object *obj, Visitor *v, const char *name, return; } + if (value < 0) { + error_setg(errp, "Invalid core id %"PRId64, value); + return; + } + core->core_id = value; } From patchwork Tue Aug 29 00:14:52 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806894 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh9kS37WSz9s7m for ; Tue, 29 Aug 2017 11:18:22 +1000 (AEST) Received: from localhost ([::1]:42244 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmVAZ-0006M1-BC for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 21:18:19 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49190) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUD0-0001zL-BH for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCw-0006Me-EE for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:46 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:56332 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCw-0006Lp-51 for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:42 -0400 Received: from pps.filterd (m0098419.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0ESGn087684 for ; Mon, 28 Aug 2017 20:16:41 -0400 Received: from e31.co.us.ibm.com (e31.co.us.ibm.com [32.97.110.149]) by mx0b-001b2d01.pphosted.com with ESMTP id 2cmvhgarq2-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:41 -0400 Received: from localhost by e31.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 18:16:40 -0600 Received: from b03cxnp08025.gho.boulder.ibm.com (9.17.130.17) by e31.co.us.ibm.com (192.168.1.131) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 18:16:38 -0600 Received: from b03ledav004.gho.boulder.ibm.com (b03ledav004.gho.boulder.ibm.com [9.17.130.235]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0Gb4f2752874; Mon, 28 Aug 2017 17:16:37 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id B9C4478047; Mon, 28 Aug 2017 18:16:37 -0600 (MDT) Received: from localhost (unknown [9.80.85.217]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP id 8A81B78038; Mon, 28 Aug 2017 18:16:37 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:52 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-8235-0000-0000-00000C2FE7D8 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:39 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-8236-0000-0000-00003D6C0756 Message-Id: <1503965694-10794-78-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=1 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 77/79] hw/i386: allow SHPC for Q35 machine 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: "Michael S . Tsirkin" , qemu-stable@nongnu.org, Aleksandr Bezzubikov Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Aleksandr Bezzubikov Unmask previously masked SHPC feature in _OSC method. Signed-off-by: Aleksandr Bezzubikov Reviewed-by: Marcel Apfelbaum Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin (cherry picked from commit a41c78c135eb1850826e96b2154690323ff66719) Signed-off-by: Michael Roth --- hw/i386/acpi-build.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c index 2073108..76fa455 100644 --- a/hw/i386/acpi-build.c +++ b/hw/i386/acpi-build.c @@ -1818,9 +1818,9 @@ static Aml *build_q35_osc_method(void) /* * Always allow native PME, AER (no dependencies) - * Never allow SHPC (no SHPC controller in this system) + * Allow SHPC (PCI bridges can have SHPC controller) */ - aml_append(if_ctx, aml_and(a_ctrl, aml_int(0x1D), a_ctrl)); + aml_append(if_ctx, aml_and(a_ctrl, aml_int(0x1F), a_ctrl)); if_ctx2 = aml_if(aml_lnot(aml_equal(aml_arg(1), aml_int(1)))); /* Unknown revision */ From patchwork Tue Aug 29 00:14:53 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806893 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh9gh391Yz9sQl for ; Tue, 29 Aug 2017 11:16:00 +1000 (AEST) Received: from localhost ([::1]:42233 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmV8H-0004OU-W4 for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 21:15:58 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49170) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUCz-0001xs-Jp for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:49 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCw-0006M9-7q for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:45 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:58301 helo=mx0a-001b2d01.pphosted.com) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCv-0006La-Va for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:42 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0E8nu099508 for ; Mon, 28 Aug 2017 20:16:41 -0400 Received: from e35.co.us.ibm.com (e35.co.us.ibm.com [32.97.110.153]) by mx0b-001b2d01.pphosted.com with ESMTP id 2cmr22ykt5-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:41 -0400 Received: from localhost by e35.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 18:16:40 -0600 Received: from b03cxnp08025.gho.boulder.ibm.com (9.17.130.17) by e35.co.us.ibm.com (192.168.1.135) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 18:16:39 -0600 Received: from b03ledav005.gho.boulder.ibm.com (b03ledav005.gho.boulder.ibm.com [9.17.130.236]) by b03cxnp08025.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0GckB2752888; Mon, 28 Aug 2017 17:16:38 -0700 Received: from b03ledav005.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 9C7B3BE040; Mon, 28 Aug 2017 18:16:38 -0600 (MDT) Received: from localhost (unknown [9.80.85.217]) by b03ledav005.gho.boulder.ibm.com (Postfix) with ESMTP id 687BFBE03A; Mon, 28 Aug 2017 18:16:38 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:53 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17082900-0012-0000-0000-000014ECDC63 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:40 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0013-0000-0000-00004F43FB7A Message-Id: <1503965694-10794-79-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: [Qemu-devel] [PATCH 78/79] block/nfs: fix mutex assertion in nfs_file_close() 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 , Jeff Cody , qemu-stable@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Jeff Cody Commit c096358e747e88fc7364e40e3c354ee0bb683960 introduced assertion checks for when qemu_mutex() functions are called without the corresponding qemu_mutex_init() having initialized the mutex. This uncovered a latent bug in qemu's nfs driver - in nfs_client_close(), the NFSClient structure is overwritten with zeros, prior to the mutex being destroyed. Go ahead and destroy the mutex in nfs_client_close(), and change where we call qemu_mutex_init() so that it is correctly balanced. There are also a couple of memory leaks obscured by the memset, so this fixes those as well. Finally, we should be able to get rid of the memset(), as it isn't necessary. Cc: qemu-stable@nongnu.org Signed-off-by: Jeff Cody Reviewed-by: Peter Lieven Reviewed-by: Stefan Hajnoczi Reviewed-by: John Snow Signed-off-by: Kevin Wolf (cherry picked from commit 113fe792fd4931dd0538f03859278b8719ee4fa2) Signed-off-by: Michael Roth --- block/nfs.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/block/nfs.c b/block/nfs.c index 344186f..7e1bea1 100644 --- a/block/nfs.c +++ b/block/nfs.c @@ -434,19 +434,23 @@ static void nfs_client_close(NFSClient *client) if (client->context) { if (client->fh) { nfs_close(client->context, client->fh); + client->fh = NULL; } aio_set_fd_handler(client->aio_context, nfs_get_fd(client->context), false, NULL, NULL, NULL, NULL); nfs_destroy_context(client->context); + client->context = NULL; } - memset(client, 0, sizeof(NFSClient)); + g_free(client->path); + qemu_mutex_destroy(&client->mutex); + qapi_free_NFSServer(client->server); + client->server = NULL; } static void nfs_file_close(BlockDriverState *bs) { NFSClient *client = bs->opaque; nfs_client_close(client); - qemu_mutex_destroy(&client->mutex); } static NFSServer *nfs_config(QDict *options, Error **errp) @@ -499,6 +503,7 @@ static int64_t nfs_client_open(NFSClient *client, QDict *options, struct stat st; char *file = NULL, *strp = NULL; + qemu_mutex_init(&client->mutex); opts = qemu_opts_create(&runtime_opts, NULL, 0, &error_abort); qemu_opts_absorb_qdict(opts, options, &local_err); if (local_err) { @@ -661,7 +666,7 @@ static int nfs_file_open(BlockDriverState *bs, QDict *options, int flags, if (ret < 0) { return ret; } - qemu_mutex_init(&client->mutex); + bs->total_sectors = ret; ret = 0; return ret; From patchwork Tue Aug 29 00:14:54 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Michael Roth X-Patchwork-Id: 806887 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=2001:4830:134:3::11; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xh9Z209qDz9sP5 for ; Tue, 29 Aug 2017 11:11:06 +1000 (AEST) Received: from localhost ([::1]:42199 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmV3X-0007qf-PN for incoming@patchwork.ozlabs.org; Mon, 28 Aug 2017 21:11:03 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49241) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dmUD1-00021s-Bm for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:50 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dmUCy-0006OA-51 for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:47 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:50768) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dmUCx-0006ND-QD for qemu-devel@nongnu.org; Mon, 28 Aug 2017 20:16:44 -0400 Received: from pps.filterd (m0098396.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v7T0GIc1010141 for ; Mon, 28 Aug 2017 20:16:42 -0400 Received: from e33.co.us.ibm.com (e33.co.us.ibm.com [32.97.110.151]) by mx0a-001b2d01.pphosted.com with ESMTP id 2cmvjejm5v-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Mon, 28 Aug 2017 20:16:42 -0400 Received: from localhost by e33.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Mon, 28 Aug 2017 18:16:41 -0600 Received: from b03cxnp08028.gho.boulder.ibm.com (9.17.130.20) by e33.co.us.ibm.com (192.168.1.133) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Mon, 28 Aug 2017 18:16:40 -0600 Received: from b03ledav006.gho.boulder.ibm.com (b03ledav006.gho.boulder.ibm.com [9.17.130.237]) by b03cxnp08028.gho.boulder.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v7T0Gdtk32047306; Mon, 28 Aug 2017 17:16:39 -0700 Received: from b03ledav006.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7BB7CC603E; Mon, 28 Aug 2017 18:16:39 -0600 (MDT) Received: from localhost (unknown [9.80.85.217]) by b03ledav006.gho.boulder.ibm.com (Postfix) with ESMTP id 51764C6043; Mon, 28 Aug 2017 18:16:39 -0600 (MDT) From: Michael Roth To: qemu-devel@nongnu.org Date: Mon, 28 Aug 2017 19:14:54 -0500 X-Mailer: git-send-email 2.7.4 In-Reply-To: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1503965694-10794-1-git-send-email-mdroth@linux.vnet.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 x-cbid: 17082900-0008-0000-0000-0000087D387B X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007630; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000226; SDB=6.00909028; UDB=6.00455849; IPR=6.00689279; BA=6.00005557; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00016909; XFM=3.00000015; UTC=2017-08-29 00:16:41 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17082900-0009-0000-0000-000043C04726 Message-Id: <1503965694-10794-80-git-send-email-mdroth@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-08-28_13:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=60 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1708290001 X-MIME-Autoconverted: from 8bit to quoted-printable by mx0a-001b2d01.pphosted.com id v7T0GIc1010141 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH 79/79] 9pfs: local: fix fchmodat_nofollow() limitations 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: qemu-stable@nongnu.org, Greg Kurz Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Greg Kurz This function has to ensure it doesn't follow a symlink that could be used to escape the virtfs directory. This could be easily achieved if fchmodat() on linux honored the AT_SYMLINK_NOFOLLOW flag as described in POSIX, but it doesn't. There was a tentative to implement a new fchmodat2() syscall with the correct semantics: https://patchwork.kernel.org/patch/9596301/ but it didn't gain much momentum. Also it was suggested to look at an O_PATH based solution in the first place. The current implementation covers most use-cases, but it notably fails if: - the target path has access rights equal to 0000 (openat() returns EPERM), => once you've done chmod(0000) on a file, you can never chmod() again - the target path is UNIX domain socket (openat() returns ENXIO) => bind() of UNIX domain sockets fails if the file is on 9pfs The solution is to use O_PATH: openat() now succeeds in both cases, and we can ensure the path isn't a symlink with fstat(). The associated entry in "/proc/self/fd" can hence be safely passed to the regular chmod() syscall. The previous behavior is kept for older systems that don't have O_PATH. Signed-off-by: Greg Kurz Reviewed-by: Eric Blake Tested-by: Zhi Yong Wu Acked-by: Philippe Mathieu-Daudé (cherry picked from commit 4751fd5328dfcd4fe2f9055728a72a0e3ae56512) Signed-off-by: Michael Roth --- hw/9pfs/9p-local.c | 42 +++++++++++++++++++++++++++++++++++------- hw/9pfs/9p-util.h | 24 +++++++++++++++--------- 2 files changed, 50 insertions(+), 16 deletions(-) diff --git a/hw/9pfs/9p-local.c b/hw/9pfs/9p-local.c index b13ff21..a83dbfb 100644 --- a/hw/9pfs/9p-local.c +++ b/hw/9pfs/9p-local.c @@ -278,17 +278,27 @@ update_map_file: static int fchmodat_nofollow(int dirfd, const char *name, mode_t mode) { + struct stat stbuf; int fd, ret; /* FIXME: this should be handled with fchmodat(AT_SYMLINK_NOFOLLOW). - * Unfortunately, the linux kernel doesn't implement it yet. As an - * alternative, let's open the file and use fchmod() instead. This - * may fail depending on the permissions of the file, but it is the - * best we can do to avoid TOCTTOU. We first try to open read-only - * in case name points to a directory. If that fails, we try write-only - * in case name doesn't point to a directory. + * Unfortunately, the linux kernel doesn't implement it yet. */ - fd = openat_file(dirfd, name, O_RDONLY, 0); + + /* First, we clear non-racing symlinks out of the way. */ + if (fstatat(dirfd, name, &stbuf, AT_SYMLINK_NOFOLLOW)) { + return -1; + } + if (S_ISLNK(stbuf.st_mode)) { + errno = ELOOP; + return -1; + } + + /* Access modes are ignored when O_PATH is supported. We try O_RDONLY and + * O_WRONLY for old-systems that don't support O_PATH. + */ + fd = openat_file(dirfd, name, O_RDONLY | O_PATH_9P_UTIL, 0); +#if O_PATH_9P_UTIL == 0 if (fd == -1) { /* In case the file is writable-only and isn't a directory. */ if (errno == EACCES) { @@ -302,6 +312,24 @@ static int fchmodat_nofollow(int dirfd, const char *name, mode_t mode) return -1; } ret = fchmod(fd, mode); +#else + if (fd == -1) { + return -1; + } + + /* Now we handle racing symlinks. */ + ret = fstat(fd, &stbuf); + if (!ret) { + if (S_ISLNK(stbuf.st_mode)) { + errno = ELOOP; + ret = -1; + } else { + char *proc_path = g_strdup_printf("/proc/self/fd/%d", fd); + ret = chmod(proc_path, mode); + g_free(proc_path); + } + } +#endif close_preserve_errno(fd); return ret; } diff --git a/hw/9pfs/9p-util.h b/hw/9pfs/9p-util.h index 517027c..033e7e6 100644 --- a/hw/9pfs/9p-util.h +++ b/hw/9pfs/9p-util.h @@ -13,6 +13,12 @@ #ifndef QEMU_9P_UTIL_H #define QEMU_9P_UTIL_H +#ifdef O_PATH +#define O_PATH_9P_UTIL O_PATH +#else +#define O_PATH_9P_UTIL 0 +#endif + static inline void close_preserve_errno(int fd) { int serrno = errno; @@ -22,13 +28,8 @@ static inline void close_preserve_errno(int fd) static inline int openat_dir(int dirfd, const char *name) { -#ifdef O_PATH -#define OPENAT_DIR_O_PATH O_PATH -#else -#define OPENAT_DIR_O_PATH 0 -#endif return openat(dirfd, name, - O_DIRECTORY | O_RDONLY | O_NOFOLLOW | OPENAT_DIR_O_PATH); + O_DIRECTORY | O_RDONLY | O_NOFOLLOW | O_PATH_9P_UTIL); } static inline int openat_file(int dirfd, const char *name, int flags, @@ -43,9 +44,14 @@ static inline int openat_file(int dirfd, const char *name, int flags, } serrno = errno; - /* O_NONBLOCK was only needed to open the file. Let's drop it. */ - ret = fcntl(fd, F_SETFL, flags); - assert(!ret); + /* O_NONBLOCK was only needed to open the file. Let's drop it. We don't + * do that with O_PATH since fcntl(F_SETFL) isn't supported, and openat() + * ignored it anyway. + */ + if (!(flags & O_PATH_9P_UTIL)) { + ret = fcntl(fd, F_SETFL, flags); + assert(!ret); + } errno = serrno; return fd; }