qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel]  Help: Convert HDD to QCOW2 img
@ 2014-11-27 10:15 Halsey Pian
  2014-11-27 16:31 ` Stefan Hajnoczi
  0 siblings, 1 reply; 4+ messages in thread
From: Halsey Pian @ 2014-11-27 10:15 UTC (permalink / raw)
  To: qemu-devel; +Cc: halsey.pian

[-- Attachment #1: Type: text/plain, Size: 1641 bytes --]

 

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

 


[-- Attachment #2: Type: text/html, Size: 5346 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] Help: Convert HDD to QCOW2 img
  2014-11-27 10:15 [Qemu-devel] Help: Convert HDD to QCOW2 img Halsey Pian
@ 2014-11-27 16:31 ` Stefan Hajnoczi
       [not found]   ` <00c201d00d4a$e5ea1a50$b1be4ef0$@gmail.com>
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Hajnoczi @ 2014-11-27 16:31 UTC (permalink / raw)
  To: Halsey Pian; +Cc: qemu-devel

[-- Attachment #1: Type: text/plain, Size: 1616 bytes --]

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 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.

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? Could
> 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? 

Did you look at "qemu-img convert"?  It might do what you want.

Stefan

[-- Attachment #2: Type: application/pgp-signature, Size: 473 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] Help: Convert HDD to QCOW2 img
       [not found]   ` <00c201d00d4a$e5ea1a50$b1be4ef0$@gmail.com>
@ 2014-12-01  9:52     ` Stefan Hajnoczi
  2014-12-01 14:25       ` Halsey
  0 siblings, 1 reply; 4+ messages in thread
From: Stefan Hajnoczi @ 2014-12-01  9:52 UTC (permalink / raw)
  To: Halsey Pian; +Cc: qemu-devel

On Mon, Dec 1, 2014 at 9:40 AM, Halsey Pian <halsey.pian@gmail.com> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] Help: Convert HDD to QCOW2 img
  2014-12-01  9:52     ` Stefan Hajnoczi
@ 2014-12-01 14:25       ` Halsey
  0 siblings, 0 replies; 4+ messages in thread
From: Halsey @ 2014-12-01 14:25 UTC (permalink / raw)
  To: Stefan Hajnoczi; +Cc: qemu-devel

Hi Stefan, 

Thanks for so much info you provided. 

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_read/write qcow2 img. I would look into these libraries and incorporate them based on the concept of interface design.

Thanks.

Halsey

Sent from my iPhone

> On 2014年12月1日, at 17:52, Stefan Hajnoczi <stefanha@gmail.com> wrote:
> 
> On Mon, Dec 1, 2014 at 9:40 AM, Halsey Pian <halsey.pian@gmail.com> 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-12-01 14:25 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-27 10:15 [Qemu-devel] Help: Convert HDD to QCOW2 img Halsey Pian
2014-11-27 16:31 ` Stefan Hajnoczi
     [not found]   ` <00c201d00d4a$e5ea1a50$b1be4ef0$@gmail.com>
2014-12-01  9:52     ` Stefan Hajnoczi
2014-12-01 14:25       ` Halsey

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).