[Ovirt-devel] [PATCH] Add vnc port to database.

Ian Main imain at redhat.com
Fri Jun 13 05:13:43 UTC 2008


This patch parses the xml from the newly created vm to get the vnc port
and adds it to the database.  Small but it took a while to figure out :).

Signed-off-by: Ian Main <imain at redhat.com>
---
 wui/src/task-omatic/task_vm.rb |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/wui/src/task-omatic/task_vm.rb b/wui/src/task-omatic/task_vm.rb
index 3c81453..e3f1b51 100644
--- a/wui/src/task-omatic/task_vm.rb
+++ b/wui/src/task-omatic/task_vm.rb
@@ -319,6 +319,13 @@ def start_vm(task)
     conn = Libvirt::open("qemu+tcp://" + host.hostname + "/system")
     dom = conn.define_domain_xml(xml.to_s)
     dom.create
+
+    doc = REXML::Document.new(dom.xml_desc)
+    attrib = REXML::XPath.match(doc, "//graphics/@port")
+    if not attrib.empty?:
+      vm.vnc_port = attrib.to_s.to_i
+    end
+
     conn.close
   rescue => ex
     setVmState(vm, vm_orig_state)
-- 
1.5.5.1




More information about the ovirt-devel mailing list