Statistics
| Branch: | Revision:

root / hw / ide / core.c @ 95b5edcd

History | View | Annotate | Download (55.9 kB)

# Date Author Comment
95b5edcd 05/19/2011 11:26 am Markus Armbruster

blockdev: Store -drive option media in DriveInfo

DriveInfo is closely tied to -drive, and like -drive, it mixes
information about host and guest part of the block device. Unlike
DriveInfo, BlockDriverState should be about the host part only.

One of the remaining guest bits there is the "type hint". -drive...

1f56e32a 05/19/2011 11:26 am Markus Armbruster

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 the
associated BlockDriverState's type hint. Unclean; disk vs. CD belongs
to the guest part, not the host part.

Have separate qdevs "ide-hd" and "ide-cd" to model disk vs. CD in...

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

4b9b7092 04/27/2011 03:36 pm Amit Shah

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_READY
command. Going from medium not ready to medium ready states is
communicated by throwing an error.

This adds the missing 'tray opened' event that we fail to report to...

996faf1a 04/13/2011 01:20 pm Amit Shah

atapi: GESN: implement 'media' subcommand

Implement the 'media' sub-command of the GET_EVENT_STATUS_NOTIFICATION
command. This helps us report tray open, tray closed, no media, media
present states to the guest.

Newer Linux kernels (2.6.38+) rely on this command to revalidate discs...

0af63ba3 04/13/2011 01:20 pm Amit Shah

atapi: GESN: Standardise event response handling for future additions

Handle GET_EVENT_STATUS_NOTIFICATION's No Event Available response in a
generic way so that future additions to the code to handle other
response types is easier.

Signed-off-by: Amit Shah <>...

8f8e834d 04/13/2011 01:20 pm Amit Shah

atapi: GESN: Use structs for commonly-used field types

Instead of using magic numbers, use structs that are more descriptive of
the fields being used.

Signed-off-by: Amit Shah <>
Acked-by: Jes Sorensen <>
Acked-by: Paolo Bonzini <>...

493accd6 04/13/2011 01:20 pm Amit Shah

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

Signed-off-by: Amit Shah <>...

0c370a35 04/13/2011 01:19 pm Amit Shah

atapi: Allow GET_EVENT_STATUS_NOTIFICATION after media change

After a media change, the only commands allowed from the guest were
REQUEST_SENSE and INQUIRY. The guest may also issue
GET_EVENT_STATUS_NOTIFICATION commands to get media
changed notification....

8aa71917 04/13/2011 01:06 pm Amit Shah

atapi: Drives can be locked without media present

Drivers are free to lock drives without any media present. Such a
condition should not result in an error condition.

See Table 341 in MMC-5 spec for details.

Signed-off-by: Amit Shah <>...

88f2bb58 04/13/2011 01:06 pm Amit Shah

atapi: Report correct errors on guest eject request

Table 629 of the MMC-5 spec mentions two different error conditions when
a CDROM eject is requested: a) while a disc is inserted and b) while a
disc is not inserted.

Ensure we return the appropriate error for the present condition of the...

75717903 04/07/2011 02:51 pm Isaku Yamahata

ide: consolidate drive_get(IF_IDE)

factor out ide initialization to call drive_get(IF_IDE)

Signed-off-by: Isaku Yamahata <>
Signed-off-by: Kevin Wolf <>

aa315f95 03/21/2011 10:28 pm Aurelien Jarno

Merge branch 'for-anthony' of git://github.com/bonzini/qemu

  • 'for-anthony' of git://github.com/bonzini/qemu:
    remove qemu_get_clock
    add a generic scaling mechanism for timers
    change all other clock references to use nanosecond resolution accessors
    change all rt_clock references to use millisecond resolution accessors...
74475455 03/21/2011 10:23 am Paolo Bonzini

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\>' )...
b93af93d 03/15/2011 02:21 pm Brian Wheeler

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 as
offline. Error is now explicitly set to zero.

2) SMART

The smart values that were returned were invalid and tools like skdump...

e07bbac5 02/14/2011 04:39 pm Jan Kiszka

Improve vm_stop reason declarations

Define and use dedicated constants for vm_stop reasons, they actually
have nothing to do with the EXCP_* defines used so far. At this chance,
specify more detailed reasons so that VM state change handlers can
evaluate them....

db97ee6a 01/31/2011 11:03 am Christoph Hellwig

block: tell drivers about an image resize

Extend the change_cb callback with a reason argument, and use it
to tell drivers about size changes.

Signed-off-by: Christoph Hellwig <>
Signed-off-by: Kevin Wolf <>

