From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:53976) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RQuMy-0002v4-6I for qemu-devel@nongnu.org; Thu, 17 Nov 2011 00:18:41 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RQuMx-0007mH-3J for qemu-devel@nongnu.org; Thu, 17 Nov 2011 00:18:40 -0500 Received: from e23smtp09.au.ibm.com ([202.81.31.142]:53579) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RQuMw-0007m1-IN for qemu-devel@nongnu.org; Thu, 17 Nov 2011 00:18:39 -0500 Received: from /spool/local by e23smtp09.au.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 17 Nov 2011 06:12:45 +1000 Received: from d23av04.au.ibm.com (d23av04.au.ibm.com [9.190.235.139]) by d23relay04.au.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id pAH5FEhk2912436 for ; Thu, 17 Nov 2011 16:15:17 +1100 Received: from d23av04.au.ibm.com (loopback [127.0.0.1]) by d23av04.au.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id pAH5INul024796 for ; Thu, 17 Nov 2011 16:18:23 +1100 Message-ID: <4EC4991C.1070306@linux.vnet.ibm.com> Date: Thu, 17 Nov 2011 10:48:20 +0530 From: Supriya Kannery MIME-Version: 1.0 References: <20111111064707.15024.69847.sendpatchset@skannery.in.ibm.com> <20111111064802.15024.83662.sendpatchset@skannery.in.ibm.com> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [v9 Patch 4/6]Qemu: Add commandline -drive option 'hostcache' Reply-To: supriyak@linux.vnet.ibm.com List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: Kevin Wolf , Luiz Capitulino , Christoph Hellwig , qemu-devel@nongnu.org On 11/17/2011 01:36 AM, Stefan Hajnoczi wrote: > On Fri, Nov 11, 2011 at 6:48 AM, Supriya Kannery > wrote: >> + if ((hostcache = qemu_opt_get_bool(opts, "hostcache", -1)) != -1) { > > This does not work. qemu_opt_get_bool() takes a bool default argument > and returns a bool. (bool)-1 == true. But (int)true == 1 and you > cannot expect it to ever equal -1. > > Try this: > > if (qemu_opt_get(opts, "hostcache")&& > !qemu_opt_get_bool(opts, "hostcache", false)) { > bdrv_flags |= BDRV_O_NOCACHE; > } > > Stefan > Thanks! for pointing this. Does the following look ok? if ((hostcache = qemu_opt_get_bool(opts, "hostcache", 1) == 0) { bdrv_flags |= BDRV_O_NOCACHE; } If either "hostcache" is not at all specified or it is specified as "on", qemu_opt_get_bool will return 1, which can be ignored as bdrv_flags is initialized to 0.