* [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
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).