From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46575) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xu1yX-0004dN-3V for qemu-devel@nongnu.org; Thu, 27 Nov 2014 11:31:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xu1yO-0007vO-0I for qemu-devel@nongnu.org; Thu, 27 Nov 2014 11:31:25 -0500 Received: from mail-wg0-x236.google.com ([2a00:1450:400c:c00::236]:62386) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xu1yN-0007vI-QK for qemu-devel@nongnu.org; Thu, 27 Nov 2014 11:31:15 -0500 Received: by mail-wg0-f54.google.com with SMTP id l2so6898601wgh.13 for ; Thu, 27 Nov 2014 08:31:15 -0800 (PST) Date: Thu, 27 Nov 2014 16:31:12 +0000 From: Stefan Hajnoczi Message-ID: <20141127163112.GK15586@stefanha-thinkpad.lan> References: <00b101d00a2b$1656c080$43044180$@gmail.com> MIME-Version: 1.0 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="g4MvFqI7wmANiPDo" Content-Disposition: inline In-Reply-To: <00b101d00a2b$1656c080$43044180$@gmail.com> Subject: Re: [Qemu-devel] Help: Convert HDD to QCOW2 img List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Halsey Pian Cc: qemu-devel@nongnu.org --g4MvFqI7wmANiPDo Content-Type: text/plain; charset=us-ascii Content-Disposition: inline Content-Transfer-Encoding: quoted-printable On Thu, Nov 27, 2014 at 06:15:31PM +0800, Halsey Pian wrote: > Recently, I'm writing an interface of wrapper class for QCOW2 in order to > manage QCOW2 img files conveniently based on our requirements in my curre= nt > project , this wrapper includes functions such as QCOW2 creating, read/wr= ite > and snapshot relatives. Actually, these functions would finally call > functions in qemu-img.c, block.c, qcow2.c and others related. >=20 > =20 >=20 > With respect to validation of this wrapper, I installed one VM to generat= e a > fedora20.qcow2 file using qemu team's binary qemu-system_x86-64, and use = my > wrapper to read this file and write to a new QCOW2 file from sector 0 to > total sectors the img includes, finally I can boot the VM using my > generated QCOW2 img file. Sounds like you might be reinventing qemu-img and/or qemu-io. What's unique about your program? > It seems the partition information is not wrote successfully into the img > file, what did I miss? What else should I do except writing the data? Cou= ld > you give help on it? bdrv_close_all() might help if you forgot to shut down the block layer (which closes images and flushes metadata). Since you have written custom code which you have not published, pretty much anything could be wrong but we wouldn't know. > The reason why I did above is that I want to write a hard disk drive > including OS data (and can be started up normally as host) to qcow2 file, > and then boot it as VM under qemu kvm support. Any idea or suggestion?=20 Did you look at "qemu-img convert"? It might do what you want. Stefan --g4MvFqI7wmANiPDo Content-Type: application/pgp-signature -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQEcBAEBAgAGBQJUd1HQAAoJEJykq7OBq3PI7eMIALhi+ohENq+S9/L/VAZyHi7p jA0k/3ZpLJ6QqY9tVos186oXHJuwsBR0HCxyrqCxQBUM4wSif1y4KzTFZYrQPcxs oBiatH1/nGedIWUwvwg2JebOuocJt46JT0Sw3oCuQqFOL5PcdN9hLPqdo2xtjh+M 0ggo3F2w5w3r25CNi2MIjimleGvvKQRj+dZDJd9jZSewCoqZrEqGGuZHdrkor9nH BMGEkoSff5w8qgrZ5C1q6UkpO8Io6aeZpZgg+pawIY/mT8Hj+5mcYmMwCmwxPaIB ZbJNSwgLf3Q/S6N82PFnkD2miPjjh5U2O9liGNkGUV+XQyNPHtOUcOP8hWSAnlY= =pn8S -----END PGP SIGNATURE----- --g4MvFqI7wmANiPDo--