mooli tayer has uploaded a new change for review.
Change subject: This commit only adds the libvirtd_sysv2upstart to configurator. It will
be used in a seperate commit.
......................................................................
This commit only adds the libvirtd_sysv2upstart to configurator.
It will be used in a seperate commit.
Change-Id: I872100a6d28ea6da40e6896939aeff4b514f3e71
Signed-off-by: Mooli Tayer <mtayer(a)redhat.com>
---
M lib/vdsm/tool/configurator.py
1 file changed, 39 insertions(+), 0 deletions(-)
git pull ssh://gerrit.ovirt.org:29418/vdsm refs/changes/58/26958/1
diff --git a/lib/vdsm/tool/configurator.py b/lib/vdsm/tool/configurator.py
index f0944f3..744a8c6 100644
--- a/lib/vdsm/tool/configurator.py
+++ b/lib/vdsm/tool/configurator.py
@@ -21,6 +21,10 @@
import sys
import grp
import argparse
+import filecmp
+import itertools
+import rpm
+import shutil
from .. import utils
from . import service, expose
@@ -96,6 +100,41 @@
def configure(self):
self._exec_libvirt_configure("reconfigure")
+ def libvirtd_sysv2upstart(self):
+ """
+ On RHEL 6, libvirtd can be started by either SysV init or Upstart.
+ We prefer upstart because it respawns libvirtd if when libvirtd
+ crashed.
+ """
+ INITCTL = '/sbin/initctl'
+ LIBVIRTD_UPSTART = 'libvirtd.upstart'
+ TARGET = "/etc/init/libvirtd.conf"
+ if os.path.isfile(INITCTL) and os.access(INITCTL, os.X_OK):
+ ts = rpm.TransactionSet()
+ mi = itertools.chain(*[ts.dbMatch('name', name)
+ for name in ['libvirt',
'libvirt-daemon']])
+ # libvirtd package does not provide libvirtd.upstart,
+ # this could happen in Ubuntu or other distro,
+ # so continue to use system default init mechanism
+ for filename in itertools.chain(*[h[rpm.RPMTAG_FILENAMES]
+ for h in mi]):
+ if LIBVIRTD_UPSTART in filename:
+ packeged = filename
+ break
+ if packeged is not None and os.path.isfile(packeged):
+ if not os.path.isfile(TARGET):
+ service.service_stop('libvirtd')
+ if not os.path.isfile(TARGET) or \
+ not filecmp.cmp(packeged, TARGET):
+ shutil.copyfile(packeged, TARGET)
+ rc, out, err = utils.execCmd((INITCTL,
+ "reload-configuration"))
+ if rc != 0:
+ sys.stdout.write(out)
+ sys.stderr.write(err)
+ raise RuntimeError(
+ "Failed to reload upstart configuration.")
+
def validate(self):
"""
Validate conflict in configured files
--
To view, visit
http://gerrit.ovirt.org/26958
To unsubscribe, visit
http://gerrit.ovirt.org/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I872100a6d28ea6da40e6896939aeff4b514f3e71
Gerrit-PatchSet: 1
Gerrit-Project: vdsm
Gerrit-Branch: master
Gerrit-Owner: mooli tayer <mtayer(a)redhat.com>