[Libvir] Add port number to <graphics> tag

Daniel P. Berrange berrange at redhat.com
Mon Aug 7 15:20:04 UTC 2006


We recently added the '<graphics>' tag to the XML description for HVM
machines. Any apps using this info though would have to hardcode the
assumption that Xen's QEMU listens on Domain-ID + 5900. Hardcoding the
port numbers in the first place is already a really questionable decision,
so we should avoid that propagating out to application code.

Thus, the attached patch changes:

  <graphics type="vnc"/>

So that it now looks  like

  <graphics type="vnc" port="5905"/>

The hardcoded 'Domain-ID + 5900' craziness is now at least isolated in 
libvirt, so provided apps take the port number from the XML they will be
immune from changes in port numbering scheme.

Dan.
-- 
|=- Red Hat, Engineering, Emerging Technologies, Boston.  +1 978 392 2496 -=|
|=-           Perl modules: http://search.cpan.org/~danberr/              -=|
|=-               Projects: http://freshmeat.net/~danielpb/               -=|
|=-  GnuPG: 7D3B9505   F3C9 553F A1DA 4AC2 5648 23C1 B3DF F742 7D3B 9505  -=| 
-------------- next part --------------
? COPYING
Index: ChangeLog
===================================================================
RCS file: /data/cvs/libvirt/ChangeLog,v
retrieving revision 1.201
diff -c -r1.201 ChangeLog
*** ChangeLog	7 Aug 2006 14:35:20 -0000	1.201
--- ChangeLog	7 Aug 2006 16:07:02 -0000
***************
*** 1,3 ****
--- 1,9 ----
+ Mon Aug  7 11:06:20 EDT 2006 Daniel Berrange <berrange at redhat.com>
+ 
+ 	* src/xend_internal.c: Added a 'port' attribute to the '<graphics>'
+ 	tag when display type is VNC, providing the port number on which
+ 	the VNC server is listening.
+ 	
  Fri Aug  4 20:19:23 EDT 2006 Daniel Berrange <berrange at redhat.com>
  
  	* src/libvirt.c: Fix off-by-one in validated VCPU number (it is
Index: src/xend_internal.c
===================================================================
RCS file: /data/cvs/libvirt/src/xend_internal.c,v
retrieving revision 1.47
diff -c -r1.47 xend_internal.c
*** src/xend_internal.c	4 Aug 2006 10:41:05 -0000	1.47
--- src/xend_internal.c	7 Aug 2006 16:07:03 -0000
***************
*** 1598,1610 ****
  
      if (hvm) {
          /* Graphics device */
-         /* TODO:
-          * Support for some additional attributes for graphics device?
-          */
          tmp = sexpr_node(root, "domain/image/hvm/vnc");
          if (tmp != NULL) {
              if (tmp[0] == '1')
!                 virBufferAdd(&buf, "    <graphics type='vnc'/>\n", 27 );
          }
          
          tmp = sexpr_node(root, "domain/image/hvm/sdl");
--- 1598,1608 ----
  
      if (hvm) {
          /* Graphics device */
          tmp = sexpr_node(root, "domain/image/hvm/vnc");
          if (tmp != NULL) {
              if (tmp[0] == '1')
!                 virBufferVSprintf(&buf, "    <graphics type='vnc' port='%d'/>\n", 
!                                   5900 + sexpr_int(root, "domain/domid"));
          }
          
          tmp = sexpr_node(root, "domain/image/hvm/sdl");


More information about the libvir-list mailing list