From d05cdd18792e6e5f7c595565de15ce3259724c36 Mon Sep 17 00:00:00 2001 From: Artem Chernyshev Date: Thu, 4 Jan 2024 03:17:01 +0300 Subject: [PATCH] virprocess: virProcessGetNamespaces() to void virProcessGetNamespaces() return value is invariant, so change it type and remove all dependent checks. Signed-off-by: Artem Chernyshev Signed-off-by: Michal Privoznik Reviewed-by: Michal Privoznik --- src/libvirt-lxc.c | 5 +---- src/lxc/lxc_driver.c | 3 +-- src/qemu/qemu_process.c | 3 +-- src/util/virprocess.c | 8 +++----- src/util/virprocess.h | 6 +++--- 5 files changed, 9 insertions(+), 16 deletions(-) diff --git a/src/libvirt-lxc.c b/src/libvirt-lxc.c index ecc1207ca9..99bb450702 100644 --- a/src/libvirt-lxc.c +++ b/src/libvirt-lxc.c @@ -140,10 +140,7 @@ virDomainLxcEnterNamespace(virDomainPtr domain, if (noldfdlist && oldfdlist) { size_t nfds; - if (virProcessGetNamespaces(getpid(), - &nfds, - oldfdlist) < 0) - goto error; + virProcessGetNamespaces(getpid(), &nfds, oldfdlist); *noldfdlist = nfds; } diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 3e9c1395bf..c281998652 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -4691,8 +4691,7 @@ static int lxcDomainLxcOpenNamespace(virDomainPtr dom, goto endjob; } - if (virProcessGetNamespaces(priv->initpid, &nfds, fdlist) < 0) - goto endjob; + virProcessGetNamespaces(priv->initpid, &nfds, fdlist); ret = nfds; diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 696d526a5d..7770e7e7eb 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -2737,8 +2737,7 @@ qemuProcessStartPRDaemonHook(void *opaque) int ret = -1; if (qemuDomainNamespaceEnabled(vm, QEMU_DOMAIN_NS_MOUNT)) { - if (virProcessGetNamespaces(vm->pid, &nfds, &fds) < 0) - return ret; + virProcessGetNamespaces(vm->pid, &nfds, &fds); if (nfds > 0 && virProcessSetNamespaces(nfds, fds) < 0) diff --git a/src/util/virprocess.c b/src/util/virprocess.c index b6fb17db83..047b0aa0cd 100644 --- a/src/util/virprocess.c +++ b/src/util/virprocess.c @@ -652,9 +652,9 @@ int virProcessGetPids(pid_t pid, size_t *npids, pid_t **pids) } -int virProcessGetNamespaces(pid_t pid, - size_t *nfdlist, - int **fdlist) +void virProcessGetNamespaces(pid_t pid, + size_t *nfdlist, + int **fdlist) { size_t i = 0; const char *ns[] = { "user", "ipc", "uts", "net", "pid", "mnt" }; @@ -673,8 +673,6 @@ int virProcessGetNamespaces(pid_t pid, (*fdlist)[(*nfdlist)-1] = fd; } } - - return 0; } diff --git a/src/util/virprocess.h b/src/util/virprocess.h index 6008cca4af..9c74ec7e35 100644 --- a/src/util/virprocess.h +++ b/src/util/virprocess.h @@ -70,9 +70,9 @@ int virProcessGetPids(pid_t pid, size_t *npids, pid_t **pids); int virProcessGetStartTime(pid_t pid, unsigned long long *timestamp); -int virProcessGetNamespaces(pid_t pid, - size_t *nfdlist, - int **fdlist); +void virProcessGetNamespaces(pid_t pid, + size_t *nfdlist, + int **fdlist); int virProcessSetNamespaces(size_t nfdlist, int *fdlist);