[libvirt] [PATCH] util/virprocess.c: fix MinGW build

Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/util/virprocess.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/src/util/virprocess.c b/src/util/virprocess.c index 15d8309..3dae1bd 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -28,7 +28,6 @@ #include <stdlib.h> #include <sys/wait.h> #include <unistd.h> -#include <sys/syscall.h> #if HAVE_SETRLIMIT # include <sys/time.h> # include <sys/resource.h> @@ -78,10 +77,21 @@ VIR_LOG_INIT("util.process"); #endif #ifndef HAVE_SETNS +# ifndef WIN32 +# include <sys/syscall.h> + static inline int setns(int fd, int nstype) { return syscall(__NR_setns, fd, nstype); } +# else +static inline int setns(int fd ATTRIBUTE_UNUSED, int nstype ATTRIBUTE_UNUSED) +{ + virReportSystemError(ENOSYS, "%s", + _("Namespaces are not supported on windows.")); + return -1; +} +# endif /* WIN32 */ #endif /* HAVE_SETNS */ /** -- 1.8.5.5

Subject doesn't describe what caused the build to fail. On 09/11/14 14:57, Pavel Hrdina wrote: Neither the rest of the commit message.
Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/util/virprocess.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/util/virprocess.c b/src/util/virprocess.c index 15d8309..3dae1bd 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -28,7 +28,6 @@ #include <stdlib.h> #include <sys/wait.h> #include <unistd.h> -#include <sys/syscall.h> #if HAVE_SETRLIMIT # include <sys/time.h> # include <sys/resource.h> @@ -78,10 +77,21 @@ VIR_LOG_INIT("util.process"); #endif
#ifndef HAVE_SETNS
Is this set on the windows build? That's strange. Shouldn't we fix the make system to avoid it?
+# ifndef WIN32 +# include <sys/syscall.h> + static inline int setns(int fd, int nstype) { return syscall(__NR_setns, fd, nstype); } +# else +static inline int setns(int fd ATTRIBUTE_UNUSED, int nstype ATTRIBUTE_UNUSED) +{ + virReportSystemError(ENOSYS, "%s", + _("Namespaces are not supported on windows.")); + return -1; +} +# endif /* WIN32 */ #endif /* HAVE_SETNS */
/**
Peter

On 09/11/2014 03:03 PM, Peter Krempa wrote:
Subject doesn't describe what caused the build to fail.
On 09/11/14 14:57, Pavel Hrdina wrote:
Neither the rest of the commit message.
The build failed because of missing "sys/syscall.h". Will update the commit message, thanks.
Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/util/virprocess.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/util/virprocess.c b/src/util/virprocess.c index 15d8309..3dae1bd 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -28,7 +28,6 @@ #include <stdlib.h> #include <sys/wait.h> #include <unistd.h> -#include <sys/syscall.h> #if HAVE_SETRLIMIT # include <sys/time.h> # include <sys/resource.h> @@ -78,10 +77,21 @@ VIR_LOG_INIT("util.process"); #endif
#ifndef HAVE_SETNS
Is this set on the windows build? That's strange. Shouldn't we fix the make system to avoid it?
This is a workaround if the HAVE_SETNS is not defined because old glibc may not have a wrapper for this syscall. And it obviously isn't defined for windows. Pavel
+# ifndef WIN32 +# include <sys/syscall.h> + static inline int setns(int fd, int nstype) { return syscall(__NR_setns, fd, nstype); } +# else +static inline int setns(int fd ATTRIBUTE_UNUSED, int nstype ATTRIBUTE_UNUSED) +{ + virReportSystemError(ENOSYS, "%s", + _("Namespaces are not supported on windows.")); + return -1; +} +# endif /* WIN32 */ #endif /* HAVE_SETNS */
/**
Peter

On 09/11/14 15:12, Pavel Hrdina wrote:
On 09/11/2014 03:03 PM, Peter Krempa wrote:
Subject doesn't describe what caused the build to fail.
On 09/11/14 14:57, Pavel Hrdina wrote:
Neither the rest of the commit message.
The build failed because of missing "sys/syscall.h".
Will update the commit message, thanks.
Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/util/virprocess.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/util/virprocess.c b/src/util/virprocess.c index 15d8309..3dae1bd 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -28,7 +28,6 @@ #include <stdlib.h> #include <sys/wait.h> #include <unistd.h> -#include <sys/syscall.h> #if HAVE_SETRLIMIT # include <sys/time.h> # include <sys/resource.h> @@ -78,10 +77,21 @@ VIR_LOG_INIT("util.process"); #endif
#ifndef HAVE_SETNS
Is this set on the windows build? That's strange. Shouldn't we fix the make system to avoid it?
This is a workaround if the HAVE_SETNS is not defined because old glibc may not have a wrapper for this syscall. And it obviously isn't defined for windows.
Aaah, right. I overlooked the "n" in ifndef ... ACK if you add the commit message then. Peter

On 09/11/2014 03:13 PM, Peter Krempa wrote:
On 09/11/14 15:12, Pavel Hrdina wrote:
On 09/11/2014 03:03 PM, Peter Krempa wrote:
Subject doesn't describe what caused the build to fail.
On 09/11/14 14:57, Pavel Hrdina wrote:
Neither the rest of the commit message.
The build failed because of missing "sys/syscall.h".
Will update the commit message, thanks.
Signed-off-by: Pavel Hrdina <phrdina@redhat.com> --- src/util/virprocess.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-)
diff --git a/src/util/virprocess.c b/src/util/virprocess.c index 15d8309..3dae1bd 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -28,7 +28,6 @@ #include <stdlib.h> #include <sys/wait.h> #include <unistd.h> -#include <sys/syscall.h> #if HAVE_SETRLIMIT # include <sys/time.h> # include <sys/resource.h> @@ -78,10 +77,21 @@ VIR_LOG_INIT("util.process"); #endif
#ifndef HAVE_SETNS
Is this set on the windows build? That's strange. Shouldn't we fix the make system to avoid it?
This is a workaround if the HAVE_SETNS is not defined because old glibc may not have a wrapper for this syscall. And it obviously isn't defined for windows.
Aaah, right. I overlooked the "n" in ifndef ...
ACK if you add the commit message then.
Peter
Pushed, thanks. Pavel
participants (2)
-
Pavel Hrdina
-
Peter Krempa