From patchwork Mon Jul 13 21:48:23 2009 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Randall Smith X-Patchwork-Id: 35484 Received: from vger.kernel.org (vger.kernel.org [209.132.176.167]) by demeter.kernel.org (8.14.2/8.14.2) with ESMTP id n6DLmTwl007504 for ; Mon, 13 Jul 2009 21:48:29 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756937AbZGMVs1 (ORCPT ); Mon, 13 Jul 2009 17:48:27 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1757206AbZGMVs1 (ORCPT ); Mon, 13 Jul 2009 17:48:27 -0400 Received: from mail-yx0-f184.google.com ([209.85.210.184]:55626 "EHLO mail-yx0-f184.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1756937AbZGMVs0 convert rfc822-to-8bit (ORCPT ); Mon, 13 Jul 2009 17:48:26 -0400 Received: by yxe14 with SMTP id 14so3601375yxe.33 for ; Mon, 13 Jul 2009 14:48:25 -0700 (PDT) MIME-Version: 1.0 Received: by 10.231.12.135 with SMTP id x7mr1267239ibx.42.1247521703924; Mon, 13 Jul 2009 14:48:23 -0700 (PDT) In-Reply-To: <4A5BA9CF.9000205@codemonkey.ws> References: <4A5BA908.7080003@vuser.org> <4A5BA9CF.9000205@codemonkey.ws> Date: Mon, 13 Jul 2009 15:48:23 -0600 Message-ID: <92f126f40907131448o2700bd4di258064c4249eaa06@mail.gmail.com> Subject: Re: kvm-87: qemu-img creates raw file with wrong size From: Randall Smith To: Anthony Liguori Cc: kvm@vger.kernel.org Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org On Mon, Jul 13, 2009 at 3:40 PM, Anthony Liguori wrote: > Randy Smith wrote: >> >> Greetings, >> >> Running `qemu-img create -f raw file.raw 1000` creates a 512 byte file >> rather than the 1000K file the docs imply. >> >> From the help message: >> " >> 'size' is the disk image size in kilobytes. Optional suffixes >> 'M' (megabyte, 1024 * 1024) and 'G' (gigabyte, 1024 * 1024 * 1024) are >> supported any 'k' or 'K' is ignored >> " >> >> Did the default change or is there bug with the create? >> > > No suffix assumes bytes.  It truncates to the nearest sector which is why > you see a 512 byte file.  If you did `qemu-img create -f raw file.raw 1024` > you would see a file of 1024 bytes. > > Not sure if the docs is wrong or this behavior changed.  Patch either way > would be appreciated/accepted. It looks like the behavior changed. The ubuntu-vm-builder depended on 'size' defaulting to kilobytes and the help message printed when qemu-img is run claims that it should default to kilobytes. Here's a patch that updates the help message. It doesn't matter to me if the behavior changed here but as long as the docs match what's really happening. 1024 * 1024) are\n" " supported any 'k' or 'K' is ignored\n" " 'output_filename' is the destination disk image filename\n" --- qemu-img.c.orig 2009-07-13 15:42:49.000000000 -0600 +++ qemu-img.c 2009-07-13 15:43:11.000000000 -0600 @@ -78,7 +78,7 @@ " content as the input's base image, however the path, image format, etc may\n" " differ\n" " 'fmt' is the disk image format. It is guessed automatically in most cases\n" - " 'size' is the disk image size in kilobytes. Optional suffixes\n" + " 'size' is the disk image size in bytes. Optional suffixes\n" " 'M' (megabyte, 1024 * 1024) and 'G' (gigabyte, 1024 *