History | View | Annotate | Download (15.2 kB)
block: iostatus: Drop BDRV_IOS_INVAL
A future commit will convert bdrv_info() to the QAPI and it won'tprovide IOS_INVAL.
Luckily all we have to do is to add a new 'iostatus_enabled'member to BlockDriverState and use it instead.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
block: Rename the BlockIOStatus enum values
The biggest change is to rename its prefix from BDRV_IOS toBLOCK_DEVICE_IO_STATUS.
Next commit will convert the query-block command to the QAPIand that's how the enumeration is going to be generated.
qapi: Convert query-block
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
block: unify flush implementations
Add coroutine support for flush and apply the same emulation thatwe already do for read/write. bdrv_aio_flush is simplified to alwaysgo through a coroutine.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: add bdrv_co_discard and bdrv_aio_discard support
This similarly adds support for coroutine and asynchronous discard.
block: Keep track of devices' I/O status
This commit adds support to the BlockDriverState type to keep trackof devices' I/O status.
There are three possible status: BDRV_IOS_OK (no error), BDRV_IOS_ENOSPC(no space error) and BDRV_IOS_FAILED (any other error). The distinction...
block: New bdrv_set_buffer_alignment()
Device models should be able to set it without an unclean include ofblock_int.h.
Signed-off-by: Markus Armbruster <armbru@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: New change_media_cb() parameter load
To let device models distinguish between eject and load.
block: Clean up remaining users of "removable"
BlockDriverState member removable is a confused mess. It is true whenan ide-cd, scsi-cd or floppy qdev is attached, or when theBlockDriverState was created with -drive if={floppy,sd} or -driveif={ide,scsi,xen,none},media=cdrom ("created removable"), except when...
block: Drop BlockDriverState member removable
It's a confused mess (see previous commit). No users remain.
block: Show whether the virtual tray is open in info block
Need to ask the device, so this requires new BlockDevOps memberis_tray_open().
block: Move BlockConf & friends from block_int.h to block.h
It's convenience stuff for block device models, so block.h isn't theideal home either, but better than block_int.h.
Permits moving some #include "block_int.h" from device model .h into.c.
Signed-off-by: Markus Armbruster <armbru@redhat.com>...
block: Leave enforcing tray lock to device models
The device model knows best when to accept the guest's eject command.No need to detour through the block layer.
bdrv_eject() can't fail anymore. Make it void.
block: Drop medium lock tracking, ask device models instead
Requires new BlockDevOps member is_medium_locked(). Implement for IDEand SCSI CD-ROMs.
block: Rename bdrv_set_locked() to bdrv_lock_medium()
While there, make the locked parameter bool.
block: Declare qemu_blockalign() in block.h, not block_int.h
Device models should be able to use it without an unclean include ofblock_int.h.
block: Attach non-qdev devices as well
For now, this just protects against programming errors like having thesame drive back multiple non-qdev devices, or untimely bdrv_delete().Later commits will add other interesting uses.
While there, rename BlockDriverState member peer to dev, bdrv_attach()...
block: Generalize change_cb() to BlockDevOps
So we can more easily add device model callbacks.
block: Split change_cb() into change_media_cb(), resize_cb()
Multiplexing callbacks complicates matters needlessly.
block: latency accounting
Account the total latency for read/write/flush requests. This allowsmanagement tools to average it based on a snapshot of the nr opscounters and allow checking for SLAs or provide statistics.
Signed-off-by: Christoph Hellwig <hch@lst.de>...
block: explicit I/O accounting
Decouple the I/O accounting from bdrv_aio_readv/writev/flush andmake the hardware models call directly into the accounting helpers.
This means: - we do not count internal requests from image formats in addition to guest originating I/O...
block: parse cache mode flags in a single place
This patch introduces bdrv_parse_cache_flags() which sets open flagsgiven a cache mode. Previously this was duplicated in blockdev.c andqemu-img.c.
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>...
block: Add bdrv_co_readv/writev
Add new block driver callbacks bdrv_co_readv/writev, which work on aQEMUIOVector like bdrv_aio_*, but don't need a callback. The function may onlybe called inside a coroutine, so a block driver implementing this interface can...
block: Removed unused function bdrv_write_sync
Signed-off-by: Frediano Ziglio <freddy77@gmail.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: add bdrv_get_allocated_file_size() operation
qemu-img.c wants to count allocated file size of image. Previously itcounts a single bs->file by 'stat' or Window API. As VMDK introducesmultiple file support, the operation becomes format specific with...
Replaced tabs with spaces in block.h and block_int.h
Signed-off-by: Devin Nakamura <devin122@gmail.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
block: Remove type hint, it's guest matter, doesn't belong here
No users of bdrv_get_type_hint() left. bdrv_set_type_hint() can makethe media removable by side effect. Make that explicit.
Do not delete BlockDriverState when deleting the drive
When removing a drive from the host-side via drive_del we currently havethe following path:
drive_delqemu_aio_flush()bdrv_close() // zaps bs->drv, which makes any subsequent I/O get // dropped. Works as designed...
fdc: move floppy geometry guessing to block.c
Other geometry guessing functions already reside in block.c.
Remove some unused or debugging only fields.
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
Add flag to indicate external users to block device
Certain operations such as drive_del or resize cannot be performedwhile external users (eg. block migration) reference the block device.
Add a flag to indicate that.
Signed-off-by: Marcelo Tosatti <mtosatti@redhat.com>...
block: tell drivers about an image resize
Extend the change_cb callback with a reason argument, and use itto tell drivers about size changes.
Signed-off-by: Christoph Hellwig <hch@lst.de>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
qemu-img.c: Re-factor img_create()
This patch re-factors img_create() moving the code doing the actualwork into block.c where it can be shared with QEMU. This is needed tobe able to create images from QEMU to be used for live snapshots.
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>...
block: add discard support
Add a new bdrv_discard method to free blocks in a mapping image, and a newdrive property to set the granularity for these discard. If no discardgranularity support is set discard support is disabled.
block: Allow bdrv_flush to return errors
This changes bdrv_flush to return 0 on success and -errno in case of failure.It's a requirement for implementing proper error handle in users of bdrv_flush.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
Copy snapshots out of QCOW2 disk
In order to backup snapshots, created from QCOW2 iamge, we want to copy snapshots out of QCOW2 disk to a seperate storage.The following patch adds a new option in "qemu-img": qemu-img convert -f qcow2 -O qcow2 -s snapshot_name src_img bck_img....
block: Fix BDRV_O_CACHE_MASK
BDRV_O_CACHE_MASK should have been extended when cache=unsafe introduced a newflag BDRV_O_NO_FLUSH. There are currently no users that would change theirbehaviour because of this, but let's clean it up before things break.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Fix -snapshot deleting images on disk change
Block device change command did not copy BDRV_O_SNAPSHOT flag. Thusthe new image did not have this flag and the file got deleted duringopening.
Fix by copying BDRV_O_SNAPSHOT flag.
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>...
qemu-img check: Distinguish different kinds of errors
People think that their images are corrupted when in fact there are just someleaked clusters. Differentiating several error cases should make the messagesmore comprehensible.
block: Catch attempt to attach multiple devices to a blockdev
For instance, -device scsi-disk,drive=foo -device scsi-disk,drive=foohappily creates two SCSI disks connected to the same block device.It's all downhill from there.
Device usb-storage deliberately attaches twice to the same blockdev,...
savevm: Survive hot-unplug of snapshot device
savevm.c keeps a pointer to the snapshot block device. If you manageto get that device deleted, the pointer dangles, and the next snapshotoperation will crash & burn. Unplugging a guest device that uses it...
block: Fix virtual media change for if=none
BlockDriverState member removable controls whether virtual mediachange (monitor commands change, eject) is allowed. It is set whenthe "type hint" is BDRV_TYPE_CDROM or BDRV_TYPE_FLOPPY.
The type hint is only set by drive_init(). It sets BDRV_TYPE_FLOPPY...
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: 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.
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?...
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.h: Make BDRV_SECTOR_SIZE 64 bit safe
C defaults to int, so make definition of BDRV_SECTOR_SIZE 64 bitsafe as it and BDRV_SECTOR_MASK may be used against 64 bit addresses.
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>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: Remove semicolon in BDRV_SECTOR_MASK macro
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
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: 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.h: bdrv_create2 doesn't exist any more
The bdrv_create2 implementation has disappeared long ago. Remove itsprototype from the header file, too.
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...
qcow2: Trigger blkdebug events
This adds blkdebug events to qcow2 to allow injecting I/O errors in specificplaces.
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: 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:...
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: kill BDRV_O_CREAT
The BDRV_O_CREAT option is unused inside qemu and partially duplicatesthe bdrv_create method. Remove it, and the -C option to qemu-io whichisn't used in qemu-iotests anyway.
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>
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,...
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.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
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.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
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: Increase dirty chunk size to 1M
4K is too small for efficiently saving and restoring multi-GB blockdevices.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
block migration: Fix coding style and whitespaces
No functional changes.
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>...
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: 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...
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...
Revert "support colon in filenames"
This reverts commit 707c0dbc97cddfe8d2441b8259c6c526d99f2dd8.
Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
qcow2: Make cache=writethrough default
The performance of qcow2 has improved meanwhile, so we don't need tospecial-case it any more. Switch the default to write-through cachinglike all other block drivers.
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....
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....
Convert block infrastructure to use new module init functionality
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.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>...
remove bdrv_aio_read/bdrv_aio_write (Christoph Hellwig)
Always use the vectored APIs to reduce code churn once we switch the BlockDriverAPI to be vectored.
Signed-off-by: Christoph Hellwig <hch@lst.de>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>...
Fix savevm after BDRV_FILE size enforcement
We now enforce that you cannot write beyond the end of a non-growable file.qcow2 files are not growable but we rely on them being growable to dosavevm/loadvm. Temporarily allow them to be growable by introducing a new...
block: support known backing format for image create and open (Uri Lublin)
Added a backing_format field to BlockDriverState.Added bdrv_create2 and drv->bdrv_create2 to create an image witha known backing file format.Upon bdrv_open2 if backing format is known use it, instead of...
new scsi-generic abstraction, use SG_IO (Christoph Hellwig)
Okay, I started looking into how to handle scsi-generic I/O in thenew world order.
I think the best is to use the SG_IO ioctl instead of the read/writeinterface as that allows us to support scsi passthrough on disk/cdrom...
Add specialized block driver scsi generic API (Avi Kivity)
When a scsi device is backed by a scsi generic device instead of anordinary host block device, the block API is abused in a couple of annoyingways:
- nb_sectors is negative, and specifies a byte count instead of a sector count...
Revert r6405
This series is broken by design as it requires expensive IO operations atopen time causing very long delays when starting a virtual machine for thefirst time.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6815 c046a42c-6fe2-441c-8c8c-71466251a162
Revert r6407
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6813 c046a42c-6fe2-441c-8c8c-71466251a162
monitor: Rework API (Jan Kiszka)
Refactor the monitor API and prepare it for decoupled terminals:term_print functions are renamed to monitor_* and all monitor servicesgain a new parameter (mon) that will once refer to the monitor instancethe output is supposed to appear on. However, the argument remains...
monitor: Rework early disk password inquiry (Jan Kiszka)
Reading the passwords for encrypted hard disks during early startup isbroken (I guess for quiet a while now): - No monitor terminal is ready for input at this point - Forcing all mux'ed terminals into monitor mode can confuse other...
block: Introduce bdrv_get_encrypted_filename (Jan Kiszka)
Introduce bdrv_get_encrypted_filename service to allow more informativepassword prompting.
Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>...
block: Improve bdrv_iterate (Jan Kiszka)
Make bdrv_iterate more useful by passing the BlockDriverState to theiterator instead of the device name.
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6703 c046a42c-6fe2-441c-8c8c-71466251a162
qcow2 format: keep 'num_free_bytes', and show it upon 'info blockstats' (Uri Lublin)
'num_free_bytes' is the number of non-allocated bytes below highest-allocation.It's useful, together with the highest-allocation, to figure out howfragmented the image is, and how likely it will run out-of-space soon....
block-qcow2: export highest_allocated through BlockDriverInfo and get_info() (Uri Lublin)
Signed-off-by: Uri Lublin <uril@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
git-svn-id: svn://svn.savannah.nongnu.org/qemu/trunk@6405 c046a42c-6fe2-441c-8c8c-71466251a162
Vectored block device API (Avi Kivity)
Most devices that are capable of DMA are also capable of scatter-gather.With the memory mapping API, this means that the device code needs to beable to access discontiguous host memory regions.
For block devices, this translates to vectored I/O. This patch implements...
Use writeback caching by default with qcow2
qcow2 writes a cluster reference count on every cluster update. This causesperformance to crater when using anything but cache=writeback. This is mostnoticeable when using savevm. Right now, qcow2 isn't a reliable format...