From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:38287) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VU7Gb-00061E-AQ for qemu-devel@nongnu.org; Wed, 09 Oct 2013 23:50:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VU7GT-0000aO-T7 for qemu-devel@nongnu.org; Wed, 09 Oct 2013 23:50:25 -0400 Received: from mail-pb0-f42.google.com ([209.85.160.42]:34081) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VU7GT-0000ZN-My for qemu-devel@nongnu.org; Wed, 09 Oct 2013 23:50:17 -0400 Received: by mail-pb0-f42.google.com with SMTP id un15so1923096pbc.29 for ; Wed, 09 Oct 2013 20:50:15 -0700 (PDT) Message-ID: <525623ED.70208@ozlabs.ru> Date: Thu, 10 Oct 2013 14:50:05 +1100 From: Alexey Kardashevskiy MIME-Version: 1.0 References: <5253C514.6090103@ozlabs.ru> <5253CAB5.7040708@redhat.com> <20131008092330.GB25109@dhcp-200-207.str.redhat.com> <5253D174.1060200@redhat.com> <52550275.7000007@ozlabs.ru> <525509FA.1070105@redhat.com> In-Reply-To: <525509FA.1070105@redhat.com> Content-Type: text/plain; charset=KOI8-R Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] savevm/loadvm List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: Kevin Wolf , "qemu-devel@nongnu.org" On 10/09/2013 06:47 PM, Paolo Bonzini wrote: > Il 09/10/2013 09:15, Alexey Kardashevskiy ha scritto: >> Sorry for my ignorance (I never ever touched this part of qemu) but how can >> you possibly avoid block.c while doing savevm? The qcow2 driver must not >> use posix read()/write(), right? So no matter how, all writes end up in >> bdrv_co_do_writev() which changes blocks number. Or use >> raw_aio_readv()/raw_aio_writev() API directly? Please give some more hints. >> Thanks. > > I think Kevin was suggesting using qcow_aio_writev directly, or > something like that. But it is not trivial, especially because > save_vm_state takes byte offsets instead of sectors. So for now I'd > still go for the more hacky solution. I failed to find qcow_aio_writev() or anything like that. qcow2_co_writev() uses block.c. And I tried this: diff --git a/block/qcow2.c b/block/qcow2.c index 4a9888c..17faf8b 100644 --- a/block/qcow2.c +++ b/block/qcow2.c @@ -1837,10 +1837,16 @@ static int qcow2_save_vmstate(BlockDriverState *bs, QEMUIOVector *qiov, BDRVQcowState *s = bs->opaque; int growable = bs->growable; int ret; + int64_t total_sectors = bs->total_sectors; BLKDBG_EVENT(bs->file, BLKDBG_VMSTATE_SAVE); bs->growable = 1; ret = bdrv_pwritev(bs, qcow2_vm_state_offset(s) + pos, qiov); + /* + * Setting @growable may cause underlying bdrv_co_do_writev() + * to increase bs->total_sectors and we do not want this to happen. + */ + bs->total_sectors = total_sectors; bs->growable = growable; return ret; It breaks loadvm in a different (weird) way, the error is something like "ram" or "spapr/htab" (streams registered with register_savevm_live()) chunk cannot be read. Need to debug more... -- Alexey