From: Stefan Hajnoczi <stefanha@redhat.com>
To: qemu-devel@nongnu.org
Cc: Peter Maydell <peter.maydell@linaro.org>,
John Snow <jsnow@redhat.com>,
Stefan Hajnoczi <stefanha@redhat.com>
Subject: [Qemu-devel] [PULL 60/69] qtest/ahci: test different disk sectors
Date: Fri, 27 Feb 2015 18:18:58 +0000 [thread overview]
Message-ID: <1425061147-1411-61-git-send-email-stefanha@redhat.com> (raw)
In-Reply-To: <1425061147-1411-1-git-send-email-stefanha@redhat.com>
From: John Snow <jsnow@redhat.com>
Test sector offset 0, 1, and the last sector(s)
in LBA28 and LBA48 modes.
Signed-off-by: John Snow <jsnow@redhat.com>
Message-id: 1424905602-24715-9-git-send-email-jsnow@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
---
tests/ahci-test.c | 68 +++++++++++++++++++++++++++++++++++++++++++----------
tests/libqos/ahci.c | 10 ++++----
tests/libqos/ahci.h | 4 ++--
3 files changed, 63 insertions(+), 19 deletions(-)
diff --git a/tests/ahci-test.c b/tests/ahci-test.c
index 3f93c15..fb4739f 100644
--- a/tests/ahci-test.c
+++ b/tests/ahci-test.c
@@ -41,6 +41,8 @@
/* Test-specific defines -- in MiB */
#define TEST_IMAGE_SIZE_MB (200 * 1024)
+#define TEST_IMAGE_SECTORS ((TEST_IMAGE_SIZE_MB / AHCI_SECTOR_SIZE) \
+ * 1024 * 1024)
/*** Globals ***/
static char tmp_path[] = "/tmp/qtest.XXXXXX";
@@ -712,7 +714,7 @@ static void ahci_test_identify(AHCIQState *ahci)
ahci_port_clear(ahci, px);
/* "Read" 512 bytes using CMD_IDENTIFY into the host buffer. */
- ahci_io(ahci, px, CMD_IDENTIFY, &buff, buffsize);
+ ahci_io(ahci, px, CMD_IDENTIFY, &buff, buffsize, 0);
/* Check serial number/version in the buffer */
/* NB: IDENTIFY strings are packed in 16bit little endian chunks.
@@ -728,11 +730,12 @@ static void ahci_test_identify(AHCIQState *ahci)
g_assert_cmphex(rc, ==, 0);
sect_size = le16_to_cpu(*((uint16_t *)(&buff[5])));
- g_assert_cmphex(sect_size, ==, 0x200);
+ g_assert_cmphex(sect_size, ==, AHCI_SECTOR_SIZE);
}
static void ahci_test_io_rw_simple(AHCIQState *ahci, unsigned bufsize,
- uint8_t read_cmd, uint8_t write_cmd)
+ uint64_t sector, uint8_t read_cmd,
+ uint8_t write_cmd)
{
uint64_t ptr;
uint8_t port;
@@ -758,9 +761,9 @@ static void ahci_test_io_rw_simple(AHCIQState *ahci, unsigned bufsize,
memwrite(ptr, tx, bufsize);
/* Write this buffer to disk, then read it back to the DMA buffer. */
- ahci_guest_io(ahci, port, write_cmd, ptr, bufsize);
+ ahci_guest_io(ahci, port, write_cmd, ptr, bufsize, sector);
qmemset(ptr, 0x00, bufsize);
- ahci_guest_io(ahci, port, read_cmd, ptr, bufsize);
+ ahci_guest_io(ahci, port, read_cmd, ptr, bufsize, sector);
/*** Read back the Data ***/
memread(ptr, rx, bufsize);
@@ -948,12 +951,45 @@ enum IOOps {
NUM_IO_OPS
};
+enum OffsetType {
+ OFFSET_BEGIN = 0,
+ OFFSET_ZERO = OFFSET_BEGIN,
+ OFFSET_LOW,
+ OFFSET_HIGH,
+ NUM_OFFSETS
+};
+
+static const char *offset_str[NUM_OFFSETS] = { "zero", "low", "high" };
+
typedef struct AHCIIOTestOptions {
enum BuffLen length;
enum AddrMode address_type;
enum IOMode io_type;
+ enum OffsetType offset;
} AHCIIOTestOptions;
+static uint64_t offset_sector(enum OffsetType ofst,
+ enum AddrMode addr_type,
+ uint64_t buffsize)
+{
+ uint64_t ceil;
+ uint64_t nsectors;
+
+ switch (ofst) {
+ case OFFSET_ZERO:
+ return 0;
+ case OFFSET_LOW:
+ return 1;
+ case OFFSET_HIGH:
+ ceil = (addr_type == ADDR_MODE_LBA28) ? 0xfffffff : 0xffffffffffff;
+ ceil = MIN(ceil, TEST_IMAGE_SECTORS - 1);
+ nsectors = buffsize / AHCI_SECTOR_SIZE;
+ return ceil - nsectors + 1;
+ default:
+ g_assert_not_reached();
+ }
+}
+
/**
* Table of possible I/O ATA commands given a set of enumerations.
*/
@@ -981,12 +1017,12 @@ static const uint8_t io_cmds[NUM_MODES][NUM_ADDR_MODES][NUM_IO_OPS] = {
* transfer modes, and buffer sizes.
*/
static void test_io_rw_interface(enum AddrMode lba48, enum IOMode dma,
- unsigned bufsize)
+ unsigned bufsize, uint64_t sector)
{
AHCIQState *ahci;
ahci = ahci_boot_and_enable();
- ahci_test_io_rw_simple(ahci, bufsize,
+ ahci_test_io_rw_simple(ahci, bufsize, sector,
io_cmds[dma][lba48][IO_READ],
io_cmds[dma][lba48][IO_WRITE]);
ahci_shutdown(ahci);
@@ -999,6 +1035,7 @@ static void test_io_interface(gconstpointer opaque)
{
AHCIIOTestOptions *opts = (AHCIIOTestOptions *)opaque;
unsigned bufsize;
+ uint64_t sector;
switch (opts->length) {
case LEN_SIMPLE:
@@ -1017,13 +1054,14 @@ static void test_io_interface(gconstpointer opaque)
g_assert_not_reached();
}
- test_io_rw_interface(opts->address_type, opts->io_type, bufsize);
+ sector = offset_sector(opts->offset, opts->address_type, bufsize);
+ test_io_rw_interface(opts->address_type, opts->io_type, bufsize, sector);
g_free(opts);
return;
}
static void create_ahci_io_test(enum IOMode type, enum AddrMode addr,
- enum BuffLen len)
+ enum BuffLen len, enum OffsetType offset)
{
static const char *arch;
char *name;
@@ -1032,15 +1070,17 @@ static void create_ahci_io_test(enum IOMode type, enum AddrMode addr,
opts->length = len;
opts->address_type = addr;
opts->io_type = type;
+ opts->offset = offset;
if (!arch) {
arch = qtest_get_arch();
}
- name = g_strdup_printf("/%s/ahci/io/%s/%s/%s", arch,
+ name = g_strdup_printf("/%s/ahci/io/%s/%s/%s/%s", arch,
io_mode_str[type],
addr_mode_str[addr],
- buff_len_str[len]);
+ buff_len_str[len],
+ offset_str[offset]);
g_test_add_data_func(name, opts, test_io_interface);
g_free(name);
@@ -1053,7 +1093,7 @@ int main(int argc, char **argv)
const char *arch;
int ret;
int c;
- int i, j, k;
+ int i, j, k, m;
static struct option long_options[] = {
{"pedantic", no_argument, 0, 'p' },
@@ -1102,7 +1142,9 @@ int main(int argc, char **argv)
for (i = MODE_BEGIN; i < NUM_MODES; i++) {
for (j = ADDR_MODE_BEGIN; j < NUM_ADDR_MODES; j++) {
for (k = LEN_BEGIN; k < NUM_LENGTHS; k++) {
- create_ahci_io_test(i, j, k);
+ for (m = OFFSET_BEGIN; m < NUM_OFFSETS; m++) {
+ create_ahci_io_test(i, j, k, m);
+ }
}
}
}
diff --git a/tests/libqos/ahci.c b/tests/libqos/ahci.c
index 14651ff..dbd69b0 100644
--- a/tests/libqos/ahci.c
+++ b/tests/libqos/ahci.c
@@ -568,13 +568,15 @@ inline unsigned size_to_prdtl(unsigned bytes, unsigned bytes_per_prd)
/* Given a guest buffer address, perform an IO operation */
void ahci_guest_io(AHCIQState *ahci, uint8_t port, uint8_t ide_cmd,
- uint64_t buffer, size_t bufsize)
+ uint64_t buffer, size_t bufsize, uint64_t sector)
{
AHCICommand *cmd;
-
cmd = ahci_command_create(ide_cmd);
ahci_command_set_buffer(cmd, buffer);
ahci_command_set_size(cmd, bufsize);
+ if (sector) {
+ ahci_command_set_offset(cmd, sector);
+ }
ahci_command_commit(ahci, cmd, port);
ahci_command_issue(ahci, cmd);
ahci_command_verify(ahci, cmd);
@@ -612,7 +614,7 @@ static AHCICommandProp *ahci_command_find(uint8_t command_name)
/* Given a HOST buffer, create a buffer address and perform an IO operation. */
void ahci_io(AHCIQState *ahci, uint8_t port, uint8_t ide_cmd,
- void *buffer, size_t bufsize)
+ void *buffer, size_t bufsize, uint64_t sector)
{
uint64_t ptr;
AHCICommandProp *props;
@@ -626,7 +628,7 @@ void ahci_io(AHCIQState *ahci, uint8_t port, uint8_t ide_cmd,
memwrite(ptr, buffer, bufsize);
}
- ahci_guest_io(ahci, port, ide_cmd, ptr, bufsize);
+ ahci_guest_io(ahci, port, ide_cmd, ptr, bufsize, sector);
if (props->read) {
memread(ptr, buffer, bufsize);
diff --git a/tests/libqos/ahci.h b/tests/libqos/ahci.h
index 888545d..40e8ca4 100644
--- a/tests/libqos/ahci.h
+++ b/tests/libqos/ahci.h
@@ -523,9 +523,9 @@ void ahci_write_fis(AHCIQState *ahci, RegH2DFIS *fis, uint64_t addr);
unsigned ahci_pick_cmd(AHCIQState *ahci, uint8_t port);
unsigned size_to_prdtl(unsigned bytes, unsigned bytes_per_prd);
void ahci_guest_io(AHCIQState *ahci, uint8_t port, uint8_t ide_cmd,
- uint64_t gbuffer, size_t size);
+ uint64_t gbuffer, size_t size, uint64_t sector);
void ahci_io(AHCIQState *ahci, uint8_t port, uint8_t ide_cmd,
- void *buffer, size_t bufsize);
+ void *buffer, size_t bufsize, uint64_t sector);
/* Command Lifecycle */
AHCICommand *ahci_command_create(uint8_t command_name);
--
2.1.0
next prev parent reply other threads:[~2015-02-27 18:21 UTC|newest]
Thread overview: 78+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-02-27 18:17 [Qemu-devel] [PULL 00/69] Block patches Stefan Hajnoczi
2015-02-27 18:17 ` [Qemu-devel] [PULL 01/69] coroutine: Fix use after free with qemu_coroutine_yield() Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 02/69] coroutine: Clean up qemu_coroutine_enter() Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 03/69] test-coroutine: Regression test for yield bug Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 04/69] vpc: Fix size in fixed image creation Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 05/69] vpc: Implement bdrv_co_get_block_status() Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 06/69] sheepdog: selectable object size support Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 07/69] block/raw-posix: fix compilation warning on OSX Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 08/69] qcow2: Remove unused struct QCowCreateState Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 09/69] virtio-blk: Check return value of blk_aio_ioctl Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 10/69] libqos: Change use of pointers to uint64_t in virtio Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 11/69] tests: Prepare virtio-blk-test for multi-arch implementation Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 12/69] libqos: Remove PCI assumptions in constants of virtio driver Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 13/69] libqos: Add malloc generic Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 14/69] libqos: Add virtio MMIO support Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 15/69] qcow2: Add two new fields to BDRVQcowState Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 16/69] qcow2: Add refcount_bits to format-specific info Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 17/69] qcow2: Do not return new value after refcount update Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 18/69] qcow2: Only return status from qcow2_get_refcount Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 19/69] qcow2: Use unsigned addend for update_refcount() Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 20/69] qcow2: Use 64 bits for refcount values Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 21/69] qcow2: Helper for refcount array reallocation Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 22/69] qcow2: Helper function for refcount modification Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 23/69] qcow2: More helpers " Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 24/69] qcow2: Open images with refcount order != 4 Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 25/69] qcow2: refcount_order parameter for qcow2_create2 Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 26/69] qcow2: Use symbolic macros in qcow2_amend_options Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 27/69] iotests: Prepare for refcount_bits option Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 28/69] qcow2: Allow creation with refcount order != 4 Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 29/69] iotests: Add test for different refcount widths Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 30/69] blkdebug: fix "once" rule Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 31/69] block: add bdrv functions for geometry and blocksize Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 32/69] raw-posix: Factor block size detection out of raw_probe_alignment() Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 33/69] block: Add driver methods to probe blocksizes and geometry Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 34/69] block-backend: Add wrappers for blocksizes and geometry probing Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 35/69] BlockConf: Call backend functions to detect geometry and blocksizes Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 36/69] ide: start extracting ide_restart_dma out of bmdma_restart_dma Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 37/69] ide: prepare to move restart to common code Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 38/69] ide: introduce ide_register_restart_cb Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 39/69] ide: do not use BMDMA in restart callback Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 40/69] ide: pass IDEBus to the restart_cb Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 41/69] ide: move restart callback to common code Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 42/69] ide: remove restart_cb callback Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 43/69] ide: replace set_unit callback with more IDEBus state Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 44/69] ide: place initial state of the current request to IDEBus Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 45/69] ide: migrate initial request state via IDEBus Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 46/69] ide: commonize io_buffer_index initialization Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 47/69] ide: make more functions static Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 48/69] ide: support PIO restart for the ISA controller Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 49/69] ahci: Migrate IDEStatus Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 50/69] ahci: add support for restarting non-queued commands Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 51/69] ahci: Recompute cur_cmd on migrate post load Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 52/69] qtest/ide: Test flush / retry for ISA and PCI Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 53/69] libqos/ahci: Zero-fill AHCI headers Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 54/69] qtest/ahci: Add a macro bootup routine Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 55/69] libqos/ahci: add ahci command helpers Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 56/69] qtest/ahci: Add DMA test variants Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 57/69] qtest/ahci: Add PIO and LBA48 tests Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 58/69] qtest/ahci: add fragmented dma test Stefan Hajnoczi
2015-02-27 18:18 ` [Qemu-devel] [PULL 59/69] qtest/ahci: add qcow2 support to ahci-test Stefan Hajnoczi
2015-02-27 18:18 ` Stefan Hajnoczi [this message]
2015-02-27 18:18 ` [Qemu-devel] [PULL 61/69] qtest/ahci: Add simple flush test Stefan Hajnoczi
2015-02-27 18:19 ` [Qemu-devel] [PULL 62/69] qtest/ahci: Allow override of default CLI options Stefan Hajnoczi
2015-02-27 18:19 ` [Qemu-devel] [PULL 63/69] libqtest: add qmp_eventwait Stefan Hajnoczi
2015-02-27 18:19 ` [Qemu-devel] [PULL 64/69] libqtest: add qmp_async Stefan Hajnoczi
2015-02-27 18:19 ` [Qemu-devel] [PULL 65/69] libqos: add blkdebug_prepare_script Stefan Hajnoczi
2015-02-27 18:19 ` [Qemu-devel] [PULL 66/69] qtest/ahci: add flush retry test Stefan Hajnoczi
2015-02-27 18:19 ` [Qemu-devel] [PULL 67/69] sheepdog: fix confused return values Stefan Hajnoczi
2015-02-27 18:19 ` [Qemu-devel] [PULL 68/69] libqos: Solve bug in interrupt checking when using MSIX in virtio-pci.c Stefan Hajnoczi
2015-02-27 18:19 ` [Qemu-devel] [PULL 69/69] tests: Check QVIRTIO_F_ANY_LAYOUT flag in virtio-blk test Stefan Hajnoczi
2015-02-27 18:57 ` [Qemu-devel] [PULL 00/69] Block patches Stefan Hajnoczi
2015-03-03 14:52 ` Peter Maydell
2015-03-03 17:29 ` Christian Borntraeger
2015-03-03 17:33 ` Max Reitz
2015-03-04 8:28 ` Christian Borntraeger
2015-03-04 12:03 ` Kevin Wolf
2015-03-04 16:32 ` Stefan Hajnoczi
2015-03-08 8:49 ` Peter Maydell
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1425061147-1411-61-git-send-email-stefanha@redhat.com \
--to=stefanha@redhat.com \
--cc=jsnow@redhat.com \
--cc=peter.maydell@linaro.org \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).