Ide patches
The following changes since commit a9392bc93c8615ad1983047e9f91ee3fa8aae75f:
Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (2015-04-28 16:55:03 +0100)
are available in the git repository at:
https://github.com/jnsnow/qemu.git tags/ide-pull-request
for you to fetch changes up to c8368674980b299604e3cfe9215c4105acefa516:
qtest: Add assertion that required environment variable is set (2015-04-28 15:27:51 -0400)
----------------------------------------------------------------
----------------------------------------------------------------
Ed Maste (1):
qtest: Add assertion that required environment variable is set
Hervé Poussineau (1):
fdc: remove sparc sun4m mutations
John Snow (8):
qtest/ahci: add qcow2 support to ahci-test qtest/ahci: test different disk sectors qtest/ahci: Add simple flush test qtest/ahci: Allow override of default CLI options
libqtest: add qmp_eventwait
libqtest: add qmp_async
libqos: add blkdebug_prepare_script qtest/ahci: add flush retry test
hw/block/fdc.c | 17 ---- tests/Makefile | 1 + tests/ahci-test.c | 221 ++++++++++++++++++++++++++++++++++++++--------- tests/ide-test.c | 34 +------- tests/libqos/ahci.c | 10 ++- tests/libqos/ahci.h | 4 +- tests/libqos/libqos-pc.c | 5 ++ tests/libqos/libqos-pc.h | 1 + tests/libqos/libqos.c | 66 ++++++++++++++ tests/libqos/libqos.h | 3 + tests/libqtest.c | 47 +++++++++- tests/libqtest.h | 47 ++++++++++ 12 files changed, 359 insertions(+), 97 deletions(-)
Signature · 1 line
2.1.0
[Qemu-devel] [PULL 01/10] fdc: remove sparc sun4m mutations
From: Hervé Poussineau <[email protected]>
They were introduced in 6f7e9aec5eb5bdfa57a9e458e391b785c283a007 and 82407d1a4035e5bfefb53ffdcb270872f813b34c and lots of bug fixes were done after that.
This fixes (at least) the detection of the floppy controller on Debian 4.0r9/SPARC, and SS-5's OBP initialization routine still works.
Message-id: [email protected]
--- hw/block/fdc.c | 17 ----------------- 1 file changed, 17 deletions(-)
hw/block/fdc.c +0 -17
@@ -535,8 +535,6 @@ struct FDCtrl {uint8_t pwrd;/* Floppy drives */ uint8_t num_floppies; -/* Sun4m quirks? */ -int sun4m;FDrive drives[MAX_FD ];int reset_sensei;uint32_t check_media_rate;
@@ -885,13 +883,6 @@ static void fdctrl_reset_irq(FDCtrl *fdctrl)static void fdctrl_raise_irq (FDCtrl *fdctrl) { -/* Sparc mutation */ -if (fdctrl->sun4m && (fdctrl->msr &FD_MSR_CMDBUSY )) { -/* XXX: not sure */ - fdctrl->msr &= ~FD_MSR_CMDBUSY ; - fdctrl->msr |=FD_MSR_RQM |FD_MSR_DIO ; -return ; - }if (!(fdctrl->sra &FD_SRA_INTPEND )) {qemu_set_irq (fdctrl->irq,1 ); fdctrl->sra |=FD_SRA_INTPEND ;
@@ -1080,12 +1071,6 @@ static uint32_t fdctrl_read_main_status(FDCtrl *fdctrl) fdctrl->dsr &= ~FD_DSR_PWRDOWN ; fdctrl->dor |= FD_DOR_nRESET; -/* Sparc mutation */ -if (fdctrl->sun4m) { - retval |=FD_MSR_DIO ; -fdctrl_reset_irq (fdctrl); - }; -FLOPPY_DPRINTF ("main status register: 0x%02x\n" , retval);return retval;
@@ -2241,8 +2226,6 @@ static void sun4m_fdc_initfn(Object *obj)FDCtrlSysBus *sys =SYSBUS_FDC (obj);FDCtrl *fdctrl = &sys->state; - fdctrl->sun4m =1 ; -memory_region_init_io (&fdctrl->iomem, obj, &fdctrl_mem_strict_ops, fdctrl,"fdctrl" ,0x08 );sysbus_init_mmio (sbd, &fdctrl->iomem);
Signature · 1 line
2.1.0
[Qemu-devel] [PULL 04/10] qtest/ahci: Add simple flush test
In reply to John SnowMessage-id: [email protected]
--- tests/ahci-test.c | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+)
tests/ahci-test.c +34 -0
@@ -797,6 +797,29 @@ static void ahci_test_io_rw_simple(AHCIQState *ahci, unsigned bufsize,g_free (rx); } +static void ahci_test_nondata (AHCIQState *ahci,uint8_t ide_cmd) +{ +uint8_t px; +AHCICommand *cmd; + +/* Sanitize */ + px =ahci_port_select (ahci); +ahci_port_clear (ahci, px); + +/* Issue Command */ + cmd =ahci_command_create (ide_cmd); +ahci_command_commit (ahci, cmd, px); +ahci_command_issue (ahci, cmd); +ahci_command_verify (ahci, cmd); +ahci_command_free (cmd); +} + +static void ahci_test_flush (AHCIQState *ahci) +{ +ahci_test_nondata (ahci,CMD_FLUSH_CACHE ); +} + +/******************************************************************************/ /* Test Interfaces */ /******************************************************************************/
@@ -931,6 +954,15 @@ static void test_dma_fragmented(void)g_free (tx); } +static void test_flush (void ) +{ +AHCIQState *ahci; + + ahci =ahci_boot_and_enable (); +ahci_test_flush (ahci); +ahci_shutdown (ahci); +} +/******************************************************************************/ /* AHCI I/O Test Matrix Definitions */
@@ -1171,6 +1203,8 @@ int main(int argc, char **argv)qtest_add_func ("/ahci/io/dma/lba28/fragmented" , test_dma_fragmented); +qtest_add_func ("/ahci/flush/simple" , test_flush); + ret =g_test_run ();/* Cleanup */
Signature · 1 line
2.1.0
[Qemu-devel] [PULL 07/10] libqtest: add qmp_async
In reply to John SnowAdd qmp_async, which lets us send QMP commands asynchronously. This is useful when we want to send commands that will trigger event responses, but we don't know in what order to expect them.
Sometimes the event responses may arrive even before the command confirmation will show up, so it is convenient to leave the responses in the stream.
Message-id: [email protected]
--- tests/libqtest.c | 30 +++++++++++++++++++++++++++++- tests/libqtest.h | 27 +++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 1 deletion(-)
tests/libqtest.c +29 -1
@@ -388,7 +388,12 @@ QDict *qtest_qmp_receive(QTestState *s)return qmp.response; } -QDict *qtest_qmpv (QTestState *s,const char *fmt,va_list ap) +/** +* Allow users to send a message without waiting for the reply, +* in the case that they choose to discard all replies up until +* a particular EVENT is received. +*/ +void qtest_async_qmpv (QTestState *s,const char *fmt,va_list ap) {va_list ap_copy;QObject *qobj;
@@ -417,6 +422,11 @@ QDict *qtest_qmpv(QTestState *s, const char *fmt, va_list ap)QDECREF (qstr);qobject_decref (qobj); } +} + +QDict *qtest_qmpv (QTestState *s,const char *fmt,va_list ap) +{ +qtest_async_qmpv (s, fmt, ap);/* Receive reply */ return qtest_qmp_receive (s);
@@ -433,6 +443,15 @@ QDict *qtest_qmp(QTestState *s, const char *fmt, ...)return response; } +void qtest_async_qmp (QTestState *s,const char *fmt, ...) +{ +va_list ap; + +va_start (ap, fmt); +qtest_async_qmpv (s, fmt, ap); +va_end (ap); +} +void qtest_qmpv_discard_response (QTestState *s,const char *fmt,va_list ap) {QDict *response =qtest_qmpv (s, fmt, ap);
@@ -711,6 +730,15 @@ QDict *qmp(const char *fmt, ...)return response; } +void qmp_async (const char *fmt, ...) +{ +va_list ap; + +va_start (ap, fmt); +qtest_async_qmpv (global_qtest, fmt, ap); +va_end (ap); +} +void qmp_discard_response (const char *fmt, ...) {va_list ap;
tests/libqtest.h +27 -0
@@ -64,6 +64,15 @@ void qtest_qmp_discard_response(QTestState *s, const char *fmt, ...);QDict *qtest_qmp (QTestState *s,const char *fmt, ...);/** +* qtest_async_qmp: +* @s: #QTestState instance to operate on. +* @fmt...: QMP message to send to qemu +* +* Sends a QMP message to QEMU and leaves the response in the stream. +*/ +void qtest_async_qmp (QTestState *s,const char *fmt, ...); + +/** * qtest_qmpv_discard_response: * @s: #QTestState instance to operate on. * @fmt: QMP message to send to QEMU
@@ -84,6 +93,16 @@ void qtest_qmpv_discard_response(QTestState *s, const char *fmt, va_list ap);QDict *qtest_qmpv (QTestState *s,const char *fmt,va_list ap);/** +* qtest_async_qmpv: +* @s: #QTestState instance to operate on. +* @fmt: QMP message to send to QEMU +* @ap: QMP message arguments +* +* Sends a QMP message to QEMU and leaves the response in the stream. +*/ +void qtest_async_qmpv (QTestState *s,const char *fmt,va_list ap); + +/** * qtest_receive: * @s: #QTestState instance to operate on. *
@@ -420,6 +439,14 @@ static inline void qtest_end(void)QDict *qmp (const char *fmt, ...);/** +* qmp_async: +* @fmt...: QMP message to send to qemu +* +* Sends a QMP message to QEMU and leaves the response in the stream. +*/ +void qmp_async (const char *fmt, ...); + +/** * qmp_discard_response: * @fmt...: QMP message to send to qemu *
Signature · 1 line
2.1.0
[Qemu-devel] [PULL 02/10] qtest/ahci: add qcow2 support to ahci-test
In reply to John SnowThis will enable the testing of high offsets without wasting a lot of disk space, and does not impact the previous tests.
mkimg and mkqcow2 are added to libqos for other tests.
Message-id: [email protected]
--- tests/Makefile | 1 + tests/ahci-test.c | 16 ++++++---------- tests/libqos/libqos.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ tests/libqos/libqos.h | 2 ++ 4 files changed, 53 insertions(+), 10 deletions(-)
tests/Makefile +1 -0
@@ -415,6 +415,7 @@ GCOV_OPTIONS = -n $(if $(V),-f,) $(patsubst %, check-qtest-%, $(QTEST_TARGETS)): check-qtest-%: $(check-qtest-y) $(if $(CONFIG_GCOV),@rm -f *.gcda */*.gcda */*/*.gcda */*/*/*.gcda,) $(call quiet-command,QTEST_QEMU_BINARY=$*-softmmu/qemu-system-$* \ + QTEST_QEMU_IMG=qemu-img$(EXESUF) \ MALLOC_PERTURB_=$${MALLOC_PERTURB_:-$$((RANDOM % 255 + 1))} \ gtester $(GTESTER_OPTIONS) -m=$(SPEED) $(check-qtest-$*-y),"GTESTER $@") $(if $(CONFIG_GCOV),@for f in $(gcov-files-$*-y); do \
tests/ahci-test.c +6 -10
@@ -39,8 +39,8 @@#include "hw/pci/pci_ids.h" #include "hw/pci/pci_regs.h" -/* Test-specific defines. */ -#define TEST_IMAGE_SIZE (64 * 1024 * 1024) +/* Test-specific defines -- in MiB */ +#define TEST_IMAGE_SIZE_MB (200 * 1024)/*** Globals ***/ static char tmp_path[] ="/tmp/qtest.XXXXXX" ;
@@ -107,7 +107,7 @@ static AHCIQState *ahci_boot(void) s =g_malloc0 (sizeof (AHCIQState)); cli ="-drive if=none,id=drive0,file=%s,cache=writeback,serial=%s" -",format=raw" +",format=qcow2" " -M q35 " "-device ide-hd,drive=drive0 " "-global ide-hd.ver=%s" ;
@@ -1071,7 +1071,6 @@ static void create_ahci_io_test(enum IOMode type, enum AddrMode addr,int main (int argc,char **argv) {const char *arch; -int fd;int ret;int c;int i, j, k;
@@ -1108,12 +1107,9 @@ int main(int argc, char **argv)return 0 ; } -/* Create a temporary raw image */ - fd =mkstemp (tmp_path); -g_assert (fd >=0 ); - ret =ftruncate (fd,TEST_IMAGE_SIZE ); -g_assert (ret ==0 ); -close (fd); +/* Create a temporary qcow2 image */ +close (mkstemp (tmp_path)); +mkqcow2 (tmp_path,TEST_IMAGE_SIZE_MB );/* Run the tests */ qtest_add_func ("/ahci/sanity" , test_sanity);
tests/libqos/libqos.c +44 -0
47 lines not on this page · raw message
tests/libqos/libqos.h +2 -0
@@ -19,6 +19,8 @@ typedef struct QOSState {QOSState *qtest_vboot (QOSOps *ops,const char *cmdline_fmt,va_list ap);QOSState *qtest_boot (QOSOps *ops,const char *cmdline_fmt, ...);void qtest_shutdown (QOSState *qs); +void mkimg (const char *file,const char *fmt,unsigned size_mb); +void mkqcow2 (const char *file,unsigned size_mb);static inline uint64_t qmalloc (QOSState *q,size_t bytes) {
Signature · 1 line
2.1.0
Re: [Qemu-devel] [PULL 02/10] qtest/ahci: add qcow2 support to ahci-test
Quoted 9 lines · John Snow
This will enable the testing of high offsets without wasting a lot of disk space, and does not impact the previous tests.
mkimg and mkqcow2 are added to libqos for other tests.
tests/libqos/libqos.c +2
-0+ qemu_img_path =getenv ("QTEST_QEMU_IMG" ); + abs_path =realpath (qemu_img_path,NULL );
tests/libqos/libqos.c void qtest_shutdown(QOSState *qs) · line 86
Quoted 10 lines
tests/libqos/libqos.c +10
-0+assert (qemu_img_path); + + cli =g_strdup_printf ("%s create -f %s %s %uM" , abs_path, + fmt, file, size_mb); + ret =g_spawn_command_line_sync (cli, &out, &out2, &rc, &err); +if (err) { +fprintf (stderr,"%s\n" , err->message); +g_error_free (err); + } +g_assert (ret && !err);
I've just discovered that this change means that "make check" will fail on a system which doesn't have an installed qemu-img and where the build was configured with --disable-tools, and with a confusing error message:
Failed to execute child process "(null)" (No such file or directory) ** ERROR:/Users/pm215/src/qemu/tests/libqos/libqos.c:171:void mkimg(const char *, const char *, unsigned int): assertion failed: (ret && !err)
The test should probably be skipped if qemu-img isn't available.
thanks
-- PMM
Re: [Qemu-devel] [PULL 02/10] qtest/ahci: add qcow2 support to ahci-test
Quoted 31 lines · Peter Maydell
Quoted 9 lines · John Snow
This will enable the testing of high offsets without wasting a lot of disk space, and does not impact the previous tests.
mkimg and mkqcow2 are added to libqos for other tests.
tests/libqos/libqos.c +2
-0+ qemu_img_path =getenv ("QTEST_QEMU_IMG" ); + abs_path =realpath (qemu_img_path,NULL );tests/libqos/libqos.c void qtest_shutdown(QOSState *qs) · line 86
Quoted 10 lines
tests/libqos/libqos.c +10
-0+assert (qemu_img_path); + + cli =g_strdup_printf ("%s create -f %s %s %uM" , abs_path, + fmt, file, size_mb); + ret =g_spawn_command_line_sync (cli, &out, &out2, &rc, &err); +if (err) { +fprintf (stderr,"%s\n" , err->message); +g_error_free (err); + } +g_assert (ret && !err);I've just discovered that this change means that "make check" will fail on a system which doesn't have an installed qemu-img and where the build was configured with --disable-tools, and with a confusing error message:
Failed to execute child process "(null)" (No such file or directory) ** ERROR:/Users/pm215/src/qemu/tests/libqos/libqos.c:171:void
mkimg(const char *, const char *, unsigned int): assertion failed: (ret && !err)
Quoted 5 lines
The test should probably be skipped if qemu-img isn't available.
thanks
-- PMM
In part I feel that it's reasonable to expect that you have tools available in order to run tests, but I don't want to be the first to break rank.
(At the very least, the error is extremely confusing.)
I'm writing a patch now to skip the LBA48 high-sector tests if qemu-img isn't available and fall back to raw.
--js
[Qemu-devel] [PULL 03/10] qtest/ahci: test different disk sectors
In reply to John SnowTest sector offset 0, 1, and the last sector(s)
in LBA28 and LBA48 modes.
Message-id: [email protected]
--- tests/ahci-test.c | 68 +++++++++++++++++++++++++++++++++++++++++++---------- tests/libqos/ahci.c | 10 ++++---- tests/libqos/ahci.h | 4 ++-- 3 files changed, 63 insertions(+), 19 deletions(-)
tests/ahci-test.c +55 -13
@@ -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" ;
@@ -738,7 +740,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.
@@ -754,11 +756,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;
@@ -781,9 +784,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);
@@ -968,12 +971,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. */
@@ -1001,12 +1037,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);
@@ -1019,6 +1055,7 @@ static void test_io_interface(gconstpointer opaque) {AHCIIOTestOptions *opts = (AHCIIOTestOptions *)opaque;unsigned bufsize; +uint64_t sector;switch (opts->length) {case LEN_SIMPLE :
@@ -1037,13 +1074,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;
@@ -1052,15 +1090,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);
@@ -1073,7 +1113,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' },
@@ -1122,7 +1162,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); + } } } }
tests/libqos/ahci.c +6 -4
@@ -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);
tests/libqos/ahci.h +2 -2
@@ -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);
Signature · 1 line
2.1.0
[Qemu-devel] [PULL 05/10] qtest/ahci: Allow override of default CLI options
In reply to John SnowMessage-id: [email protected]
--- tests/ahci-test.c | 67 ++++++++++++++++++++++++++++++++---------------- tests/libqos/libqos-pc.c | 5 ++++ tests/libqos/libqos-pc.h | 1 + 3 files changed, 51 insertions(+), 22 deletions(-)
tests/ahci-test.c +45 -22
@@ -101,19 +101,12 @@ static void generate_pattern(void *buffer, size_t len, size_t cycle_len)/** * Start a Q35 machine and bookmark a handle to the AHCI device. */ -static AHCIQState *ahci_boot (void ) +static AHCIQState *ahci_vboot (const char *cli,va_list ap) {AHCIQState *s; -const char *cli; s =g_malloc0 (sizeof (AHCIQState)); - - cli ="-drive if=none,id=drive0,file=%s,cache=writeback,serial=%s" -",format=qcow2" -" -M q35 " -"-device ide-hd,drive=drive0 " -"-global ide-hd.ver=%s" ; - s->parent =qtest_pc_boot (cli, tmp_path,"testdisk" ,"version" ); + s->parent =qtest_pc_vboot (cli, ap);alloc_set_flags (s->parent->alloc,ALLOC_LEAK_ASSERT );/* Verify that we have an AHCI device present. */
@@ -123,12 +116,35 @@ static AHCIQState *ahci_boot(void) }/** +* Start a Q35 machine and bookmark a handle to the AHCI device. +*/ +static AHCIQState *ahci_boot (const char *cli, ...) +{ +AHCIQState *s; +va_list ap; + +if (cli) { +va_start (ap, cli); + s =ahci_vboot (cli, ap); +va_end (ap); + }else { + cli ="-drive if=none,id=drive0,file=%s,cache=writeback,serial=%s" +",format=qcow2" +" -M q35 " +"-device ide-hd,drive=drive0 " +"-global ide-hd.ver=%s" ; + s =ahci_boot (cli, tmp_path,"testdisk" ,"version" ); + } + +return s; +} + +/** * Clean up the PCI device, then terminate the QEMU instance. */ static void ahci_shutdown (AHCIQState *ahci) {QOSState *qs = ahci->parent; -ahci_clean_mem (ahci);free_ahci_device (ahci->dev);g_free (ahci);
@@ -139,10 +155,18 @@ static void ahci_shutdown(AHCIQState *ahci)* Boot and fully enable the HBA device. * @see ahci_boot, ahci_pci_enable and ahci_hba_enable. */ -static AHCIQState *ahci_boot_and_enable (void ) +static AHCIQState *ahci_boot_and_enable (const char *cli, ...) {AHCIQState *ahci; - ahci =ahci_boot (); +va_list ap; + +if (cli) { +va_start (ap, cli); + ahci =ahci_vboot (cli, ap); +va_end (ap); + }else { + ahci =ahci_boot (NULL ); + }ahci_pci_enable (ahci);ahci_hba_enable (ahci);
@@ -830,7 +854,7 @@ static void ahci_test_flush(AHCIQState *ahci)static void test_sanity (void ) {AHCIQState *ahci; - ahci =ahci_boot (); + ahci =ahci_boot (NULL );ahci_shutdown (ahci); }
@@ -841,7 +865,7 @@ static void test_sanity(void)static void test_pci_spec (void ) {AHCIQState *ahci; - ahci =ahci_boot (); + ahci =ahci_boot (NULL );ahci_test_pci_spec (ahci);ahci_shutdown (ahci); }
@@ -853,8 +877,7 @@ static void test_pci_spec(void)static void test_pci_enable (void ) {AHCIQState *ahci; - - ahci =ahci_boot (); + ahci =ahci_boot (NULL );ahci_pci_enable (ahci);ahci_shutdown (ahci); }
@@ -867,7 +890,7 @@ static void test_hba_spec(void) {AHCIQState *ahci; - ahci =ahci_boot (); + ahci =ahci_boot (NULL );ahci_pci_enable (ahci);ahci_test_hba_spec (ahci);ahci_shutdown (ahci);
@@ -881,7 +904,7 @@ static void test_hba_enable(void) {AHCIQState *ahci; - ahci =ahci_boot (); + ahci =ahci_boot (NULL );ahci_pci_enable (ahci);ahci_hba_enable (ahci);ahci_shutdown (ahci);
@@ -895,7 +918,7 @@ static void test_identify(void) {AHCIQState *ahci; - ahci =ahci_boot_and_enable (); + ahci =ahci_boot_and_enable (NULL );ahci_test_identify (ahci);ahci_shutdown (ahci); }
@@ -916,7 +939,7 @@ static void test_dma_fragmented(void)unsigned char *rx =g_malloc0 (bufsize);uint64_t ptr; - ahci =ahci_boot_and_enable (); + ahci =ahci_boot_and_enable (NULL ); px =ahci_port_select (ahci);ahci_port_clear (ahci, px);
@@ -958,7 +981,7 @@ static void test_flush(void) {AHCIQState *ahci; - ahci =ahci_boot_and_enable (); + ahci =ahci_boot_and_enable (NULL );ahci_test_flush (ahci);ahci_shutdown (ahci); }
@@ -1073,7 +1096,7 @@ static void test_io_rw_interface(enum AddrMode lba48, enum IOMode dma, {AHCIQState *ahci; - ahci =ahci_boot_and_enable (); + ahci =ahci_boot_and_enable (NULL );ahci_test_io_rw_simple (ahci, bufsize, sector, io_cmds[dma][lba48][IO_READ ], io_cmds[dma][lba48][IO_WRITE ]);
tests/libqos/libqos-pc.c +5 -0
@@ -6,6 +6,11 @@ static QOSOps qos_ops = { .uninit_allocator = pc_alloc_uninit }; +QOSState *qtest_pc_vboot (const char *cmdline_fmt,va_list ap) +{ +return qtest_vboot (&qos_ops, cmdline_fmt, ap); +} +QOSState *qtest_pc_boot (const char *cmdline_fmt, ...) {QOSState *qs;
tests/libqos/libqos-pc.h +1 -0
@@ -3,6 +3,7 @@#include "libqos/libqos.h" +QOSState *qtest_pc_vboot (const char *cmdline_fmt,va_list ap);QOSState *qtest_pc_boot (const char *cmdline_fmt, ...);void qtest_pc_shutdown (QOSState *qs);
Signature · 1 line
2.1.0
[Qemu-devel] [PULL 06/10] libqtest: add qmp_eventwait
In reply to John SnowAllow the user to poll until a desired interrupt occurs.
Message-id: [email protected]
--- tests/ide-test.c | 11 +---------- tests/libqtest.c | 16 ++++++++++++++++ tests/libqtest.h | 20 ++++++++++++++++++++ 3 files changed, 37 insertions(+), 10 deletions(-)
tests/ide-test.c +1 -10
@@ -520,7 +520,6 @@ static void test_retry_flush(const char *machine) {uint8_t data;const char *s; -QDict *response;prepare_blkdebug_script (debug_path,"flush_to_disk" );
@@ -539,15 +538,7 @@ static void test_retry_flush(const char *machine)assert_bit_set (data,BSY |DRDY );assert_bit_clear (data,DF |ERR |DRQ ); -for (;; response =NULL ) { - response =qmp_receive (); -if ((qdict_haskey (response,"event" )) && - (strcmp (qdict_get_str (response,"event" ),"STOP" ) ==0 )) { -QDECREF (response); -break ; - } -QDECREF (response); - } +qmp_eventwait ("STOP" );/* Complete the command */ s ="{'execute':'cont' }" ;
tests/libqtest.c +16 -0
@@ -450,6 +450,22 @@ void qtest_qmp_discard_response(QTestState *s, const char *fmt, ...)QDECREF (response); } +void qtest_qmp_eventwait (QTestState *s,const char *event) +{ +QDict *response; + +for (;;) { + response =qtest_qmp_receive (s); +if ((qdict_haskey (response,"event" )) && + (strcmp (qdict_get_str (response,"event" ), event) ==0 )) { +QDECREF (response); +break ; + } +QDECREF (response); + } +} + +const char *qtest_get_arch (void ) {const char *qemu =getenv ("QTEST_QEMU_BINARY" );
tests/libqtest.h +20 -0
@@ -92,6 +92,15 @@ QDict *qtest_qmpv(QTestState *s, const char *fmt, va_list ap);QDict *qtest_qmp_receive (QTestState *s);/** +* qtest_qmp_eventwait: +* @s: #QTestState instance to operate on. +* @s: #event event to wait for. +* +* Continuosly polls for QMP responses until it receives the desired event. +*/ +void qtest_qmp_eventwait (QTestState *s,const char *event); + +/** * qtest_get_irq: * @s: #QTestState instance to operate on. * @num: Interrupt to observe.
@@ -429,6 +438,17 @@ static inline QDict *qmp_receive(void) }/** +* qmp_eventwait: +* @s: #event event to wait for. +* +* Continuosly polls for QMP responses until it receives the desired event. +*/ +static inline void qmp_eventwait (const char *event) +{ +return qtest_qmp_eventwait (global_qtest, event); +} + +/** * get_irq: * @num: Interrupt to observe. *
Signature · 1 line
2.1.0
[Qemu-devel] [PULL 08/10] libqos: add blkdebug_prepare_script
In reply to John SnowPull this helper out of ide-test and into libqos,
to be shared with ahci-test.
Message-id: [email protected]
--- tests/ide-test.c | 23 +---------------------- tests/libqos/libqos.c | 22 ++++++++++++++++++++++ tests/libqos/libqos.h | 1 + 3 files changed, 24 insertions(+), 22 deletions(-)
tests/ide-test.c +1 -22
@@ -29,6 +29,7 @@#include <glib.h> #include "libqtest.h" +#include "libqos/libqos.h" #include "libqos/pci-pc.h" #include "libqos/malloc-pc.h"
@@ -494,28 +495,6 @@ static void test_flush(void)ide_test_quit (); } -static void prepare_blkdebug_script (const char *debug_fn,const char *event) -{ -FILE *debug_file =fopen (debug_fn,"w" ); -int ret; - -fprintf (debug_file,"[inject-error]\n" ); -fprintf (debug_file,"event = \"%s\"\n" , event); -fprintf (debug_file,"errno = \"5\"\n" ); -fprintf (debug_file,"state = \"1\"\n" ); -fprintf (debug_file,"immediately = \"off\"\n" ); -fprintf (debug_file,"once = \"on\"\n" ); - -fprintf (debug_file,"[set-state]\n" ); -fprintf (debug_file,"event = \"%s\"\n" , event); -fprintf (debug_file,"new_state = \"2\"\n" ); -fflush (debug_file); -g_assert (!ferror (debug_file)); - - ret =fclose (debug_file); -g_assert (ret ==0 ); -} -static void test_retry_flush (const char *machine) {uint8_t data;
tests/libqos/libqos.c +22 -0
@@ -105,3 +105,25 @@ void mkqcow2(const char *file, unsigned size_mb) {return mkimg (file,"qcow2" , size_mb); } + +void prepare_blkdebug_script (const char *debug_fn,const char *event) +{ +FILE *debug_file =fopen (debug_fn,"w" ); +int ret; + +fprintf (debug_file,"[inject-error]\n" ); +fprintf (debug_file,"event = \"%s\"\n" , event); +fprintf (debug_file,"errno = \"5\"\n" ); +fprintf (debug_file,"state = \"1\"\n" ); +fprintf (debug_file,"immediately = \"off\"\n" ); +fprintf (debug_file,"once = \"on\"\n" ); + +fprintf (debug_file,"[set-state]\n" ); +fprintf (debug_file,"event = \"%s\"\n" , event); +fprintf (debug_file,"new_state = \"2\"\n" ); +fflush (debug_file); +g_assert (!ferror (debug_file)); + + ret =fclose (debug_file); +g_assert (ret ==0 ); +}
tests/libqos/libqos.h +1 -0
@@ -21,6 +21,7 @@ QOSState *qtest_boot(QOSOps *ops, const char *cmdline_fmt, ...);void qtest_shutdown (QOSState *qs);void mkimg (const char *file,const char *fmt,unsigned size_mb);void mkqcow2 (const char *file,unsigned size_mb); +void prepare_blkdebug_script (const char *debug_fn,const char *event);static inline uint64_t qmalloc (QOSState *q,size_t bytes) {
Signature · 1 line
2.1.0
[Qemu-devel] [PULL 09/10] qtest/ahci: add flush retry test
In reply to John SnowMessage-id: [email protected]
--- tests/ahci-test.c | 44 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+)
tests/ahci-test.c +44 -0
@@ -46,6 +46,7 @@/*** Globals ***/ static char tmp_path[] ="/tmp/qtest.XXXXXX" ; +static char debug_path[] ="/tmp/qtest-blkdebug.XXXXXX" ;static bool ahci_pedantic;/*** Function Declarations ***/
@@ -986,6 +987,41 @@ static void test_flush(void)ahci_shutdown (ahci); } +static void test_flush_retry (void ) +{ +AHCIQState *ahci; +AHCICommand *cmd; +uint8_t port; +const char *s; + +prepare_blkdebug_script (debug_path,"flush_to_disk" ); + ahci =ahci_boot_and_enable ("-drive file=blkdebug:%s:%s,if=none,id=drive0," +"format=qcow2,cache=writeback," +"rerror=stop,werror=stop " +"-M q35 " +"-device ide-hd,drive=drive0 " , + debug_path, + tmp_path); + +/* Issue Flush Command */ + port =ahci_port_select (ahci); +ahci_port_clear (ahci, port); + cmd =ahci_command_create (CMD_FLUSH_CACHE ); +ahci_command_commit (ahci, cmd, port); +ahci_command_issue_async (ahci, cmd); +qmp_eventwait ("STOP" ); + +/* Complete the command */ + s ="{'execute':'cont' }" ; +qmp_async (s); +qmp_eventwait ("RESUME" ); +ahci_command_wait (ahci, cmd); +ahci_command_verify (ahci, cmd); + +ahci_command_free (cmd); +ahci_shutdown (ahci); +} +/******************************************************************************/ /* AHCI I/O Test Matrix Definitions */
@@ -1167,6 +1203,7 @@ int main(int argc, char **argv) {const char *arch;int ret; +int fd;int c;int i, j, k, m;
@@ -1206,6 +1243,11 @@ int main(int argc, char **argv)close (mkstemp (tmp_path));mkqcow2 (tmp_path,TEST_IMAGE_SIZE_MB ); +/* Create temporary blkdebug instructions */ + fd =mkstemp (debug_path); +g_assert (fd >=0 ); +close (fd); +/* Run the tests */ qtest_add_func ("/ahci/sanity" , test_sanity);qtest_add_func ("/ahci/pci_spec" , test_pci_spec);
@@ -1227,11 +1269,13 @@ int main(int argc, char **argv)qtest_add_func ("/ahci/io/dma/lba28/fragmented" , test_dma_fragmented);qtest_add_func ("/ahci/flush/simple" , test_flush); +qtest_add_func ("/ahci/flush/retry" , test_flush_retry); ret =g_test_run ();/* Cleanup */ unlink (tmp_path); +unlink (debug_path);return ret; }
Signature · 1 line
2.1.0
[Qemu-devel] [PULL 10/10] qtest: Add assertion that required environment variable is set
In reply to John SnowFrom: Ed Maste <[email protected]>
Message-id: [email protected]
--- tests/libqtest.c | 1 + 1 file changed, 1 insertion(+)
tests/libqtest.c +1 -0
@@ -488,6 +488,7 @@ void qtest_qmp_eventwait(QTestState *s, const char *event)const char *qtest_get_arch (void ) {const char *qemu =getenv ("QTEST_QEMU_BINARY" ); +g_assert (qemu !=NULL );const char *end =strrchr (qemu,'/' );return end +strlen ("/qemu-system-" );
Signature · 1 line
2.1.0
Peter Maydell
AppliedQuoted 8 lines · John Snow
The following changes since commit
a9392bc93c8615ad1983047e9f91ee3fa8aae75f:Merge remote-tracking branch 'remotes/kevin/tags/for-upstream' into staging (2015-04-28 16:55:03 +0100)
are available in the git repository at:
https://github.com/jnsnow/qemu.git tags/ide-pull-request
Quoted 7 lines
for you to fetch changes up to
c8368674980b299604e3cfe9215c4105acefa516:qtest: Add assertion that required environment variable is set (2015-04-28 15:27:51 -0400)
----------------------------------------------------------------
----------------------------------------------------------------
Applied, thanks.
-- PMM