History | View | Annotate | Download (19.2 kB)
virtio-blk: Return UNSUPP for unknown request types
Currently, all unknown requests are treated as VIRTIO_BLK_T_IN
Signed-off-by: Alexey Zaytsev <alexey.zaytsev@gmail.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
virtio-blk: add x-data-plane=on|off performance feature
The virtio-blk-data-plane feature is easy to integrate intohw/virtio-blk.c. The data plane can be started and stopped similar tovhost-net.
Users can take advantage of the virtio-blk-data-plane feature using the...
virtio-blk: restore VirtIOBlkConf->config_wce flag
Two slightly different versions of a patch to conditionally setVIRTIO_BLK_F_CONFIG_WCE through the "config-wce" qdev property have beenapplied (ea776abca and eec7f96c2). David Gibson<david@gibson.dropbear.id.au> noticed that the "config-wce"...
softmmu: move include files to include/sysemu/
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
misc: move include files to include/qemu/
iostatus: change is_read to a bool
Do this while we are touching this part of the code, before introducingmore uses of "int is_read".
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Reviewed-by: Eric Blake <eblake@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
iostatus: reorganize io error code
Move the common part of IDE/SCSI/virtio error handling to the blocklayer. The new function bdrv_error_action subsumes all three ofbdrv_emit_qmp_error_event, vm_stop, bdrv_iostatus_set_err.
The same scheme will be used for errors in block jobs....
iostatus: move BlockdevOnError declaration to QAPI
This will let block-stream reuse the enum. Places that used the enumsare renamed accordingly.
iostatus: rename BlockErrorAction, BlockQMPEventAction
We want to remove knowledge of BLOCK_ERR_STOP_ENOSPC from drivers;drivers should only be told whether to stop/report/ignore the error.On the other hand, we want to keep using the nicer BlockErrorAction...
virtio-blk: hide VIRTIO_BLK_F_CONFIG_WCE from old machine types
QEMU has a policy of keeping a stable guest device ABI. When new guest devicefeatures are introduced they must not change hardware info seen by existingguests. This is important because operating systems or applications may...
virtio-blk: support VIRTIO_BLK_F_CONFIG_WCE
Also rename VIRTIO_BLK_F_WCACHE to VIRTIO_BLK_F_WCE for consistency withthe spec.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
virtio-blk: disable write cache if not negotiated
If the guest does not support flushes, we should run in writethrough mode.The setting is temporary until the next reset, so that for example theBIOS will run in writethrough mode while Linux will run with a writeback...
virtio-blk: fix use-after-free while handling scsi commands
The scsi passthrough handler falls through after completing arequest into the failure path, resulting in a use after free.
Reproducible by running a guest with aio=native on a block device.
Reported-by: Stefan Priebe <s.priebe@profihost.ag>...
hw/block-common: Factor out fall back to legacy -drive serial=...
Signed-off-by: Markus Armbruster <armbru@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
hw/block-common: Factor out fall back to legacy -drive cyls=...
hd-geometry: Move disk geometry guessing back from block.c
Commit f3d54fc4 factored it out of hw/ide.c for reuse. Sensible,except it was put into block.c. Device-specific functionality shouldbe kept in device code, not the block layer. Move it tohw/hd-geometry.c, and make stylistic changes required to keep...
hd-geometry: Cut out block layer translation middleman
hd_geometry_guess() picks geometry and translation. Callers can getthe geometry directly, via parameters, but for translation they needto go through the block layer.
Add a parameter for translation, so it can optionally be gotten just...
hd-geometry: Switch to uint32_t to match BlockConf
Best to use the same type, to avoid unwanted truncation or signextension.
BlockConf can't use plain int for cyls, heads and secs, becauseinteger properties require an exact width.
Signed-off-by: Markus Armbruster <armbru@redhat.com>...
virtio-blk: qdev properties for disk geometry
Geometry needs to be qdev properties, because it belongs to thedisk's guest part.
Maintain backward compatibility exactly like for serial: fall back toDriveInfo's geometry, set with -drive cyls=...
Bonus: info qtree now shows the geometry....
virtio-blk: Fix geometry sector calculation
Currently the sector value for the geometry is masked, even if theuser usesa command line parameter that explicitely gives a number.This breaks dasd devices on s390. A dasd device can havea physical block size of 4096 (== same for logical block size)...
virtio: Fix compiler warning for non Linux hosts
The local variables ret, i are only used if linux is defined.
Signed-off-by: Stefan Weil <sw@weilnetz.de>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
virtio-blk: report non-zero status when failing SG_IO requests
Linux really looks only at scsi->errors for SG_IO requests; it doesnot look at the virtio request status at all. Because of this, whena SG_IO request is failed early with virtio_blk_req_complete(req,...
virtio-blk: blockdev_mark_auto_del is transport-independent
Move it from virtio_blk_exit_pci to virtio_blk_exit.
This is included here because the next patch removes proxy->block.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
virtio-blk: define VirtIOBlkConf
We will have to add another field to the virtio-blk configuration inthe next patch. Avoid a proliferation of arguments to virtio_blk_init.
virtio-blk: always enable VIRTIO_BLK_F_SCSI
VIRTIO_BLK_F_SCSI is supposed to mean whether the host can parseSCSI requests, not execute them. You could run QEMU with scsi=onand a file-backed disk, and QEMU would fail all SCSI requests eventhough it advertises VIRTIO_BLK_F_SCSI....
virtio: check virtio_load return code
Otherwise we crash on error.
Signed-off-by: Ulrich Obergfell <uobergfe@redhat.com>Signed-off-by: Orit Wassermann <owasserm@redhat.com>Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
block: Rename bdrv_mon_event() & BlockMonEventAction
They are QMP events, not monitor events. Rename them accordingly.
Also, move bdrv_emit_qmp_error_event() up in the file. A new event willbe added soon and it's good to have them next each other.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>...
virtio-blk: add virtio_blk_handle_read trace event
There already exists a virtio_blk_handle_write trace event as well ascompletion events. Add the virtio_blk_handle_read event so it's easy totrace virtio-blk requests for both read and write operations....
virtio-blk: refuse SG_IO requests with scsi=off
QEMU does have a "scsi" option (to be used like -devicevirtio-blk-pci,drive=foo,scsi=off). However, it onlymasks the feature bit, and does not reject the commandif a malicious guest disregards the feature bits and...
scsi virtio-blk usb-msd: Clean up device init error messages
Replace
error_report("DEVICE-NAME: MESSAGE");
by just
error_report("MESSAGE");
in block device init functions.
DEVICE-NAME is bogus in some cases: it's "scsi-disk" for devicescsi-hd and scsi-cd, "virtio-blk-pci" for virtio-blk-s390, and...
block: bdrv_aio_* do not return NULL
Initially done with the following semantic patch:
rule1 expression E;statement S;@@ E =( bdrv_aio_readv | bdrv_aio_writev | bdrv_aio_flush | bdrv_aio_discard | bdrv_aio_ioctl) (...);(- if (E == NULL) { ... }...
rule1
block: convert qemu_aio_flush() calls to bdrv_drain_all()
Many places in QEMU call qemu_aio_flush() to complete all pendingasynchronous I/O. Most of these places actually want to drain all blockrequests but there is no block layer API to do so.
This patch introduces the bdrv_drain_all() API to wait for requests...
virtio-blk: fix cross-endian config space
virtio-blk: pass full status to the guest
When SCSI passthrough is being used by the guest with virtio-blk, theguest is not able to detect disk failures. This is because the statusfield is expected by the guest driver to include also the msg_status,host_status and driver_status fields, but the device is only passing...
virtio: Support I/O status
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>Reviewed-by: Markus Armbruster <armbru@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
RunState: Rename enum values as generated by the QAPI
Next commit will convert the query-status command to use theRunState type as generated by the QAPI.
In order to "transparently" replace the current enum by the QAPIone, we have to make some changes to some enum values....
Replace the VMSTOP macros with a proper state type
Today, when notifying a VM state change with vm_state_notify(),we pass a VMSTOP macro as the 'reason' argument. This is not idealbecause the VMSTOP macros tell why qemu stopped and not exactlywhat the current VM state is....
block: New bdrv_set_buffer_alignment()
Device models should be able to set it without an unclean include ofblock_int.h.
block: Drop BlockDriverState member removable
It's a confused mess (see previous commit). No users remain.
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.
Fix include statements for qemu-common.h
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: 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...
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>
virtio-blk: Fix memleak on exit
Calling virtio_cleanup() will free up memory allocated invirtio_common_init().
Signed-off-by: Amit Shah <amit.shah@redhat.com>Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
virtio-blk: Turn drive serial into a qdev property
It needs to be a qdev property, because it belongs to the drive'sguest part. Precedence: commit a0fef654 and 6ced55a5.
Bonus: info qtree now shows the serial number.
virtio-blk: fail unaligned requests
Like all block drivers virtio-blk should not allow small than block sizegranularity access. But given that the protocol specifies abyte unit length field we currently accept such requests, which causeqemu to abort() in lower layers. Add checks to the main read and...
Improve vm_stop reason declarations
Define and use dedicated constants for vm_stop reasons, they actuallyhave nothing to do with the EXCP_* defines used so far. At this chance,specify more detailed reasons so that VM state change handlers canevaluate them....
virtio-blk: tell the guest about size changes
Raise a config change interrupt when the size changed. This allowsvirtio-blk guest drivers to read-read the information from theconfig space once it got the config chaged interrupt.
Signed-off-by: Christoph Hellwig <hch@lst.de>...
virtio-blk: fix cross-endianness targets
virtio-blk doesn't work on cross-endian configuration, as endianness isnot handled correctly.
This patch adds missing endianness conversions to make virtio-blkworking. Tested on the following configurations:- i386 guest on x86_64 host...
Add bootindex parameter to net/block/fd device
If bootindex is specified on command line a string that describes devicein firmware readable way is added into sorted list. Later this list willbe passed into firmware to control boot order.
Signed-off-by: Gleb Natapov <gleb@redhat.com>...
virtio-blk: Convert fprintf() to error_report()
Errors should be logged using error_report() so they go to theappropriate monitor.
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
virtio-blk: Handle immediate flush failure properly
Fix virtio-blk to use the usual completion path that involves werror handlinginstead of directly completing the request in cases where bdrv_aio_flushreturns NULL.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
virtio-blk: Respect werror option for flushes
The werror option now affects not only write requests, but also flush requests.Previously, it was not possible to stop a VM on a failed flush.
virtio-blk: propagate the required alignment
Signed-off-by: Christoph Hellwig <hch@lst.de>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
trace: Trace virtio-blk, multiwrite, and paio_submit
This patch adds trace events that make it possible to observevirtio-blk.
Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
virtio-blk: Fix migration of queued requests
in_sg[].iovec and out_sg[].ioved are pointer to (source) host memory andtherefore invalid after migration. When loading the device state we mustcreate a new mapping on the destination host.
Rearrange block headers
Changing block.h or blockdev.h resulted in recompiling most objects.
Move DriveInfo typedef and BlockInterfaceType enum definitionsto qemu-common.h and rearrange blockdev.h use to decrease churn.
Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
virtio-blk: Create exit function to unregister savevm
Otherwise we can't migrate after we've removed a virtio block device.
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
virtio-blk: Fix virtio-blk-s390 to require drive
Move the check from virtio_blk_init_pci(), where it protects onlyvirtio-blk-pci, to virtio_blk_init(). Without that, virtio-blk-s390initializes without a drive. I figure that can lead to null pointerdereferences....
ide scsi virtio-blk: Reject empty drives unless media is removable
Disks without media make no sense. For SCSI, a Linux guest kernelcomplains during boot. I didn't try other combinations.
scsi-generic doesn't need the additional check, because it already...
Merge remote branch 'kwolf/for-anthony' into staging
savevm: Add DeviceState param
When available, we'd like to be able to access the DeviceStatewhen registering a savevm. For buses with a get_dev_path()function, this will allow us to create more unique savevmid strings.
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>...
Add virtio disk identification support
This patch adds the final missing bits for support ofpassing a serial/id string to a virtio-blk guest driver.
The guest-side component already exists in the virtiodriver, and has recently been reworked by Ryan to export...
qdev: Decouple qdev_prop_drive from DriveInfo
Make the property point to BlockDriverState, cutting out the DriveInfomiddleman. This prepares the ground for block devices that don't havea DriveInfo.
Currently all user-defined ones have a DriveInfo, because the only way...
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...
virtio-blk: fix the list operation in virtio_blk_load().
Although it is really rare to get in to the while loop, the listoperation in the loop is obviously wrong.
Signed-off-by: Yoshiaki Tamura <tamura.yoshiaki@lab.ntt.co.jp>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
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.
virtio-blk: stop tracking old_bs
There is a 1:1 relation between VirtIOBlock and BlockDriverState instances,no need to track it because it won't change.
Signed-off-by: Christoph Hellwig <hch@lst.de>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
virtio-blk: simplify multiwrite calling conventions
Pass the MultiReqBuffer structure down all the way to the I/O submissioninstead of takin it apart. Also mark num_writes unsigned as it can'tgo negative, and take the check for any pending I/O requests into the...
blockdev: Collect block device code in new blockdev.c
Anything that moves hundreds of lines out of vl.c can't be all bad.
Cleanup: virtio-blk.c: Be more consistent using BDRV_SECTOR_SIZE instead
Clean up virtio-blk.c to be more consistent using BDRV_SECTOR_SIZEinstead of hard coded 512 values.
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
virtio-blk: fix barrier support
Before issuing the barrier to the block driver we need to flush our oustandingqueue of write requests, as the flush is supposed to be issued after them.
virtio-blk: Avoid zeroing every request structure
The VirtIOBlockRequest structure is about 40 KB in size. This patchavoids zeroing every request by only initializing fields that are read.The other fields are either written to or may not be used at all....
Remove un-needed code
The bdrv_set_geometry_hint call below is not needed - it's just settingwhat was just read.
Signed-off-by: Bruce Rogers <brogers@novell.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
virtio-blk: Fix use after free in error case
virtio_blk_req_complete frees the request, so we can't access it any more whencalling bdrv_mon_event. Use the pointer that was copied earlier.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
block: add logical_block_size property
Add a logical block size attribute as various guest side tools onlyincrease the filesystem sector size based on it, not the advisoryphysical block size.
For scsi we already have support for a different logical block size...
block: Emit BLOCK_IO_ERROR before vm_stop() call
The next commit will move the STOP event into do_vm_stop(), tohave the expected event sequence we need to emit the I/O errorevent before calling vm_stop().
The expected sequence is:
{ "event": "BLOCK_IO_ERROR" [...] }...
virtio-blk: add topology support
Export all topology information in the block config structure,guarded by a new VIRTIO_BLK_F_TOPOLOGY feature flag.
block: add topology qdev properties
Add three new qdev properties to export block topology information tothe guest. This is needed to get optimal I/O alignment for RAID arraysor SSDs.
The options are:
- physical_block_size to specify the physical block size of the device,...
virtio-blk: revert serial number support
The addition of the whole ATA IDENTIY page caused the config space togo above the allowed size in the PCI spec, and thus the feature wasalready reverted in the Linux guest driver and disabled by default inqemu....
virtio-blk: Generate BLOCK_IO_ERROR QMP event
Just call bdrv_mon_event() in the right place.
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
virtio-blk: Fix restart after read error
Current code assumes that only write requests are ever going to be restarted.This is wrong since rerror=stop exists. Instead of directly starting writes,use the same request processing as used for new requests....
virtio-blk: Fix error cases which ignored rerror/werror
If an I/O request fails right away instead of getting an error only in thecallback, we still need to consider rerror/werror.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
virtio_blk: Factor virtio_blk_handle_request out
We need a function that handles a single request. Create one by splitting outcode from virtio_blk_handle_output.
virtio-blk: remove dead variable in virtio_blk_handle_scsi
As pointed out by clang size is only ever written to, but never actuallyused.
virtio: add features as qdev properties
Add feature bits as properties to virtio. This makes it possible to e.g. definemachine without indirect buffer support, which is required for 0.10compatibility, or without hardware checksum support, which is required for 0.11...
Rename DriveInfo.onerror to on_write_error
Either rename variables and functions to refer to write errors (which is whatthey actually do) or introduce a parameter to distinguish reads and writes.
virtio-blk: Implement rerror option
virtio-blk: Pass read errors to the guest
We need to signal not only write errors, but also read errors to the guestdriver. This fixes a regression introduced by 869a5c6d.
Pass the drive's readonly attribute to the guest OS
Implemented for virtio-blk and for scsi
Signed-off-by: Naphtali Sprei <nsprei@redhat.com>Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
drive cleanup fixes.
Changes: * drive_uninit() wants a DriveInfo now. * drive_uninit() also calls bdrv_delete(), so callers don't need to do that. * drive_uninit() calls are moved over to the ->exit() callbacks, destroy_bdrvs() is zapped. * setting bdrv->private is not needed any more as the...
qemu: make virtio-blk PCI compliant by default
commit bf011293faaa7f87e4de83185931e7411b794128 made virtio-blk-pci notPCI-compliant, since it makes region 0 (which is an i/o region)size > 256, and, since PCI 2.1, i/o regions are limited to 256 bytes size....
virtio-blk: add volatile writecache feature
Add a new VIRTIO_BLK_F_WCACHE feature to virtio-blk to indicate that we havea volatile write cache that needs controlled flushing. Implement aVIRTIO_BLK_T_FLUSH operation to flush it.
virtio-blk: Use bdrv_aio_multiwrite
It is quite common for virtio-blk to submit more than one write request in arow to the qemu block layer. Use bdrv_aio_multiwrite to allow block drivers tooptimize its handling of the requests.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>...
virtio-blk: handle NULL returns from bdrv_aio_{read, write}
The bdrv_aio_{read,write} routines can return a NULL pointer when theI/O submission fails. Currently we ignore this and will wait foreverfor an I/O completion and leading to a hang of the guest....
qdev-ify virtio-blk.
First user of the new drive property. With this patch applied hostand guest config can be specified separately, like this:
-drive if=none,id=disk1,file=/path/to/disk.img -device virtio-blk-pci,drive=disk1
You can set any property for virtio-blk-pci now. You can set the pci...
Fix VM state change handlers running out of order
When a VM state change handler changes VM state, other VM state changehandlers can see the state transitions out of order.
bmdma_map(), scsi_disk_init() and virtio_blk_init() install VM statechange handlers to restart DMA. These handlers can vm_stop() by...
Add serial number support for virtio_blk
[brought forward to current qemu-kvm.git]
This patch implements the missing qemu logic tointerpret a '-drive .. serial=XYZ ..' flag fora virtio_blk device.
The serial number string is contained in askeletal IDENTIFY DEVICE data structure and...