Commit Graph

264 Commits

Author SHA1 Message Date
Kevin Wolf b9eaf9ecb1 qemu-img: Improve error messages for failed bdrv_open
Output the error message string of the bdrv_open return code. Also set a
non-empty device name for the images because the unknown feature error message
includes it.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Anthony Liguori <aliguori@us.ibm.com>
2011-02-10 13:24:11 +01:00
Jes Sorensen 70b4f4bb05 Make strtosz() return int64_t instead of ssize_t
strtosz() needs to return a 64 bit type even on 32 bit
architectures. Otherwise qemu-img will fail to create disk
images >= 2GB

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-01-24 11:08:50 +01:00
Kevin Wolf 710da702be qemu-img snapshot: Use writeback caching
None of the other qemu-img subcommands uses writethrough, and there's no reason
why snapshot should be special.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-01-24 11:08:50 +01:00
Kevin Wolf ad7171394f Remove NULL checks for bdrv_new return value
It's an indirect call to qemu_malloc, which never returns an error.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-12-17 16:11:03 +01:00
Jes Sorensen 15654a6d7c qemu.img.c: Use error_report() instead of own error() implementation
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-12-17 16:11:03 +01:00
Jes Sorensen f88e1a4201 qemu-img.c: Re-factor img_create()
This patch re-factors img_create() moving the code doing the actual
work into block.c where it can be shared with QEMU. This is needed to
be able to create images from QEMU to be used for live snapshots.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-12-17 16:11:03 +01:00
Kevin Wolf 53f76e5857 qemu-img: Call error_set_progname
Call error_set_progname during the qemu-img initialization, so that error
messages printed with error_report() use the right prefix.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-12-17 16:11:03 +01:00
Jes Sorensen 1da7cfbd01 qemu-img.c: Clean up handling of image size in img_create()
This cleans up the handling of image size in img_create() by parsing
the value early, and then only setting it once if a value has been
added as the last argument to the command line.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-12-17 16:10:59 +01:00
Stefan Hajnoczi 5eeaad5a57 qemu-img: Fail creation if backing format is invalid
The qemu-img create command should check the backing format to ensure
only image files with valid backing formats are created.  By checking in
qemu-img.c we can print a useful error message.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-12-14 15:44:21 +01:00
Stefan Hajnoczi a87a6721db qemu-img: Free option parameter lists in img_create()
Free option parameter lists in the img_create() error return path.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-12-14 15:44:21 +01:00
Jes Sorensen eec77d9e71 qemu-img: Deprecate obsolete -6 and -e options
If -6 or -e is specified, an error message is printed and we exit. It
does not print help() to avoid the error message getting lost in the
noise.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-12-14 15:44:21 +01:00
Jes Sorensen 2a81998a1a Make error handling more consistent in img_create() and img_resize()
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-12-14 15:44:21 +01:00
Jes Sorensen ef87394c08 Fail if detecting an unknown option
This patch changes qemu-img to exit if an unknown option is detected,
instead of trying to continue with a set of arguments which may be
incorrect.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-12-14 15:44:21 +01:00
Jes Sorensen b8fb60da2d Fix formatting and missing braces in qemu-img.c
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-12-14 15:44:21 +01:00
Jes Sorensen 4ac8aacd95 Consolidate printing of block driver options
This consolidates the printing of block driver options in
print_block_option_help() which is called from both img_create() and
img_convert().

This allows for the "?" detection to be done just after the parsing of
options and the filename, instead of half way down the codepath of
these functions.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-12-14 15:44:21 +01:00
Jes Sorensen 31ca34b8cc img_convert(): Only try to free bs[] entries if bs is valid.
This allows for jumping to 'out:' consistently for error exit.

Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-12-14 15:44:21 +01:00
Jes Sorensen 5bdf61fdd7 Use qemu_mallocz() instead of calloc() in img_convert()
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-12-14 15:44:21 +01:00
Jes Sorensen dc786bc910 Move qemu_gettimeofday() to OS specific files
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-10-30 08:02:38 +00:00
Kevin Wolf a18953fbe7 qemu-img: Fix qemu-img convert -obacking_file
The old -B option caused a backing file to be used for the converted image and
to avoid copying clusters from the old backing file. When replaced with
-obacking_file, qemu-img convert does assign the backing file to the new image,
but it doesn't realize that it should avoid copying clusters from the backing
file.

