History | View | Annotate | Download (70.1 kB)
ide: refuse WIN_READ_NATIVE_MAX on empty device
What is the highest addressable sector on an empty CD-ROM? Nothing isaddressable so produce an error.
This patch prevents a divide-by-zero in ide_set_sector() sinces->sectors and s->heads would be 0. Not to mention that a sector=-1...
hw: move headers to include/
Many of these should be cleaned up with proper qdev-/QOM-ification.Right now there are many catch-all headers in include/hw/ARCH dependingon cpu.h, and this makes it necessary to compile these files per-target.However, fixing this does not belong in these patches....
ide: Add fall through annotations
Add comments to help static analysers detect that these cases areintentional, and clean up some whitespace in the environment of thesecomments.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Markus Armbruster <armbru@redhat.com>
ide: fix TRIM with empty range entry
ATA-ACS-3 says "If the two byte range length is zero, then the LBARange Entry shall be discarded as padding." iovecs are used as ifthey are linearized, so it is incorrect to discard the rest ofthis iovec.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>...
ide: issue discard asynchronously but serialize the pieces
Now that discard can take a long time, make it asynchronous.Each LBA range entry is processed separately because discardcan be an expensive operation.
softmmu: move include files to include/sysemu/
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
misc: move include files to include/qemu/
Merge commit '1dd3a74d2ee2d873cde0b390b536e45420b3fe05' into HEAD
pci: update all users to look in pci/
update all users so we can remove the makefile hack.
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
atapi: reset cdrom tray statuses on ide_reset
Tray statuses should be also reseted. Some guests may lock the trayand after reset before any kernel is loaded the tray should be unlocked.
Also if you reset the real computer the tray is closed. We shoulddo the same in qemu....
atapi: make change media detection for guests easier
If you have a guest with a media in the optical drive and you changeit, the windows guest cannot properly recognize this media change.
Windows needs to detect sense "NOT_READY with ASC_MEDIUM_NOT_PRESENT"...
ide: Fix crash with too long PRD
Without this, s->nsector can become negative and badness happens (tryingto malloc huge amount of memory and glib calls abort())
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
ide: Fix status register after short PRDs
When failing a request because the length of the regions described bythe PRDT was too short for the requested number of sectors, the IDEemulation forgot to update the status register, so that the device wouldkeep the BSY flag set indefinitely....
aio: rename AIOPool to AIOCBInfo
Now that AIOPool no longer keeps a freelist, it isn't really a "pool" anymore. Rename it to AIOCBInfo and make it const since it no longerneeds to be modified.
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
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...
ide: Fix error messages from static code analysis (no real error)
Report from smatch:hw/ide/core.c:1472 ide_exec_cmd(423) error: buffer overflow 'smart_attributes' 8 <= 29hw/ide/core.c:1474 ide_exec_cmd(425) error: buffer overflow 'smart_attributes' 8 <= 29...
hd-geometry: Compute BIOS CHS translation in one place
Currently, it is split between hd_geometry_guess() andpc_cmos_init_late(). Confusing. info qtree shows the result of theformer. Also confusing.
Fold the part done in pc_cmos_init_late() into hd_geometry_guess()....
Relax IDE CHS limits from 16383,16,63 to 65535,16,255
New limits straight from ATA4 6.2 Register delivered data transfercommand sector addressing.
I figure the old sector limit 63 was blindly copied from the BIOSint 13 limit. Doesn't apply to the hardware. No idea where the old...
blockdev: Don't limit DriveInfo serial to 20 characters
All current users (IDE, SCSI and virtio-blk) happen to share this 20characters limit. Still, it should be left to device models. Theyalready enforce their limits. They have to, as the DriveInfo limit...
hw/block-common: Factor out fall back to legacy -drive cyls=...
Signed-off-by: Markus Armbruster <armbru@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ide: 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=...
Do this only for ide-hd. ide-drive is legacy. ide-cd doesn't have a...
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...
ide pc: Cut out the block layer geometry middleman
PC BIOS setup needs IDE geometry information. Get it directly fromthe device model rather than through the block layer. In preparationof purging geometry from the block layer, which will happen later in...
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>...
Allow machines to configure the QEMU_VERSION that's exposed via hardware
QEMU exposes its version to the guest's hardware and in some cases that is wrong(e.g. Windows prints messages about driver updates when you switchthe QEMU version).There is a new field now on the struct QEmuMachine, hw_version, which may...
ide: support enable/disable write cache
Enabling or disabling the write cache is done with the SET FEATUREScommand. The command can be issued with sg_sat_set_features fromsg3-utils.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ATA: Allow WIN_SECURITY_FREEZE_LOCK as nop
When using Windows 8 with an AHCI disk drive, it issues a blue screen.The reason is that WIN_SECURITY_FREEZE_LOCK / CFA_WEAR_LEVEL is notsupported by our ATA implementation, but Windows expects it to be there....
ide: convert ide_sector_read() to asynchronous I/O
The IDE PIO interface currently uses bdrv_read() to perform readssynchronously. Synchronous I/O in the vcpu thread is bad because itprevents the guest from executing code - it makes the guestunresponsive....
ide: convert ide_sector_write() to asynchronous I/O
The IDE PIO write sector code path uses bdrv_write() and hence can makethe guest unresponsive while the I/O request is in progress. This patchconverts ide_sector_write() to use bdrv_aio_writev() by using the...
Use DMADirection type for dma_bdrv_io
Currently dma_bdrv_io() takes a 'to_dev' boolean parameter todetermine the direction of DMA it is emulating. We already have aDMADirection enum designed specifically to encode DMA directions.This patch uses it for dma_bdrv_io() as well. This involves removing...
aio: move BlockDriverAIOCB to qemu-aio.h
And remove several block_int.h inclusions that should not be there.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ide: IDENTIFY word 86 bit 14 is reserved
Reserved bits should be cleared to zero.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
ide: Add "model=s" qdev option
Allow the user to override the default disk model name "QEMU HARDDISK".
Some Linux distributions use the /dev/disk/by-id/scsi-SATA_name-of-disk-model_serial addressing scheme when refering to partitions in /etc/fstaband elsewhere. This causes problems when starting a disk image taken from...
ide: Change serial number strncpy() to pstrcpy()
strncpy may not null-terminate the destination string.
Cc: kwolf@redhat.comSigned-off-by: Floris Bos <dev@noc-ps.com>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ide: Adds wwn=hex qdev option
Allow the user to specify a disk's World Wide Name.
Linux guests can address disks by their unique World Wide Name number(e.g. /dev/disk/by-id/wwn-0x5001517959123522). This patch adds supportfor assigning a World Wide Name number to a virtual IDE disk....
ide: fail I/O to empty disk
Requesting a read or a write operation on an empty disk can leadto QEMU dumping core.
Also fix a few braces here and there.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>...
ide: drop ide_tray_state_post_load()
This is used to sync the physical tray state after migration whenusing CD-ROM passthrough. However, migrating when using passthroughis broken anyway and shouldn't be supported...
So, drop this function as it causes a problem with the DEVICE_TRAY_MOVED...
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>...
Merge remote-tracking branch 'stefanha/trivial-patches' into staging
ide: drop argument to dma_buf_commit
The argument is unused and even wrong when the function is calledby ide_handle_rw_error. Drop it.
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
block: dma_bdrv_* does not return NULL
Initially attempted with the following semantic patch:
rule1 expression E;statement S;@@ E =( dma_bdrv_io | dma_bdrv_read | dma_bdrv_write) (...);(- if (E == NULL) { ... } |- if (E) { <... S ...> }...
rule1
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) { ... }...
fix spelling in hw sub directory
Correct obvious spelling errors in qemu/hw directory.
Signed-off-by: Dong Xu Wang <wdongxu@linux.vnet.ibm.com>Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
atapi: implement eject requests
atapi/scsi: unify definitions for MMC
The definitions in ide/internal.h are duplicates, since ATAPI commandsactually come from SCSI. Use the ones in scsi-defs.h and move themissing ones there. Two exceptions:
- MODE_PAGE_WRITE_PARMS conflicts with the "flexible disk geometry"...
ide: Fix off-by-one error in array index check
Signed-off-by: Kevin Wolf <kwolf@redhat.com>Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
Merge remote-tracking branch 'kwolf/for-anthony' into staging
Merge remote-tracking branch 'qemu-kvm-tmp/memory/batch' into staging
ide: Convert to isa_register_portio_list
Signed-off-by: Richard Henderson <rth@twiddle.net>Signed-off-by: Avi Kivity <avi@redhat.com>
ide: 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....
dma-helpers: rename is_write to to_dev
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: New change_media_cb() parameter load
To let device models distinguish between eject and load.
ide/atapi scsi-disk: Make monitor eject -f, then change work
change fails while the tray is locked by the guest. eject -f forcesit open and removes any media. Unfortunately, the tray closes againinstantly. Since the lock remains as it is, there is no way to insert...
ide/atapi: Preserve tray state on migration
Use a subsection, so that migration to older version still works,provided the tray is closed and unlocked.
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.
block: Drop medium lock tracking, ask device models instead
Requires new BlockDevOps member is_medium_locked(). Implement for IDEand SCSI CD-ROMs.
ide: Use a table to declare which drive kinds accept each command
No functional change.
It would be nice to have handler functions in the table, like commite1a064f9 did for ATAPI. Left for another day.
ide: Reject ATA commands specific to drive kinds
ACS-2 Table B.2 explicitly prohibits ATAPI devices from implementingWIN_RECAL, WIN_READ_EXT, WIN_READDMA_EXT, WIN_READ_NATIVE_MAX,WIN_MULTREAD_EXT, WIN_WRITE, WIN_WRITE_ONCE, WIN_WRITE_EXT,WIN_WRITEDMA_EXT, WIN_MULTWRITE_EXT, WIN_WRITE_VERIFY, WIN_VERIFY,...
ide: Fix ATA command READ to set ATAPI signature for CD-ROM
Must set the ATAPI device signature, see ATA4 8.27.5.2 Outputs forPACKET Command feature set devices, and ACS-2 7.36.6 Outputs forPACKET feature set devices.
ide: Give vmstate structs internal linkage where possible
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.
ide: Update command code definitions as per ACS-2 Table B.2
Drop WIN_SRST, it has the same value as WIN_DEVICE_RESET.
Drop unused WIN_RESTORE, it has the same value as WIN_RECAL.
Drop codes that are not implemented and long obsolete: WIN_READ_LONG,WIN_READ_LONG_ONCE, WIN_WRITE_LONG, WIN_WRITE_LONG_ONCE, WIN_FORMAT...
ide: Clean up case label indentation in ide_exec_cmd()
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...
ide: Initialise buffers with zeros
Just in case there's still a way how a guest can read out buffers when it's notsupposed to, let's zero the buffers during initialisation so that we don't leakinformation to the guest.
Signed-off-by: Kevin Wolf <kwolf@redhat.com>...
ide: Ignore reads during PIO in and writes during PIO out
This fixes https://bugs.launchpad.net/qemu/+bug/786209:
When the DRQ_STAT bit is set, the IDE core permits both data reads and data writes, regardless of whether the current transfer was initiated as a read or write....
ide: Add forgotten VMSTATE_END_OF_LIST in subsection
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ide: allow other dma comands than read and write
Replace the is_read flag with a dma_cmd flag to allow the dma andrestart logic to handler other commands like TRIM.
Signed-off-by: Christoph Hellwig <hch@lst.de>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
ide: add TRIM support
Add support for TRIM sub function of the data set management command,and wire it up to the qemu discard infrastructure.
ide: Split error status from status register
When adding the werror=stop mode, some flags were added to s->statuswhich are used to determine what kind of operation should be restartedwhen the VM is continued.
Unfortunately, it turns out that s->status is in fact a device register...
ide: Fix ide_drive_pio_state_needed()
When a failed PIO request caused the VM to stop, we still need to transfer thePIO state even though DRQ=0 at this point.
ide/core: Remove explicit setting of BM_STATUS_INT
BM_STATUS_INT is automatically set during ide_set_irq(), there's no reason toset it manually in addition.
There is even one case where the interrupt status bit was set, but no IRQ wasraised. This is when the PRD table was reached but there is more data to...
blockdev: Store -drive option media in DriveInfo
DriveInfo is closely tied to -drive, and like -drive, it mixesinformation about host and guest part of the block device. UnlikeDriveInfo, BlockDriverState should be about the host part only.
One of the remaining guest bits there is the "type hint". -drive...
ide: Split qdev "ide-drive" into "ide-hd" and "ide-cd"
An "ide-drive" is either a hard disk or a CD-ROM, depending on theassociated BlockDriverState's type hint. Unclean; disk vs. CD belongsto the guest part, not the host part.
Have separate qdevs "ide-hd" and "ide-cd" to model disk vs. CD in...
ide: Split atapi.c out
Besides moving code, this patch only fixes some whitespace issues in the movedcode and makes all functions in atapi.c static which can be static.
atapi: Add 'medium ready' to 'medium not ready' transition on cd change
MMC-5 Table F.1 lists errors that can be thrown for the TEST_UNIT_READYcommand. Going from medium not ready to medium ready states iscommunicated by throwing an error.
This adds the missing 'tray opened' event that we fail to report to...
atapi: GESN: implement 'media' subcommand
Implement the 'media' sub-command of the GET_EVENT_STATUS_NOTIFICATIONcommand. This helps us report tray open, tray closed, no media, mediapresent states to the guest.
Newer Linux kernels (2.6.38+) rely on this command to revalidate discs...
atapi: GESN: Standardise event response handling for future additions
Handle GET_EVENT_STATUS_NOTIFICATION's No Event Available response in ageneric way so that future additions to the code to handle otherresponse types is easier.
Signed-off-by: Amit Shah <amit.shah@redhat.com>...
atapi: GESN: Use structs for commonly-used field types
Instead of using magic numbers, use structs that are more descriptive ofthe fields being used.
Signed-off-by: Amit Shah <amit.shah@redhat.com>Acked-by: Jes Sorensen <Jes.Sorensen@redhat.com>Acked-by: Paolo Bonzini <pbonzini@redhat.com>...
atapi: Move GET_EVENT_STATUS_NOTIFICATION command handling to its own function
This makes the code more readable.
Also, there's a block like:
if () { ...} else { ...}
Split that into
if () { ... return;}...
atapi: Allow GET_EVENT_STATUS_NOTIFICATION after media change
After a media change, the only commands allowed from the guest wereREQUEST_SENSE and INQUIRY. The guest may also issueGET_EVENT_STATUS_NOTIFICATION commands to get mediachanged notification....
atapi: Drives can be locked without media present
Drivers are free to lock drives without any media present. Such acondition should not result in an error condition.
See Table 341 in MMC-5 spec for details.
atapi: Report correct errors on guest eject request
Table 629 of the MMC-5 spec mentions two different error conditions whena CDROM eject is requested: a) while a disc is inserted and b) while adisc is not inserted.
Ensure we return the appropriate error for the present condition of the...
ide: consolidate drive_get(IF_IDE)
factor out ide initialization to call drive_get(IF_IDE)
Signed-off-by: Isaku Yamahata <yamahata@valinux.co.jp>Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Merge branch 'for-anthony' of git://github.com/bonzini/qemu
change all other clock references to use nanosecond resolution accessors
This was done with:
sed -i 's/qemu_get_clock\>/qemu_get_clock_ns/' \ $(git grep -l 'qemu_get_clock\>' ) sed -i 's/qemu_new_timer\>/qemu_new_timer_ns/' \ $(git grep -l 'qemu_new_timer\>' )...
Fix ATA SMART and CHECK POWER MODE
This patch fixes two things:
1) CHECK POWER MODE
The error return value wasn't always zero, so it would show up asoffline. Error is now explicitly set to zero.
2) SMART
The smart values that were returned were invalid and tools like skdump...
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....