596bb44d 01/24/2011 12:08 pm Christoph Hellwig

ide: also reset io_buffer_index for writes

Currenly the code only resets the io_buffer_index field for reads,
but the code seems to expect this for all types of I/O. I guess
we simply don't hit large enough transfers that would require this
often enough....

c641483f 01/24/2011 12:08 pm Christoph Hellwig

ide: kill ide_dma_submit_check

Merge ide_dma_submit_check into it's only caller. Also use tail recursion
using a goto instead of a real recursion - this avoid overflowing the
stack in the pathological situation of an recurring error that is ignored.
We'll still be busy looping in ide_dma_cb, but at least won't eat up...

cd369c46 01/24/2011 12:08 pm Christoph Hellwig

ide: factor dma handling helpers

Factor the DMA I/O path that is duplicated between read and write
commands, into common helpers using the s->is_read flag added for
the macio ATA controller.

Signed-off-by: Christoph Hellwig <>
Signed-off-by: Kevin Wolf <>

1bdaa28d 12/17/2010 05:11 pm Alexander Graf

ide: honor ncq for atapi

ATAPI also can do ncq, so let's expose the capability.

This patch makes CD-ROM support work on Windows 7 for me.

Signed-off-by: Alexander Graf <>
Signed-off-by: Kevin Wolf <>

ccf0fd8b 12/17/2010 05:11 pm Roland Elek

ide: add ncq identify data for ahci sata drives

I modified ide_identify() to include the zero-based queue length
value in word 75, and set bit 8 in word 76 to signal NCQ support
in the identify data for AHCI SATA drives.

Signed-off-by: Roland Elek <>...

40a6238a 12/17/2010 05:11 pm Alexander Graf

ide: Split out BMDMA code from ATA core

The ATA core is currently heavily intertwined with BMDMA code. Let's loosen
that a bit, so we can happily replace the DMA backend with different
implementations.

Signed-off-by: Alexander Graf <>
Signed-off-by: Kevin Wolf <>

2ff61ff1 12/17/2010 05:11 pm Alexander Graf

ide: move transfer_start after variable modification

We hook into transfer_start and immediately call the end function
for ahci. This means that everything needs to be in place for the
end function when we start the transfer, so let's move the function
down to where all state is in place....

7cff87ff 12/17/2010 05:11 pm Alexander Graf

ide: split ide command interpretation off

The ATA command interpretation code can be used for PATA and SATA
interfaces alike. So let's split it out into a separate function.

Signed-off-by: Alexander Graf <>
Signed-off-by: Kevin Wolf <>

6ef2ba5e 12/17/2010 05:11 pm Alexander Graf

ide: fix whitespace gap in ide_exec_cmd

Now that we have the function split out, we have to reindent it.
In order to increase the readability of the actual functional change,
this is split out.

Signed-off-by: Alexander Graf <>
Signed-off-by: Kevin Wolf <>

8337606d 11/29/2010 05:15 pm Kevin Wolf

ide: Factor ide_dma_set_inactive out

Several places that stop a DMA transfer duplicate this code. Factor it out into
a common function.

Signed-off-by: Kevin Wolf <>
Reviewed-by: Stefan Hajnoczi <>

e3982b3c 11/29/2010 05:15 pm Kevin Wolf

ide: Set bus master inactive on error

BMIDEA in the status register must be cleared on error. This makes FreeBSD
respond (more) correctly to I/O errors.

Signed-off-by: Kevin Wolf <>
Reviewed-by: Stefan Hajnoczi <>

b2df7531 11/04/2010 02:54 pm Kevin Wolf

ide: Handle immediate bdrv_aio_flush failure

If bdrv_aio_flush returns NULL, this should be treated as an error.

Signed-off-by: Kevin Wolf <>

a58b8d54 10/22/2010 03:49 pm Christoph Hellwig

ide: set WCACHE supported in IDENTIFY data

ATA does not only have the WCACHE enabled bit in identify word 85, but also
a WCACHE supported bit in word 82. While the Linux kernel is fine with the
latter at least hdparm also needs the former before correctly displaying...

6bcb1a79 10/22/2010 03:49 pm Kevin Wolf

ide: Factor ide_flush_cache out

The next patch reuses this code, so put it in its own function.

Signed-off-by: Kevin Wolf <>

e2bcadad 10/22/2010 03:49 pm Kevin Wolf

ide: Handle flush failure

Instead of always assuming success for bdrv_aio_flush, actually do something
with the error. This respects the werror option and accordingly ignores the
error, reports it to the guest or stops the VM and retries after cont.

Ignoring the error is trivial, obviously. For stopping the VM and retrying...

