[gnome-boxes] Use libvirt spice autoport



commit 08e4d72f272341723a9f396fbbff01f846885b33
Author: Marc-Andrà Lureau <marcandre lureau gmail com>
Date:   Tue Nov 22 23:06:30 2011 +0100

    Use libvirt spice autoport
    
    https://bugzilla.gnome.org/show_bug.cgi?id=664594

 src/vm-creator.vala |   22 +---------------------
 1 files changed, 1 insertions(+), 21 deletions(-)
---
diff --git a/src/vm-creator.vala b/src/vm-creator.vala
index fc6f946..30c54d8 100644
--- a/src/vm-creator.vala
+++ b/src/vm-creator.vala
@@ -5,7 +5,6 @@ using GVir;
 
 private class Boxes.VMCreator {
     private Connection connection;
-    private uint16 spice_port;
 
     private static Regex direct_boot_regex;
     private static Regex cdrom_boot_regex;
@@ -17,24 +16,6 @@ private class Boxes.VMCreator {
 
     public VMCreator (App app, string uri) throws GLib.Error {
         connection = new Connection (uri);
-        spice_port = 5800;
-
-        // Ensure unique spice port
-        foreach (var item in app.collection.items.data) {
-            if (item is LibvirtMachine) {
-                var machine = item as LibvirtMachine;
-                var xmldoc = machine.domain.get_config (0).to_xml();
-
-                var type = extract_xpath (xmldoc, "string(/domain/devices/graphics/@type)", true);
-                var port_str = extract_xpath (xmldoc, "string(/domain/devices/graphics[ type='" + type + "']/@port)");
-                var port = int.parse (port_str);
-
-                if (port > 0)
-                    spice_port = uint16.max (spice_port, (uint16) port);
-            }
-        }
-
-        spice_port++;
     }
 
     public async GVir.Domain create_and_launch_vm (InstallerMedia install_media,
@@ -55,7 +36,6 @@ private class Boxes.VMCreator {
         var target_path = yield create_target_volume (name, resources.storage);
 
         var xml = get_virt_xml (install_media, name, target_path, resources);
-        spice_port++; // So next VM doesn't get the same port
         var config = new GVirConfig.Domain.from_xml (xml);
 
         var domain = connection.create_domain (config);
@@ -119,7 +99,7 @@ private class Boxes.VMCreator {
                "      <mac address='00:11:22:33:44:55'/>\n" +
                "    </interface>\n" +
                "    <input type='tablet' bus='usb'/>\n" +
-               "    <graphics type='spice' port='" + spice_port.to_string () + "' />\n" +
+               "    <graphics type='spice' autoport='yes' />\n" +
                "    <console type='pty'/>\n" +
                "    <video>\n" +
                // FIXME: Should be 'qxl', work-around for a spice bug



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