From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41089) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xtw7C-0002W7-9Q for qemu-devel@nongnu.org; Thu, 27 Nov 2014 05:16:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Xtw72-00023f-O5 for qemu-devel@nongnu.org; Thu, 27 Nov 2014 05:15:58 -0500 Received: from mail-pd0-x22a.google.com ([2607:f8b0:400e:c02::22a]:35002) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Xtw72-00023L-CP for qemu-devel@nongnu.org; Thu, 27 Nov 2014 05:15:48 -0500 Received: by mail-pd0-f170.google.com with SMTP id fp1so4680594pdb.29 for ; Thu, 27 Nov 2014 02:15:42 -0800 (PST) From: "Halsey Pian" Date: Thu, 27 Nov 2014 18:15:31 +0800 Message-ID: <00b101d00a2b$1656c080$43044180$@gmail.com> MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----=_NextPart_000_00B2_01D00A6E.247CE6B0" Content-Language: zh-cn Subject: [Qemu-devel] Help: Convert HDD to QCOW2 img List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: halsey.pian@gmail.com This is a multipart message in MIME format. ------=_NextPart_000_00B2_01D00A6E.247CE6B0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Hi All, 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 current project , this wrapper includes functions such as QCOW2 creating, read/write and snapshot relatives. Actually, these functions would finally call functions in qemu-img.c, block.c, qcow2.c and others related. With respect to validation of this wrapper, I installed one VM to generate 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. Unfortunately, I'm suffering issue below, I connected the fedora20.qcow2 to /dev/nbd0 using support of qemu-nbd and kernel nbd moduel, and fread this block node as file and also write the data to a new QCOW2 file using bdrv_write implemented in block.c starting from sector 0, but this img file doesn't work successfully, error report below when starts up Error: file 'grub2/i386-pc/normal.mod' not found Grub rescue> 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? Could you give help on it? 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? Host: Fedora20 VM: Fedora20 Kernel: 3.12.32 QEMU: 2.1.2 Thanks a lot! Best Regards Halsey Pian ------=_NextPart_000_00B2_01D00A6E.247CE6B0 Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

 

Hi = All,

 

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 current project , this wrapper includes functions = such as QCOW2 creating, read/write and snapshot relatives. Actually, = these functions would finally call functions in qemu-img.c, block.c, = qcow2.c and others related.

 

With = respect to validation of this wrapper, I installed one VM to generate 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.

 

Unfortunately, I'm suffering issue = below,

I connected the = fedora20.qcow2 to /dev/nbd0 using support of qemu-nbd and kernel nbd = moduel, and fread this block node as file and also write the data to a = new QCOW2 file using bdrv_write implemented in block.c starting from = sector 0, but this img file doesn't work successfully, error report = below when starts up

 

Error: file = 'grub2/i386-pc/normal.mod' not found

Grub = rescue>

 

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? = Could you give help on it?

 

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?

 

Host: = Fedora20

VM: = Fedora20

Kernel: = 3.12.32

QEMU: = 2.1.2

 

 

Thanks = a lot!

 

 

Best = Regards

Halsey = Pian

 

