aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorEric Blake <eblake@redhat.com>2011-03-26 05:27:57 -0600
committerEric Blake <eblake@redhat.com>2011-03-28 10:26:32 -0600
commitd51023d4c28c3c7e717cf349f1bcfed4af044bc4 (patch)
treec2f134d55ba9dfe81b3949be6e5dd954b07fd330 /tests
parentutil: allow clearing cloexec bit (diff)
downloadlibvirt-d51023d4c28c3c7e717cf349f1bcfed4af044bc4.tar.gz
libvirt-d51023d4c28c3c7e717cf349f1bcfed4af044bc4.tar.bz2
libvirt-d51023d4c28c3c7e717cf349f1bcfed4af044bc4.zip
qemu: fix restoring a compressed save image
Latent bug introduced in commit 2d6a581960 (Aug 2009), but not exposed until commit 1859939a (Jan 2011). Basically, when virExec creates a pipe, it always marks libvirt's side as cloexec. If libvirt then wants to hand that pipe to another child process, things work great if the fd is dup2()'d onto stdin or stdout (as with stdin: or exec: migration), but if the pipe is instead used as-is (such as with fd: migration) then qemu sees EBADF because the fd was closed at exec(). This is a minimal fix for the problem at hand; it is slightly racy, but no more racy than the rest of libvirt fd handling, including the case of uncompressed save images. A more invasive fix, but ultimately safer at avoiding leaking unintended fds, would be to _always and atomically_ open all fds as cloexec in libvirt (thanks to primitives like open(O_CLOEXEC), pipe2(), accept4(), ...), then teach virExec to clear that bit for all fds explicitly marked to be handed to the child only after forking. * src/qemu/qemu_command.c (qemuBuildCommandLine): Clear cloexec flag. * tests/qemuxml2argvtest.c (testCompareXMLToArgvFiles): Tweak test.
Diffstat (limited to 'tests')
-rw-r--r--tests/qemuxml2argvtest.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c
index c1329faf1..02de8de1a 100644
--- a/tests/qemuxml2argvtest.c
+++ b/tests/qemuxml2argvtest.c
@@ -122,7 +122,7 @@ static int testCompareXMLToArgvFiles(const char *xml,
if (!(cmd = qemuBuildCommandLine(conn, &driver,
vmdef, &monitor_chr, false, extraFlags,
migrateFrom, migrateFd, NULL,
- VIR_VM_OP_CREATE)))
+ VIR_VM_OP_NO_OP)))
goto fail;
if (!!virGetLastError() != expectError) {