1b2adf28 09/21/2010 04:39 pm Christoph Hellwig

ide: propagate the required alignment

IDE is a bit ugly in this respect. For one it doesn't really keep track
of a sector size - most of the protocol is in units of 512 bytes, and we
assume 2048 bytes for CDROMs which is correct most of the time.

Second IDE allocates an I/O buffer long before we know if we're dealing...

79d1d331 09/08/2010 01:39 pm Jonathan A. Kollasch

Improve ATA IDENTIFY word 64 contents.

Fill in word 64 of IDENTIFY data to indicate support for PIO modes 3 and 4.
This allows NetBSD guests to use UltraDMA modes instead of just PIO mode 0.

Signed-off-by: Jonathan A. Kollasch <>
Signed-off-by: Kevin Wolf <>

2446333c 08/24/2010 06:22 pm Blue Swirl

Rearrange block headers

Changing block.h or blockdev.h resulted in recompiling most objects.

Move DriveInfo typedef and BlockInterfaceType enum definitions
to qemu-common.h and rearrange blockdev.h use to decrease churn.

Signed-off-by: Blue Swirl <>

cdc6f542 07/30/2010 10:12 pm Aurelien Jarno

Merge branch 'for-anthony' of git://repo.or.cz/qemu/kevin

  • 'for-anthony' of git://repo.or.cz/qemu/kevin:
    Fix -snapshot deleting images on disk change
    block: Use error codes from lower levels for error message
    block: default to 0 minimal / optiomal I/O size...
7bccf573 07/27/2010 06:32 pm Blue Swirl

Fix uint8_t comparisons with negative values

Fix the following warnings:
/src/qemu/hw/ide/core.c: In function `ide_drive_pio_post_load':
/src/qemu/hw/ide/core.c:2767: warning: comparison is always false due to limited range of data type

/src/qemu/ui/vnc-enc-tight.c: In function `tight_detect_smooth_image':...

50641c5c 07/27/2010 12:19 am Juan Quintela

ide: fix migration in the middle of pio operation

Signed-off-by: Juan Quintela <>
Signed-off-by: Anthony Liguori <>

3abb6260 07/27/2010 12:19 am Juan Quintela

Revert "ide save/restore pio/atapi cmd transfer fields and io buffer"

This reverts commit ed487bb1d69040b9dac64a4fc076d8dd82b131d6.

The conflicts are due to commit 4fc8d6711aff7a9c11e402c3d77b481609f9f486
that is a fix to the ide_drive_pre_save() function. It reverts both...

253cb7b9 07/26/2010 02:39 pm Aurelien Jarno

ide/atapi: add support for GET EVENT STATUS NOTIFICATION

The GET EVENT STATUS NOTIFICATION is a mandatory command according
to MMC-3, even if event status notification is not supported.

