summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorZac Medico <zmedico@gentoo.org>2008-07-24 14:43:37 +0000
committerZac Medico <zmedico@gentoo.org>2008-07-24 14:43:37 +0000
commit39ee57ea5760c13d9e892c6a057ee7913f818d34 (patch)
tree9b5ffb3e52325e0ec56cc0d37c7e865cc57a6c98
parent3b91a546c90f20a6099f211f198584003a34ae7b (diff)
downloadportage-39ee57ea5760c13d9e892c6a057ee7913f818d34.tar.gz
portage-39ee57ea5760c13d9e892c6a057ee7913f818d34.tar.bz2
portage-39ee57ea5760c13d9e892c6a057ee7913f818d34.zip
Bug #206773 - Add a new PORTAGE_IONICE_COMMAND variable that emerge uses
to adjust ionice priority, similar to PORTAGE_NICENESS but used more like FETCHCOMMAND since so that portage doesn't have to know anything about ionice options. The command should include a \${PID} place-holder to be substituted with an integer pid. svn path=/main/trunk/; revision=11182
-rw-r--r--cnf/make.globals3
-rw-r--r--man/make.conf.58
-rw-r--r--pym/_emerge/__init__.py25
-rw-r--r--pym/portage/__init__.py3
4 files changed, 38 insertions, 1 deletions
diff --git a/cnf/make.globals b/cnf/make.globals
index 594278f19..0b29536fe 100644
--- a/cnf/make.globals
+++ b/cnf/make.globals
@@ -62,6 +62,9 @@ PORTAGE_FETCH_CHECKSUM_TRY_MIRRORS="5"
# Minimum size of existing file for RESUMECOMMAND to be called.
PORTAGE_FETCH_RESUME_MIN_SIZE="350K"
+# Command called to adjust the io priority of portage and it's subprocesses.
+PORTAGE_IONICE_COMMAND="ionice -c 2 -n 7 -p \${PID}"
+
# Number of times 'emerge --sync' will run before giving up.
PORTAGE_RSYNC_RETRIES="3"
diff --git a/man/make.conf.5 b/man/make.conf.5
index b3dc3c49d..36db9d536 100644
--- a/man/make.conf.5
+++ b/man/make.conf.5
@@ -459,6 +459,14 @@ that small garbage files such as html 404 pages are properly discarded. The
variable should contain an integer number of bytes and may have a suffix such
as K, M, or G.
.TP
+\fBPORTAGE_IONICE_COMMAND\fR = \fI[ionice command string]\fR
+This variable should contain a command for portage to call in order
+to adjust the io priority of portage and it's subprocesses. The command
+string should contain a \\${PID} place-holder that will be substituted
+with an integer pid. For more information about ionice, see \fBionice\fR(1).
+.br
+Defaults to "ionice -c 2 -n 7 -p \\${PID}".
+.TP
\fBPORTAGE_NICENESS\fR = \fI[number]\fR
The value of this variable will be added to the current nice level that
emerge is running at. In other words, this will not set the nice level,
diff --git a/pym/_emerge/__init__.py b/pym/_emerge/__init__.py
index 50462940d..6c25bafd3 100644
--- a/pym/_emerge/__init__.py
+++ b/pym/_emerge/__init__.py
@@ -12846,6 +12846,29 @@ def adjust_config(myopts, settings):
settings["NOCOLOR"] = "true"
settings.backup_changes("NOCOLOR")
+def ionice(settings):
+
+ ionice_cmd = settings.get("PORTAGE_IONICE_COMMAND")
+ if ionice_cmd:
+ ionice_cmd = shlex.split(ionice_cmd)
+ if not ionice_cmd:
+ return
+
+ from portage.util import varexpand
+ variables = {"PID" : str(os.getpid())}
+ cmd = [varexpand(x, mydict=variables) for x in ionice_cmd]
+
+ try:
+ rval = portage.process.spawn(cmd, env=os.environ)
+ except portage.exception.CommandNotFound:
+ # The OS kernel probably doesn't support ionice,
+ # so return silently.
+ return
+
+ if rval != os.EX_OK:
+ out = portage.output.EOutput()
+ out.eerror("PORTAGE_IONICE_COMMAND returned %d" % (rval,))
+
def emerge_main():
global portage # NFC why this is necessary now - genone
portage._disable_legacy_globals()
@@ -12867,6 +12890,8 @@ def emerge_main():
settings, trees, mtimedb = load_emerge_config()
portdb = trees[settings["ROOT"]]["porttree"].dbapi
+ ionice(settings)
+
try:
os.nice(int(settings.get("PORTAGE_NICENESS", "0")))
except (OSError, ValueError), e:
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py
index 66e3377ac..e4fe13eed 100644
--- a/pym/portage/__init__.py
+++ b/pym/portage/__init__.py
@@ -996,7 +996,8 @@ class config(object):
"PORTAGE_ELOG_MAILURI", "PORTAGE_ELOG_SYSTEM",
"PORTAGE_FETCH_CHECKSUM_TRY_MIRRORS", "PORTAGE_FETCH_RESUME_MIN_SIZE",
"PORTAGE_GPG_DIR",
- "PORTAGE_GPG_KEY", "PORTAGE_PACKAGE_EMPTY_ABORT",
+ "PORTAGE_GPG_KEY", "PORTAGE_IONICE_COMMAND",
+ "PORTAGE_PACKAGE_EMPTY_ABORT",
"PORTAGE_RO_DISTDIRS",
"PORTAGE_RSYNC_EXTRA_OPTS", "PORTAGE_RSYNC_OPTS",
"PORTAGE_RSYNC_RETRIES", "PORTAGE_USE", "PORT_LOGDIR",