2 * This library is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU Lesser General Public
4 * License as published by the Free Software Foundation; either
5 * version 2.1 of the License, or (at your option) any later version.
7 * This library is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
10 * Lesser General Public License for more details.
12 * You should have received a copy of the GNU Lesser General Public
13 * License along with this library. If not, see
14 * <http://www.gnu.org/licenses/>.
21 # include "capabilities.h"
22 # include "virfilecache.h"
23 # include "domain_conf.h"
24 # include "qemu/qemu_capabilities.h"
25 # include "qemu/qemu_conf.h"
27 # define TEST_QEMU_CAPS_PATH abs_srcdir "/qemucapabilitiesdata"
28 # define TEST_TPM_ENV_VAR "VIR_TEST_MOCK_FAKE_TPM_VERSION"
29 # define TPM_VER_1_2 "1.2"
30 # define TPM_VER_2_0 "2.0"
31 # define TEST_NBDKIT_PATH "/fakebindir/nbdkit"
41 ARG_QEMU_CAPS
= QEMU_CAPS_LAST
+ 1,
51 ARG_CAPS_HOST_CPU_MODEL
,
52 ARG_FD_GROUP
, /* name, nfds, fd[0], ... fd[n-1] */
53 ARG_VDPA_FD
, /* vdpadev, fd */
56 } testQemuInfoArgName
;
59 FLAG_EXPECT_FAILURE
= 1 << 0,
60 FLAG_EXPECT_PARSE_ERROR
= 1 << 1,
61 FLAG_REAL_CAPS
= 1 << 2,
62 FLAG_SLIRP_HELPER
= 1 << 3,
63 FLAG_ALLOW_DUPLICATE_OUTPUT
= 1 << 4, /* allow multiple tests with the same output file */
64 FLAG_ALLOW_MISSING_INPUT
= 1 << 5,
68 GHashTable
*capscache
;
69 GHashTable
*capslatest
;
70 GHashTable
*qapiSchemaCache
;
71 GHashTable
*duplicateTests
; /* for checking duplicated invocations */
72 GHashTable
*existingTestCases
; /* for checking missing invocations */
85 virBitmap
*fakeCapsAdd
;
86 virBitmap
*fakeCapsDel
;
87 virBitmap
*fakeNbdkitCaps
;
90 const char *capsvariant
;
91 qemuTestCPUDef capsHostCPUModel
;
98 struct _testQemuInfo
{
102 char *out_xml_active
;
103 char *out_xml_inactive
;
105 virDomainDef
*def
; /* parsed domain definition */
106 virQEMUCaps
*qemuCaps
;
107 qemuNbdkitCaps
*nbdkitCaps
;
108 const char *migrateFrom
;
111 unsigned int parseFlags
;
113 GHashTable
*qmpSchema
; /* borrowed pointer from the cache */
115 /* Some tests have a common prepare step for multiple cases, but
116 * the common setup needs to be invoked with each virTestRun to facilitate
121 struct testQemuArgs args
;
122 struct testQemuConf
*conf
;
125 typedef struct _testQemuInfo testQemuInfo
;
126 void testQemuInfoFree(testQemuInfo
*info
);
127 G_DEFINE_AUTOPTR_CLEANUP_FUNC(testQemuInfo
, testQemuInfoFree
);
129 virQEMUCaps
*qemuTestParseCapabilitiesArch(virArch arch
,
130 const char *capsFile
);
131 virCPUDef
*qemuTestGetCPUDef(qemuTestCPUDef d
);
133 void qemuTestSetHostArch(virQEMUDriver
*driver
,
135 void qemuTestSetHostCPU(virQEMUDriver
*driver
,
139 int qemuTestDriverInit(virQEMUDriver
*driver
);
140 void qemuTestDriverFree(virQEMUDriver
*driver
);
141 int qemuTestCapsCacheInsert(virFileCache
*cache
,
144 int testQemuCapsSetGIC(virQEMUCaps
*qemuCaps
,
147 char *testQemuGetLatestCapsForArch(const char *arch
,
149 GHashTable
*testQemuGetLatestCaps(void);
151 typedef int (*testQemuCapsIterateCallback
)(const char *inputDir
,
154 const char *archName
,
158 int testQemuCapsIterate(const char *suffix
,
159 testQemuCapsIterateCallback callback
,
162 void testQemuInfoSetArgs(testQemuInfo
*info
,
164 int testQemuInfoInitArgs(testQemuInfo
*info
);
166 int testQemuPrepareHostBackendChardevOne(virDomainDeviceDef
*dev
,
167 virDomainChrSourceDef
*chardev
,
171 testQemuGetRealCaps(const char *arch
,
174 GHashTable
*capsLatestFiles
,
175 GHashTable
*capsCache
,
176 GHashTable
*schemaCache
,
177 GHashTable
**schema
);
180 testQemuInsertRealCaps(virFileCache
*cache
,
184 GHashTable
*capsLatestFiles
,
185 GHashTable
*capsCache
,
186 GHashTable
*schemaCache
,
187 GHashTable
**schema
);