[virt-tools-list] [PATCH 5 of 5] cli: add --spice* arguments

Marc-André Lureau marcandre.lureau at redhat.com
Mon Nov 15 18:16:53 UTC 2010


# HG changeset patch
# User Marc-André Lureau <marcandre.lureau at redhat.com>
# Date 1289839732 -3600
# Node ID 6f860a0d1e4dd7ded7cc2de2c5f82886ab230089
# Parent  815ba529139a23056ad68a679bf829de5ce9230a
cli: add --spice* arguments

diff -r 815ba529139a -r 6f860a0d1e4d tests/clitest.py
--- a/tests/clitest.py	Mon Nov 15 19:15:15 2010 +0100
+++ b/tests/clitest.py	Mon Nov 15 17:48:52 2010 +0100
@@ -286,8 +286,12 @@
         "--sdl",
         # VNC w/ lots of options
         "--vnc --keymap ja --vncport 5950 --vnclisten 1.2.3.4",
+        # SPICE w/ lots of options
+        "--spice --keymap ja --spiceport 5950 --spicetlsport 5950 --spicelisten 1.2.3.4",
         # --video option
         "--vnc --video vga",
+        # --video option
+        "--spice --video qxl",
         # --keymap local,
         "--vnc --keymap local",
         # --keymap none
@@ -299,6 +303,8 @@
         "--vnc --keymap ZZZ",
         # Invalid port
         "--vnc --vncport -50",
+        # Invalid port
+        "--spice --spicetlsport -50",
         # Invalid --video
         "--vnc --video foobar",
       ],
diff -r 815ba529139a -r 6f860a0d1e4d virtinst/cli.py
--- a/virtinst/cli.py	Mon Nov 15 19:15:15 2010 +0100
+++ b/virtinst/cli.py	Mon Nov 15 17:48:52 2010 +0100
@@ -421,9 +421,17 @@
                     help=_("Address to listen on for VNC connections."))
     vncg.add_option("-k", "--keymap", type="string", dest="keymap",
                     action="callback", callback=check_before_store,
-                    help=_("set up keymap for the VNC console"))
+                    help=_("set up keymap for the graphical console"))
     vncg.add_option("", "--sdl", action="store_true", dest="sdl",
                     help=_("Use SDL for graphics support"))
+    vncg.add_option("", "--spice", action="store_true", dest="spice",
+                    help=_("Use SPICE for graphics support"))
+    vncg.add_option("", "--spiceport", type="int", dest="spiceport",
+                    help=_("Port to use for SPICE"))
+    vncg.add_option("", "--spicetlsport", type="int", dest="spicetlsport",
+                    help=_("TLS port to use for SPICE"))
+    vncg.add_option("", "--spicelisten", type="string", dest="spicelisten",
+                    help=_("Address to listen on for SPICE connections."))
     vncg.add_option("", "--nographics", action="store_true",
                     help=_("Don't set up a graphical console for the guest."))
     return vncg
@@ -728,12 +736,11 @@
     return net_init_dicts
 
 def get_graphics(vnc, vncport, vnclisten, nographics, sdl, keymap,
-                 video_models, guest):
+                 video_models, spice, spiceport, spicetlsport,
+                 spicelisten, guest):
     video_models = video_models or []
 
-    if ((vnc and nographics) or
-        (vnc and sdl) or
-        (sdl and nographics)):
+    if (sum(map(int, [vnc, nographics, sdl, spice]))) > 1:
         raise ValueError, _("Can't specify more than one of VNC, SDL, "
                             "or --nographics")
 
@@ -770,6 +777,15 @@
         if vnclisten:
             guest.graphics_dev.listen = vnclisten
 
+    if spice is not None:
+        guest.graphics_dev = VirtualGraphics(type=VirtualGraphics.TYPE_SPICE)
+        if spiceport:
+            guest.graphics_dev.port = spiceport
+        if spicetlsport:
+            guest.graphics_dev.tlsPort = spicetlsport
+        if spicelisten:
+            guest.graphics_dev.listen = spicelisten
+
     if keymap:
         use_keymap = None
 




More information about the virt-tools-list mailing list