This patch checks the -o options for a backing_file and applies the same logic
as for -B in this case.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-10-22 14:49:35 +02:00
edison 51ef67270b Copy snapshots out of QCOW2 disk
In order to backup snapshots, created from QCOW2 iamge, we want to copy snapshots out of QCOW2 disk to a seperate storage.
The following patch adds a new option in "qemu-img": qemu-img convert -f qcow2 -O qcow2 -s snapshot_name src_img bck_img.
Right now, it only supports to copy the full snapshot, delta snapshot is on the way.

Changes from V1: all the comments from Kevin are addressed:
Add read-only checking
Fix coding style
Change the name from bdrv_snapshot_load to bdrv_snapshot_load_tmp

Signed-off-by: Disheng Su <edison@cloud.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-10-22 14:49:35 +02:00
Stefan Weil 8b7968f7c4 Use GCC_FMT_ATTR (format checking)
Signed-off-by: Stefan Weil <weil@mail.berlios.de>
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-10-03 06:34:51 +00:00
Kevin Wolf 1bd8e17558 qemu-img convert: Use cache=unsafe for output image
If qemu-img crashes during the conversion, the user will throw away the broken
output file anyway and start over. So no need to be too cautious.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-09-08 12:39:20 +02:00
Kevin Wolf cdbae85169 qemu-img rebase: Open new backing file read-only
We never write to a backing file, so opening rw is useless. It just means that
you can't rebase on top of a file for which you don't have write permissions.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-08-30 18:29:22 +02:00
Kevin Wolf e076f3383b qemu-img check: Distinguish different kinds of errors
People think that their images are corrupted when in fact there are just some
leaked clusters. Differentiating several error cases should make the messages
more comprehensible.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-07-06 17:05:48 +02:00
MORITA Kazutaka c2abccecd9 qemu-img: avoid calling exit(1) to release resources properly
This patch removes exit(1) from error(), and properly releases
resources such as a block driver and an allocated memory.

For testing the Sheepdog block driver with qemu-iotests, it is
necessary to call bdrv_delete() before the program exits.  Because the
driver releases the lock of VM images in the close handler.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-07-02 13:18:02 +02:00
MORITA Kazutaka b50cbabc1b add support for protocol driver create_options
This patch enables protocol drivers to use their create options which
are not supported by the format.  For example, protcol drivers can use
a backing_file option with raw format.

Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-05-28 13:14:25 +02:00
Blue Swirl 0bfcd599e3 Fix %lld or %llx printf format use
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-05-22 08:02:12 +00:00
Kevin Wolf cc60e327c0 qemu-img rebase: Fix output image corruption
qemu-img rebase must always give clusters in the COW file priority over those
in the backing file. As it failed to use number of non-allocated clusters but
assumed the maximum, it was possible that allocated clusters were taken from
the backing file instead, leading to a corrupted output image.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-05-03 10:07:32 +02:00
Stefan Hajnoczi ae6b0ed6d4 qemu-img: Add 'resize' command to grow/shrink disk images
This patch adds a 'resize' command to grow/shrink disk images.  This
allows changing the size of disk images without copying to a new image
file.  Currently only raw files support resize.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-05-03 10:07:32 +02:00
Kevin Wolf f2feebbd93 block: bdrv_has_zero_init
This fixes the problem that qemu-img's use of no_zero_init only considered the
no_zero_init flag of the format driver, but not of the underlying protocols.

