[libvirt] PATCH: Support SDL configuration for QEMU driver

QEMU has two modes of providing a graphical display, VNC and SDL. Now most of our tools just use VNC, but occasionally people want to use SDL for some crazy reason. We already support this in Xen driver, but the QEMU impl has been rather lacking. At the moment if you ask for a SDL display it'll only happen to work if you had the $DISPLAY environment variable set when you started libvirtd - you probably don't. The generic XML parser allows for two attributes on the <graohics> element for setting the display and xauth filename, so this patch updates the QEMU driver to use this data if available. This means we have to start setting environment variables when invoking QEMU, so this patch is a little larger than would otherwise be expected. 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 ? src/qemu_conf.c | 60 +++++++++- src/qemu_conf.h | 3 src/qemu_driver.c | 19 ++- tests/qemuxml2argvdata/qemuxml2argv-boot-cdrom.args | 2 tests/qemuxml2argvdata/qemuxml2argv-boot-floppy.args | 2 tests/qemuxml2argvdata/qemuxml2argv-boot-network.args | 2 tests/qemuxml2argvdata/qemuxml2argv-bootloader.args | 2 tests/qemuxml2argvdata/qemuxml2argv-clock-localtime.args | 2 tests/qemuxml2argvdata/qemuxml2argv-clock-utc.args | 2 tests/qemuxml2argvdata/qemuxml2argv-console-compat.args | 2 tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-empty.args | 2 tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom.args | 2 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-boot-cdrom.args | 2 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-boot-disk.args | 2 tests/qemuxml2argvdata/qemuxml2argv-disk-floppy.args | 2 tests/qemuxml2argvdata/qemuxml2argv-disk-many.args | 2 tests/qemuxml2argvdata/qemuxml2argv-disk-usb.args | 2 tests/qemuxml2argvdata/qemuxml2argv-disk-virtio.args | 2 tests/qemuxml2argvdata/qemuxml2argv-disk-xenvbd.args | 2 tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl.args | 2 tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl.xml | 2 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc.args | 2 tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address.args | 2 tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-product.args | 2 tests/qemuxml2argvdata/qemuxml2argv-input-usbmouse.args | 2 tests/qemuxml2argvdata/qemuxml2argv-input-usbtablet.args | 2 tests/qemuxml2argvdata/qemuxml2argv-input-xen.args | 2 tests/qemuxml2argvdata/qemuxml2argv-minimal.args | 2 tests/qemuxml2argvdata/qemuxml2argv-misc-acpi.args | 2 tests/qemuxml2argvdata/qemuxml2argv-misc-no-reboot.args | 2 tests/qemuxml2argvdata/qemuxml2argv-net-user.args | 2 tests/qemuxml2argvdata/qemuxml2argv-net-virtio.args | 2 tests/qemuxml2argvdata/qemuxml2argv-parallel-tcp.args | 2 tests/qemuxml2argvdata/qemuxml2argv-serial-dev.args | 2 tests/qemuxml2argvdata/qemuxml2argv-serial-file.args | 2 tests/qemuxml2argvdata/qemuxml2argv-serial-many.args | 2 tests/qemuxml2argvdata/qemuxml2argv-serial-pty.args | 2 tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-telnet.args | 2 tests/qemuxml2argvdata/qemuxml2argv-serial-tcp.args | 2 tests/qemuxml2argvdata/qemuxml2argv-serial-udp.args | 2 tests/qemuxml2argvdata/qemuxml2argv-serial-unix.args | 2 tests/qemuxml2argvdata/qemuxml2argv-serial-vc.args | 2 tests/qemuxml2argvdata/qemuxml2argv-sound.args | 2 tests/qemuxml2argvtest.c | 31 ++++- 44 files changed, 145 insertions(+), 48 deletions(-) Daniel diff -r 194a93a4a942 src/qemu_conf.c --- a/src/qemu_conf.c Wed Oct 01 11:52:52 2008 +0100 +++ b/src/qemu_conf.c Thu Oct 02 18:03:43 2008 +0100 @@ -710,6 +710,7 @@ virDomainObjPtr vm, unsigned int qemuCmdFlags, const char ***retargv, + const char ***retenv, int **tapfds, int *ntapfds, const char *migrateFrom) { @@ -728,6 +729,8 @@ 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 +778,39 @@ 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) + snprintf(memory, sizeof(memory), "%lu", vm->def->memory/1024); snprintf(vcpus, sizeof(vcpus), "%lu", vm->def->vcpus); + + ADD_ENV_LIT("LC_ALL=C"); emulator = vm->def->emulator; if (!emulator) @@ -1163,7 +1191,24 @@ } } 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 +1270,10 @@ } ADD_ARG(NULL); + ADD_ENV(NULL); *retargv = qargv; + *retenv = qenv; return 0; no_memory: @@ -1245,9 +1292,18 @@ 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_LIT +#undef ADD_ENV_SPACE } diff -r 194a93a4a942 src/qemu_conf.h --- a/src/qemu_conf.h Wed Oct 01 11:52:52 2008 +0100 +++ b/src/qemu_conf.h Thu Oct 02 18:03:43 2008 +0100 @@ -93,7 +93,8 @@ 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 -r 194a93a4a942 src/qemu_driver.c --- a/src/qemu_driver.c Wed Oct 01 11:52:52 2008 +0100 +++ b/src/qemu_driver.c Thu Oct 02 18:03:43 2008 +0100 @@ -844,6 +844,7 @@ 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 @@ } 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 @@ 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 @@ 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 -r 194a93a4a942 tests/qemuxml2argvdata/qemuxml2argv-boot-cdrom.args --- a/tests/qemuxml2argvdata/qemuxml2argv-boot-cdrom.args Wed Oct 01 11:52:52 2008 +0100 +++ b/tests/qemuxml2argvdata/qemuxml2argv-boot-cdrom.args Thu Oct 02 18:03:43 2008 +0100 @@ -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 -r 194a93a4a942 tests/qemuxml2argvdata/qemuxml2argv-boot-floppy.args --- a/tests/qemuxml2argvdata/qemuxml2argv-boot-floppy.args Wed Oct 01 11:52:52 2008 +0100 +++ b/tests/qemuxml2argvdata/qemuxml2argv-boot-floppy.args Thu Oct 02 18:03:43 2008 +0100 @@ -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 -r 194a93a4a942 tests/qemuxml2argvdata/qemuxml2argv-boot-network.args --- a/tests/qemuxml2argvdata/qemuxml2argv-boot-network.args Wed Oct 01 11:52:52 2008 +0100 +++ b/tests/qemuxml2argvdata/qemuxml2argv-boot-network.args Thu Oct 02 18:03:43 2008 +0100 @@ -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 -r 194a93a4a942 tests/qemuxml2argvdata/qemuxml2argv-bootloader.args --- a/tests/qemuxml2argvdata/qemuxml2argv-bootloader.args Wed Oct 01 11:52:52 2008 +0100 +++ b/tests/qemuxml2argvdata/qemuxml2argv-bootloader.args Thu Oct 02 18:03:43 2008 +0100 @@ -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 -r 194a93a4a942 tests/qemuxml2argvdata/qemuxml2argv-clock-localtime.args --- a/tests/qemuxml2argvdata/qemuxml2argv-clock-localtime.args Wed Oct 01 11:52:52 2008 +0100 +++ b/tests/qemuxml2argvdata/qemuxml2argv-clock-localtime.args Thu Oct 02 18:03:43 2008 +0100 @@ -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 -r 194a93a4a942 tests/qemuxml2argvdata/qemuxml2argv-clock-utc.args --- a/tests/qemuxml2argvdata/qemuxml2argv-clock-utc.args Wed Oct 01 11:52:52 2008 +0100 +++ b/tests/qemuxml2argvdata/qemuxml2argv-clock-utc.args Thu Oct 02 18:03:43 2008 +0100 @@ -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 -r 194a93a4a942 tests/qemuxml2argvdata/qemuxml2argv-console-compat.args --- a/tests/qemuxml2argvdata/qemuxml2argv-console-compat.args Wed Oct 01 11:52:52 2008 +0100 +++ b/tests/qemuxml2argvdata/qemuxml2argv-console-compat.args Thu Oct 02 18:03:43 2008 +0100 @@ -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 -r 194a93a4a942 tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-empty.args --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-empty.args Wed Oct 01 11:52:52 2008 +0100 +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom-empty.args Thu Oct 02 18:03:43 2008 +0100 @@ -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 -r 194a93a4a942 tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom.args --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom.args Wed Oct 01 11:52:52 2008 +0100 +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-cdrom.args Thu Oct 02 18:03:43 2008 +0100 @@ -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 -r 194a93a4a942 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-boot-cdrom.args --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-boot-cdrom.args Wed Oct 01 11:52:52 2008 +0100 +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-boot-cdrom.args Thu Oct 02 18:03:43 2008 +0100 @@ -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 -r 194a93a4a942 tests/qemuxml2argvdata/qemuxml2argv-disk-drive-boot-disk.args --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-boot-disk.args Wed Oct 01 11:52:52 2008 +0100 +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-drive-boot-disk.args Thu Oct 02 18:03:43 2008 +0100 @@ -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 -r 194a93a4a942 tests/qemuxml2argvdata/qemuxml2argv-disk-floppy.args --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-floppy.args Wed Oct 01 11:52:52 2008 +0100 +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-floppy.args Thu Oct 02 18:03:43 2008 +0100 @@ -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 -r 194a93a4a942 tests/qemuxml2argvdata/qemuxml2argv-disk-many.args --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-many.args Wed Oct 01 11:52:52 2008 +0100 +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-many.args Thu Oct 02 18:03:43 2008 +0100 @@ -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 -r 194a93a4a942 tests/qemuxml2argvdata/qemuxml2argv-disk-usb.args --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-usb.args Wed Oct 01 11:52:52 2008 +0100 +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-usb.args Thu Oct 02 18:03:43 2008 +0100 @@ -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 -r 194a93a4a942 tests/qemuxml2argvdata/qemuxml2argv-disk-virtio.args --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio.args Wed Oct 01 11:52:52 2008 +0100 +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-virtio.args Thu Oct 02 18:03:43 2008 +0100 @@ -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 -r 194a93a4a942 tests/qemuxml2argvdata/qemuxml2argv-disk-xenvbd.args --- a/tests/qemuxml2argvdata/qemuxml2argv-disk-xenvbd.args Wed Oct 01 11:52:52 2008 +0100 +++ b/tests/qemuxml2argvdata/qemuxml2argv-disk-xenvbd.args Thu Oct 02 18:03:43 2008 +0100 @@ -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 -r 194a93a4a942 tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl.args --- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl.args Wed Oct 01 11:52:52 2008 +0100 +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl.args Thu Oct 02 18:03:43 2008 +0100 @@ -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 -r 194a93a4a942 tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl.xml --- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl.xml Wed Oct 01 11:52:52 2008 +0100 +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-sdl.xml Thu Oct 02 18:03:43 2008 +0100 @@ -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 -r 194a93a4a942 tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc.args --- a/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc.args Wed Oct 01 11:52:52 2008 +0100 +++ b/tests/qemuxml2argvdata/qemuxml2argv-graphics-vnc.args Thu Oct 02 18:03:43 2008 +0100 @@ -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 -r 194a93a4a942 tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address.args --- a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address.args Wed Oct 01 11:52:52 2008 +0100 +++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-address.args Thu Oct 02 18:03:43 2008 +0100 @@ -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 -r 194a93a4a942 tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-product.args --- a/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-product.args Wed Oct 01 11:52:52 2008 +0100 +++ b/tests/qemuxml2argvdata/qemuxml2argv-hostdev-usb-product.args Thu Oct 02 18:03:43 2008 +0100 @@ -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 -r 194a93a4a942 tests/qemuxml2argvdata/qemuxml2argv-input-usbmouse.args --- a/tests/qemuxml2argvdata/qemuxml2argv-input-usbmouse.args Wed Oct 01 11:52:52 2008 +0100 +++ b/tests/qemuxml2argvdata/qemuxml2argv-input-usbmouse.args Thu Oct 02 18:03:43 2008 +0100 @@ -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 -r 194a93a4a942 tests/qemuxml2argvdata/qemuxml2argv-input-usbtablet.args --- a/tests/qemuxml2argvdata/qemuxml2argv-input-usbtablet.args Wed Oct 01 11:52:52 2008 +0100 +++ b/tests/qemuxml2argvdata/qemuxml2argv-input-usbtablet.args Thu Oct 02 18:03:43 2008 +0100 @@ -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 -r 194a93a4a942 tests/qemuxml2argvdata/qemuxml2argv-input-xen.args --- a/tests/qemuxml2argvdata/qemuxml2argv-input-xen.args Wed Oct 01 11:52:52 2008 +0100 +++ b/tests/qemuxml2argvdata/qemuxml2argv-input-xen.args Thu Oct 02 18:03:43 2008 +0100 @@ -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 -r 194a93a4a942 tests/qemuxml2argvdata/qemuxml2argv-minimal.args --- a/tests/qemuxml2argvdata/qemuxml2argv-minimal.args Wed Oct 01 11:52:52 2008 +0100 +++ b/tests/qemuxml2argvdata/qemuxml2argv-minimal.args Thu Oct 02 18:03:43 2008 +0100 @@ -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 -r 194a93a4a942 tests/qemuxml2argvdata/qemuxml2argv-misc-acpi.args --- a/tests/qemuxml2argvdata/qemuxml2argv-misc-acpi.args Wed Oct 01 11:52:52 2008 +0100 +++ b/tests/qemuxml2argvdata/qemuxml2argv-misc-acpi.args Thu Oct 02 18:03:43 2008 +0100 @@ -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 -r 194a93a4a942 tests/qemuxml2argvdata/qemuxml2argv-misc-no-reboot.args --- a/tests/qemuxml2argvdata/qemuxml2argv-misc-no-reboot.args Wed Oct 01 11:52:52 2008 +0100 +++ b/tests/qemuxml2argvdata/qemuxml2argv-misc-no-reboot.args Thu Oct 02 18:03:43 2008 +0100 @@ -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 -r 194a93a4a942 tests/qemuxml2argvdata/qemuxml2argv-net-user.args --- a/tests/qemuxml2argvdata/qemuxml2argv-net-user.args Wed Oct 01 11:52:52 2008 +0100 +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-user.args Thu Oct 02 18:03:43 2008 +0100 @@ -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 -r 194a93a4a942 tests/qemuxml2argvdata/qemuxml2argv-net-virtio.args --- a/tests/qemuxml2argvdata/qemuxml2argv-net-virtio.args Wed Oct 01 11:52:52 2008 +0100 +++ b/tests/qemuxml2argvdata/qemuxml2argv-net-virtio.args Thu Oct 02 18:03:43 2008 +0100 @@ -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 -r 194a93a4a942 tests/qemuxml2argvdata/qemuxml2argv-parallel-tcp.args --- a/tests/qemuxml2argvdata/qemuxml2argv-parallel-tcp.args Wed Oct 01 11:52:52 2008 +0100 +++ b/tests/qemuxml2argvdata/qemuxml2argv-parallel-tcp.args Thu Oct 02 18:03:43 2008 +0100 @@ -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 -r 194a93a4a942 tests/qemuxml2argvdata/qemuxml2argv-serial-dev.args --- a/tests/qemuxml2argvdata/qemuxml2argv-serial-dev.args Wed Oct 01 11:52:52 2008 +0100 +++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-dev.args Thu Oct 02 18:03:43 2008 +0100 @@ -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 -r 194a93a4a942 tests/qemuxml2argvdata/qemuxml2argv-serial-file.args --- a/tests/qemuxml2argvdata/qemuxml2argv-serial-file.args Wed Oct 01 11:52:52 2008 +0100 +++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-file.args Thu Oct 02 18:03:43 2008 +0100 @@ -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 -r 194a93a4a942 tests/qemuxml2argvdata/qemuxml2argv-serial-many.args --- a/tests/qemuxml2argvdata/qemuxml2argv-serial-many.args Wed Oct 01 11:52:52 2008 +0100 +++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-many.args Thu Oct 02 18:03:43 2008 +0100 @@ -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 -r 194a93a4a942 tests/qemuxml2argvdata/qemuxml2argv-serial-pty.args --- a/tests/qemuxml2argvdata/qemuxml2argv-serial-pty.args Wed Oct 01 11:52:52 2008 +0100 +++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-pty.args Thu Oct 02 18:03:43 2008 +0100 @@ -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 -r 194a93a4a942 tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-telnet.args --- a/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-telnet.args Wed Oct 01 11:52:52 2008 +0100 +++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp-telnet.args Thu Oct 02 18:03:43 2008 +0100 @@ -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 -r 194a93a4a942 tests/qemuxml2argvdata/qemuxml2argv-serial-tcp.args --- a/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp.args Wed Oct 01 11:52:52 2008 +0100 +++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-tcp.args Thu Oct 02 18:03:43 2008 +0100 @@ -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 -r 194a93a4a942 tests/qemuxml2argvdata/qemuxml2argv-serial-udp.args --- a/tests/qemuxml2argvdata/qemuxml2argv-serial-udp.args Wed Oct 01 11:52:52 2008 +0100 +++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-udp.args Thu Oct 02 18:03:43 2008 +0100 @@ -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 -r 194a93a4a942 tests/qemuxml2argvdata/qemuxml2argv-serial-unix.args --- a/tests/qemuxml2argvdata/qemuxml2argv-serial-unix.args Wed Oct 01 11:52:52 2008 +0100 +++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-unix.args Thu Oct 02 18:03:43 2008 +0100 @@ -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 -r 194a93a4a942 tests/qemuxml2argvdata/qemuxml2argv-serial-vc.args --- a/tests/qemuxml2argvdata/qemuxml2argv-serial-vc.args Wed Oct 01 11:52:52 2008 +0100 +++ b/tests/qemuxml2argvdata/qemuxml2argv-serial-vc.args Thu Oct 02 18:03:43 2008 +0100 @@ -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 -r 194a93a4a942 tests/qemuxml2argvdata/qemuxml2argv-sound.args --- a/tests/qemuxml2argvdata/qemuxml2argv-sound.args Wed Oct 01 11:52:52 2008 +0100 +++ b/tests/qemuxml2argvdata/qemuxml2argv-sound.args Thu Oct 02 18:03:43 2008 +0100 @@ -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 -r 194a93a4a942 tests/qemuxml2argvtest.c --- a/tests/qemuxml2argvtest.c Wed Oct 01 11:52:52 2008 +0100 +++ b/tests/qemuxml2argvtest.c Thu Oct 02 18:03:43 2008 +0100 @@ -22,11 +22,14 @@ #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 @@ 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 @@ 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 :|

