summaryrefslogtreecommitdiffstats
path: root/src/launch-libvirt.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/launch-libvirt.c')
-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.