Between the raw/file split and this fix, converting to host devices is broken.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-05-03 10:07:30 +02:00
Stefan Hajnoczi adfe078e4b qemu-img: Fix BRDV_O_FLAGS typo
It should be BDRV_O_FLAGS instead of BRDV_O_FLAGS.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-04-23 16:21:57 +02:00
Stefan Hajnoczi f163d0736c qemu-img: Eliminate bdrv_new_open() code duplication
Several commands have code to create a BlockDriverState and open a file.
The bdrv_new_open() function can be used to perform these steps.  This
patch converts the qemu-img commands to actually use bdrv_new_open().

Replaced the bdrv_new_open() 'readonly' argument with bdrv_open()-style
flags to support generic flags like BDRV_O_NO_BACKING.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-04-23 16:21:57 +02:00
Kevin Wolf d6e9098e10 Replace calls of old bdrv_open
What is known today as bdrv_open2 becomes the new bdrv_open. All remaining
callers of the old function are converted to the new one. In some places they
even know the right format, so they should have used bdrv_open2 from the
beginning.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-04-23 16:08:46 +02:00
Juan Quintela 3e7896dec4 block: print errno on error
Now that we changed all create calls to return errno, just print it.

Signed-off-by: Juan Quintela <quintela@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-03-09 11:23:00 -06:00
Kevin Wolf e53dbee05d qemu-img rebase: Add -f option
Allow the user to specify the format of the image to rebase.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-03-09 09:04:17 -06:00
Kevin Wolf 584771e6b6 qemu-img: Fix error message
When qemu-img can't open the new backing file for a rebase, it prints an error
message which contains the file name of the old backing file. This is wrong,
obviously.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-19 15:53:54 -06:00
Kevin Wolf 60b1bd4fc5 qemu-img: Fix segfault during rebase
This fixes a possible read beyond the end of the temporary buffers used for
comparing data in the old and the new backing file.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-19 15:53:54 -06:00
TeLeMan d6771bfa52 qemu-img: use the heap instead of the huge stack array for win32
The default stack size of PE is 1MB on win32 and IO_BUF_SIZE in
img_convert() & img_rebase() is 2MB, so qemu-img will crash when doing
"convert" & "rebase" on win32.
Although we can improve the stack size of PE to resolve it, I think we
should avoid using the huge stack variables.

Signed-off-by: TeLeMan <geleman@gmail.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-10 14:00:53 -06:00
Sheng Yang 9bc378c143 qemu-img: Fix qemu-img can't create qcow image based on read-only image
Commit 03cbdac7 "Disable fall-back to read-only when cannot open drive's
file for read-write" result in read-only image can't be used as backed
image in qemu-img.

Cc: Naphtali Sprei <nsprei@redhat.com>
Signed-off-by: Sheng Yang <sheng@linux.intel.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-02-10 11:56:56 -06:00
Paolo Bonzini e00291c008 qemu-img: avoid preprocessor directives in a printf call
Other choices include using "(printf)", but this one is not bad in
terms of readability.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: malc <av1474@comtv.ru>
2010-02-08 12:12:40 +03:00
malc 3f020d7024 Revert "On some systems printf is a macro"
This reverts commit bc5b600458.
2010-02-08 12:12:40 +03:00
malc bc5b600458 On some systems printf is a macro
Signed-off-by: malc <av1474@comtv.ru>
2010-02-07 02:04:28 +03:00
Naphtali Sprei 058fc8c768 Ask for read-write permissions when opening files
Found some places that seems needs this explicitly, now that
read-write is not the default.

Signed-off-by: Naphtali Sprei <nsprei@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-26 15:42:01 -06:00
Naphtali Sprei f5edb014ed Clean-up a little bit the RW related bits of BDRV_O_FLAGS. BDRV_O_RDONLY gone (and so is BDRV_O_ACCESS). Default value for bdrv_flags (0/zero) is READ-ONLY. Need to explicitly request READ-WRITE.
Instead of using the field 'readonly' of the BlockDriverState struct for passing the request,
pass the request in the flags parameter to the function.

