1 /* 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. 6 * 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. 11 * 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/>. 15 */ 16 17 #pragma once 18 19 #ifdef WITH_QEMU 20 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" 26 27 # define TEST_QEMU_CAPS_PATH abs_srcdir "/qemucapabilitiesdata" 28 29 enum { 30 GIC_NONE = 0, 31 GIC_V2, 32 GIC_V3, 33 GIC_BOTH, 34 }; 35 36 typedef enum { 37 ARG_QEMU_CAPS = QEMU_CAPS_LAST + 1, 38 ARG_GIC, 39 ARG_MIGRATE_FROM, 40 ARG_MIGRATE_FD, 41 ARG_FLAGS, 42 ARG_PARSEFLAGS, 43 ARG_CAPS_ARCH, 44 ARG_CAPS_VER, 45 ARG_END, 46 } testQemuInfoArgName; 47 48 typedef enum { 49 FLAG_EXPECT_FAILURE = 1 << 0, 50 FLAG_EXPECT_PARSE_ERROR = 1 << 1, 51 FLAG_FIPS_HOST = 1 << 2, /* simulate host with FIPS mode enabled */ 52 FLAG_REAL_CAPS = 1 << 3, 53 FLAG_SKIP_LEGACY_CPUS = 1 << 4, 54 FLAG_SLIRP_HELPER = 1 << 5, 55 } testQemuInfoFlags; 56 57 struct testQemuConf { 58 GHashTable *capscache; 59 GHashTable *capslatest; 60 GHashTable *qapiSchemaCache; 61 }; 62 63 struct testQemuArgs { 64 bool newargs; 65 virQEMUCaps *fakeCaps; 66 bool fakeCapsUsed; 67 char *capsver; 68 char *capsarch; 69 int gic; 70 bool invalidarg; 71 }; 72 73 struct testQemuInfo { 74 const char *name; 75 char *infile; 76 char *outfile; 77 char *errfile; 78 virQEMUCaps *qemuCaps; 79 const char *migrateFrom; 80 int migrateFd; 81 unsigned int flags; 82 unsigned int parseFlags; 83 virArch arch; 84 char *schemafile; 85 86 struct testQemuArgs args; 87 struct testQemuConf *conf; 88 }; 89 90 virCaps *testQemuCapsInit(void); 91 virDomainXMLOption *testQemuXMLConfInit(void); 92 93 94 virQEMUCaps *qemuTestParseCapabilitiesArch(virArch arch, 95 const char *capsFile); 96 97 extern virCPUDef *cpuDefault; 98 extern virCPUDef *cpuHaswell; 99 extern virCPUDef *cpuPower8; 100 extern virCPUDef *cpuPower9; 101 102 void qemuTestSetHostArch(virQEMUDriver *driver, 103 virArch arch); 104 void qemuTestSetHostCPU(virQEMUDriver *driver, 105 virArch arch, 106 virCPUDef *cpu); 107 108 int qemuTestDriverInit(virQEMUDriver *driver); 109 void qemuTestDriverFree(virQEMUDriver *driver); 110 int qemuTestCapsCacheInsert(virFileCache *cache, 111 virQEMUCaps *caps); 112 113 int testQemuCapsSetGIC(virQEMUCaps *qemuCaps, 114 int gic); 115 116 char *testQemuGetLatestCapsForArch(const char *arch, 117 const char *suffix); 118 GHashTable *testQemuGetLatestCaps(void); 119 120 typedef int (*testQemuCapsIterateCallback)(const char *inputDir, 121 const char *prefix, 122 const char *version, 123 const char *archName, 124 const char *suffix, 125 void *opaque); 126 int testQemuCapsIterate(const char *suffix, 127 testQemuCapsIterateCallback callback, 128 void *opaque); 129 130 void testQemuInfoSetArgs(struct testQemuInfo *info, 131 struct testQemuConf *conf, 132 ...); 133 int testQemuInfoInitArgs(struct testQemuInfo *info); 134 void testQemuInfoClear(struct testQemuInfo *info); 135 136 #endif 137