aboutsummaryrefslogtreecommitdiffstats
path: root/debian/patches/601-openvz-new-ctid-vpid.patch
diff options
context:
space:
mode:
authorDaniel Lange <DLange@git.local>2016-04-13 15:55:48 +0200
committerDaniel Lange <DLange@git.local>2016-04-13 16:04:16 +0200
commit3d90f42e81876dbb9dabcbd227f7f211b18756d1 (patch)
treeb0bb479504bcdcba111e4a949f100aa3c500bdea /debian/patches/601-openvz-new-ctid-vpid.patch
parentadefe52ce2ad43c442c0b40bfe637e238e454246 (diff)
downloaddebian_htop-3d90f42e81876dbb9dabcbd227f7f211b18756d1.tar.gz
debian_htop-3d90f42e81876dbb9dabcbd227f7f211b18756d1.tar.bz2
debian_htop-3d90f42e81876dbb9dabcbd227f7f211b18756d1.zip
Clean up patches from 1.0.3 -> 2.0.1
* 600-openvz-veid-on-kernels-gt-2.6.18.patch replaced by 601-openvz-new-ctid-vpid.patch from Alexander Pisarev * 610-io-priority-only-on-linux.patch was only needed for GNU/kFreeBSD support * 700-ltrace-support.patch has not been upstreamed in 7 years and the underlying code has been completely refactored so re-writing the patch seems unreasonable. Note: This results in a loss of functionality for Debian users. htop has no longer bound the key L to run ltrace as comfortably as strace.
Diffstat (limited to 'debian/patches/601-openvz-new-ctid-vpid.patch')
-rw-r--r--debian/patches/601-openvz-new-ctid-vpid.patch121
1 files changed, 121 insertions, 0 deletions
diff --git a/debian/patches/601-openvz-new-ctid-vpid.patch b/debian/patches/601-openvz-new-ctid-vpid.patch
new file mode 100644
index 0000000..83ed8b7
--- /dev/null
+++ b/debian/patches/601-openvz-new-ctid-vpid.patch
@@ -0,0 +1,121 @@
+This replaces the old 600-openvz-veid-on-kernels-gt-2.6.18.patch
+Source: https://patch-diff.githubusercontent.com/raw/hishamhm/htop/pull/464.patch
+From: Alexander Pisarev <apisarev@virtuozzo.com>
+Date: Wed, 6 Apr 2016 14:47:28 +0300
+Subject: [PATCH] Add support of UUID CTID used in the new version of OpenVZ
+
+In the new version of OpenVZ (Virtuozzo 7), containers could be identified by UUIDs and integer numbers like before (so called legacy CTID). Existing support of OpenVZ can't work with UUIDs. This patch fix it.
+
+CTIDs and VPIDs are now read from /proc/[id]/status instead of /proc/[id]/stat because of the following reasons:
+* the /proc/[id]/status has named fields and OpenVZ kernel writes either CTID or UUID to envID field (depending on which type is used);
+* OpenVZ kernel appends own data to /proc/[id]/stat file, a change in parameters reported by vanilla kernel would also shift the position of OpenVZ data so it would not be read correctly.
+
+As UUIDs are much longer than old numerical CTIDs, the UUID strings will get truncated in output (although sorting is still done using complete UUIDs).
+---
+ linux/LinuxProcess.c | 9 ++++++---
+ linux/LinuxProcess.h | 2 +-
+ linux/LinuxProcessList.c | 38 +++++++++++++++++++++++---------------
+ 3 files changed, 30 insertions(+), 19 deletions(-)
+--- a/linux/LinuxProcess.c
++++ b/linux/LinuxProcess.c
+@@ -114,7 +114,7 @@ typedef struct LinuxProcess_ {
+ double io_rate_write_bps;
+ #endif
+ #ifdef HAVE_OPENVZ
+- unsigned int ctid;
++ char* ctid;
+ unsigned int vpid;
+ #endif
+ #ifdef HAVE_VSERVER
+@@ -251,6 +251,9 @@ LinuxProcess* LinuxProcess_new(Settings*
+ void Process_delete(Object* cast) {
+ LinuxProcess* this = (LinuxProcess*) cast;
+ Process_done((Process*)cast);
++#ifdef HAVE_OPENVZ
++ free(this->ctid);
++#endif
+ #ifdef HAVE_CGROUP
+ free(this->cgroup);
+ #endif
+@@ -321,7 +324,7 @@ void LinuxProcess_writeField(Process* th
+ }
+ #endif
+ #ifdef HAVE_OPENVZ
+- case CTID: snprintf(buffer, n, "%7u ", lp->ctid); break;
++ case CTID: snprintf(buffer, n, "%8.8s ", lp->ctid); break;
+ case VPID: snprintf(buffer, n, Process_pidFormat, lp->vpid); break;
+ #endif
+ #ifdef HAVE_VSERVER
+@@ -396,7 +399,7 @@ long LinuxProcess_compare(const void* v1
+ #endif
+ #ifdef HAVE_OPENVZ
+ case CTID:
+- return (p2->ctid - p1->ctid);
++ return strcmp(p1->ctid ?: "", p2->ctid ?: "");
+ case VPID:
+ return (p2->vpid - p1->vpid);
+ #endif
+--- a/linux/LinuxProcess.h
++++ b/linux/LinuxProcess.h
+@@ -106,7 +106,7 @@ typedef struct LinuxProcess_ {
+ double io_rate_write_bps;
+ #endif
+ #ifdef HAVE_OPENVZ
+- unsigned int ctid;
++ char* ctid;
+ unsigned int vpid;
+ #endif
+ #ifdef HAVE_VSERVER
+--- a/linux/LinuxProcessList.c
++++ b/linux/LinuxProcessList.c
+@@ -336,27 +336,35 @@ static bool LinuxProcessList_readStatmFi
+ #ifdef HAVE_OPENVZ
+
+ static void LinuxProcessList_readOpenVZData(LinuxProcess* process, const char* dirname, const char* name) {
+- if ( (access("/proc/vz", R_OK) != 0)) {
+- process->vpid = process->super.pid;
+- process->ctid = 0;
++ process->vpid = process->super.pid;
++ free(process->ctid);
++ process->ctid = xStrdup("0");
++ if ( (access("/proc/vz", R_OK) != 0))
+ return;
+- }
+ char filename[MAX_NAME+1];
+- snprintf(filename, MAX_NAME, "%s/%s/stat", dirname, name);
++ snprintf(filename, MAX_NAME, "%s/%s/status", dirname, name);
+ FILE* file = fopen(filename, "r");
+ if (!file)
+ return;
+- (void) fscanf(file,
+- "%*32u %*32s %*1c %*32u %*32u %*32u %*32u %*32u %*32u %*32u "
+- "%*32u %*32u %*32u %*32u %*32u %*32u %*32u %*32u "
+- "%*32u %*32u %*32u %*32u %*32u %*32u %*32u %*32u "
+- "%*32u %*32u %*32u %*32u %*32u %*32u %*32u %*32u "
+- "%*32u %*32u %*32u %*32u %*32u %*32u %*32u %*32u "
+- "%*32u %*32u %*32u %*32u %*32u %*32u %*32u "
+- "%*32u %*32u %32u %32u",
+- &process->vpid, &process->ctid);
++ char buffer[PROC_LINE_LENGTH + 1];
++ while (fgets(buffer, PROC_LINE_LENGTH, file)) {
++ if (String_startsWith(buffer, "envID:")) {
++ char ctid[PROC_LINE_LENGTH + 1];
++ int ok = sscanf(buffer, "envID:\t%36s", ctid);
++ if (ok == 1) {
++ free(process->ctid);
++ process->ctid = xStrdup(ctid);
++ }
++ }
++ else if (String_startsWith(buffer, "VPid:")) {
++ unsigned int vpid;
++ int ok = sscanf(buffer, "VPid:\t%32u", &vpid);
++ if (ok == 1) {
++ process->vpid = vpid;
++ }
++ }
++ }
+ fclose(file);
+- return;
+ }
+
+ #endif

© 2014-2024 Faster IT GmbH | imprint | privacy policy