[PATCH 12/22] Set $DISPLAY before threads are started.
David Shea
dshea at redhat.com
Wed Jun 3 16:03:36 UTC 2015
$DISPLAY is effectively a constant, so set it early, before the network
thread is started, using a value in pyanaconda.constants.
(cherry picked from commit 8fd90556af510e41ec3acbac46e536f95594aa9f)
Related: rhbz#1188287
---
anaconda | 14 +++++++-------
pyanaconda/constants.py | 3 +++
pyanaconda/vnc.py | 17 ++++++++---------
3 files changed, 18 insertions(+), 16 deletions(-)
diff --git a/anaconda b/anaconda
index d8bad60..00f4c5b 100755
--- a/anaconda
+++ b/anaconda
@@ -115,13 +115,10 @@ def startX11():
# Start Xorg and wait for it become ready
iutil.startX(["Xorg", "-br", "-logfile", "/tmp/X.log",
- ":1", "vt6", "-s", "1440", "-ac",
+ ":%s" % constants.X_DISPLAY_NUMBER, "vt6", "-s", "1440", "-ac",
"-nolisten", "tcp", "-dpi", "96",
"-noreset"], output_redirect=xfd)
- # Now that X is started, make $DISPLAY available
- os.environ["DISPLAY"] = ":1"
-
# function to handle X startup special issues for anaconda
def doStartupX11Actions():
"""Start window manager"""
@@ -393,6 +390,12 @@ def setupEnvironment():
if "LD_PRELOAD" in os.environ:
del os.environ["LD_PRELOAD"]
+ # Go ahead and set $DISPLAY whether we're going to use X or not
+ if 'DISPLAY' in os.environ:
+ flags.preexisting_x11 = True
+ else:
+ os.environ["DISPLAY"] = ":%s" % constants.X_DISPLAY_NUMBER
+
def setupLoggingFromOpts(options):
if (options.debug or options.updateSrc) and not options.loglevel:
# debugging means debug logging if an explicit level hasn't been st
@@ -592,9 +595,6 @@ def setupDisplay(anaconda, options, addons=None):
stdoutLog.warning("Not asking for VNC because we don't have Xvnc")
flags.vncquestion = False
- if 'DISPLAY' in os.environ:
- flags.preexisting_x11 = True
-
# Should we try to start Xorg?
want_x = anaconda.displayMode == 'g' and \
not (flags.preexisting_x11 or flags.usevnc)
diff --git a/pyanaconda/constants.py b/pyanaconda/constants.py
index ae2dcb4..807bf0d 100644
--- a/pyanaconda/constants.py
+++ b/pyanaconda/constants.py
@@ -171,3 +171,6 @@ IPMI_STARTED = 0x7 # installation started
IPMI_FINISHED = 0x8 # installation finished successfully
IPMI_ABORTED = 0x9 # installation finished unsuccessfully, due to some non-exn error
IPMI_FAILED = 0xA # installation hit an exception
+
+# X display number to use
+X_DISPLAY_NUMBER = 1
diff --git a/pyanaconda/vnc.py b/pyanaconda/vnc.py
index 4281ae6..c31006b 100644
--- a/pyanaconda/vnc.py
+++ b/pyanaconda/vnc.py
@@ -55,11 +55,10 @@ def shutdownServer():
class VncServer:
- def __init__(self, display="1", root="/", ip=None, name=None,
+ def __init__(self, root="/", ip=None, name=None,
password="", vncconnecthost="",
vncconnectport="", log_file="/tmp/vncserver.log",
pw_file="/tmp/vncpassword"):
- self.display = display
self.root = root
self.ip = ip
self.name = name
@@ -123,9 +122,11 @@ class VncServer:
name_ips = [i[4][0] for i in socket.getaddrinfo(self.name, 0)]
if self.name is not None and not self.name.startswith('localhost') \
and ipstr is not None and self.ip in name_ips:
- self.connxinfo = "%s:%s (%s:%s)" % (socket.getfqdn(name=self.name), self.display, ipstr, self.display)
+ self.connxinfo = "%s:%s (%s:%s)" % \
+ (socket.getfqdn(name=self.name), constants.X_DISPLAY_NUMBER,
+ ipstr, constants.X_DISPLAY_NUMBER)
elif ipstr is not None:
- self.connxinfo = "%s:%s" % (ipstr, self.display,)
+ self.connxinfo = "%s:%s" % (ipstr, constants.X_DISPLAY_NUMBER)
else:
self.connxinfo = None
@@ -157,7 +158,7 @@ class VncServer:
else:
hostarg = self.vncconnecthost
- vncconfigcommand = [self.root+"/usr/bin/vncconfig", "-display", ":%s"%self.display, "-connect", hostarg]
+ vncconfigcommand = [self.root+"/usr/bin/vncconfig", "-display", ":%s" % constants.X_DISPLAY_NUMBER, "-connect", hostarg]
for _i in range(maxTries):
vncconfp = iutil.startProgram(vncconfigcommand, stdout=subprocess.PIPE, stderr=subprocess.PIPE) # vncconfig process
@@ -189,7 +190,7 @@ class VncServer:
else:
self.log.info(_("Please manually connect your vnc client to <IP ADDRESS>:%s "
"to begin the install. Switch to the shell (Ctrl-B 2) and "
- "run 'ip addr' to find the <IP ADDRESS>."), self.display)
+ "run 'ip addr' to find the <IP ADDRESS>."), constants.X_DISPLAY_NUMBER)
def startServer(self):
self.log.info(_("Starting VNC..."))
@@ -216,7 +217,7 @@ class VncServer:
self.setVNCPassword()
# Lets start the xvnc.
- xvnccommand = [ XVNC_BINARY_NAME, ":%s" % self.display,
+ xvnccommand = [ XVNC_BINARY_NAME, ":%s" % constants.X_DISPLAY_NUMBER,
"-depth", "16", "-br",
"IdleTimeout=0", "-auth", "/dev/null", "-once",
"DisconnectClients=false", "desktop=%s" % (self.desktop,),
@@ -256,8 +257,6 @@ class VncServer:
else:
self.VNCListen()
- os.environ["DISPLAY"]=":%s" % self.display
-
def changeVNCPasswdWindow(self):
""" Change the password to a sane parameter.
--
2.1.0
More information about the anaconda-patches
mailing list