[Ovirt-devel] Re: [PATCH server] allow admin to setup iptables port forwarding on server for a vm's vnc port

Mohammed Morsi mmorsi at redhat.com
Tue Feb 3 15:57:06 UTC 2009


David Lutterkort wrote:
> Kicking out that error when the user wants 'autoassign' is pretty
> confusing.
>
> As long as you take the lock inside a transaction, it will be released
> at the end of the transaction, i.e. something like this _should_ do the
> right thing
>
>         Vm.transaction do
>           # Whatever Rails magic is needed to do 'LOCK TABLE vms EXCLUSIVE;'
>           ... determine vnc port ...
>           ... save VM ...
>         end
>
> David
>
>   
I guess I misread this when I just implemented it and sent out the
patch, I added the transaction bits where necessary but couldn't find a
suitable way to lock an entire table via rails (am I mistaken Jay or
Scott?), though particular rows can be locked quite easily upon retrieval.

I could add an array class variable to the VM class, concurrently
protected via  mutex, to store ports returned by
available_forward_vnc_port, but this seems to me to be an iffy solution
at best.

I figure the best solution given what we have would be to determine if
the error raised by the model is due to the forward_vnc_port unique
constraint failing and then loop around to generate another port (doing
as many times as necessary). It will make the controller code a bit
uglier, but it should work so long as I can determine the particular
fields and validations which cause the failure (from what I've read I
should be able to). I'll get started on this bit, unless there are
better alternate suggestions.

    -Mo




More information about the ovirt-devel mailing list