"Daniel P. Berrange" <berrange@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.

On Thu, Oct 02, 2008 at 07:37:38PM +0200, Jim Meyering wrote:
"Daniel P. Berrange" <berrange@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 :|

On Wed, Oct 08, 2008 at 08:08:35PM +0100, Daniel P. Berrange wrote:
On Thu, Oct 02, 2008 at 07:37:38PM +0200, Jim Meyering wrote:
"Daniel P. Berrange" <berrange@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");
+1 again, Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

"Daniel P. Berrange" <berrange@redhat.com> wrote:
On Thu, Oct 02, 2008 at 07:37:38PM +0200, Jim Meyering wrote:
"Daniel P. Berrange" <berrange@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");
Looks good. I guess you're adding those two in case qemu uses dlopen. This time I've reviewed the rest of the patch. Comments below:
+ ADD_ENV_COPY("PATH"); + ADD_ENV_COPY("HOME"); + ADD_ENV_COPY("USER"); + ADD_ENV_COPY("LOGNAME"); + ADD_ENV_COPY("TMPDIR"); ... diff --git a/src/qemu_conf.c b/src/qemu_conf.c +#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)
Doesn't this need to be adding "envname=val" strings, rather than just "val"? If it works as-is, then maybe none of these is actually used (or at least they're not exercised in tests).
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;
...
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, ... + tmp = qenv; + len = 0; + while (*tmp) { + if (actualargv[0]) + strcat(actualargv, " "); + strcat(actualargv, *tmp); + tmp++; + } tmp = argv; len = 0;
No big deal, but both of those "len = 0" assignments can be removed, since "len" is no longer used.