------=_NextPart_000_00B2_01D00A6E.247CE6B0-- 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-- From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:48048) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XvNec-0005Aw-TU for qemu-devel@nongnu.org; Mon, 01 Dec 2014 04:52:27 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XvNeb-00024A-Vw for qemu-devel@nongnu.org; Mon, 01 Dec 2014 04:52:26 -0500 Received: from mail-ob0-x231.google.com ([2607:f8b0:4003:c01::231]:44313) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XvNeb-000245-Ql for qemu-devel@nongnu.org; Mon, 01 Dec 2014 04:52:25 -0500 Received: by mail-ob0-f177.google.com with SMTP id va2so7512443obc.22 for ; Mon, 01 Dec 2014 01:52:25 -0800 (PST) MIME-Version: 1.0 In-Reply-To: <00c201d00d4a$e5ea1a50$b1be4ef0$@gmail.com> References: <00b101d00a2b$1656c080$43044180$@gmail.com> <20141127163112.GK15586@stefanha-thinkpad.lan> <00c201d00d4a$e5ea1a50$b1be4ef0$@gmail.com> Date: Mon, 1 Dec 2014 09:52:24 +0000 Message-ID: From: Stefan Hajnoczi Content-Type: text/plain; charset=UTF-8 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 On Mon, Dec 1, 2014 at 9:40 AM, Halsey Pian wrote: Please keep qemu-devel@nongnu.org CCed so the discussion stays on the mailing list. I have added it back. > Hi Stefan, not know if there is similar module, currently I have not seen it. If yes, please forgive me. And for the program if it > is unique, there should be some policies for involving QEMU team, right? Thanks. QEMU does not have something directly equivalent to VMware's SDK for storage. But there is a very powerful API called libguestfs. Maybe it does what you want: http://libguestfs.org/ libvirt has APIs for snapshotting and managing storage: http://libvirt.org/html/libvirt-libvirt-storage.html QEMU's qemu-img supports JSON output to make it easy to parse. qemu-nbd can be used for read-write access. There was an attempt to create something called libqblock but the work was never completed. I guess your approach is similar: https://lists.gnu.org/archive/html/qemu-devel/2013-02/msg02356.html Stefan From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:49915) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XvRvE-0008OV-QU for qemu-devel@nongnu.org; Mon, 01 Dec 2014 09:25:58 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XvRv9-0005Gk-1A for qemu-devel@nongnu.org; Mon, 01 Dec 2014 09:25:52 -0500 Received: from mail-pd0-x22e.google.com ([2607:f8b0:400e:c02::22e]:49627) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XvRv8-0005GO-PS for qemu-devel@nongnu.org; Mon, 01 Dec 2014 09:25:46 -0500 Received: by mail-pd0-f174.google.com with SMTP id w10so10906625pde.5 for ; Mon, 01 Dec 2014 06:25:45 -0800 (PST) References: <00b101d00a2b$1656c080$43044180$@gmail.com> <20141127163112.GK15586@stefanha-thinkpad.lan> <00c201d00d4a$e5ea1a50$b1be4ef0$@gmail.com> Mime-Version: 1.0 (1.0) In-Reply-To: Content-Type: text/plain; charset=gb2312 Content-Transfer-Encoding: quoted-printable Message-Id: <0D187FD4-0BCF-4331-B414-F490463F01CE@gmail.com> From: Halsey Date: Mon, 1 Dec 2014 22:25:40 +0800 Subject: Re: [Qemu-devel] Help: Convert HDD to QCOW2 img List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Stefan Hajnoczi Cc: qemu-devel Hi Stefan,=20 Thanks for so much info you provided.=20 Okay, I would keep qemu-devel mailing list in the loop, no problem. Currently, I have finished the coding of the wrapper, now testing the bdrv_r= ead/write qcow2 img. I would look into these libraries and incorporate them b= ased on the concept of interface design. Thanks. Halsey Sent from my iPhone > On 2014=C4=EA12=D4=C21=C8=D5, at 17:52, Stefan Hajnoczi wrote: >=20 > On Mon, Dec 1, 2014 at 9:40 AM, Halsey Pian wrote:= >=20 > Please keep qemu-devel@nongnu.org CCed so the discussion stays on the > mailing list. I have added it back. >=20 >> Hi Stefan, not know if there is similar module, currently I have not seen= it. If yes, please forgive me. And for the program if it >> is unique, there should be some policies for involving QEMU team, right?= Thanks. >=20 > QEMU does not have something directly equivalent to VMware's SDK for stora= ge. >=20 > But there is a very powerful API called libguestfs. Maybe it does > what you want: > http://libguestfs.org/ >=20 > libvirt has APIs for snapshotting and managing storage: > http://libvirt.org/html/libvirt-libvirt-storage.html >=20 > QEMU's qemu-img supports JSON output to make it easy to parse. > qemu-nbd can be used for read-write access. >=20 > There was an attempt to create something called libqblock but the work > was never completed. I guess your approach is similar: > https://lists.gnu.org/archive/html/qemu-devel/2013-02/msg02356.html >=20 > Stefan