qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Fam Zheng <famz@redhat.com>
To: Milos Vyletel <milos.vyletel@gmail.com>
Cc: qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] qemu-img convert from raw to vmdk does not work in vmware esxi
Date: Mon, 16 Jun 2014 14:36:31 +0800	[thread overview]
Message-ID: <20140616063631.GD1943@T430.nay.redhat.com> (raw)
In-Reply-To: <CAAFXRd38Uc6TFkJhL=rH-OMUWnhO-Wpy38QJjFR+zkR=icKgWg@mail.gmail.com>

On Fri, 06/13 15:00, Milos Vyletel wrote:
> Hi,
> 
> I've tried to convert my VM image from raw format to vmdk to create
> OVF/OVA archive so that we can deploy our OS on other hypervisors. the
> problem was that no matter how I've converted to vmdk vmware ESXi
> (tried 4.1 and 5.5) complained that it was: "Not a supported disk
> format (sparse VMDK too old)".
> 
> I've found similar report on this list from 2011 but it was never solved.
> http://lists.gnu.org/archive/html/qemu-devel/2011-10/msg02463.html
> 
> Anyway, I've managed to find the problem. Even though vmdk specs
> (latest I've found were at
> https://www.vmware.com/support/developer/vddk/vmdk_50_technote.pdf?src=vmdk)
> say that version of the vmdk is either 1 or 2 vmware actually uses
> version 3 for streamOptimized vmdk format. When I've patched qemu-img
> to set version to 3 for streamOptimzed (or more specifically
> compressed) vmdk format import worked just fine.
> 
> These are the options I've use to convert
> qemu-img version 2.0.50, Copyright (c) 2004-2008 Fabrice Bellard
> qemu-img convert -p -f raw /storage/gs.img -O vmdk -o
> adapter_type=lsilogic,subformat=streamOptimized,compat6
> /storage/exp/gs/gs.vmdk
> 
> Below is quick and dirty patch I've come up with that does the trick.
> I did not spend too much time looking into code to be 100% sure it's
> correct so any comments are welcome.
> 
> Milos
> 
> ---
> diff --git a/block/vmdk.c b/block/vmdk.c
> index b8a4762..71d53b8 100644
> --- a/block/vmdk.c
> +++ b/block/vmdk.c
> @@ -645,7 +645,9 @@ static int vmdk_open_vmdk4(BlockDriverState *bs,
>          error_set(errp, QERR_UNKNOWN_BLOCK_FORMAT_FEATURE,
>                    bs->device_name, "vmdk", buf);
>          return -ENOTSUP;
> -    } else if (le32_to_cpu(header.version) == 3 && (flags & BDRV_O_RDWR)) {
> +    } else if (le32_to_cpu(header.version) == 3 &&
> +               (flags & BDRV_O_RDWR) &&
> +               (flags & VMDK4_FLAG_COMPRESS)) {

I think this should be:

    } else if (le32_to_cpu(header.version) == 3
               && (flags & bdrv_o_rdwr)
               && !(le64_to_cpu(header.flags) & vmdk4_flag_compress)) {

We should look in header, because flags is not containing the bit we want.

Fam

>          /* VMware KB 2064959 explains that version 3 added support for
>           * persistent changed block tracking (CBT), and backup software can
>           * read it as version=1 if it doesn't care about the changed area
> @@ -1562,7 +1564,7 @@ static int vmdk_create_extent(const char
> *filename, int64_t filesize,
>      }
>      magic = cpu_to_be32(VMDK4_MAGIC);
>      memset(&header, 0, sizeof(header));
> -    header.version = zeroed_grain ? 2 : 1;
> +    header.version = zeroed_grain ? 2 : (compress ? 3 : 1);
>      header.flags = VMDK4_FLAG_RGD | VMDK4_FLAG_NL_DETECT
>                     | (compress ? VMDK4_FLAG_COMPRESS | VMDK4_FLAG_MARKER : 0)
>                     | (zeroed_grain ? VMDK4_FLAG_ZERO_GRAIN : 0);
> 

  reply	other threads:[~2014-06-16  6:36 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-13 19:00 [Qemu-devel] qemu-img convert from raw to vmdk does not work in vmware esxi Milos Vyletel
2014-06-16  6:36 ` Fam Zheng [this message]
2014-06-17 15:03   ` Milos Vyletel

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20140616063631.GD1943@T430.nay.redhat.com \
    --to=famz@redhat.com \
    --cc=milos.vyletel@gmail.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).