[libvirt] Bug: virsh edit broken on master

Hey all, commit 4ac47730: Use g_mkstemp_full instead of mkostemp(s) broke `virsh edit` (at least on S390): virsh # edit test error: write: /tmp/virshQ7SXB0.xml: failed to write to temporary file: Bad file descriptorx I didn't find out why, everything looks normal: # ls -l /proc/$(pgrep virsh)/fd/ total 0 [...] lr-x------. 1 root root 64 Nov 18 16:58 10 -> /tmp/virshAEKYB0.xml # ls -l /tmp/virshAEKYB0.xml -rw-------. 1 root root 0 Nov 18 16:59 /tmp/virshAEKYB0.xml Best, Bjoern -- IBM Systems Linux on Z & Virtualization Development -------------------------------------------------- IBM Deutschland Research & Development GmbH Schönaicher Str. 220, 71032 Böblingen Phone: +49 7031 16 1819 -------------------------------------------------- Vorsitzende des Aufsichtsrats: Matthias Hartmann Geschäftsführung: Dirk Wittkopp Sitz der Gesellschaft: Böblingen Registergericht: Amtsgericht Stuttgart, HRB 243294

On Mon, Nov 18, 2019 at 05:12:23PM +0100, Bjoern Walk wrote:
Hey all,
commit 4ac47730: Use g_mkstemp_full instead of mkostemp(s) broke `virsh edit` (at least on S390):
This change didn't request any access bits so the temp files are all being created with O_RDONLY. openat(AT_FDCWD, "/tmp/virshUVWDB0.xml", O_RDONLY|O_CREAT|O_EXCL|O_CLOEXEC, 0600) = 5 write(5, "<domain type='test'>\n <name>tes"..., 1027) = -1 EBADF (Bad file descriptor)
virsh # edit test error: write: /tmp/virshQ7SXB0.xml: failed to write to temporary file: Bad file descriptorx
I didn't find out why, everything looks normal:
# ls -l /proc/$(pgrep virsh)/fd/ total 0 [...] lr-x------. 1 root root 64 Nov 18 16:58 10 -> /tmp/virshAEKYB0.xml
# ls -l /tmp/virshAEKYB0.xml -rw-------. 1 root root 0 Nov 18 16:59 /tmp/virshAEKYB0.xml
Regards, Daniel -- |: https://berrange.com -o- https://www.flickr.com/photos/dberrange :| |: https://libvirt.org -o- https://fstop138.berrange.com :| |: https://entangle-photo.org -o- https://www.instagram.com/dberrange :|

On Mon, Nov 18, 2019 at 05:12:23PM +0100, Bjoern Walk wrote:
Hey all,
commit 4ac47730: Use g_mkstemp_full instead of mkostemp(s) broke `virsh
Oops,
edit` (at least on S390):
virsh # edit test error: write: /tmp/virshQ7SXB0.xml: failed to write to temporary file: Bad file descriptorx
I didn't find out why, everything looks normal:
# ls -l /proc/$(pgrep virsh)/fd/ total 0 [...] lr-x------. 1 root root 64 Nov 18 16:58 10 -> /tmp/virshAEKYB0.xml
# ls -l /tmp/virshAEKYB0.xml -rw-------. 1 root root 0 Nov 18 16:59 /tmp/virshAEKYB0.xml
strace shows that the file is open with O_RDONLY openat(AT_FDCWD, "/tmp/virshXNQGB0.xml", O_RDONLY|O_CREAT|O_EXCL|O_CLOEXEC, 0600) = 9 write(9, "<domain type='kvm'>\n <name>r8</"..., 6087) = -1 EBADF (Bad file descriptor) It seems O_RDWR is only implied by g_mkstemp, not g_mkstemp_full. Jano
participants (3)
-
Bjoern Walk
-
Daniel P. Berrangé
-
Ján Tomko