History | View | Annotate | Download (66.7 kB)
block: Don't parse protocol from file.filename
One of the major reasons for doing something new for -blockdev andblockdev-add was that the old block layer code parses filenames insteadof just taking them literally. So we should really leave it untouched...
qemu-img: Add missing GCC_FMT_ATTR
Signed-off-by: Stefan Weil <sw@weilnetz.de>Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>Signed-off-by: Michael Tokarev <mjt@tls.msk.ru>
block: add snapshot info query function bdrv_query_snapshot_info_list()
This patch adds function bdrv_query_snapshot_info_list(), which willretrieve snapshot info of an image in qmp object format. The implementationis based on the code moved from qemu-img.c with modification to fit more...
block: add image info query function bdrv_query_image_info()
This patch adds function bdrv_query_image_info(), which willretrieve image info in qmp object format. The implementation isbased on the code moved from qemu-img.c, but uses block layerfunction to get snapshot info....
cutils: Support 'P' and 'E' suffixes in strtosz()
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
block: move qmp and info dump related code to block/qapi.c
This patch is a pure code move patch, except following modification:1 get_human_readable_size() is changed to static function.2 dump_human_image_info() is renamed to bdrv_image_info_dump().3 in qmp_query_block() and qmp_query_blockstats, use bdrv_next(bs)...
block: dump snapshot and image info to specified output
bdrv_snapshot_dump() and bdrv_image_info_dump() do not dump to a buffer now,some internal buffers are still used for format control, which have nochance to be truncated. As a result, these two functions have no more issue...
qemu-img: do not zero-pad the compressed write buffer
bdrv_write_compressed() does not allow requests that span the end of thedevice. Therefore it is useless to zero-pad the last cluster andthereby exceed the end of the device.
Let image formats handle zero-padding the final compressed cluster, if...
block: Add options QDict to bdrv_open() prototype
It doesn't do anything yet except storing the options QDict in theBlockDriverState.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>...
qemu-img: Add compare subcommand
This patch adds new qemu-img subcommand that compares content of two diskimages.
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>Reviewed-by: Kevin Wolf <kwolf@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
qemu-img: fix missing space in qemu-img check output
The qemu-img check fragmentation printf() is missing a space before the'=' sign. The human output is not guaranteed to be stable and we arenot aware of screen scrapers, so add the missing space.
Also fix the missing indentation of the printf() arguments....
qemu-img: add compressed clusters to BlockFragInfo
Show how many clusters are compressed. This can be used to monitor howmany compressed clusters remain and whether to recompress the image.
Suggested-by: Cole Robinson <crobinso@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
qemu-img: Add "Quiet mode" option
There can be a need to turn output to stdout off. This patch adds a -q optionthat enable "Quiet mode". In Quiet mode, only errors are printed out.
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>Reviewed-by: Kevin Wolf <kwolf@redhat.com>...
qemu-img: find the image end offset during check
This patch adds the support for reporting the image end offset (inbytes). This is particularly useful after a conversion (or a rebase)where the destination is a block device in order to find the firstunused byte at the end of the image....
qemu-img: add json output option to the check command
This option --output=[human|json] makes qemu-img check output a humanor JSON representation at the choice of the user.
Signed-off-by: Federico Simoncelli <fsimonce@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>...
qemu-img: report size overflow error message
qemu-img will complain when qcow or qcow2size overflow for 64 bits, report the rightmessage in this condition.
$./qemu-img create -f qcow2 /tmp/foo 0x10000000000000000before change:qemu-img: Invalid image size specified! You may use k, M, G or T suffixes for...
softmmu: move include files to include/sysemu/
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
misc: move include files to include/qemu/
qapi: move include files to include/qobject/
block: move include files to include/block/
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>