summary refs log tree commit diff stats
path: root/hw/ide/atapi.c (follow)
Commit message (Collapse)AuthorAgeFilesLines
...
* atapi: implement eject requestsPaolo Bonzini2011-11-111-3/+8
| | | | | Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* atapi/scsi-disk: make mode page values coherent between the twoPaolo Bonzini2011-10-281-7/+7
| | | | | | | | | | | | This patch adds to scsi-disk the missing mode page 0x01 for both disk and CD-ROM drives, and mode page 0x0e for CD drives only. A few offsets were wrong in atapi.c. Also change the 2Ah mode page to expose DVD media read capabilities in the IDE cdrom. This lets you run dvd+rw-mediainfo on the virtual DVD drives. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* atapi: cleanup/fix mode sense resultsPaolo Bonzini2011-10-281-4/+6
| | | | | | | | | | | | The first two bytes (after the 8-byte ATAPI header) are the mode page number and the number of bytes after the length field itself. Make this clear in the code. The AUDIO_CTL page was filled with wrong values. It is not anymore in MMC, but at least keep the values sane. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* atapi: move GESN definitions to scsi-defs.hPaolo Bonzini2011-10-281-37/+6
| | | | | | | | | | | As a complement to the previous patch, move definitions for GET EVENT STATUS NOTIFICATION from the two functions to scsi-defs.h. The NCR_* constants are just bit values corresponding to the ENC_* values, with no offsets even, so keep just one copy. Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* atapi/scsi: unify definitions for MMCPaolo Bonzini2011-10-281-26/+26
| | | | | | | | | | | | | | 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>
* ide/atapi: Don't fail eject when tray is already openMarkus Armbruster2011-09-121-1/+1
| | | | | | | | | MMC-5 6.40.2.6 specifies that START STOP UNIT succeeds when the drive already has the requested state. cmd_start_stop_unit() fails when asked to eject while the tray is open and locked. Fix that. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* block: Rename bdrv_set_locked() to bdrv_lock_medium()Markus Armbruster2011-09-121-1/+1
| | | | | | | While there, make the locked parameter bool. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* block: Leave enforcing tray lock to device modelsMarkus Armbruster2011-09-121-20/+9
| | | | | | | | | | 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. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* ide/atapi: Track tray locked stateMarkus Armbruster2011-09-121-1/+3
| | | | | | | | | We already track it in BlockDriverState. Just like tray open/close state, we should track it in the device models instead, because it's device state. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* block: Revert entanglement of bdrv_is_inserted() with tray statusMarkus Armbruster2011-09-121-7/+8
| | | | | | | | | | | | | | | | | | | | | | | | | Commit 4be9762a changed bdrv_is_inserted() to fail when the tray is open. Unfortunately, there are two different kinds of users, with conflicting needs. 1. Device models using bdrv_eject(), currently ide-cd and scsi-cd. They expect bdrv_is_inserted() to reflect the tray status. Commit 4be9762a makes them happy. 2. Code that wants to know whether a BlockDriverState has media, such as find_image_format(), bdrv_flush_all(). Commit 4be9762a makes them unhappy. In particular, it breaks flush on VM stop for media ejected by the guest. Revert the change to bdrv_is_inserted(). Check the tray status in the device models instead. Note on IDE: Since only ATAPI devices have a tray, and they don't accept ATA commands since the recent commit "ide: Reject ATA commands specific to drive kinds", checking in atapi.c suffices. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* ide/atapi: Track tray open/close stateMarkus Armbruster2011-09-121-1/+5
| | | | | | | | | We already track it in BlockDriverState since commit 4be9762a. As discussed in that commit's message, we should track it in the device device models instead, because it's device state. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* ide/atapi: Clean up misleading name in cmd_start_stop_unit()Markus Armbruster2011-09-121-4/+4
| | | | | | | | | "eject" is misleading; it means "eject" when start is clear, but "load" when start is set. Rename to loej, because that's how MMC-5 calls it, in section 6.40. Signed-off-by: Markus Armbruster <armbru@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* Use new macro QEMU_PACKED for packed structuresStefan Weil2011-09-031-2/+2
| | | | | | | | | | | | | | | | | | | | | Most changes were made using these commands: git grep -la '__attribute__((packed))'|xargs perl -pi -e 's/__attribute__\(\(packed\)\)/QEMU_PACKED/' git grep -la '__attribute__ ((packed))'|xargs perl -pi -e 's/__attribute__ \(\(packed\)\)/QEMU_PACKED/' git grep -la '__attribute__((__packed__))'|xargs perl -pi -e 's/__attribute__\(\(__packed__\)\)/QEMU_PACKED/' git grep -la '__attribute__ ((__packed__))'|xargs perl -pi -e 's/__attribute__ \(\(__packed__\)\)/QEMU_PACKED/' git grep -la '__attribute((packed))'|xargs perl -pi -e 's/__attribute\(\(packed\)\)/QEMU_PACKED/' Whitespace in linux-user/syscall_defs.h was fixed manually to avoid warnings from scripts/checkpatch.pl. Manual changes were also applied to hw/pc.c. I did not fix indentation with tabs in block/vvfat.c. The patch will show 4 errors with scripts/checkpatch.pl. Signed-off-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Blue Swirl <blauwirbel@gmail.com>
* block: explicit I/O accountingChristoph Hellwig2011-08-251-9/+20
| | | | | | | | | | | | | | | | | | | | | | | 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>
* ide/atapi: fix set but unusedAlon Levy2011-05-031-3/+1
| | | | | | Signed-off-by: Alon Levy <alevy@redhat.com> Acked-by: Stefan Weil <weil@mail.berlios.de> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* atapi: Explain why we need a 'media not present' stateAmit Shah2011-05-031-1/+7
| | | | | | | | | After the re-org of the atapi code, it might not be intuitive for a reader of the code to understand why we're inserting a 'media not present' state between cd changes. Signed-off-by: Amit Shah <amit.shah@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* atapi: Move comment to proper placeAmit Shah2011-05-031-1/+1
| | | | | | | Move misplaced comment for media_is_dvd() Signed-off-by: Amit Shah <amit.shah@redhat.com> Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* ide/atapi: Introduce CHECK_READY flag for commandsKevin Wolf2011-04-271-25/+23
| | | | | | | | | | | | Some commands are supposed to report a Not Ready Condition (i.e. they require a medium to be present in order to execute successfully). Instead of duplicating the check in each command implementation, let's add a flag and check it before calling the command. This patch only converts existing checks, it does not introduce new checks for any of the other commands that can/should report a Not Ready Condition. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* ide/atapi: Replace bdrv_get_geometry calls by s->nb_sectorsKevin Wolf2011-04-271-15/+6
| | | | | | | The disk size can only change when the medium is changed, and the change callback takes care of updating s->nb_sectors in this case. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* ide/atapi: Use table instead of switch for commandsKevin Wolf2011-04-271-67/+48
| | | | Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* ide/atapi: Factor commands outKevin Wolf2011-04-271-378/+459
| | | | | | | In preparation for a table of function pointers, factor each command out from ide_atapi_cmd() into its own function. Signed-off-by: Kevin Wolf <kwolf@redhat.com>
* ide: Split atapi.c outKevin Wolf2011-04-271-0/+1083
Besides moving code, this patch only fixes some whitespace issues in the moved code and makes all functions in atapi.c static which can be static. Signed-off-by: Kevin Wolf <kwolf@redhat.com>