2009-06-11 14:17:42 +00:00
|
|
|
#include <config.h>
|
|
|
|
|
|
|
|
#ifdef WITH_QEMU
|
|
|
|
|
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
|
|
|
|
#include "testutils.h"
|
2009-09-15 16:14:43 +00:00
|
|
|
#include "qemu/qemu_conf.h"
|
2009-06-11 14:17:42 +00:00
|
|
|
|
|
|
|
#define MAX_HELP_OUTPUT_SIZE 1024*64
|
|
|
|
|
|
|
|
struct testInfo {
|
|
|
|
const char *name;
|
2010-02-09 13:06:56 +00:00
|
|
|
unsigned long long flags;
|
|
|
|
unsigned int version;
|
|
|
|
unsigned int is_kvm;
|
|
|
|
unsigned int kvm_version;
|
2009-06-11 14:17:42 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
static char *progname;
|
|
|
|
static char *abs_srcdir;
|
|
|
|
|
2009-12-21 20:36:32 +00:00
|
|
|
static void printMismatchedFlags(int got, int expect)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
for (i = 0 ; i < (sizeof(got)*8) ; i++) {
|
|
|
|
int gotFlag = (got & (1 << i));
|
|
|
|
int expectFlag = (expect & (1 << i));
|
|
|
|
if (gotFlag && !expectFlag)
|
|
|
|
fprintf(stderr, "Extra flag %i\n", i);
|
|
|
|
if (!gotFlag && expectFlag)
|
|
|
|
fprintf(stderr, "Missing flag %i\n", i);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2009-06-11 14:17:42 +00:00
|
|
|
static int testHelpStrParsing(const void *data)
|
|
|
|
{
|
|
|
|
const struct testInfo *info = data;
|
|
|
|
char path[PATH_MAX];
|
|
|
|
char helpStr[MAX_HELP_OUTPUT_SIZE];
|
|
|
|
char *help = &(helpStr[0]);
|
2010-02-09 13:06:56 +00:00
|
|
|
unsigned int version, is_kvm, kvm_version;
|
|
|
|
unsigned long long flags;
|
2009-06-11 14:17:42 +00:00
|
|
|
|
|
|
|
snprintf(path, PATH_MAX, "%s/qemuhelpdata/%s", abs_srcdir, info->name);
|
|
|
|
|
|
|
|
if (virtTestLoadFile(path, &help, MAX_HELP_OUTPUT_SIZE) < 0)
|
|
|
|
return -1;
|
|
|
|
|
2010-02-24 16:44:36 +00:00
|
|
|
if (qemudParseHelpStr("QEMU", help, &flags,
|
|
|
|
&version, &is_kvm, &kvm_version) == -1)
|
2009-06-11 14:17:42 +00:00
|
|
|
return -1;
|
|
|
|
|
|
|
|
if (flags != info->flags) {
|
2010-02-09 13:06:56 +00:00
|
|
|
fprintf(stderr, "Computed flags do not match: got 0x%llx, expected 0x%llx\n",
|
2009-06-11 14:17:42 +00:00
|
|
|
flags, info->flags);
|
2009-12-21 20:36:32 +00:00
|
|
|
|
|
|
|
if (getenv("VIR_TEST_DEBUG"))
|
|
|
|
printMismatchedFlags(flags, info->flags);
|
|
|
|
|
2009-06-11 14:17:42 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (version != info->version) {
|
|
|
|
fprintf(stderr, "Parsed versions do not match: got %u, expected %u\n",
|
|
|
|
version, info->version);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (is_kvm != info->is_kvm) {
|
|
|
|
fprintf(stderr, "Parsed is_kvm flag does not match: got %u, expected %u\n",
|
|
|
|
is_kvm, info->is_kvm);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
2009-12-21 20:36:32 +00:00
|
|
|
if (kvm_version != info->kvm_version) {
|
2009-06-11 14:17:42 +00:00
|
|
|
fprintf(stderr, "Parsed KVM versions do not match: got %u, expected %u\n",
|
2009-12-21 20:36:32 +00:00
|
|
|
kvm_version, info->kvm_version);
|
2009-06-11 14:17:42 +00:00
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int
|
|
|
|
mymain(int argc, char **argv)
|
|
|
|
{
|
|
|
|
int ret = 0;
|
|
|
|
char cwd[PATH_MAX];
|
|
|
|
|
|
|
|
progname = argv[0];
|
|
|
|
|
|
|
|
if (argc > 1) {
|
|
|
|
fprintf(stderr, "Usage: %s\n", progname);
|
|
|
|
return (EXIT_FAILURE);
|
|
|
|
}
|
|
|
|
|
|
|
|
abs_srcdir = getenv("abs_srcdir");
|
|
|
|
if (!abs_srcdir)
|
|
|
|
abs_srcdir = getcwd(cwd, sizeof(cwd));
|
|
|
|
|
|
|
|
#define DO_TEST(name, flags, version, is_kvm, kvm_version) \
|
|
|
|
do { \
|
|
|
|
const struct testInfo info = { name, flags, version, is_kvm, kvm_version }; \
|
|
|
|
if (virtTestRun("QEMU Help String Parsing " name, \
|
|
|
|
1, testHelpStrParsing, &info) < 0) \
|
|
|
|
ret = -1; \
|
|
|
|
} while (0)
|
|
|
|
|
2009-07-06 13:59:19 +00:00
|
|
|
DO_TEST("qemu-0.9.1",
|
|
|
|
QEMUD_CMD_FLAG_KQEMU |
|
|
|
|
QEMUD_CMD_FLAG_VNC_COLON |
|
|
|
|
QEMUD_CMD_FLAG_NO_REBOOT |
|
|
|
|
QEMUD_CMD_FLAG_DRIVE |
|
|
|
|
QEMUD_CMD_FLAG_NAME,
|
|
|
|
9001, 0, 0);
|
|
|
|
DO_TEST("kvm-74",
|
|
|
|
QEMUD_CMD_FLAG_VNC_COLON |
|
|
|
|
QEMUD_CMD_FLAG_NO_REBOOT |
|
|
|
|
QEMUD_CMD_FLAG_DRIVE |
|
|
|
|
QEMUD_CMD_FLAG_DRIVE_BOOT |
|
|
|
|
QEMUD_CMD_FLAG_NAME |
|
|
|
|
QEMUD_CMD_FLAG_VNET_HDR |
|
|
|
|
QEMUD_CMD_FLAG_MIGRATE_KVM_STDIO |
|
|
|
|
QEMUD_CMD_FLAG_KVM |
|
Support configuration of huge pages in guests
Add option to domain XML for
<memoryBacking>
<hugepages/>
</memoryBacking>
* configure.in: Add check for mntent.h
* qemud/libvirtd_qemu.aug, qemud/test_libvirtd_qemu.aug, src/qemu.conf
Add 'hugetlbfs_mount' config parameter
* src/qemu_conf.c, src/qemu_conf.h: Check for -mem-path flag in QEMU,
and pass it when hugepages are requested.
Load hugetlbfs_mount config parameter, search for mount if not given.
* src/qemu_driver.c: Free hugetlbfs_mount/path parameter in driver shutdown.
Create directory for QEMU hugepage usage, chowning if required.
* docs/formatdomain.html.in: Document memoryBacking/hugepages elements
* docs/schemas/domain.rng: Add memoryBacking/hugepages elements to schema
* src/util.c, src/util.h, src/libvirt_private.syms: Add virFileFindMountPoint
helper API
* tests/qemuhelptest.c: Add -mem-path constants
* tests/qemuxml2argvtest.c, tests/qemuxml2xmltest.c: Add tests for hugepage
handling
* tests/qemuxml2argvdata/qemuxml2argv-hugepages.xml,
tests/qemuxml2argvdata/qemuxml2argv-hugepages.args: Data files for
hugepage tests
2009-08-25 14:05:18 +00:00
|
|
|
QEMUD_CMD_FLAG_DRIVE_FORMAT |
|
|
|
|
QEMUD_CMD_FLAG_MEM_PATH,
|
2009-07-06 13:59:19 +00:00
|
|
|
9001, 1, 74);
|
|
|
|
DO_TEST("qemu-0.10.5",
|
|
|
|
QEMUD_CMD_FLAG_KQEMU |
|
|
|
|
QEMUD_CMD_FLAG_VNC_COLON |
|
|
|
|
QEMUD_CMD_FLAG_NO_REBOOT |
|
|
|
|
QEMUD_CMD_FLAG_DRIVE |
|
|
|
|
QEMUD_CMD_FLAG_NAME |
|
|
|
|
QEMUD_CMD_FLAG_UUID |
|
|
|
|
QEMUD_CMD_FLAG_MIGRATE_QEMU_TCP |
|
|
|
|
QEMUD_CMD_FLAG_MIGRATE_QEMU_EXEC |
|
|
|
|
QEMUD_CMD_FLAG_DRIVE_CACHE_V2 |
|
|
|
|
QEMUD_CMD_FLAG_DRIVE_FORMAT |
|
2009-08-14 11:22:01 +00:00
|
|
|
QEMUD_CMD_FLAG_DRIVE_SERIAL |
|
2009-07-17 21:08:33 +00:00
|
|
|
QEMUD_CMD_FLAG_VGA |
|
2009-11-20 14:41:05 +00:00
|
|
|
QEMUD_CMD_FLAG_0_10 |
|
2009-12-21 20:23:55 +00:00
|
|
|
QEMUD_CMD_FLAG_ENABLE_KVM |
|
|
|
|
QEMUD_CMD_FLAG_SDL,
|
2009-07-06 13:59:19 +00:00
|
|
|
10005, 0, 0);
|
|
|
|
DO_TEST("qemu-kvm-0.10.5",
|
|
|
|
QEMUD_CMD_FLAG_VNC_COLON |
|
|
|
|
QEMUD_CMD_FLAG_NO_REBOOT |
|
|
|
|
QEMUD_CMD_FLAG_DRIVE |
|
|
|
|
QEMUD_CMD_FLAG_DRIVE_BOOT |
|
|
|
|
QEMUD_CMD_FLAG_NAME |
|
|
|
|
QEMUD_CMD_FLAG_UUID |
|
|
|
|
QEMUD_CMD_FLAG_VNET_HDR |
|
|
|
|
QEMUD_CMD_FLAG_MIGRATE_QEMU_TCP |
|
|
|
|
QEMUD_CMD_FLAG_MIGRATE_QEMU_EXEC |
|
|
|
|
QEMUD_CMD_FLAG_DRIVE_CACHE_V2 |
|
|
|
|
QEMUD_CMD_FLAG_KVM |
|
|
|
|
QEMUD_CMD_FLAG_DRIVE_FORMAT |
|
2009-08-14 11:22:01 +00:00
|
|
|
QEMUD_CMD_FLAG_DRIVE_SERIAL |
|
2009-07-17 21:08:33 +00:00
|
|
|
QEMUD_CMD_FLAG_VGA |
|
2009-08-14 07:31:11 +00:00
|
|
|
QEMUD_CMD_FLAG_0_10 |
|
Support configuration of huge pages in guests
Add option to domain XML for
<memoryBacking>
<hugepages/>
</memoryBacking>
* configure.in: Add check for mntent.h
* qemud/libvirtd_qemu.aug, qemud/test_libvirtd_qemu.aug, src/qemu.conf
Add 'hugetlbfs_mount' config parameter
* src/qemu_conf.c, src/qemu_conf.h: Check for -mem-path flag in QEMU,
and pass it when hugepages are requested.
Load hugetlbfs_mount config parameter, search for mount if not given.
* src/qemu_driver.c: Free hugetlbfs_mount/path parameter in driver shutdown.
Create directory for QEMU hugepage usage, chowning if required.
* docs/formatdomain.html.in: Document memoryBacking/hugepages elements
* docs/schemas/domain.rng: Add memoryBacking/hugepages elements to schema
* src/util.c, src/util.h, src/libvirt_private.syms: Add virFileFindMountPoint
helper API
* tests/qemuhelptest.c: Add -mem-path constants
* tests/qemuxml2argvtest.c, tests/qemuxml2xmltest.c: Add tests for hugepage
handling
* tests/qemuxml2argvdata/qemuxml2argv-hugepages.xml,
tests/qemuxml2argvdata/qemuxml2argv-hugepages.args: Data files for
hugepage tests
2009-08-25 14:05:18 +00:00
|
|
|
QEMUD_CMD_FLAG_PCIDEVICE |
|
2009-12-21 20:23:55 +00:00
|
|
|
QEMUD_CMD_FLAG_MEM_PATH |
|
|
|
|
QEMUD_CMD_FLAG_SDL,
|
2009-07-06 13:59:19 +00:00
|
|
|
10005, 1, 0);
|
|
|
|
DO_TEST("kvm-86",
|
|
|
|
QEMUD_CMD_FLAG_VNC_COLON |
|
|
|
|
QEMUD_CMD_FLAG_NO_REBOOT |
|
|
|
|
QEMUD_CMD_FLAG_DRIVE |
|
|
|
|
QEMUD_CMD_FLAG_DRIVE_BOOT |
|
|
|
|
QEMUD_CMD_FLAG_NAME |
|
|
|
|
QEMUD_CMD_FLAG_UUID |
|
|
|
|
QEMUD_CMD_FLAG_VNET_HDR |
|
|
|
|
QEMUD_CMD_FLAG_MIGRATE_QEMU_TCP |
|
|
|
|
QEMUD_CMD_FLAG_MIGRATE_QEMU_EXEC |
|
|
|
|
QEMUD_CMD_FLAG_DRIVE_CACHE_V2 |
|
|
|
|
QEMUD_CMD_FLAG_KVM |
|
|
|
|
QEMUD_CMD_FLAG_DRIVE_FORMAT |
|
2009-08-14 11:22:01 +00:00
|
|
|
QEMUD_CMD_FLAG_DRIVE_SERIAL |
|
2009-07-17 21:08:33 +00:00
|
|
|
QEMUD_CMD_FLAG_VGA |
|
2009-08-14 07:31:11 +00:00
|
|
|
QEMUD_CMD_FLAG_0_10 |
|
2009-12-21 20:23:55 +00:00
|
|
|
QEMUD_CMD_FLAG_PCIDEVICE |
|
|
|
|
QEMUD_CMD_FLAG_SDL,
|
2009-07-06 13:59:19 +00:00
|
|
|
10050, 1, 0);
|
2009-09-10 08:36:13 +00:00
|
|
|
DO_TEST("qemu-kvm-0.11.0-rc2",
|
|
|
|
QEMUD_CMD_FLAG_VNC_COLON |
|
|
|
|
QEMUD_CMD_FLAG_NO_REBOOT |
|
|
|
|
QEMUD_CMD_FLAG_DRIVE |
|
|
|
|
QEMUD_CMD_FLAG_DRIVE_BOOT |
|
|
|
|
QEMUD_CMD_FLAG_NAME |
|
|
|
|
QEMUD_CMD_FLAG_UUID |
|
|
|
|
QEMUD_CMD_FLAG_VNET_HDR |
|
|
|
|
QEMUD_CMD_FLAG_MIGRATE_QEMU_TCP |
|
|
|
|
QEMUD_CMD_FLAG_MIGRATE_QEMU_EXEC |
|
|
|
|
QEMUD_CMD_FLAG_DRIVE_CACHE_V2 |
|
|
|
|
QEMUD_CMD_FLAG_KVM |
|
|
|
|
QEMUD_CMD_FLAG_DRIVE_FORMAT |
|
|
|
|
QEMUD_CMD_FLAG_DRIVE_SERIAL |
|
|
|
|
QEMUD_CMD_FLAG_VGA |
|
|
|
|
QEMUD_CMD_FLAG_0_10 |
|
|
|
|
QEMUD_CMD_FLAG_PCIDEVICE |
|
2009-11-20 14:41:05 +00:00
|
|
|
QEMUD_CMD_FLAG_MEM_PATH |
|
2010-01-06 17:01:51 +00:00
|
|
|
QEMUD_CMD_FLAG_ENABLE_KVM |
|
2009-12-21 20:23:55 +00:00
|
|
|
QEMUD_CMD_FLAG_BALLOON |
|
|
|
|
QEMUD_CMD_FLAG_SDL,
|
2009-09-10 08:36:13 +00:00
|
|
|
10092, 1, 0);
|
2009-12-21 20:36:32 +00:00
|
|
|
DO_TEST("qemu-0.12.1",
|
|
|
|
QEMUD_CMD_FLAG_VNC_COLON |
|
|
|
|
QEMUD_CMD_FLAG_NO_REBOOT |
|
|
|
|
QEMUD_CMD_FLAG_DRIVE |
|
|
|
|
QEMUD_CMD_FLAG_NAME |
|
|
|
|
QEMUD_CMD_FLAG_UUID |
|
|
|
|
QEMUD_CMD_FLAG_MIGRATE_QEMU_TCP |
|
|
|
|
QEMUD_CMD_FLAG_MIGRATE_QEMU_EXEC |
|
|
|
|
QEMUD_CMD_FLAG_DRIVE_CACHE_V2 |
|
|
|
|
QEMUD_CMD_FLAG_DRIVE_FORMAT |
|
|
|
|
QEMUD_CMD_FLAG_DRIVE_SERIAL |
|
|
|
|
QEMUD_CMD_FLAG_VGA |
|
|
|
|
QEMUD_CMD_FLAG_0_10 |
|
|
|
|
QEMUD_CMD_FLAG_ENABLE_KVM |
|
2009-12-21 20:23:55 +00:00
|
|
|
QEMUD_CMD_FLAG_SDL |
|
2009-12-21 20:36:32 +00:00
|
|
|
QEMUD_CMD_FLAG_XEN_DOMID |
|
|
|
|
QEMUD_CMD_FLAG_MIGRATE_QEMU_UNIX |
|
|
|
|
QEMUD_CMD_FLAG_CHARDEV |
|
|
|
|
QEMUD_CMD_FLAG_BALLOON |
|
2010-01-18 15:51:52 +00:00
|
|
|
QEMUD_CMD_FLAG_DEVICE |
|
2010-02-02 18:07:12 +00:00
|
|
|
QEMUD_CMD_FLAG_SMP_TOPOLOGY |
|
|
|
|
QEMUD_CMD_FLAG_RTC,
|
2009-12-21 20:36:32 +00:00
|
|
|
12001, 0, 0);
|
2009-06-11 14:17:42 +00:00
|
|
|
|
|
|
|
return ret == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
|
|
|
|
}
|
|
|
|
|
|
|
|
VIRT_TEST_MAIN(mymain)
|
|
|
|
|
|
|
|
#else
|
|
|
|
|
|
|
|
int main (void) { return (77); /* means 'test skipped' for automake */ }
|
|
|
|
|
|
|
|
#endif /* WITH_QEMU */
|