On Thu, Oct 02, 2008 at 07:37:38PM +0200, Jim Meyering wrote:
"Daniel P. Berrange" <berrange(a)redhat.com> wrote:
...
> Now previously since we just use 'execv' the QEMU process would just
> inherit all libvirtd's environment variables. When we now use execve()
> no variables are inherited - we have to explicitly set all the ones
> we need. I'm not sure what we should consider the mimimum required?
>
> I'm merely setting 'LC_ALL=C' to ensure it runs in C locale. Do we
> need to set $PATH for QEMU - maybe ? Anything else which is good
> practice to set ?
If QEMU uses PATH, then propagating that is necessary.
I guess it's debatable whether to use PATH=$PATH or
to use some hard-coded default on the RHS. But using PATH=$PATH
seems friendlier, in case whatever QEMU uses is in some non-default
location.
If it uses mkstemp or the like, then including TMPDIR would be good.
Depending on QEMU, maybe things like HOME, USER, LOGNAME too.
Here's an update which sets those, if they're present in libvirtd env.
The changed bit is here:
+ ADD_ENV_COPY("LD_PRELOAD");
+ ADD_ENV_COPY("LD_LIBRARY_PATH");
+ ADD_ENV_COPY("PATH");
+ ADD_ENV_COPY("HOME");
+ ADD_ENV_COPY("USER");
+ ADD_ENV_COPY("LOGNAME");
+ ADD_ENV_COPY("TMPDIR");
Daniel
diff --git a/docs/libvirt.rng b/docs/libvirt.rng
--- a/docs/libvirt.rng
+++ b/docs/libvirt.rng
@@ -645,9 +645,21 @@
<define name='graphic'>
<element name='graphics'>
<choice>
- <attribute name='type'>
- <value>sdl</value>
- </attribute>
+ <group>
+ <attribute name='type'>
+ <value>sdl</value>
+ </attribute>
+ <optional>
+ <attribute name='display'>
+ <text/>
+ </attribute>
+ </optional>
+ <optional>
+ <attribute name='xauth'>
+ <text/>
+ </attribute>
+ </optional>
+ </group>
<group>
<attribute name='type'>
<value>vnc</value>
diff --git a/src/qemu_conf.c b/src/qemu_conf.c
--- a/src/qemu_conf.c
+++ b/src/qemu_conf.c
@@ -28,6 +28,7 @@
#include <limits.h>
#include <sys/types.h>
#include <sys/stat.h>
+#include <stdlib.h>
#include <unistd.h>
#include <errno.h>
#include <fcntl.h>
@@ -710,6 +711,7 @@ int qemudBuildCommandLine(virConnectPtr
virDomainObjPtr vm,
unsigned int qemuCmdFlags,
const char ***retargv,
+ const char ***retenv,
int **tapfds,
int *ntapfds,
const char *migrateFrom) {
@@ -728,6 +730,8 @@ int qemudBuildCommandLine(virConnectPtr
int disableKQEMU = 0;
int qargc = 0, qarga = 0;
const char **qargv = NULL;
+ int qenvc = 0, qenva = 0;
+ const char **qenv = NULL;
const char *emulator;
uname(&ut);
@@ -775,14 +779,56 @@ int qemudBuildCommandLine(virConnectPtr
do { \
ADD_ARG_LIT("-usbdevice"); \
ADD_ARG_SPACE; \
- if ((asprintf((char **)&(qargv[qargc++]), "disk:%s", thisarg)) ==
-1) { \
+ if ((asprintf((char **)&(qargv[qargc++]), \
+ "disk:%s", thisarg)) == -1) { \
qargv[qargc-1] = NULL; \
goto no_memory; \
} \
} while (0)
+#define ADD_ENV_SPACE \
+ do { \
+ if (qenvc == qenva) { \
+ qenva += 10; \
+ if (VIR_REALLOC_N(qenv, qenva) < 0) \
+ goto no_memory; \
+ } \
+ } while (0)
+
+#define ADD_ENV(thisarg) \
+ do { \
+ ADD_ENV_SPACE; \
+ qenv[qenvc++] = thisarg; \
+ } while (0)
+
+#define ADD_ENV_LIT(thisarg) \
+ do { \
+ ADD_ENV_SPACE; \
+ if ((qenv[qenvc++] = strdup(thisarg)) == NULL) \
+ goto no_memory; \
+ } while (0)
+
+#define ADD_ENV_COPY(envname) \
+ do { \
+ char *val = getenv(envname); \
+ ADD_ENV_SPACE; \
+ if (val != NULL && \
+ (qenv[qenvc++] = strdup(val)) == NULL) \
+ goto no_memory; \
+ } while (0)
+
snprintf(memory, sizeof(memory), "%lu", vm->def->memory/1024);
snprintf(vcpus, sizeof(vcpus), "%lu", vm->def->vcpus);
+
+ ADD_ENV_LIT("LC_ALL=C");
+
+ ADD_ENV_COPY("LD_PRELOAD");
+ ADD_ENV_COPY("LD_LIBRARY_PATH");
+ ADD_ENV_COPY("PATH");
+ ADD_ENV_COPY("HOME");
+ ADD_ENV_COPY("USER");
+ ADD_ENV_COPY("LOGNAME");
+ ADD_ENV_COPY("TMPDIR");
emulator = vm->def->emulator;
if (!emulator)
@@ -1163,7 +1209,24 @@ int qemudBuildCommandLine(virConnectPtr
}
} else if (vm->def->graphics &&
vm->def->graphics->type == VIR_DOMAIN_GRAPHICS_TYPE_SDL) {
- /* SDL is the default. no args needed */
+ char *xauth = NULL;
+ char *display = NULL;
+
+ if (vm->def->graphics->data.sdl.xauth &&
+ asprintf(&xauth, "XAUTHORITY=%s",
+ vm->def->graphics->data.sdl.xauth) < 0)
+ goto no_memory;
+ if (vm->def->graphics->data.sdl.display &&
+ asprintf(&display, "DISPLAY=%s",
+ vm->def->graphics->data.sdl.display) < 0) {
+ VIR_FREE(xauth);
+ goto no_memory;
+ }
+
+ if (xauth)
+ ADD_ENV(xauth);
+ if (display)
+ ADD_ENV(display);
}
/* Add sound hardware */
@@ -1225,8 +1288,10 @@ int qemudBuildCommandLine(virConnectPtr
}
ADD_ARG(NULL);
+ ADD_ENV(NULL);
*retargv = qargv;
+ *retenv = qenv;
return 0;
no_memory:
@@ -1245,9 +1310,19 @@ int qemudBuildCommandLine(virConnectPtr
VIR_FREE((qargv)[i]);
VIR_FREE(qargv);
}
+ if (qenv) {
+ for (i = 0 ; i < qenvc ; i++)
+ VIR_FREE((qenv)[i]);
+ VIR_FREE(qenv);
+ }
return -1;
#undef ADD_ARG
#undef ADD_ARG_LIT
#undef ADD_ARG_SPACE
+#undef ADD_USBDISK
+#undef ADD_ENV
+#undef ADD_ENV_COPY
+#undef ADD_ENV_LIT
+#undef ADD_ENV_SPACE
}
diff --git a/src/qemu_conf.h b/src/qemu_conf.h
--- a/src/qemu_conf.h
+++ b/src/qemu_conf.h
@@ -93,7 +93,8 @@ int qemudBuildCommandLine
struct qemud_driver *driver,
virDomainObjPtr dom,
unsigned int qemuCmdFlags,
- const char ***argv,
+ const char ***retargv,
+ const char ***retenv,
int **tapfds,
int *ntapfds,
const char *migrateFrom);
diff --git a/src/qemu_driver.c b/src/qemu_driver.c
--- a/src/qemu_driver.c
+++ b/src/qemu_driver.c
@@ -844,6 +844,7 @@ static int qemudStartVMDaemon(virConnect
virDomainObjPtr vm,
const char *migrateFrom) {
const char **argv = NULL, **tmp;
+ const char **progenv = NULL;
int i, ret;
char logfile[PATH_MAX];
struct stat sb;
@@ -939,13 +940,23 @@ static int qemudStartVMDaemon(virConnect
}
if (qemudBuildCommandLine(conn, driver, vm,
- qemuCmdFlags, &argv,
+ qemuCmdFlags, &argv, &progenv,
&tapfds, &ntapfds, migrateFrom) < 0) {
close(vm->logfile);
vm->logfile = -1;
return -1;
}
+ tmp = progenv;
+ while (*tmp) {
+ if (safewrite(vm->logfile, *tmp, strlen(*tmp)) < 0)
+ qemudLog(QEMUD_WARN, _("Unable to write envv to logfile %d:
%s\n"),
+ errno, strerror(errno));
+ if (safewrite(vm->logfile, " ", 1) < 0)
+ qemudLog(QEMUD_WARN, _("Unable to write envv to logfile %d:
%s\n"),
+ errno, strerror(errno));
+ tmp++;
+ }
tmp = argv;
while (*tmp) {
if (safewrite(vm->logfile, *tmp, strlen(*tmp)) < 0)
@@ -966,7 +977,7 @@ static int qemudStartVMDaemon(virConnect
for (i = 0 ; i < ntapfds ; i++)
FD_SET(tapfds[i], &keepfd);
- ret = virExec(conn, argv, NULL, &keepfd, &vm->pid,
+ ret = virExec(conn, argv, progenv, &keepfd, &vm->pid,
vm->stdin_fd, &vm->stdout_fd, &vm->stderr_fd,
VIR_EXEC_NONBLOCK);
if (ret == 0) {
@@ -977,6 +988,10 @@ static int qemudStartVMDaemon(virConnect
for (i = 0 ; argv[i] ; i++)
VIR_FREE(argv[i]);
VIR_FREE(argv);
+
+ for (i = 0 ; progenv[i] ; i++)
+ VIR_FREE(progenv[i]);
+ VIR_FREE(progenv);
if (tapfds) {
for (i = 0 ; i < ntapfds ; i++) {
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-boot-cdrom.args
b/tests/qemuxml2argvdata/qemuxml2argv-boot-cdrom.args
--- a/tests/qemuxml2argvdata/qemuxml2argv-boot-cdrom.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-boot-cdrom.args
@@ -1,1 +1,1 @@
-/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot d -cdrom
/dev/cdrom -net none -serial none -parallel none -usb
+LC_ALL=C /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot d
-cdrom /dev/cdrom -net none -serial none -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-boot-floppy.args
b/tests/qemuxml2argvdata/qemuxml2argv-boot-floppy.args
--- a/tests/qemuxml2argvdata/qemuxml2argv-boot-floppy.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-boot-floppy.args
@@ -1,1 +1,1 @@
-/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot a -hda
/dev/HostVG/QEMUGuest1 -fda /tmp/firmware.img -net none -serial none -parallel none -usb
+LC_ALL=C /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot a
-hda /dev/HostVG/QEMUGuest1 -fda /tmp/firmware.img -net none -serial none -parallel none
-usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-boot-network.args
b/tests/qemuxml2argvdata/qemuxml2argv-boot-network.args
--- a/tests/qemuxml2argvdata/qemuxml2argv-boot-network.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-boot-network.args
@@ -1,1 +1,1 @@
-/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot n -hda
/dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb
+LC_ALL=C /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot n
-hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-bootloader.args
b/tests/qemuxml2argvdata/qemuxml2argv-bootloader.args
--- a/tests/qemuxml2argvdata/qemuxml2argv-bootloader.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-bootloader.args
@@ -1,1 +1,1 @@
-/usr/bin/qemu-kvm -S -M xenner -m 214 -smp 1 -nographic -monitor pty -no-acpi -bootloader
/usr/bin/pygrub -cdrom /dev/cdrom -net none -serial none -parallel none -usb
+LC_ALL=C /usr/bin/qemu-kvm -S -M xenner -m 214 -smp 1 -nographic -monitor pty -no-acpi
-bootloader /usr/bin/pygrub -cdrom /dev/cdrom -net none -serial none -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-clock-localtime.args
b/tests/qemuxml2argvdata/qemuxml2argv-clock-localtime.args
--- a/tests/qemuxml2argvdata/qemuxml2argv-clock-localtime.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-clock-localtime.args
@@ -1,1 +1,1 @@
-/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -localtime -no-acpi -boot c
-hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb
+LC_ALL=C /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -localtime -no-acpi
-boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-clock-utc.args
b/tests/qemuxml2argvdata/qemuxml2argv-clock-utc.args
--- a/tests/qemuxml2argvdata/qemuxml2argv-clock-utc.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-clock-utc.args
@@ -1,1 +1,1 @@
-/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda
/dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb
+LC_ALL=C /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c
-hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-console-compat.args
b/tests/qemuxml2argvdata/qemuxml2argv-console-compat.args
--- a/tests/qemuxml2argvdata/qemuxml2argv-console-compat.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-console-compat.args
@@ -1,1 +1,1 @@
-/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda
/dev/HostVG/QEMUGuest1 -net none -serial pty -parallel none -usb
+LC_ALL=C /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c
-hda /dev/HostVG/QEMUGuest1 -net none -serial pty -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-empty.args
b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-empty.args
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-empty.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-empty.args
@@ -1,1 +1,1 @@
-/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -drive
file=/dev/HostVG/QEMUGuest1,if=ide,index=0 -drive file=,if=ide,media=cdrom,index=2 -net
none -serial none -parallel none -usb
+LC_ALL=C /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c
-drive file=/dev/HostVG/QEMUGuest1,if=ide,index=0 -drive file=,if=ide,media=cdrom,index=2
-net none -serial none -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom.args
b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom.args
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom.args
@@ -1,1 +1,1 @@
-/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda
/dev/HostVG/QEMUGuest1 -cdrom /root/boot.iso -net none -serial none -parallel none -usb
+LC_ALL=C /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c
-hda /dev/HostVG/QEMUGuest1 -cdrom /root/boot.iso -net none -serial none -parallel none
-usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-boot-cdrom.args
b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-boot-cdrom.args
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-boot-cdrom.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-boot-cdrom.args
@@ -1,1 +1,1 @@
-/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot d -drive
file=/dev/HostVG/QEMUGuest1,if=ide,index=0 -drive
file=/dev/HostVG/QEMUGuest2,if=ide,media=cdrom,index=2 -net none -serial none -parallel
none -usb
+LC_ALL=C /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot d
-drive file=/dev/HostVG/QEMUGuest1,if=ide,index=0 -drive
file=/dev/HostVG/QEMUGuest2,if=ide,media=cdrom,index=2 -net none -serial none -parallel
none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-boot-disk.args
b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-boot-disk.args
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-boot-disk.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-boot-disk.args
@@ -1,1 +1,1 @@
-/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -drive
file=/dev/HostVG/QEMUGuest1,if=ide,index=0,boot=on -drive
file=/dev/HostVG/QEMUGuest2,if=ide,media=cdrom,index=2 -net none -serial none -parallel
none -usb
+LC_ALL=C /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c
-drive file=/dev/HostVG/QEMUGuest1,if=ide,index=0,boot=on -drive
file=/dev/HostVG/QEMUGuest2,if=ide,media=cdrom,index=2 -net none -serial none -parallel
none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-floppy.args
b/tests/qemuxml2argvdata/qemuxml2argv-disk-floppy.args
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-floppy.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-floppy.args
@@ -1,1 +1,1 @@
-/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda
/dev/HostVG/QEMUGuest1 -fda /dev/fd0 -fdb /tmp/firmware.img -net none -serial none
-parallel none -usb
+LC_ALL=C /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c
-hda /dev/HostVG/QEMUGuest1 -fda /dev/fd0 -fdb /tmp/firmware.img -net none -serial none
-parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-many.args
b/tests/qemuxml2argvdata/qemuxml2argv-disk-many.args
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-many.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-many.args
@@ -1,1 +1,1 @@
-/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda
/dev/HostVG/QEMUGuest1 -hdb /dev/HostVG/QEMUGuest2 -hdc /tmp/data.img -hdd /tmp/logs.img
-net none -serial none -parallel none -usb
+LC_ALL=C /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c
-hda /dev/HostVG/QEMUGuest1 -hdb /dev/HostVG/QEMUGuest2 -hdc /tmp/data.img -hdd
/tmp/logs.img -net none -serial none -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-usb.args
b/tests/qemuxml2argvdata/qemuxml2argv-disk-usb.args
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-usb.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-usb.args
@@ -1,1 +1,1 @@
-/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda
/dev/HostVG/QEMUGuest1 -usbdevice disk:/tmp/usbdisk.img -net none -serial none -parallel
none -usb
+LC_ALL=C /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c
-hda /dev/HostVG/QEMUGuest1 -usbdevice disk:/tmp/usbdisk.img -net none -serial none
-parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio.args
b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio.args
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio.args
@@ -1,1 +1,1 @@
-/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -drive
file=/dev/HostVG/QEMUGuest1,if=ide,index=0,boot=on -drive
file=/dev/HostVG/QEMUGuest2,if=ide,media=cdrom,index=2 -drive
file=/tmp/data.img,if=virtio,index=0 -drive file=/tmp/logs.img,if=virtio,index=6 -net none
-serial none -parallel none -usb
+LC_ALL=C /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c
-drive file=/dev/HostVG/QEMUGuest1,if=ide,index=0,boot=on -drive
file=/dev/HostVG/QEMUGuest2,if=ide,media=cdrom,index=2 -drive
file=/tmp/data.img,if=virtio,index=0 -drive file=/tmp/logs.img,if=virtio,index=6 -net none
-serial none -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-disk-xenvbd.args
b/tests/qemuxml2argvdata/qemuxml2argv-disk-xenvbd.args
--- a/tests/qemuxml2argvdata/qemuxml2argv-disk-xenvbd.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-xenvbd.args
@@ -1,1 +1,1 @@
-/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -drive
file=/dev/HostVG/QEMUGuest1,if=ide,index=0,boot=on -drive
file=/dev/HostVG/QEMUGuest2,if=ide,media=cdrom,index=2 -drive
file=/tmp/data.img,if=xen,index=0 -drive file=/tmp/logs.img,if=xen,index=6 -net none
-serial none -parallel none -usb
+LC_ALL=C /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c
-drive file=/dev/HostVG/QEMUGuest1,if=ide,index=0,boot=on -drive
file=/dev/HostVG/QEMUGuest2,if=ide,media=cdrom,index=2 -drive
file=/tmp/data.img,if=xen,index=0 -drive file=/tmp/logs.img,if=xen,index=6 -net none
-serial none -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl.args
b/tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl.args
--- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl.args
@@ -1,1 +1,1 @@
-/usr/bin/qemu -S -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda
/dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb
+LC_ALL=C XAUTHORITY=/root/.Xauthority DISPLAY=:0.1 /usr/bin/qemu -S -M pc -m 214 -smp 1
-monitor pty -no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel
none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl.xml
b/tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl.xml
--- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl.xml
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl.xml
@@ -19,6 +19,6 @@
<target dev='hda' bus='ide'/>
</disk>
<input type='mouse' bus='ps2'/>
- <graphics type='sdl'/>
+ <graphics type='sdl' display=':0.1'
xauth='/root/.Xauthority'/>
</devices>
</domain>
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc.args
b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc.args
--- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc.args
@@ -1,1 +1,1 @@
-/usr/bin/qemu -S -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda
/dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb -vnc 127.0.0.1:3
+LC_ALL=C /usr/bin/qemu -S -M pc -m 214 -smp 1 -monitor pty -no-acpi -boot c -hda
/dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb -vnc 127.0.0.1:3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address.args
b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address.args
--- a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address.args
@@ -1,1 +1,1 @@
-/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda
/dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb -usbdevice host:014.006
+LC_ALL=C /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c
-hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb -usbdevice
host:014.006
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-product.args
b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-product.args
--- a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-product.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-product.args
@@ -1,1 +1,1 @@
-/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda
/dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb -usbdevice
host:0204:6025
+LC_ALL=C /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c
-hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb -usbdevice
host:0204:6025
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-input-usbmouse.args
b/tests/qemuxml2argvdata/qemuxml2argv-input-usbmouse.args
--- a/tests/qemuxml2argvdata/qemuxml2argv-input-usbmouse.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-input-usbmouse.args
@@ -1,1 +1,1 @@
-/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda
/dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb -usbdevice mouse
+LC_ALL=C /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c
-hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb -usbdevice mouse
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-input-usbtablet.args
b/tests/qemuxml2argvdata/qemuxml2argv-input-usbtablet.args
--- a/tests/qemuxml2argvdata/qemuxml2argv-input-usbtablet.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-input-usbtablet.args
@@ -1,1 +1,1 @@
-/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda
/dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb -usbdevice tablet
+LC_ALL=C /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c
-hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb -usbdevice tablet
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-input-xen.args
b/tests/qemuxml2argvdata/qemuxml2argv-input-xen.args
--- a/tests/qemuxml2argvdata/qemuxml2argv-input-xen.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-input-xen.args
@@ -1,1 +1,1 @@
-/usr/bin/xenner -S -M xenner -m 214 -smp 1 -monitor pty -no-acpi -bootloader /foo -hda
/dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb -vnc 127.0.0.1:3
+LC_ALL=C /usr/bin/xenner -S -M xenner -m 214 -smp 1 -monitor pty -no-acpi -bootloader
/foo -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb -vnc
127.0.0.1:3
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-minimal.args
b/tests/qemuxml2argvdata/qemuxml2argv-minimal.args
--- a/tests/qemuxml2argvdata/qemuxml2argv-minimal.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-minimal.args
@@ -1,1 +1,1 @@
-/usr/bin/qemu -S -M pc -m 214 -smp 1 -name QEMUGuest1 -nographic -monitor pty -no-acpi
-boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb
+LC_ALL=C /usr/bin/qemu -S -M pc -m 214 -smp 1 -name QEMUGuest1 -nographic -monitor pty
-no-acpi -boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-misc-acpi.args
b/tests/qemuxml2argvdata/qemuxml2argv-misc-acpi.args
--- a/tests/qemuxml2argvdata/qemuxml2argv-misc-acpi.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-misc-acpi.args
@@ -1,1 +1,1 @@
-/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -boot c -hda
/dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb
+LC_ALL=C /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -boot c -hda
/dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-misc-no-reboot.args
b/tests/qemuxml2argvdata/qemuxml2argv-misc-no-reboot.args
--- a/tests/qemuxml2argvdata/qemuxml2argv-misc-no-reboot.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-misc-no-reboot.args
@@ -1,1 +1,1 @@
-/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-reboot -no-acpi -boot c
-hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb
+LC_ALL=C /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-reboot -no-acpi
-boot c -hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-user.args
b/tests/qemuxml2argvdata/qemuxml2argv-net-user.args
--- a/tests/qemuxml2argvdata/qemuxml2argv-net-user.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-user.args
@@ -1,1 +1,1 @@
-/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda
/dev/HostVG/QEMUGuest1 -net nic,macaddr=00:11:22:33:44:55,vlan=0 -net user,vlan=0 -serial
none -parallel none -usb
+LC_ALL=C /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c
-hda /dev/HostVG/QEMUGuest1 -net nic,macaddr=00:11:22:33:44:55,vlan=0 -net user,vlan=0
-serial none -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-net-virtio.args
b/tests/qemuxml2argvdata/qemuxml2argv-net-virtio.args
--- a/tests/qemuxml2argvdata/qemuxml2argv-net-virtio.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-net-virtio.args
@@ -1,1 +1,1 @@
-/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda
/dev/HostVG/QEMUGuest1 -net nic,macaddr=00:11:22:33:44:55,vlan=0,model=virtio -net
user,vlan=0 -serial none -parallel none -usb
+LC_ALL=C /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c
-hda /dev/HostVG/QEMUGuest1 -net nic,macaddr=00:11:22:33:44:55,vlan=0,model=virtio -net
user,vlan=0 -serial none -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-parallel-tcp.args
b/tests/qemuxml2argvdata/qemuxml2argv-parallel-tcp.args
--- a/tests/qemuxml2argvdata/qemuxml2argv-parallel-tcp.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-parallel-tcp.args
@@ -1,1 +1,1 @@
-/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda
/dev/HostVG/QEMUGuest1 -net none -serial none -parallel tcp:127.0.0.1:9999,listen -usb
+LC_ALL=C /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c
-hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel tcp:127.0.0.1:9999,listen
-usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-dev.args
b/tests/qemuxml2argvdata/qemuxml2argv-serial-dev.args
--- a/tests/qemuxml2argvdata/qemuxml2argv-serial-dev.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-dev.args
@@ -1,1 +1,1 @@
-/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda
/dev/HostVG/QEMUGuest1 -net none -serial /dev/ttyS2 -parallel none -usb
+LC_ALL=C /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c
-hda /dev/HostVG/QEMUGuest1 -net none -serial /dev/ttyS2 -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-file.args
b/tests/qemuxml2argvdata/qemuxml2argv-serial-file.args
--- a/tests/qemuxml2argvdata/qemuxml2argv-serial-file.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-file.args
@@ -1,1 +1,1 @@
-/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda
/dev/HostVG/QEMUGuest1 -net none -serial file:/tmp/serial.log -parallel none -usb
+LC_ALL=C /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c
-hda /dev/HostVG/QEMUGuest1 -net none -serial file:/tmp/serial.log -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-many.args
b/tests/qemuxml2argvdata/qemuxml2argv-serial-many.args
--- a/tests/qemuxml2argvdata/qemuxml2argv-serial-many.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-many.args
@@ -1,1 +1,1 @@
-/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda
/dev/HostVG/QEMUGuest1 -net none -serial pty -serial file:/tmp/serial.log -parallel none
-usb
+LC_ALL=C /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c
-hda /dev/HostVG/QEMUGuest1 -net none -serial pty -serial file:/tmp/serial.log -parallel
none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-pty.args
b/tests/qemuxml2argvdata/qemuxml2argv-serial-pty.args
--- a/tests/qemuxml2argvdata/qemuxml2argv-serial-pty.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-pty.args
@@ -1,1 +1,1 @@
-/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda
/dev/HostVG/QEMUGuest1 -net none -serial pty -parallel none -usb
+LC_ALL=C /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c
-hda /dev/HostVG/QEMUGuest1 -net none -serial pty -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-telnet.args
b/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-telnet.args
--- a/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-telnet.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-telnet.args
@@ -1,1 +1,1 @@
-/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda
/dev/HostVG/QEMUGuest1 -net none -serial telnet:127.0.0.1:9999,server -parallel none -usb
+LC_ALL=C /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c
-hda /dev/HostVG/QEMUGuest1 -net none -serial telnet:127.0.0.1:9999,server -parallel none
-usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp.args
b/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp.args
--- a/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp.args
@@ -1,1 +1,1 @@
-/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda
/dev/HostVG/QEMUGuest1 -net none -serial tcp:127.0.0.1:9999 -parallel none -usb
+LC_ALL=C /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c
-hda /dev/HostVG/QEMUGuest1 -net none -serial tcp:127.0.0.1:9999 -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-udp.args
b/tests/qemuxml2argvdata/qemuxml2argv-serial-udp.args
--- a/tests/qemuxml2argvdata/qemuxml2argv-serial-udp.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-udp.args
@@ -1,1 +1,1 @@
-/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda
/dev/HostVG/QEMUGuest1 -net none -serial udp:127.0.0.1:9998@127.0.0.1:9999 -parallel none
-usb
+LC_ALL=C /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c
-hda /dev/HostVG/QEMUGuest1 -net none -serial udp:127.0.0.1:9998@127.0.0.1:9999 -parallel
none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-unix.args
b/tests/qemuxml2argvdata/qemuxml2argv-serial-unix.args
--- a/tests/qemuxml2argvdata/qemuxml2argv-serial-unix.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-unix.args
@@ -1,1 +1,1 @@
-/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda
/dev/HostVG/QEMUGuest1 -net none -serial unix:/tmp/serial.sock -parallel none -usb
+LC_ALL=C /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c
-hda /dev/HostVG/QEMUGuest1 -net none -serial unix:/tmp/serial.sock -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-serial-vc.args
b/tests/qemuxml2argvdata/qemuxml2argv-serial-vc.args
--- a/tests/qemuxml2argvdata/qemuxml2argv-serial-vc.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-vc.args
@@ -1,1 +1,1 @@
-/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda
/dev/HostVG/QEMUGuest1 -net none -serial vc -parallel none -usb
+LC_ALL=C /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c
-hda /dev/HostVG/QEMUGuest1 -net none -serial vc -parallel none -usb
diff --git a/tests/qemuxml2argvdata/qemuxml2argv-sound.args
b/tests/qemuxml2argvdata/qemuxml2argv-sound.args
--- a/tests/qemuxml2argvdata/qemuxml2argv-sound.args
+++ b/tests/qemuxml2argvdata/qemuxml2argv-sound.args
@@ -1,1 +1,1 @@
-/usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c -hda
/dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb -soundhw
pcspk,es1370,sb16
+LC_ALL=C /usr/bin/qemu -S -M pc -m 214 -smp 1 -nographic -monitor pty -no-acpi -boot c
-hda /dev/HostVG/QEMUGuest1 -net none -serial none -parallel none -usb -soundhw
pcspk,es1370,sb16
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -22,11 +22,14 @@ static struct qemud_driver driver;
#define MAX_FILE 4096
-static int testCompareXMLToArgvFiles(const char *xml, const char *cmd, int extraFlags) {
+static int testCompareXMLToArgvFiles(const char *xml,
+ const char *cmd,
+ int extraFlags) {
char argvData[MAX_FILE];
char *expectargv = &(argvData[0]);
char *actualargv = NULL;
const char **argv = NULL;
+ const char **qenv = NULL;
const char **tmp = NULL;
int ret = -1, len, flags;
virDomainDefPtr vmdef = NULL;
@@ -48,18 +51,32 @@ static int testCompareXMLToArgvFiles(con
extraFlags;
if (qemudBuildCommandLine(NULL, &driver,
- &vm, flags, &argv,
+ &vm, flags, &argv, &qenv,
NULL, NULL, NULL) < 0)
goto fail;
+ len = 1; /* for trailing newline */
+ tmp = qenv;
+ while (*tmp) {
+ len += strlen(*tmp) + 1;
+ tmp++;
+ }
+
tmp = argv;
- len = 1; /* for trailing newline */
while (*tmp) {
len += strlen(*tmp) + 1;
tmp++;
}
actualargv = malloc(sizeof(*actualargv)*len);
actualargv[0] = '\0';
+ tmp = qenv;
+ len = 0;
+ while (*tmp) {
+ if (actualargv[0])
+ strcat(actualargv, " ");
+ strcat(actualargv, *tmp);
+ tmp++;
+ }
tmp = argv;
len = 0;
while (*tmp) {
@@ -86,6 +103,14 @@ static int testCompareXMLToArgvFiles(con
tmp++;
}
free(argv);
+ }
+ if (qenv) {
+ tmp = qenv;
+ while (*tmp) {
+ free(*(char**)tmp);
+ tmp++;
+ }
+ free(qenv);
}
virDomainDefFree(vmdef);
return ret;
--
|: Red Hat, Engineering, London -o-
http://people.redhat.com/berrange/ :|
|:
http://libvirt.org -o-
http://virt-manager.org -o-
http://ovirt.org :|
|:
http://autobuild.org -o-
http://search.cpan.org/~danberr/ :|
|: GnuPG: 7D3B9505 -o- F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505 :|