[gnome-boxes] ovirt: Set host-subject when needed



commit 9ba2b56b178412036f157edae2c15e84eeba1155
Author: Christophe Fergeau <cfergeau redhat com>
Date:   Thu Jun 6 17:47:04 2013 +0200

    ovirt: Set host-subject when needed
    
    oVirt 3.2/libgovirt 0.1.0 can be used to know the host subject
    to use to validate the SSL certificate of a given VM. This
    host subject can be needed in some cases, for example when oVirt VMs
    migrated from one host to another.
    
    The BOXES_SPICE_HOST_SUBJECT environment variable hack is kept for now
    as this is still needed on older oVirt instances which don't provide the
    host subject in their REST API.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=702011

 src/ovirt-machine.vala |    6 +++++-
 src/spice-display.vala |   14 +++++++++-----
 2 files changed, 14 insertions(+), 6 deletions(-)
---
diff --git a/src/ovirt-machine.vala b/src/ovirt-machine.vala
index b60ddd5..804d620 100644
--- a/src/ovirt-machine.vala
+++ b/src/ovirt-machine.vala
@@ -81,7 +81,11 @@ private class Boxes.OvirtMachine: Boxes.Machine {
 
         switch (vm.display.type) {
         case Ovirt.VmDisplayType.SPICE:
-            var display = new SpiceDisplay (config, vm.display.address, (int) vm.display.port, (int) 
vm.display.secure_port);
+            var display = new SpiceDisplay (config,
+                                            vm.display.address,
+                                            (int) vm.display.port,
+                                            (int) vm.display.secure_port);
+                                            vm.display.host_subject);
             display.ca_cert = proxy.ca_cert;
             return display;
 
diff --git a/src/spice-display.vala b/src/spice-display.vala
index a386672..05294dd 100644
--- a/src/spice-display.vala
+++ b/src/spice-display.vala
@@ -92,7 +92,7 @@ private class Boxes.SpiceDisplay: Boxes.Display {
         main_cleanup ();
     }
 
-    public SpiceDisplay (BoxConfig config, string host, int port, int tls_port = 0)
+    public SpiceDisplay (BoxConfig config, string host, int port, int tls_port = 0, string? host_subject = 
null)
         requires (port != 0 || tls_port != 0) {
         this.config = config;
 
@@ -103,10 +103,14 @@ private class Boxes.SpiceDisplay: Boxes.Display {
         if (tls_port != 0)
             session.tls_port = tls_port.to_string ();
 
-        // FIXME: remove this once libgovirt has proper support for
-        // getting the SPICE host subject, it's useful for testing purpose
-        // in the mean time
-        session.cert_subject = GLib.Environment.get_variable ("BOXES_SPICE_HOST_SUBJECT");
+        // FIXME: together with newer oVirt, libgovirt should be able
+        // to automatically provide the host subject when needed. Keep
+        // this environment variable a while longer to be able to cope
+        // with older oVirt versions.
+        if (host_subject != null)
+            session.cert_subject = host_subject;
+        else
+            session.cert_subject = GLib.Environment.get_variable ("BOXES_SPICE_HOST_SUBJECT");
     }
 
     public SpiceDisplay.with_uri (BoxConfig config, string uri) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]