virprocess: virProcessGetNamespaces() to void

virProcessGetNamespaces() return value is invariant, so change it
type and remove all dependent checks.

Signed-off-by: Artem Chernyshev <artem.chernyshev@red-soft.ru>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
Artem Chernyshev 2024-01-04 03:17:01 +03:00 committed by Michal Privoznik
parent 88903f9abf
commit d05cdd1879
5 changed files with 9 additions and 16 deletions

View File

@ -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;
}

View File

@ -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;

View File

@ -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)

View File

@ -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;
}

View File

@ -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);