+Fri May 16 12:50:08 EST 2008 Daniel P. Berrange <berrange@redhat.com>
+
+ Make QEMU test cases independant of QEMU capabilities on
+ the host OS.
+ * src/qemu_conf.c, src/qemu_driver.c: Move stat() check on
+ qemu binary out of qemudBuildCommandLine() and into caller.
+ * tests/Makefile.am: Add testutilsqemu.{c,h} to qemu tests
+ * tests/qemuxml2argvtest.c, tests/qemuxml2xmltest.c: use
+ stable capability set in tests, independant of host OS.
+ * tests/testutilsqemu.c, tests/testutilsqemu.h: Define a
+ stable capability set for test suites
+
Fri May 16 11:29:30 CEST 2008 Jim Meyering <meyering@redhat.com>
* src/xml.c: Include "c-ctype.h".
char memory[50];
char vcpus[50];
char boot[QEMUD_MAX_BOOT_DEVS+1];
- struct stat sb;
struct qemud_vm_disk_def *disk = vm->def->disks;
struct qemud_vm_net_def *net = vm->def->nets;
struct qemud_vm_input_def *input = vm->def->inputs;
struct utsname ut;
int disableKQEMU = 0;
- /* Make sure the binary we are about to try exec'ing exists.
- * Technically we could catch the exec() failure, but that's
- * in a sub-process so its hard to feed back a useful error
- */
- if (stat(vm->def->os.binary, &sb) < 0) {
- qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
- _("Cannot find QEMU binary %s: %s"),
- vm->def->os.binary,
- strerror(errno));
- return -1;
- }
-
if (vm->qemuVersion == 0) {
if (qemudExtractVersionInfo(vm->def->os.binary,
&(vm->qemuVersion),
char **argv = NULL, **tmp;
int i, ret;
char logfile[PATH_MAX];
+ struct stat sb;
if (qemudIsActiveVM(vm)) {
qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
return -1;
}
+ /* Make sure the binary we are about to try exec'ing exists.
+ * Technically we could catch the exec() failure, but that's
+ * in a sub-process so its hard to feed back a useful error
+ */
+ if (stat(vm->def->os.binary, &sb) < 0) {
+ qemudReportError(conn, NULL, NULL, VIR_ERR_INTERNAL_ERROR,
+ _("Cannot find QEMU binary %s: %s"),
+ vm->def->os.binary,
+ strerror(errno));
+ return -1;
+ }
+
+
if (qemudBuildCommandLine(conn, driver, vm, &argv) < 0) {
close(vm->logfile);
vm->logfile = -1;
xmconfigtest_LDADD = $(LDADDS)
qemuxml2argvtest_SOURCES = \
- qemuxml2argvtest.c \
+ qemuxml2argvtest.c testutilsqemu.c testutilsqemu.h \
testutils.c testutils.h
qemuxml2argvtest_LDADD = $(LDADDS)
qemuxml2xmltest_SOURCES = \
- qemuxml2xmltest.c \
+ qemuxml2xmltest.c testutilsqemu.c testutilsqemu.h \
testutils.c testutils.h
qemuxml2xmltest_LDADD = $(LDADDS)
#include "testutils.h"
#include "qemu_conf.h"
+#include "testutilsqemu.h"
+
static char *progname;
static char *abs_srcdir;
static struct qemud_driver driver;
if (!abs_srcdir)
abs_srcdir = getcwd(cwd, sizeof(cwd));
- driver.caps = qemudCapsInit();
+ driver.caps = testQemuCapsInit();
#define DO_TEST(name, extraFlags) \
do { \
#include "internal.h"
#include "testutils.h"
#include "qemu_conf.h"
+#include "testutilsqemu.h"
static char *progname;
static char *abs_srcdir;
if (!abs_srcdir)
abs_srcdir = getcwd(cwd, sizeof(cwd));
- driver.caps = qemudCapsInit();
+ driver.caps = testQemuCapsInit();
#define DO_TEST(name) \
if (virtTestRun("QEMU XML-2-XML " name, \
--- /dev/null
+
+#include <sys/utsname.h>
+#include <stdlib.h>
+
+#include "testutilsqemu.h"
+
+virCapsPtr testQemuCapsInit(void) {
+ struct utsname utsname;
+ virCapsPtr caps;
+ virCapsGuestPtr guest;
+ static const char *const x86_machines[] = {
+ "pc", "isapc"
+ };
+ static const char *const xen_machines[] = {
+ "xenner"
+ };
+
+ uname (&utsname);
+ if ((caps = virCapabilitiesNew(utsname.machine,
+ 0, 0)) == NULL)
+ return NULL;
+
+ if ((guest = virCapabilitiesAddGuest(caps, "hvm", "i686", 32,
+ "/usr/bin/qemu", NULL,
+ 2, x86_machines)) == NULL)
+ goto cleanup;
+ if (virCapabilitiesAddGuestDomain(guest,
+ "qemu",
+ NULL,
+ NULL,
+ 0,
+ NULL) == NULL)
+ goto cleanup;
+
+ if ((guest = virCapabilitiesAddGuest(caps, "hvm", "x86_64", 64,
+ "/usr/bin/qemu-system-x86_64", NULL,
+ 2, x86_machines)) == NULL)
+ goto cleanup;
+ if (virCapabilitiesAddGuestDomain(guest,
+ "qemu",
+ NULL,
+ NULL,
+ 0,
+ NULL) == NULL)
+ goto cleanup;
+ if (virCapabilitiesAddGuestDomain(guest,
+ "kvm",
+ "/usr/bin/kvm",
+ NULL,
+ 0,
+ NULL) == NULL)
+ goto cleanup;
+
+ if ((guest = virCapabilitiesAddGuest(caps, "xen", "x86_64", 64,
+ "/usr/bin/xenner", NULL,
+ 1, xen_machines)) == NULL)
+ goto cleanup;
+ if (virCapabilitiesAddGuestDomain(guest,
+ "kvm",
+ "/usr/bin/kvm",
+ NULL,
+ 0,
+ NULL) == NULL)
+ goto cleanup;
+
+ return caps;
+
+cleanup:
+ virCapabilitiesFree(caps);
+ return NULL;
+}
--- /dev/null
+
+#include "capabilities.h"
+
+virCapsPtr testQemuCapsInit(void);
+