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

David Lutterkort lutter at redhat.com
Tue Feb 3 18:23:36 UTC 2009


On Tue, 2009-02-03 at 10:57 -0500, Mohammed Morsi wrote:
> 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.

You might have to do that by giving AR a raw SQL statement. (get the
connection from ActiveRecord::Base and execute the SQL statement)

> 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.

Mutexes are pretty much useless in web applications, since several
server processes might be accessing the same DB.

> 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.

That's a really ugly hack - just lock the table and be done with it.

David





More information about the ovirt-devel mailing list