summaryrefslogtreecommitdiffstats
path: root/qemu-io.c
Commit message (Collapse)AuthorAgeFilesLines
* qemu-io: add write -z option for bdrv_co_write_zeroesStefan Hajnoczi2012-02-091-8/+69
| | | | | | | | | Extend the qemu-io write command with the -z option to call bdrv_co_write_zeroes(). Exposing the zero write interface from qemu-io allows us to write tests that exercise this new block layer interface. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* Merge remote-tracking branch 'kwolf/for-anthony' into stagingAnthony Liguori2012-01-271-24/+24
|\ | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | * kwolf/for-anthony: (22 commits) scsi: Guard against buflen exceeding req->cmd.xfer in scsi_disk_emulate_command qcow: Use bdrv functions to replace file operation qcow: Return real error code in qcow_open block/vdi: Zero unused parts when allocating a new block (fix #919242) virtio-blk: add virtio_blk_handle_read trace event docs: describe live block operations block: add support for partial streaming add QERR_BASE_NOT_FOUND block: add bdrv_find_backing_image blockdev: make image streaming safe across hotplug qmp: add query-block-jobs qmp: add block_job_cancel command qmp: add block_job_set_speed command qmp: add block_stream command block: rate-limit streaming operations block: add image streaming block job block: add BlockJob interface for long-running operations block: make copy-on-read a per-request flag block: check bdrv_in_use() before blockdev operations coroutine: add co_sleep_ns() coroutine sleep function ...
| * block: replace unchecked strdup/malloc/calloc with glibStefan Hajnoczi2012-01-261-24/+24
| | | | | | | | | | | | | | | | | | | | | | Most of the codebase as been converted to use glib memory allocation functions. There are still a few instances of malloc/calloc in the block layer and qemu-io. Replace them, especially since they do not check the strdup/malloc/calloc return value. Reported-by: Dr David Alan Gilbert <davidagilbert@uk.ibm.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* | qemu-io: end aio help text sentences with periodsLaszlo Ersek2012-01-271-2/+2
|/ | | | | Signed-off-by: Laszlo Ersek <lersek@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
* block: bdrv_aio_* do not return NULLPaolo Bonzini2011-12-151-31/+8
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Initially done with the following semantic patch: @ rule1 @ expression E; statement S; @@ E = ( bdrv_aio_readv | bdrv_aio_writev | bdrv_aio_flush | bdrv_aio_discard | bdrv_aio_ioctl ) (...); ( - if (E == NULL) { ... } | - if (E) { <... S ...> } ) which however missed the occurrence in block/blkverify.c (as it should have done), and left behind some unused variables. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* Merge remote-tracking branch 'kwolf/for-anthony' into stagingAnthony Liguori2011-12-051-2/+2
|\
| * block: convert qemu_aio_flush() calls to bdrv_drain_all()Stefan Hajnoczi2011-12-051-2/+2
| | | | | | | | | | | | | | | | | | | | | | | | | | Many places in QEMU call qemu_aio_flush() to complete all pending asynchronous I/O. Most of these places actually want to drain all block requests but there is no block layer API to do so. This patch introduces the bdrv_drain_all() API to wait for requests across all BlockDriverStates to complete. As a bonus we perform checks after qemu_aio_wait() to ensure that requests really have finished. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* | fix spelling in main directoryDong Xu Wang2011-12-021-1/+1
|/ | | | | Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
* qemu-io: Fix multiwrite_f error handlingKevin Wolf2011-11-041-3/+6
| | | | | | | Without this fix, some qiovs can be leaked if an error occurs. Also a semicolon at the end of the command line would make the code walk beyond the end of argv. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qemu-io: Handle create_iovec errorsKevin Wolf2011-11-041-4/+24
| | | | | | | Callers of create_iovec() didn't check for failure and continued with uninitialised data in error cases. This patch adds checks to each call. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qemu-io: delete bs instead of leaking itStefan Hajnoczi2011-10-281-2/+3
| | | | | | | | | Using bdrv_close() is not enough to free a BlockDriverState. Since we explicitly create it with bdrv_new(), use bdrv_delete() to close and delete it. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* fix memory leak in aio_write_fAlex Jia2011-10-211-0/+1
| | | | | | | Haven't released memory of 'ctx' before return. Signed-off-by: Alex Jia <ajia@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* Remove blanks before \n in output stringsStefan Weil2011-09-161-1/+1
| | | | | | | | | | | | | | Those blanks violate the coding conventions, see scripts/checkpatch.pl. Blanks missing after colons in the changed lines were added. This patch does not try to fix tabs, long lines and other problems in the changed lines, therefore checkpatch.pl reports many violations. Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qemu-io: remove unnecessary assignmentBlue Swirl2011-09-101-1/+0
| | | | | | | | | Remove an unnecessary assignment, spotted by clang analyzer: /src/qemu/qemu-io.c:995:9: warning: Value stored to 'offset' is never read offset += reqs[i].qiov->size; Acked-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* Use glib memory allocation and free functionsAnthony Liguori2011-08-201-6/+6
| | | | | | qemu_malloc/qemu_free no longer exist after this commit. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qemu-io: Fix if scoping bugDevin Nakamura2011-07-181-1/+2
| | | | | | | | | Fix a bug caused by lack of braces in if statement Lack of braces means that if(count & 0x1ff) is never reached Signed-off-by: Devin Nakamura <devin122@gmail.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qemu-io: Fix formattingDevin Nakamura2011-07-181-1322/+1330
| | | | | | | | Replaced tabs with spaces, 8 space indentations with 4 space indentation, and other fixes to better adhere to CODING_STYLE Signed-off-by: Devin Nakamura <devin122@gmail.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* block: clarify the meaning of BDRV_O_NOCACHEChristoph Hellwig2011-06-081-2/+2
| | | | | | | | | Change BDRV_O_NOCACHE to only imply bypassing the host OS file cache, but no writeback semantics. All existing callers are changed to also specify BDRV_O_CACHE_WB to give them writeback semantics. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qemu-io: Fix discard commandKevin Wolf2011-01-311-1/+1
| | | | | | | | qemu-io passed bytes where it's supposed to pass sectors, so discard requests were off. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
* qemu-io: fix a memory leakBlue Swirl2011-01-121-1/+3
| | | | | | | Fix a memory leak, reported by cppcheck: [/src/qemu/qemu-io.c:1135]: (error) Memory leak: ctx Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* qemu-io: Fix typo in help textsKevin Wolf2010-12-171-7/+7
| | | | Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qemu-io: Add discard commandStefan Hajnoczi2010-12-171-0/+88
| | | | | | | | | | | | | | | | | discard [-Cq] off len -- discards a number of bytes at a specified offset discards a range of bytes from the given offset Example: 'discard 512 1k' - discards 1 kilobyte from 512 bytes into the file Discards a segment of the currently open file. -C, -- report statistics in a machine parsable format -q, -- quite mode, do not show I/O statistics Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* Remove NULL checks for bdrv_new return valueKevin Wolf2010-12-171-2/+0
| | | | | | It's an indirect call to qemu_malloc, which never returns an error. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qemu-io: New command mapKevin Wolf2010-10-221-0/+39
| | | | | | | The new map command in qemu-io lists all allocated/unallocated areas in an image file. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* use qemu_blockalign consistentlyChristoph Hellwig2010-09-211-1/+1
| | | | | | | | | Use qemu_blockalign for all allocations in the block layer. This allows increasing the required alignment, which is need to support O_DIRECT on devices with large block sizes. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qemu-io: Make alloc output useful when nb_sectors=1Stefan Hajnoczi2010-09-081-5/+2
| | | | | | | | | | | | | | | | | | | | There is no indication whether or not the sector is allocated when nb_sectors=1: sector allocated at offset 64 KiB This message is produced whether or not the sector is allocated. Simply use the same message as the plural case, I don't think the English is so broken that we need special case output here: 0/1 sectors allocated at offset 64 KiB This change does not affect qemu-iotests since nb_sectors=1 is not used there. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* fix variable type in qemu-io.cJoel Schopp2010-07-301-2/+2
| | | | | | | | | | The variable len can get a negative return value from cvtnum, which we check for, but which is impossible with the current unsigned variable type. Currently the if(len < 0) check is pointless. This patch fixes that. Signed-off-by: Joel Schopp <jschopp@austin.ibm.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* qemu-io: Fix error messagesKevin Wolf2010-06-041-2/+2
| | | | | | | | The truncate and getlength commands passed a negative error number to strerror. They also happen to be the two functions that are lacking a newline at the end of their error message. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* qemu-io: Add multiwrite commandKevin Wolf2010-05-281-0/+192
| | | | | | | The new multiwrite commands allows to use qemu-io for testing bdrv_aio_multiwrite. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* Fix %lld or %llx printf format useBlue Swirl2010-05-221-29/+29
| | | | Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* block: get rid of the BDRV_O_FILE flagChristoph Hellwig2010-04-231-14/+14
| | | | | | | | | | | | | | | | | | | | BDRV_O_FILE is only used to communicate between bdrv_file_open and bdrv_open. It affects two things: first bdrv_open only searches for protocols using find_protocol instead of all image formats and host drivers. We can easily move that to the caller and pass the found driver to bdrv_open. Second it is used to not force a read-write open of a snapshot file. But we never use bdrv_file_open to open snapshots and this behaviour doesn't make sense to start with. qemu-io abused the BDRV_O_FILE for it's growable option, switch it to using bdrv_file_open to make sure we only open files as growable were we can actually support that. This patch requires Kevin's "[PATCH] Replace calls of old bdrv_open" to be applied first. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* Replace calls of old bdrv_openKevin Wolf2010-04-231-1/+1
| | | | | | | | | 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>
* qemu-io: fix aio help textsChristoph Hellwig2010-03-281-5/+5
| | | | | | | Fix a few typos in the help texts for the various aio commands. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* qemu-io: Fix return value handling of bdrv_openRyota Ozaki2010-03-271-1/+1
| | | | | | | | bdrv_open may return -errno so we have to check if the return value is '< 0', not '== -1'. Signed-off-by: Ryota Ozaki <ozaki.ryota@gmail.com> Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
* block: kill BDRV_O_CREATChristoph Hellwig2010-01-261-12/+3
| | | | | | | | | The BDRV_O_CREAT option is unused inside qemu and partially duplicates the bdrv_create method. Remove it, and the -C option to qemu-io which isn't used in qemu-iotests anyway. Signed-off-by: Christoph Hellwig <hch@lst.de> 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 ↵Naphtali Sprei2010-01-201-8/+6
| | | | | | | | | | 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>
* qemu-io: suppress a warning with gcc 4.0.2Blue Swirl2009-12-231-2/+4
| | | | Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* qemu-io: Fix memory leakKevin Wolf2009-12-181-4/+6
| | | | | Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qemu-io: add 'const'Blue Swirl2009-12-131-1/+1
| | | | Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* Fix OpenBSD build of qemu-ioBlue Swirl2009-11-211-87/+86
| | | | | | | | | GCC 3.3.5 generates warnings for static forward declarations of data, so rearrange code to use static forward declarations of functions instead. Use <getopt.h> for optind instead of local definition. Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* qemu-io: Improve portability (win32 now supported).Stefan Weil2009-09-091-0/+2
| | | | | | | | | * Add missing include for struct timeval. * Replace non-portable strsep by local qemu_strsep. * Use POSIX basename by including libgen.h. Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* raw-posix: add Linux native AIO supportChristoph Hellwig2009-08-271-1/+6
| | | | | | | | | | | | | | | | | | | Now that do have a nicer interface to work against we can add Linux native AIO support. It's an extremly thing layer just setting up an iocb for the io_submit system call in the submission path, and registering an eventfd with the qemu poll handler to do complete the iocbs directly from there. This started out based on Anthony's earlier AIO patch, but after estimated 42,000 rewrites and just as many build system changes there's not much left of it. To enable native kernel aio use the aio=native sub-command on the drive command line. I have also added an option to qemu-io to test the aio support without needing a guest. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* Fix Sparse warnings: "Using plain integer as NULL pointer"Blue Swirl2009-07-311-11/+11
| | | | Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* qemu-io: reject invalid patternChristoph Hellwig2009-07-221-6/+38
| | | | | | | | | | | | | | | Replace the use of atoi which is used for pattern parsing currently with strtol. Atoi won't parse sedecimal pattern values (it always returns 0), but qemu-iotests use such pattern values. Also reject every pattern that is not a unsigned char as we pass the pattern to memset which expect a bye value (despite having the pattern argument declared as int). Based on an earlier patch by Stefan Weil which did not include the error handling. Signed-off-by: Christoph Hellwig <hch@lst.de> Reported-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qemu-io: Rework alloc commandKevin Wolf2009-07-221-8/+14
| | | | | | | | | | | | | | The alloc command in qemu-io is mostly useless currently. Instead of doing a single call to bdrv_is_allocated, we must call bdrv_is_allocated in a loop until we have found out for each requested sector if it is allocated or not (bdrv_is_allocated returns a number of sectors that are known to be in the same state as the first one, but it is not required to include all of them) This changes the output format of the alloc command so that a change to the expected output of qemu-iotests 019 is necessary once this is included. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qemu-io: use BDRV_O_FILE to implement the growable open optionChristoph Hellwig2009-07-161-8/+5
| | | | | | | | | | | | Instead of doing our own check for protocols which fails because raw isn't formally a protocol but special cased in find_protocol specify the BDRV_O_FILE option to use the same code as bdrv_file_open does. While we're at it also add the missing documentation for -g to the main qemu-io help string. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qemu-io: Implement bdrv_load_vmstate/bdrv_save_vmstateKevin Wolf2009-07-161-6/+44
| | | | | | | | | | The load_vmstate and save_vmstate functions are implemented as a variation of the normal read/write operation, enabled by the -b option. This is the same mechanism as is used to switch from read/write to pread/pwrite. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
* qemu-io: fix memory leakKevin Wolf2009-07-101-22/+38
| | | | | | | | | | qemu-io leaks the request buffer whenever the read or write function isn't executed completely down the "normal" code path. [hch: also fix the aio and vectored variants the same way] Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Christoph Hellwig <hch@lst.de>
* qemu-io: add flag to mark files growableChristoph Hellwig2009-07-101-5/+26
| | | | | | | | | Add a -g flag to the open command and the main qemu-io command line to allow opening a file growable. This is only allowed for protocols, mirroring the limitation exposed through bdrv_file_open. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Kevin Wolf <kwolf@redhat.com>
* qemu-io: better input validation for vector-based commandsChristoph Hellwig2009-07-101-150/+68
| | | | | | | | | | | | | | | | Fix up a couple of issues with validating the input of the various length arguments for the vectored I/O commands: - do the alignment check on each length instead the always 0 count argument - use a long long varibale for the cvtnum return value so that we can check wether it wasn't a number - check for a too large argument instead of truncating it Also refactor it into a common helper for all four calers and avoid parsing the numbers twice. Signed-off-by: Christoph Hellwig <hch@lst.de> Reviewed-by: Kevin Wolf <kwolf@redhat.com>
OpenPOWER on IntegriCloud