From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39447) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1YVhXR-0003rA-4P for qemu-devel@nongnu.org; Wed, 11 Mar 2015 10:23:10 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1YVhXN-0004mZ-9h for qemu-devel@nongnu.org; Wed, 11 Mar 2015 10:23:09 -0400 Message-ID: <55004FC5.7080806@redhat.com> Date: Wed, 11 Mar 2015 10:23:01 -0400 From: John Snow MIME-Version: 1.0 References: <1425338403-16138-1-git-send-email-jsnow@redhat.com> <1425338403-16138-5-git-send-email-jsnow@redhat.com> <20150311135806.GF10493@stefanha-thinkpad.redhat.com> In-Reply-To: <20150311135806.GF10493@stefanha-thinkpad.redhat.com> Content-Type: text/plain; charset=windows-1252; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [Qemu-block] [PATCH v2 04/17] qmp: Add block-dirty-bitmap-add and block-dirty-bitmap-remove List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: famz@redhat.com, qemu-block@nongnu.org, qemu-devel@nongnu.org, armbru@redhat.com, vsementsov@parallels.com, stefanha@redhat.com On 03/11/2015 09:58 AM, Stefan Hajnoczi wrote: > On Mon, Mar 02, 2015 at 06:19:50PM -0500, John Snow wrote: >> +static BdrvDirtyBitmap *block_dirty_bitmap_lookup(const char *node, >> + const char *name, >> + BlockDriverState **pbs, >> + Error **errp) >> +{ >> + BlockDriverState *bs; >> + BdrvDirtyBitmap *bitmap; >> + >> + if (!node) { >> + error_setg(errp, "Node cannot be NULL"); >> + return NULL; >> + } >> + if (!name) { >> + error_setg(errp, "Bitmap name cannot be NULL"); >> + return NULL; >> + } >> + >> + bs = bdrv_lookup_bs(node, node, NULL); >> + if (!bs) { >> + error_setg(errp, "Node '%s' not found", node); >> + return NULL; >> + } >> + >> + /* If caller provided a BDS*, provide the result of that lookup, too. */ >> + if (pbs) { >> + *pbs = bs; >> + } >> + >> + bitmap = bdrv_find_dirty_bitmap(bs, name); > > AioContext is not held here. I'm worried that a block job (running > under the AioContext) could change or delete the bitmap at the same time > as this function is running. > > This function should acquire the AioContext before calling > bdrv_find_dirty_bitmap() and fill out an AioContext** parameter so the > caller can continue to use bs/bitmap under the lock. > OK, I'll audit all uses of this function with this in mind.