History | View | Annotate | Download (67.3 kB)
block: Add bdrv_(p)write_sync
Add new functions that write and flush the written data to disk immediately.This is what needs to be used for image format metadata to maintain integrityfor cache=... modes that don't use O_DSYNC. (Actually, we only need barriers,...
block: fix a warning and possible truncation
Fix a warning from OpenBSD gcc (3.3.5 (propolice)):/src/qemu/block.c: In function `bdrv_info_stats_bs':/src/qemu/block.c:1548: warning: long long int format, long unsignedint arg (arg 6)
There may be also truncation effects....
block: Move error actions from DriveInfo to BlockDriverState
That's where they belong semantically (block device host part), eventhough the actions are actually executed by guest device code.
Signed-off-by: Markus Armbruster <armbru@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: Decouple block device "commit all" from DriveInfo
do_commit() and mux_proc_byte() iterate over the list of drivesdefined with drive_init(). This misses host block devices defined byother means. Such means don't exist now, but will be introduced later...
block: New bdrv_next()
This is a more flexible alternative to bdrv_iterate().
savevm: Really verify if a drive supports snapshots
Both bdrv_can_snapshot() and bdrv_has_snapshot() does not work as advertized.
First issue: Their names implies different porpouses, but they do the same thingand have exactly the same code. Maybe copied and pasted and forgotten?...
block: Assume raw for drives without media
qemu -cdrom /dev/cdrom with an empty CD-ROM drive doesn't work any more becausewe try to guess the format and when this fails (because there is no medium) weexit with an error message.
This patch should restore the old behaviour by assuming raw format for such...
close all the block drivers before the qemu process exits
This patch calls the close handler of the block driver before the qemuprocess exits.
This is necessary because the sheepdog block driver releases the lockof VM images in the close handler.
Signed-off-by: MORITA Kazutaka <morita.kazutaka@lab.ntt.co.jp>...
block: call the snapshot handlers of the protocol drivers
When snapshot handlers are not defined in the format driver, it isbetter to call the ones of the protocol driver. This enables us toimplement snapshot support in the protocol driver.
We need to call bdrv_close() and bdrv_open() handlers of the format...
Cleanup: bdrv_open() no need to shift total_size just to shift back.
In bdrv_open() there is no need to shift total_size >> 9 just tomultiply it by 512 again just a few lines later, since this is theonly place the variable is used.
Mask with BDRV_SECTOR_MASK to protect against case where we are...
Cleanup: Be consistent and use BDRV_SECTOR_SIZE instead of 512
Clean up block.c and use BDRV_SECTOR_SIZE rather than hard codednumbers (512) when referring to sector size throughout the code.
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Merge remote branch 'kwolf/for-anthony' into staging
Monitor: Drop QMP documentation from code
Previous commit added QMP documentation to the qemu-monitor.hxfile, it's is a copy of this information.
While it's good to keep it near code, maintaining two copies ofthe same information is too hard and has little benefit as we...
block: Add missing bdrv_delete() for SG_IO BlockDriver in find_image_format()
This patch adds a missing bdrv_delete() call in find_image_format() so that aSG_IO BlockDriver properly releases the temporary BlockDriverState *bs createdfrom bdrv_file_open()...
block: Fix multiwrite with overlapping requests
With overlapping requests, the total number of sectors is smaller than the sumof the nb_sectors of both requests.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
add support for protocol driver create_options
This patch enables protocol drivers to use their create options whichare not supported by the format. For example, protcol drivers can usea backing_file option with raw format.
Add cache=unsafe parameter to -drive
Usually the guest can tell the host to flush data to disk. In some cases wedon't want to flush though, but try to keep everything in cache.
So let's add a new cache value to -drive that allows us to set the cachepolicy to most aggressive, disabling flushes. We call this mode "unsafe",...
block: fix sector comparism in multiwrite_req_compare
The difference between the start sectors of two requests can be largerthan the size of the "int" type, which can lead to a not correctlysorted multiwrite array and thus spurious I/O errors and filesystem...
block: Make find_image_format() return 'raw' BlockDriver for SG_IO devices
This patch adds a special BlockDriverState->sg check in block.c:find_image_format()after bdrv_file_open() -> block/raw-posix.c:hdev_open() has been called to determineif we are dealing with a Linux host scsi-generic device....
block: Add SG_IO device check in refresh_total_sectors()
This patch adds a special case check for scsi-generic devices inrefresh_total_sectors() to skip the subsequent BlockDriver->bdrv_getlength()that will be returning -ESPIPE from block/raw-posic.c:raw_getlength() for...
block: Avoid unchecked casts for AIOCBs
Use container_of for one direction and &acb->common for the other one.
block: Fix protocol detection for Windows devices
We can't assume the file protocol for Windows devices, they need the samedetection as other files for which an explicit protocol is not specified.
block: Fix bdrv_commit
When reopening the image, don't guess the driver, but use the same driver aswas used before. This is important if the format=... option was used for thatimage.
use qemu_free() instead of free()
There is a call to free() where qemu_free() should instead be used.
Signed-off-by: Bruce Rogers <brogers@novell.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Fix docs for block stats monitor command
The 'parent' field in the 'query-blockstats' monitor command ispart of the top level block device QDict, not part of the 2ndlevel 'stats' QDict.
block: Remove special case for vvfat
The special case doesn't really us buy anything. Without it vvfat works moreconsistently as a protocol. We get raw on top of vvfat now, which works justas well as using vvfat directly.
block: Cache total_sectors to reduce bdrv_getlength calls
The BlockDriver bdrv_getlength function is called from the I/O code pathwhen checking that the request falls within the device. Unfortunatelythis involves an lseek system call in the raw protocol; every read or...
block: Add wr_highest_sector blockstat
This adds the wr_highest_sector blockstat which implements what is generallyknown as the high watermark. It is the highest offset of a sector written tothe respective BlockDriverState since it has been opened.
The query-blockstat QMP command is extended to add this value to the result,...
block: Release allocated options after bdrv_open
They aren't used afterwards nor supposed to be stored by a bdrv_createhandler.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: Set backing_hd to NULL after deleting it
It is safer to set backing_hd to NULL after deleting it so that any useafter deletion is obvious during development. Happy segfaulting!
This patch should be applied after Kevin Wolf's "vmdk: Convert tobdrv_open" so that vmdk does not segfault on close....
block: separate raw images from the file protocol
We're running into various problems because the "raw" file access, whichis used internally by the various image formats is entangled with the"raw" image format, which maps the VM view 1:1 to a file system....
block: Split bdrv_open
bdrv_open contains quite some code that is only useful for opening images (asopposed to opening files by a protocol), for example snapshots.
This patch splits the code so that we have bdrv_open_file() for files (usesprotocols), bdrv_open() for images (uses format drivers) and bdrv_open_common()...
block: Avoid forward declaration of bdrv_open_common
Move bdrv_open_common so it's defined before its callers and remove the forwarddeclaration.
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...
block: bdrv_has_zero_init
This fixes the problem that qemu-img's use of no_zero_init only considered theno_zero_init flag of the format driver, but not of the underlying protocols.
Between the raw/file split and this fix, converting to host devices is broken....
block: Free iovec arrays allocated by multiwrite_merge()
A new iovec array is allocated when creating a merged write request.This patch ensures that the iovec array is deleted in addition to itsqiov owner.
Reported-by: Leszek Urbanski <tygrys@moo.pl>Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>...
block: Do not export bdrv_first
The bdrv_first linked list of BlockDriverStates is currently extern sothat block migration can iterate the list. However, since there isalready a bdrv_iterate() function there is no need to expose bdrv_first.
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>...
block: Convert bdrv_first to QTAILQ
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: Convert first_drv to QLIST
blkdebug: Add events and rules
Block drivers can trigger a blkdebug event whenever they reach a place where itcould be useful to inject an error for testing/debugging purposes.
Rules are read from a blkdebug config file and describe which action is taken...
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...
block: get rid of the BDRV_O_FILE flag
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 usingfind_protocol instead of all image formats and host drivers. We can easily...
block: Fix multiwrite memory leak in error case
Previously multiwrite_user_cb was never called if a request in the multiwritebatch failed right away because it did set mcb->error immediately. Make it lookmore like a normal callback to fix this.
Reported-by: Juan Quintela <quintela@redhat.com>...
block: Fix error code in multiwrite for immediate failures
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
block: Fix multiwrite error handling
When two requests of the same multiwrite batch fail, the callback of allrequests in that batch were called twice. This could have any kind of nastyeffects, in my case it lead to use after free and eventually a segfault....
Wrong error message in block_passwd command
Signed-off-by: Shahar Havivi <shaharh@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
block: more read-only changes, related to backing files
Open backing file read-only where possibleUpgrade backing file to read-write during commit, back to read-only after commit If upgrade fail, back to read-only. If also fail, "disconnect" the drive....
Monitor: remove unneeded checks
It's not needed to check the return of qobject_from_jsonf()anymore, as an assert() has been added there.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
block: BLOCK_IO_ERROR QMP event
This commit introduces the bdrv_mon_event() function, whichshould be called by block subsystems (eg. IDE) when a I/Oerror occurs, so that an QMP event is emitted.
The following information is currently provided in the event:...
block: saner flags filtering in bdrv_open2
Clean up the current mess about figuring out which flags to pass to thedriver. BDRV_O_FILE, BDRV_O_SNAPSHOT and BDRV_O_NO_BACKING are flagsonly used by the block layer internally so filter them out directly.Previously BDRV_O_NO_BACKING could accidentally be passed to the drivers,...
Count dirty blocks and expose an API to get dirty count
This will manage dirty counter for each device and will allow to get thedirty counter from above.
Signed-off-by: Liran Schour <lirans@il.ibm.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
block: avoid creating too large iovecs in multiwrite_merge
If we go over the maximum number of iovecs support by syscall we getback EINVAL from the kernel which translate to I/O errors for the guest.
Add a MAX_IOV defintion for platforms that don't have it. For now we use...
win32: pair qemu_memalign() with qemu_vfree()
Win32 suffers from a very big memory leak when dealing with SCSI devices.Each read/write request allocates memory with qemu_memalign (ieVirtualAlloc) but frees it with qemu_free (ie free).Pair all qemu_memalign() calls with qemu_vfree() to prevent such leaks....
block: clean up bdrv_open2 structure a bit
Check the whitelist as early as possible instead of continuing thesetup, and move all the error handling code to the end of thefunction.
Signed-off-by: Christoph Hellwig <hch@lst.de>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
No need anymoe for bdrv_set_read_only
Signed-off-by: Naphtali Sprei <nsprei@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
block: Return original error codes in bdrv_pread/write
Don't assume -EIO but return the real error.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Revert "block: prevent multiwrite_merge from creating too large iovecs"
This reverts commit 0076bc0c1d93adcbc7f1af184e04902cf37e9ab8.
Kevin Wolf pointed out that this breaks the mingw32 build.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
block: prevent multiwrite_merge from creating too large iovecs
block: fix cache flushing in bdrv_commit
Clean-up a little bit the RW related bits of BDRV_O_FLAGS. BDRV_O_RDONLY 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,...
Disable fall-back to read-only when cannot open drive's file for read-write
block: Introduce BDRV_O_NO_BACKING
If an image references a backing file that doesn't exist, qemu-img info failsto open this image. Exactly in this case the info would be valuable, though:the user might want to find out which file is missing.
This patch introduces a BDRV_O_NO_BACKING flag to ignore the backing file when...
block: Add bdrv_change_backing_file
Introduce the functions needed to change the backing file of an image. Thefunction is implemented for qcow2.
block: flush backing_hd in the right place
The backing device is only modified from bdrv_commit. So instead offlushing it every time bdrv_flush is called for the front-end deviceonly flush it after we're written data to it in bdrv_commit.
Signed-off-by: Christoph Hellwig <hch@lst.de>...
block.c: fix warning with _FORTIFY_SOURCE
CC block.occ1: warnings being treated as errorsblock.c: In function 'bdrv_open2':block.c:400: error: ignoring return value of 'realpath', declared with attribute warn_unused_result
Signed-off-by: Kirill A. Shutemov <kirill@shutemov.name>...
block: Convert bdrv_info() to QObject
Each block device information is stored in a QDict and thereturned QObject is a QList of all devices.
This commit should not change user output.
block: Convert bdrv_info_stats() to QObject
Each device statistic information is stored in a QDict andthe returned QObject is a QList of all devices.
block migration: Fix coding style and whitespaces
No functional changes.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
block migration: Rework constants API
Instead of duplicating the definition of constants or introducingtrivial retrieval functions move the SECTOR constants into the publicblock API. This also obsoletes sector_per_block in BlkMigState.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>...
block migration: Cleanup dirty tracking code
This switches the dirty bitmap to a true bitmap, reducing its footprint(specifically in caches). It moreover fixes off-by-one bugs inset_dirty_bitmap (nb_sectors+1 were marked) and bdrv_get_dirty (limitcheck allowed one sector behind end of drive). And is drops redundant...
Expose a mechanism to trace block writes
To support live migration without shared storage we need to be able to tracewrites to disk while migrating. This Patch expose dirty block tracking perdevice to be polled from upper layer.
Changes from v4:- Register dirty tracking for each block device....
Configurable block format whitelist
We have code for a quite a few block formats. While I trust that allof these formats are useful at least for some people in somecircumstances, some of them are of a kind that friends don't letfriends use in production....
Added readonly flag to -drive command
This is a slightly revised patch for adding readonly flag to the -drive command.Even though this patch is "stand-alone", it assumes a previous related patch (in Anthony staging tree), that passesthe readonly attribute of the drive to the guest OS, applied first....
block: Use new AsyncContext for bdrv_read/write emulation
bdrv_read/write emulation is used as the perfect example why we need somethinglike AsyncContexts. So maybe they better start using it.
Fix sys-queue.h conflict for good
Problem: Our file sys-queue.h is a copy of the BSD file, but there aresome additions and it's not entirely compatible. Because of that, there havebeen conflicts with system headers on BSD systems. Some hacks have beenintroduced in the commits 15cc9235840a22c289edbe064a9b3c19c5f49896,...
block: add enable_write_cache flag
Add a enable_write_cache flag in the block driver state, and use it todecide if we claim to have a volatile write cache that needs controlledflushing from the guest. The flag is off if cache=writethrough isdefined because O_DSYNC guarantees that every write goes to stable...
block: add aio_flush operation
Instead stalling the VCPU while serving a cache flush try to do itasynchronously. Use our good old helper thread pool to issue anasynchronous fdatasync for raw-posix. Note that while Linux AIOimplements a fdatasync operation it is not useful for us because...
Add bdrv_aio_multiwrite
One performance problem of qcow2 during the initial image growth aresequential writes that are not cluster aligned. In this case, when a firstrequests requires to allocate a new cluster but writes only to the firstcouple of sectors in that cluster, the rest of the cluster is zeroed - just...
raw-posix: add Linux native AIO support
Now that do have a nicer interface to work against we can add Linux nativeAIO support. It's an extremly thing layer just setting up an iocb forthe io_submit system call in the submission path, and registering an...
rename HOST_BSD to CONFIG_BSD
Signed-off-by: Juan Quintela <quintela@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
replace bdrv_{get, put}_buffer with bdrv_{load, save}_vmstate
The VM state offset is a concept internal to the image format. Replacethe old bdrv_{get,put}_buffer method that require an index into theimage file that is constructed from the VM state offset and an offset...
block: Clean up after deleting BHs
Commit 6a7ad299 ("Call qemu_bh_delete at bdrv_aio_bh_cb") deletes emulatedaio bottom halves to prevent endless accumulation. However, it leaves astale ->bh pointer, which is then waited on when the aio is reused.
Zeroing the pointer fixes the issue, allowing vmdk format images to be used....
Revert "support colon in filenames"
This reverts commit 707c0dbc97cddfe8d2441b8259c6c526d99f2dd8.
Fix missing strnlen problems
Fix missing strnlen (a GNU extension) problems by using qemu_strnlenused for user emulators also for system emulators.
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
support colon in filenames
Problem: It is impossible to feed filenames with the character colon becauseqemu interprets such names as a protocol. For example filename scsi:0, isinterpreted as a protocol by name "scsi".
This patch allows user to espace colon characters. For example the above...
Prevent CD-ROM media eject while device is locked
Section 10.8.25 ("START/STOP UNIT Command") of SFF-8020i states thatif the device is locked we should refuse to eject if the device islocked.
ASC_MEDIA_REMOVAL_PREVENTED is the appropriate return in this case....
Call qemu_bh_delete at bdrv_aio_bh_cb.
Also replave qemu_bh_cancel with qemu_bh_delete in bdrv_aio_cancel_em. Otherwise the bh will live forever in the bh list.
Signed-off-by: Dor Laor <dor@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
block: add bdrv_probe_device method
Add a bdrv_probe_device method to all BlockDriver instances implementinghost devices to move matching of host device types into the actual drivers.For now we keep exacly the old matching behaviour based on the devices names,...
raw-posix: split hdev drivers
Instead of declaring one BlockDriver for all host devices declared onefor each type: a generic one for normal disk devices, a Linux floppydriver and a CDROM driver for Linux and FreeBSD. This gets rid of a lotof messy ifdefs and switching based on the type in the various removal...
fully split aio_pool from BlockDriver
Now that we have a separate aio pool structure we can remove thoseaio pool details from BlockDriver.
Every driver supporting AIO now needs to declare a static AIOPoolwith the aiocb size and the cancellation method. This cleans up the...
Drop bdrv_create2
This patch converts the remaining users of bdrv_create2 to bdrv_create andremoves the now unused function.
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....
Fix segv when passing an unknown protocol
Convert block infrastructure to use new module init functionality
Improve block range checks
This patch makes the range checks for block requests more strict: It fixes apotential integer overflow and checks for negative offsets. Also, it adds thecheck for compressed writes.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>...
implement qemu_blockalign (Stefano Stabellini)
this patch adds a buffer_alignment field to BlockDriverState andimplements a qemu_blockalign function that uses that field to allocate amemory aligned buffer to be used by the block driver.buffer_alignment is initialized to 512 but each block driver can set...
Introduce bdrv_check (Kevin Wolf)
From: Kevin Wolf <kwolf@redhat.com>
Introduce a new bdrv_check function pointer for block drivers. Modify qcow2 toreturn an error status in check_refcounts(), so it can implement bdrv_check.
Fix OpenSolaris gcc4 warnings: iovec type mismatches, missing 'static'
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@7103 c046a42c-6fe2-441c-8c8c-71466251a162
native preadv/pwritev support (Christoph Hellwig)
This ties up the preadv/pwritev syscalls to qemu if they are declared inunistd.h. This is the case currently on at least NetBSD and OpenBSD andwill hopefully soon be the case on Linux.
Thanks to Blue Swirl and Gerd Hoffmann for the configure autodetection...
push down vector linearization to posix-aio-compat.c (Christoph Hellwig)
Make all AIO requests vectored and defer linearization until the actualI/O thread. This prepares for using native preadv/pwritev.
Also enables asynchronous direct I/O by handling that case in the I/O thread....