History | View | Annotate | Download (57.3 kB)
use qemu_opts_create_nofail
We will use qemu_opts_create_nofail function, it can make codemore readable.
Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: bdrv_img_create(): add Error ** argument
This commit adds an Error ** argument to bdrv_img_create() and set itappropriately on error.
Callers of bdrv_img_create() pass NULL for the new argument and stillrely on bdrv_img_create()'s return value. Next commits will change...
qemu-img: img_create(): pass Error object to bdrv_img_create()
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
qemu-img: img_create(): drop unneeded goto and ret variable
tools: initialize main loop before block layer
Tools were broken because they initialized the block layer whileqemu_aio_context was still NULL.
Reported-by: malc <av1474@comtv.ru>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: malc <av1474@comtv.ru>
qemu-img: Add --backing-chain option to info command
The qemu-img info --backing-chain option enumerates the backing filechain. For example, for base.qcow2 <- snap1.qcow2 <- snap2.qcow2 theoutput becomes:
$ qemu-img info --backing-chain snap2.qcow2...
qemu-img: Fix division by zero for zero size images
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
qemu-img rebase: use empty string to rebase without backing file
This patch allows an empty filename to be passed as the new base image namefor qemu-img rebase to mean base the image on no backing file (i.e.independent of any backing file). According to Eric Blake, qemu-img rebase...
Merge remote-tracking branch 'kwolf/for-anthony' into staging
Spelling fixes in comments and documentation
These wrong spellings were detected by codespell:
["also is" -> "is also" and "ressources" -> "resources" suggested by...
qemu-img: Add json output option to the info command.
This option --output=[human|json] make qemu-img info output onhuman or JSON representation at the choice of the user.
example: { "snapshots": [ { "vm-clock-nsec": 637102488, "name": "vm-20120821145509",...
Don't require encryption password for 'qemu-img info' command
The encryption password is only required if I/O is going to beperformed on a disk image. The 'qemu-img info' command merelyreports metadata, so it should not ask for a decryption password
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>...
block: add BLOCK_O_CHECK for qemu-img check
Image formats with a dirty bit, like qed and qcow2, repair dirty imagefiles upon open with BDRV_O_RDWR. Performing automatic repair whenqemu-img check runs is not ideal because the bdrv_open() call repairsthe image before the actual bdrv_check() call from qemu-img.c....
qemu-img: use QemuOpts instead of QEMUOptionParameter in resize function
Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Support 'help' as a synonym for '?' in command line options
For command line options which permit '?' meaning 'please list thepermitted values', add support for 'help' as a synonym, by abstractingthe check out into a helper function.
This change means that in some cases where we were being lazy in...
block: Replace bdrv_get_format() by bdrv_get_format_name()
So callers don't need to know anything about maximum name length.Returning a pointer is safe, because the name string lives as long asthe block driver it names, and block drivers don't die.
Requested by Peter Maydell....
qemu-img check -r for repairing images
The QED block driver already provides the functionality to not onlydetect inconsistencies in images, but also fix them. However, thisfunctionality cannot be manually invoked with qemu-img, but thecheck happens only automatically during bdrv_open()....
qemu-img check: Print fixed clusters and recheck
When any inconsistencies have been fixed, print the statistics and runanother check to make sure everything is correct now.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
qemu-img: Fix segmentation fault
The following command generates a segmentation fault.qemu-img convert -O vpc -o ? test test2This is because the 'goto out;' statement calls qemu_progress_endbefore qemu_progress_init is called resulting in a NULL pointer...
qemu-img: make "info" backing file output correct and easier to use
qemu-img info should use the same logic as qemu when printing thebacking file path, or debugging becomes quite tricky. We can alsosimplify the output in case the backing file has an absolute path...
qemu-img: let 'qemu-img convert' flush data
The 'qemu-img convert -h' advertise that the default cache mode is'writeback', while in fact it is 'unsafe'.
This patch 1) fix the help manual and 2) let bdrv_close() call bdrv_flush()
2) is needed because some backend storage doesn't have a self-flush...
qemu-img: add dirty flag status
Some block drivers can verify their image files are clean or not. So we can showit while using "qemu-img info".
Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>...
qemu-img: add image fragmentation statistics
Discussion can be found at:http://patchwork.ozlabs.org/patch/128730/
This patch add image fragmentation statistics while using qemu-img check.
qcow2: Add error messages in qcow2_truncate
qemu-img resize has some limitations with qcow2, but the user is onlytold that "this image format does not support resize". Quite confusing,so add some more detailed error_report() calls and change "this image...
qemu-img: fix segment fault when the image format is qed
[root@f15 qemu]# qemu-img info /home/zwu/work/misc/rh6.imgimage: /home/zwu/work/misc/rh6.imgfile format: qedvirtual size: 4.0G (4294967296 bytes)disk size: 1.2Gcluster_size: 65536Segmentation fault (core dumped)...
cutils: extract buffer_is_zero() from qemu-img.c
The qemu-img.c:is_not_zero() function checks if a buffer contains allzeroes. This function will come in handy for zero-detection in theblock layer, so clean it up and move it to cutils.c.
Note that the function now returns true if the buffer is all zeroes....
qemu-img rebase: Fix for undersized backing files
Backing files may be smaller than the corresponding COW file. Whenreading directly from the backing file, qemu-img rebase must considerthis and assume zero sectors after the end of backing files.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>...
qemu-img: Tighten parsing of size arguments
strtosz_suffix() fails unless the size is followed by 0, whitespace or','. Useless here, because we need to fail for any junk following thesize, even if it starts with whitespace or ','. Check manually.Things like "qemu-img create xxx 1024," and "qemu-img convert -S '1024...
qemu-img: Don't allow preallocation and compression at the same time
Only qcow and qcow2 can do compression at all, and they require unallocatedclusters when writing the compressed data.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
qemu-img: Require larger zero areas for sparse handling
By default, require 4k of consecutive zero bytes for qemu-img to make theoutput file sparse by not issuing a write request for the zeroed parts. Add an-S option to allow users to tune this setting....
block: parse cache mode flags in a single place
This patch introduces bdrv_parse_cache_flags() which sets open flagsgiven a cache mode. Previously this was duplicated in blockdev.c andqemu-img.c.
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>...
block: add cache=directsync parameter to -drive
This patch adds -drive cache=directsync for O_DIRECT | O_SYNC host fileI/O with no disk write cache presented to the guest.
This mode is useful when guests may not be sending flushes whenappropriate and therefore leave data at risk in case of power failure....
qemu-img: Use qemu_blockalign
Now that you can use cache=none for the output file in qemu-img, we shouldproperly align our buffers so that raw-posix doesn't have to use its (smaller)bounce buffer.
qemu-img: print error codes when convert fails
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Use glib memory allocation and free functions
qemu_malloc/qemu_free no longer exist after this commit.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
block: add bdrv_get_allocated_file_size() operation
qemu-img.c wants to count allocated file size of image. Previously itcounts a single bs->file by 'stat' or Window API. As VMDK introducesmultiple file support, the operation becomes format specific with...
qemu-img: Add cache command line option
qemu-img currently writes disk images using writeback and fillingup the cache buffers which are then flushed by the kernel preventingother processes from accessing the storage.This is particularly bad in cluster environments where time-based...
qemu-img: Don't prepend qemu-img to error messages twice.
error_report() prepends the location already. Example:
$ qemu-img convert -6qemu-img: qemu-img: option -6 is deprecated, please use '-o compat6' instead!
Signed-off-by: Markus Armbruster <armbru@redhat.com>...
Strip trailing '\n' from error_report()'s first argument
error_report() prepends location, and appends a newline. The messageconstructed from the arguments should not contain a newline. Fix theobvious offenders.
qemu_img: is_not_zero() optimization
I run qemu-img under profiler and realized, that most of CPU time isconsumed by is_not_zero() function. I had made a couple of optimizationson it and got the following output for `time qemu-img convert -O qcow2volume.qcow2 snapshot.qcow2`:...
qemu-img.c: Remove superfluous parenthesis
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
qemu-img resize: Fix option parsing
For shrinking images, you're supposed to use a negative size. However, theleading minus makes getopt think that it's an option and so you get the helptext if you don't use -- like in 'qemu-img resize test.img -- -1G'....
qemu-img: allow rebase to a NULL backing file when unsafe
QEMU can drop a backing file so that an image file no longer depends onthe backing file, but this feature has not been exposed in qemu-img.This is useful in an image streaming usecase or when an image file has...
qemu-img rebase: Fix segfault if backing file can't be opened
bdrv_delete must not be called for a NULL BlockDriverState.
qemu-img: Initial progress printing support
This adds the basic infrastructure for supporting progress outputon the command line, as well as progress support for qemu-img commands'rebase' and 'convert'.
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>...
qemu-img: Improve error messages for failed bdrv_open
Output the error message string of the bdrv_open return code. Also set anon-empty device name for the images because the unknown feature error messageincludes it.
qemu-img snapshot: Use writeback caching
None of the other qemu-img subcommands uses writethrough, and there's no reasonwhy snapshot should be special.
Make strtosz() return int64_t instead of ssize_t
strtosz() needs to return a 64 bit type even on 32 bitarchitectures. Otherwise qemu-img will fail to create diskimages >= 2GB
qemu-img: Call error_set_progname
Call error_set_progname during the qemu-img initialization, so that errormessages printed with error_report() use the right prefix.
qemu-img.c: Re-factor img_create()
This patch re-factors img_create() moving the code doing the actualwork into block.c where it can be shared with QEMU. This is needed tobe able to create images from QEMU to be used for live snapshots.
qemu.img.c: Use error_report() instead of own error() implementation
Remove NULL checks for bdrv_new return value
It's an indirect call to qemu_malloc, which never returns an error.
qemu-img.c: Clean up handling of image size in img_create()
This cleans up the handling of image size in img_create() by parsingthe value early, and then only setting it once if a value has beenadded as the last argument to the command line.
Use qemu_mallocz() instead of calloc() in img_convert()
img_convert(): Only try to free bs[] entries if bs is valid.
This allows for jumping to 'out:' consistently for error exit.
Consolidate printing of block driver options
This consolidates the printing of block driver options inprint_block_option_help() which is called from both img_create() andimg_convert().
This allows for the "?" detection to be done just after the parsing of...
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>
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 beincorrect.
Make error handling more consistent in img_create() and img_resize()
qemu-img: Deprecate obsolete -6 and -e options
If -6 or -e is specified, an error message is printed and we exit. Itdoes not print help() to avoid the error message getting lost in thenoise.
qemu-img: Free option parameter lists in img_create()
Free option parameter lists in the img_create() error return path.
qemu-img: Fail creation if backing format is invalid
The qemu-img create command should check the backing format to ensureonly image files with valid backing formats are created. By checking inqemu-img.c we can print a useful error message.
Move qemu_gettimeofday() to OS specific files
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
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....
qemu-img: Fix qemu-img convert -obacking_file
The old -B option caused a backing file to be used for the converted image andto 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,...
Use GCC_FMT_ATTR (format checking)
Signed-off-by: Stefan Weil <weil@mail.berlios.de>Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
qemu-img convert: Use cache=unsafe for output image
If qemu-img crashes during the conversion, the user will throw away the brokenoutput file anyway and start over. So no need to be too cautious.
qemu-img rebase: Open new backing file read-only
We never write to a backing file, so opening rw is useless. It just means thatyou can't rebase on top of a file for which you don't have write permissions.
qemu-img check: Distinguish different kinds of errors
People think that their images are corrupted when in fact there are just someleaked clusters. Differentiating several error cases should make the messagesmore comprehensible.
qemu-img: avoid calling exit(1) to release resources properly
This patch removes exit(1) from error(), and properly releasesresources such as a block driver and an allocated memory.
For testing the Sheepdog block driver with qemu-iotests, it isnecessary to call bdrv_delete() before the program exits. Because the...
add support for protocol driver create_options
This patch enables protocol drivers to use their create options whichare not supported by the format. For example, protcol drivers can usea backing_file option with raw format.
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>...
Fix %lld or %llx printf format use
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
qemu-img: Add 'resize' command to grow/shrink disk images
This patch adds a 'resize' command to grow/shrink disk images. Thisallows changing the size of disk images without copying to a new imagefile. Currently only raw files support resize.
qemu-img rebase: Fix output image corruption
qemu-img rebase must always give clusters in the COW file priority over thosein the backing file. As it failed to use number of non-allocated clusters butassumed the maximum, it was possible that allocated clusters were taken from...
block: bdrv_has_zero_init
This fixes the problem that qemu-img's use of no_zero_init only considered theno_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....
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. Thispatch converts the qemu-img commands to actually use bdrv_new_open()....
qemu-img: Fix BRDV_O_FLAGS typo
It should be BDRV_O_FLAGS instead of BRDV_O_FLAGS.
Replace calls of old bdrv_open
What is known today as bdrv_open2 becomes the new bdrv_open. All remainingcallers of the old function are converted to the new one. In some places theyeven know the right format, so they should have used bdrv_open2 from the...
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>
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>
qemu-img: Fix segfault during rebase
This fixes a possible read beyond the end of the temporary buffers used forcomparing data in the old and the new backing file.
qemu-img: Fix error message
When qemu-img can't open the new backing file for a rebase, it prints an errormessage which contains the file name of the old backing file. This is wrong,obviously.
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 inimg_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...
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'sfile for read-write" result in read-only image can't be used as backedimage in qemu-img.
Cc: Naphtali Sprei <nsprei@redhat.com>...
Revert "On some systems printf is a macro"
This reverts commit bc5b6004588ad17370e0416e40b4aa9cf977023b.
qemu-img: avoid preprocessor directives in a printf call
Other choices include using "(printf)", but this one is not bad interms of readability.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: malc <av1474@comtv.ru>
On some systems printf is a macro
Signed-off-by: malc <av1474@comtv.ru>
Ask for read-write permissions when opening files
Found some places that seems needs this explicitly, now thatread-write is not the default.
Signed-off-by: Naphtali Sprei <nsprei@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
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,...
block: Introduce BDRV_O_NO_BACKING
If an image references a backing file that doesn't exist, qemu-img info failsto 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...
qemu-img rebase
This adds a rebase subcommand to qemu-img which allows to change the backingfile of an image.
In default mode, both the current and the new backing file need to exist, andafter the rebase, the COW image is guaranteed to have the same guest visible...
qemu-img: Fix memory leak
Fix description of size parameter in qemu-img's help text
Valid description taken from qemu-img.texi, although it would be betterto 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>
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.
Documentation: Don't mention old qemu-img options
The old options are still supported for compatibility, but they areinconsistent (for example create -b vs. convert -B for backing files) andincomplete (-F only exists for create) which tends to confuse people. Remove...
qemu-img: Allow creating zero sized images
A size of 0 should be valid and cannot be treated as "missing value". Use -1for this purpose instead.
qcow2: Increase maximum cluster size to 2 MB
This patch increases the maximum qcow2 cluster size to 2 MB. Starting with 128kclusters, L2 tables span 2 GB or more of virtual disk space, causing 32 bittruncation and wraparound of signed integers. Therefore some variables need to...
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. Somethinglike this must be presented on the list first so people can provide input...
Get rid of _t suffix
Some not so obvious bits, slirp and Xen were left alone for the timebeing.
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 imagewhen -B option was not specified.
Signed-off-by: Akkarit Sangpetch <asangpet@andrew.cmu.edu>...