summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRichard W.M. Jones <rjones@redhat.com>2012-10-11 15:50:41 +0100
committerRichard W.M. Jones <rjones@redhat.com>2012-10-11 15:50:41 +0100
commit67e9572286f98b830bef64cfcae5a072bf3a1882 (patch)
tree529082727055eefc399e1c220c122240c2b8ab90
parent911a16a9fa965ce8defb3307f6bf338f5d2d5c94 (diff)
downloadlibguestfs-67e9572286f98b830bef64cfcae5a072bf3a1882.tar.gz
libguestfs-67e9572286f98b830bef64cfcae5a072bf3a1882.tar.xz
libguestfs-67e9572286f98b830bef64cfcae5a072bf3a1882.zip
launch: libvirt: Always set <qemu:env> TMPDIR.
If TMPDIR is not set, we must choose one, because otherwise libvirt will use a random TMPDIR: http://bugzilla.redhat.com/865464 The convenient guestfs___persistent_tmpdir function does everything needed in this case.
-rw-r--r--src/launch-libvirt.c29
1 files changed, 16 insertions, 13 deletions
diff --git a/src/launch-libvirt.c b/src/launch-libvirt.c
index 183008ed..ad250826 100644
--- a/src/launch-libvirt.c
+++ b/src/launch-libvirt.c
@@ -1031,22 +1031,25 @@ static int
construct_libvirt_xml_qemu_cmdline (guestfs_h *g, xmlTextWriterPtr xo)
{
struct qemu_param *qp;
- char *p;
+ const char *tmpdir;
XMLERROR (-1, xmlTextWriterStartElement (xo, BAD_CAST "qemu:commandline"));
- /* We need to ensure the snapshots are created in $TMPDIR (RHBZ#856619). */
- p = getenv ("TMPDIR");
- if (p) {
- XMLERROR (-1, xmlTextWriterStartElement (xo, BAD_CAST "qemu:env"));
- XMLERROR (-1,
- xmlTextWriterWriteAttribute (xo, BAD_CAST "name",
- BAD_CAST "TMPDIR"));
- XMLERROR (-1,
- xmlTextWriterWriteAttribute (xo, BAD_CAST "value",
- BAD_CAST p));
- XMLERROR (-1, xmlTextWriterEndElement (xo));
- }
+ /* We need to ensure the snapshots are created in $TMPDIR (RHBZ#856619).
+ * If TMPDIR is not set, we must choose one, because otherwise libvirt
+ * will use a random TMPDIR (RHBZ#865464). Luckily the
+ * guestfs___persistent_tmpdir function does both of these tasks.
+ */
+ tmpdir = guestfs___persistent_tmpdir ();
+
+ XMLERROR (-1, xmlTextWriterStartElement (xo, BAD_CAST "qemu:env"));
+ XMLERROR (-1,
+ xmlTextWriterWriteAttribute (xo, BAD_CAST "name",
+ BAD_CAST "TMPDIR"));
+ XMLERROR (-1,
+ xmlTextWriterWriteAttribute (xo, BAD_CAST "value",
+ BAD_CAST tmpdir));
+ XMLERROR (-1, xmlTextWriterEndElement (xo));
/* Workaround because libvirt user networking cannot specify "net="
* parameter.