qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Qemu-devel] Help: Convert HDD to QCOW2 img


From: Stefan Hajnoczi
Subject: Re: [Qemu-devel] Help: Convert HDD to QCOW2 img
Date: Thu, 27 Nov 2014 16:31:12 +0000
User-agent: Mutt/1.5.23 (2014-03-12)

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: pgpJSt0Z5lnL3.pgp
Description: PGP signature


reply via email to

[Prev in Thread] Current Thread [Next in Thread]