On Thu, Oct 09, 2008 at 04:31:49PM +0200, Jim Meyering wrote:
"Daniel P. Berrange" <berrange@redhat.com> wrote:
+#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)
Doesn't this need to be adding "envname=val" strings, rather than just "val"?
If it works as-is, then maybe none of these is actually used (or at least they're not exercised in tests).
No it doesn't work & is exercised in the tests & I forgot to run them :-) I also needed to explicitly set the env vars to predictable values in the test suite.
...
+ tmp = qenv; + len = 0; + while (*tmp) { + if (actualargv[0]) + strcat(actualargv, " "); + strcat(actualargv, *tmp); + tmp++; + } tmp = argv; len = 0;
No big deal, but both of those "len = 0" assignments can be removed, since "len" is no longer used.
Yep, killed them off. 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> @@ -689,6 +690,7 @@ int qemudBuildCommandLine(virConnectPtr virDomainObjPtr vm, unsigned int qemuCmdFlags, const char ***retargv, + const char ***retenv, int **tapfds, int *ntapfds, const char *migrateFrom) { @@ -707,6 +709,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); @@ -754,14 +758,59 @@ 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); \ + char *envval; \ + ADD_ENV_SPACE; \ + if (val != NULL) { \ + if (asprintf(&envval, "%s=%s", envname, val) < 0) \ + goto no_memory; \ + qenv[qenvc++] = envval; \ + } \ + } 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) @@ -1142,7 +1191,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 */ @@ -1204,8 +1270,10 @@ int qemudBuildCommandLine(virConnectPtr } ADD_ARG(NULL); + ADD_ENV(NULL); *retargv = qargv; + *retenv = qenv; return 0; no_memory: @@ -1224,9 +1292,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 @@ -91,7 +91,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 @@ -842,6 +842,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; @@ -937,13 +938,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) @@ -964,7 +975,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) { @@ -975,6 +986,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/src/xen_internal.c b/src/xen_internal.c --- a/src/xen_internal.c +++ b/src/xen_internal.c @@ -1927,7 +1927,8 @@ xenHypervisorInit(void) */ hypervisor_version = -1; - virXenError(NULL, VIR_ERR_XEN_CALL, " ioctl %lu", IOCTL_PRIVCMD_HYPERCALL); + virXenError(NULL, VIR_ERR_XEN_CALL, " ioctl %lu", + (unsigned long)IOCTL_PRIVCMD_HYPERCALL); close(fd); in_init = 0; return(-1); @@ -2004,7 +2005,8 @@ xenHypervisorInit(void) DEBUG0("Failed to find any Xen hypervisor method\n"); hypervisor_version = -1; - virXenError(NULL, VIR_ERR_XEN_CALL, " ioctl %lu", IOCTL_PRIVCMD_HYPERCALL); + virXenError(NULL, VIR_ERR_XEN_CALL, " ioctl %lu", + (unsigned long)IOCTL_PRIVCMD_HYPERCALL); close(fd); in_init = 0; VIR_FREE(ipt); diff --git a/src/xml.c b/src/xml.c --- a/src/xml.c +++ b/src/xml.c @@ -351,7 +351,7 @@ virXPathNodeSet(virConnectPtr conn, if (VIR_ALLOC_N(*list, ret) < 0) { virXMLError(conn, VIR_ERR_NO_MEMORY, _("allocate string array size %lu"), - ret * sizeof(**list)); + (unsigned long)ret * sizeof(**list)); ret = -1; } else { memcpy(*list, obj->nodesetval->nodeTab, 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 PATH=/bin HOME=/home/test USER=test LOGNAME=test /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 PATH=/bin HOME=/home/test USER=test LOGNAME=test /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 PATH=/bin HOME=/home/test USER=test LOGNAME=test /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 PATH=/bin HOME=/home/test USER=test LOGNAME=test /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 PATH=/bin HOME=/home/test USER=test LOGNAME=test /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 PATH=/bin HOME=/home/test USER=test LOGNAME=test /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 PATH=/bin HOME=/home/test USER=test LOGNAME=test /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 PATH=/bin HOME=/home/test USER=test LOGNAME=test /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 PATH=/bin HOME=/home/test USER=test LOGNAME=test /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 PATH=/bin HOME=/home/test USER=test LOGNAME=test /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 PATH=/bin HOME=/home/test USER=test LOGNAME=test /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 PATH=/bin HOME=/home/test USER=test LOGNAME=test /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 PATH=/bin HOME=/home/test USER=test LOGNAME=test /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 PATH=/bin HOME=/home/test USER=test LOGNAME=test /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 PATH=/bin HOME=/home/test USER=test LOGNAME=test /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 PATH=/bin HOME=/home/test USER=test LOGNAME=test /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 PATH=/bin HOME=/home/test USER=test LOGNAME=test 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 PATH=/bin HOME=/home/test USER=test LOGNAME=test /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 PATH=/bin HOME=/home/test USER=test LOGNAME=test /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 PATH=/bin HOME=/home/test USER=test LOGNAME=test /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 PATH=/bin HOME=/home/test USER=test LOGNAME=test /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 PATH=/bin HOME=/home/test USER=test LOGNAME=test /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 PATH=/bin HOME=/home/test USER=test LOGNAME=test /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 PATH=/bin HOME=/home/test USER=test LOGNAME=test /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 PATH=/bin HOME=/home/test USER=test LOGNAME=test /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 PATH=/bin HOME=/home/test USER=test LOGNAME=test /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 PATH=/bin HOME=/home/test USER=test LOGNAME=test /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 PATH=/bin HOME=/home/test USER=test LOGNAME=test /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 PATH=/bin HOME=/home/test USER=test LOGNAME=test /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 PATH=/bin HOME=/home/test USER=test LOGNAME=test /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 PATH=/bin HOME=/home/test USER=test LOGNAME=test /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 PATH=/bin HOME=/home/test USER=test LOGNAME=test /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 PATH=/bin HOME=/home/test USER=test LOGNAME=test /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 PATH=/bin HOME=/home/test USER=test LOGNAME=test /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 PATH=/bin HOME=/home/test USER=test LOGNAME=test /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 PATH=/bin HOME=/home/test USER=test LOGNAME=test /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 PATH=/bin HOME=/home/test USER=test LOGNAME=test /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 PATH=/bin HOME=/home/test USER=test LOGNAME=test /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 PATH=/bin HOME=/home/test USER=test LOGNAME=test /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,20 +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; + while (*tmp) { + if (actualargv[0]) + strcat(actualargv, " "); + strcat(actualargv, *tmp); + tmp++; + } tmp = argv; - len = 0; while (*tmp) { if (actualargv[0]) strcat(actualargv, " "); @@ -86,6 +101,14 @@ static int testCompareXMLToArgvFiles(con tmp++; } free(argv); + } + if (qenv) { + tmp = qenv; + while (*tmp) { + free(*(char**)tmp); + tmp++; + } + free(qenv); } virDomainDefFree(vmdef); return ret; @@ -137,6 +160,14 @@ mymain(int argc, char **argv) 1, testCompareXMLToArgvHelper, &info) < 0) \ ret = -1; \ } while (0) + + setenv("PATH", "/bin", 1); + setenv("USER", "test", 1); + setenv("LOGNAME", "test", 1); + setenv("HOME", "/home/test", 1); + unsetenv("TMPDIR"); + unsetenv("LD_PRELOAD"); + unsetenv("LD_LIBRARY_PATH"); DO_TEST("minimal", QEMUD_CMD_FLAG_NAME); DO_TEST("boot-cdrom", 0); -- |: 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 :|

