File cd7acb33-virfile-report-error.patch of Package libvirt.26629
commit cd7acb33231837c4bcf6ccbd7d451e145b5f3667
Author: Michal Prívozník <mprivozn@redhat.com>
Date: Mon Mar 28 13:29:19 2022 +0200
virfile: Report error when changing pipe size fails
When changing the size of pipe that virFileWrapperFdNew() creates
we start at 1MiB and if that fails because it's above the system
wide limit we get EPERM and continue with half of the size.
However, we might get another error in which case we should
report proper system error and return failure from
virFileWrapperFdNew().
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Index: libvirt-8.0.0/src/util/virfile.c
===================================================================
--- libvirt-8.0.0.orig/src/util/virfile.c
+++ libvirt-8.0.0/src/util/virfile.c
@@ -217,7 +217,7 @@ struct _virFileWrapperFd {
*
* OS note: only for linux, on other OS this is a no-op.
*/
-static void
+static int
virFileWrapperSetPipeSize(int fd)
{
int sz;
@@ -230,21 +230,24 @@ virFileWrapperSetPipeSize(int fd)
continue; /* retry with half the size */
}
if (rv < 0) {
- break;
+ virReportSystemError(errno, "%s",
+ _("unable to set pipe size"));
+ return -1;
}
VIR_DEBUG("fd %d pipe size adjusted to %d", fd, sz);
- return;
+ return 0;
}
VIR_WARN("unable to set pipe size, data transfer might be slow: %s",
g_strerror(errno));
+ return 0;
}
# else /* !__linux__ */
-static void
+static int
virFileWrapperSetPipeSize(int fd G_GNUC_UNUSED)
{
- return;
+ return 0;
}
# endif /* !__linux__ */
@@ -323,6 +326,9 @@ virFileWrapperFdNew(int *fd, const char
if (virPipe(pipefd) < 0)
goto error;
+ if (virFileWrapperSetPipeSize(pipefd[output]) < 0)
+ goto error;
+
if (!(iohelper_path = virFileFindResource("libvirt_iohelper",
abs_top_builddir "/src",
LIBEXECDIR)))
@@ -330,8 +336,6 @@ virFileWrapperFdNew(int *fd, const char
ret->cmd = virCommandNewArgList(iohelper_path, name, NULL);
- virFileWrapperSetPipeSize(pipefd[output]);
-
if (output) {
virCommandSetInputFD(ret->cmd, pipefd[0]);
virCommandSetOutputFD(ret->cmd, fd);