Bug 691659

Summary: libguestfs fails to run under JRuby 1.6.0
Product: [Community] Virtualization Tools Reporter: Marek Goldmann <mgoldman>
Component: libguestfsAssignee: Richard W.M. Jones <rjones>
Status: CLOSED UPSTREAM QA Contact:
Severity: unspecified Docs Contact:
Priority: unspecified    
Version: unspecifiedCC: mbooth, virt-maint
Target Milestone: ---   
Target Release: ---   
Hardware: x86_64   
OS: Linux   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2012-05-03 13:53:39 UTC Type: ---
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:
Embargoed:
Bug Depends On: 561484, 723191    
Bug Blocks:    
Attachments:
Description Flags
Sample Ruby script
none
Strace output for create_disk.rb
none
JRuby program none

Description Marek Goldmann 2011-03-29 07:55:58 UTC
Created attachment 488364 [details]
Sample Ruby script

Description of problem:

With JRuby 1.6.0 we have now experimental support for C extensions. Unfortunately guestfs doesn't work. To start work with JRuby and libguestfs do:

1. Download latest JRuby (http://www.jruby.org/)
2. Copy Ruby bindings from your Fedora 14 installation:

cp /usr/lib/ruby/site_ruby/1.8/guestfs.rb $JRUBY_HOME/lib/ruby/site_ruby/1.8/
cp /usr/lib64/ruby/site_ruby/1.8/x86_64-linux/_guestfs.so $JRUBY_HOME/lib/native/x86_64-Linux/

3. Launch irb:

[goldmann@work tmp]$ jruby -J-Xmx1024m -I$JRUBY_HOME/lib/native/x86_64-Linux/ -S irb
irb(main):001:0> require 'guestfs'
=> true
irb(main):002:0> g = Guestfs::create
=> #<Guestfs::Guestfs:0x3458213c>
irb(main):003:0> g.set_trace(1)
Fatal: unknown type 0x22
	from (irb):3:in `evaluate'
	from org/jruby/RubyKernel.java:1087:in `eval'
	from /home/goldmann/boxgrinder-torquebox/jruby/lib/ruby/1.8/irb.rb:158:in `eval_input'
	from /home/goldmann/boxgrinder-torquebox/jruby/lib/ruby/1.8/irb.rb:271:in `signal_status'
	from /home/goldmann/boxgrinder-torquebox/jruby/lib/ruby/1.8/irb.rb:155:in `eval_input'
	from org/jruby/RubyKernel.java:1417:in `loop'
	from org/jruby/RubyKernel.java:1190:in `catch'
	from /home/goldmann/boxgrinder-torquebox/jruby/lib/ruby/1.8/irb.rb:154:in `eval_input'
	from /home/goldmann/boxgrinder-torquebox/jruby/lib/ruby/1.8/irb.rb:71:in `start'
	from org/jruby/RubyKernel.java:1190:in `catch'
	from /home/goldmann/boxgrinder-torquebox/jruby/lib/ruby/1.8/irb.rb:70:in `start'
	from /home/goldmann/boxgrinder-torquebox/jruby/bin/jirb:13:in `(root)'

Version-Release number of selected component (if applicable):

ruby-libguestfs-1.8.2-1.fc14.x86_64

Comment 1 Marek Goldmann 2011-03-29 07:56:33 UTC
Created attachment 488365 [details]
Strace output for create_disk.rb

Comment 2 Richard W.M. Jones 2011-04-12 17:16:30 UTC
From reading about this, it seems that JRuby has some
support for C extensions, but that it is known to be
problematic.

There seem to be two possible ways forward:

(1) Use the actual Java libguestfs bindings instead.  This
seems to be the standard reply, eg:
http://stackoverflow.com/questions/526205/jruby-windows-and-native-extensions-how-do-i-distinguish-them/526456#526456

(2) Ask upstream JRuby developers if there is anything we
can do to make the Ruby extensions friendlier towards JRuby
or the JVM.

Comment 3 Richard W.M. Jones 2011-07-18 19:13:58 UTC
Now we have jruby in Rawhide, we could actually test this and
debug it ...

Comment 4 Marek Goldmann 2011-07-19 06:23:01 UTC
(In reply to comment #3)
> Now we have jruby in Rawhide, we could actually test this and
> debug it ...

Yes, I'll try to reproduce it on Rawhide and get back to you with my results.

Comment 5 Marek Goldmann 2011-07-19 10:45:37 UTC
With latest jruby-1.6.2-2.fc16.noarch which is in Rawhide I got:

$ jruby -J-Xmx1024m -I/usr/share/jruby/lib/native/ -S irb
/usr/bin/build-classpath: error: Could not find jffi Java extension for this JVM
/usr/bin/build-classpath: error: Could not find jruby-yecht Java extension for this JVM
/usr/bin/build-classpath: error: Some specified jars were not found
irb(main):001:0> require 'guestfs'
LoadError: load error: _guestfs -- java.lang.NoClassDefFoundError: com/kenai/jffi/Library
from org/jruby/RubyKernel.java:1038:in `require'
from /usr/share/jruby/lib/ruby/site_ruby/1.8/guestfs.rb:18:in `(root)'
from org/jruby/RubyKernel.java:1038:in `require'
from /usr/share/jruby/lib/ruby/site_ruby/1.8/guestfs.rb:1:in `evaluate'
from org/jruby/RubyKernel.java:1088:in `eval'
from /usr/share/jruby/lib/ruby/1.8/irb.rb:158:in `eval_input'
from /usr/share/jruby/lib/ruby/1.8/irb.rb:271:in `signal_status'
from /usr/share/jruby/lib/ruby/1.8/irb.rb:155:in `eval_input'
from org/jruby/RubyKernel.java:1419:in `loop'
from org/jruby/RubyKernel.java:1191:in `catch'
from /usr/share/jruby/lib/ruby/1.8/irb.rb:154:in `eval_input'
from /usr/share/jruby/lib/ruby/1.8/irb.rb:71:in `start'
from org/jruby/RubyKernel.java:1191:in `catch'
from /usr/share/jruby/lib/ruby/1.8/irb.rb:70:in `start'
from /usr/share/jruby/bin/jirb:13:in `(root)'
irb(main):002:0>

It seems that ffi lib couldn't be found and seems to be a JRuby packaging issue to me.

Comment 6 Richard W.M. Jones 2011-07-19 21:12:16 UTC
It works for me OK if you use the Java bindings via JRuby.

I will attach a test program to demonstrate.

Comment 7 Richard W.M. Jones 2011-07-19 21:32:48 UTC
Created attachment 513884 [details]
JRuby program

The attached program has been tested with JRuby in
Fedora Rawhide.  Note that it also requires the very
latest libguestfs (>= 1.11.20).

Comment 8 Richard W.M. Jones 2012-05-03 13:39:30 UTC
I think the recommended approach (for jruby) is to
use the Java classes.  I have checked that this works.
If this is sufficient for you I would like to close
this bug.

Comment 9 Marek Goldmann 2012-05-03 13:43:38 UTC
Rich, That's fine. When I'll have more info on this in the future, I'll add to this ticket. Feel free to close it.

Comment 10 Richard W.M. Jones 2012-05-03 13:53:39 UTC
Closing as per comment 9.