summaryrefslogtreecommitdiff
path: root/hw/ide/core.c
AgeCommit message (Collapse)AuthorFilesLines
2013-08-22aio / timers: Switch entire codebase to the new timer APIAlex Bligh1-3/+3
This is an autogenerated patch using scripts/switch-timer-api. Switch the entire code base to using the new timer API. Note this patch may introduce some line length issues. Signed-off-by: Alex Bligh <alex@alex.org.uk> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-07-15ahci: Fix FLUSH commandKevin Wolf1-0/+9
AHCI couldn't cope with asynchronous commands that aren't doing DMA, it simply wouldn't complete them. Due to the bug fixed in commit f68ec837, FLUSH commands would seem to have completed immediately even if they were still running on the host. After the commit, they would simply hang and never unset the BSY bit, rendering AHCI unusable on any OS sending flushes. This patch adds another callback for the completion of asynchronous commands. This is what AHCI really wants to use for its command completion logic rather than an DMA completion callback. Cc: qemu-stable@nongnu.org Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-06-24ide: Clean up ide_exec_cmd()Kevin Wolf1-24/+12
All commands are now converted to ide_cmd_table handlers, so it can be unconditional now and the old switch block can go. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-06-24ide: Convert SMART commands to ide_cmd_table handlerKevin Wolf1-151/+174
Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-06-24ide: Convert CF-ATA commands to ide_cmd_table handlerKevin Wolf1-75/+95
Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-06-24ide: Convert ATAPI commands to ide_cmd_table handlerKevin Wolf1-39/+61
Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-06-24ide: Convert SEEK to ide_cmd_table handlerKevin Wolf1-6/+7
Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-06-24ide: Convert FLUSH CACHE to ide_cmd_table handlerKevin Wolf1-6/+8
Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-06-24ide: Convert SET FEATURES to ide_cmd_table handlerKevin Wolf1-72/+75
Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-06-24ide: Convert CHECK POWER MDOE to ide_cmd_table handlerKevin Wolf1-9/+8
Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-06-24ide: Convert READ NATIVE MAX ADDRESS to ide_cmd_table handlerKevin Wolf1-17/+18
Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-06-24ide: Convert DMA read/write commands to ide_cmd_table handlerKevin Wolf1-31/+38
Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-06-24ide: Convert PIO read/write commands to ide_cmd_table handlerKevin Wolf1-43/+50
Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-06-24ide: Convert read/write multiple commands to ide_cmd_table handlerKevin Wolf1-59/+60
Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-06-24ide: Convert verify commands to ide_cmd_table handlerKevin Wolf1-14/+13
Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-06-24ide: Convert cmd_nop commands to ide_cmd_table handlerKevin Wolf1-31/+17
cmd_nop handles all commands that don't really do anything in our implementation except setting status register flags. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-06-24ide: Convert WIN_IDENTIFY to ide_cmd_table handlerKevin Wolf1-17/+23
Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-06-24ide: Convert WIN_DSM to ide_cmd_table handlerKevin Wolf1-13/+16
Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-06-24ide: Add handler to ide_cmd_tableKevin Wolf1-58/+86
As a preparation for moving all IDE commands into their own function like in the ATAPI code, introduce a 'handler' callback to ide_cmd_table. Commands using this new infrastructure get some things handled automatically: * The BSY flag is set before calling the handler (in order to avoid bugs like the one fixed in f68ec837) and reset on completion. * The (obsolete) DSC flag in the status register is set on completion if the command is flagged with SET_DSC in the command table * An IRQ is triggered on completion. * The error register and the ERR flag in the status register are cleared before calling the handler and on completion it is asserted that either none or both of them are set. No commands are converted at this point. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-06-06ide: Set BSY bit during FLUSHAndreas Färber1-0/+1
The implementation of the ATA FLUSH command invokes a flush at the block layer, which may on raw files on POSIX entail a synchronous fdatasync(). This may in some cases take so long that the SLES 11 SP1 guest driver reports I/O errors and filesystems get corrupted or remounted read-only. Avoid this by setting BUSY_STAT, so that the guest is made aware we are in the middle of an operation and no ATA commands are attempted to be processed concurrently. Addresses BNC#637297. Suggested-by: Gonglei (Arei) <arei.gonglei@huawei.com> Signed-off-by: Andreas Färber <afaerber@suse.de> Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-04-15ide: refuse WIN_READ_NATIVE_MAX on empty deviceStefan Hajnoczi1-0/+4
What is the highest addressable sector on an empty CD-ROM? Nothing is addressable so produce an error. This patch prevents a divide-by-zero in ide_set_sector() since s->sectors and s->heads would be 0. Not to mention that a sector=-1 argument would be nonsense. Note that WIN_READ_NATIVE_MAX can be triggered using hdparm -N 1024 /dev/cdrom. The LBA bit will be set to 1 though, so the only easy way to go down the ide_set_sector() CHS code path which divides by zero is to comment out the s->select & 0x40 case for testing. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com>
2013-04-08hw: move headers to include/Paolo Bonzini1-3/+3
Many of these should be cleaned up with proper qdev-/QOM-ification. Right now there are many catch-all headers in include/hw/ARCH depending on cpu.h, and this makes it necessary to compile these files per-target. However, fixing this does not belong in these patches. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2013-01-25ide: Add fall through annotationsKevin Wolf1-8/+25
Add comments to help static analysers detect that these cases are intentional, and clean up some whitespace in the environment of these comments. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com>
2013-01-15ide: issue discard asynchronously but serialize the piecesPaolo Bonzini1-25/+54
Now that discard can take a long time, make it asynchronous. Each LBA range entry is processed separately because discard can be an expensive operation. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2013-01-15ide: fix TRIM with empty range entryPaolo Bonzini1-1/+1
ATA-ACS-3 says "If the two byte range length is zero, then the LBA Range Entry shall be discarded as padding." iovecs are used as if they are linearized, so it is incorrect to discard the rest of this iovec. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2012-12-19softmmu: move include files to include/sysemu/Paolo Bonzini1-3/+3
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-19misc: move include files to include/qemu/Paolo Bonzini1-2/+2
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-17Merge commit '1dd3a74d2ee2d873cde0b390b536e45420b3fe05' into HEADPaolo Bonzini1-1/+1
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2012-12-17pci: update all users to look in pci/Michael S. Tsirkin1-1/+1
update all users so we can remove the makefile hack. Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
2012-12-13atapi: reset cdrom tray statuses on ide_resetPavel Hrdina1-0/+2
Tray statuses should be also reseted. Some guests may lock the tray and after reset before any kernel is loaded the tray should be unlocked. Also if you reset the real computer the tray is closed. We should do the same in qemu. Signed-off-by: Pavel Hrdina <phrdina@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-11-30atapi: make change media detection for guests easierPavel Hrdina1-6/+0
If you have a guest with a media in the optical drive and you change it, the windows guest cannot properly recognize this media change. Windows needs to detect sense "NOT_READY with ASC_MEDIUM_NOT_PRESENT" before we send sense "UNIT_ATTENTION with ASC_MEDIUM_MAY_HAVE_CHANGED". Signed-off-by: Pavel Hrdina <phrdina@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-11-21ide: Fix status register after short PRDsKevin Wolf1-0/+1
When failing a request because the length of the regions described by the PRDT was too short for the requested number of sectors, the IDE emulation forgot to update the status register, so that the device would keep the BSY flag set indefinitely. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
2012-11-21ide: Fix crash with too long PRDKevin Wolf1-0/+12
Without this, s->nsector can become negative and badness happens (trying to 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>
2012-11-14aio: rename AIOPool to AIOCBInfoStefan Hajnoczi1-2/+2
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 longer needs to be modified. Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-09-28iostatus: reorganize io error codePaolo Bonzini1-15/+5
Move the common part of IDE/SCSI/virtio error handling to the block layer. The new function bdrv_error_action subsumes all three of bdrv_emit_qmp_error_event, vm_stop, bdrv_iostatus_set_err. The same scheme will be used for errors in block jobs. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-09-28iostatus: change is_read to a boolPaolo Bonzini1-1/+1
Do this while we are touching this part of the code, before introducing more 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>
2012-09-28iostatus: move BlockdevOnError declaration to QAPIPaolo Bonzini1-3/+3
This will let block-stream reuse the enum. Places that used the enums are renamed accordingly. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-09-28iostatus: rename BlockErrorAction, BlockQMPEventActionPaolo Bonzini1-1/+1
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 name in the drivers. So rename the enums, while leaving aside the names of the enum values for now. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-09-12ide: Fix error messages from static code analysis (no real error)Stefan Weil1-9/+2
Report from smatch: hw/ide/core.c:1472 ide_exec_cmd(423) error: buffer overflow 'smart_attributes' 8 <= 29 hw/ide/core.c:1474 ide_exec_cmd(425) error: buffer overflow 'smart_attributes' 8 <= 29 hw/ide/core.c:1475 ide_exec_cmd(426) error: buffer overflow 'smart_attributes' 8 <= 29 ... The upper limit of 30 was never reached because both for loops terminated when 'smart_attributes' reached end of list, so there was no real buffer overflow. Nevertheless, changing the code not only fixes the error report, but also reduces the size of smart_attributes and simplifies the for loops. Signed-off-by: Stefan Weil <sw@weilnetz.de> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-07-17hw/block-common: Factor out fall back to legacy -drive cyls=...Markus Armbruster1-12/+12
Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-07-17blockdev: Don't limit DriveInfo serial to 20 charactersMarkus Armbruster1-3/+3
All current users (IDE, SCSI and virtio-blk) happen to share this 20 characters limit. Still, it should be left to device models. They already enforce their limits. They have to, as the DriveInfo limit only affects legacy -drive serial=..., not the qdev properties. usb-storage, which doesn't limit serial number length, also uses DriveInfo for -usbdevice. But that doesn't provide access to DriveInfo serial. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-07-17Relax IDE CHS limits from 16383,16,63 to 65535,16,255Markus Armbruster1-4/+4
New limits straight from ATA4 6.2 Register delivered data transfer command sector addressing. I figure the old sector limit 63 was blindly copied from the BIOS int 13 limit. Doesn't apply to the hardware. No idea where the old cylinder limit comes from. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-07-17hd-geometry: Compute BIOS CHS translation in one placeMarkus Armbruster1-0/+2
Currently, it is split between hd_geometry_guess() and pc_cmos_init_late(). Confusing. info qtree shows the result of the former. Also confusing. Fold the part done in pc_cmos_init_late() into hd_geometry_guess(). Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-07-17ide: qdev properties for disk geometryMarkus Armbruster1-5/+14
Geometry needs to be qdev properties, because it belongs to the disk's guest part. Maintain backward compatibility exactly like for serial: fall back to DriveInfo's geometry, set with -drive cyls=... Do this only for ide-hd. ide-drive is legacy. ide-cd doesn't have a geometry. Bonus: info qtree now shows the geometry. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-07-17hd-geometry: Switch to uint32_t to match BlockConfMarkus Armbruster1-1/+1
Best to use the same type, to avoid unwanted truncation or sign extension. BlockConf can't use plain int for cyls, heads and secs, because integer properties require an exact width. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-07-17ide pc: Cut out the block layer geometry middlemanMarkus Armbruster1-1/+1
PC BIOS setup needs IDE geometry information. Get it directly from the device model rather than through the block layer. In preparation of purging geometry from the block layer, which will happen later in this series. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-07-17hd-geometry: Cut out block layer translation middlemanMarkus Armbruster1-1/+1
hd_geometry_guess() picks geometry and translation. Callers can get the geometry directly, via parameters, but for translation they need to go through the block layer. Add a parameter for translation, so it can optionally be gotten just like geometry. In preparation of purging translation from the block layer, which will happen later in this series. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-07-17hd-geometry: Move disk geometry guessing back from block.cMarkus Armbruster1-1/+2
Commit f3d54fc4 factored it out of hw/ide.c for reuse. Sensible, except it was put into block.c. Device-specific functionality should be kept in device code, not the block layer. Move it to hw/hd-geometry.c, and make stylistic changes required to keep checkpatch.pl happy. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-06-19Allow machines to configure the QEMU_VERSION that's exposed via hardwareCrístian Viana1-1/+1
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 switch the QEMU version). There is a new field now on the struct QEmuMachine, hw_version, which may contain the version that the specific machine should report. If that field is set, then that machine will report that version to the guest. Signed-off-by: Crístian Viana <vianac@linux.vnet.ibm.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
2012-06-15ide: support enable/disable write cachePaolo Bonzini1-3/+18
Enabling or disabling the write cache is done with the SET FEATURES command. The command can be issued with sg_sat_set_features from sg3-utils. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>