virprocess.h 3.0 KB
Newer Older
1 2 3
/*
 * virprocess.h: interaction with processes
 *
4
 * Copyright (C) 2010-2015 Red Hat, Inc.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library.  If not, see
 * <http://www.gnu.org/licenses/>.
 *
 */

#ifndef __VIR_PROCESS_H__
# define __VIR_PROCESS_H__

# include <sys/types.h>

# include "internal.h"
28
# include "virbitmap.h"
29 30 31 32 33 34 35 36 37 38 39 40 41
# include "virutil.h"

typedef enum {
    VIR_PROC_POLICY_NONE = 0,
    VIR_PROC_POLICY_BATCH,
    VIR_PROC_POLICY_IDLE,
    VIR_PROC_POLICY_FIFO,
    VIR_PROC_POLICY_RR,

    VIR_PROC_POLICY_LAST
} virProcessSchedPolicy;

VIR_ENUM_DECL(virProcessSchedPolicy);
42

43 44 45 46 47 48
char *
virProcessTranslateStatus(int status);

void
virProcessAbort(pid_t pid);

49 50
void virProcessExitWithStatus(int status) ATTRIBUTE_NORETURN;

51
int
52
virProcessWait(pid_t pid, int *exitstatus, bool raw)
53 54
    ATTRIBUTE_RETURN_CHECK;

55 56
int virProcessKill(pid_t pid, int sig);

57 58
int virProcessKillPainfully(pid_t pid, bool force);

59 60
int virProcessSetAffinity(pid_t pid, virBitmapPtr map);

61
virBitmapPtr virProcessGetAffinity(pid_t pid);
62

63 64
int virProcessGetPids(pid_t pid, size_t *npids, pid_t **pids);

65 66 67
int virProcessGetStartTime(pid_t pid,
                           unsigned long long *timestamp);

68 69 70 71 72 73 74
int virProcessGetNamespaces(pid_t pid,
                            size_t *nfdlist,
                            int **fdlist);

int virProcessSetNamespaces(size_t nfdlist,
                            int *fdlist);

75 76 77
int virProcessSetMaxMemLock(pid_t pid, unsigned long long bytes);
int virProcessSetMaxProcesses(pid_t pid, unsigned int procs);
int virProcessSetMaxFiles(pid_t pid, unsigned int files);
78
int virProcessSetMaxCoreSize(pid_t pid, unsigned long long bytes);
79

80 81
int virProcessGetMaxMemLock(pid_t pid, unsigned long long *bytes);

82 83 84 85
/* Callback to run code within the mount namespace tied to the given
 * pid.  This function must use only async-signal-safe functions, as
 * it gets run after a fork of a multi-threaded process.  The return
 * value of this function is passed to _exit(), except that a
86
 * negative value is treated as EXIT_CANCELED.  */
87 88 89 90 91
typedef int (*virProcessNamespaceCallback)(pid_t pid, void *opaque);

int virProcessRunInMountNamespace(pid_t pid,
                                  virProcessNamespaceCallback cb,
                                  void *opaque);
92

93 94
int virProcessSetupPrivateMountNS(void);

95 96 97 98
int virProcessSetScheduler(pid_t pid,
                           virProcessSchedPolicy policy,
                           int priority);

99
#endif /* __VIR_PROCESS_H__ */