Hi,
I thought I'd need it but turned out I didn't. In case someone else finds a
good use for that, here's the patch. The idea was to provide a way to fake
qemu responses on -M ?, -cpu ?, and the like.
Jirka
From d1fa129d1018cd66d2bbdadc68a5f72e91bc6b0c Mon Sep 17 00:00:00 2001
Message-Id:
<d1fa129d1018cd66d2bbdadc68a5f72e91bc6b0c.1271681198.git.jdenemar(a)redhat.com>
From: Jiri Denemark <jdenemar(a)redhat.com>
Date: Fri, 16 Apr 2010 08:20:33 +0200
Subject: [PATCH] Support for faking emulator in qemuxml2argv tests
Mail-Followup-To: libvir-list(a)redhat.com
This patch allows for using custom scripts instead of /usr/bin/qemu
emulator in domain XML. To do so, one can specify relative path to the
custom script in <emulator/>. The path needs to be relative to
qemuxml2argvdata directory and it will be transparently made absolute in
runtime. The expected command line needs to contain the exact relative
path as was used in domain XML.
---
tests/qemuxml2argvtest.c | 19 +++++++++++++++++++
1 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index beb5dcd..da28c93 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -38,6 +38,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
virDomainDefPtr vmdef = NULL;
virDomainChrDef monitor_chr;
virConnectPtr conn;
+ char *emulator = NULL;
if (!(conn = virGetConnect()))
goto fail;
@@ -49,6 +50,17 @@ static int testCompareXMLToArgvFiles(const char *xml,
VIR_DOMAIN_XML_INACTIVE)))
goto fail;
+ if (vmdef->emulator && *vmdef->emulator != '/') {
+ emulator = vmdef->emulator;
+ vmdef->emulator = NULL;
+ if (virAsprintf(&vmdef->emulator, "%s/qemuxml2argvdata/%s",
+ abs_srcdir, emulator) < 0) {
+ vmdef->emulator = emulator;
+ emulator = NULL;
+ goto fail;
+ }
+ }
+
if (extraFlags & QEMUD_CMD_FLAG_DOMID)
vmdef->id = 6;
else
@@ -86,6 +98,12 @@ static int testCompareXMLToArgvFiles(const char *xml,
NULL, NULL, migrateFrom, NULL) < 0)
goto fail;
+ if (emulator && *argv) {
+ free(*(char**) argv);
+ *argv = emulator;
+ emulator = NULL;
+ }
+
len = 1; /* for trailing newline */
tmp = qenv;
while (*tmp) {
@@ -125,6 +143,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
ret = 0;
fail:
+ free(emulator);
free(actualargv);
if (argv) {
tmp = argv;
--
1.7.0.4