summaryrefslogtreecommitdiff
path: root/block/vpc.c
AgeCommit message (Collapse)AuthorFilesLines
2011-10-21block: add a CoMutex to synchronous read driversPaolo Bonzini1-0/+2
The big conversion of bdrv_read/write to coroutines caused the two homonymous callbacks in BlockDriver to become reentrant. It goes like this: 1) bdrv_read is now called in a coroutine, and calls bdrv_read or bdrv_pread. 2) the nested bdrv_read goes through the fast path in bdrv_rw_co_entry; 3) in the common case when the protocol is file, bdrv_co_do_readv calls bdrv_co_readv_em (and from here goes to bdrv_co_io_em), which yields until the AIO operation is complete; 4) if bdrv_read had been called from a bottom half, the main loop is free to iterate again: a device model or another bottom half can then come and call bdrv_read again. This applies to all four of read/write/flush/discard. It would also apply to is_allocated, but it is not used from within coroutines: besides qemu-img.c and qemu-io.c, which operate synchronously, the only user is the monitor. Copy-on-read will introduce a use in the block layer, and will require converting it. The solution is "simply" to convert all drivers to coroutines! We just need to add a CoMutex that is taken around affected operations. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-08-20Use glib memory allocation and free functionsAnthony Liguori1-4/+4
qemu_malloc/qemu_free no longer exist after this commit. Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2011-08-01block/vpc.c: Detect too-large vpc fileSerge E. Hallyn1-1/+7
VHD files technically can be up to 2Tb, but virtual pc is limited to 127G. Currently qemu-img refused to create vpc files > 127G, but it is failing to return error when converting from a non-vpc VHD file which is >127G. It returns success, but creates a truncated converted image. Also, qemu-img info claims the vpc file is 127G (and clean). This patch detects a too-large vpc file and returns -EFBIG. Without this patch, ============================================================= root@ip-10-38-123-242:~/qemu-fixed# qemu-img info /mnt/140g-dynamic.vhd image: /mnt/140g-dynamic.vhd file format: vpc virtual size: 127G (136899993600 bytes) disk size: 284K root@ip-10-38-123-242:~/qemu-fixed# qemu-img convert -f vpc -O raw /mnt/140g-dynamic.vhd /mnt/y root@ip-10-38-123-242:~/qemu-fixed# echo $? 0 root@ip-10-38-123-242:~/qemu-fixed# qemu-img info /mnt/y image: /mnt/y file format: raw virtual size: 127G (136899993600 bytes) disk size: 0 ============================================================= (The 140G image was truncated with no warning or error.) With the patch, I get: ============================================================= root@ip-10-38-123-242:~/qemu-fixed# ./qemu-img info /mnt/140g-dynamic.vhd qemu-img: Could not open '/mnt/140g-dynamic.vhd': File too large root@ip-10-38-123-242:~/qemu-fixed# ./qemu-img convert -f vpc -O raw /mnt/140g-dynamic.vhd /mnt/y qemu-img: Could not open '/mnt/140g-dynamic.vhd': File too large qemu-img: Could not open '/mnt/140g-dynamic.vhd' ============================================================= See https://bugs.launchpad.net/qemu/+bug/814222 for details. Signed-off-by: Serge Hallyn <serge.hallyn@canonical.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-04-13vpc.c: Use get_option_parameter() does the searchMitnick Lyu1-6/+2
Use get_option_parameter() to instead of duplicating the loop, and use BDRV_SECTOR_SIZE to instead of 512 Signed-off-by: Mitnick Lyu <mitnick.lyu@gmail.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-01-12vpc: fix a file descriptor leakBlue Swirl1-17/+30
Fix a file descriptor leak, reported by cppcheck: [/src/qemu/block/vpc.c:524]: (error) Resource leak: fd Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
2010-11-24block: Remove unused s->hd in various driversKevin Wolf1-2/+0
All drivers use bs->file instead of s->hd for quite a while now, so it's time to remove s->hd. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2010-11-04vpc: Implement bdrv_flushKevin Wolf1-8/+13
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-06-22vpc: Use bdrv_(p)write_sync for metadata writesKevin Wolf1-4/+5
Use bdrv_(p)write_sync to ensure metadata integrity in case of a crash. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-06-15vpc: Read/write multiple sectors at onceKevin Wolf1-11/+30
This changes the vpc block driver (for VHD) to read/write multiple sectors at once instead of doing a request for each single sector. Before this, running qemu-iotests for VPC took ages, now it's actually quite reasonable to run it always (down from ~1 hour to 40 seconds for me). Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-05-17block/vpc: Fix conversion from size to disk geometryStefan Weil1-9/+12
The VHD algorithm calculates a disk geometry which is usually smaller than the requested size. QEMU tried to round up but failed for certain sizes: qemu-img create -f vpc disk.vpc 9437184 would create an image with 9435136 bytes (which is too small for qemu-img convert). Instead of hacking the geometry algorithm, the patch increases the number of sectors until we get enough sectors. Cc: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2010-05-03block: Open the underlying image file in generic codeKevin Wolf1-20/+12
Format drivers shouldn't need to bother with things like file names, but rather just get an open BlockDriverState for the underlying protocol. This patch introduces this behaviour for bdrv_open implementation. For protocols which need to access the filename to open their file/device/connection/... a new callback bdrv_file_open is introduced which doesn't get an underlying file opened. For now, also some of the more obscure formats use bdrv_file_open because they open() the file themselves instead of using the block.c functions. They need to be fixed in later patches. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2009-09-09Fix spelling in comment.Stefan Weil1-1/+1
The company which made Virtual PC was Connectix. They use the magic string "conectix" in their disk images. Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-08-24eliminate errors about unused results in block/vpc.cNathan Froyd1-4/+4
These errors come up when compiling with gcc-4.3.3 and some older headers: /scratch/froydnj/qemu.git/block/vpc.c: In function 'vpc_create': /scratch/froydnj/qemu.git/block/vpc.c:514: error: value computed is not used /scratch/froydnj/qemu.git/block/vpc.c:516: error: value computed is not used /scratch/froydnj/qemu.git/block/vpc.c:517: error: value computed is not used /scratch/froydnj/qemu.git/block/vpc.c:566: error: value computed is not used Use memcpy to copy the strings instead of strncpy. Signed-off-by: Nathan Froyd <froydnj@codesourcery.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-06-06qemu-img: Print available options with -o ?Kevin Wolf1-1/+5
This patch adds a small help text to each of the options in the block drivers which can be displayed by using qemu-img create -f fmt -o ? Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2009-05-22Convert all block drivers to new bdrv_createKevin Wolf1-4/+17
Now we can make use of the newly introduced option structures. Instead of having bdrv_create carry more and more parameters (which are format specific in most cases), just pass a option structure as defined by the driver itself. bdrv_create2() contains an emulation of the old interface to simplify the transition. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2009-05-14Move block drivers into their own directoryAnthony Liguori1-0/+606
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>