Re: [libvirt] PATCH: Support SDL configuration for QEMU driver

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Thu, Oct 09, 2008 at 04:31:49PM +0200, Jim Meyering wrote:
> "Daniel P. Berrange" <berrange@xxxxxxxxxx> 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@xxxxxxxxx: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@xxxxxxxxx: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 :|

--
Libvir-list mailing list
Libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list

[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]