History | View | Annotate | Download (84.7 kB)
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.
bdrv: Use "Error" for opening images
Add an Error ** parameter to BlockDriver.bdrv_open andBlockDriver.bdrv_file_open to allow more specific error messages.
block: introduce bdrv_get_block_status API
For now, bdrv_get_block_status is just another name for bdrv_is_allocated.The next patches will add more flags.
This also touches all block drivers with a mostly mechanical rename. Thesole exception is cow; because it calls cow_co_is_allocated from the read...
block: return get_block_status data and flags for formats
Reviewed-by: Eric Blake <eblake@redhat.com>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
vvfat: use bdrv_new() to allocate BlockDriverState
we need bdrv_new() to properly initialize BDS, don't allocate memorymanually.
Signed-off-by: Fam Zheng <famz@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...
block: fix vvfat error path for enable_write_target
s->qcow and s->qcow_filename are allocated but not freed on error. Fix thepossible leaks, remove unnecessary check for bdrv_new(), propagate ret code ofbdrv_create() and also the one of enable_write_target()....
block: Remove filename parameter from .bdrv_file_open()
It is unused now in all block drivers.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>
vvfat: Use bdrv_open options instead of filename
block: Add options QDict to bdrv_file_open() prototypes
The new parameter is unused yet.
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>...
Replace remaining gmtime, localtime by gmtime_r, localtime_r
This allows removing of MinGW specific code and improvesreentrancy for POSIX hosts.
[Removed unused ret variable in qemu_get_timedate() to fix warning:vl.c: In function ‘qemu_get_timedate’:vl.c:451:16: error: variable ‘ret’ set but not used [-Werror=unused-but-set-variable]...
misc: move include files to include/qemu/
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
migration: move include files to include/migration/
block: move include files to include/block/
block: Convert open calls to qemu_open
This patch converts all block layer open calls to qemu_open.
Note that this adds the O_CLOEXEC flag to the changed open pathswhen the O_CLOEXEC macro is defined.
Signed-off-by: Corey Bryant <coreyb@linux.vnet.ibm.com>...
block: Convert close calls to qemu_close
This patch converts all block layer close calls, that correspondto qemu_open calls, to qemu_close.
Signed-off-by: Corey Bryant <coreyb@linux.vnet.ibm.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
vvfat: Fix partition table
Unless parameter ":floppy:" is given, vvfat creates a virtual imagewith DOS MBR defining a single partition which holds the FAT filesystem. The size of the virtual image depends on the width of theFAT: 32 MiB (CHS 64, 16, 63) for 12 bit FAT, 504 MiB (CHS 1024, 16,...
vvfat: Do not clobber the user's geometry
vvfat creates a virtual VFAT filesystem with a certain logicalgeometry that depends on its options. It sets the "geometry hint" tothis geometry. It is the only block driver to do this.
The geometry hint is about about physical geometry, and used only by...
block: prevent snapshot mode $TMPDIR symlink attack
In snapshot mode, bdrv_open creates an empty temporary file withoutchecking for mkstemp or close failure, and ignoring the possibilityof a buffer overrun given a surprisingly long $TMPDIR.Change the get_tmp_filename function to return int (not void),...
block: fix snapshot on QED
QED's opaque data includes a pointer back to the BlockDriverState.This breaks when bdrv_append shuffles data between bs_new and bs_top.To avoid this, add a "rebind" function that tells the driver aboutthe new relationship between the BlockDriverState and its opaque....
vvfat: avoid leaking file descriptor in commit_one_file()
Reported-by: Dr David Alan Gilbert <davidagilbert@uk.ibm.com>Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
vvfat: convert to .bdrv_co_is_allocated()
It is trivial to switch from the synchronous .bdrv_is_allocated()interface to .bdrv_co_is_allocated() since vvfat_is_allocated() does notblock.
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
vvfat: Add migration blocker
vvfat caches more or less everything when in writable mode. For migrationto work, it would have to be invalidated. Block migration for now whenin writable mode (default is readonly).
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
vvfat: Fix read-write mode
vvfat used to directly call into the qcow2 block driver instead of using theblock.c wrappers. With the coroutine conversion, this stopped working.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
vvfat: reorganize computation of disk geometry
First determine FAT12/16/32, then compute geometry from that for bothFDD and HDD. For 1.44MB floppies, and 2.88MB floppies using FAT16,change to 1 sector/cluster. The default remains 2.88MB with FAT12and 2 sectors/cluster. Both DOS and mkdosfs by default format a 2.88MB...
vvfat: do not hardcode sector counts in error message
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
vvfat: unify and correct computation of sector count
The sector count is stored in the partition and hence must not include thesectors before its start. At the same time, remove the useless specialcasing for 1.44 MB floppies. This fixes fsck on VVFAT hard disks,...
vvfat: need to use first_sectors_number to distinguish fdd/hdd
This is consistent with what "real" floppies have, so file(1)now actually recognizes the VVFAT image as a 1.44 MB floppy.
vvfat: do not fail if the disk has spare sectors
If the number of "faked sectors" + the number of sectors that arepart of a cluster does not sum up to the total number of sectors,qemu-img convert fails. Read these spare sectors as all zeros.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>...
vvfat: fix out of bounds array_get usage
When reading the address of the first free entry, you cannotuse array_get without first marking all entries as occupied.
This is visible if you change the sectors per cluster on afloppy from 2 to 1.
block: take lock around bdrv_read implementations
This does the first part of the conversion to coroutines, bywrapping bdrv_read implementations to take the mutex.
Drivers that implement bdrv_read rather than bdrv_co_readv canthen benefit from asynchronous operation (at least if the underlying...
block: take lock around bdrv_write implementations
This does the first part of the conversion to coroutines, bywrapping bdrv_write implementations to take the mutex.
Drivers that implement bdrv_write rather than bdrv_co_writev canthen benefit from asynchronous operation (at least if the underlying...
block: add a CoMutex to synchronous read drivers
The big conversion of bdrv_read/write to coroutines caused the twohomonymous callbacks in BlockDriver to become reentrant. It goeslike this:
1) bdrv_read is now called in a coroutine, and calls bdrv_read or...
vvfat: Fix potential buffer overflow
path2[PATH_MAX] can be used for the null termination, so make the array bigenough to allow this.
block/vvfat: Fix potential memory leaks and other memory errors
cppcheck reported memory leaks and mismatched g_malloc() with free()instead of g_free().
Fix these errors.
Cc: Kevin Wolf <kwolf@redhat.com>Signed-off-by: Stefan Weil <weil@mail.berlios.de>...
block/vvfat: Remove unused code
The unused code was detected using cppcheck.
Cc: Kevin Wolf <kwolf@redhat.com>Signed-off-by: Stefan Weil <weil@mail.berlios.de>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Remove blanks before \n in output strings
Those blanks violate the coding conventions, seescripts/checkpatch.pl.
Blanks missing after colons in the changed lines were added.
This patch does not try to fix tabs, long lines and otherproblems in the changed lines, therefore checkpatch.pl reports...
Use new macro QEMU_PACKED for packed structures
Most changes were made using these commands:
git grep -la '__attribute__((packed))'|xargs perl -pi -e 's/__attribute__\(\(packed\)\)/QEMU_PACKED/'git grep -la '__attribute__ ((packed))'|xargs perl -pi -e 's/__attribute__ \(\(packed\)\)/QEMU_PACKED/'...
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>
vvfat: fix a file descriptor leak
Fix a file descriptor leak, reported by cppcheck:[/src/qemu/block/vvfat.c:759]: (error) Resource leak: dir
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
block/vvfat: Fix compiler warning in debug code
Fix this compiler warning:./block/vvfat.c:2285: error: comparison of unsigned expression >= 0 is always true
Cc: Blue Swirl <blauwirbel@gmail.com>Cc: Kevin Wolf <kwolf@redhat.com>Signed-off-by: Stefan Weil <weil@mail.berlios.de>...
vvfat: Fix segfault on write to read-only disk
vvfat tries to set the readonly flag in its open function, but nowadaysthis is overwritted with the readonly=... command line option. Check inbdrv_write if the vvfat was opened read-only and return an error in this...
vvfat: Fix double free for opening the image rw
Allocation and deallocation of bs->opaque is not in the control of ablock driver. Therefore it should not set bs->opaque to a data structureused by another bs, or closing the image will lead to a double free....
vvfat: Use cache=unsafe
The qcow file used for write support in vvfat is a temporary file,so we can use cache=unsafe there. Without this, write support is justtoo slow to be of any use.
Signed-off-by: Kevin Wolf <mail@kevin-wolf.de>
vvfat: fat_chksum(): fix access above array bounds
Signed-off-by: Loïc Minier <loic.minier@linaro.org>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
vvfat: Fix compilation with DEBUG defined
gcc does not like passing a NULL where an int value is expected:
block/vvfat.c: In function ‘checkpoint’:block/vvfat.c:2868: error: passing argument 2 of ‘remove_mapping’ makes integer from pointer without a cast...
vvfat: More build fixes with DEBUG
Casting a pointer to an int doesn't work on 64 bit platforms. Use the %p printfconversion specifier instead.
block: Open the underlying image file in generic code
Format drivers shouldn't need to bother with things like file names, but ratherjust get an open BlockDriverState for the underlying protocol. This patchintroduces this behaviour for bdrv_open implementation. For protocols which...
Fix dead initialization, spotted by clang analyzer
Fix clang warnings:/src/qemu/block/vvfat.c:1102:9: warning: Value stored to 'index3' during its initialization is never read int index3=index1+1;/src/qemu/cmd.c:290:15: warning: Value stored to 'p' during its initialization is never read...
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...
Replace assert(0) with abort() or cpu_abort()
When building with -DNDEBUG, assert(0) will not stop executionso it must not be used for abnormal termination.
Use cpu_abort() when in CPU context, abort() otherwise.
Fix build with -DNDEBUG in CFLAGS
don't dereference NULL after failed strdup
Most of these are obvious NULL-deref bug fixes, for example,the ones in these files:
block/curl.c net.c slirp/misc.c
and the first one in block/vvfat.c.The others in block/vvfat.c may not lead to an immediate segfault, but I...
Ask for read-write permissions when opening files
Found some places that seems needs this explicitly, now thatread-write is not the default.
Signed-off-by: Naphtali Sprei <nsprei@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
block/vvfat.c: fix warnings with _FORTIFY_SOURCE
CC block/vvfat.occ1: warnings being treated as errorsblock/vvfat.c: In function 'commit_one_file':block/vvfat.c:2259: error: ignoring return value of 'ftruncate', declared with attribute warn_unused_result...
Revert "Get rid of _t suffix"
In the very least, a change like this requires discussion on the list.
The naming convention is goofy and it causes a massive merge problem. Somethinglike this must be presented on the list first so people can provide input...
Get rid of _t suffix
Some not so obvious bits, slirp and Xen were left alone for the timebeing.
Signed-off-by: malc <av1474@comtv.ru>
vvfat: fix coding style nit
Put space between = and & when taking a pointer,to avoid confusion with old-style "&=".
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
vvfat: one more missing BlockDriver C99 initializer conversion
Signed-off-by: Christoph Hellwig <hch@lst.de>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Drop bdrv_create2
This patch converts the remaining users of bdrv_create2 to bdrv_create andremoves the now unused function.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Convert all block drivers to new bdrv_create
Now we can make use of the newly introduced option structures. Instead ofhaving bdrv_create carry more and more parameters (which are format specific inmost cases), just pass a option structure as defined by the driver itself....
Move block drivers into their own directory