All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] qemu-img needs "-O host_device" describing
@ 2009-09-30 21:27 Adrian Bridgett
  2009-10-01  8:16 ` [Qemu-devel] " Adrian Bridgett
  2009-10-01  9:57 ` [Qemu-devel] " Kevin Wolf
  0 siblings, 2 replies; 6+ messages in thread
From: Adrian Bridgett @ 2009-09-30 21:27 UTC (permalink / raw)
  To: qemu-devel

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

I've been trying to convert some personal KVM qemu (raw) file images
to raw LVs using kvm-img -O raw.  There's a short version and long
version of this tale.

The short version is "here is a patch to add '-O host_device' to the
manpage", perhaps we should also warn if "kvm-img convert -O raw" is
used on a block device (or even just automatically use host_device?)

The long version is that first of all I changed block/raw-posix.c so
that it didn't try and ftruncat() block devices and then eventually
tracked down why "kvm-img convert -O raw" fails to block devices (it
seeks past holes effectively which is good on files, but not block
devices).

Digging a bit deeper I found reference to "host_device" type and it
turns out that using that as an output format fixes both these issues
- with only one buglet - a hopefully irrelevant error:

  kvm-img convert -O host_device /var/lib/vm/bishop-disk /dev/rootvg/bishop-disk 
  Unknown option 'size'

This on qemu-kvm 0.11.

Thanks,

Adrian
-- 
bitcube.co.uk - Linux infrastructure consultancy
Puppet, Debian, Red Hat, Ubuntu, CentOS, ...

