From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35980) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1flDBG-00048R-P3 for qemu-devel@nongnu.org; Thu, 02 Aug 2018 08:58:15 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1flDBC-0008RW-T5 for qemu-devel@nongnu.org; Thu, 02 Aug 2018 08:58:14 -0400 Received: from mx3-rdu2.redhat.com ([66.187.233.73]:41754 helo=mx1.redhat.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1flDBC-0008Pl-Ni for qemu-devel@nongnu.org; Thu, 02 Aug 2018 08:58:10 -0400 References: From: Eric Blake Message-ID: Date: Thu, 2 Aug 2018 07:58:08 -0500 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] Any tutorial to read/write in qcow2 format by programming way? List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: lampahome Cc: QEMU Developers On 08/02/2018 01:57 AM, lampahome wrote: [Top-posting is difficult to read on technical lists; it's better to reply inline] > I have some questions about qcow2 > If I have 2 img A & B, and A is backing file of B. > Is the format(such as L1, L2, ref block...etc) different from A and B? image A can be a completely different format from B (different cluster sizing, different refcount sizing, for that matter, image A doesn't even have to be qcow2). All that matters from B's perspective is that a read of any cluster not present in B is satisfied by reading the same range of guest-visible bytes from image A in whatever manner A serves up those bytes; and a write to a cluster not present in B causes a COW (copy-on-write) operation to pull in remaining data from A for any portion of the cluster not covered by the write itself. The entire block layer in qemu is a well-defined recursive interface of driver callbacks, where any particular operation calls through as few or as many block drivers as needed to either reach the data in question or determine that the data is not available. -- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3266 Virtualization: qemu.org | libvirt.org