Signed-off-by: Naphtali Sprei <nsprei@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-20 08:25:22 -06:00
Kevin Wolf 3e85c6fd71 qemu-img rebase
This adds a rebase subcommand to qemu-img which allows to change the backing
file of an image.

In default mode, both the current and the new backing file need to exist, and
after the rebase, the COW image is guaranteed to have the same guest visible
content as before. To achieve this, old and new backing file are compared and,
if necessary, data is copied from the old backing file into the COW image.

With -u an unsafe mode is enabled that doesn't require the backing files to
exist. It merely changes the backing file reference in the COW image. This is
useful for renaming or moving the backing file. The user is responsible to make
sure that the new backing file has no changes compared to the old one, or
corruption may occur.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-13 17:14:15 -06:00
Kevin Wolf b783e409bf block: Introduce BDRV_O_NO_BACKING
If an image references a backing file that doesn't exist, qemu-img info fails
to open this image. Exactly in this case the info would be valuable, though:
the user might want to find out which file is missing.

This patch introduces a BDRV_O_NO_BACKING flag to ignore the backing file when
opening the image. qemu-img info is the first user and provides info now even
if the backing file is invalid.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2010-01-13 17:14:15 -06:00
Kevin Wolf 7078dead94 qemu-img: Fix memory leak
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 15:26:00 -06:00
Pierre Riteau 21eb3a2ba3 Fix description of size parameter in qemu-img's help text
Valid description taken from qemu-img.texi, although it would be better
to have this information recorded in only one place.

Signed-off-by: Pierre Riteau <Pierre.Riteau@irisa.fr>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 15:25:58 -06:00
Kevin Wolf 12c09b8ce2 qemu-img: There is more than one host device driver
I haven't heard yet of anyone using qemu-img to copy an image to a real floppy,
but it's a valid use case.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-03 11:45:50 -06:00
Kevin Wolf 8063d0fe3b Documentation: Don't mention old qemu-img options
The old options are still supported for compatibility, but they are
inconsistent (for example create -b vs. convert -B for backing files) and
incomplete (-F only exists for create) which tends to confuse people. Remove
all references to the old options from the documentation to guide users to the
more consistent -o options.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-09 08:43:12 -06:00
Kevin Wolf 9f56640c85 qemu-img: Allow creating zero sized images
A size of 0 should be valid and cannot be treated as "missing value". Use -1
for this purpose instead.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-11-09 08:43:03 -06:00
Kevin Wolf 80ee15a6b2 qcow2: Increase maximum cluster size to 2 MB
This patch increases the maximum qcow2 cluster size to 2 MB. Starting with 128k
clusters, L2 tables span 2 GB or more of virtual disk space, causing 32 bit
truncation and wraparound of signed integers. Therefore some variables need to
use a larger data type.

While being at reviewing data types, change some integers that are used for
array indices to unsigned. In some places they were checked against some upper
limit but not for negative values. This could avoid potential segfaults with
corrupted qcow2 images.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-05 09:32:52 -05:00
Anthony Liguori c227f0995e Revert "Get rid of _t suffix"
In the very least, a change like this requires discussion on the list.

The naming convention is goofy and it causes a massive merge problem.  Something
like this _must_ be presented on the list first so people can provide input
and cope with it.

This reverts commit 99a0949b72.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-10-01 16:12:16 -05:00
malc 99a0949b72 Get rid of _t suffix
Some not so obvious bits, slirp and Xen were left alone for the time
being.

Signed-off-by: malc <av1474@comtv.ru>
2009-10-01 22:45:02 +04:00
Akkarit Sangpetch d032044fb9 qmu-img: fix qemu-img convert to generate a valid image when the source referenced a backing file
Make 'qemu-img convert' copies unallocated parts of the source image
when -B option was not specified.

