Statistics
| Branch: | Revision:

root / hw / ide / atapi.c @ 07a7484e

History | View | Annotate | Download (34.6 kB)

# Date Author Comment
0c6f08b0 11/30/2012 12:33 pm Pavel Hrdina

atapi: make change media detection for guests easier

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"...

ce560dcf 09/12/2012 04:50 pm Ronnie Sahlberg

ATAPI: STARTSTOPUNIT only eject/load media if powercondition is 0

The START STOP UNIT command will only eject/load media if
power condition is zero.

If power condition is !0 then LOEJ and START will be ignored.

From MMC (sbc contains similar wordings too)...

55042b95 07/02/2012 11:18 am Paolo Bonzini

atapi: implement READ DISC INFORMATION

This command is not necessary for CD-ROM and DVD-ROM, but some versions of
udev trip on its absence.

Cc: Kevin Wolf <>
Cc: Markus Armbruster <>
Signed-off-by: Paolo Bonzini <>

d88b1819 02/22/2012 09:23 pm Luiz Capitulino

block: Don't call bdrv_eject() if the tray state didn't change

It's not needed. Besides we can then assume that bdrv_eject() is
only called when there's a tray state change, which is useful to
the DEVICE_TRAY_MOVED event (going to be added in a future
commit)....

ad54ae80 12/15/2011 01:40 pm Paolo Bonzini

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) { ... }...

2c20ae11 11/18/2011 02:54 pm Paolo Bonzini

atapi: kill MODE SENSE, fix MODE SENSE

Mode page 2A of emulated ATAPI DVD-ROM should have page length 0x14
like SCSI CD-ROM, rather than 0x12.

Mode page length is off by 8, as it should contain the length of the
payload after the first two bytes....

2df0a3a3 11/11/2011 03:02 pm Paolo Bonzini

atapi: implement eject requests

Signed-off-by: Paolo Bonzini <>
Signed-off-by: Kevin Wolf <>

67cc61e4 10/28/2011 08:25 pm Paolo Bonzini

atapi/scsi: unify definitions for MMC

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"...

f0f992e6 10/28/2011 08:25 pm Paolo Bonzini

atapi: move GESN definitions to scsi-defs.h

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....

af0e1ea2 10/28/2011 08:25 pm Paolo Bonzini

atapi: cleanup/fix mode sense results

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...

a07c7dcd 10/28/2011 08:25 pm Paolo Bonzini

atapi/scsi-disk: make mode page values coherent between the two

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...

48f65b3f 09/12/2011 04:17 pm Markus Armbruster

ide/atapi: Don't fail eject when tray is already open

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 <>...

dd063333 09/12/2011 04:17 pm Markus Armbruster

ide/atapi: Track tray open/close state

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 <>...

a1aff5bf 09/12/2011 04:17 pm Markus Armbruster

block: Revert entanglement of bdrv_is_inserted() with tray status

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....

a0a7573b 09/12/2011 04:17 pm Markus Armbruster

ide/atapi: Track tray locked state

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 <>
Signed-off-by: Kevin Wolf <>

fdec4404 09/12/2011 04:17 pm Markus Armbruster

block: Leave enforcing tray lock to device models

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 <>...

025e849a 09/12/2011 04:17 pm Markus Armbruster

block: Rename bdrv_set_locked() to bdrv_lock_medium()

While there, make the locked parameter bool.

Signed-off-by: Markus Armbruster <>
Signed-off-by: Kevin Wolf <>

f0776564 09/12/2011 04:17 pm Markus Armbruster

ide/atapi: Clean up misleading name in cmd_start_stop_unit()

"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 <>...

541dc0d4 09/03/2011 01:45 pm Stefan Weil

Use new macro QEMU_PACKED for packed structures

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/'...

a597e79c 08/25/2011 07:18 pm Christoph Hellwig

block: explicit I/O accounting

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...

a7acf552 05/03/2011 12:29 pm Amit Shah

atapi: Move comment to proper place

Move misplaced comment for media_is_dvd()

Signed-off-by: Amit Shah <>
Signed-off-by: Kevin Wolf <>

4a737d14 05/03/2011 12:29 pm Amit Shah

atapi: Explain why we need a 'media not present' state

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 <>...

ab719827 05/03/2011 12:29 pm Alon Levy

ide/atapi: fix set but unused

Signed-off-by: Alon Levy <>
Acked-by: Stefan Weil <>
Signed-off-by: Kevin Wolf <>

7a2c4b82 04/27/2011 05:21 pm Kevin Wolf

ide/atapi: Introduce CHECK_READY flag for commands

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...

a60cf7e7 04/27/2011 05:20 pm Kevin Wolf

ide/atapi: Factor commands out

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 <>

e1a064f9 04/27/2011 05:20 pm Kevin Wolf

ide/atapi: Use table instead of switch for commands

Signed-off-by: Kevin Wolf <>

e119bcac 04/27/2011 05:20 pm Kevin Wolf

ide/atapi: Replace bdrv_get_geometry calls by s->nb_sectors

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 <>

33231e0e 04/27/2011 05:20 pm Kevin Wolf

ide: Split atapi.c out

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 <>