[libvirt] Patch for Ruby Bindings to include attach & detach device

Hi David Lutterkort asked me to send this patch to the list so it could be reviewed. What this small patch does is, it adds two functions to call "virDomainAttachDevice" & "virDomainDetachDevice" which allow devices to be attached & detached at run-time. The Ruby methods are called "attach_device" & "detach_device" and belong to the Domain class. Martin --- orig_libvirt.c 2009-06-18 12:17:47.000000000 +0200 +++ mine_libvirt.c 2009-06-18 12:22:25.000000000 +0200 @@ -970,6 +970,22 @@ } /* + * Call +virDomainAttachDevice+[ http://www.libvirt.org/html/libvirt-libvirt.html#virDomainAttachDevice] + */ +VALUE libvirt_dom_attach_device(VALUE s, VALUE xml) { + gen_call_void(virDomainAttachDevice, conn(s), + domain_get(s), StringValueCStr(xml)); +} + +/* + * Call +virDomainDetachDevice+[ http://www.libvirt.org/html/libvirt-libvirt.html#virDomainDetachDevice] + */ +VALUE libvirt_dom_detach_device(VALUE s, VALUE xml) { + gen_call_void(virDomainDetachDevice, conn(s), + domain_get(s), StringValueCStr(xml)); +} + +/* * Call +virDomainCreateLinux+[ http://www.libvirt.org/html/libvirt-libvirt.html#virDomainCreateLinux] */ VALUE libvirt_conn_create_linux(int argc, VALUE *argv, VALUE c) { @@ -1921,6 +1937,8 @@ rb_define_method(c_domain, "autostart", libvirt_dom_autostart, 0); rb_define_method(c_domain, "autostart=", libvirt_dom_autostart_set, 1); rb_define_method(c_domain, "free", libvirt_dom_free, 0); + rb_define_method(c_domain, "attach_device", libvirt_dom_attach_device, 1); + rb_define_method(c_domain, "detach_device", libvirt_dom_detach_device, 1); /* * Class Libvirt::Domain::Info

On Thu, Jun 18, 2009 at 12:31:12PM +0200, Martin Gajdos wrote:
Hi
David Lutterkort asked me to send this patch to the list so it could be reviewed.
What this small patch does is, it adds two functions to call "virDomainAttachDevice" & "virDomainDetachDevice" which allow devices to be attached & detached at run-time. The Ruby methods are called "attach_device" & "detach_device" and belong to the Domain class.
That looks fairly simple but David will double check :-) thanks ! Daniel -- Daniel Veillard | libxml Gnome XML XSLT toolkit http://xmlsoft.org/ daniel@veillard.com | Rpmfind RPM search engine http://rpmfind.net/ http://veillard.com/ | virtualization library http://libvirt.org/

On Thu, 2009-06-18 at 12:31 +0200, Martin Gajdos wrote:
What this small patch does is, it adds two functions to call "virDomainAttachDevice" & "virDomainDetachDevice" which allow devices to be attached & detached at run-time. The Ruby methods are called "attach_device" & "detach_device" and belong to the Domain class.
Thanks for sending this - I just committed the patch. For extra credit, any chance I can get you to add a test to tests/tc_connect.rb that calls these methods ? David
participants (3)
-
Daniel Veillard
-
David Lutterkort
-
Martin Gajdos