Signed-off-by: Akkarit Sangpetch <asangpet@andrew.cmu.edu>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-07-22 10:58:47 -05:00
Stuart Brady 153859be1a Use hxtool for qemu-img command list
Use hxtool to generate the 'command syntax' section of qemu-img's help
message, and the corresponding section of the texinfo documentation.

This has the side-effect of adding 'check' to this list of commands in
the texinfo documentation.

Signed-off-by: Stuart Brady <stuart.brady@gmail.com>
2009-06-07 09:59:47 +03:00
Kevin Wolf eff442662d Document changes in qemu-img interface
Update the documentation to reflect the introduction of format specific options
with -o. Don't advertise -e or -6 any more, they exist only for compatibility
reasons and can be replaced by the corresponding -o options.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2009-06-06 18:39:02 +03:00
Kevin Wolf db08adf526 qemu-img: Print available options with -o ?
This patch adds a small help text to each of the options in the block drivers
which can be displayed by using qemu-img create -f fmt -o ?

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2009-06-06 18:38:57 +03:00
Kevin Wolf efa84d43cc Convert qemu-img convert to new bdrv_create
This is part two of the qemu-img conversion. This really works the same as the
previous conversion of qemu-img create: It introduces a new -o option for the
generic approach and adds the old-style options to this option set.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-05-22 10:50:32 -05:00
Kevin Wolf 9ea2ea7146 Convert qemu-img create to new bdrv_create
This patch changes qemu-img to actually use the new bdrv_create interface. It
translates the old-style qemu-img options which have been bdrv_create2
parameters or flags so far to option structures. As the generic approach, it
introduces an -o option which accepts any parameter the driver knows.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-05-22 10:50:31 -05:00
Kevin Wolf 0e7e1989f7 Convert all block drivers to new bdrv_create
Now we can make use of the newly introduced option structures. Instead of
having bdrv_create carry more and more parameters (which are format specific in
most cases), just pass a option structure as defined by the driver itself.

bdrv_create2() contains an emulation of the old interface to simplify the
transition.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-05-22 10:50:31 -05:00
Anthony Liguori 5efa9d5a8b Convert block infrastructure to use new module init functionality
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-05-14 16:13:41 -05:00
Paul Brook 5561650587 Include assert.h from qemu-common.h
Include assert.h from qemu-common.h and remove other direct uses.
cpu-all.h still need to include it because of the dyngen-exec.h hacks

Signed-off-by: Paul Brook <paul@codesourcery.com>
2009-05-13 20:54:26 +01:00
aliguori 1585969c6e Introduce qemu-img check subcommand (Kevin Wolf)
From: Kevin Wolf <kwolf@redhat.com>

Now that block drivers can provide check functions, expose them through
qemu-img.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7215 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-21 23:11:53 +00:00
aurel32 6e9ea0c062 block-vpc: Don't silently create smaller image than requested
The algorithm from the VHD specification for CHS calculation silently limits
images to 127 GB which may confuse a user who requested a larger image. Better
output an error message and abort.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7109 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-15 14:42:46 +00:00
aliguori 93c65b47a6 Add host_device support to qemu-img. (Nolan Leake)
This patch allows the use a host_device as the destination for "qemu-img
convert".

I added a ->bdrv_create function host_device.  It merely verifies that
the device exists and is large enough.

A check is needed in the qemu-img convert loop to ensure that we write
out all 0 sectors to the host_device.  Otherwise they end up with stale
garbage where all zero sectors were expected.

I also made the check against bdrv_is_allocated enabled for everything
_except_ host devices, since there is no point in making the block
backend write a bunch of zeros just so that we can memcmp them
immediately afterwards.  Host devices can't benefit from this because
there is no way to differentiate between a sector being unallocated
because it was never written, or because it was written with all zeros
and then made a trip through qemu-img convert.

