Revision 13c564e7
b/lib/hypervisor/hv_lxc.py | ||
---|---|---|
65 | 65 |
|
66 | 66 |
""" |
67 | 67 |
_ROOT_DIR = constants.RUN_GANETI_DIR + "/lxc" |
68 |
_LOG_FILE = constants.LOG_DIR + "hv_lxc.log" |
|
69 | 68 |
_DEVS = [ |
70 | 69 |
"c 1:3", # /dev/null |
71 | 70 |
"c 1:5", # /dev/zero |
... | ... | |
124 | 123 |
return utils.PathJoin(cls._ROOT_DIR, instance_name + ".conf") |
125 | 124 |
|
126 | 125 |
@classmethod |
126 |
def _InstanceLogFile(cls, instance_name): |
|
127 |
"""Return the log file for an instance. |
|
128 |
|
|
129 |
""" |
|
130 |
return utils.PathJoin(cls._ROOT_DIR, instance_name + ".log") |
|
131 |
|
|
132 |
@classmethod |
|
127 | 133 |
def _GetCgroupMountPoint(cls): |
128 | 134 |
for _, mountpoint, fstype, _ in utils.GetMounts(): |
129 | 135 |
if fstype == "cgroup": |
... | ... | |
268 | 274 |
conf_file = self._InstanceConfFile(instance.name) |
269 | 275 |
utils.WriteFile(conf_file, data=self._CreateConfigFile(instance, root_dir)) |
270 | 276 |
|
277 |
log_file = self._InstanceLogFile(instance.name) |
|
278 |
if not os.path.exists(log_file): |
|
279 |
try: |
|
280 |
utils.WriteFile(log_file, data="", mode=constants.SECURE_FILE_MODE) |
|
281 |
except EnvironmentError, err: |
|
282 |
raise errors.HypervisorError("Creating hypervisor log file %s for" |
|
283 |
" instance %s failed: %s" % |
|
284 |
(log_file, instance.name, err)) |
|
285 |
|
|
271 | 286 |
if not os.path.ismount(root_dir): |
272 | 287 |
if not block_devices: |
273 | 288 |
raise HypervisorError("LXC needs at least one disk") |
... | ... | |
276 | 291 |
result = utils.RunCmd(["mount", sda_dev_path, root_dir]) |
277 | 292 |
if result.failed: |
278 | 293 |
raise HypervisorError("Can't mount the chroot dir: %s" % result.output) |
279 |
# TODO: replace the global log file with a per-instance log file |
|
280 | 294 |
result = utils.RunCmd(["lxc-start", "-n", instance.name, |
281 |
"-o", self._LOG_FILE, "-l", "DEBUG", |
|
295 |
"-o", log_file, |
|
296 |
"-l", "DEBUG", |
|
282 | 297 |
"-f", conf_file, "-d"]) |
283 | 298 |
if result.failed: |
284 | 299 |
raise HypervisorError("Running the lxc-start script failed: %s" % |
Also available in: Unified diff