[-- Attachment #2: qemu-truncate.diff --]
[-- Type: text/x-diff, Size: 490 bytes --]

--- qemu-kvm-0.11.0~rc2.orig/block/raw-posix.c
+++ qemu-kvm-0.11.0~rc2/block/raw-posix.c
@@ -867,7 +867,12 @@
     if (fd < 0) {
         result = -errno;
     } else {
-        if (ftruncate(fd, total_size * 512) != 0) {
+        struct stat stat;
+        if (!fstat(fd,&stat)) {
+          result = -errno;
+        }
+        if ((stat.st_mode & S_IFREG) && 
+            (ftruncate(fd, total_size * 512) != 0)) {
             result = -errno;
         }
         if (close(fd) != 0) {

[-- Attachment #3: qemu-host_device.diff --]
[-- Type: text/x-diff, Size: 526 bytes --]

--- qemu-kvm-0.11.0.orig/qemu-img.texi
+++ qemu-kvm-0.11.0/qemu-img.texi
@@ -37,6 +37,12 @@
 space. Use @code{qemu-img info} to know the real size used by the
 image or @code{ls -ls} on Unix/Linux.
 
+@item host_device
+
+Host device format. This format should be used instead of raw when
+converting to block devices or other devices where "holes" are not
+supported.
+
 @item qcow2
 QEMU image format, the most versatile format. Use it to have smaller
 images (useful if your filesystem does not supports holes, for example

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

* [Qemu-devel] Re: qemu-img needs "-O host_device" describing
  2009-09-30 21:27 [Qemu-devel] qemu-img needs "-O host_device" describing Adrian Bridgett
@ 2009-10-01  8:16 ` Adrian Bridgett
  2009-10-01  9:57 ` [Qemu-devel] " Kevin Wolf
  1 sibling, 0 replies; 6+ messages in thread
From: Adrian Bridgett @ 2009-10-01  8:16 UTC (permalink / raw)
  To: qemu-devel

The qemu-truncate.diff patch should be ignored (since host_device
doesn't need it).  Ah, the hazards of using postponed emails!

Adrian
-- 
bitcube.co.uk - Linux infrastructure consultancy
Puppet, Debian, Red Hat, Ubuntu, CentOS, ...

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

* Re: [Qemu-devel] qemu-img needs "-O host_device" describing
  2009-09-30 21:27 [Qemu-devel] qemu-img needs "-O host_device" describing Adrian Bridgett
  2009-10-01  8:16 ` [Qemu-devel] " Adrian Bridgett
@ 2009-10-01  9:57 ` Kevin Wolf
  2009-10-01 10:48   ` Adrian Bridgett
  1 sibling, 1 reply; 6+ messages in thread
From: Kevin Wolf @ 2009-10-01  9:57 UTC (permalink / raw)
  To: adrian; +Cc: qemu-devel

Am 30.09.2009 23:27, schrieb Adrian Bridgett:
> I've been trying to convert some personal KVM qemu (raw) file images
> to raw LVs using kvm-img -O raw.  There's a short version and long
> version of this tale.
> 
> The short version is "here is a patch to add '-O host_device' to the
> manpage", perhaps we should also warn if "kvm-img convert -O raw" is
> used on a block device (or even just automatically use host_device?)
> 
> The long version is that first of all I changed block/raw-posix.c so
> that it didn't try and ftruncat() block devices and then eventually
> tracked down why "kvm-img convert -O raw" fails to block devices (it
> seeks past holes effectively which is good on files, but not block
> devices).

What is the result of this patch? Will raw instead of host_device work
without an error message for devices? If so, I'm against the change.
It's dangerous: qemu-img would leave zero blocks unchanged instead of
overwriting them with zeros, silently corrupting the converted data.

> Digging a bit deeper I found reference to "host_device" type and it
> turns out that using that as an output format fixes both these issues
> - with only one buglet - a hopefully irrelevant error:
> 
>   kvm-img convert -O host_device /var/lib/vm/bishop-disk /dev/rootvg/bishop-disk 
>   Unknown option 'size'

Yes, this is a bug in the host_device definition. I'll send a fix.

Your documentation fix looks fine. Can you resubmit it in a new
(top-level) mail with [PATCH] in its subject and a Signed-off-by line in
it? Only this way the maintainers will pick it up.

Kevin

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

* Re: [Qemu-devel] qemu-img needs "-O host_device" describing
  2009-10-01  9:57 ` [Qemu-devel] " Kevin Wolf
@ 2009-10-01 10:48   ` Adrian Bridgett
  2009-10-01 12:07     ` Kevin Wolf
  0 siblings, 1 reply; 6+ messages in thread
From: Adrian Bridgett @ 2009-10-01 10:48 UTC (permalink / raw)
  To: Kevin Wolf; +Cc: qemu-devel

On Thu, Oct  1, 2009 at 11:57:02 +0200 (+0200), Kevin Wolf wrote:
> Am 30.09.2009 23:27, schrieb Adrian Bridgett:
[snip]
> > The long version is that first of all I changed block/raw-posix.c so
> > that it didn't try and ftruncat() block devices and then eventually
> > tracked down why "kvm-img convert -O raw" fails to block devices (it
> > seeks past holes effectively which is good on files, but not block
> > devices).
> 
> What is the result of this patch? Will raw instead of host_device work
> without an error message for devices? If so, I'm against the change.
> It's dangerous: qemu-img would leave zero blocks unchanged instead of
> overwriting them with zeros, silently corrupting the converted data.

Yep - that's exactly what happens - I was going to send a subsequent
one to stop qemu-img convert from skipping past unallocated blocks -
but then found the host_device format and that sorted it all out,
sorry if that wasn't clear.  I do wonder if -O raw should warn when
run against output devices which aren't regular files though.

> Your documentation fix looks fine. Can you resubmit it in a new
> (top-level) mail with [PATCH] in its subject and a Signed-off-by line in
> it? Only this way the maintainers will pick it up.

Absolutely, thanks for the help :-)

Adrian
-- 
bitcube.co.uk - Linux infrastructure consultancy
Puppet, Debian, Red Hat, Ubuntu, CentOS, ...

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

* Re: [Qemu-devel] qemu-img needs "-O host_device" describing
  2009-10-01 10:48   ` Adrian Bridgett
@ 2009-10-01 12:07     ` Kevin Wolf
  2009-10-01 23:42       ` Jamie Lokier
  0 siblings, 1 reply; 6+ messages in thread
From: Kevin Wolf @ 2009-10-01 12:07 UTC (permalink / raw)
  To: adrian; +Cc: qemu-devel

Am 01.10.2009 12:48, schrieb Adrian Bridgett:
> I do wonder if -O raw should warn when
> run against output devices which aren't regular files though.

I'd consider an error message pointing to host_device helpful (error
meaning that qemu-img aborts, not just a warning). So if you like to add
the check, go ahead.

Kevin

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

* Re: [Qemu-devel] qemu-img needs "-O host_device" describing
  2009-10-01 12:07     ` Kevin Wolf
@ 2009-10-01 23:42       ` Jamie Lokier
  0 siblings, 0 replies; 6+ messages in thread
From: Jamie Lokier @ 2009-10-01 23:42 UTC (permalink / raw)
  To: Kevin Wolf; +Cc: adrian, qemu-devel

Kevin Wolf wrote:
> Am 01.10.2009 12:48, schrieb Adrian Bridgett:
> > I do wonder if -O raw should warn when
> > run against output devices which aren't regular files though.
> 
> I'd consider an error message pointing to host_device helpful (error
> meaning that qemu-img aborts, not just a warning). So if you like to add
> the check, go ahead.

Why not simply provide the host_device behaviour when -O raw is used
on a device?  Is there anything to be gained from not doing so?

-- Jamie

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

end of thread, other threads:[~2009-10-01 23:43 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-09-30 21:27 [Qemu-devel] qemu-img needs "-O host_device" describing Adrian Bridgett
2009-10-01  8:16 ` [Qemu-devel] " Adrian Bridgett
2009-10-01  9:57 ` [Qemu-devel] " Kevin Wolf
2009-10-01 10:48   ` Adrian Bridgett
2009-10-01 12:07     ` Kevin Wolf
2009-10-01 23:42       ` Jamie Lokier

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.