launchpad-reviewers team mailing list archive
-
launchpad-reviewers team
-
Mailing list archive
-
Message #01675
[Merge] lp:~abentley/launchpad/detect-xen-2 into lp:launchpad
Aaron Bentley has proposed merging lp:~abentley/launchpad/detect-xen-2 into lp:launchpad.
Requested reviews:
Launchpad code reviewers (launchpad-reviewers)
= Summary =
Detect that running as a Xen guest
== Proposed fix ==
It turns out xen-detect doesn't detect whether the current environment is a Xen
guest, so Lamont said that ensuring /proc/xen but not /prox/xen/xsd_kva exists
was a hacky, but workable test.
== Pre-implementation notes ==
Done at Lamont's request
== Implementation details ==
See above
== Tests ==
None
== Demo and Q/A ==
Get Lamont to install this on the staging buildfarm. Ensure it can perform a
sourcepackagerecipe build.
= Launchpad lint =
Checking for conflicts and issues in changed files.
Linting changed files:
lib/canonical/buildd/buildrecipe
--
https://code.launchpad.net/~abentley/launchpad/detect-xen-2/+merge/39294
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~abentley/launchpad/detect-xen-2 into lp:launchpad.
=== modified file 'lib/canonical/buildd/buildrecipe'
--- lib/canonical/buildd/buildrecipe 2010-09-30 20:22:15 +0000
+++ lib/canonical/buildd/buildrecipe 2010-10-25 16:59:49 +0000
@@ -7,12 +7,11 @@
__metaclass__ = type
-import errno
import os
+import os.path
import pwd
-import re
import socket
-from subprocess import call, Popen, PIPE
+from subprocess import call
import sys
@@ -26,21 +25,8 @@
class NotVirtualized(Exception):
"""Exception raised when not running in a virtualized environment."""
-
-class NoXenDetect(NotVirtualized):
- """xen-detect not installed."""
-
def __init__(self):
- NotVirtualized.__init__(self, 'xen-detect is not installed.')
-
-
-class BadXenDetect(NotVirtualized):
- """xen-detect's output not not indicate that we are virtualized."""
-
- def __init__(self, xen_detect_output):
- NotVirtualized.__init__(
- self, 'Bad xen-detect output: %s' % xen_detect_output)
- self.xen_detect_output = xen_detect_output
+ Exception.__init__(self, 'Not running under Xen.')
class RecipeBuilder:
@@ -191,18 +177,10 @@
def ensure_virtualized():
"""Raise an exception if not running in a virtualized environment.
- Raises if unsure, or if not running under Xen.
+ Raises if not running under Xen.
"""
- try:
- proc = Popen(['xen-detect'], stdout=PIPE)
- except OSError, e:
- if e.errno != errno.ENOENT:
- raise
- raise NoXenDetect()
- status_code = proc.wait()
- output = proc.stdout.read()
- if not re.match('Running in .* context on Xen', output):
- raise BadXenDetect(output)
+ if not os.path.isdir('/proc/xen') or os.path.exists('/proc/xen/xsd_kva'):
+ raise NotVirtualized()
if __name__ == '__main__':