"Daniel P. Berrange" <berrange@redhat.com> wrote: ...
diff --git a/src/qemu_conf.c b/src/qemu_conf.c ... +#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_COPY(envname) \ + do { \ + char *val = getenv(envname); \ + char *envval; \ + ADD_ENV_SPACE; \ + if (val != NULL) { \ + if (asprintf(&envval, "%s=%s", envname, val) < 0) \ + goto no_memory; \ + qenv[qenvc++] = envval; \ + } \ + } while (0)
All looks good. You might as well move the ADD_ENV_SPACE down into the "if" block.

On Thu, Oct 02, 2008 at 06:09:21PM +0100, Daniel P. Berrange wrote:
QEMU has two modes of providing a graphical display, VNC and SDL. Now most of our tools just use VNC, but occasionally people want to use SDL for some crazy reason. We already support this in Xen driver, but the QEMU impl has been rather lacking. At the moment if you ask for a SDL display it'll only happen to work if you had the $DISPLAY environment variable set when you started libvirtd - you probably don't.
Hum, it would be really nicer if everything was driven only by command line options, but i can understand why the QEmu guys made it that way, at least historically
The generic XML parser allows for two attributes on the <graohics> element for setting the display and xauth filename, so this patch updates the QEMU driver to use this data if available. This means we have to start setting environment variables when invoking QEMU, so this patch is a little larger than would otherwise be expected.
Okay i think I understand the patch, i didn't find anything suspicious in the C code diff (except missing -p ?) The tests diff looks simple and systematic, and for the test program this looks fine too. +1
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 there is an LD_PRELOAD, pass it maybe, that can be really useful at times especially when debugging. Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

