Files
libvirt/tests/testutilsqemu.h
T

159 lines
4.5 KiB
C
Raw Normal View History

/*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
*/
2019-06-18 11:13:14 -05:00
#pragma once
2019-06-18 11:13:14 -05:00
#ifdef WITH_QEMU
2019-06-18 11:13:14 -05:00
# include "capabilities.h"
# include "virfilecache.h"
# include "domain_conf.h"
# include "qemu/qemu_capabilities.h"
# include "qemu/qemu_conf.h"
2019-06-18 11:13:14 -05:00
# define TEST_QEMU_CAPS_PATH abs_srcdir "/qemucapabilitiesdata"
2022-07-20 09:51:55 +02:00
# define TEST_TPM_ENV_VAR "VIR_TEST_MOCK_FAKE_TPM_VERSION"
# define TPM_VER_1_2 "1.2"
# define TPM_VER_2_0 "2.0"
2019-04-16 12:22:31 +02:00
enum {
GIC_NONE = 0,
GIC_V2,
GIC_V3,
GIC_BOTH,
};
2022-01-06 12:32:25 +01:00
typedef enum {
HOST_OS_LINUX = 0,
2022-01-06 11:45:25 +01:00
HOST_OS_MACOS,
2022-01-06 12:32:25 +01:00
} testQemuHostOS;
2019-03-31 11:49:34 -04:00
typedef enum {
ARG_QEMU_CAPS = QEMU_CAPS_LAST + 1,
2019-03-31 11:49:34 -04:00
ARG_GIC,
ARG_MIGRATE_FROM,
ARG_MIGRATE_FD,
ARG_FLAGS,
ARG_PARSEFLAGS,
ARG_CAPS_ARCH,
ARG_CAPS_VER,
ARG_CAPS_HOST_CPU_MODEL,
2022-01-06 12:32:33 +01:00
ARG_HOST_OS,
2019-03-31 11:49:34 -04:00
ARG_END,
} testQemuInfoArgName;
typedef enum {
FLAG_EXPECT_FAILURE = 1 << 0,
FLAG_EXPECT_PARSE_ERROR = 1 << 1,
FLAG_FIPS_HOST = 1 << 2, /* simulate host with FIPS mode enabled */
2019-03-31 11:49:34 -04:00
FLAG_REAL_CAPS = 1 << 3,
FLAG_SKIP_LEGACY_CPUS = 1 << 4,
2019-08-08 18:55:14 +04:00
FLAG_SLIRP_HELPER = 1 << 5,
2019-03-31 11:49:34 -04:00
} testQemuInfoFlags;
struct testQemuConf {
GHashTable *capscache;
GHashTable *capslatest;
GHashTable *qapiSchemaCache;
};
typedef enum {
QEMU_CPU_DEF_DEFAULT,
QEMU_CPU_DEF_HASWELL,
QEMU_CPU_DEF_POWER8,
QEMU_CPU_DEF_POWER9,
QEMU_CPU_DEF_POWER10,
} qemuTestCPUDef;
struct testQemuArgs {
bool newargs;
virQEMUCaps *fakeCaps;
bool fakeCapsUsed;
char *capsver;
char *capsarch;
qemuTestCPUDef capsHostCPUModel;
int gic;
2022-01-06 12:32:33 +01:00
testQemuHostOS hostOS;
bool invalidarg;
};
2019-03-31 11:49:34 -04:00
struct testQemuInfo {
const char *name;
char *infile;
char *outfile;
char *errfile;
2021-03-11 08:16:13 +01:00
virQEMUCaps *qemuCaps;
2019-03-31 11:49:34 -04:00
const char *migrateFrom;
int migrateFd;
unsigned int flags;
unsigned int parseFlags;
virArch arch;
char *schemafile;
struct testQemuArgs args;
struct testQemuConf *conf;
2019-03-31 11:49:34 -04:00
};
2021-03-11 08:16:13 +01:00
virCaps *testQemuCapsInit(void);
2022-01-06 11:45:25 +01:00
virCaps *testQemuCapsInitMacOS(void);
2021-03-11 08:16:13 +01:00
virDomainXMLOption *testQemuXMLConfInit(void);
2021-03-11 08:16:13 +01:00
virQEMUCaps *qemuTestParseCapabilitiesArch(virArch arch,
const char *capsFile);
virCPUDef *qemuTestGetCPUDef(qemuTestCPUDef d);
2021-03-11 08:16:13 +01:00
void qemuTestSetHostArch(virQEMUDriver *driver,
virArch arch);
2021-03-11 08:16:13 +01:00
void qemuTestSetHostCPU(virQEMUDriver *driver,
2019-11-29 10:40:39 +00:00
virArch arch,
2021-03-11 08:16:13 +01:00
virCPUDef *cpu);
int qemuTestDriverInit(virQEMUDriver *driver);
void qemuTestDriverFree(virQEMUDriver *driver);
2021-03-11 08:16:13 +01:00
int qemuTestCapsCacheInsert(virFileCache *cache,
virQEMUCaps *caps);
2022-01-06 11:45:25 +01:00
int qemuTestCapsCacheInsertMacOS(virFileCache *cache,
virQEMUCaps *caps);
2021-03-11 08:16:13 +01:00
int testQemuCapsSetGIC(virQEMUCaps *qemuCaps,
int gic);
char *testQemuGetLatestCapsForArch(const char *arch,
const char *suffix);
GHashTable *testQemuGetLatestCaps(void);
typedef int (*testQemuCapsIterateCallback)(const char *inputDir,
const char *prefix,
const char *version,
2019-03-07 15:54:55 +01:00
const char *archName,
const char *suffix,
2019-03-07 15:54:55 +01:00
void *opaque);
int testQemuCapsIterate(const char *suffix,
2019-03-07 15:54:55 +01:00
testQemuCapsIterateCallback callback,
void *opaque);
void testQemuInfoSetArgs(struct testQemuInfo *info,
struct testQemuConf *conf,
...);
int testQemuInfoInitArgs(struct testQemuInfo *info);
2019-03-31 11:49:34 -04:00
void testQemuInfoClear(struct testQemuInfo *info);
int testQemuPrepareHostBackendChardevOne(virDomainDeviceDef *dev,
virDomainChrSourceDef *chardev,
void *opaque);
2019-06-18 11:13:14 -05:00
#endif