From patchwork Fri Jun 13 19:00:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Milos Vyletel X-Patchwork-Id: 359685 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 7FF081400EE for ; Sat, 14 Jun 2014 06:41:00 +1000 (EST) Received: from localhost ([::1]:33116 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WvYHR-0002Je-U5 for incoming@patchwork.ozlabs.org; Fri, 13 Jun 2014 16:40:57 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:60191) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WvWig-0004ZN-My for qemu-devel@nongnu.org; Fri, 13 Jun 2014 15:01:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WvWif-0006t8-2f for qemu-devel@nongnu.org; Fri, 13 Jun 2014 15:00:58 -0400 Received: from mail-ve0-x233.google.com ([2607:f8b0:400c:c01::233]:48530) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WvWie-0006sy-Mz for qemu-devel@nongnu.org; Fri, 13 Jun 2014 15:00:56 -0400 Received: by mail-ve0-f179.google.com with SMTP id sa20so1941460veb.10 for ; Fri, 13 Jun 2014 12:00:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=UDodN9Ro4Z3LL5ImOQGF4Br9vF4Z9+pHJ1lYuxQJiis=; b=1GOVLwNAnX7PGphE9xB7CZnGRb1lFEeuNCZ4wcWAd2Z4NrW37MfB2w7XDKczIDhxV5 38B4BbIav2wrSVyCC6o/s7Qasd6eXW+BHgPEePAAuEBDFDQST7gft+uHM3ObKmWwoI9g Y5IkXnGUGnDyPO7uB+Hwu3/tcsddFG/6YZhz89JoT4PTQCu5Ct/yqOPIDUUsy//NIHon 2EZKCSsO2xeAqgYAyQ/Kq4P9WD6n5g0lxK+8u/EZjSChagyfynqEOqRS5gTXCMnpyIJk rpf2YLYv11JdWBOrtg7Qxyi30pQavUMqBb43b8+YsAerMslSVAR3s3XYA/OlOBpUbYlT rZhA== MIME-Version: 1.0 X-Received: by 10.220.105.136 with SMTP id t8mr2995800vco.13.1402686055581; Fri, 13 Jun 2014 12:00:55 -0700 (PDT) Received: by 10.220.132.130 with HTTP; Fri, 13 Jun 2014 12:00:55 -0700 (PDT) Date: Fri, 13 Jun 2014 15:00:55 -0400 Message-ID: From: Milos Vyletel To: qemu-devel@nongnu.org X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2607:f8b0:400c:c01::233 X-Mailman-Approved-At: Fri, 13 Jun 2014 16:40:36 -0400 Subject: [Qemu-devel] qemu-img convert from raw to vmdk does not work in vmware esxi X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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 --- | (zeroed_grain ? VMDK4_FLAG_ZERO_GRAIN : 0); 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)) { /* 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)