tests/qtest/libqos/ahci: support raw (2352-byte) READ CD

ahci_exec() always builds ATAPI commands with a 2048-byte logical
sector size, so it cannot drive a READ CD that returns full 2352-byte
raw sectors. Add an atapi_raw option that sets the READ CD
field-selector to 0xf8 and the command's sector size to 2352 before
the transfer is sized, so the derived block count stays correct while
the buffer and byte counts cover the raw sectors.

Signed-off-by: Denis V. Lunev <den@openvz.org>
This commit is contained in:
Denis V. Lunev 2026-06-19 02:29:11 +02:00
parent 502dbdfd96
commit de86ef3dfd
2 changed files with 7 additions and 0 deletions

View file

@ -707,6 +707,11 @@ void ahci_exec(AHCIQState *ahci, uint8_t port,
if (opts->atapi) {
uint16_t bcl = opts->set_bcl ? opts->bcl : ATAPI_SECTOR_SIZE;
cmd = ahci_atapi_command_create(op, bcl, opts->atapi_dma);
if (opts->atapi_raw) {
/* request full 2352-byte raw sectors; sector_size must match */
cmd->atapi_cmd[9] = 0xf8;
cmd->sector_size = ATAPI_RAW_SECTOR_SIZE;
}
} else {
cmd = ahci_command_create(op);
}

View file

@ -242,6 +242,7 @@
#define AHCI_SECTOR_SIZE (512)
#define ATAPI_SECTOR_SIZE (2048)
#define ATAPI_RAW_SECTOR_SIZE (2352)
#define AHCI_SIGNATURE_CDROM (0xeb140101)
#define AHCI_SIGNATURE_DISK (0x00000101)
@ -485,6 +486,7 @@ typedef struct AHCIOpts {
uint64_t buffer; /* Pointer to source or destination guest buffer */
bool atapi; /* ATAPI command? */
bool atapi_dma; /* Use DMA for ATAPI? */
bool atapi_raw; /* READ CD returning 2352-byte raw sectors */
bool error;
int (*pre_cb)(AHCIQState*, AHCICommand*, const struct AHCIOpts *);
int (*mid_cb)(AHCIQState*, AHCICommand*, const struct AHCIOpts *);