Daniel P. Berrange wrote:
QEMU has two modes of providing a graphical display, VNC and SDL. Now most of our tools just use VNC, but occasionally people want to use SDL for some crazy reason. We already support this in Xen driver, but the QEMU impl has been rather lacking. At the moment if you ask for a SDL display it'll only happen to work if you had the $DISPLAY environment variable set when you started libvirtd - you probably don't.
I've thought about this issue before, not sure how to fully solve it though. If we set the display in the xml at install time (say setting it to :0.0), but at a later time we ssh =Y into that machine, the display in the xml will be wrong, and possibly pop the sdl window on someone else's display. Possibly a solution at the virsh or virt-manager level? Thanks, Cole

On Fri, Oct 03, 2008 at 11:26:55AM -0400, Cole Robinson wrote:
Daniel P. Berrange wrote:
QEMU has two modes of providing a graphical display, VNC and SDL. Now most of our tools just use VNC, but occasionally people want to use SDL for some crazy reason. We already support this in Xen driver, but the QEMU impl has been rather lacking. At the moment if you ask for a SDL display it'll only happen to work if you had the $DISPLAY environment variable set when you started libvirtd - you probably don't.
I've thought about this issue before, not sure how to fully solve it though. If we set the display in the xml at install time (say setting it to :0.0), but at a later time we ssh =Y into that machine, the display in the xml will be wrong, and possibly pop the sdl window on someone else's display. Possibly a solution at the virsh or virt-manager level?
There's frankly no practical way to solve the general case problem. This only attempts to solve one specific use case. A server running the guest has a permanent X11 display available, and the admin wants to configure a guest to use this display, regardless of what $DISPLAY libvirtd/virsh happen to have. This patch enables this use case by allowing the XML to contain the explicit display name & xauth file for the server the admin wants to use. I don't expect this to be useful in the context of virt-manager. VNC is the only sensible general purpose config - SDL should only be considered for specific use cases. Daniel -- |: 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 :|
participants (4)
-
Cole Robinson
-
Daniel P. Berrange
-
Daniel Veillard
-
Jim Meyering