From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55236) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1ZeOfn-0001eW-5O for qemu-devel@nongnu.org; Tue, 22 Sep 2015 10:36:05 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1ZeOfm-0001aB-9j for qemu-devel@nongnu.org; Tue, 22 Sep 2015 10:35:59 -0400 Date: Tue, 22 Sep 2015 16:35:51 +0200 From: Kevin Wolf Message-ID: <20150922143551.GF3999@noname.str.redhat.com> References: <1442589793-7105-1-git-send-email-mreitz@redhat.com> <1442589793-7105-21-git-send-email-mreitz@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1442589793-7105-21-git-send-email-mreitz@redhat.com> Subject: Re: [Qemu-devel] [PATCH v5 20/38] block: Prepare remaining BB functions for NULL BDS List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Max Reitz Cc: Alberto Garcia , qemu-block@nongnu.org, John Snow , qemu-devel@nongnu.org, Markus Armbruster , Stefan Hajnoczi Am 18.09.2015 um 17:22 hat Max Reitz geschrieben: > There are several BlockBackend functions which, in theory, cannot fail. > This patch makes them cope with the BlockDriverState pointer being NULL > by making them fall back to some default action like ignoring the value > in setters and returning the default in getters. > > Signed-off-by: Max Reitz > Reviewed-by: Eric Blake Hm, okay, maybe bdrv_drain() belongs here. I just reviewed the end result for completeness and didn't check which patch did what. > int blk_enable_write_cache(BlockBackend *blk) > { > + if (!blk->bs) { > + return 0; > + } > + > return bdrv_enable_write_cache(blk->bs); > } > > void blk_set_enable_write_cache(BlockBackend *blk, bool wce) > { > - bdrv_set_enable_write_cache(blk->bs, wce); > + if (blk->bs) { > + bdrv_set_enable_write_cache(blk->bs, wce); > + } > } WCE is part of the open_flags in BlockBackendRootState. The root state doesn't seem to be used yet, and I wrote about my concerns about it in reply to an earlier patch, but as long as we have it, should this query/modify the root state if no BDS is attached? Kevin