Finally, there is an unrelated fix for a typo in the error message
printed if the destination device does not support ->bdrv_create.

Signed-off-by: Nolan Leake <nolan <at> sigbus.net>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6978 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-05 17:40:43 +00:00
aliguori 9230eaf679 qemu-img: adding a "-F base_fmt" option to "qemu-img create -b" (Uri Lublin)
If the user specifies the backing file format,
then when opening the backing file, there is no need
to probe the (backing file) image to figure out its format.

This follows my previous patches implementing bdrv_create2
which keeps (for qcow2 only) the backing file format
as a qcow2-extension

Suggested by Daniel P. Berrange.

Signed-off-by: Uri Lublin <uril@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6910 c046a42c-6fe2-441c-8c8c-71466251a162
2009-03-28 17:55:19 +00:00
aliguori fc19793453 Revert r6408
This series is broken by design as it requires expensive IO operations at
open time causing very long delays when starting a virtual machine for the
first time.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6812 c046a42c-6fe2-441c-8c8c-71466251a162
2009-03-11 20:05:20 +00:00
aurel32 2fbc409571 qemu-img: fix help message
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6787 c046a42c-6fe2-441c-8c8c-71466251a162
2009-03-08 19:49:51 +00:00
aurel32 2450148920 qemu-img: accept sizes with decimal values
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6786 c046a42c-6fe2-441c-8c8c-71466251a162
2009-03-08 19:49:44 +00:00
aliguori 49dc768d4c Fix windows build and clean up use of <windows.h>
We want to globally define WIN_LEAN_AND_MEAN and WINVER to particular values so
let's do it in OS_CFLAGS.

Then, we can pepper in windows.h includes where using #includes that require it.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>



git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6783 c046a42c-6fe2-441c-8c8c-71466251a162
2009-03-08 16:26:59 +00:00
aurel32 8f9b157e06 Make qemu-img argument handling POSIX compliant
Signed-off-by: Hervé Poussineau <hpoussin@reactos.org>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6578 c046a42c-6fe2-441c-8c8c-71466251a162
2009-02-09 18:14:31 +00:00
malc a5e50b263a Replace noreturn with QEMU_NORETURN
Thanks to Robert Riebisch for analysis [1]

[1] http://marc.info/?l=qemu-devel&m=123352293319271&w=2

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6492 c046a42c-6fe2-441c-8c8c-71466251a162
2009-02-01 22:19:27 +00:00
blueswir1 d2c639d6dc Synch code, help and docs
Rearrange code, help printout and docs so that they are in the same
(hopefully more logical) order for easier maintenance.

Add help and docs for undocumented options.

Reformat slightly for more consistent help output.

Add comments to encourage better synchronization in the future.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6432 c046a42c-6fe2-441c-8c8c-71466251a162
2009-01-24 18:19:25 +00:00
malc 4f94dc644e Fix format warnings
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6417 c046a42c-6fe2-441c-8c8c-71466251a162
2009-01-24 14:38:06 +00:00
aliguori 7e739a58bb qemu-img: info: show highest_alloc and num_free_bytes if exist (Uri Lublin)
Signed-off-by: Uri Lublin <uril@redhat.com>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6408 c046a42c-6fe2-441c-8c8c-71466251a162
2009-01-22 18:57:38 +00:00
aliguori 40a4539e20 qemu-img: Fix type of getopt return value (Kevin Wolf)
getopt doesn't return a char but an int.

Signed-off-by: Kevin Wolf <kwolf@suse.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>



git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6331 c046a42c-6fe2-441c-8c8c-71466251a162
2009-01-15 21:42:12 +00:00
blueswir1 7d99a001df Add noreturn function attribute
Introduce noreturn attribute and attach it to cpu_loop_exit as well as
interrupt/exception helpers for i386. This avoids a bunch of gcc4
warnings.

