History | View | Annotate | Download (78.6 kB)
block: Add reference parameter to bdrv_open()
Allow bdrv_open() to handle references to existing block devices just asbdrv_file_open() is already capable of.
Signed-off-by: Max Reitz <mreitz@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: Change BDS parameter of bdrv_open() to **
Make bdrv_open() take a pointer to a BDS pointer, similarly tobdrv_file_open(). If a pointer to a NULL pointer is given, bdrv_open()will create a new BDS with an empty name; if the BDS pointer is notNULL, that existing BDS will be reused (in the same way as bdrv_open()...
Use error_is_set() only when necessary
error_is_set(&var) is the same as var != NULL, but it takeswhole-program analysis to figure that out. Unnecessarily hard foroptimizers, static checkers, and human readers. Dumb it down toobvious.
Gets rid of several dozen Coverity false positives....
qemu-option: Remove qemu_opts_create_nofail
This is a boiler-plate _nofail variant of qemu_opts_create. Remove anduse error_abort in call sites.
null/0 arguments needs to be added for the id and fail_if_exists fieldsin affected callsites due to argument inconsistency between the normal and...
qemu-img: make progress output more accurate during convert
the progress output is very bumpy if the input images containsa significant portion of unallocated sectors. This patchchecks how much sectors are allocated a priori if progressoutput is selected....
qemu-img: decrease progress update interval on convert
when doing very large jobs updating the progress only every 2%is too rare.
Signed-off-by: Peter Lieven <pl@kamp.de>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
qemu-img: round down request length to an aligned sector
this patch shortens requests to end at an aligned sector so thatthe next request starts aligned.
[Squashed Peter's fix for bdrv_get_info() failure discussed on themailing list.--Stefan]
Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>...
qemu-img: add support for skipping zeroes in input during convert
we currently do not check if a sector is allocated during convert.This means if a sector is unallocated that we allocate a bouncebuffer of zeroes, find out its zero later and do not write it...
qemu-img: fix usage instruction for qemu-img convert
Reviewed-by: Eric Blake <eblake@redhat.com>Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Peter Lieven <pl@kamp.de>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
qemu-img: dynamically adjust iobuffer size during convert
since the convert process is basically a sync operation it mightbe benificial in some case to change the hardcoded I/O buffersize to a greater value.
This patch increases the I/O buffer size if the output...
snapshot: distinguish id and name in load_tmp
Since later this function will be used so improve it. The only caller of itnow is qemu-img, and it is not impacted by introduce functionbdrv_snapshot_load_tmp_by_id_or_name() that call bdrv_snapshot_load_tmp()...
qemu-img: add -l for snapshot in convert
Now qemu-img convert have similar options as qemu-nbd for internalsnapshot.
Signed-off-by: Wenchao Xia <xiawenc@linux.vnet.ibm.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
qemu-img: add support for fully allocated images
qemu-img: conditionally zero out target on convert
If the target has_zero_init = 0, but supports efficientlywriting zeroes by unmapping we call bdrv_make_zero toavoid fully allocating the target. This currently worksonly for iscsi. It can be extended to raw with...
qemu-img: Fix overwriting 'ret' before using
This patch moves ret assignment after reporting original error.
We were lucky to pass qemu-iotests 048 (qemu-img compare case) but whenI tried to run with TEST_DIR=/tmp (tmpfs), it fails with a "wrong" mismatch offset. This fixes two bugs....
qemu-img: add special exit code if bdrv_check is not supported
currently it is not possible to distinguish by exitcode if therehas been an error or if bdrv_check is not supported by the imageformat. Change the exitcode from 1 to 63 for the latter case....
qemu-img: fix invalid JSON
Single quotes for JSON are a QMP-ism, use real JSON inqemu-img output.
Reported-by: Kevin Wolf <kwolf@redhat.com>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: Error parameter for open functions
Add an Error ** parameter to bdrv_open, bdrv_file_open and associatedfunctions to allow more specific error messages.
Signed-off-by: Max Reitz <mreitz@redhat.com>
block: Error parameter for create functions
Add an Error ** parameter to bdrv_create and its associated functions toallow more specific error messages.
qemu-img create: Emit filename on error
bdrv_img_create generally does not emit the target filename, althoughthis is pretty important information. Therefore, prepend its errormessage with the output filename (if an error occurs).
snapshot: distinguish id and name in snapshot delete
Snapshot creation actually already distinguish id and name since it takea structured parameter *sn, but delete can't. Later an accurate deleteis needed in qmp_transaction abort and blockdev-snapshot-delete-sync,...
block: Image file option amendment
This patch adds the "amend" option to qemu-img which allows changingimage options on existing image files. It also adds the generic bdrvimplementation which is basically just a wrapper for the image formatspecific function....
block: expect errors from bdrv_co_is_allocated
Some bdrv_is_allocated callers do not expect errors, but the fallbackin qcow2.c might make other callers trip on assertion failures orinfinite loops.
Fix the callers to always look for errors.
Cc: qemu-stable@nongnu.org...
qemu-img: always probe the input image for allocated sectors
qemu-img convert can assume "that sectors which are unallocated in theinput image are present in both the output's and input's base images".
However it is only doing this if the output image returns true for...
block: make bdrv_has_zero_init return false for copy-on-write-images
This helps implementing is_allocated on top of get_block_status.
Reviewed-by: Eric Blake <eblake@redhat.com>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
qemu-img: add a "map" subcommand
This command dumps the metadata of an entire chain, in either tabular or JSONformat.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
block: make bdrv_delete() static
Manage BlockDriverState lifecycle with refcnt, so bdrv_delete() is nolonger public and should be called by bdrv_unref() if refcnt isdecreased to 0.
This is an identical change because effectively, there's no multiplereference of BDS now: no caller of bdrv_ref() yet, only bdrv_new() sets...
add qemu-img convert -n option (skip target volume creation)
Add a -n option to skip volume creation on qemu-img convert.This is useful for targets such as rbd / ceph, where thetarget volume may already exist; we cannot always rely onqemu-img convert to create the image, as dependent on the...
qemu-img: Error out for excess arguments
Don't silently ignore excess arguments at the end of the command line,but error out instead. This can catch typos like 'resize test.img + 1G',which doesn't increase the image size by 1G as intended, but truncates...
ignore SIGPIPE in qemu-img and qemu-io
This prevents the tools from being stopped when they write data to aclosed connection in the other side.
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>...
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.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.