[one-users] Xen driver and automatic VNC port generation

Tiago Batista tiagosbatista at gmail.com
Fri Oct 8 06:25:49 PDT 2010


I don't think so, if I am correct, the port value that the driver gets
already takes that into account:

from src/vm/VirtualMachine.cc, line 518 of the 2.0 beta1

        nd.get_configuration_attribute("VNC_BASE_PORT",base_port_s);
        iss.str(base_port_s);
        iss >> base_port;

        oss << ( base_port + oid ); // <-- HERE
        graphics->replace("PORT", oss.str());

Meaning that the port if not specifed on the template takes the value
of VNC_BASE_PORT + VM_ID. This generates a valid port number for KVM.
In the case of Xen however, it would result on a vnc server listening
on port+5900. So, the opennebula xen driver should subtract that 5900
that will be added by xen on the next step.

A check should be added, but to make sure that the final vncdisplay is
not a negative number as that will make xen listen on the first
available port.... Unfortunately, I do not remember where I got this
information from... Can this check be performed when loading the
driver, or should it be performed during each VM deployment because
opennebula re-reads this value from oned.conf every time?

So, if VNC_BASE_PORT >= 5900 the vncdisplay that is generated is
always translated to a specific port and this should cause no
problems, if the VNC_BASE_PORT is  bellow 5900 then a negative
vncdisplay may be generated and xen will listen on the first available
port, which is not the intended behavior.

Plus, the driver is not aware if the port number that it receives is
generated or if it was specified by the user on the template (at least
I think so..), so taking the VNC_BASE_PORT into account here would
likely break virtual machines where the user specifies a port on the
GRAPHICS section

Tiago

On Fri, Oct 8, 2010 at 12:37 PM, Ruben S. Montero <rubensm at dacya.ucm.es> wrote:
> Ok thanks. That was what I expected. May be we could do
> port - VNC_BASE_PORT
> seems safer to me.. thoughts?
> Cheers
> Ruben
>
> On Fri, Oct 8, 2010 at 12:30 PM, Tiago Batista <tiagosbatista at gmail.com>
> wrote:
>>
>> It does work as long as it is opennebula generating the port numbers
>> (with 5900 as the base) and it does work for static port assignments:
>>
>> the template
>>
>> GRAPHICS =[type="vnc", passwd="qwerty", port="5900"]
>>
>> translates to "vncdisplay=0" that is translated by xen back to 5900...
>>
>> and the template
>>
>> GRAPHICS =[type="vnc", passwd="qwerty"]
>>
>> translates to "vncdisplay=vmId" that is translated by xen back to
>> 5900+vmid as intended
>>
>> The current code translates port 5900 to vncdisplay 5900, xen then
>> adds another 5900, ending up listening on port 11800 while openebula
>> claims the port to be 5900! So, I am just offsetting the 5900 that is
>> going to be added by xen on the next step!
>>
>> What is the situation where opennebula is not the generator of the
>> port number? I have tested it successfully with and without port
>> numbers on the template, and I think of no usecase where this fails as
>> long as VNC_BASE_PORT=5900...
>>
>> Tiago
>>
>>
>>
>>
>> On Thu, Oct 7, 2010 at 10:51 PM, Ruben S. Montero <rubensm at dacya.ucm.es>
>> wrote:
>> >
>> > Hi
>> > Yes this is a Xen specific bug. vncdisplay sets the port by adding 5900.
>> > That is already done by OpenNebula (e.g. to use it with KVM).
>> > So your solution seems fine for the port generation but, if the port is
>> > not generated by OpenNebula we will be substracting 5900...
>> > Thanks for the feedback!
>> > Ruben
>> > On Wed, Oct 6, 2010 at 5:17 PM, Tiago Batista <tiagosbatista at gmail.com>
>> > wrote:
>> >>
>> >> Hello all
>> >>
>> >> I am using Centos, and to be honnest I am not sure if this is platform
>> >> specific, but the standard port generation code for xen does not work here
>> >> (both 2.0 beta 1 and rc1)
>> >>
>> >> The following patch solves it but forces the base port in oned.conf to
>> >> be set to 5900 if using the xen driver.
>> >>
>> >> I rememmber reading somewhere that the port number is 5900 + vnc
>> >> display number... In this case I used the generated port number to calculate
>> >> the display number, but given that the port number is calculated from the VM
>> >> id, I expect that there should be a cleaner way to do this!
>> >>
>> >> Anyway.... This solves my problem!
>> >>
>> >>
>> >> --- one-2.0-beta1/src/vmm/XenDriver.cc    2010-07-27 15:34:04.000000000
>> >> +0100
>> >> +++ one-2.0-beta1_mod/src/vmm/XenDriver.cc    2010-09-21
>> >> 10:07:32.000000000 +0100
>> >> @@ -364,12 +364,10 @@
>> >>                  {
>> >>                      file << ",vnclisten=" << listen;
>> >>                  }
>> >> -
>> >>                  if ( !port.empty() )
>> >>                  {
>> >> -                    file << ",vncdisplay=" << port;
>> >> +                    file << ",vncdisplay=" <<
>> >> (atoi(port.c_str())-5900);
>> >>                  }
>> >> -
>> >>                  if ( !passwd.empty() )
>> >>                  {
>> >>                      file << ",vncpasswd=" << passwd;
>> >>
>> >>
>> >>
>> >>
>> >> _______________________________________________
>> >> Users mailing list
>> >> Users at lists.opennebula.org
>> >> http://lists.opennebula.org/listinfo.cgi/users-opennebula.org
>> >>
>> >
>> >
>> >
>> > --
>> > Dr. Ruben Santiago Montero
>> > Associate Professor (Profesor Titular), Complutense University of Madrid
>> >
>> > URL: http://dsa-research.org/doku.php?id=people:ruben
>> > Weblog: http://blog.dsa-research.org/?author=7
>
>
>
> --
> Dr. Ruben Santiago Montero
> Associate Professor (Profesor Titular), Complutense University of Madrid
>
> URL: http://dsa-research.org/doku.php?id=people:ruben
> Weblog: http://blog.dsa-research.org/?author=7
>



More information about the Users mailing list