mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-02-25 18:55:27 -06:00
Start libvirtd with system-config-services if we just installed it
This commit is contained in:
parent
a80c1ce882
commit
f7eb8f0f96
@ -25,6 +25,7 @@ import logging
|
|||||||
import traceback
|
import traceback
|
||||||
import threading
|
import threading
|
||||||
import os
|
import os
|
||||||
|
import time
|
||||||
|
|
||||||
import libvirt
|
import libvirt
|
||||||
import virtinst
|
import virtinst
|
||||||
@ -216,6 +217,53 @@ def packagekit_search(session, pk_control, package_name, packages):
|
|||||||
return found
|
return found
|
||||||
|
|
||||||
|
|
||||||
|
def start_libvirtd():
|
||||||
|
"""
|
||||||
|
Connect to systemd and start libvirtd if required
|
||||||
|
"""
|
||||||
|
logging.debug("Trying to start libvirtd through systemd")
|
||||||
|
unitname = "libvirtd.service"
|
||||||
|
|
||||||
|
try:
|
||||||
|
bus = dbus.SystemBus()
|
||||||
|
except:
|
||||||
|
logging.exception("Error getting system bus handle")
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
systemd = dbus.Interface(bus.get_object(
|
||||||
|
"org.freedesktop.systemd1",
|
||||||
|
"/org/freedesktop/systemd1"),
|
||||||
|
"org.freedesktop.systemd1.Manager")
|
||||||
|
except:
|
||||||
|
logging.exception("Couldn't connect to systemd")
|
||||||
|
return
|
||||||
|
|
||||||
|
try:
|
||||||
|
unitpath = systemd.GetUnit(unitname)
|
||||||
|
proxy = bus.get_object("org.freedesktop.systemd1", unitpath)
|
||||||
|
props = dbus.Interface(proxy, "org.freedesktop.DBus.Properties")
|
||||||
|
state = props.Get("org.freedesktop.systemd1.Unit", "ActiveState")
|
||||||
|
|
||||||
|
logging.debug("libvirtd state=%s", state)
|
||||||
|
if state == "Active":
|
||||||
|
logging.debug("libvirtd already active, not starting")
|
||||||
|
return True
|
||||||
|
except:
|
||||||
|
logging.exception("Failed to lookup libvirtd status")
|
||||||
|
return
|
||||||
|
|
||||||
|
# Connect to system-config-services and offer to start
|
||||||
|
try:
|
||||||
|
scs = dbus.Interface(bus.get_object(
|
||||||
|
"org.fedoraproject.Config.Services",
|
||||||
|
"/org/fedoraproject/Config/Services/systemd1"),
|
||||||
|
"org.freedesktop.systemd1.Manager")
|
||||||
|
scs.StartUnit(unitname, "replace")
|
||||||
|
time.sleep(2)
|
||||||
|
return True
|
||||||
|
except:
|
||||||
|
logging.exception("Failed to talk to system-config-services")
|
||||||
|
|
||||||
class vmmEngine(vmmGObject):
|
class vmmEngine(vmmGObject):
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
@ -324,16 +372,15 @@ class vmmEngine(vmmGObject):
|
|||||||
return
|
return
|
||||||
|
|
||||||
if did_install_libvirt:
|
if did_install_libvirt:
|
||||||
|
didstart = start_libvirtd()
|
||||||
warnmsg = _(
|
warnmsg = _(
|
||||||
"Libvirt was just installed, so the 'libvirtd' service will\n"
|
"Libvirt was just installed, so the 'libvirtd' service will\n"
|
||||||
"will need to be started. This can be done with one \n"
|
"will need to be started.\n"
|
||||||
"of the following:\n\n"
|
|
||||||
"- From GNOME menus: System->Administration->Services\n"
|
|
||||||
"- From the terminal: su -c 'service libvirtd restart'\n"
|
|
||||||
"- Restart your computer\n\n"
|
|
||||||
"virt-manager will connect to libvirt on the next application\n"
|
"virt-manager will connect to libvirt on the next application\n"
|
||||||
"start up.")
|
"start up.")
|
||||||
self.err.ok(_("Libvirt service must be started"), warnmsg)
|
|
||||||
|
if not didstart:
|
||||||
|
self.err.ok(_("Libvirt service must be started"), warnmsg)
|
||||||
|
|
||||||
self.connect_to_uri(tryuri, autoconnect=True,
|
self.connect_to_uri(tryuri, autoconnect=True,
|
||||||
do_start=not did_install_libvirt)
|
do_start=not did_install_libvirt)
|
||||||
|
Loading…
Reference in New Issue
Block a user