mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-01-13 13:17:57 +03:00
configure: Allow configuring preferred hv/libvirt packages
This commit is contained in:
parent
f441c9d2d0
commit
d0ad31c168
30
configure.ac
30
configure.ac
@ -48,6 +48,22 @@ AC_ARG_WITH([qemu-user],
|
||||
[DEFAULT_QEMU_USER=$withval],
|
||||
[DEFAULT_QEMU_USER="root"])
|
||||
|
||||
dnl Distro libvirt package name
|
||||
AC_ARG_WITH([libvirt-package-names],
|
||||
AC_HELP_STRING(
|
||||
[--with-libvirt-package-names],
|
||||
[name of libvirt distro packages virt-manager will check for on first run @<:@default=none@:>@]),
|
||||
[LIBVIRT_PACKAGES=$withval],
|
||||
[LIBVIRT_PACKAGES=""])
|
||||
|
||||
dnl Recommended HV packages
|
||||
AC_ARG_WITH([kvm-packages],
|
||||
AC_HELP_STRING(
|
||||
[--with-kvm-packages],
|
||||
[recommended kvm packages virt-manager will check for on first run @<:@default=none@:>@]),
|
||||
[KVM_PACKAGES=$withval],
|
||||
[KVM_PACKAGES=""])
|
||||
|
||||
dnl Don't list options that rhel doesn't support
|
||||
AC_ARG_ENABLE([unsupported-rhel-options],
|
||||
AC_HELP_STRING(
|
||||
@ -60,7 +76,7 @@ dnl Allow passing in a prefered distro list
|
||||
AC_ARG_WITH([preferred-distros],
|
||||
AC_HELP_STRING(
|
||||
[--with-preferred-distros],
|
||||
[Distros to list first in New VM wizard @<:@default=root@:>@]),
|
||||
[Distros to list first in New VM wizard @<:@default=none@:>@]),
|
||||
[PREFERRED_DISTROS=$withval],
|
||||
[PREFERRED_DISTROS=""])
|
||||
|
||||
@ -71,6 +87,8 @@ AC_SUBST([VIRTINST_VERSION])
|
||||
AC_SUBST([DEFAULT_QEMU_USER])
|
||||
AC_SUBST([ENABLE_UNSUPPORTED_RHEL_OPTS])
|
||||
AC_SUBST([PREFERRED_DISTROS])
|
||||
AC_SUBST([LIBVIRT_PACKAGES])
|
||||
AC_SUBST([KVM_PACKAGES])
|
||||
AM_CONDITIONAL([INSTALL_TUI], [test "x$with_tui" = "xyes"])
|
||||
|
||||
|
||||
@ -114,6 +132,16 @@ AC_MSG_NOTICE([Preferred distros: none])
|
||||
else
|
||||
AC_MSG_NOTICE([Preferred distros: $PREFERRED_DISTROS])
|
||||
fi
|
||||
if test "x$LIBVIRT_PACKAGES" = "x" ; then
|
||||
AC_MSG_NOTICE([Libvirt packages: none])
|
||||
else
|
||||
AC_MSG_NOTICE([Libvirt Packages: $LIBVIRT_PACKAGES])
|
||||
fi
|
||||
if test "x$KVM_PACKAGES" = "x" ; then
|
||||
AC_MSG_NOTICE([KVM packages: none])
|
||||
else
|
||||
AC_MSG_NOTICE([KVM packages: $KVM_PACKAGES])
|
||||
fi
|
||||
|
||||
AC_MSG_NOTICE([])
|
||||
AC_MSG_NOTICE([])
|
||||
|
@ -63,6 +63,8 @@ endif
|
||||
-e "s,::DEFAULT_QEMU_USER::,$(DEFAULT_QEMU_USER)," \
|
||||
-e "s,::ENABLE_UNSUPPORTED_RHEL_OPTS::,$(ENABLE_UNSUPPORTED_RHEL_OPTS)," \
|
||||
-e "s|::PREFERRED_DISTROS::|$(PREFERRED_DISTROS)|" \
|
||||
-e "s|::HV_PACKAGES::|$(KVM_PACKAGES)|" \
|
||||
-e "s|::LIBVIRT_PACKAGES::|$(LIBVIRT_PACKAGES)|" \
|
||||
< $< > $@
|
||||
|
||||
$(PACKAGE): $(srcdir)/$(PACKAGE).in
|
||||
|
@ -40,6 +40,9 @@ try:
|
||||
except:
|
||||
pass
|
||||
|
||||
def split_list(commastr):
|
||||
return [d for d in commastr.split(",") if d]
|
||||
|
||||
# These are substituted into code based on --prefix given to configure
|
||||
appname = "::PACKAGE::"
|
||||
appversion = "::VERSION::"
|
||||
@ -58,7 +61,10 @@ data_dir = "::DATADIR::"
|
||||
|
||||
default_qemu_user = "::DEFAULT_QEMU_USER::"
|
||||
rhel_enable_unsupported_opts = bool(int("::ENABLE_UNSUPPORTED_RHEL_OPTS::"))
|
||||
preferred_distros = [d for d in "::PREFERRED_DISTROS::".split(",") if d]
|
||||
preferred_distros = split_list("::PREFERRED_DISTROS::")
|
||||
|
||||
hv_packages = split_list("::HV_PACKAGES::")
|
||||
libvirt_packages = split_list("::LIBVIRT_PACKAGES::")
|
||||
|
||||
logging_setup = False
|
||||
|
||||
@ -387,6 +393,9 @@ def main():
|
||||
config.enable_unsupported_rhel_opts = rhel_enable_unsupported_opts
|
||||
config.preferred_distros = preferred_distros
|
||||
|
||||
config.hv_packages = hv_packages
|
||||
config.libvirt_packages = libvirt_packages
|
||||
|
||||
# Now we've got basic environment up & running we can fork
|
||||
if not options.nofork and not options.debug:
|
||||
drop_tty()
|
||||
|
@ -112,6 +112,8 @@ class vmmConfig(object):
|
||||
# Use this key to disable certain features not supported on RHEL
|
||||
self.enable_unsupported_rhel_opts = True
|
||||
self.preferred_distros = []
|
||||
self.hv_packages = []
|
||||
self.libvirt_packages = []
|
||||
|
||||
self.status_icons = {
|
||||
libvirt.VIR_DOMAIN_BLOCKED: gtk.gdk.pixbuf_new_from_file_at_size(self.get_icon_dir() + "/state_running.png", 18, 18),
|
||||
|
@ -47,22 +47,6 @@ from virtManager.error import vmmErrorDialog
|
||||
from virtManager.systray import vmmSystray
|
||||
import virtManager.util as util
|
||||
|
||||
|
||||
# List of packages to look for via packagekit at first startup.
|
||||
# If this list is empty, no attempt to contact packagekit is made
|
||||
LIBVIRT_DAEMON = ""
|
||||
HV_PACKAGE = ""
|
||||
OTHER_PACKAGES = []
|
||||
PACKAGEKIT_PACKAGES = []
|
||||
|
||||
if LIBVIRT_DAEMON:
|
||||
PACKAGEKIT_PACKAGES.append(LIBVIRT_DAEMON)
|
||||
if HV_PACKAGE:
|
||||
PACKAGEKIT_PACKAGES.append(HV_PACKAGE)
|
||||
if OTHER_PACKAGES:
|
||||
PACKAGEKIT_PACKAGES.extend(OTHER_PACKAGES)
|
||||
|
||||
|
||||
def default_uri():
|
||||
tryuri = None
|
||||
if os.path.exists("/var/lib/xend") and os.path.exists("/proc/xen"):
|
||||
@ -80,12 +64,12 @@ def default_uri():
|
||||
# PackageKit lookup helpers #
|
||||
#############################
|
||||
|
||||
def check_packagekit(errbox):
|
||||
def check_packagekit(errbox, packages, libvirt_packages):
|
||||
"""
|
||||
Returns None when we determine nothing useful.
|
||||
Returns (success, did we just install libvirt) otherwise.
|
||||
"""
|
||||
if not PACKAGEKIT_PACKAGES:
|
||||
if not packages:
|
||||
logging.debug("No PackageKit packages to search for.")
|
||||
return
|
||||
|
||||
@ -103,7 +87,7 @@ def check_packagekit(errbox):
|
||||
|
||||
found = []
|
||||
progWin = vmmAsyncJob(_do_async_search,
|
||||
[session, pk_control],
|
||||
[session, pk_control, packages],
|
||||
_("Searching for available hypervisors..."),
|
||||
_("Searching for available hypervisors..."),
|
||||
run_main=False)
|
||||
@ -113,7 +97,7 @@ def check_packagekit(errbox):
|
||||
|
||||
found = progWin.get_data()
|
||||
|
||||
not_found = filter(lambda x: x not in found, PACKAGEKIT_PACKAGES)
|
||||
not_found = filter(lambda x: x not in found, packages)
|
||||
logging.debug("Missing packages: %s" % not_found)
|
||||
|
||||
do_install = not_found
|
||||
@ -145,13 +129,19 @@ def check_packagekit(errbox):
|
||||
"".join(traceback.format_exc()))
|
||||
return
|
||||
|
||||
return (True, LIBVIRT_DAEMON in do_install)
|
||||
need_libvirt = False
|
||||
for p in libvirt_packages:
|
||||
if p in do_install:
|
||||
need_libvirt = True
|
||||
break
|
||||
|
||||
def _do_async_search(asyncjob, session, pk_control):
|
||||
return (True, need_libvirt)
|
||||
|
||||
def _do_async_search(asyncjob, session, pk_control, packages):
|
||||
found = []
|
||||
try:
|
||||
for name in PACKAGEKIT_PACKAGES:
|
||||
ret_found = packagekit_search(session, pk_control, name)
|
||||
for name in packages:
|
||||
ret_found = packagekit_search(session, pk_control, name, packages)
|
||||
found += ret_found
|
||||
|
||||
except Exception, e:
|
||||
@ -171,7 +161,7 @@ def packagekit_install(package_list):
|
||||
logging.debug("Installing packages: %s" % package_list)
|
||||
pk_control.InstallPackageNames(0, package_list, "hide-confirm-search")
|
||||
|
||||
def packagekit_search(session, pk_control, package_name):
|
||||
def packagekit_search(session, pk_control, package_name, packages):
|
||||
tid = pk_control.GetTid()
|
||||
pk_trans = dbus.Interface(
|
||||
session.get_object("org.freedesktop.PackageKit", tid),
|
||||
@ -183,7 +173,7 @@ def packagekit_search(session, pk_control, package_name):
|
||||
ignore = summary
|
||||
|
||||
found_name = str(package_id.split(";")[0])
|
||||
if found_name in PACKAGEKIT_PACKAGES:
|
||||
if found_name in packages:
|
||||
found.append(found_name)
|
||||
|
||||
def error(code, details):
|
||||
@ -304,7 +294,10 @@ class vmmEngine(vmmGObject):
|
||||
ret = None
|
||||
did_install_libvirt = False
|
||||
try:
|
||||
ret = check_packagekit(self.err)
|
||||
libvirt_packages = self.config.libvirt_packages
|
||||
packages = self.config.hv_packages + libvirt_packages
|
||||
|
||||
ret = check_packagekit(self.err, packages, libvirt_packages)
|
||||
except:
|
||||
logging.exception("Error talking to PackageKit")
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user