On 12/01/2010 07:56 AM, Jiri Denemark wrote:
This patch allows for using custom scripts instead of /usr/bin/qemu
emulator in domain XML. To do so, one would 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.
Makes sense as a testing mechanism, while still something we do not want
exposed to normal usage.
The problem is RelaxNG schema for domain XML only allows for absolute
path within <emulator/>. To workaround it, an extra '/' must be added at
the beginning of the path. That is, instead of "./qemu.sh" or
"../emulator/qemu.sh" one would use "/./qemu.sh" or
"/../emulator/qemu.sh". The extra slash is removed before further
processing. I don't like this workaround, it's very ugly but it's the
best option I was able to come up with. Relaxing domain XML schema is
not an option IMO.
Agreed - relaxing the schema would leak the notion of a relative
emulator path, which we don't want to do. The hack looks as good as any
to me, as long as it's well documented in the code as well as the commit
message.
---
tests/qemuxml2argvtest.c | 18 ++++++++++++++++++
1 files changed, 18 insertions(+), 0 deletions(-)
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index e6174be..dd07001 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -41,6 +41,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
virDomainChrDef monitor_chr;
virConnectPtr conn;
char *log = NULL;
+ char *emulator = NULL;
if (!(conn = virGetConnect()))
goto fail;
@@ -52,6 +53,16 @@ static int testCompareXMLToArgvFiles(const char *xml,
VIR_DOMAIN_XML_INACTIVE)))
goto fail;
+ if (vmdef->emulator && STRPREFIX(vmdef->emulator, "/.")) {
+ if (!(emulator = strdup(vmdef->emulator + 1)))
In other words, I'd add a comment here explaining that for test purposes
only, we massage particular emulator names.
ACK, with that nit addressed.
--
Eric Blake eblake(a)redhat.com +1-801-349-2682
Libvirt virtualization library
http://libvirt.org