[virt-tools-list] [virt-manager PATCH] virt-install: Make default graphics configurable

Martin Kletzander mkletzan at redhat.com
Mon Jul 15 08:00:20 UTC 2013


The '--default-graphics' option of 'setup.py configure' only affects
virt-manager, but not virt-install.  This should be unified, so this
patch checks whether default_graphics taken from the cli is supported
and uses that option.

Signed-off-by: Martin Kletzander <mkletzan at redhat.com>
---
 man/virt-install.pod |  6 +++---
 virtcli/cliconfig.py |  2 +-
 virtinst/cli.py      | 13 ++++++++++---
 3 files changed, 14 insertions(+), 7 deletions(-)

diff --git a/man/virt-install.pod b/man/virt-install.pod
index 4067ec2..153345f 100644
--- a/man/virt-install.pod
+++ b/man/virt-install.pod
@@ -639,9 +639,9 @@ This parameter is deprecated in favour of C<--network NETWORK,mac=12:34...>

 =head2 Graphics Configuration

-If no graphics option is specified, C<virt-install> will default to
-'--graphics vnc' if the DISPLAY environment variable is set, otherwise
-'--graphics none' is used.
+If no graphics option is specified, C<virt-install> will try to select
+the appropriate graphics if the DISPLAY environment variable is set,
+otherwise '--graphics none' is used.

 =over 2

diff --git a/virtcli/cliconfig.py b/virtcli/cliconfig.py
index 3edb964..ce43b3c 100644
--- a/virtcli/cliconfig.py
+++ b/virtcli/cliconfig.py
@@ -84,4 +84,4 @@ preferred_distros = _split_list(_get_param("preferred_distros", ""))
 hv_packages = _split_list(_get_param("hv_packages", ""))
 askpass_package = _split_list(_get_param("askpass_packages", ""))
 libvirt_packages = _split_list(_get_param("libvirt_packages", ""))
-default_graphics = _get_param("default_graphics", "vnc")
+default_graphics = _get_param("default_graphics", "spice")
diff --git a/virtinst/cli.py b/virtinst/cli.py
index a2a7c86..d6e5647 100644
--- a/virtinst/cli.py
+++ b/virtinst/cli.py
@@ -788,7 +788,8 @@ def digest_graphics(guest, options, default_override=None):
     if optnum == 0:
         # If no graphics specified, choose a default
         if default_override is True:
-            vnc = True
+            if cliconfig.default_graphics in ["spice", "vnc", "sdl"]:
+                return [cliconfig.default_graphics]
         elif default_override is False:
             nographics = True
         else:
@@ -796,8 +797,14 @@ def digest_graphics(guest, options, default_override=None):
                 logging.debug("Container guest, defaulting to nographics")
                 nographics = True
             elif "DISPLAY" in os.environ.keys():
-                logging.debug("DISPLAY is set: graphics defaulting to VNC.")
-                vnc = True
+                logging.debug("DISPLAY is set: looking for pre-configured graphics")
+                if cliconfig.default_graphics in ["spice", "vnc", "sdl"]:
+                    logging.debug("Defaulting graphics to pre-configured %s" %
+                                  cliconfig.default_graphics.upper())
+                    return [cliconfig.default_graphics]
+                logging.debug("No valid pre-configured graphics "
+                              "found, defaulting to VNC")
+                return ["vnc"]
             else:
                 logging.debug("DISPLAY is not set: defaulting to nographics.")
                 nographics = True
-- 
1.8.3.2




More information about the virt-tools-list mailing list