[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]

[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

[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]