Blob Blame History Raw
From 0242900389573107fb32c9f5fda579d38dc7e15a Mon Sep 17 00:00:00 2001
From: Martin Kletzander <mkletzan@redhat.com>
Date: Wed, 22 Jan 2014 14:48:35 +0100
Subject: [PATCH] Rename hide_unsupported_rhel_options to stable_defaults and
 clean-up its usage

https://bugzilla.redhat.com/show_bug.cgi?id=908616

There were multiple problems with the setting and usage of
hide_unsupported_rhel_options.  Due to the fact that the option has
several diferent namings throughout the code, this patch is renaming
it to stable_defaults, which basically says what the option does and
makes it possible to use it without need for more than one negation
(where the old code had up to 4 of them in some places), which also
helps understanding it.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
(cherry picked from commit dc0b9bbaafa98498f5621a2c318a43fdfe1fa7ff)

Downstream diverged so much it's pointless waste of time to explain
all these conflicts:
	setup.py
	tests/__init__.py
	tests/xmlconfig.py
	virt-manager.spec.in
	virtManager/addhardware.py
	virtManager/choosecd.py
	virtManager/config.py
	virtManager/connection.py
	virtManager/create.py
	virtManager/createvol.py
	virtManager/fsdetails.py
	virtManager/storagebrowse.py
	virtManager/uihelpers.py
	virtinst/__init__.py

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
---
 setup.py                     |  9 ++++-----
 virt-manager                 |  4 ++--
 virt-manager.spec.in         | 10 +++++-----
 virtManager/addhardware.py   | 14 +++++++-------
 virtManager/choosecd.py      |  5 ++---
 virtManager/config.py        |  4 ++--
 virtManager/connection.py    | 27 +++++++++++++--------------
 virtManager/create.py        | 20 ++++++++++----------
 virtManager/createvol.py     |  8 ++++----
 virtManager/details.py       |  4 ++--
 virtManager/domain.py        |  6 +++---
 virtManager/storagebrowse.py |  7 ++++---
 virtManager/uihelpers.py     | 12 ++++++------
 virtcli/cliconfig.py         |  5 ++---
 virtinst/VirtualDisk.py      |  4 ++--
 virtinst/__init__.py         |  2 +-
 16 files changed, 69 insertions(+), 72 deletions(-)

diff --git a/setup.py b/setup.py
index 6b5ceb1..505e533 100755
--- a/setup.py
+++ b/setup.py
@@ -312,10 +312,10 @@ class configure(Command):
          "(default=none)"),
         ("askpass-package-names=", None,
          "name of your distro's askpass package(s) (default=none)"),
-        ("hide-unsupported-rhel-options", None,
-         "Hide config bits that are not supported on RHEL (default=no)"),
         ("preferred-distros=", None,
          "Distros to list first in the New VM wizard (default=none)"),
+        ("stable-defaults", None,
+         "Hide config bits that are not considered stable (default=no)"),
         ("default-graphics=", None,
          "Default graphics type (spice or vnc) (default=spice)"),
 
@@ -330,7 +330,7 @@ class configure(Command):
         self.libvirt_package_names = ""
         self.kvm_package_names = ""
         self.askpass_package_names = ""
-        self.hide_unsupported_rhel_options = 0
+        self.stable_defaults = 0
         self.preferred_distros = ""
         self.default_graphics = "spice"
         self.prefix = sysprefix
@@ -347,8 +347,7 @@ class configure(Command):
         template += "hv_packages = %s\n" % self.kvm_package_names
         template += "askpass_packages = %s\n" % self.askpass_package_names
         template += "preferred_distros = %s\n" % self.preferred_distros
-        template += ("hide_unsupported_rhel_options = %s\n" %
-                     self.hide_unsupported_rhel_options)
+        template += "stable_defaults = %s\n" % self.stable_defaults
         template += "default_graphics = %s\n" % self.default_graphics
 
         file(cliconfig.cfgpath, "w").write(template)
diff --git a/virt-manager b/virt-manager
index 4c26524..a1ba06c 100755
--- a/virt-manager
+++ b/virt-manager
@@ -1,7 +1,7 @@
 #!/usr/bin/python
 
 #