[ Note that this patch comes with a workaround to include qemu-common.h
even in cases where is currently causes conflicts with dyngen-exec.h.
I've been told that these conflicts will get resolved in the future
(/me will try to have a look as well - as time permits). ]

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6303 c046a42c-6fe2-441c-8c8c-71466251a162
2009-01-14 19:00:36 +00:00
aliguori f7b4a940a4 snapshot subcommand for qemu-img (Kevin Wolf)
Add snapshot subcommand to qemu-img which allows to list, create, apply
and delete snapshots on qcow2 images.

Signed-off-by: Kevin Wolf <kwolf@suse.de>
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>



git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6215 c046a42c-6fe2-441c-8c8c-71466251a162
2009-01-07 17:40:15 +00:00
aurel32 137519ce2e qemu-img: open files with cache=writeback
Data integrity is not important in qemu-img, so open the files with
cache=writeback. This fixes the performance regression seen with qemu-img
since revision 5485, and most particularly with the qcow2 format.

Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>

git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5839 c046a42c-6fe2-441c-8c8c-71466251a162
2008-11-30 19:12:49 +00:00
blueswir1 a10ea30b11 Fix OpenBSD linker warnings in qemu-img
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@5078 c046a42c-6fe2-441c-8c8c-71466251a162
2008-08-24 10:30:33 +00:00
aliguori e94f3a609e Revert 4977. Laurent asked for this not to be applied but I mistakenly applied
it.

Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>




git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4978 c046a42c-6fe2-441c-8c8c-71466251a162
2008-08-01 15:04:00 +00:00
aliguori 61fce45f12 qemu-img: set encrypted disk image password (Laurent Vivier)
This patch modify qemu-img to ask and set a password when an encrypted
disk image is created.

Signed-off-by: Laurent Vivier <Laurent.Vivier@bull.net>
Signed-off-by: Anthony Liguori <anthony@codemonkey.ws>



git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4977 c046a42c-6fe2-441c-8c8c-71466251a162
2008-08-01 15:00:04 +00:00
ths f58c7b3545 New qemu-img convert -B option, by Marc Bevand.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4672 c046a42c-6fe2-441c-8c8c-71466251a162
2008-06-05 21:53:49 +00:00
aurel32 ca10f86763 Remove osdep.c/qemu-img code duplication
(Kevin Wolf)


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@4191 c046a42c-6fe2-441c-8c8c-71466251a162
2008-04-11 21:35:42 +00:00
balrog c0be16d39f Correct qemu-img usage hint (Andreas Färber).
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3975 c046a42c-6fe2-441c-8c8c-71466251a162
2008-02-10 14:10:31 +00:00
bellard 68d0f70e3c copyright update
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3893 c046a42c-6fe2-441c-8c8c-71466251a162
2008-01-06 17:21:48 +00:00
ths 4fddf62a74 Use WIN32_LEAN_AND_MEAN, by Stefan Weil.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3832 c046a42c-6fe2-441c-8c8c-71466251a162
2007-12-17 04:42:29 +00:00
ths 96b8f136f5 Fix bdrv_get_geometry to return uint64_t, by Andre Przywara.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3825 c046a42c-6fe2-441c-8c8c-71466251a162
2007-12-17 01:35:20 +00:00
pbrook 3f379ab187 Cleanup qemu-img.c.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3579 c046a42c-6fe2-441c-8c8c-71466251a162
2007-11-11 03:33:13 +00:00
pbrook faf07963cb Split block API from vl.h.
Remove QEMU_TOOL. Replace with QEMU_IMG and NEED_CPU_H.
Avoid linking qemu-img against whole system emulatior.


