ovirt: Set host subject if needed

For some VMs, setting host subject on SpiceSession is needed to
be able to connect to it using SPICE/SSL. Until recently, this
was not exposed in oVirt REST API/libgovirt. Since
oVirt 3.2/libgovirt 0.1.0, the host subject is available, this
patch makes use of it.
This should fix connection to oVirt VMs that were migrated to a
different host than the one they were started on.
This commit is contained in:
Christophe Fergeau 2013-06-11 15:54:37 +02:00
parent 16df26cf5f
commit 7c0967fc8c
2 changed files with 5 additions and 1 deletions

View File

@ -178,7 +178,7 @@ AC_ARG_WITH([ovirt],
AS_HELP_STRING([--without-ovirt], [Ignore presence of librest and disable oVirt support]))
AS_IF([test "x$with_ovirt" != "xno"],
[PKG_CHECK_MODULES([OVIRT], [govirt-1.0],
[PKG_CHECK_MODULES([OVIRT], [govirt-1.0 >= 0.1.0],
[have_ovirt=yes], [have_ovirt=no])],
[have_ovirt=no])

View File

@ -730,6 +730,7 @@ create_ovirt_session(VirtViewerApp *app, const char *uri)
gchar *gtlsport = NULL;
gchar *ghost = NULL;
gchar *ticket = NULL;
gchar *host_subject = NULL;
g_return_val_if_fail(VIRT_VIEWER_IS_APP(app), FALSE);
@ -777,6 +778,7 @@ create_ovirt_session(VirtViewerApp *app, const char *uri)
"port", &port,
"secure-port", &secure_port,
"ticket", &ticket,
"host-subject", &host_subject,
NULL);
gport = g_strdup_printf("%d", port);
gtlsport = g_strdup_printf("%d", secure_port);
@ -806,6 +808,7 @@ create_ovirt_session(VirtViewerApp *app, const char *uri)
g_object_set(G_OBJECT(session),
"ca", ca_cert,
"password", ticket,
"cert-subject", host_subject,
NULL);
g_byte_array_unref(ca_cert);
}
@ -820,6 +823,7 @@ error:
g_free(gport);
g_free(gtlsport);
g_free(ghost);
g_free(host_subject);
if (error != NULL)
g_error_free(error);