-# Copyright (C) 2006 Red Hat, Inc.
+# Copyright (C) 2006, 2014 Red Hat, Inc.
 # Copyright (C) 2006 Daniel P. Berrange <berrange@redhat.com>
 #
 # This program is free software; you can redistribute it and/or modify
@@ -267,7 +267,7 @@ def main():
                                     options.testfirstrun)
     virtManager.util.running_config = config
     config.default_qemu_user = cliconfig.default_qemu_user
-    config.rhel6_defaults = not cliconfig.rhel_enable_unsupported_opts
+    config.stable_defaults = cliconfig.stable_defaults
     config.preferred_distros = cliconfig.preferred_distros
 
     config.hv_packages = cliconfig.hv_packages
diff --git a/virt-manager.spec.in b/virt-manager.spec.in
index 22b6a15..81b75ac 100644
--- a/virt-manager.spec.in
+++ b/virt-manager.spec.in
@@ -2,7 +2,7 @@
 
 
 %define with_guestfs               0
-%define disable_unsupported_rhel   0
+%define stable_defaults            0
 %define askpass_package            "openssh-askpass"
 %define qemu_user                  "qemu"
 %define libvirt_packages           "libvirt-daemon-kvm,libvirt-daemon-config-network"
@@ -13,7 +13,7 @@
 %if 0%{?rhel}
 %define preferred_distros          "rhel,fedora"
 %define kvm_packages               "qemu-kvm"
-%define disable_unsupported_rhel   1
+%define stable_defaults            1
 %endif
 
 
@@ -125,8 +125,8 @@ machine).
 %define _askpass_package --askpass-package-names=%{askpass_package}
 %endif
 
-%if %{disable_unsupported_rhel}
-%define _disable_unsupported_rhel --hide-unsupported-rhel-options
+%if %{stable_defaults}
+%define _stable_defaults --stable-defaults
 %endif
 
 %if %{default_graphics}
@@ -140,7 +140,7 @@ python setup.py configure \
     %{?_libvirt_packages} \
     %{?_askpass_package} \
     %{?_preferred_distros} \
-    %{?_disable_unsupported_rhel} \
+    %{?_stable_defaults} \
     %{?_default_graphics}
 
 
diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py
index f66e493..38c2bf6 100644
--- a/virtManager/addhardware.py
+++ b/virtManager/addhardware.py
@@ -1,5 +1,5 @@
 #
-# Copyright (C) 2006-2007, 2013 Red Hat, Inc.
+# Copyright (C) 2006-2007, 2013, 2014 Red Hat, Inc.
 # Copyright (C) 2006 Hugh O. Brock <hbrock@redhat.com>
 #
 # This program is free software; you can redistribute it and/or modify
@@ -547,7 +547,7 @@ class vmmAddHardware(vmmGObjectUI):
             add_dev("fdc", virtinst.VirtualDisk.DEVICE_FLOPPY,
                     _("Floppy disk"))
 
-            if self.vm.rhel6_defaults():
+            if self.vm.stable_defaults():
                 add_dev("scsi", virtinst.VirtualDisk.DEVICE_DISK,
                         _("SCSI disk"))
                 add_dev("usb", virtinst.VirtualDisk.DEVICE_DISK,
@@ -563,6 +563,7 @@ class vmmAddHardware(vmmGObjectUI):
                     _("Virtio SCSI disk"))
             add_dev("virtio-scsi", virtinst.VirtualDisk.DEVICE_LUN,
                     _("Virtio SCSI lun"))
+
         if self.conn.is_xen() or self.conn.is_test_conn():
             add_dev("xen", virtinst.VirtualDisk.DEVICE_DISK,
                     _("Xen virtual disk"))
@@ -956,7 +957,7 @@ class vmmAddHardware(vmmGObjectUI):
         return util.get_list_selection(self.widget("hardware-list"))
 
     def update_char_device_type_model(self):
-        rhel6_blacklist = ["pipe", "udp"]
+        stable_blacklist = ["pipe", "udp"]
 
         # Char device type
         char_devtype = self.widget("char-device-type")
@@ -970,8 +971,8 @@ class vmmAddHardware(vmmGObjectUI):
         char_devtype.add_attribute(text, 'text', 1)
 
         for t in VirtualCharDevice.char_types_for_dev_type[dev_type]:
-            if (t in rhel6_blacklist and
-                not self.vm.rhel6_defaults()):
+            if (t in stable_blacklist and
+                self.vm.stable_defaults()):
                 continue
 
             desc = VirtualCharDevice.get_char_type_desc(t)
@@ -1811,8 +1812,7 @@ class vmmAddHardware(vmmGObjectUI):
         if self.storage_browser is None:
             self.storage_browser = vmmStorageBrowser(conn)
 
-        rhel6 = self.vm.rhel6_defaults()
-        self.storage_browser.rhel6_defaults = rhel6
+        self.storage_browser.stable_defaults = self.vm.stable_defaults()
 
         self.storage_browser.set_finish_cb(set_storage_cb)
         self.storage_browser.set_browse_reason(reason)
diff --git a/virtManager/choosecd.py b/virtManager/choosecd.py
index aa68252..a0cac24 100644
--- a/virtManager/choosecd.py
+++ b/virtManager/choosecd.py
@@ -1,5 +1,5 @@
 #
-# Copyright (C) 2006 Red Hat, Inc.
+# Copyright (C) 2006, 2014 Red Hat, Inc.
 # Copyright (C) 2006 Hugh O. Brock <hbrock@redhat.com>
 #
 # This program is free software; you can redistribute it and/or modify
@@ -161,8 +161,7 @@ class vmmChooseCD(vmmGObjectUI):
             self.storage_browser.connect("storage-browse-finish",
                                          self.set_storage_path)
 
