[Libvir] ruby binding patch

I have attempted to add following methods to Domain class: 1. vcpus= 2. memory= This is my first patch to libvirt-ruby, and I will appreciate your feedback. My next goal is to add binding for virDomainPinVcpu() method. Sincerely, Vadim

Hi Vadim, thanks a lot for the patch. First off, can you send patches in the future as text patches, either attached or inline[1] ? I was able to apply your hg bundle though. On Thu, 2008-03-27 at 23:59 -0700, Vadim Zaliva wrote:
I have attempted to add following methods to Domain class:
1. vcpus= 2. memory=
This is my first patch to libvirt-ruby, and I will appreciate your feedback. My next goal is to add binding for virDomainPinVcpu() method.
The patch overall looks good, and I committed it. There were some minor nits: * libvirt_dom_memory_set called virDomainSetMaxMemory instead of virDomainSetMemory (probably cut&paste error) * there were no tests for the two new methods. In general, try to add/expand the tests in tests/tc_connect.rb when you add to the bindings, though that is highly dependent on what the test driver supports. In this case though it was pretty easy. Thanks again for doing this, and I am looking forward to the virDomainPinVcpu patch. David [1] the hg patchbomb extension makes that very easy: http://hgbook.red-bean.com/hgbookch14.html#x18-32100014.4

On Mar 28, 2008, at 10:48, David Lutterkort wrote:
* there were no tests for the two new methods. In general, try to add/expand the tests in tests/tc_connect.rb when you add to the bindings, though that is highly dependent on what the test driver supports. In this case though it was pretty easy.
Thanks again for doing this, and I am looking forward to the virDomainPinVcpu patch.
Attached is a patch, implementing Domain.pin_vcpu method. I have tested it locally and it works. Here is my test code: require 'libvirt' conn = Libvirt::open("") dom = conn.lookup_domain_by_name("centos52") dom.pin_vcpu(0,[2,3]) After running it, I can verify via virsh that it does pin CPUs correctly: virsh > vcpuinfo centos52 VCPU: 0 CPU: 2 State: blocked CPU time: 40.8s CPU Affinity: --yy However, when I try this method from test/tc_connect.rb it fails: # rake test (in /home/lord/src/ruby-libvirt) Loaded suite /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake/ rake_test_loader Started libvir: error : this function is not supported by the hypervisor: virDomainPinVcpu E.... Finished in 0.006319 seconds. 1) Error: test_domain(TestConnect): SystemCallError: unknown error - libvir call virDomainPinVcpu failed ./tests/tc_connect.rb:113:in `pin_vcpu' ./tests/tc_connect.rb:113:in `test_domain' 5 tests, 60 assertions, 0 failures, 1 errors rake aborted! Command failed with status (1): [/usr/bin/ruby -Ilib:ext/libvirt "/usr/ lib/...] (See full trace by running task with --trace) I will appreciate if somebody could help me to figure out why it is happening. I might need to implement couple more methods, so if there are any remarks on my code, I will appreciate your feedback. Sincerely, Vadim -- "La perfection est atteinte non quand il ne reste rien a ajouter, mais quand il ne reste rien a enlever." (Antoine de Saint-Exupery)

On Fri, 2008-03-28 at 18:10 -0700, Vadim Zaliva wrote:
Attached is a patch, implementing Domain.pin_vcpu method. I have tested it locally and it works. Here is my test code:
Excellent. I just committed it with some minor modifications (use ALLOC/ALLOC_N instead of malloc, since the former will raise proper out-of-memory exceptions and runs the gc when memory is low)
However, when I try this method from test/tc_connect.rb it fails:
# rake test (in /home/lord/src/ruby-libvirt) Loaded suite /usr/lib/ruby/gems/1.8/gems/rake-0.7.3/lib/rake/ rake_test_loader Started libvir: error : this function is not supported by the hypervisor: virDomainPinVcpu E.... Finished in 0.006319 seconds.
1) Error: test_domain(TestConnect): SystemCallError: unknown error - libvir call virDomainPinVcpu failed ./tests/tc_connect.rb:113:in `pin_vcpu' ./tests/tc_connect.rb:113:in `test_domain'
It looks like virDomainPinVcpu is simply not implemented in the test driver; I'll take your word for it that it works properly ;) David
participants (3)
-
David Lutterkort
-
Vadim Zaliva
-
Vadim Zaliva