提交 debaaa11 编写于 作者: J John Snow

qtest/ahci: Allow override of default CLI options

Signed-off-by: NJohn Snow <jsnow@redhat.com>
Message-id: 1426018503-821-3-git-send-email-jsnow@redhat.com
上级 4e217074
...@@ -101,19 +101,12 @@ static void generate_pattern(void *buffer, size_t len, size_t cycle_len) ...@@ -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. * 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; AHCIQState *s;
const char *cli;
s = g_malloc0(sizeof(AHCIQState)); s = g_malloc0(sizeof(AHCIQState));
s->parent = qtest_pc_vboot(cli, ap);
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");
alloc_set_flags(s->parent->alloc, ALLOC_LEAK_ASSERT); alloc_set_flags(s->parent->alloc, ALLOC_LEAK_ASSERT);
/* Verify that we have an AHCI device present. */ /* Verify that we have an AHCI device present. */
...@@ -122,13 +115,36 @@ static AHCIQState *ahci_boot(void) ...@@ -122,13 +115,36 @@ static AHCIQState *ahci_boot(void)
return s; return s;
} }
/**
* 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. * Clean up the PCI device, then terminate the QEMU instance.
*/ */
static void ahci_shutdown(AHCIQState *ahci) static void ahci_shutdown(AHCIQState *ahci)
{ {
QOSState *qs = ahci->parent; QOSState *qs = ahci->parent;
ahci_clean_mem(ahci); ahci_clean_mem(ahci);
free_ahci_device(ahci->dev); free_ahci_device(ahci->dev);
g_free(ahci); g_free(ahci);
...@@ -139,10 +155,18 @@ static void ahci_shutdown(AHCIQState *ahci) ...@@ -139,10 +155,18 @@ static void ahci_shutdown(AHCIQState *ahci)
* Boot and fully enable the HBA device. * Boot and fully enable the HBA device.
* @see ahci_boot, ahci_pci_enable and ahci_hba_enable. * @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; 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_pci_enable(ahci);
ahci_hba_enable(ahci); ahci_hba_enable(ahci);
...@@ -830,7 +854,7 @@ static void ahci_test_flush(AHCIQState *ahci) ...@@ -830,7 +854,7 @@ static void ahci_test_flush(AHCIQState *ahci)
static void test_sanity(void) static void test_sanity(void)
{ {
AHCIQState *ahci; AHCIQState *ahci;
ahci = ahci_boot(); ahci = ahci_boot(NULL);
ahci_shutdown(ahci); ahci_shutdown(ahci);
} }
...@@ -841,7 +865,7 @@ static void test_sanity(void) ...@@ -841,7 +865,7 @@ static void test_sanity(void)
static void test_pci_spec(void) static void test_pci_spec(void)
{ {
AHCIQState *ahci; AHCIQState *ahci;
ahci = ahci_boot(); ahci = ahci_boot(NULL);
ahci_test_pci_spec(ahci); ahci_test_pci_spec(ahci);
ahci_shutdown(ahci); ahci_shutdown(ahci);
} }
...@@ -853,8 +877,7 @@ static void test_pci_spec(void) ...@@ -853,8 +877,7 @@ static void test_pci_spec(void)
static void test_pci_enable(void) static void test_pci_enable(void)
{ {
AHCIQState *ahci; AHCIQState *ahci;
ahci = ahci_boot(NULL);
ahci = ahci_boot();
ahci_pci_enable(ahci); ahci_pci_enable(ahci);
ahci_shutdown(ahci); ahci_shutdown(ahci);
} }
...@@ -867,7 +890,7 @@ static void test_hba_spec(void) ...@@ -867,7 +890,7 @@ static void test_hba_spec(void)
{ {
AHCIQState *ahci; AHCIQState *ahci;
ahci = ahci_boot(); ahci = ahci_boot(NULL);
ahci_pci_enable(ahci); ahci_pci_enable(ahci);
ahci_test_hba_spec(ahci); ahci_test_hba_spec(ahci);
ahci_shutdown(ahci); ahci_shutdown(ahci);
...@@ -881,7 +904,7 @@ static void test_hba_enable(void) ...@@ -881,7 +904,7 @@ static void test_hba_enable(void)
{ {
AHCIQState *ahci; AHCIQState *ahci;
ahci = ahci_boot(); ahci = ahci_boot(NULL);
ahci_pci_enable(ahci); ahci_pci_enable(ahci);
ahci_hba_enable(ahci); ahci_hba_enable(ahci);
ahci_shutdown(ahci); ahci_shutdown(ahci);
...@@ -895,7 +918,7 @@ static void test_identify(void) ...@@ -895,7 +918,7 @@ static void test_identify(void)
{ {
AHCIQState *ahci; AHCIQState *ahci;
ahci = ahci_boot_and_enable(); ahci = ahci_boot_and_enable(NULL);
ahci_test_identify(ahci); ahci_test_identify(ahci);
ahci_shutdown(ahci); ahci_shutdown(ahci);
} }
...@@ -916,7 +939,7 @@ static void test_dma_fragmented(void) ...@@ -916,7 +939,7 @@ static void test_dma_fragmented(void)
unsigned char *rx = g_malloc0(bufsize); unsigned char *rx = g_malloc0(bufsize);
uint64_t ptr; uint64_t ptr;
ahci = ahci_boot_and_enable(); ahci = ahci_boot_and_enable(NULL);
px = ahci_port_select(ahci); px = ahci_port_select(ahci);
ahci_port_clear(ahci, px); ahci_port_clear(ahci, px);
...@@ -958,7 +981,7 @@ static void test_flush(void) ...@@ -958,7 +981,7 @@ static void test_flush(void)
{ {
AHCIQState *ahci; AHCIQState *ahci;
ahci = ahci_boot_and_enable(); ahci = ahci_boot_and_enable(NULL);
ahci_test_flush(ahci); ahci_test_flush(ahci);
ahci_shutdown(ahci); ahci_shutdown(ahci);
} }
...@@ -1073,7 +1096,7 @@ static void test_io_rw_interface(enum AddrMode lba48, enum IOMode dma, ...@@ -1073,7 +1096,7 @@ static void test_io_rw_interface(enum AddrMode lba48, enum IOMode dma,
{ {
AHCIQState *ahci; AHCIQState *ahci;
ahci = ahci_boot_and_enable(); ahci = ahci_boot_and_enable(NULL);
ahci_test_io_rw_simple(ahci, bufsize, sector, ahci_test_io_rw_simple(ahci, bufsize, sector,
io_cmds[dma][lba48][IO_READ], io_cmds[dma][lba48][IO_READ],
io_cmds[dma][lba48][IO_WRITE]); io_cmds[dma][lba48][IO_WRITE]);
......
...@@ -6,6 +6,11 @@ static QOSOps qos_ops = { ...@@ -6,6 +6,11 @@ static QOSOps qos_ops = {
.uninit_allocator = pc_alloc_uninit .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 *qtest_pc_boot(const char *cmdline_fmt, ...)
{ {
QOSState *qs; QOSState *qs;
......
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
#include "libqos/libqos.h" #include "libqos/libqos.h"
QOSState *qtest_pc_vboot(const char *cmdline_fmt, va_list ap);
QOSState *qtest_pc_boot(const char *cmdline_fmt, ...); QOSState *qtest_pc_boot(const char *cmdline_fmt, ...);
void qtest_pc_shutdown(QOSState *qs); void qtest_pc_shutdown(QOSState *qs);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册