summaryrefslogtreecommitdiff
path: root/hw/ide/core.c
AgeCommit message (Collapse)AuthorFilesLines
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>
2012-05-02ATA: Allow WIN_SECURITY_FREEZE_LOCK as nopAlexander Graf1-1/+6
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 not supported by our ATA implementation, but Windows expects it to be there. Since without security stuff implemented, the lock would be a nop anyway and CFA_WEAR_LEVEL already is treated as a nop, let's just allow the cmd for HD drives as well. That way Windows is happy. Signed-off-by: Alexander Graf <agraf@suse.de> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-04-19ide: convert ide_sector_write() to asynchronous I/OStefan Hajnoczi1-19/+42
The IDE PIO write sector code path uses bdrv_write() and hence can make the guest unresponsive while the I/O request is in progress. This patch converts ide_sector_write() to use bdrv_aio_writev() by using the BUSY_STAT bit to tell the guest that the request is in progress. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com> Tested-by: Richard Davies <richard@arachsys.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-04-19ide: convert ide_sector_read() to asynchronous I/OStefan Hajnoczi1-21/+55
The IDE PIO interface currently uses bdrv_read() to perform reads synchronously. Synchronous I/O in the vcpu thread is bad because it prevents the guest from executing code - it makes the guest unresponsive. This patch converts IDE PIO to use bdrv_aio_readv(). We simply need to use the BUSY_STAT status so the guest knows to wait while we are busy. The only external user of ide_sector_read() is restart behavior on I/O errors and it is not affected by this change. We still need to restart I/O in the same way. Migration is also unaffected if I understand the code correctly. We continue to use the same transfer function and the BUSY_STAT status should never be migrated since we flush I/O before migrating device state. Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com> Tested-by: Richard Davies <richard@arachsys.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-04-05Use DMADirection type for dma_bdrv_ioDavid Gibson1-1/+2
Currently dma_bdrv_io() takes a 'to_dev' boolean parameter to determine the direction of DMA it is emulating. We already have a DMADirection enum designed specifically to encode DMA directions. This patch uses it for dma_bdrv_io() as well. This involves removing the DMADirection definition from the #ifdef it was inside, but since that only existed to protect the definition of dma_addr_t from places where config.h is not included, there wasn't any reason for it to be there in the first place. Signed-off-by: David Gibson <david@gibson.dropbear.id.au> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Reviewed-by: Andreas Färber <afaerber@suse.de> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-04-05ide: Adds wwn=hex qdev optionFloris Bos1-6/+23
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 support for assigning a World Wide Name number to a virtual IDE disk. Cc: kwolf@redhat.com Signed-off-by: Floris Bos <dev@noc-ps.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-04-05ide: Change serial number strncpy() to pstrcpy()Floris Bos1-1/+1
strncpy may not null-terminate the destination string. Cc: kwolf@redhat.com Signed-off-by: Floris Bos <dev@noc-ps.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-04-05ide: Add "model=s" qdev optionFloris Bos1-5/+22
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/fstab and elsewhere. This causes problems when starting a disk image taken from an existing physical server under qemu, because when running under qemu name-of-disk-model is always "QEMU HARDDISK". This patch introduces a model=s option which in combination with the existing serial=s option can be used to fake the disk the operating system was previously on, allowing the OS to boot properly. Cc: kwolf@redhat.com Signed-off-by: Floris Bos <dev@noc-ps.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-04-05ide: IDENTIFY word 86 bit 14 is reservedKevin Wolf1-1/+1
Reserved bits should be cleared to zero. Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2012-04-05aio: move BlockDriverAIOCB to qemu-aio.hPaolo Bonzini1-1/+0
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>
2012-02-29ide: fail I/O to empty diskPaolo Bonzini1-4/+20
Requesting a read or a write operation on an empty disk can lead to 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> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2012-02-22ide: drop ide_tray_state_post_load()Luiz Capitulino1-10/+0
This is used to sync the physical tray state after migration when using CD-ROM passthrough. However, migrating when using passthrough is broken anyway and shouldn't be supported... So, drop this function as it causes a problem with the DEVICE_TRAY_MOVED event, which is going to be introduced by the next commit. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Acked-by: Kevin Wolf <kwolf@redhat.com>
2012-02-22block: Rename bdrv_mon_event() & BlockMonEventActionLuiz Capitulino1-3/+3
They are QMP events, not monitor events. Rename them accordingly. Also, move bdrv_emit_qmp_error_event() up in the file. A new event will be added soon and it's good to have them next each other. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Acked-by: Kevin Wolf <kwolf@redhat.com>
2011-12-19Merge remote-tracking branch 'stefanha/trivial-patches' into stagingAnthony Liguori1-3/+3
2011-12-16ide: drop argument to dma_buf_commitPaolo Bonzini1-3/+3
The argument is unused and even wrong when the function is called by ide_handle_rw_error. Drop it. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
2011-12-15block: dma_bdrv_* does not return NULLPaolo Bonzini1-6/+0
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 ...> } ) which however did not match anything. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-12-15block: bdrv_aio_* do not return NULLPaolo Bonzini1-6/+1
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) { ... } | - if (E) { <... S ...> } ) which however missed the occurrence in block/blkverify.c (as it should have done), and left behind some unused variables. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-12-06fix spelling in hw sub directoryDong Xu Wang1-1/+1
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>
2011-11-11atapi: implement eject requestsPaolo Bonzini1-0/+13
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-10-28atapi/scsi: unify definitions for MMCPaolo Bonzini1-2/+2
The definitions in ide/internal.h are duplicates, since ATAPI commands actually come from SCSI. Use the ones in scsi-defs.h and move the missing ones there. Two exceptions: - MODE_PAGE_WRITE_PARMS conflicts with the "flexible disk geometry" page in scsi-disk.c. It is unused, so pick the latter. - GPCMD_* is left in ide/internal.h, at least for now. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-10-28ide: Fix off-by-one error in array index checkKevin Wolf1-1/+1
Signed-off-by: Kevin Wolf <kwolf@redhat.com> Reviewed-by: Paolo Bonzini <pbonzini@redhat.com>
2011-10-14Merge remote-tracking branch 'kwolf/for-anthony' into stagingAnthony Liguori1-0/+2
2011-10-14Merge remote-tracking branch 'qemu-kvm-tmp/memory/batch' into stagingAnthony Liguori1-11/+19
2011-10-11ide: Convert to isa_register_portio_listRichard Henderson1-11/+19
Signed-off-by: Richard Henderson <rth@twiddle.net> Signed-off-by: Avi Kivity <avi@redhat.com>
2011-10-11ide: Support I/O statusLuiz Capitulino1-0/+2
Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com> Reviewed-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-10-04RunState: Rename enum values as generated by the QAPILuiz Capitulino1-1/+1
Next commit will convert the query-status command to use the RunState type as generated by the QAPI. In order to "transparently" replace the current enum by the QAPI one, we have to make some changes to some enum values. As the changes are simple renames, I'll do them in one shot. The changes are: - Rename the prefix from RSTATE_ to RUN_STATE_ - RUN_STATE_SAVEVM to RUN_STATE_SAVE_VM - RUN_STATE_IN_MIGRATE to RUN_STATE_INMIGRATE - RUN_STATE_PANICKED to RUN_STATE_INTERNAL_ERROR - RUN_STATE_POST_MIGRATE to RUN_STATE_POSTMIGRATE - RUN_STATE_PRE_LAUNCH to RUN_STATE_PRELAUNCH - RUN_STATE_PRE_MIGRATE to RUN_STATE_PREMIGRATE - RUN_STATE_RESTORE to RUN_STATE_RESTORE_VM - RUN_STATE_PRE_MIGRATE to RUN_STATE_FINISH_MIGRATE Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-09-20Merge remote-tracking branch 'kwolf/for-anthony' into stagingAnthony Liguori1-1/+1
2011-09-19dma-helpers: rename is_write to to_devPaolo Bonzini1-1/+1
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-15Replace the VMSTOP macros with a proper state typeLuiz Capitulino1-2/+2
Today, when notifying a VM state change with vm_state_notify(), we pass a VMSTOP macro as the 'reason' argument. This is not ideal because the VMSTOP macros tell why qemu stopped and not exactly what the current VM state is. One example to demonstrate this problem is that vm_start() calls vm_state_notify() with reason=0, which turns out to be VMSTOP_USER. This commit fixes that by replacing the VMSTOP macros with a proper state type called RunState. Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
2011-09-12ide/atapi scsi-disk: Make monitor eject -f, then change workMarkus Armbruster1-0/+1
change fails while the tray is locked by the guest. eject -f forces it open and removes any media. Unfortunately, the tray closes again instantly. Since the lock remains as it is, there is no way to insert another medium unless the guest voluntarily unlocks. Fix by leaving the tray open after monitor eject. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-12block: New change_media_cb() parameter loadMarkus Armbruster1-1/+1
To let device models distinguish between eject and load. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-12block: New bdrv_set_buffer_alignment()Markus Armbruster1-1/+1
Device models should be able to set it without an unclean include of block_int.h. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-12block: Move BlockConf & friends from block_int.h to block.hMarkus Armbruster1-0/+1
It's convenience stuff for block device models, so block.h isn't the ideal 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> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-12block: Show whether the virtual tray is open in info blockMarkus Armbruster1-0/+6
Need to ask the device, so this requires new BlockDevOps member is_tray_open(). Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-12block: Drop BlockDriverState member removableMarkus Armbruster1-1/+0
It's a confused mess (see previous commit). No users remain. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-12ide/atapi: Preserve tray state on migrationMarkus Armbruster1-0/+32
Use a subsection, so that migration to older version still works, provided the tray is closed and unlocked. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-12block: Drop medium lock tracking, ask device models insteadMarkus Armbruster1-0/+6
Requires new BlockDevOps member is_medium_locked(). Implement for IDE and SCSI CD-ROMs. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-12ide: Reject ATA commands specific to drive kindsMarkus Armbruster1-25/+25
ACS-2 Table B.2 explicitly prohibits ATAPI devices from implementing WIN_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, WIN_VERIFY_ONCE, WIN_VERIFY_EXT, WIN_SPECIFY, WIN_MULTREAD, WIN_MULTWRITE, WIN_SETMULT, WIN_READDMA, WIN_READDMA_ONCE, WIN_WRITEDMA, WIN_WRITEDMA_ONCE, WIN_FLUSH_CACHE_EXT. Restrict them to IDE_HD and IDE_CFATA. Same for CFA_WRITE_SECT_WO_ERASE, CFA_WRITE_MULTI_WO_ERASE. Restrict them to IDE_CFATA, like the other CFA_ commands. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-12ide: Use a table to declare which drive kinds accept each commandMarkus Armbruster1-25/+80
No functional change. It would be nice to have handler functions in the table, like commit e1a064f9 did for ATAPI. Left for another day. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-12ide: Fix ATA command READ to set ATAPI signature for CD-ROMMarkus Armbruster1-1/+3
Must set the ATAPI device signature, see ATA4 8.27.5.2 Outputs for PACKET Command feature set devices, and ACS-2 7.36.6 Outputs for PACKET feature set devices. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-06ide: Give vmstate structs internal linkage where possibleMarkus Armbruster1-3/+3
Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-06ide: Clean up case label indentation in ide_exec_cmd()Markus Armbruster1-6/+6
Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-06ide: Update command code definitions as per ACS-2 Table B.2Markus Armbruster1-2/+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 (all obsolete since ATA4), WIN_ACKMEDIACHANGE, WIN_POSTBOOT, WIN_PREBOOT (obsolete since ATA3), WIN_WRITE_SAME (obsolete since ATA3, code reused for something else in ACS2), WIN_IDENTIFY_DMA (obsolete since ATA4). Drop codes that are not implemented and vendor-specific: EXABYTE_ENABLE_NEST, DISABLE_SEAGATE. Drop WIN_INIT, it isn't implemented, its value used to be reserved, and is used for something else since ATA8. CFA_IDLEIMMEDIATE isn't specific to CFATA. ACS-2 shows it as a defined command in ATA-1, -2 and -3. Rename to WIN_IDLEIMMEDIATE2. Mark vendor specific, retired, and obsolete codes. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-06block: Split change_cb() into change_media_cb(), resize_cb()Markus Armbruster1-6/+2
Multiplexing callbacks complicates matters needlessly. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-06block: Generalize change_cb() to BlockDevOpsMarkus Armbruster1-1/+5
So we can more easily add device model callbacks. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-09-06block: Attach non-qdev devices as wellMarkus Armbruster1-0/+1
For now, this just protects against programming errors like having the same 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() to bdrv_attach_dev(), bdrv_detach() to bdrv_detach_dev(), and bdrv_get_attached() to bdrv_get_attached_dev(). Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
2011-08-25block: explicit I/O accountingChristoph Hellwig1-1/+26
Decouple the I/O accounting from bdrv_aio_readv/writev/flush and make 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 - we do not double count I/O ops if the device model handles it chunk wise - we only account I/O once it actuall is done - can extent I/O accounting to synchronous or coroutine I/O easily - implement I/O latency tracking easily (see the next patch) I've conveted the existing device model callers to the new model, device models that are using synchronous I/O and weren't accounted before haven't been updated yet. Also scsi hasn't been converted to the end-to-end accounting as I want to defer that after the pending scsi layer overhaul. Signed-off-by: Christoph Hellwig <hch@lst.de> Signed-off-by: Kevin Wolf <kwolf@redhat.com>