From patchwork Wed Mar 8 02:15:33 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Dong Jia Shi X-Patchwork-Id: 9610191 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id E8F99604DC for ; Wed, 8 Mar 2017 02:17:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D709627D16 for ; Wed, 8 Mar 2017 02:17:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C97A72846D; Wed, 8 Mar 2017 02:17:17 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 84C7227D16 for ; Wed, 8 Mar 2017 02:17:17 +0000 (UTC) Received: from localhost ([::1]:53539 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1clRAC-0007pg-RG for patchwork-qemu-devel@patchwork.kernel.org; Tue, 07 Mar 2017 21:17:16 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:34606) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1clR8s-0007ID-H0 for qemu-devel@nongnu.org; Tue, 07 Mar 2017 21:15:55 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1clR8n-0005D8-7V for qemu-devel@nongnu.org; Tue, 07 Mar 2017 21:15:54 -0500 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:53290 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 1clR8n-0005Cw-0o for qemu-devel@nongnu.org; Tue, 07 Mar 2017 21:15:49 -0500 Received: from pps.filterd (m0098421.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v282Eaww040185 for ; Tue, 7 Mar 2017 21:15:48 -0500 Received: from e11.ny.us.ibm.com (e11.ny.us.ibm.com [129.33.205.201]) by mx0a-001b2d01.pphosted.com with ESMTP id 29272v4gs9-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Tue, 07 Mar 2017 21:15:48 -0500 Received: from localhost by e11.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Tue, 7 Mar 2017 21:15:47 -0500 Received: from b03cxnp08025.gho.boulder.ibm.com (9.17.130.17) by e11.ny.us.ibm.com (146.89.104.198) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Tue, 7 Mar 2017 21:15:44 -0500 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 v282FhaH8520160; Tue, 7 Mar 2017 19:15:43 -0700 Received: from b03ledav004.gho.boulder.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7F08278047; Tue, 7 Mar 2017 19:15:43 -0700 (MST) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by b03ledav004.gho.boulder.ibm.com (Postfix) with ESMTP id 2764278037; Tue, 7 Mar 2017 19:15:42 -0700 (MST) From: Dong Jia Shi To: qemu-block@nongnu.org, kwolf@redhat.com, mreitz@redhat.com Date: Wed, 8 Mar 2017 03:15:33 +0100 X-Mailer: git-send-email 2.8.4 In-Reply-To: <20170308021533.78292-1-bjsdjshi@linux.vnet.ibm.com> References: <20170308021533.78292-1-bjsdjshi@linux.vnet.ibm.com> X-TM-AS-GCONF: 00 x-cbid: 17030802-2213-0000-0000-000001490FFF X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006742; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000206; SDB=6.00831480; UDB=6.00407948; IPR=6.00609072; BA=6.00005194; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00014550; XFM=3.00000012; UTC=2017-03-08 02:15:46 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17030802-2214-0000-0000-000054734B52 Message-Id: <20170308021533.78292-2-bjsdjshi@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-03-08_01:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1702020001 definitions=main-1703080016 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 RFC 1/1] block: Handle NULL options correctly in raw_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: cornelia.huck@de.ibm.com, bjsdjshi@linux.vnet.ibm.com, pasic@linux.vnet.ibm.com, qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP A normal call for raw_open should always pass in a non-NULL @options, but for some certain cases (e.g. trying to applying snapshot on a RBD image), they call raw_open with a NULL @options right after the calling for raw_close. Let's take the NULL @options as a sign of trying to do raw_open again, and just simply return a success code. Signed-off-by: Dong Jia Shi --- block/raw-format.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/block/raw-format.c b/block/raw-format.c index 86fbc65..ee05730 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -384,6 +384,14 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags, BDRVRawState *s = bs->opaque; int ret; + /* + * Notice: + * NULL options is only sensible when applying a snapshot. + */ + if (!options) { + return 0; + } + bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, false, errp); if (!bs->file) {