summaryrefslogtreecommitdiff
path: root/qemu-io.c
AgeCommit message (Collapse)Author
2010-07-30fix variable type in qemu-io.cJoel Schopp
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>
2010-06-04qemu-io: Fix error messagesKevin Wolf
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>
2010-05-28qemu-io: Add multiwrite commandKevin Wolf
The new multiwrite commands allows to use qemu-io for testing bdrv_aio_multiwrite. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-05-22Fix %lld or %llx printf format useBlue Swirl
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-04-23block: get rid of the BDRV_O_FILE flagChristoph Hellwig
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>
2010-04-23Replace calls of old bdrv_openKevin Wolf
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-03-28qemu-io: fix aio help textsChristoph Hellwig
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>
2010-03-27qemu-io: Fix return value handling of bdrv_openRyota Ozaki
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>
2010-01-26block: kill BDRV_O_CREATChristoph Hellwig
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>
2010-01-20Clean-up a little bit the RW related bits of BDRV_O_FLAGS. BDRV_O_RDONLY ↵Naphtali Sprei
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>
2009-12-23qemu-io: suppress a warning with gcc 4.0.2Blue Swirl
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-12-18qemu-io: Fix memory leakKevin Wolf
Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-12-13qemu-io: add 'const'Blue Swirl
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-11-21Fix OpenBSD build of qemu-ioBlue Swirl
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>
2009-09-09qemu-io: Improve portability (win32 now supported).Stefan Weil
* 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>
2009-08-27raw-posix: add Linux native AIO supportChristoph Hellwig
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>
2009-07-31Fix Sparse warnings: "Using plain integer as NULL pointer"Blue Swirl
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2009-07-22qemu-io: reject invalid patternChristoph Hellwig
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>
2009-07-22qemu-io: Rework alloc commandKevin Wolf
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>
2009-07-16qemu-io: use BDRV_O_FILE to implement the growable open optionChristoph Hellwig
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>
2009-07-16qemu-io: Implement bdrv_load_vmstate/bdrv_save_vmstateKevin Wolf
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>
2009-07-10qemu-io: fix memory leakKevin Wolf
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>
2009-07-10qemu-io: add flag to mark files growableChristoph Hellwig
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>
2009-07-10qemu-io: better input validation for vector-based commandsChristoph Hellwig
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>
2009-07-10qemu-io: small cleanups for the aio codeChristoph Hellwig
Address a couple of review comments from Kevin. Signed-off-by: Christoph Hellwig <hch@lst.de>
2009-06-24qemu-io: add aio read/write/flush commandsChristoph Hellwig
Add commands to exercise asynchronous reads/writes and to flush all outstanding aio commands. Commands to exercise aio cancellations will follow in a separate patch. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-24qemu-io: Fix spelling in help message.Stefan Weil
excerciser -> exerciser Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-24Fix dump output in qemu-io.Stefan Weil
The dump output was not nicely formatted for bytes larger than 0x7f, because signed values expanded to sizeof(int) bytes. So for example 0xab did not print as "ab", but as "ffffffab". I also cleaned the function prototype, which avoids new type casts and allows to remove an existing type cast. Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-05-09Workaround compiler warnings at -O1Paul Brook
Signed-off-by: Paul Brook <paul@codesourcery.com>
2009-05-01qemu-io: Optionally verify only part of read dataKevin Wolf
There are reasonable test cases where a read must span areas that are not uniformly filled with one pattern but contains several parts. This makes -P useless for them currently. Introducing additional options which determine the part of the read data that should be verified with the given pattern allows to check such reads. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-04-18qemu-io: Verify read data by patterns (Kevin Wolf)aliguori
This patch adds a -P option to read and readv which allows to compare the read data to a given pattern. This can be used to verify data written by write -P. 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@7182 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-18qemu-io: Fix handling of bdrv_is_allocated() return value (Kevin Wolf)aliguori
bdrv_is_allocated() returns a boolean which indicates if the offset is allocated, not 0 on success and everything else is an error. 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@7181 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-18a couple of qemu-io fixes (Christoph Hellwig)aliguori
Fix two stupid bugs that I forgot to push out: - qiov->size already is in bytes, no need to shift it - actually use the supplied patter in the writev command Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7178 c046a42c-6fe2-441c-8c8c-71466251a162
2009-04-05Add files not included in previous commit.aliguori
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com> git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6995 c046a42c-6fe2-441c-8c8c-71466251a162