From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:52881) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RQ2ox-0007PW-Lr for qemu-devel@nongnu.org; Mon, 14 Nov 2011 15:08:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RQ2ow-00016J-3f for qemu-devel@nongnu.org; Mon, 14 Nov 2011 15:07:59 -0500 Received: from mx1.redhat.com ([209.132.183.28]:34104) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RQ2ov-00016C-Rb for qemu-devel@nongnu.org; Mon, 14 Nov 2011 15:07:58 -0500 Message-ID: <4EC175D5.1000906@redhat.com> Date: Mon, 14 Nov 2011 21:11:01 +0100 From: Kevin Wolf MIME-Version: 1.0 References: <1321113420-3252-1-git-send-email-aliguori@us.ibm.com> <1321113420-3252-5-git-send-email-aliguori@us.ibm.com> <4EC1214B.8050105@us.ibm.com> <4EC170C9.5060202@codemonkey.ws> In-Reply-To: <4EC170C9.5060202@codemonkey.ws> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [PATCH 5/7] block: allow migration to work with image files (v2) List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Anthony Liguori Cc: Lucas Meneghel Rodrigues , Anthony Liguori , Stefan Hajnoczi , "Michael S. Tsirkin" , quintela@redhat.com, qemu-devel@nongnu.org, Avi Kivity Am 14.11.2011 20:49, schrieb Anthony Liguori: > On 11/14/2011 01:46 PM, Juan Quintela wrote: >> Anthony Liguori wrote: >>> On 11/14/2011 07:11 AM, Juan Quintela wrote: >>>> >>>>> diff --git a/cpus.c b/cpus.c >>>>> index 82530c4..ae5ec99 100644 >>>>> --- a/cpus.c >>>>> +++ b/cpus.c >>>>> @@ -398,6 +398,7 @@ static void do_vm_stop(RunState state) >>>>> vm_state_notify(0, state); >>>>> qemu_aio_flush(); >>>>> bdrv_flush_all(); >>>>> + bdrv_invalidate_cache_all(); >>>>> monitor_protocol_event(QEVENT_STOP, NULL); >>>>> } >>>> >>>> This is too much. Reopening all qcow2 images each time that we stop the >>>> vm looks excesive, no? >>> >>> This general code came in via: >>> >>> http://mid.gmane.org/cover.1290613959.git.mst@redhat.com >>> >>> That series made migration stable after issuing a stop operation. I >>> believe the justification was for debugging purposes or something like >>> that. >>> >>> At any rate, invalidating the cache is part of what's required to make >>> things stable. If you look at something like cache=unsafe, the only >>> way the metadata will get flushed if via a bdrv_close since bdrv_flush >>> is a nop. >>> >>> So this is needed as long as we care about supporting this use-case. >> >> Then we need a "proper" qcow2 invalidate call. Doing in qemu toplevel: >> >> (qemu)stop >> >> And now all your qcow2 block devices are closed, or perhaps failing to >> re-open() looks too much to me (TM). >> >> Kevin? > > Look closely at the patch. It doesn't actually close()/open() anything. > > It just invokes the bdrv_close() routine which calls the free functions on the > l1/l2 caching functions. bdrv_open() doesn't actually open anything (it assumes > the file is already open. It just reads the header and metadata over again. > > For something that's basically a hack, it turned out to work very cleanly :-) But why do we need to do it on stop? I don't think it makes even sense logically: bdrv_invalidate_cache() means "throw all your caches away and refetch everything from disk". What do we gain from doing this on stop? To some degree I could understand if you did it on cont, so that you can modify an image on the host while the VM is stopped (though I would still consider it criminal :-)). Kevin