
On 10/17/18 5:06 AM, Michal Privoznik wrote:
Both virProcessRunInMountNamespace() and virProcessRunInFork() look very similar. De-duplicate the code and make virProcessRunInMountNamespace() call virProcessRunInFork().> Signed-off-by: Michal Privoznik <mprivozn@redhat.com> --- src/util/virprocess.c | 62 +++++++++---------------------------------- 1 file changed, 12 insertions(+), 50 deletions(-)
diff --git a/src/util/virprocess.c b/src/util/virprocess.c index 51b9ccb1bb..3304879212 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -1073,11 +1073,17 @@ int virProcessGetStartTime(pid_t pid, #endif
-static int virProcessNamespaceHelper(int errfd, - pid_t pid, - virProcessNamespaceCallback cb, +typedef struct _virProcessNamespaceHelperData virProcessNamespaceHelperData; +struct _virProcessNamespaceHelperData { + pid_t pid; + virProcessNamespaceCallback cb; + void *opaque; +}; + +static int virProcessNamespaceHelper(pid_t pid ATTRIBUTE_UNUSED, void *opaque) { + virProcessNamespaceHelperData *data = opaque; int fd = -1; int ret = -1; VIR_AUTOFREE(char *) path = NULL;
Right after this there's a : if (virAsprintf(&path, "/proc/%lld/ns/mnt", (long long) pid) < 0) goto cleanup; The last arg should be data->pid I believe... Beyond that - nothing jumps out at me... Reviewed-by: John Ferlan <jferlan@redhat.com> John