[PATCH console-proxy 1/6] Adapt to API change for dom.Devices.Graphics

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

 



Follow
> commit 4772b681e87a8d0dcee011b8e43813e851e4f934
> Author: Daniel P. Berrange <berrange@xxxxxxxxxx>
> Date:   Fri Nov 24 16:15:30 2017 +0000
>
>     Add remaining graphics configuration options

Signed-off-by: Philipp Hahn <hahn@xxxxxxxxxxxxx>
---
 cmd/virtconsoleresolveradm/cmd/enable.go |  6 ++----
 pkg/resolver/server.go                   | 26 ++++++++++++++++--------
 2 files changed, 20 insertions(+), 12 deletions(-)

diff --git a/cmd/virtconsoleresolveradm/cmd/enable.go b/cmd/virtconsoleresolveradm/cmd/enable.go
index 04ca80b..dd95e9e 100644
--- a/cmd/virtconsoleresolveradm/cmd/enable.go
+++ b/cmd/virtconsoleresolveradm/cmd/enable.go
@@ -164,15 +164,13 @@ func doEnable(cmd *cobra.Command, args []string) {
 	meta = &resolver.ConsoleServerProxyMetadata{}
 
 	for _, graphics := range domcfg.Devices.Graphics {
-		switch graphics.Type {
-		case "spice":
+		if graphics.Spice != nil {
 			meta.Consoles = append(meta.Consoles,
 				createConsole("spice", 0, conn, domname, domuuid))
-		case "vnc":
+		} else if graphics.VNC != nil {
 			meta.Consoles = append(meta.Consoles,
 				createConsole("vnc", 0, conn, domname, domuuid))
 		}
-
 	}
 
 	for idx, chardev := range domcfg.Devices.Serials {
diff --git a/pkg/resolver/server.go b/pkg/resolver/server.go
index 115d75d..eefdad7 100644
--- a/pkg/resolver/server.go
+++ b/pkg/resolver/server.go
@@ -86,13 +86,19 @@ type ConsoleServer struct {
 
 const tokenpath = "/consoleresolver/token/"
 
+func isListenAddress(listen string) bool {
+	return listen != "" && listen != "0.0.0.0" && listen != "::"
+}
+
 func getListener(dom libvirtxml.Domain, gtype string, insecure bool, consoleHost, defaultHost string) (string, error) {
 	if dom.Devices == nil {
 		return "", errors.New("No devices present")
 	}
 
 	for _, graphics := range dom.Devices.Graphics {
-		if graphics.Type != gtype {
+		if gtype == "vnc" && graphics.VNC != nil {
+		} else if gtype == "spice" && graphics.Spice != nil {
+		} else {
 			continue
 		}
 
@@ -100,21 +106,25 @@ func getListener(dom libvirtxml.Domain, gtype string, insecure bool, consoleHost
 		if consoleHost != "" {
 			host = consoleHost
 		} else {
-			if graphics.Listen != "" && graphics.Listen != "0.0.0.0" && graphics.Listen != "::" {
-				host = graphics.Listen
+			if graphics.VNC != nil && isListenAddress(graphics.VNC.Listen) {
+				host = graphics.VNC.Listen
+			} else if graphics.Spice != nil && isListenAddress(graphics.Spice.Listen) {
+				host = graphics.Spice.Listen
 			} else {
 				host = defaultHost
 			}
 		}
 
 		var port int
-		if graphics.Type == "spice" && !insecure {
-			port = graphics.TLSPort
-		} else {
-			port = graphics.Port
+		if graphics.Spice != nil && !insecure {
+			port = graphics.Spice.TLSPort
+		} else if graphics.Spice != nil {
+			port = graphics.Spice.Port
+		} else if graphics.VNC != nil {
+			port = graphics.VNC.Port
 		}
 		glog.V(1).Infof("Got port %d\n", port)
-		if graphics.Port == 0 || graphics.Port == -1 {
+		if port == 0 || port == -1 {
 			return "", errors.New("Missing port for graphics")
 		}
 
-- 
2.20.1


--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list





[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]

  Powered by Linux