]> Git Repo - qemu.git/blob - tests/libqos/libqos.c
libqos/ahci: Add ahci_port_select helper
[qemu.git] / tests / libqos / libqos.c
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <glib.h>
4 #include <unistd.h>
5 #include <fcntl.h>
6 #include <sys/wait.h>
7
8 #include "libqtest.h"
9 #include "libqos/libqos.h"
10 #include "libqos/pci.h"
11
12 /*** Test Setup & Teardown ***/
13
14 /**
15  * Launch QEMU with the given command line,
16  * and then set up interrupts and our guest malloc interface.
17  */
18 QOSState *qtest_vboot(QOSOps *ops, const char *cmdline_fmt, va_list ap)
19 {
20     char *cmdline;
21
22     struct QOSState *qs = g_malloc(sizeof(QOSState));
23
24     cmdline = g_strdup_vprintf(cmdline_fmt, ap);
25     qs->qts = qtest_start(cmdline);
26     qs->ops = ops;
27     qtest_irq_intercept_in(global_qtest, "ioapic");
28     if (ops && ops->init_allocator) {
29         qs->alloc = ops->init_allocator(ALLOC_NO_FLAGS);
30     }
31
32     g_free(cmdline);
33     return qs;
34 }
35
36 /**
37  * Launch QEMU with the given command line,
38  * and then set up interrupts and our guest malloc interface.
39  */
40 QOSState *qtest_boot(QOSOps *ops, const char *cmdline_fmt, ...)
41 {
42     QOSState *qs;
43     va_list ap;
44
45     va_start(ap, cmdline_fmt);
46     qs = qtest_vboot(ops, cmdline_fmt, ap);
47     va_end(ap);
48
49     return qs;
50 }
51
52 /**
53  * Tear down the QEMU instance.
54  */
55 void qtest_shutdown(QOSState *qs)
56 {
57     if (qs->alloc && qs->ops && qs->ops->uninit_allocator) {
58         qs->ops->uninit_allocator(qs->alloc);
59         qs->alloc = NULL;
60     }
61     qtest_quit(qs->qts);
62     g_free(qs);
63 }
This page took 0.027162 seconds and 4 git commands to generate.