git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3578 c046a42c-6fe2-441c-8c8c-71466251a162
2007-11-11 02:51:17 +00:00
balrog 926c2d23df Support multipart images as input to qemu-img (Salvador Fandino).
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3496 c046a42c-6fe2-441c-8c8c-71466251a162
2007-10-31 01:11:44 +00:00
ths d8871c5a49 Fix typo, spotted by Edivaldo de Araujo Pereira.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3434 c046a42c-6fe2-441c-8c8c-71466251a162
2007-10-24 16:11:42 +00:00
ths 3b46e62427 find -type f | xargs sed -i 's/[\t ]*$//g' # Yes, again. Note the star in the regex.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3177 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-17 08:09:54 +00:00
ths ec36ba1474 vmdk compatibility level 6 images, by Soren Hansen.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3175 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-16 21:59:02 +00:00
ths 5fafdf24ef find -type f | xargs sed -i 's/[\t ]$//g' # on most files
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3173 c046a42c-6fe2-441c-8c8c-71466251a162
2007-09-16 21:08:06 +00:00
ths 0cfec834c5 Spelling fixes, by Aurelien Jarno.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@3009 c046a42c-6fe2-441c-8c8c-71466251a162
2007-06-23 16:02:43 +00:00
ths d34dda5ea5 qemu-img: fix incorrect error message, by Stuart Brady.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2414 c046a42c-6fe2-441c-8c8c-71466251a162
2007-02-10 22:59:40 +00:00
bellard 84f2e8ef05 copyright update
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2392 c046a42c-6fe2-441c-8c8c-71466251a162
2007-02-05 20:21:32 +00:00
bellard 18607dcb7c added cutils.c
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2310 c046a42c-6fe2-441c-8c8c-71466251a162
2007-01-07 22:04:40 +00:00
ths fef3074347 Escape filname printout properly, by Anthony Liguori and Julian Seward.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2263 c046a42c-6fe2-441c-8c8c-71466251a162
2006-12-22 14:11:32 +00:00
bellard fb43f4dddc copyright update
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2101 c046a42c-6fe2-441c-8c8c-71466251a162
2006-08-07 21:34:46 +00:00
bellard faea38e786 multiple snapshot support
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2086 c046a42c-6fe2-441c-8c8c-71466251a162
2006-08-05 21:31:00 +00:00
bellard 93b6b2a3cd show backing file name
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@2073 c046a42c-6fe2-441c-8c8c-71466251a162
2006-08-01 15:51:11 +00:00
bellard ec3757de32 use C99 64 bit printf format to ease win32 porting
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1974 c046a42c-6fe2-441c-8c8c-71466251a162
2006-06-14 15:50:07 +00:00
bellard e8445331b6 show real allocated disk image size on Windows (Frediano Ziglio)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1973 c046a42c-6fe2-441c-8c8c-71466251a162
2006-06-14 15:32:10 +00:00
bellard f5a8510c7c copyright
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1534 c046a42c-6fe2-441c-8c8c-71466251a162
2005-07-24 18:44:56 +00:00
bellard de167e416f Virtual VFAT support (Johannes Schindelin)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1426 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-28 21:15:08 +00:00
bellard b8076a748d ia64 host support (David Mosberger)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1360 c046a42c-6fe2-441c-8c8c-71466251a162
2005-04-07 22:20:31 +00:00
bellard e388818682 BSD getopt fix
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1103 c046a42c-6fe2-441c-8c8c-71466251a162
2004-10-09 16:44:06 +00:00
bellard 3c56521b70 cloop driver (Johannes Schindelin)
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1076 c046a42c-6fe2-441c-8c8c-71466251a162
2004-09-29 21:29:14 +00:00
bellard 75c2380584 fixed image creation with base filename
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1056 c046a42c-6fe2-441c-8c8c-71466251a162
2004-08-27 21:28:58 +00:00
bellard 57d1a2b62c win32 port
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1041 c046a42c-6fe2-441c-8c8c-71466251a162
2004-08-03 21:15:11 +00:00
bellard ea2384d36e new disk image layer
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@1037 c046a42c-6fe2-441c-8c8c-71466251a162
2004-08-01 21:59:26 +00:00