From patchwork Mon Mar 13 03:31:05 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: 9619715 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 1167960414 for ; Mon, 13 Mar 2017 03:32:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ED07C2841E for ; Mon, 13 Mar 2017 03:32:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id DEB4928428; Mon, 13 Mar 2017 03:32:14 +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=-5.9 required=2.0 tests=BAYES_00, MSGID_MULTIPLE_AT, 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 EB0C02841E for ; Mon, 13 Mar 2017 03:32:12 +0000 (UTC) Received: from localhost ([::1]:49928 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnGiS-0007n5-28 for patchwork-qemu-devel@patchwork.kernel.org; Sun, 12 Mar 2017 23:32:12 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:56629) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cnGhu-0007Z9-Br for qemu-devel@nongnu.org; Sun, 12 Mar 2017 23:31:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cnGhV-0000eO-Ow for qemu-devel@nongnu.org; Sun, 12 Mar 2017 23:31:38 -0400 Received: from mx0b-001b2d01.pphosted.com ([148.163.158.5]:47381 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 1cnGhV-0000ad-Df for qemu-devel@nongnu.org; Sun, 12 Mar 2017 23:31:13 -0400 Received: from pps.filterd (m0098420.ppops.net [127.0.0.1]) by mx0b-001b2d01.pphosted.com (8.16.0.20/8.16.0.20) with SMTP id v2D3SaoJ087760 for ; Sun, 12 Mar 2017 23:31:10 -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 294ea23ebs-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Sun, 12 Mar 2017 23:31:10 -0400 Received: from localhost by e14.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sun, 12 Mar 2017 23:31:09 -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; Sun, 12 Mar 2017 23:31:07 -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 v2D3V7JW43188236; Mon, 13 Mar 2017 03:31:07 GMT Received: from b01ledav002.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 7DBDA12403D; Sun, 12 Mar 2017 23:31:03 -0400 (EDT) Received: from oc7835276234.ibm.com (unknown [9.115.114.145]) by b01ledav002.gho.pok.ibm.com (Postfix) with ESMTP id 001FD124035; Sun, 12 Mar 2017 23:31:02 -0400 (EDT) Date: Mon, 13 Mar 2017 11:31:05 +0800 From: Dong Jia Shi To: Kevin Wolf , Dong Jia Shi , qemu-block@nongnu.org, mreitz@redhat.com, qemu-devel@nongnu.org, cornelia.huck@de.ibm.com, pasic@linux.vnet.ibm.com Mail-Followup-To: Kevin Wolf , Dong Jia Shi , qemu-block@nongnu.org, mreitz@redhat.com, qemu-devel@nongnu.org, cornelia.huck@de.ibm.com, pasic@linux.vnet.ibm.com References: <20170308021533.78292-1-bjsdjshi@linux.vnet.ibm.com> <20170308021533.78292-2-bjsdjshi@linux.vnet.ibm.com> <20170308091346.GB5211@noname.redhat.com> <20170308093105.GC7563@bjsdjshi@linux.vnet.ibm.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20170308093105.GC7563@bjsdjshi@linux.vnet.ibm.com> Organization: (IBM CSL) X-URL: http://ibm.com/ User-Agent: Mutt/1.7.0 (2016-08-17) X-TM-AS-GCONF: 00 x-cbid: 17031303-0052-0000-0000-0000019C0531 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00006772; HX=3.00000240; KW=3.00000007; PH=3.00000004; SC=3.00000206; SDB=6.00833105; UDB=6.00408985; IPR=6.00610760; BA=6.00005203; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00014620; XFM=3.00000013; UTC=2017-03-13 03:31:08 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17031303-0053-0000-0000-00004F0F4133 Message-Id: <20170313033105.GA6756@bjsdjshi@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-03-13_02:, , 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-1703130027 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] [fuzzy] X-Received-From: 148.163.158.5 Subject: Re: [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: , Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP * Dong Jia Shi [2017-03-08 17:31:05 +0800]: > * Kevin Wolf [2017-03-08 10:13:46 +0100]: > > > Am 08.03.2017 um 03:15 hat Dong Jia Shi geschrieben: > > > 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 > > > > I think we rather need to fix bdrv_snapshot_goto() so that it doesn't > > pass NULL, but the actual options that were given for the node (i.e. > > bs->options). > I've tried that before the current try. bs->options does not have the > "file" key-value pair, so that leads to a fail too. Should we put "file" > in to the options manually? I noticed that it was removed from > bs->options during the calling of bdrv_open_inherit. > Hi Kevin, After thinking for quite some time, I still don't think we need to fix the caller. The reason is that raw_close always does nothing, so no matter what the caller passing in, raw_open should do nothing but just return 0. The following is another proposal. Looking forward for your comments. Thanks, > > > > Kevin > > > > -- > Dong Jia diff --git a/block/raw-format.c b/block/raw-format.c index 86fbc65..c309d4c 100644 --- a/block/raw-format.c +++ b/block/raw-format.c @@ -384,6 +384,11 @@ static int raw_open(BlockDriverState *bs, QDict *options, int flags, BDRVRawState *s = bs->opaque; int ret; + if (!bs->file) { + return 0; + } + + assert(options != NULL); bs->file = bdrv_open_child(NULL, options, "file", bs, &child_file, false, errp); if (!bs->file) {