-        rhel6 = self.vm.rhel6_defaults()
-        self.storage_browser.rhel6_defaults = rhel6
+        self.storage_browser.stable_defaults = self.vm.stable_defaults()
 
         if self.media_type == MEDIA_FLOPPY:
             self.storage_browser.set_browse_reason(
diff --git a/virtManager/config.py b/virtManager/config.py
index 7c63567..886096b 100644
--- a/virtManager/config.py
+++ b/virtManager/config.py
@@ -1,5 +1,5 @@
 #
-# Copyright (C) 2006, 2012 Red Hat, Inc.
+# Copyright (C) 2006, 2012, 2014 Red Hat, Inc.
 # Copyright (C) 2006 Daniel P. Berrange <berrange@redhat.com>
 #
 # This program is free software; you can redistribute it and/or modify
@@ -162,7 +162,7 @@ class vmmConfig(object):
         self.default_qemu_user = "root"
 
         # Use this key to disable certain features not supported on RHEL
-        self.rhel6_defaults = True
+        self.stable_defaults = True
         self.preferred_distros = []
         self.hv_packages = []
         self.libvirt_packages = []
diff --git a/virtManager/connection.py b/virtManager/connection.py
index 3b943ec..01e2df4 100644
--- a/virtManager/connection.py
+++ b/virtManager/connection.py
@@ -1,5 +1,5 @@
 #
-# Copyright (C) 2006 Red Hat, Inc.
+# Copyright (C) 2006, 2014 Red Hat, Inc.
 # Copyright (C) 2006 Daniel P. Berrange <berrange@redhat.com>
 #
 # This program is free software; you can redistribute it and/or modify
@@ -354,20 +354,19 @@ class vmmConnection(vmmGObject):
         return path == "/session"
 
     # Connection capabilities debug helpers
-    def rhel6_defaults(self, emulator):
+    def stable_defaults(self, emulator=None):
         if not self.is_qemu_system():
-            return True
-        if not str(emulator).startswith("/usr/libexec"):
-            return True
-        return self.config.rhel6_defaults
-
-    def rhel6_defaults_caps(self):
-        caps = self.get_capabilities()
-        for guest in caps.guests:
-            for dom in guest.domains:
-                if dom.emulator.startswith("/usr/libexec"):
-                    return self.config.rhel6_defaults
-        return True
+            return False
+        if emulator:
+            if not str(emulator).startswith("/usr/libexec"):
+                return False
+        else:
+            caps = self.get_capabilities()
+            for guest in caps.guests:
+                for dom in guest.domains:
+                    if dom.emulator.startswith("/usr/libexec"):
+                        return self.config.stable_defaults
+        return self.config.stable_defaults
 
     def is_kvm_supported(self):
         return self.get_capabilities().is_kvm_available()
diff --git a/virtManager/create.py b/virtManager/create.py
index fed9b35..90ef1eb 100644
--- a/virtManager/create.py
+++ b/virtManager/create.py
@@ -1,5 +1,5 @@
 #
-# Copyright (C) 2008 Red Hat, Inc.
+# Copyright (C) 2008, 2014 Red Hat, Inc.
 # Copyright (C) 2008 Cole Robinson <crobinso@redhat.com>
 #
 # This program is free software; you can redistribute it and/or modify
@@ -56,7 +56,7 @@ INSTALL_PAGE_IMPORT = 3
 INSTALL_PAGE_CONTAINER_APP = 4
 INSTALL_PAGE_CONTAINER_OS = 5
 
-RHEL6_OS_SUPPORT = [
+STABLE_OS_SUPPORT = [
     "rhel3", "rhel4", "rhel5.4", "rhel6",
     "win2k3", "winxp", "win2k8", "vista", "win7",
 ]
@@ -756,8 +756,8 @@ class vmmCreate(vmmGObjectUI):
         widget = self.widget("install-os-type")
         model = widget.get_model()
         model.clear()
-        filtervars = (not self._rhel6_defaults() and
-                      RHEL6_OS_SUPPORT or
+        filtervars = (self._stable_defaults() and
+                      STABLE_OS_SUPPORT or
                       None)
 
         types = virtinst.Guest.list_os_types()
@@ -790,8 +790,8 @@ class vmmCreate(vmmGObjectUI):
             self._add_os_row(model, None, _("Generic"), True)
             return
 
-        filtervars = (not self._rhel6_defaults() and
-                      RHEL6_OS_SUPPORT or
+        filtervars = (not self._stable_defaults() and
+                      STABLE_OS_SUPPORT or
                       None)
         preferred = self.config.preferred_distros
         variants = virtinst.Guest.list_os_variants(_type, preferred)
@@ -1419,7 +1419,7 @@ class vmmCreate(vmmGObjectUI):
 
         support_spice = virtinst.support.check_conn_support(guest.conn,
                             virtinst.support.SUPPORT_CONN_HV_GRAPHICS_SPICE)
-        if not self._rhel6_defaults():
+        if not self._stable_defaults():
             support_spice = True
 
         gtype = self.get_config_graphics_type()
@@ -2094,14 +2094,14 @@ class vmmCreate(vmmGObjectUI):
             logging.exception("Error detecting distro.")
             self.detectedDistro = (None, None)
 
-    def _rhel6_defaults(self):
+    def _stable_defaults(self):
         emu = None
         if self.guest:
             emu = self.guest.emulator
         elif self.capsdomain:
             emu = self.capsdomain.emulator
 
-        ret = self.conn.rhel6_defaults(emu)
+        ret = self.conn.stable_defaults(emu)
         return ret
 
     def _browse_file(self, callback, is_media=False, is_dir=False):
@@ -2115,7 +2115,7 @@ class vmmCreate(vmmGObjectUI):
         if self.storage_browser is None:
             self.storage_browser = vmmStorageBrowser(self.conn)
 
-        self.storage_browser.rhel6_defaults = self._rhel6_defaults()
+        self.storage_browser.stable_defaults = self._stable_defaults()
 
         self.storage_browser.set_vm_name(self.get_config_name())
         self.storage_browser.set_finish_cb(callback)
diff --git a/virtManager/createvol.py b/virtManager/createvol.py
index ec1a14d..346824b 100644
--- a/virtManager/createvol.py
+++ b/virtManager/createvol.py
@@ -1,5 +1,5 @@
 #
-# Copyright (C) 2008, 2013 Red Hat, Inc.
+# Copyright (C) 2008, 2013, 2014 Red Hat, Inc.
 # Copyright (C) 2008 Cole Robinson <crobinso@redhat.com>
 #
 # This program is free software; you can redistribute it and/or modify
@@ -170,7 +170,7 @@ class vmmCreateVolume(vmmGObjectUI):
         return None
 
     def populate_vol_format(self):
-        rhel6_file_whitelist = ["raw", "qcow2", "qed"]
+        stable_whitelist = ["raw", "qcow2", "qed"]
         model = self.widget("vol-format").get_model()
         model.clear()
 
@@ -179,9 +179,9 @@ class vmmCreateVolume(vmmGObjectUI):
             formats = getattr(self.vol_class, "create_formats")
 
         if (self.vol_class == Storage.FileVolume and
-            not self.conn.rhel6_defaults_caps()):
+            self.conn.stable_defaults()):
             newfmts = []
-            for f in rhel6_file_whitelist:
+            for f in stable_whitelist:
                 if f in formats:
                     newfmts.append(f)
             formats = newfmts
diff --git a/virtManager/details.py b/virtManager/details.py
index be3b6ec..d101d63 100644
--- a/virtManager/details.py
+++ b/virtManager/details.py
@@ -3483,12 +3483,12 @@ class vmmDetails(vmmGObjectUI):
             buses.append(["fdc", "Floppy"])
         elif devtype == virtinst.VirtualDisk.DEVICE_CDROM:
             buses.append(["ide", "IDE"])
-            if self.vm.rhel6_defaults():
+            if not self.vm.stable_defaults():
                 buses.append(["scsi", "SCSI"])
         else:
             if self.vm.is_hvm():
                 buses.append(["ide", "IDE"])
-                if self.vm.rhel6_defaults():
+                if not self.vm.stable_defaults():
                     buses.append(["scsi", "SCSI"])
                     buses.append(["usb", "USB"])
             if self.vm.get_hv_type() in ["kvm", "test"]:
diff --git a/virtManager/domain.py b/virtManager/domain.py
index a51e421..1d8cd73 100644
--- a/virtManager/domain.py
+++ b/virtManager/domain.py
@@ -1,5 +1,5 @@
 #
-# Copyright (C) 2006, 2013 Red Hat, Inc.
+# Copyright (C) 2006, 2013, 2014 Red Hat, Inc.
 # Copyright (C) 2006 Daniel P. Berrange <berrange@redhat.com>
 #
 # This program is free software; you can redistribute it and/or modify
@@ -314,8 +314,8 @@ class vmmDomain(vmmLibvirtObject):
     def get_install_abort(self):
         return bool(self._install_abort)
 
-    def rhel6_defaults(self):
-        return self.conn.rhel6_defaults(self.get_emulator())
+    def stable_defaults(self):
+        return self.conn.stable_defaults(self.get_emulator())
 
     def is_read_only(self):
         if self.conn.is_read_only():
diff --git a/virtManager/storagebrowse.py b/virtManager/storagebrowse.py
index 6f4d3c0..7439f65 100644
--- a/virtManager/storagebrowse.py
+++ b/virtManager/storagebrowse.py
@@ -1,5 +1,5 @@
 #
-# Copyright (C) 2009 Red Hat, Inc.
+# Copyright (C) 2009, 2014 Red Hat, Inc.
 # Copyright (C) 2009 Cole Robinson <crobinso@redhat.com>
 #
 # This program is free software; you can redistribute it and/or modify
@@ -56,9 +56,10 @@ class vmmStorageBrowser(vmmGObjectUI):
 
         # Arguments to pass to util.browse_local for local storage
         self.browse_reason = None
-        self.rhel6_defaults = True
         self.local_args = {}
 
+        self.stable_defaults = False
+
         self.builder.connect_signals({
             "on_vmm_storage_browse_delete_event" : self.close,
             "on_browse_cancel_clicked" : self.close,
@@ -350,7 +351,7 @@ class vmmStorageBrowser(vmmGObjectUI):
 
             if dironly and fmt != 'dir':
                 sensitive = False
-            elif not self.rhel6_defaults:
+            elif self.stable_defaults:
                 if fmt == "vmdk":
                     sensitive = False
 
diff --git a/virtManager/uihelpers.py b/virtManager/uihelpers.py
index 415c67d..ab193e1 100644
--- a/virtManager/uihelpers.py
+++ b/virtManager/uihelpers.py
@@ -1,5 +1,5 @@
 #
-# Copyright (C) 2009, 2013 Red Hat, Inc.
+# Copyright (C) 2009, 2013, 2014 Red Hat, Inc.
 # Copyright (C) 2009 Cole Robinson <crobinso@redhat.com>
 #
 # This program is free software; you can redistribute it and/or modify
@@ -166,7 +166,7 @@ def populate_video_combo(vm, video_dev, no_default=None):
     video_dev_model.clear()
     tmpdev = virtinst.VirtualVideoDevice(vm.conn.vmm)
     for m in tmpdev.model_types:
-        if not vm.rhel6_defaults():
+        if vm.stable_defaults():
             if m == "qxl" and not has_spice and not has_qxl:
                 # Only list QXL video option when VM has SPICE video
                 continue
@@ -187,14 +187,14 @@ def build_sound_combo(vm, combo, no_default=False):
     combo.add_attribute(text, 'text', 0)
     dev_model.set_sort_column_id(0, Gtk.SortType.ASCENDING)
 
-    disable_rhel = not vm.rhel6_defaults()
-    rhel_soundmodels = ["ich6", "ac97"]
+    stable_defaults = vm.stable_defaults()
+    stable_soundmodels = ["ich6", "ac97"]
 
     for m in virtinst.VirtualAudio.MODELS:
         if m == virtinst.VirtualAudio.MODEL_DEFAULT and no_default:
             continue
 
-        if (disable_rhel and m not in rhel_soundmodels):
+        if (stable_defaults and m not in stable_soundmodels):
             continue
 
         dev_model.append([m])
@@ -427,7 +427,7 @@ def update_storage_format_combo(vm, combo, create):
 
     formats = ["raw", "qcow2", "qed"]
     no_create_formats = []
-    if vm.rhel6_defaults():
+    if not vm.stable_defaults():
         formats.append("vmdk")
         no_create_formats.append("vdi")
 
diff --git a/virtcli/cliconfig.py b/virtcli/cliconfig.py
index ce43b3c..38cd9d3 100644
--- a/virtcli/cliconfig.py
+++ b/virtcli/cliconfig.py
@@ -1,5 +1,5 @@
 #
-# Copyright (C) 2013 Red Hat, Inc.
+# Copyright (C) 2013, 2014 Red Hat, Inc.
 #
 # This program is free software; you can redistribute it and/or modify
 # it under the terms of the GNU General Public License as published by
@@ -77,8 +77,7 @@ else:
     icon_dir = os.path.join(asset_dir, "icons")
 
 default_qemu_user = _get_param("default_qemu_user", "root")
-rhel_enable_unsupported_opts = not bool(int(
-    _get_param("hide_unsupported_rhel_options", "0")))
+stable_defaults = bool(int(_get_param("stable_defaults", "0")))
 
 preferred_distros = _split_list(_get_param("preferred_distros", ""))
 hv_packages = _split_list(_get_param("hv_packages", ""))
diff --git a/virtinst/VirtualDisk.py b/virtinst/VirtualDisk.py
index 77f3c20..708f34a 100644
--- a/virtinst/VirtualDisk.py
+++ b/virtinst/VirtualDisk.py
@@ -1,7 +1,7 @@
 #
 # Classes for building disk device xml
 #
-# Copyright 2006-2008, 2012-2013  Red Hat, Inc.
+# Copyright 2006-2008, 2012-2014  Red Hat, Inc.
 # Jeremy Katz <katzj@redhat.com>
 #
 # This program is free software; you can redistribute it and/or modify
@@ -1506,7 +1506,7 @@ class VirtualDisk(VirtualDevice):
         cache = self.driver_cache
         iomode = self.driver_io
 
-        if virtinst.enable_rhel6_defaults:
+        if virtinst.stable_defaults:
             # Enable cache=none for non-CDROM devs
             if (self.is_qemu() and
                 not cache and
diff --git a/virtinst/__init__.py b/virtinst/__init__.py
index cdbefe5..a3737dc 100644
--- a/virtinst/__init__.py
+++ b/virtinst/__init__.py
@@ -15,7 +15,7 @@
 # MA 02110-1301 USA.
 
 from virtcli import cliconfig, cliutils
-enable_rhel6_defaults = not cliconfig.rhel_enable_unsupported_opts
+stable_defaults = cliconfig.stable_defaults
 cliutils.setup_i18n()
 
 
-- 
1.8.4.2