This patch adds support for this command. It returns NEA ("No Event...

98f28ad7 07/13/2010 06:48 pm Markus Armbruster

ide scsi virtio-blk: Reject empty drives unless media is removable

Disks without media make no sense. For SCSI, a Linux guest kernel
complains during boot. I didn't try other combinations.

scsi-generic doesn't need the additional check, because it already...

7aa9c811 07/06/2010 06:05 pm Markus Armbruster

ide: Reject readonly drives unless CD-ROM

drive_init() doesn't permit option readonly for if=ide, but that's
worthless: we get it via if=none and -device.

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

dce9e928 07/06/2010 06:05 pm Markus Armbruster

ide: Reject invalid CHS geometry

drive_init() doesn't permit invalid CHS for if=ide, but that's
worthless: we get it via if=none and -device.

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

cd8722bb 07/06/2010 06:05 pm Markus Armbruster

ide: Replace IDEState members is_cdrom, is_cf by drive_kind

The two aren't independent variables. Make that obvious.

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

c4d74df7 07/06/2010 06:05 pm Markus Armbruster

ide: Make ide_init_drive() return success

It still always succeeds. The next commits will add failures.

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

f8b6cc00 07/02/2010 02:18 pm Markus Armbruster

qdev: Decouple qdev_prop_drive from DriveInfo

Make the property point to BlockDriverState, cutting out the DriveInfo
middleman. This prepares the ground for block devices that don't have
a DriveInfo.

Currently all user-defined ones have a DriveInfo, because the only way...

7d0d6950 07/02/2010 02:18 pm Markus Armbruster

block: Fix virtual media change for if=none

BlockDriverState member removable controls whether virtual media
change (monitor commands change, eject) is allowed. It is set when
the "type hint" is BDRV_TYPE_CDROM or BDRV_TYPE_FLOPPY.

The type hint is only set by drive_init(). It sets BDRV_TYPE_FLOPPY...

abd7f68d 06/15/2010 10:41 am Markus Armbruster

block: Move error actions from DriveInfo to BlockDriverState

That's where they belong semantically (block device host part), even
though the actions are actually executed by guest device code.

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

666daa68 06/04/2010 04:20 pm Markus Armbruster

blockdev: Collect block device code in new blockdev.c

Anything that moves hundreds of lines out of vl.c can't be all bad.

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

57dac7ef 06/04/2010 12:43 pm Markus Armbruster

ide: Remove redundant IDEState member conf

Commit 428c149b added IDEState member conf to let commit 0009baf1 find
the BlockConf from there. It exists only for qdev drives, created via
ide_drive_initfn(), not for drives created via ide_init2().

But for a qdev drive, we can just as well reach its IDEDevice, which...

d459da0e 06/04/2010 12:43 pm Markus Armbruster

ide: Split ide_init1() off ide_init2()

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

870111c8 06/04/2010 12:43 pm Markus Armbruster

ide: Change ide_init_drive() to require valid dinfo argument

IDEState members drive_serial_str and version are now left empty until
an actual drive is connected. Before, they got a default value that
was overwritten when a drive got connected. Doesn't matter, because...

57234ee4 06/04/2010 12:43 pm Markus Armbruster

ide: Split non-qdev code off ide_init2()

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

6ced55a5 06/04/2010 12:43 pm Markus Armbruster

ide: Turn drive serial into a qdev property ide-drive.serial

It needs to be a qdev property, because it belongs to the drive's
guest part.

Bonus: info qtree now shows the serial number.

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

38d8dfa1 05/17/2010 11:20 am Kevin Wolf

ide: Fix ide_dma_cancel

When cancelling a request, bdrv_aio_cancel may decide that it waits for
completion of a request rather than for cancellation. IDE therefore can't
abandon its DMA status before calling bdrv_aio_cancel; otherwise the callback
of a completed request would use invalid data....

117e1e82 05/14/2010 10:32 pm Blue Swirl

ide: make a table 'const'

Signed-off-by: Blue Swirl <>

6450a334 03/27/2010 08:58 am Blue Swirl

Fix build

Actually some systems don't define PAGE_SIZE. Fixes build breakage
by f7736b91c40a617e93505e32dcbd2cb56aad8a23.

Signed-off-by: Blue Swirl <>

f7736b91 03/27/2010 08:20 am Blue Swirl

Compile ide/core only once

Make win2k install hack unconditional as it is still restricted to
x86 only in vl.c.

Replace TARGET_PAGE_SIZE and 4096 with PAGE_SIZE.

Signed-off-by: Blue Swirl <>

554a310b 03/08/2010 07:30 pm Luiz Capitulino

block: Emit BLOCK_IO_ERROR before vm_stop() call

The next commit will move the STOP event into do_vm_stop(), to
have the expected event sequence we need to emit the I/O error
event before calling vm_stop().

The expected sequence is:

{ "event": "BLOCK_IO_ERROR" [...] }...

4fc8d671 02/20/2010 10:29 am Blue Swirl

Fix warning on mingw32

/src/qemu/hw/ide/core.c: In function 'ide_drive_pre_save':
/src/qemu/hw/ide/core.c:2740: warning: comparison is always false due to limited range of data type

Signed-off-by: Blue Swirl <>

ed487bb1 02/19/2010 11:33 pm Marcelo Tosatti

ide save/restore pio/atapi cmd transfer fields and io buffer

Save/restore information necessary to continue in progress PIO/ATAPI CMD
transfers.

This includes the IO buffer.

Signed-off-by: Marcelo Tosatti <>
Signed-off-by: Anthony Liguori <>

0009baf1 02/11/2010 12:53 am Christoph Hellwig

ide: add topology support

Export the physical block size in the ATA IDENTIFY command. The
other topology values are not supported in ATA so skip them.

Signed-off-by: Christoph Hellwig <>
Signed-off-by: Anthony Liguori <>

428c149b 02/11/2010 12:53 am Christoph Hellwig

block: add topology qdev properties

Add three new qdev properties to export block topology information to
the guest. This is needed to get optimal I/O alignment for RAID arrays
or SSDs.

The options are:

- physical_block_size to specify the physical block size of the device,...
7ad7e3c3 02/10/2010 07:57 pm Luiz Capitulino

ide: Generate BLOCK_IO_ERROR QMP event

Just call bdrv_mon_event() in the right place.

Signed-off-by: Luiz Capitulino <>
Signed-off-by: Anthony Liguori <>

47c06340 01/20/2010 12:31 am Gerd Hoffmann

ide: device version property

This patch adds a new property named 'ver' to ide-drive which allows to
specify the version which the virtual disk/cdrom should report to the
guest. By default this is the qemu version (i.e. 0.12). usage:

-drive if=none,id=disk,file=......
a70089ce 12/03/2009 11:26 pm Thadeu Lima de Souza Cascardo

ide: Use some already defined page macros instead of constants

Some PAGE constants were used instead of the macros we already have
defined in internal.h.

Signed-off-by: Thadeu Lima de Souza Cascardo <>
Signed-off-by: Anthony Liguori <>

fe0d6123 12/03/2009 11:26 pm Thadeu Lima de Souza Cascardo

ide: implement stub for audio control/volume read

This implements the audio control or volume read support as needed by
some systems. A Conectiva Parolin system required this to detect an IDE
device as CD-ROM, through the CDVOLREAD ioctl.

Signed-off-by: Thadeu Lima de Souza Cascardo <>...

f7850099 12/03/2009 07:45 pm Kevin Wolf

Rename DriveInfo.onerror to on_write_error

Either rename variables and functions to refer to write errors (which is what
they actually do) or introduce a parameter to distinguish reads and writes.

Signed-off-by: Kevin Wolf <>
Signed-off-by: Anthony Liguori <>

ce4b6522 12/03/2009 07:45 pm Kevin Wolf

ide: Implement rerror option

Signed-off-by: Kevin Wolf <>
Signed-off-by: Anthony Liguori <>

43b443b6 11/09/2009 04:43 pm Gerd Hoffmann

scsi: move scsi-disk.h -> scsi.h

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Anthony Liguori <>

4a643563 11/07/2009 04:13 pm Blue Swirl

IDE: Fix reset handling

Problem: x86 systems could not survive a few system_resets.

Clear most of IDE state when reset. Implement the missing reset handlers.

Signed-off-by: Blue Swirl <>

b3a7d328 10/27/2009 07:28 pm Juan Quintela

ide: pre VMState functions are not needed anymore

Signed-off-by: Juan Quintela <>
Signed-off-by: Anthony Liguori <>

37159f13 10/27/2009 07:28 pm Juan Quintela

ide: port ide_drive to vmstate

Signed-off-by: Juan Quintela <>
Signed-off-by: Anthony Liguori <>

6521dc62 10/27/2009 07:28 pm Juan Quintela

ide: port idebus to vmstate

Signed-off-by: Juan Quintela <>
Signed-off-by: Anthony Liguori <>

96c35ceb 10/27/2009 07:28 pm Juan Quintela

ide: change identify_data type to uint8_t

It is used everywhere as uint8_t except in one place. Cast to uint16_t
in that place
Signed-off-by: Juan Quintela <>
Signed-off-by: Anthony Liguori <>

88804180 09/15/2009 10:23 pm Gerd Hoffmann

split away drive init from ide_init2()

This allows the ide bus being initialized without drives attached
and the drives being attached and initialization later on as
separate step.

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Blue Swirl <>

6ee093c9 09/11/2009 06:19 pm Juan Quintela

Unexport ticks_per_sec variable. Create get_ticks_per_sec() function

Signed-off-by: Juan Quintela <>
Signed-off-by: Anthony Liguori <>

e900a7b7 09/11/2009 06:19 pm Christoph Hellwig

block: add enable_write_cache flag

Add a enable_write_cache flag in the block driver state, and use it to
decide if we claim to have a volatile write cache that needs controlled
flushing from the guest. The flag is off if cache=writethrough is
defined because O_DSYNC guarantees that every write goes to stable...

b0484ae4 09/11/2009 06:19 pm Christoph Hellwig

ide: use bdrv_aio_flush

Signed-off-by: Christoph Hellwig <>
Signed-off-by: Anthony Liguori <>

f455e98c 09/04/2009 05:37 pm Gerd Hoffmann

ide: pass down DriveInfo instead of BlockDriverState

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Anthony Liguori <>

9cdd03a7 09/04/2009 05:37 pm Gerd Hoffmann

ide: move cmd+irq from IDEState to IDEBus.

These variables are per bus, not per drive. Lets move them and
cleanup things a bit. And fix the cmd migration bug for real.

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Anthony Liguori <>

59f2a787 08/28/2009 04:46 am Gerd Hoffmann

ide: move code to hw/ide/

Signed-off-by: Gerd Hoffmann <>
Signed-off-by: Anthony Liguori <>