ruby-libvirt 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/NEWS +43 -0
 - data/README +40 -2
 - data/README.rdoc +3 -1
 - data/Rakefile +3 -25
 - data/ext/libvirt/_libvirt.c +636 -35
 - data/ext/libvirt/common.c +142 -16
 - data/ext/libvirt/common.h +78 -22
 - data/ext/libvirt/connect.c +1811 -95
 - data/ext/libvirt/connect.h +0 -1
 - data/ext/libvirt/domain.c +880 -424
 - data/ext/libvirt/domain.h +4 -0
 - data/ext/libvirt/extconf.rb +90 -0
 - data/ext/libvirt/interface.c +40 -118
 - data/ext/libvirt/network.c +22 -125
 - data/ext/libvirt/network.h +1 -0
 - data/ext/libvirt/nodedevice.c +27 -142
 - data/ext/libvirt/nwfilter.c +10 -83
 - data/ext/libvirt/secret.c +35 -113
 - data/ext/libvirt/storage.c +125 -223
 - data/tests/test_conn.rb +193 -43
 - data/tests/test_domain.rb +1067 -102
 - data/tests/test_interface.rb +156 -19
 - data/tests/test_network.rb +237 -26
 - data/tests/test_nodedevice.rb +103 -15
 - data/tests/test_nwfilter.rb +97 -14
 - data/tests/test_open.rb +186 -6
 - data/tests/test_secret.rb +126 -14
 - data/tests/test_storage.rb +513 -40
 - data/tests/test_utils.rb +73 -0
 - metadata +5 -6
 - data/tests/node.xml +0 -110
 - data/tests/tc_connect.rb +0 -178
 
    
        data/ext/libvirt/common.c
    CHANGED
    
    | 
         @@ -18,38 +18,113 @@ 
     | 
|
| 
       18 
18 
     | 
    
         
             
             * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
         
     | 
| 
       19 
19 
     | 
    
         
             
             */
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
      
 21 
     | 
    
         
            +
            #ifndef _GNU_SOURCE
         
     | 
| 
      
 22 
     | 
    
         
            +
            #define _GNU_SOURCE 1
         
     | 
| 
      
 23 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 24 
     | 
    
         
            +
            #include <stdio.h>
         
     | 
| 
       21 
25 
     | 
    
         
             
            #include <ruby.h>
         
     | 
| 
       22 
26 
     | 
    
         
             
            #include <libvirt/libvirt.h>
         
     | 
| 
       23 
27 
     | 
    
         
             
            #include <libvirt/virterror.h>
         
     | 
| 
      
 28 
     | 
    
         
            +
            #include "common.h"
         
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
            struct rb_exc_new2_arg {
         
     | 
| 
      
 31 
     | 
    
         
            +
                VALUE error;
         
     | 
| 
      
 32 
     | 
    
         
            +
                char *msg;
         
     | 
| 
      
 33 
     | 
    
         
            +
            };
         
     | 
| 
      
 34 
     | 
    
         
            +
             
     | 
| 
      
 35 
     | 
    
         
            +
            static VALUE rb_exc_new2_wrap(VALUE arg) {
         
     | 
| 
      
 36 
     | 
    
         
            +
                struct rb_exc_new2_arg *e = (struct rb_exc_new2_arg *)arg;
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
                return rb_exc_new2(e->error, e->msg);
         
     | 
| 
      
 39 
     | 
    
         
            +
            }
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
            VALUE rb_ary_new2_wrap(VALUE arg) {
         
     | 
| 
      
 42 
     | 
    
         
            +
                return rb_ary_new2(*((int *)arg));
         
     | 
| 
      
 43 
     | 
    
         
            +
            }
         
     | 
| 
      
 44 
     | 
    
         
            +
             
     | 
| 
      
 45 
     | 
    
         
            +
            VALUE rb_ary_push_wrap(VALUE arg) {
         
     | 
| 
      
 46 
     | 
    
         
            +
                struct rb_ary_push_arg *e = (struct rb_ary_push_arg *)arg;
         
     | 
| 
      
 47 
     | 
    
         
            +
             
     | 
| 
      
 48 
     | 
    
         
            +
                return rb_ary_push(e->arr, e->value);
         
     | 
| 
      
 49 
     | 
    
         
            +
            }
         
     | 
| 
      
 50 
     | 
    
         
            +
             
     | 
| 
      
 51 
     | 
    
         
            +
            VALUE rb_str_new2_wrap(VALUE arg) {
         
     | 
| 
      
 52 
     | 
    
         
            +
                char **str = (char **)arg;
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
                return rb_str_new2(*str);
         
     | 
| 
      
 55 
     | 
    
         
            +
            }
         
     | 
| 
      
 56 
     | 
    
         
            +
             
     | 
| 
      
 57 
     | 
    
         
            +
            VALUE rb_ary_entry_wrap(VALUE arg) {
         
     | 
| 
      
 58 
     | 
    
         
            +
                struct rb_ary_entry_arg *e = (struct rb_ary_entry_arg *)arg;
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
                return rb_ary_entry(e->arr, e->elem);
         
     | 
| 
      
 61 
     | 
    
         
            +
            }
         
     | 
| 
      
 62 
     | 
    
         
            +
             
     | 
| 
      
 63 
     | 
    
         
            +
            VALUE rb_ary_new_wrap(VALUE arg) {
         
     | 
| 
      
 64 
     | 
    
         
            +
                return rb_ary_new();
         
     | 
| 
      
 65 
     | 
    
         
            +
            }
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
            VALUE rb_str_new_wrap(VALUE arg) {
         
     | 
| 
      
 68 
     | 
    
         
            +
                struct rb_str_new_arg *e = (struct rb_str_new_arg *)arg;
         
     | 
| 
      
 69 
     | 
    
         
            +
             
     | 
| 
      
 70 
     | 
    
         
            +
                return rb_str_new(e->val, e->size);
         
     | 
| 
      
 71 
     | 
    
         
            +
            }
         
     | 
| 
      
 72 
     | 
    
         
            +
             
     | 
| 
      
 73 
     | 
    
         
            +
            VALUE rb_iv_set_wrap(VALUE arg) {
         
     | 
| 
      
 74 
     | 
    
         
            +
                struct rb_iv_set_arg *e = (struct rb_iv_set_arg *)arg;
         
     | 
| 
      
 75 
     | 
    
         
            +
             
     | 
| 
      
 76 
     | 
    
         
            +
                return rb_iv_set(e->klass, e->member, e->value);
         
     | 
| 
      
 77 
     | 
    
         
            +
            }
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
            VALUE rb_class_new_instance_wrap(VALUE arg) {
         
     | 
| 
      
 80 
     | 
    
         
            +
                struct rb_class_new_instance_arg *e = (struct rb_class_new_instance_arg *)arg;
         
     | 
| 
      
 81 
     | 
    
         
            +
             
     | 
| 
      
 82 
     | 
    
         
            +
                return rb_class_new_instance(e->argc, e->argv, e->klass);
         
     | 
| 
      
 83 
     | 
    
         
            +
            }
         
     | 
| 
      
 84 
     | 
    
         
            +
             
     | 
| 
      
 85 
     | 
    
         
            +
            VALUE rb_string_value_cstr_wrap(VALUE arg) {
         
     | 
| 
      
 86 
     | 
    
         
            +
                return (VALUE)rb_string_value_cstr((VALUE *)arg);
         
     | 
| 
      
 87 
     | 
    
         
            +
            }
         
     | 
| 
       24 
88 
     | 
    
         | 
| 
       25 
89 
     | 
    
         
             
            /* Error handling */
         
     | 
| 
       26 
     | 
    
         
            -
            VALUE create_error(VALUE error, const char* method,  
     | 
| 
       27 
     | 
    
         
            -
                               virConnectPtr conn) {
         
     | 
| 
      
 90 
     | 
    
         
            +
            VALUE create_error(VALUE error, const char* method, virConnectPtr conn) {
         
     | 
| 
       28 
91 
     | 
    
         
             
                VALUE ruby_errinfo;
         
     | 
| 
       29 
92 
     | 
    
         
             
                virErrorPtr err;
         
     | 
| 
       30 
     | 
    
         
            -
             
     | 
| 
       31 
     | 
    
         
            -
                 
     | 
| 
       32 
     | 
    
         
            -
             
     | 
| 
       33 
     | 
    
         
            -
             
     | 
| 
       34 
     | 
    
         
            -
                    len = snprintf(NULL, 0, "Call to function %s failed", method) + 1;
         
     | 
| 
       35 
     | 
    
         
            -
                    defmsg = ALLOC_N(char, len);
         
     | 
| 
       36 
     | 
    
         
            -
                    snprintf(defmsg, len, "Call to function %s failed", method);
         
     | 
| 
       37 
     | 
    
         
            -
                    ruby_errinfo = rb_exc_new2(error, defmsg);
         
     | 
| 
       38 
     | 
    
         
            -
                    free(defmsg);
         
     | 
| 
       39 
     | 
    
         
            -
                } else {
         
     | 
| 
       40 
     | 
    
         
            -
                    ruby_errinfo = rb_exc_new2(error, msg);
         
     | 
| 
       41 
     | 
    
         
            -
                }
         
     | 
| 
       42 
     | 
    
         
            -
                rb_iv_set(ruby_errinfo, "@libvirt_function_name", rb_str_new2(method));
         
     | 
| 
      
 93 
     | 
    
         
            +
                char *msg;
         
     | 
| 
      
 94 
     | 
    
         
            +
                int rc;
         
     | 
| 
      
 95 
     | 
    
         
            +
                struct rb_exc_new2_arg arg;
         
     | 
| 
      
 96 
     | 
    
         
            +
                int exception = 0;
         
     | 
| 
       43 
97 
     | 
    
         | 
| 
       44 
98 
     | 
    
         
             
                if (conn == NULL)
         
     | 
| 
       45 
99 
     | 
    
         
             
                    err = virGetLastError();
         
     | 
| 
       46 
100 
     | 
    
         
             
                else
         
     | 
| 
       47 
101 
     | 
    
         
             
                    err = virConnGetLastError(conn);
         
     | 
| 
       48 
102 
     | 
    
         | 
| 
      
 103 
     | 
    
         
            +
                if (err != NULL && err->message != NULL)
         
     | 
| 
      
 104 
     | 
    
         
            +
                    rc = asprintf(&msg, "Call to %s failed: %s", method, err->message);
         
     | 
| 
      
 105 
     | 
    
         
            +
                else
         
     | 
| 
      
 106 
     | 
    
         
            +
                    rc = asprintf(&msg, "Call to %s failed", method);
         
     | 
| 
      
 107 
     | 
    
         
            +
             
     | 
| 
      
 108 
     | 
    
         
            +
                if (rc < 0) {
         
     | 
| 
      
 109 
     | 
    
         
            +
                    /* there's not a whole lot we can do here; try to raise an
         
     | 
| 
      
 110 
     | 
    
         
            +
                     * out-of-memory message */
         
     | 
| 
      
 111 
     | 
    
         
            +
                    rb_memerror();
         
     | 
| 
      
 112 
     | 
    
         
            +
                }
         
     | 
| 
      
 113 
     | 
    
         
            +
             
     | 
| 
      
 114 
     | 
    
         
            +
                arg.error = error;
         
     | 
| 
      
 115 
     | 
    
         
            +
                arg.msg = msg;
         
     | 
| 
      
 116 
     | 
    
         
            +
                ruby_errinfo = rb_protect(rb_exc_new2_wrap, (VALUE)&arg, &exception);
         
     | 
| 
      
 117 
     | 
    
         
            +
                free(msg);
         
     | 
| 
      
 118 
     | 
    
         
            +
                if (exception)
         
     | 
| 
      
 119 
     | 
    
         
            +
                    rb_jump_tag(exception);
         
     | 
| 
      
 120 
     | 
    
         
            +
             
     | 
| 
      
 121 
     | 
    
         
            +
                rb_iv_set(ruby_errinfo, "@libvirt_function_name", rb_str_new2(method));
         
     | 
| 
      
 122 
     | 
    
         
            +
             
     | 
| 
       49 
123 
     | 
    
         
             
                if (err != NULL) {
         
     | 
| 
       50 
124 
     | 
    
         
             
                    rb_iv_set(ruby_errinfo, "@libvirt_code", INT2FIX(err->code));
         
     | 
| 
       51 
125 
     | 
    
         
             
                    if (err->message != NULL)
         
     | 
| 
       52 
     | 
    
         
            -
                        rb_iv_set(ruby_errinfo, "@libvirt_message", 
     | 
| 
      
 126 
     | 
    
         
            +
                        rb_iv_set(ruby_errinfo, "@libvirt_message",
         
     | 
| 
      
 127 
     | 
    
         
            +
                                  rb_str_new2(err->message));
         
     | 
| 
       53 
128 
     | 
    
         
             
                }
         
     | 
| 
       54 
129 
     | 
    
         | 
| 
       55 
130 
     | 
    
         
             
                return ruby_errinfo;
         
     | 
| 
         @@ -73,3 +148,54 @@ VALUE generic_new(VALUE klass, void *ptr, VALUE conn, 
     | 
|
| 
       73 
148 
     | 
    
         
             
                return result;
         
     | 
| 
       74 
149 
     | 
    
         
             
            }
         
     | 
| 
       75 
150 
     | 
    
         | 
| 
      
 151 
     | 
    
         
            +
            int is_symbol_or_proc(VALUE handle) {
         
     | 
| 
      
 152 
     | 
    
         
            +
                return ((strcmp(rb_obj_classname(handle), "Symbol") == 0) ||
         
     | 
| 
      
 153 
     | 
    
         
            +
                        (strcmp(rb_obj_classname(handle), "Proc") == 0));
         
     | 
| 
      
 154 
     | 
    
         
            +
            }
         
     | 
| 
      
 155 
     | 
    
         
            +
             
     | 
| 
      
 156 
     | 
    
         
            +
            /* this is an odd function, because it has massive side-effects.  The first
         
     | 
| 
      
 157 
     | 
    
         
            +
             * tip that something is weird here should be the triple-starred list.
         
     | 
| 
      
 158 
     | 
    
         
            +
             * The intended usage of this function is after a list has been collected
         
     | 
| 
      
 159 
     | 
    
         
            +
             * from a libvirt list function, and now we want to make an array out of it.
         
     | 
| 
      
 160 
     | 
    
         
            +
             * However, it is possible that the act of creating an array causes an
         
     | 
| 
      
 161 
     | 
    
         
            +
             * exception, which would lead to a memory leak of the values we got from
         
     | 
| 
      
 162 
     | 
    
         
            +
             * libvirt.  Therefore, this function not only wraps all of the relevant
         
     | 
| 
      
 163 
     | 
    
         
            +
             * calls with rb_protect, it also frees every individual entry in list
         
     | 
| 
      
 164 
     | 
    
         
            +
             * along with list itself.
         
     | 
| 
      
 165 
     | 
    
         
            +
             */
         
     | 
| 
      
 166 
     | 
    
         
            +
            VALUE gen_list(int num, char ***list) {
         
     | 
| 
      
 167 
     | 
    
         
            +
                VALUE result;
         
     | 
| 
      
 168 
     | 
    
         
            +
                int exception = 0;
         
     | 
| 
      
 169 
     | 
    
         
            +
                int i, j;
         
     | 
| 
      
 170 
     | 
    
         
            +
                struct rb_ary_push_arg arg;
         
     | 
| 
      
 171 
     | 
    
         
            +
             
     | 
| 
      
 172 
     | 
    
         
            +
                result = rb_protect(rb_ary_new2_wrap, (VALUE)&num, &exception);
         
     | 
| 
      
 173 
     | 
    
         
            +
                if (exception) {
         
     | 
| 
      
 174 
     | 
    
         
            +
                    for (i = 0; i < num; i++)
         
     | 
| 
      
 175 
     | 
    
         
            +
                        free((*list)[i]);
         
     | 
| 
      
 176 
     | 
    
         
            +
                    xfree(*list);
         
     | 
| 
      
 177 
     | 
    
         
            +
                    rb_jump_tag(exception);
         
     | 
| 
      
 178 
     | 
    
         
            +
                }
         
     | 
| 
      
 179 
     | 
    
         
            +
                for (i = 0; i < num; i++) {
         
     | 
| 
      
 180 
     | 
    
         
            +
                    arg.arr = result;
         
     | 
| 
      
 181 
     | 
    
         
            +
                    arg.value = rb_protect(rb_str_new2_wrap, (VALUE)&((*list)[i]),
         
     | 
| 
      
 182 
     | 
    
         
            +
                                           &exception);
         
     | 
| 
      
 183 
     | 
    
         
            +
                    if (exception) {
         
     | 
| 
      
 184 
     | 
    
         
            +
                        for (j = i; j < num; j++)
         
     | 
| 
      
 185 
     | 
    
         
            +
                            xfree((*list)[j]);
         
     | 
| 
      
 186 
     | 
    
         
            +
                        xfree(*list);
         
     | 
| 
      
 187 
     | 
    
         
            +
                        rb_jump_tag(exception);
         
     | 
| 
      
 188 
     | 
    
         
            +
                    }
         
     | 
| 
      
 189 
     | 
    
         
            +
                    rb_protect(rb_ary_push_wrap, (VALUE)&arg, &exception);
         
     | 
| 
      
 190 
     | 
    
         
            +
                    if (exception) {
         
     | 
| 
      
 191 
     | 
    
         
            +
                        for (j = i; j < num; j++)
         
     | 
| 
      
 192 
     | 
    
         
            +
                            xfree((*list)[j]);
         
     | 
| 
      
 193 
     | 
    
         
            +
                        xfree(*list);
         
     | 
| 
      
 194 
     | 
    
         
            +
                        rb_jump_tag(exception);
         
     | 
| 
      
 195 
     | 
    
         
            +
                    }
         
     | 
| 
      
 196 
     | 
    
         
            +
                    xfree((*list)[i]);
         
     | 
| 
      
 197 
     | 
    
         
            +
                }
         
     | 
| 
      
 198 
     | 
    
         
            +
                xfree(*list);
         
     | 
| 
      
 199 
     | 
    
         
            +
             
     | 
| 
      
 200 
     | 
    
         
            +
                return result;
         
     | 
| 
      
 201 
     | 
    
         
            +
            }
         
     | 
    
        data/ext/libvirt/common.h
    CHANGED
    
    | 
         @@ -22,8 +22,7 @@ VALUE generic_new(VALUE klass, void *ptr, VALUE conn, 
     | 
|
| 
       22 
22 
     | 
    
         
             
                        rb_raise(rb_eSystemCallError, # kind " free failed");       \
         
     | 
| 
       23 
23 
     | 
    
         
             
                } while(0);
         
     | 
| 
       24 
24 
     | 
    
         | 
| 
       25 
     | 
    
         
            -
            VALUE create_error(VALUE error, const char* method,  
     | 
| 
       26 
     | 
    
         
            -
                               virConnectPtr conn);
         
     | 
| 
      
 25 
     | 
    
         
            +
            VALUE create_error(VALUE error, const char* method, virConnectPtr conn);
         
     | 
| 
       27 
26 
     | 
    
         | 
| 
       28 
27 
     | 
    
         
             
            /*
         
     | 
| 
       29 
28 
     | 
    
         
             
             * Code generating macros.
         
     | 
| 
         @@ -42,11 +41,11 @@ VALUE create_error(VALUE error, const char* method, const char* msg, 
     | 
|
| 
       42 
41 
     | 
    
         
             
                    VALUE result;                                                   \
         
     | 
| 
       43 
42 
     | 
    
         
             
                                                                                    \
         
     | 
| 
       44 
43 
     | 
    
         
             
                    str = func(args);                                               \
         
     | 
| 
       45 
     | 
    
         
            -
                    _E(str == NULL, create_error(e_Error, # func,  
     | 
| 
      
 44 
     | 
    
         
            +
                    _E(str == NULL, create_error(e_Error, # func, conn));           \
         
     | 
| 
       46 
45 
     | 
    
         
             
                                                                                    \
         
     | 
| 
       47 
46 
     | 
    
         
             
                    result = rb_str_new2(str);                                      \
         
     | 
| 
       48 
47 
     | 
    
         
             
                    if (dealloc)                                                    \
         
     | 
| 
       49 
     | 
    
         
            -
                         
     | 
| 
      
 48 
     | 
    
         
            +
                        xfree((void *) str);                                        \
         
     | 
| 
       50 
49 
     | 
    
         
             
                    return result;                                                  \
         
     | 
| 
       51 
50 
     | 
    
         
             
                } while(0)
         
     | 
| 
       52 
51 
     | 
    
         | 
| 
         @@ -59,7 +58,7 @@ VALUE create_error(VALUE error, const char* method, const char* msg, 
     | 
|
| 
       59 
58 
     | 
    
         
             
                    Data_Get_Struct(s, vir##kind, ptr);                             \
         
     | 
| 
       60 
59 
     | 
    
         
             
                    if (ptr != NULL) {                                              \
         
     | 
| 
       61 
60 
     | 
    
         
             
                        int r = vir##kind##Free(ptr);                               \
         
     | 
| 
       62 
     | 
    
         
            -
                        _E(r < 0, create_error(e_Error, "vir" #kind "Free",  
     | 
| 
      
 61 
     | 
    
         
            +
                        _E(r < 0, create_error(e_Error, "vir" #kind "Free", conn(s))); \
         
     | 
| 
       63 
62 
     | 
    
         
             
                        DATA_PTR(s) = NULL;                                         \
         
     | 
| 
       64 
63 
     | 
    
         
             
                    }                                                               \
         
     | 
| 
       65 
64 
     | 
    
         
             
                    return Qnil;                                                    \
         
     | 
| 
         @@ -73,7 +72,7 @@ VALUE create_error(VALUE error, const char* method, const char* msg, 
     | 
|
| 
       73 
72 
     | 
    
         
             
                do {                                                                \
         
     | 
| 
       74 
73 
     | 
    
         
             
                    int _r_##func;                                                  \
         
     | 
| 
       75 
74 
     | 
    
         
             
                    _r_##func = func(args);                                         \
         
     | 
| 
       76 
     | 
    
         
            -
                    _E(_r_##func < 0, create_error(e_Error, #func,  
     | 
| 
      
 75 
     | 
    
         
            +
                    _E(_r_##func < 0, create_error(e_Error, #func, conn));          \
         
     | 
| 
       77 
76 
     | 
    
         
             
                    return Qnil;                                                    \
         
     | 
| 
       78 
77 
     | 
    
         
             
                } while(0)
         
     | 
| 
       79 
78 
     | 
    
         | 
| 
         @@ -88,11 +87,14 @@ VALUE create_error(VALUE error, const char* method, const char* msg, 
     | 
|
| 
       88 
87 
     | 
    
         
             
                    virConnectPtr conn = connect_get(c);                            \
         
     | 
| 
       89 
88 
     | 
    
         
             
                                                                                    \
         
     | 
| 
       90 
89 
     | 
    
         
             
                    result = virConnectNumOf##objs(conn);                           \
         
     | 
| 
       91 
     | 
    
         
            -
                    _E(result < 0, create_error(e_RetrieveError, "virConnectNumOf" # objs,  
     | 
| 
      
 90 
     | 
    
         
            +
                    _E(result < 0, create_error(e_RetrieveError, "virConnectNumOf" # objs, conn));                \
         
     | 
| 
       92 
91 
     | 
    
         
             
                                                                                    \
         
     | 
| 
       93 
92 
     | 
    
         
             
                    return INT2NUM(result);                                         \
         
     | 
| 
       94 
93 
     | 
    
         
             
                } while(0)
         
     | 
| 
       95 
94 
     | 
    
         | 
| 
      
 95 
     | 
    
         
            +
             
     | 
| 
      
 96 
     | 
    
         
            +
            VALUE gen_list(int num, char ***list);
         
     | 
| 
      
 97 
     | 
    
         
            +
             
     | 
| 
       96 
98 
     | 
    
         
             
            /*
         
     | 
| 
       97 
99 
     | 
    
         
             
             * Generate a call to a virConnectList... function. S is the Ruby VALUE
         
     | 
| 
       98 
100 
     | 
    
         
             
             * holding the connection and OBJS is a token indicating what objects to
         
     | 
| 
         @@ -101,32 +103,24 @@ VALUE create_error(VALUE error, const char* method, const char* msg, 
     | 
|
| 
       101 
103 
     | 
    
         
             
             */
         
     | 
| 
       102 
104 
     | 
    
         
             
            #define gen_conn_list_names(s, objs)                                    \
         
     | 
| 
       103 
105 
     | 
    
         
             
                do {                                                                \
         
     | 
| 
       104 
     | 
    
         
            -
                    int  
     | 
| 
      
 106 
     | 
    
         
            +
                    int r, num;                                                     \
         
     | 
| 
       105 
107 
     | 
    
         
             
                    char **names;                                                   \
         
     | 
| 
       106 
108 
     | 
    
         
             
                    virConnectPtr conn = connect_get(s);                            \
         
     | 
| 
       107 
     | 
    
         
            -
                    VALUE result;                                                   \
         
     | 
| 
       108 
109 
     | 
    
         
             
                                                                                    \
         
     | 
| 
       109 
110 
     | 
    
         
             
                    num = virConnectNumOf##objs(conn);                              \
         
     | 
| 
       110 
     | 
    
         
            -
                    _E(num < 0, create_error(e_RetrieveError, "virConnectNumOf" # objs,  
     | 
| 
      
 111 
     | 
    
         
            +
                    _E(num < 0, create_error(e_RetrieveError, "virConnectNumOf" # objs, conn));   \
         
     | 
| 
       111 
112 
     | 
    
         
             
                    if (num == 0) {                                                 \
         
     | 
| 
       112 
113 
     | 
    
         
             
                        /* if num is 0, don't call virConnectList* function */      \
         
     | 
| 
       113 
     | 
    
         
            -
                         
     | 
| 
       114 
     | 
    
         
            -
                        return result;                                              \
         
     | 
| 
      
 114 
     | 
    
         
            +
                        return rb_ary_new2(num);                                    \
         
     | 
| 
       115 
115 
     | 
    
         
             
                    }                                                               \
         
     | 
| 
       116 
116 
     | 
    
         
             
                    names = ALLOC_N(char *, num);                                   \
         
     | 
| 
       117 
117 
     | 
    
         
             
                    r = virConnectList##objs(conn, names, num);                     \
         
     | 
| 
       118 
118 
     | 
    
         
             
                    if (r < 0) {                                                    \
         
     | 
| 
       119 
     | 
    
         
            -
                         
     | 
| 
       120 
     | 
    
         
            -
                        _E(r < 0, create_error(e_RetrieveError, "virConnectList" # objs,  
     | 
| 
      
 119 
     | 
    
         
            +
                        xfree(names);                                               \
         
     | 
| 
      
 120 
     | 
    
         
            +
                        _E(r < 0, create_error(e_RetrieveError, "virConnectList" # objs, conn));  \
         
     | 
| 
       121 
121 
     | 
    
         
             
                    }                                                               \
         
     | 
| 
       122 
122 
     | 
    
         
             
                                                                                    \
         
     | 
| 
       123 
     | 
    
         
            -
                     
     | 
| 
       124 
     | 
    
         
            -
                    for (i=0; i<num; i++) {                                         \
         
     | 
| 
       125 
     | 
    
         
            -
                        rb_ary_push(result, rb_str_new2(names[i]));                 \
         
     | 
| 
       126 
     | 
    
         
            -
                        free(names[i]);                                             \
         
     | 
| 
       127 
     | 
    
         
            -
                    }                                                               \
         
     | 
| 
       128 
     | 
    
         
            -
                    free(names);                                                    \
         
     | 
| 
       129 
     | 
    
         
            -
                    return result;                                                  \
         
     | 
| 
      
 123 
     | 
    
         
            +
                    return gen_list(num, &names);                                   \
         
     | 
| 
       130 
124 
     | 
    
         
             
                } while(0)
         
     | 
| 
       131 
125 
     | 
    
         | 
| 
       132 
126 
     | 
    
         
             
            /* Generate a call to a function FUNC which returns an int; -1 indicates
         
     | 
| 
         @@ -136,20 +130,82 @@ VALUE create_error(VALUE error, const char* method, const char* msg, 
     | 
|
| 
       136 
130 
     | 
    
         
             
                do {                                                                \
         
     | 
| 
       137 
131 
     | 
    
         
             
                    int _r_##func;                                                  \
         
     | 
| 
       138 
132 
     | 
    
         
             
                    _r_##func = func(args);                                         \
         
     | 
| 
       139 
     | 
    
         
            -
                    _E(_r_##func < 0, create_error(e_Error, #func,  
     | 
| 
      
 133 
     | 
    
         
            +
                    _E(_r_##func < 0, create_error(e_Error, #func, conn));          \
         
     | 
| 
       140 
134 
     | 
    
         
             
                    return _r_##func ? Qtrue : Qfalse;                              \
         
     | 
| 
       141 
135 
     | 
    
         
             
                } while(0)
         
     | 
| 
       142 
136 
     | 
    
         | 
| 
      
 137 
     | 
    
         
            +
            /* Generate a call to a function FUNC which returns an int error, where -1
         
     | 
| 
      
 138 
     | 
    
         
            +
             * indicates error and >= 0 success. The Ruby function will return the integer
         
     | 
| 
      
 139 
     | 
    
         
            +
             * success and throw an exception on error.
         
     | 
| 
      
 140 
     | 
    
         
            +
             */
         
     | 
| 
      
 141 
     | 
    
         
            +
            #define gen_call_int(func, conn, args...)                               \
         
     | 
| 
      
 142 
     | 
    
         
            +
                do {                                                                \
         
     | 
| 
      
 143 
     | 
    
         
            +
                    int _r_##func;                                                  \
         
     | 
| 
      
 144 
     | 
    
         
            +
                    _r_##func = func(args);                                         \
         
     | 
| 
      
 145 
     | 
    
         
            +
                    _E(_r_##func < 0, create_error(e_RetrieveError, #func, conn));  \
         
     | 
| 
      
 146 
     | 
    
         
            +
                    return INT2NUM(_r_##func);                                      \
         
     | 
| 
      
 147 
     | 
    
         
            +
                } while(0)
         
     | 
| 
      
 148 
     | 
    
         
            +
             
     | 
| 
       143 
149 
     | 
    
         
             
            /* Error handling */
         
     | 
| 
       144 
150 
     | 
    
         
             
            #define _E(cond, excep) \
         
     | 
| 
       145 
151 
     | 
    
         
             
                do { if (cond) rb_exc_raise(excep); } while(0)
         
     | 
| 
       146 
152 
     | 
    
         | 
| 
      
 153 
     | 
    
         
            +
            int is_symbol_or_proc(VALUE handle);
         
     | 
| 
      
 154 
     | 
    
         
            +
             
     | 
| 
       147 
155 
     | 
    
         
             
            extern VALUE e_RetrieveError;
         
     | 
| 
       148 
156 
     | 
    
         
             
            extern VALUE e_Error;
         
     | 
| 
       149 
157 
     | 
    
         
             
            extern VALUE e_DefinitionError;
         
     | 
| 
      
 158 
     | 
    
         
            +
            extern VALUE e_NoSupportError;
         
     | 
| 
       150 
159 
     | 
    
         | 
| 
       151 
160 
     | 
    
         
             
            extern VALUE m_libvirt;
         
     | 
| 
       152 
161 
     | 
    
         | 
| 
       153 
162 
     | 
    
         
             
            char *get_string_or_nil(VALUE arg);
         
     | 
| 
       154 
163 
     | 
    
         | 
| 
      
 164 
     | 
    
         
            +
            struct rb_ary_entry_arg {
         
     | 
| 
      
 165 
     | 
    
         
            +
                VALUE arr;
         
     | 
| 
      
 166 
     | 
    
         
            +
                int elem;
         
     | 
| 
      
 167 
     | 
    
         
            +
            };
         
     | 
| 
      
 168 
     | 
    
         
            +
            VALUE rb_ary_entry_wrap(VALUE arg);
         
     | 
| 
      
 169 
     | 
    
         
            +
            VALUE rb_ary_new_wrap(VALUE arg);
         
     | 
| 
      
 170 
     | 
    
         
            +
            struct rb_ary_push_arg {
         
     | 
| 
      
 171 
     | 
    
         
            +
                VALUE arr;
         
     | 
| 
      
 172 
     | 
    
         
            +
                VALUE value;
         
     | 
| 
      
 173 
     | 
    
         
            +
            };
         
     | 
| 
      
 174 
     | 
    
         
            +
            VALUE rb_ary_push_wrap(VALUE arg);
         
     | 
| 
      
 175 
     | 
    
         
            +
            VALUE rb_ary_new2_wrap(VALUE arg);
         
     | 
| 
      
 176 
     | 
    
         
            +
             
     | 
| 
      
 177 
     | 
    
         
            +
            VALUE rb_str_new2_wrap(VALUE arg);
         
     | 
| 
      
 178 
     | 
    
         
            +
            struct rb_str_new_arg {
         
     | 
| 
      
 179 
     | 
    
         
            +
                char *val;
         
     | 
| 
      
 180 
     | 
    
         
            +
                size_t size;
         
     | 
| 
      
 181 
     | 
    
         
            +
            };
         
     | 
| 
      
 182 
     | 
    
         
            +
            VALUE rb_str_new_wrap(VALUE arg);
         
     | 
| 
      
 183 
     | 
    
         
            +
            VALUE rb_string_value_cstr_wrap(VALUE arg);
         
     | 
| 
      
 184 
     | 
    
         
            +
             
     | 
| 
      
 185 
     | 
    
         
            +
            struct rb_iv_set_arg {
         
     | 
| 
      
 186 
     | 
    
         
            +
                VALUE klass;
         
     | 
| 
      
 187 
     | 
    
         
            +
                char *member;
         
     | 
| 
      
 188 
     | 
    
         
            +
                VALUE value;
         
     | 
| 
      
 189 
     | 
    
         
            +
            };
         
     | 
| 
      
 190 
     | 
    
         
            +
            VALUE rb_iv_set_wrap(VALUE arg);
         
     | 
| 
      
 191 
     | 
    
         
            +
             
     | 
| 
      
 192 
     | 
    
         
            +
            struct rb_class_new_instance_arg {
         
     | 
| 
      
 193 
     | 
    
         
            +
                int argc;
         
     | 
| 
      
 194 
     | 
    
         
            +
                VALUE *argv;
         
     | 
| 
      
 195 
     | 
    
         
            +
                VALUE klass;
         
     | 
| 
      
 196 
     | 
    
         
            +
            };
         
     | 
| 
      
 197 
     | 
    
         
            +
            VALUE rb_class_new_instance_wrap(VALUE arg);
         
     | 
| 
      
 198 
     | 
    
         
            +
             
     | 
| 
      
 199 
     | 
    
         
            +
            #ifndef RARRAY_LEN
         
     | 
| 
      
 200 
     | 
    
         
            +
            #define RARRAY_LEN(ar) (RARRAY(ar)->len)
         
     | 
| 
      
 201 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 202 
     | 
    
         
            +
             
     | 
| 
      
 203 
     | 
    
         
            +
            #ifndef RSTRING_PTR
         
     | 
| 
      
 204 
     | 
    
         
            +
            #define RSTRING_PTR(str) (RSTRING(str)->ptr)
         
     | 
| 
      
 205 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 206 
     | 
    
         
            +
             
     | 
| 
      
 207 
     | 
    
         
            +
            #ifndef RSTRING_LEN
         
     | 
| 
      
 208 
     | 
    
         
            +
            #define RSTRING_LEN(str) (RSTRING(str)->len)
         
     | 
| 
      
 209 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 210 
     | 
    
         
            +
             
     | 
| 
       155 
211 
     | 
    
         
             
            #endif
         
     | 
    
        data/ext/libvirt/connect.c
    CHANGED
    
    | 
         @@ -23,8 +23,15 @@ 
     | 
|
| 
       23 
23 
     | 
    
         
             
            #include <libvirt/virterror.h>
         
     | 
| 
       24 
24 
     | 
    
         
             
            #include "extconf.h"
         
     | 
| 
       25 
25 
     | 
    
         
             
            #include "common.h"
         
     | 
| 
      
 26 
     | 
    
         
            +
            #include "domain.h"
         
     | 
| 
      
 27 
     | 
    
         
            +
            #include "interface.h"
         
     | 
| 
      
 28 
     | 
    
         
            +
            #include "network.h"
         
     | 
| 
      
 29 
     | 
    
         
            +
            #include "nodedevice.h"
         
     | 
| 
      
 30 
     | 
    
         
            +
            #include "nwfilter.h"
         
     | 
| 
      
 31 
     | 
    
         
            +
            #include "secret.h"
         
     | 
| 
      
 32 
     | 
    
         
            +
            #include "storage.h"
         
     | 
| 
       26 
33 
     | 
    
         | 
| 
       27 
     | 
    
         
            -
            VALUE c_connect;
         
     | 
| 
      
 34 
     | 
    
         
            +
            static VALUE c_connect;
         
     | 
| 
       28 
35 
     | 
    
         
             
            static VALUE c_node_security_model;
         
     | 
| 
       29 
36 
     | 
    
         
             
            static VALUE c_node_info;
         
     | 
| 
       30 
37 
     | 
    
         | 
| 
         @@ -34,8 +41,7 @@ static void connect_close(void *p) { 
     | 
|
| 
       34 
41 
     | 
    
         
             
                if (!p)
         
     | 
| 
       35 
42 
     | 
    
         
             
                    return;
         
     | 
| 
       36 
43 
     | 
    
         
             
                r = virConnectClose((virConnectPtr) p);
         
     | 
| 
       37 
     | 
    
         
            -
                _E(r < 0, create_error(rb_eSystemCallError, "virConnectClose",
         
     | 
| 
       38 
     | 
    
         
            -
                                       "Connection close failed", p));
         
     | 
| 
      
 44 
     | 
    
         
            +
                _E(r < 0, create_error(rb_eSystemCallError, "virConnectClose", p));
         
     | 
| 
       39 
45 
     | 
    
         
             
            }
         
     | 
| 
       40 
46 
     | 
    
         | 
| 
       41 
47 
     | 
    
         
             
            VALUE connect_new(virConnectPtr p) {
         
     | 
| 
         @@ -70,7 +76,8 @@ virConnectPtr conn(VALUE s) { 
     | 
|
| 
       70 
76 
     | 
    
         
             
             * call-seq:
         
     | 
| 
       71 
77 
     | 
    
         
             
             *   conn.close -> nil
         
     | 
| 
       72 
78 
     | 
    
         
             
             *
         
     | 
| 
       73 
     | 
    
         
            -
             *  
     | 
| 
      
 79 
     | 
    
         
            +
             * Call +virConnectClose+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectClose]
         
     | 
| 
      
 80 
     | 
    
         
            +
             * to close the connection.
         
     | 
| 
       74 
81 
     | 
    
         
             
             */
         
     | 
| 
       75 
82 
     | 
    
         
             
            static VALUE libvirt_conn_close(VALUE s) {
         
     | 
| 
       76 
83 
     | 
    
         
             
                virConnectPtr conn;
         
     | 
| 
         @@ -86,7 +93,7 @@ static VALUE libvirt_conn_close(VALUE s) { 
     | 
|
| 
       86 
93 
     | 
    
         
             
             * call-seq:
         
     | 
| 
       87 
94 
     | 
    
         
             
             *   conn.closed? -> [True|False]
         
     | 
| 
       88 
95 
     | 
    
         
             
             *
         
     | 
| 
       89 
     | 
    
         
            -
             * Return +true+ if the connection is closed, +false+ if it is open
         
     | 
| 
      
 96 
     | 
    
         
            +
             * Return +true+ if the connection is closed, +false+ if it is open.
         
     | 
| 
       90 
97 
     | 
    
         
             
             */
         
     | 
| 
       91 
98 
     | 
    
         
             
            static VALUE libvirt_conn_closed_p(VALUE s) {
         
     | 
| 
       92 
99 
     | 
    
         
             
                virConnectPtr conn;
         
     | 
| 
         @@ -100,6 +107,7 @@ static VALUE libvirt_conn_closed_p(VALUE s) { 
     | 
|
| 
       100 
107 
     | 
    
         
             
             *   conn.type -> string
         
     | 
| 
       101 
108 
     | 
    
         
             
             *
         
     | 
| 
       102 
109 
     | 
    
         
             
             * Call +virConnectGetType+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectGetType]
         
     | 
| 
      
 110 
     | 
    
         
            +
             * to retrieve the type of hypervisor for this connection.
         
     | 
| 
       103 
111 
     | 
    
         
             
             */
         
     | 
| 
       104 
112 
     | 
    
         
             
            static VALUE libvirt_conn_type(VALUE s) {
         
     | 
| 
       105 
113 
     | 
    
         
             
                gen_call_string(virConnectGetType, conn(s), 0, connect_get(s));
         
     | 
| 
         @@ -110,6 +118,7 @@ static VALUE libvirt_conn_type(VALUE s) { 
     | 
|
| 
       110 
118 
     | 
    
         
             
             *   conn.version -> fixnum
         
     | 
| 
       111 
119 
     | 
    
         
             
             *
         
     | 
| 
       112 
120 
     | 
    
         
             
             * Call +virConnectGetVersion+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectGetVersion]
         
     | 
| 
      
 121 
     | 
    
         
            +
             * to retrieve the version of the hypervisor for this connection.
         
     | 
| 
       113 
122 
     | 
    
         
             
             */
         
     | 
| 
       114 
123 
     | 
    
         
             
            static VALUE libvirt_conn_version(VALUE s) {
         
     | 
| 
       115 
124 
     | 
    
         
             
                int r;
         
     | 
| 
         @@ -117,7 +126,7 @@ static VALUE libvirt_conn_version(VALUE s) { 
     | 
|
| 
       117 
126 
     | 
    
         
             
                virConnectPtr conn = connect_get(s);
         
     | 
| 
       118 
127 
     | 
    
         | 
| 
       119 
128 
     | 
    
         
             
                r = virConnectGetVersion(conn, &v);
         
     | 
| 
       120 
     | 
    
         
            -
                _E(r < 0, create_error(e_RetrieveError, "virConnectGetVersion",  
     | 
| 
      
 129 
     | 
    
         
            +
                _E(r < 0, create_error(e_RetrieveError, "virConnectGetVersion", conn));
         
     | 
| 
       121 
130 
     | 
    
         | 
| 
       122 
131 
     | 
    
         
             
                return ULONG2NUM(v);
         
     | 
| 
       123 
132 
     | 
    
         
             
            }
         
     | 
| 
         @@ -128,6 +137,7 @@ static VALUE libvirt_conn_version(VALUE s) { 
     | 
|
| 
       128 
137 
     | 
    
         
             
             *   conn.libversion -> fixnum
         
     | 
| 
       129 
138 
     | 
    
         
             
             *
         
     | 
| 
       130 
139 
     | 
    
         
             
             * Call +virConnectGetLibVersion+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectGetLibVersion]
         
     | 
| 
      
 140 
     | 
    
         
            +
             * to retrieve the version of the libvirt library for this connection.
         
     | 
| 
       131 
141 
     | 
    
         
             
             */
         
     | 
| 
       132 
142 
     | 
    
         
             
            static VALUE libvirt_conn_libversion(VALUE s) {
         
     | 
| 
       133 
143 
     | 
    
         
             
                int r;
         
     | 
| 
         @@ -135,8 +145,7 @@ static VALUE libvirt_conn_libversion(VALUE s) { 
     | 
|
| 
       135 
145 
     | 
    
         
             
                virConnectPtr conn = connect_get(s);
         
     | 
| 
       136 
146 
     | 
    
         | 
| 
       137 
147 
     | 
    
         
             
                r = virConnectGetLibVersion(conn, &v);
         
     | 
| 
       138 
     | 
    
         
            -
                _E(r < 0, create_error(e_RetrieveError, "virConnectGetLibVersion",
         
     | 
| 
       139 
     | 
    
         
            -
                                       "", conn));
         
     | 
| 
      
 148 
     | 
    
         
            +
                _E(r < 0, create_error(e_RetrieveError, "virConnectGetLibVersion", conn));
         
     | 
| 
       140 
149 
     | 
    
         | 
| 
       141 
150 
     | 
    
         
             
                return ULONG2NUM(v);
         
     | 
| 
       142 
151 
     | 
    
         
             
            }
         
     | 
| 
         @@ -147,6 +156,7 @@ static VALUE libvirt_conn_libversion(VALUE s) { 
     | 
|
| 
       147 
156 
     | 
    
         
             
             *   conn.hostname -> string
         
     | 
| 
       148 
157 
     | 
    
         
             
             *
         
     | 
| 
       149 
158 
     | 
    
         
             
             * Call +virConnectGetHostname+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectGetHostname]
         
     | 
| 
      
 159 
     | 
    
         
            +
             * to retrieve the hostname of the hypervisor for this connection.
         
     | 
| 
       150 
160 
     | 
    
         
             
             */
         
     | 
| 
       151 
161 
     | 
    
         
             
            static VALUE libvirt_conn_hostname(VALUE s) {
         
     | 
| 
       152 
162 
     | 
    
         
             
                gen_call_string(virConnectGetHostname, conn(s), 1, connect_get(s));
         
     | 
| 
         @@ -157,6 +167,7 @@ static VALUE libvirt_conn_hostname(VALUE s) { 
     | 
|
| 
       157 
167 
     | 
    
         
             
             *   conn.uri -> string
         
     | 
| 
       158 
168 
     | 
    
         
             
             *
         
     | 
| 
       159 
169 
     | 
    
         
             
             * Call +virConnectGetURI+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectGetURI]
         
     | 
| 
      
 170 
     | 
    
         
            +
             * to retrieve the canonical URI for this connection.
         
     | 
| 
       160 
171 
     | 
    
         
             
             */
         
     | 
| 
       161 
172 
     | 
    
         
             
            static VALUE libvirt_conn_uri(VALUE s) {
         
     | 
| 
       162 
173 
     | 
    
         
             
                gen_call_string(virConnectGetURI, conn(s), 1, connect_get(s));
         
     | 
| 
         @@ -164,22 +175,19 @@ static VALUE libvirt_conn_uri(VALUE s) { 
     | 
|
| 
       164 
175 
     | 
    
         | 
| 
       165 
176 
     | 
    
         
             
            /*
         
     | 
| 
       166 
177 
     | 
    
         
             
             * call-seq:
         
     | 
| 
       167 
     | 
    
         
            -
             *   conn.max_vcpus -> fixnum
         
     | 
| 
      
 178 
     | 
    
         
            +
             *   conn.max_vcpus(type=nil) -> fixnum
         
     | 
| 
       168 
179 
     | 
    
         
             
             *
         
     | 
| 
       169 
180 
     | 
    
         
             
             * Call +virConnectGetMaxVcpus+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectGetMaxVcpus]
         
     | 
| 
      
 181 
     | 
    
         
            +
             * to retrieve the maximum number of virtual cpus supported by the hypervisor
         
     | 
| 
      
 182 
     | 
    
         
            +
             * for this connection.
         
     | 
| 
       170 
183 
     | 
    
         
             
             */
         
     | 
| 
       171 
184 
     | 
    
         
             
            static VALUE libvirt_conn_max_vcpus(int argc, VALUE *argv, VALUE s) {
         
     | 
| 
       172 
     | 
    
         
            -
                int result;
         
     | 
| 
       173 
     | 
    
         
            -
                virConnectPtr conn = connect_get(s);
         
     | 
| 
       174 
185 
     | 
    
         
             
                VALUE type;
         
     | 
| 
       175 
186 
     | 
    
         | 
| 
       176 
187 
     | 
    
         
             
                rb_scan_args(argc, argv, "01", &type);
         
     | 
| 
       177 
188 
     | 
    
         | 
| 
       178 
     | 
    
         
            -
                 
     | 
| 
       179 
     | 
    
         
            -
             
     | 
| 
       180 
     | 
    
         
            -
                                            "", conn));
         
     | 
| 
       181 
     | 
    
         
            -
             
     | 
| 
       182 
     | 
    
         
            -
                return INT2NUM(result);
         
     | 
| 
      
 189 
     | 
    
         
            +
                gen_call_int(virConnectGetMaxVcpus, conn(s), connect_get(s),
         
     | 
| 
      
 190 
     | 
    
         
            +
                             get_string_or_nil(type));
         
     | 
| 
       183 
191 
     | 
    
         
             
            }
         
     | 
| 
       184 
192 
     | 
    
         | 
| 
       185 
193 
     | 
    
         
             
            /*
         
     | 
| 
         @@ -187,6 +195,7 @@ static VALUE libvirt_conn_max_vcpus(int argc, VALUE *argv, VALUE s) { 
     | 
|
| 
       187 
195 
     | 
    
         
             
             *   conn.node_get_info -> Libvirt::Connect::Nodeinfo
         
     | 
| 
       188 
196 
     | 
    
         
             
             *
         
     | 
| 
       189 
197 
     | 
    
         
             
             * Call +virNodeGetInfo+[http://www.libvirt.org/html/libvirt-libvirt.html#virNodeGetInfo]
         
     | 
| 
      
 198 
     | 
    
         
            +
             * to retrieve information about the node for this connection.
         
     | 
| 
       190 
199 
     | 
    
         
             
             */
         
     | 
| 
       191 
200 
     | 
    
         
             
            static VALUE libvirt_conn_node_get_info(VALUE s) {
         
     | 
| 
       192 
201 
     | 
    
         
             
                int r;
         
     | 
| 
         @@ -195,7 +204,7 @@ static VALUE libvirt_conn_node_get_info(VALUE s) { 
     | 
|
| 
       195 
204 
     | 
    
         
             
                VALUE result;
         
     | 
| 
       196 
205 
     | 
    
         | 
| 
       197 
206 
     | 
    
         
             
                r = virNodeGetInfo(conn, &nodeinfo);
         
     | 
| 
       198 
     | 
    
         
            -
                _E(r < 0, create_error(e_RetrieveError, "virNodeGetInfo",  
     | 
| 
      
 207 
     | 
    
         
            +
                _E(r < 0, create_error(e_RetrieveError, "virNodeGetInfo", conn));
         
     | 
| 
       199 
208 
     | 
    
         | 
| 
       200 
209 
     | 
    
         
             
                result = rb_class_new_instance(0, NULL, c_node_info);
         
     | 
| 
       201 
210 
     | 
    
         
             
                rb_iv_set(result, "@model", rb_str_new2(nodeinfo.model));
         
     | 
| 
         @@ -215,63 +224,78 @@ static VALUE libvirt_conn_node_get_info(VALUE s) { 
     | 
|
| 
       215 
224 
     | 
    
         
             
             *   conn.node_free_memory -> fixnum
         
     | 
| 
       216 
225 
     | 
    
         
             
             *
         
     | 
| 
       217 
226 
     | 
    
         
             
             * Call +virNodeGetFreeMemory+[http://www.libvirt.org/html/libvirt-libvirt.html#virNodeGetFreeMemory]
         
     | 
| 
      
 227 
     | 
    
         
            +
             * to retrieve the amount of free memory available on the host for this
         
     | 
| 
      
 228 
     | 
    
         
            +
             * connection.
         
     | 
| 
       218 
229 
     | 
    
         
             
             */
         
     | 
| 
       219 
230 
     | 
    
         
             
            static VALUE libvirt_conn_node_free_memory(VALUE s) {
         
     | 
| 
       220 
231 
     | 
    
         
             
                virConnectPtr conn = connect_get(s);
         
     | 
| 
       221 
232 
     | 
    
         
             
                unsigned long long freemem;
         
     | 
| 
       222 
233 
     | 
    
         | 
| 
       223 
234 
     | 
    
         
             
                freemem = virNodeGetFreeMemory(conn);
         
     | 
| 
      
 235 
     | 
    
         
            +
             
     | 
| 
       224 
236 
     | 
    
         
             
                _E(freemem == 0, create_error(e_RetrieveError, "virNodeGetFreeMemory",
         
     | 
| 
       225 
     | 
    
         
            -
                                               
     | 
| 
      
 237 
     | 
    
         
            +
                                              conn));
         
     | 
| 
       226 
238 
     | 
    
         | 
| 
       227 
239 
     | 
    
         
             
                return ULL2NUM(freemem);
         
     | 
| 
       228 
240 
     | 
    
         
             
            }
         
     | 
| 
       229 
241 
     | 
    
         | 
| 
       230 
242 
     | 
    
         
             
            /*
         
     | 
| 
       231 
243 
     | 
    
         
             
             * call-seq:
         
     | 
| 
       232 
     | 
    
         
            -
             *   conn.node_cells_free_memory -> list
         
     | 
| 
      
 244 
     | 
    
         
            +
             *   conn.node_cells_free_memory(startCell=0, maxCells=#nodeCells) -> list
         
     | 
| 
       233 
245 
     | 
    
         
             
             *
         
     | 
| 
       234 
246 
     | 
    
         
             
             * Call +virNodeGetCellsFreeMemory+[http://www.libvirt.org/html/libvirt-libvirt.html#virNodeGetCellsFreeMemory]
         
     | 
| 
      
 247 
     | 
    
         
            +
             * to retrieve the amount of free memory in each NUMA cell on the host for
         
     | 
| 
      
 248 
     | 
    
         
            +
             * this connection.
         
     | 
| 
       235 
249 
     | 
    
         
             
             */
         
     | 
| 
       236 
250 
     | 
    
         
             
            static VALUE libvirt_conn_node_cells_free_memory(int argc, VALUE *argv, VALUE s) {
         
     | 
| 
       237 
251 
     | 
    
         
             
                int r;
         
     | 
| 
       238 
252 
     | 
    
         
             
                virConnectPtr conn = connect_get(s);
         
     | 
| 
       239 
253 
     | 
    
         
             
                VALUE cells;
         
     | 
| 
       240 
     | 
    
         
            -
                VALUE  
     | 
| 
      
 254 
     | 
    
         
            +
                VALUE start, max;
         
     | 
| 
       241 
255 
     | 
    
         
             
                unsigned long long *freeMems;
         
     | 
| 
       242 
256 
     | 
    
         
             
                virNodeInfo nodeinfo;
         
     | 
| 
       243 
257 
     | 
    
         
             
                int i;
         
     | 
| 
      
 258 
     | 
    
         
            +
                unsigned int startCell, maxCells;
         
     | 
| 
      
 259 
     | 
    
         
            +
             
     | 
| 
      
 260 
     | 
    
         
            +
                rb_scan_args(argc, argv, "02", &start, &max);
         
     | 
| 
       244 
261 
     | 
    
         | 
| 
       245 
     | 
    
         
            -
                 
     | 
| 
      
 262 
     | 
    
         
            +
                if (NIL_P(start))
         
     | 
| 
      
 263 
     | 
    
         
            +
                    startCell = 0;
         
     | 
| 
      
 264 
     | 
    
         
            +
                else
         
     | 
| 
      
 265 
     | 
    
         
            +
                    startCell = NUM2UINT(start);
         
     | 
| 
       246 
266 
     | 
    
         | 
| 
       247 
     | 
    
         
            -
                if (NIL_P( 
     | 
| 
       248 
     | 
    
         
            -
                    startCell = INT2FIX(0);
         
     | 
| 
       249 
     | 
    
         
            -
                if (NIL_P(maxCells)) {
         
     | 
| 
      
 267 
     | 
    
         
            +
                if (NIL_P(max)) {
         
     | 
| 
       250 
268 
     | 
    
         
             
                    r = virNodeGetInfo(conn, &nodeinfo);
         
     | 
| 
       251 
     | 
    
         
            -
                    _E(r < 0, create_error(e_RetrieveError, "virNodeGetInfo",  
     | 
| 
       252 
     | 
    
         
            -
                     
     | 
| 
       253 
     | 
    
         
            -
                    maxCells = INT2FIX(nodeinfo.nodes);
         
     | 
| 
      
 269 
     | 
    
         
            +
                    _E(r < 0, create_error(e_RetrieveError, "virNodeGetInfo", conn));
         
     | 
| 
      
 270 
     | 
    
         
            +
                    maxCells = nodeinfo.nodes;
         
     | 
| 
       254 
271 
     | 
    
         
             
                }
         
     | 
| 
       255 
272 
     | 
    
         
             
                else
         
     | 
| 
       256 
     | 
    
         
            -
                     
     | 
| 
      
 273 
     | 
    
         
            +
                    maxCells = NUM2UINT(max);
         
     | 
| 
      
 274 
     | 
    
         
            +
             
     | 
| 
      
 275 
     | 
    
         
            +
                freeMems = ALLOC_N(unsigned long long, maxCells);
         
     | 
| 
       257 
276 
     | 
    
         | 
| 
       258 
     | 
    
         
            -
                r = virNodeGetCellsFreeMemory(conn, freeMems,  
     | 
| 
       259 
     | 
    
         
            -
             
     | 
| 
       260 
     | 
    
         
            -
             
     | 
| 
      
 277 
     | 
    
         
            +
                r = virNodeGetCellsFreeMemory(conn, freeMems, startCell, maxCells);
         
     | 
| 
      
 278 
     | 
    
         
            +
                if (r < 0) {
         
     | 
| 
      
 279 
     | 
    
         
            +
                    xfree(freeMems);
         
     | 
| 
      
 280 
     | 
    
         
            +
                    rb_exc_raise(create_error(e_RetrieveError, "virNodeGetCellsFreeMemory",
         
     | 
| 
      
 281 
     | 
    
         
            +
                                              conn));
         
     | 
| 
      
 282 
     | 
    
         
            +
                }
         
     | 
| 
       261 
283 
     | 
    
         | 
| 
       262 
284 
     | 
    
         
             
                cells = rb_ary_new2(r);
         
     | 
| 
       263 
285 
     | 
    
         
             
                for (i = 0; i < r; i++)
         
     | 
| 
       264 
286 
     | 
    
         
             
                    rb_ary_push(cells, ULL2NUM(freeMems[i]));
         
     | 
| 
       265 
     | 
    
         
            -
                 
     | 
| 
      
 287 
     | 
    
         
            +
                xfree(freeMems);
         
     | 
| 
       266 
288 
     | 
    
         | 
| 
       267 
289 
     | 
    
         
             
                return cells;
         
     | 
| 
       268 
290 
     | 
    
         
             
            }
         
     | 
| 
       269 
291 
     | 
    
         | 
| 
      
 292 
     | 
    
         
            +
            #if HAVE_VIRNODEGETSECURITYMODEL
         
     | 
| 
       270 
293 
     | 
    
         
             
            /*
         
     | 
| 
       271 
294 
     | 
    
         
             
             * call-seq:
         
     | 
| 
       272 
295 
     | 
    
         
             
             *   conn.node_get_security_model -> Libvirt::Connect::NodeSecurityModel
         
     | 
| 
       273 
296 
     | 
    
         
             
             *
         
     | 
| 
       274 
     | 
    
         
            -
             * Call + 
     | 
| 
      
 297 
     | 
    
         
            +
             * Call +virNodeGetSecurityModel+[http://www.libvirt.org/html/libvirt-libvirt.html#virNodeGetSecurityModel]
         
     | 
| 
      
 298 
     | 
    
         
            +
             * to retrieve the security model in use on the host for this connection.
         
     | 
| 
       275 
299 
     | 
    
         
             
             */
         
     | 
| 
       276 
300 
     | 
    
         
             
            static VALUE libvirt_conn_node_get_security_model(VALUE s) {
         
     | 
| 
       277 
301 
     | 
    
         
             
                virSecurityModel secmodel;
         
     | 
| 
         @@ -280,7 +304,7 @@ static VALUE libvirt_conn_node_get_security_model(VALUE s) { 
     | 
|
| 
       280 
304 
     | 
    
         
             
                VALUE result;
         
     | 
| 
       281 
305 
     | 
    
         | 
| 
       282 
306 
     | 
    
         
             
                r = virNodeGetSecurityModel(conn, &secmodel);
         
     | 
| 
       283 
     | 
    
         
            -
                _E(r < 0, create_error(e_RetrieveError, "virNodeGetSecurityModel",  
     | 
| 
      
 307 
     | 
    
         
            +
                _E(r < 0, create_error(e_RetrieveError, "virNodeGetSecurityModel", conn));
         
     | 
| 
       284 
308 
     | 
    
         | 
| 
       285 
309 
     | 
    
         
             
                result = rb_class_new_instance(0, NULL, c_node_security_model);
         
     | 
| 
       286 
310 
     | 
    
         
             
                rb_iv_set(result, "@model", rb_str_new2(secmodel.model));
         
     | 
| 
         @@ -288,13 +312,15 @@ static VALUE libvirt_conn_node_get_security_model(VALUE s) { 
     | 
|
| 
       288 
312 
     | 
    
         | 
| 
       289 
313 
     | 
    
         
             
                return result;
         
     | 
| 
       290 
314 
     | 
    
         
             
            }
         
     | 
| 
      
 315 
     | 
    
         
            +
            #endif
         
     | 
| 
       291 
316 
     | 
    
         | 
| 
       292 
317 
     | 
    
         
             
            #if HAVE_VIRCONNECTISENCRYPTED
         
     | 
| 
       293 
318 
     | 
    
         
             
            /*
         
     | 
| 
       294 
319 
     | 
    
         
             
             * call-seq:
         
     | 
| 
       295 
     | 
    
         
            -
             *   conn.encrypted?
         
     | 
| 
      
 320 
     | 
    
         
            +
             *   conn.encrypted? -> [True|False]
         
     | 
| 
       296 
321 
     | 
    
         
             
             *
         
     | 
| 
       297 
     | 
    
         
            -
             *  
     | 
| 
      
 322 
     | 
    
         
            +
             * Call +virConnectIsEncrypted+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectIsEncrypted]
         
     | 
| 
      
 323 
     | 
    
         
            +
             * to determine if the connection is encrypted.
         
     | 
| 
       298 
324 
     | 
    
         
             
             */
         
     | 
| 
       299 
325 
     | 
    
         
             
            static VALUE libvirt_conn_encrypted_p(VALUE s) {
         
     | 
| 
       300 
326 
     | 
    
         
             
                gen_call_truefalse(virConnectIsEncrypted, conn(s), connect_get(s));
         
     | 
| 
         @@ -304,9 +330,10 @@ static VALUE libvirt_conn_encrypted_p(VALUE s) { 
     | 
|
| 
       304 
330 
     | 
    
         
             
            #if HAVE_VIRCONNECTISSECURE
         
     | 
| 
       305 
331 
     | 
    
         
             
            /*
         
     | 
| 
       306 
332 
     | 
    
         
             
             * call-seq:
         
     | 
| 
       307 
     | 
    
         
            -
             *   conn.secure?
         
     | 
| 
      
 333 
     | 
    
         
            +
             *   conn.secure? -> [True|False]
         
     | 
| 
       308 
334 
     | 
    
         
             
             *
         
     | 
| 
       309 
     | 
    
         
            -
             *  
     | 
| 
      
 335 
     | 
    
         
            +
             * Call +virConnectIsSecure+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectIsSecure]
         
     | 
| 
      
 336 
     | 
    
         
            +
             * to determine if the connection is secure.
         
     | 
| 
       310 
337 
     | 
    
         
             
             */
         
     | 
| 
       311 
338 
     | 
    
         
             
            static VALUE libvirt_conn_secure_p(VALUE s) {
         
     | 
| 
       312 
339 
     | 
    
         
             
                gen_call_truefalse(virConnectIsSecure, conn(s), connect_get(s));
         
     | 
| 
         @@ -318,75 +345,1764 @@ static VALUE libvirt_conn_secure_p(VALUE s) { 
     | 
|
| 
       318 
345 
     | 
    
         
             
             *   conn.capabilities -> string
         
     | 
| 
       319 
346 
     | 
    
         
             
             *
         
     | 
| 
       320 
347 
     | 
    
         
             
             * Call +virConnectGetCapabilities+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectGetCapabilities]
         
     | 
| 
      
 348 
     | 
    
         
            +
             * to retrieve the capabilities XML for this connection.
         
     | 
| 
       321 
349 
     | 
    
         
             
             */
         
     | 
| 
       322 
350 
     | 
    
         
             
            static VALUE libvirt_conn_capabilities(VALUE s) {
         
     | 
| 
       323 
351 
     | 
    
         
             
                gen_call_string(virConnectGetCapabilities, conn(s), 1, connect_get(s));
         
     | 
| 
       324 
352 
     | 
    
         
             
            }
         
     | 
| 
       325 
353 
     | 
    
         | 
| 
      
 354 
     | 
    
         
            +
            #if HAVE_VIRCONNECTCOMPARECPU
         
     | 
| 
       326 
355 
     | 
    
         
             
            /*
         
     | 
| 
       327 
     | 
    
         
            -
             *  
     | 
| 
      
 356 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 357 
     | 
    
         
            +
             *   conn.compare_cpu(xml, flags=0) -> compareflag
         
     | 
| 
      
 358 
     | 
    
         
            +
             *
         
     | 
| 
      
 359 
     | 
    
         
            +
             * Call +virConnectCompareCPU+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectCompareCPU]
         
     | 
| 
      
 360 
     | 
    
         
            +
             * to compare the host CPU with the XML contained in xml.  Returns one of
         
     | 
| 
      
 361 
     | 
    
         
            +
             * Libvirt::CPU_COMPARE_ERROR, Libvirt::CPU_COMPARE_INCOMPATIBLE,
         
     | 
| 
      
 362 
     | 
    
         
            +
             * Libvirt::CPU_COMPARE_IDENTICAL, or Libvirt::CPU_COMPARE_SUPERSET.
         
     | 
| 
       328 
363 
     | 
    
         
             
             */
         
     | 
| 
       329 
     | 
    
         
            -
             
     | 
| 
       330 
     | 
    
         
            -
             
     | 
| 
       331 
     | 
    
         
            -
                c_connect = rb_define_class_under(m_libvirt, "Connect", rb_cObject);
         
     | 
| 
      
 364 
     | 
    
         
            +
            static VALUE libvirt_conn_compare_cpu(int argc, VALUE *argv, VALUE s) {
         
     | 
| 
      
 365 
     | 
    
         
            +
                VALUE xml, flags;
         
     | 
| 
       332 
366 
     | 
    
         | 
| 
       333 
     | 
    
         
            -
                 
     | 
| 
       334 
     | 
    
         
            -
             
     | 
| 
       335 
     | 
    
         
            -
             
     | 
| 
       336 
     | 
    
         
            -
                c_node_info = rb_define_class_under(c_connect, "Nodeinfo", rb_cObject);
         
     | 
| 
       337 
     | 
    
         
            -
                rb_define_attr(c_node_info, "model", 1, 0);
         
     | 
| 
       338 
     | 
    
         
            -
                rb_define_attr(c_node_info, "memory", 1, 0);
         
     | 
| 
       339 
     | 
    
         
            -
                rb_define_attr(c_node_info, "cpus", 1, 0);
         
     | 
| 
       340 
     | 
    
         
            -
                rb_define_attr(c_node_info, "mhz", 1, 0);
         
     | 
| 
       341 
     | 
    
         
            -
                rb_define_attr(c_node_info, "nodes", 1, 0);
         
     | 
| 
       342 
     | 
    
         
            -
                rb_define_attr(c_node_info, "sockets", 1, 0);
         
     | 
| 
       343 
     | 
    
         
            -
                rb_define_attr(c_node_info, "cores", 1, 0);
         
     | 
| 
       344 
     | 
    
         
            -
                rb_define_attr(c_node_info, "threads", 1, 0);
         
     | 
| 
      
 367 
     | 
    
         
            +
                rb_scan_args(argc, argv, "11", &xml, &flags);
         
     | 
| 
      
 368 
     | 
    
         
            +
                if (NIL_P(flags))
         
     | 
| 
      
 369 
     | 
    
         
            +
                    flags = INT2FIX(0);
         
     | 
| 
       345 
370 
     | 
    
         | 
| 
       346 
     | 
    
         
            -
                 
     | 
| 
       347 
     | 
    
         
            -
             
     | 
| 
       348 
     | 
    
         
            -
             
     | 
| 
       349 
     | 
    
         
            -
             
     | 
| 
       350 
     | 
    
         
            -
                                                              "NodeSecurityModel",
         
     | 
| 
       351 
     | 
    
         
            -
                                                              rb_cObject);
         
     | 
| 
       352 
     | 
    
         
            -
                rb_define_attr(c_node_security_model, "model", 1, 0);
         
     | 
| 
       353 
     | 
    
         
            -
                rb_define_attr(c_node_security_model, "doi", 1, 0);
         
     | 
| 
      
 371 
     | 
    
         
            +
                gen_call_int(virConnectCompareCPU, conn(s), connect_get(s),
         
     | 
| 
      
 372 
     | 
    
         
            +
                             StringValueCStr(xml), NUM2UINT(flags));
         
     | 
| 
      
 373 
     | 
    
         
            +
            }
         
     | 
| 
      
 374 
     | 
    
         
            +
            #endif
         
     | 
| 
       354 
375 
     | 
    
         | 
| 
       355 
     | 
    
         
            -
             
     | 
| 
       356 
     | 
    
         
            -
             
     | 
| 
       357 
     | 
    
         
            -
             
     | 
| 
       358 
     | 
    
         
            -
             
     | 
| 
       359 
     | 
    
         
            -
             
     | 
| 
       360 
     | 
    
         
            -
             
     | 
| 
      
 376 
     | 
    
         
            +
             
     | 
| 
      
 377 
     | 
    
         
            +
            #if HAVE_VIRCONNECTBASELINECPU
         
     | 
| 
      
 378 
     | 
    
         
            +
            /*
         
     | 
| 
      
 379 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 380 
     | 
    
         
            +
             *   conn.baseline_cpu([xml, xml2, ...], flags=0) -> XML
         
     | 
| 
      
 381 
     | 
    
         
            +
             *
         
     | 
| 
      
 382 
     | 
    
         
            +
             * Call +virConnectBaselineCPU+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectBaselineCPU]
         
     | 
| 
      
 383 
     | 
    
         
            +
             * to compare the most feature-rich CPU which is compatible with all
         
     | 
| 
      
 384 
     | 
    
         
            +
             * given host CPUs.
         
     | 
| 
      
 385 
     | 
    
         
            +
             */
         
     | 
| 
      
 386 
     | 
    
         
            +
            static VALUE libvirt_conn_baseline_cpu(int argc, VALUE *argv, VALUE s) {
         
     | 
| 
      
 387 
     | 
    
         
            +
                VALUE xmlcpus, flags_val;
         
     | 
| 
      
 388 
     | 
    
         
            +
                virConnectPtr conn = connect_get(s);
         
     | 
| 
      
 389 
     | 
    
         
            +
                char *r;
         
     | 
| 
      
 390 
     | 
    
         
            +
                VALUE retval;
         
     | 
| 
      
 391 
     | 
    
         
            +
                unsigned int ncpus, flags;
         
     | 
| 
      
 392 
     | 
    
         
            +
                VALUE entry;
         
     | 
| 
      
 393 
     | 
    
         
            +
                const char **xmllist;
         
     | 
| 
      
 394 
     | 
    
         
            +
                int i;
         
     | 
| 
      
 395 
     | 
    
         
            +
                int exception = 0;
         
     | 
| 
      
 396 
     | 
    
         
            +
                struct rb_ary_entry_arg arg;
         
     | 
| 
      
 397 
     | 
    
         
            +
             
     | 
| 
      
 398 
     | 
    
         
            +
                rb_scan_args(argc, argv, "11", &xmlcpus, &flags_val);
         
     | 
| 
      
 399 
     | 
    
         
            +
                if (NIL_P(flags_val))
         
     | 
| 
      
 400 
     | 
    
         
            +
                    flags = 0;
         
     | 
| 
      
 401 
     | 
    
         
            +
                else
         
     | 
| 
      
 402 
     | 
    
         
            +
                    flags = NUM2UINT(flags_val);
         
     | 
| 
      
 403 
     | 
    
         
            +
             
     | 
| 
      
 404 
     | 
    
         
            +
                Check_Type(xmlcpus, T_ARRAY);
         
     | 
| 
      
 405 
     | 
    
         
            +
             
     | 
| 
      
 406 
     | 
    
         
            +
                if (RARRAY_LEN(xmlcpus) < 1)
         
     | 
| 
      
 407 
     | 
    
         
            +
                    rb_raise(rb_eArgError, "wrong number of cpu arguments (%d for 1 or more)",
         
     | 
| 
      
 408 
     | 
    
         
            +
                             RARRAY_LEN(xmlcpus));
         
     | 
| 
      
 409 
     | 
    
         
            +
             
     | 
| 
      
 410 
     | 
    
         
            +
                ncpus = RARRAY_LEN(xmlcpus);
         
     | 
| 
      
 411 
     | 
    
         
            +
                xmllist = ALLOC_N(const char *, ncpus);
         
     | 
| 
      
 412 
     | 
    
         
            +
             
     | 
| 
      
 413 
     | 
    
         
            +
                for (i = 0; i < ncpus; i++) {
         
     | 
| 
      
 414 
     | 
    
         
            +
                    arg.arr = xmlcpus;
         
     | 
| 
      
 415 
     | 
    
         
            +
                    arg.elem = i;
         
     | 
| 
      
 416 
     | 
    
         
            +
                    entry = rb_protect(rb_ary_entry_wrap, (VALUE)&arg, &exception);
         
     | 
| 
      
 417 
     | 
    
         
            +
                    if (exception) {
         
     | 
| 
      
 418 
     | 
    
         
            +
                        xfree(xmllist);
         
     | 
| 
      
 419 
     | 
    
         
            +
                        rb_jump_tag(exception);
         
     | 
| 
      
 420 
     | 
    
         
            +
                    }
         
     | 
| 
      
 421 
     | 
    
         
            +
             
     | 
| 
      
 422 
     | 
    
         
            +
                    xmllist[i] = (char *)rb_protect(rb_string_value_cstr_wrap,
         
     | 
| 
      
 423 
     | 
    
         
            +
                                                    (VALUE)&entry, &exception);
         
     | 
| 
      
 424 
     | 
    
         
            +
                    if (exception) {
         
     | 
| 
      
 425 
     | 
    
         
            +
                        xfree(xmllist);
         
     | 
| 
      
 426 
     | 
    
         
            +
                        rb_jump_tag(exception);
         
     | 
| 
      
 427 
     | 
    
         
            +
                    }
         
     | 
| 
      
 428 
     | 
    
         
            +
                }
         
     | 
| 
      
 429 
     | 
    
         
            +
             
     | 
| 
      
 430 
     | 
    
         
            +
                r = virConnectBaselineCPU(conn, xmllist, ncpus, flags);
         
     | 
| 
      
 431 
     | 
    
         
            +
                xfree(xmllist);
         
     | 
| 
      
 432 
     | 
    
         
            +
                _E(r == NULL, create_error(e_RetrieveError, "virConnectBaselineCPU", conn));
         
     | 
| 
      
 433 
     | 
    
         
            +
             
     | 
| 
      
 434 
     | 
    
         
            +
                retval = rb_protect(rb_str_new2_wrap, (VALUE)&r, &exception);
         
     | 
| 
      
 435 
     | 
    
         
            +
                if (exception) {
         
     | 
| 
      
 436 
     | 
    
         
            +
                    free(r);
         
     | 
| 
      
 437 
     | 
    
         
            +
                    rb_jump_tag(exception);
         
     | 
| 
      
 438 
     | 
    
         
            +
                }
         
     | 
| 
      
 439 
     | 
    
         
            +
             
     | 
| 
      
 440 
     | 
    
         
            +
                free(r);
         
     | 
| 
      
 441 
     | 
    
         
            +
             
     | 
| 
      
 442 
     | 
    
         
            +
                return retval;
         
     | 
| 
      
 443 
     | 
    
         
            +
            }
         
     | 
| 
       361 
444 
     | 
    
         
             
            #endif
         
     | 
| 
       362 
     | 
    
         
            -
             
     | 
| 
       363 
     | 
    
         
            -
             
     | 
| 
       364 
     | 
    
         
            -
             
     | 
| 
       365 
     | 
    
         
            -
             
     | 
| 
       366 
     | 
    
         
            -
             
     | 
| 
       367 
     | 
    
         
            -
             
     | 
| 
       368 
     | 
    
         
            -
                 
     | 
| 
       369 
     | 
    
         
            -
             
     | 
| 
       370 
     | 
    
         
            -
                 
     | 
| 
       371 
     | 
    
         
            -
             
     | 
| 
       372 
     | 
    
         
            -
             
     | 
| 
       373 
     | 
    
         
            -
             
     | 
| 
      
 445 
     | 
    
         
            +
             
     | 
| 
      
 446 
     | 
    
         
            +
            #if HAVE_VIRCONNECTDOMAINEVENTREGISTERANY || HAVE_VIRCONNECTDOMAINEVENTREGISTER
         
     | 
| 
      
 447 
     | 
    
         
            +
            static int domain_event_lifecycle_callback(virConnectPtr conn,
         
     | 
| 
      
 448 
     | 
    
         
            +
                                                       virDomainPtr dom, int event,
         
     | 
| 
      
 449 
     | 
    
         
            +
                                                       int detail, void *opaque) {
         
     | 
| 
      
 450 
     | 
    
         
            +
                VALUE passthrough = (VALUE)opaque;
         
     | 
| 
      
 451 
     | 
    
         
            +
                VALUE cb;
         
     | 
| 
      
 452 
     | 
    
         
            +
                VALUE cb_opaque;
         
     | 
| 
      
 453 
     | 
    
         
            +
                VALUE newc;
         
     | 
| 
      
 454 
     | 
    
         
            +
             
     | 
| 
      
 455 
     | 
    
         
            +
                if (TYPE(passthrough) != T_ARRAY)
         
     | 
| 
      
 456 
     | 
    
         
            +
                    rb_raise(rb_eTypeError,
         
     | 
| 
      
 457 
     | 
    
         
            +
                             "wrong domain event lifecycle callback argument type (expected Array)");
         
     | 
| 
      
 458 
     | 
    
         
            +
             
     | 
| 
      
 459 
     | 
    
         
            +
                cb = rb_ary_entry(passthrough, 0);
         
     | 
| 
      
 460 
     | 
    
         
            +
                cb_opaque = rb_ary_entry(passthrough, 1);
         
     | 
| 
      
 461 
     | 
    
         
            +
             
     | 
| 
      
 462 
     | 
    
         
            +
                newc = connect_new(conn);
         
     | 
| 
      
 463 
     | 
    
         
            +
                if (strcmp(rb_obj_classname(cb), "Symbol") == 0)
         
     | 
| 
      
 464 
     | 
    
         
            +
                    rb_funcall(rb_class_of(cb), rb_to_id(cb), 5, newc,
         
     | 
| 
      
 465 
     | 
    
         
            +
                               domain_new(dom, newc), INT2FIX(event), INT2FIX(detail),
         
     | 
| 
      
 466 
     | 
    
         
            +
                               cb_opaque);
         
     | 
| 
      
 467 
     | 
    
         
            +
                else if (strcmp(rb_obj_classname(cb), "Proc") == 0)
         
     | 
| 
      
 468 
     | 
    
         
            +
                    rb_funcall(cb, rb_intern("call"), 5, newc, domain_new(dom, newc),
         
     | 
| 
      
 469 
     | 
    
         
            +
                               INT2FIX(event), INT2FIX(detail), cb_opaque);
         
     | 
| 
      
 470 
     | 
    
         
            +
                else
         
     | 
| 
      
 471 
     | 
    
         
            +
                    rb_raise(rb_eTypeError,
         
     | 
| 
      
 472 
     | 
    
         
            +
                             "wrong domain event lifecycle callback (expected Symbol or Proc)");
         
     | 
| 
      
 473 
     | 
    
         
            +
             
     | 
| 
      
 474 
     | 
    
         
            +
                return 0;
         
     | 
| 
      
 475 
     | 
    
         
            +
            }
         
     | 
| 
       374 
476 
     | 
    
         
             
            #endif
         
     | 
| 
       375 
     | 
    
         
            -
             
     | 
| 
       376 
     | 
    
         
            -
             
     | 
| 
      
 477 
     | 
    
         
            +
             
     | 
| 
      
 478 
     | 
    
         
            +
            #if HAVE_VIRCONNECTDOMAINEVENTREGISTERANY
         
     | 
| 
      
 479 
     | 
    
         
            +
            static int domain_event_reboot_callback(virConnectPtr conn, virDomainPtr dom,
         
     | 
| 
      
 480 
     | 
    
         
            +
                                                    void *opaque) {
         
     | 
| 
      
 481 
     | 
    
         
            +
                VALUE passthrough = (VALUE)opaque;
         
     | 
| 
      
 482 
     | 
    
         
            +
                VALUE cb;
         
     | 
| 
      
 483 
     | 
    
         
            +
                VALUE cb_opaque;
         
     | 
| 
      
 484 
     | 
    
         
            +
                VALUE newc;
         
     | 
| 
      
 485 
     | 
    
         
            +
             
     | 
| 
      
 486 
     | 
    
         
            +
                if (TYPE(passthrough) != T_ARRAY)
         
     | 
| 
      
 487 
     | 
    
         
            +
                    rb_raise(rb_eTypeError,
         
     | 
| 
      
 488 
     | 
    
         
            +
                             "wrong domain event reboot callback argument type (expected Array)");
         
     | 
| 
      
 489 
     | 
    
         
            +
             
     | 
| 
      
 490 
     | 
    
         
            +
                cb = rb_ary_entry(passthrough, 0);
         
     | 
| 
      
 491 
     | 
    
         
            +
                cb_opaque = rb_ary_entry(passthrough, 1);
         
     | 
| 
      
 492 
     | 
    
         
            +
             
     | 
| 
      
 493 
     | 
    
         
            +
                newc = connect_new(conn);
         
     | 
| 
      
 494 
     | 
    
         
            +
                if (strcmp(rb_obj_classname(cb), "Symbol") == 0)
         
     | 
| 
      
 495 
     | 
    
         
            +
                    rb_funcall(rb_class_of(cb), rb_to_id(cb), 3, newc,
         
     | 
| 
      
 496 
     | 
    
         
            +
                               domain_new(dom, newc), cb_opaque);
         
     | 
| 
      
 497 
     | 
    
         
            +
                else if (strcmp(rb_obj_classname(cb), "Proc") == 0)
         
     | 
| 
      
 498 
     | 
    
         
            +
                    rb_funcall(cb, rb_intern("call"), 3, newc, domain_new(dom, newc),
         
     | 
| 
      
 499 
     | 
    
         
            +
                               cb_opaque);
         
     | 
| 
      
 500 
     | 
    
         
            +
                else
         
     | 
| 
      
 501 
     | 
    
         
            +
                    rb_raise(rb_eTypeError,
         
     | 
| 
      
 502 
     | 
    
         
            +
                             "wrong domain event reboot callback (expected Symbol or Proc)");
         
     | 
| 
      
 503 
     | 
    
         
            +
             
     | 
| 
      
 504 
     | 
    
         
            +
                return 0;
         
     | 
| 
      
 505 
     | 
    
         
            +
            }
         
     | 
| 
      
 506 
     | 
    
         
            +
             
     | 
| 
      
 507 
     | 
    
         
            +
            static int domain_event_rtc_callback(virConnectPtr conn, virDomainPtr dom,
         
     | 
| 
      
 508 
     | 
    
         
            +
                                                 long long utc_offset, void *opaque) {
         
     | 
| 
      
 509 
     | 
    
         
            +
                VALUE passthrough = (VALUE)opaque;
         
     | 
| 
      
 510 
     | 
    
         
            +
                VALUE cb;
         
     | 
| 
      
 511 
     | 
    
         
            +
                VALUE cb_opaque;
         
     | 
| 
      
 512 
     | 
    
         
            +
                VALUE newc;
         
     | 
| 
      
 513 
     | 
    
         
            +
             
     | 
| 
      
 514 
     | 
    
         
            +
                if (TYPE(passthrough) != T_ARRAY)
         
     | 
| 
      
 515 
     | 
    
         
            +
                    rb_raise(rb_eTypeError,
         
     | 
| 
      
 516 
     | 
    
         
            +
                             "wrong domain event rtc callback argument type (expected Array)");
         
     | 
| 
      
 517 
     | 
    
         
            +
             
     | 
| 
      
 518 
     | 
    
         
            +
                cb = rb_ary_entry(passthrough, 0);
         
     | 
| 
      
 519 
     | 
    
         
            +
                cb_opaque = rb_ary_entry(passthrough, 1);
         
     | 
| 
      
 520 
     | 
    
         
            +
             
     | 
| 
      
 521 
     | 
    
         
            +
                newc = connect_new(conn);
         
     | 
| 
      
 522 
     | 
    
         
            +
                if (strcmp(rb_obj_classname(cb), "Symbol") == 0)
         
     | 
| 
      
 523 
     | 
    
         
            +
                    rb_funcall(rb_class_of(cb), rb_to_id(cb), 4, newc,
         
     | 
| 
      
 524 
     | 
    
         
            +
                               domain_new(dom, newc), LL2NUM(utc_offset), cb_opaque);
         
     | 
| 
      
 525 
     | 
    
         
            +
                else if (strcmp(rb_obj_classname(cb), "Proc") == 0)
         
     | 
| 
      
 526 
     | 
    
         
            +
                    rb_funcall(cb, rb_intern("call"), 4, newc, domain_new(dom, newc),
         
     | 
| 
      
 527 
     | 
    
         
            +
                               LL2NUM(utc_offset), cb_opaque);
         
     | 
| 
      
 528 
     | 
    
         
            +
                else
         
     | 
| 
      
 529 
     | 
    
         
            +
                    rb_raise(rb_eTypeError,
         
     | 
| 
      
 530 
     | 
    
         
            +
                             "wrong domain event rtc callback (expected Symbol or Proc)");
         
     | 
| 
      
 531 
     | 
    
         
            +
             
     | 
| 
      
 532 
     | 
    
         
            +
                return 0;
         
     | 
| 
      
 533 
     | 
    
         
            +
            }
         
     | 
| 
      
 534 
     | 
    
         
            +
             
     | 
| 
      
 535 
     | 
    
         
            +
            static int domain_event_watchdog_callback(virConnectPtr conn, virDomainPtr dom,
         
     | 
| 
      
 536 
     | 
    
         
            +
                                                      int action, void *opaque) {
         
     | 
| 
      
 537 
     | 
    
         
            +
                VALUE passthrough = (VALUE)opaque;
         
     | 
| 
      
 538 
     | 
    
         
            +
                VALUE cb;
         
     | 
| 
      
 539 
     | 
    
         
            +
                VALUE cb_opaque;
         
     | 
| 
      
 540 
     | 
    
         
            +
                VALUE newc;
         
     | 
| 
      
 541 
     | 
    
         
            +
             
     | 
| 
      
 542 
     | 
    
         
            +
                if (TYPE(passthrough) != T_ARRAY)
         
     | 
| 
      
 543 
     | 
    
         
            +
                    rb_raise(rb_eTypeError,
         
     | 
| 
      
 544 
     | 
    
         
            +
                             "wrong domain event watchdog callback argument type (expected Array)");
         
     | 
| 
      
 545 
     | 
    
         
            +
             
     | 
| 
      
 546 
     | 
    
         
            +
                cb = rb_ary_entry(passthrough, 0);
         
     | 
| 
      
 547 
     | 
    
         
            +
                cb_opaque = rb_ary_entry(passthrough, 1);
         
     | 
| 
      
 548 
     | 
    
         
            +
             
     | 
| 
      
 549 
     | 
    
         
            +
                newc = connect_new(conn);
         
     | 
| 
      
 550 
     | 
    
         
            +
                if (strcmp(rb_obj_classname(cb), "Symbol") == 0)
         
     | 
| 
      
 551 
     | 
    
         
            +
                    rb_funcall(rb_class_of(cb), rb_to_id(cb), 4, newc,
         
     | 
| 
      
 552 
     | 
    
         
            +
                               domain_new(dom, newc), INT2FIX(action), cb_opaque);
         
     | 
| 
      
 553 
     | 
    
         
            +
                else if (strcmp(rb_obj_classname(cb), "Proc") == 0)
         
     | 
| 
      
 554 
     | 
    
         
            +
                    rb_funcall(cb, rb_intern("call"), 4, newc, domain_new(dom, newc),
         
     | 
| 
      
 555 
     | 
    
         
            +
                               INT2FIX(action), cb_opaque);
         
     | 
| 
      
 556 
     | 
    
         
            +
                else
         
     | 
| 
      
 557 
     | 
    
         
            +
                    rb_raise(rb_eTypeError,
         
     | 
| 
      
 558 
     | 
    
         
            +
                             "wrong domain event watchdog callback (expected Symbol or Proc)");
         
     | 
| 
      
 559 
     | 
    
         
            +
             
     | 
| 
      
 560 
     | 
    
         
            +
                return 0;
         
     | 
| 
      
 561 
     | 
    
         
            +
            }
         
     | 
| 
      
 562 
     | 
    
         
            +
             
     | 
| 
      
 563 
     | 
    
         
            +
            static int domain_event_io_error_callback(virConnectPtr conn, virDomainPtr dom,
         
     | 
| 
      
 564 
     | 
    
         
            +
                                                      const char *src_path,
         
     | 
| 
      
 565 
     | 
    
         
            +
                                                      const char *dev_alias,
         
     | 
| 
      
 566 
     | 
    
         
            +
                                                      int action,
         
     | 
| 
      
 567 
     | 
    
         
            +
                                                      void *opaque) {
         
     | 
| 
      
 568 
     | 
    
         
            +
                VALUE passthrough = (VALUE)opaque;
         
     | 
| 
      
 569 
     | 
    
         
            +
                VALUE cb;
         
     | 
| 
      
 570 
     | 
    
         
            +
                VALUE cb_opaque;
         
     | 
| 
      
 571 
     | 
    
         
            +
                VALUE newc;
         
     | 
| 
      
 572 
     | 
    
         
            +
             
     | 
| 
      
 573 
     | 
    
         
            +
                if (TYPE(passthrough) != T_ARRAY)
         
     | 
| 
      
 574 
     | 
    
         
            +
                    rb_raise(rb_eTypeError,
         
     | 
| 
      
 575 
     | 
    
         
            +
                             "wrong domain event IO error callback argument type (expected Array)");
         
     | 
| 
      
 576 
     | 
    
         
            +
             
     | 
| 
      
 577 
     | 
    
         
            +
                cb = rb_ary_entry(passthrough, 0);
         
     | 
| 
      
 578 
     | 
    
         
            +
                cb_opaque = rb_ary_entry(passthrough, 1);
         
     | 
| 
      
 579 
     | 
    
         
            +
             
     | 
| 
      
 580 
     | 
    
         
            +
                newc = connect_new(conn);
         
     | 
| 
      
 581 
     | 
    
         
            +
                if (strcmp(rb_obj_classname(cb), "Symbol") == 0)
         
     | 
| 
      
 582 
     | 
    
         
            +
                    rb_funcall(rb_class_of(cb), rb_to_id(cb), 6, newc,
         
     | 
| 
      
 583 
     | 
    
         
            +
                               domain_new(dom, newc), rb_str_new2(src_path),
         
     | 
| 
      
 584 
     | 
    
         
            +
                               rb_str_new2(dev_alias), INT2FIX(action), cb_opaque);
         
     | 
| 
      
 585 
     | 
    
         
            +
                else if (strcmp(rb_obj_classname(cb), "Proc") == 0)
         
     | 
| 
      
 586 
     | 
    
         
            +
                    rb_funcall(cb, rb_intern("call"), 6, newc, domain_new(dom, newc),
         
     | 
| 
      
 587 
     | 
    
         
            +
                               rb_str_new2(src_path), rb_str_new2(dev_alias),
         
     | 
| 
      
 588 
     | 
    
         
            +
                               INT2FIX(action), cb_opaque);
         
     | 
| 
      
 589 
     | 
    
         
            +
                else
         
     | 
| 
      
 590 
     | 
    
         
            +
                    rb_raise(rb_eTypeError,
         
     | 
| 
      
 591 
     | 
    
         
            +
                             "wrong domain event IO error callback (expected Symbol or Proc)");
         
     | 
| 
      
 592 
     | 
    
         
            +
             
     | 
| 
      
 593 
     | 
    
         
            +
                return 0;
         
     | 
| 
      
 594 
     | 
    
         
            +
            }
         
     | 
| 
      
 595 
     | 
    
         
            +
             
     | 
| 
      
 596 
     | 
    
         
            +
            static int domain_event_io_error_reason_callback(virConnectPtr conn,
         
     | 
| 
      
 597 
     | 
    
         
            +
                                                             virDomainPtr dom,
         
     | 
| 
      
 598 
     | 
    
         
            +
                                                             const char *src_path,
         
     | 
| 
      
 599 
     | 
    
         
            +
                                                             const char *dev_alias,
         
     | 
| 
      
 600 
     | 
    
         
            +
                                                             int action,
         
     | 
| 
      
 601 
     | 
    
         
            +
                                                             const char *reason,
         
     | 
| 
      
 602 
     | 
    
         
            +
                                                             void *opaque) {
         
     | 
| 
      
 603 
     | 
    
         
            +
                VALUE passthrough = (VALUE)opaque;
         
     | 
| 
      
 604 
     | 
    
         
            +
                VALUE cb;
         
     | 
| 
      
 605 
     | 
    
         
            +
                VALUE cb_opaque;
         
     | 
| 
      
 606 
     | 
    
         
            +
                VALUE newc;
         
     | 
| 
      
 607 
     | 
    
         
            +
             
     | 
| 
      
 608 
     | 
    
         
            +
                if (TYPE(passthrough) != T_ARRAY)
         
     | 
| 
      
 609 
     | 
    
         
            +
                    rb_raise(rb_eTypeError,
         
     | 
| 
      
 610 
     | 
    
         
            +
                             "wrong domain event IO error reason callback argument type (expected Array)");
         
     | 
| 
      
 611 
     | 
    
         
            +
             
     | 
| 
      
 612 
     | 
    
         
            +
                cb = rb_ary_entry(passthrough, 0);
         
     | 
| 
      
 613 
     | 
    
         
            +
                cb_opaque = rb_ary_entry(passthrough, 1);
         
     | 
| 
      
 614 
     | 
    
         
            +
             
     | 
| 
      
 615 
     | 
    
         
            +
                newc = connect_new(conn);
         
     | 
| 
      
 616 
     | 
    
         
            +
                if (strcmp(rb_obj_classname(cb), "Symbol") == 0)
         
     | 
| 
      
 617 
     | 
    
         
            +
                    rb_funcall(rb_class_of(cb), rb_to_id(cb), 7, newc,
         
     | 
| 
      
 618 
     | 
    
         
            +
                               domain_new(dom, newc), rb_str_new2(src_path),
         
     | 
| 
      
 619 
     | 
    
         
            +
                               rb_str_new2(dev_alias), INT2FIX(action),
         
     | 
| 
      
 620 
     | 
    
         
            +
                               rb_str_new2(reason), cb_opaque);
         
     | 
| 
      
 621 
     | 
    
         
            +
                else if (strcmp(rb_obj_classname(cb), "Proc") == 0)
         
     | 
| 
      
 622 
     | 
    
         
            +
                    rb_funcall(cb, rb_intern("call"), 7, newc, domain_new(dom, newc),
         
     | 
| 
      
 623 
     | 
    
         
            +
                               rb_str_new2(src_path), rb_str_new2(dev_alias),
         
     | 
| 
      
 624 
     | 
    
         
            +
                               INT2FIX(action), rb_str_new2(reason), cb_opaque);
         
     | 
| 
      
 625 
     | 
    
         
            +
                else
         
     | 
| 
      
 626 
     | 
    
         
            +
                    rb_raise(rb_eTypeError,
         
     | 
| 
      
 627 
     | 
    
         
            +
                             "wrong domain event IO error reason callback (expected Symbol or Proc)");
         
     | 
| 
      
 628 
     | 
    
         
            +
             
     | 
| 
      
 629 
     | 
    
         
            +
                return 0;
         
     | 
| 
      
 630 
     | 
    
         
            +
            }
         
     | 
| 
      
 631 
     | 
    
         
            +
             
     | 
| 
      
 632 
     | 
    
         
            +
            static int domain_event_graphics_callback(virConnectPtr conn, virDomainPtr dom,
         
     | 
| 
      
 633 
     | 
    
         
            +
                                                      int phase,
         
     | 
| 
      
 634 
     | 
    
         
            +
                                                      virDomainEventGraphicsAddressPtr local,
         
     | 
| 
      
 635 
     | 
    
         
            +
                                                      virDomainEventGraphicsAddressPtr remote,
         
     | 
| 
      
 636 
     | 
    
         
            +
                                                      const char *authScheme,
         
     | 
| 
      
 637 
     | 
    
         
            +
                                                      virDomainEventGraphicsSubjectPtr subject,
         
     | 
| 
      
 638 
     | 
    
         
            +
                                                      void *opaque) {
         
     | 
| 
      
 639 
     | 
    
         
            +
                VALUE passthrough = (VALUE)opaque;
         
     | 
| 
      
 640 
     | 
    
         
            +
                VALUE cb;
         
     | 
| 
      
 641 
     | 
    
         
            +
                VALUE cb_opaque;
         
     | 
| 
      
 642 
     | 
    
         
            +
                VALUE newc;
         
     | 
| 
      
 643 
     | 
    
         
            +
                VALUE local_hash;
         
     | 
| 
      
 644 
     | 
    
         
            +
                VALUE remote_hash;
         
     | 
| 
      
 645 
     | 
    
         
            +
                VALUE subject_array;
         
     | 
| 
      
 646 
     | 
    
         
            +
                VALUE pair;
         
     | 
| 
      
 647 
     | 
    
         
            +
                int i;
         
     | 
| 
      
 648 
     | 
    
         
            +
             
     | 
| 
      
 649 
     | 
    
         
            +
                if (TYPE(passthrough) != T_ARRAY)
         
     | 
| 
      
 650 
     | 
    
         
            +
                    rb_raise(rb_eTypeError,
         
     | 
| 
      
 651 
     | 
    
         
            +
                             "wrong domain event graphics callback argument type (expected Array)");
         
     | 
| 
      
 652 
     | 
    
         
            +
             
     | 
| 
      
 653 
     | 
    
         
            +
                cb = rb_ary_entry(passthrough, 0);
         
     | 
| 
      
 654 
     | 
    
         
            +
                cb_opaque = rb_ary_entry(passthrough, 1);
         
     | 
| 
      
 655 
     | 
    
         
            +
             
     | 
| 
      
 656 
     | 
    
         
            +
                local_hash = rb_hash_new();
         
     | 
| 
      
 657 
     | 
    
         
            +
                rb_hash_aset(local_hash, rb_str_new2("family"), INT2FIX(local->family));
         
     | 
| 
      
 658 
     | 
    
         
            +
                rb_hash_aset(local_hash, rb_str_new2("node"), rb_str_new2(local->node));
         
     | 
| 
      
 659 
     | 
    
         
            +
                rb_hash_aset(local_hash, rb_str_new2("service"),
         
     | 
| 
      
 660 
     | 
    
         
            +
                             rb_str_new2(local->service));
         
     | 
| 
      
 661 
     | 
    
         
            +
             
     | 
| 
      
 662 
     | 
    
         
            +
                remote_hash = rb_hash_new();
         
     | 
| 
      
 663 
     | 
    
         
            +
                rb_hash_aset(remote_hash, rb_str_new2("family"), INT2FIX(remote->family));
         
     | 
| 
      
 664 
     | 
    
         
            +
                rb_hash_aset(remote_hash, rb_str_new2("node"), rb_str_new2(remote->node));
         
     | 
| 
      
 665 
     | 
    
         
            +
                rb_hash_aset(remote_hash, rb_str_new2("service"),
         
     | 
| 
      
 666 
     | 
    
         
            +
                             rb_str_new2(remote->service));
         
     | 
| 
      
 667 
     | 
    
         
            +
             
     | 
| 
      
 668 
     | 
    
         
            +
                subject_array = rb_ary_new();
         
     | 
| 
      
 669 
     | 
    
         
            +
                for (i = 0; i < subject->nidentity; i++) {
         
     | 
| 
      
 670 
     | 
    
         
            +
                    pair = rb_ary_new();
         
     | 
| 
      
 671 
     | 
    
         
            +
                    rb_ary_store(pair, 0, rb_str_new2(subject->identities[i].type));
         
     | 
| 
      
 672 
     | 
    
         
            +
                    rb_ary_store(pair, 1, rb_str_new2(subject->identities[i].name));
         
     | 
| 
      
 673 
     | 
    
         
            +
             
     | 
| 
      
 674 
     | 
    
         
            +
                    rb_ary_store(subject_array, i, pair);
         
     | 
| 
      
 675 
     | 
    
         
            +
                }
         
     | 
| 
      
 676 
     | 
    
         
            +
             
     | 
| 
      
 677 
     | 
    
         
            +
                newc = connect_new(conn);
         
     | 
| 
      
 678 
     | 
    
         
            +
                if (strcmp(rb_obj_classname(cb), "Symbol") == 0)
         
     | 
| 
      
 679 
     | 
    
         
            +
                    rb_funcall(rb_class_of(cb), rb_to_id(cb), 8, newc,
         
     | 
| 
      
 680 
     | 
    
         
            +
                               domain_new(dom, newc), INT2FIX(phase), local_hash,
         
     | 
| 
      
 681 
     | 
    
         
            +
                               remote_hash, rb_str_new2(authScheme), subject_array,
         
     | 
| 
      
 682 
     | 
    
         
            +
                               cb_opaque);
         
     | 
| 
      
 683 
     | 
    
         
            +
                else if (strcmp(rb_obj_classname(cb), "Proc") == 0)
         
     | 
| 
      
 684 
     | 
    
         
            +
                    rb_funcall(cb, rb_intern("call"), 8, newc, domain_new(dom, newc),
         
     | 
| 
      
 685 
     | 
    
         
            +
                               INT2FIX(phase), local_hash, remote_hash,
         
     | 
| 
      
 686 
     | 
    
         
            +
                               rb_str_new2(authScheme), subject_array, cb_opaque);
         
     | 
| 
      
 687 
     | 
    
         
            +
                else
         
     | 
| 
      
 688 
     | 
    
         
            +
                    rb_raise(rb_eTypeError,
         
     | 
| 
      
 689 
     | 
    
         
            +
                             "wrong domain event graphics callback (expected Symbol or Proc)");
         
     | 
| 
      
 690 
     | 
    
         
            +
             
     | 
| 
      
 691 
     | 
    
         
            +
                return 0;
         
     | 
| 
      
 692 
     | 
    
         
            +
            }
         
     | 
| 
      
 693 
     | 
    
         
            +
             
     | 
| 
      
 694 
     | 
    
         
            +
            /*
         
     | 
| 
      
 695 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 696 
     | 
    
         
            +
             *   conn.domain_event_register_any(eventID, callback, dom=nil, opaque=nil) -> fixnum
         
     | 
| 
      
 697 
     | 
    
         
            +
             *
         
     | 
| 
      
 698 
     | 
    
         
            +
             * Call +virConnectDomainEventRegisterAny+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectDomainEventRegisterAny]
         
     | 
| 
      
 699 
     | 
    
         
            +
             * to register callback for eventID with libvirt.  The eventID must be one of
         
     | 
| 
      
 700 
     | 
    
         
            +
             * the Libvirt::Connect::DOMAIN_EVENT_ID_* constants.  The callback can either
         
     | 
| 
      
 701 
     | 
    
         
            +
             * by a Symbol (that is the name of a method to callback) or a Proc.  Note that
         
     | 
| 
      
 702 
     | 
    
         
            +
             * the callback must accept different numbers of arguments depending on the
         
     | 
| 
      
 703 
     | 
    
         
            +
             * eventID passed in.  The arguments are as follows:
         
     | 
| 
      
 704 
     | 
    
         
            +
             *
         
     | 
| 
      
 705 
     | 
    
         
            +
             * - DOMAIN_EVENT_ID_LIFECYCLE: Libvirt::Connect, Libvirt::Domain, event, detail, opaque
         
     | 
| 
      
 706 
     | 
    
         
            +
             * - DOMAIN_EVENT_ID_REBOOT: Libvirt::Connect, Libvirt::Domain, opaque
         
     | 
| 
      
 707 
     | 
    
         
            +
             * - DOMAIN_EVENT_ID_RTC_CHANGE: Libvirt::Connect, Libvirt::Domain, utc_offset, opaque
         
     | 
| 
      
 708 
     | 
    
         
            +
             * - DOMAIN_EVENT_ID_WATCHDOG: Libvirt::Connect, Libvirt::Domain, action, opaque
         
     | 
| 
      
 709 
     | 
    
         
            +
             * - DOMAIN_EVENT_ID_IO_ERROR: Libvirt::Connect, Libvirt::Domain, src_path, dev_alias, action, opaque
         
     | 
| 
      
 710 
     | 
    
         
            +
             * - DOMAIN_EVENT_ID_IO_ERROR_REASON: Libvirt::Connect, Libvirt::Domain, src_path, dev_alias, action, reason, opaque
         
     | 
| 
      
 711 
     | 
    
         
            +
             * - DOMAIN_EVENT_ID_GRAPHICS: Libvirt::Connect, Libvirt::Domain, phase, local, remote, auth_scheme, subject, opaque
         
     | 
| 
      
 712 
     | 
    
         
            +
             
     | 
| 
      
 713 
     | 
    
         
            +
             * If dom is a valid Libvirt::Domain object, then only events from that
         
     | 
| 
      
 714 
     | 
    
         
            +
             * domain will be seen.  The opaque parameter can be any valid ruby type, and
         
     | 
| 
      
 715 
     | 
    
         
            +
             * will be passed into callback as "opaque".  This method returns a
         
     | 
| 
      
 716 
     | 
    
         
            +
             * libvirt-specific handle, which must be used by the application to
         
     | 
| 
      
 717 
     | 
    
         
            +
             * deregister the callback later (see domain_event_deregister_any).
         
     | 
| 
      
 718 
     | 
    
         
            +
             */
         
     | 
| 
      
 719 
     | 
    
         
            +
            static VALUE libvirt_conn_domain_event_register_any(int argc, VALUE *argv,
         
     | 
| 
      
 720 
     | 
    
         
            +
                                                                VALUE c) {
         
     | 
| 
      
 721 
     | 
    
         
            +
                VALUE eventID, cb, dom, opaque;
         
     | 
| 
      
 722 
     | 
    
         
            +
                virDomainPtr domain;
         
     | 
| 
      
 723 
     | 
    
         
            +
                virConnectDomainEventGenericCallback internalcb = NULL;
         
     | 
| 
      
 724 
     | 
    
         
            +
                VALUE passthrough;
         
     | 
| 
      
 725 
     | 
    
         
            +
             
     | 
| 
      
 726 
     | 
    
         
            +
                rb_scan_args(argc, argv, "22", &eventID, &cb, &dom, &opaque);
         
     | 
| 
      
 727 
     | 
    
         
            +
             
     | 
| 
      
 728 
     | 
    
         
            +
                if (!is_symbol_or_proc(cb))
         
     | 
| 
      
 729 
     | 
    
         
            +
                    rb_raise(rb_eTypeError, "wrong argument type (expected Symbol or Proc)");
         
     | 
| 
      
 730 
     | 
    
         
            +
             
     | 
| 
      
 731 
     | 
    
         
            +
                if (NIL_P(dom))
         
     | 
| 
      
 732 
     | 
    
         
            +
                    domain = NULL;
         
     | 
| 
      
 733 
     | 
    
         
            +
                else
         
     | 
| 
      
 734 
     | 
    
         
            +
                    domain = domain_get(dom);
         
     | 
| 
      
 735 
     | 
    
         
            +
             
     | 
| 
      
 736 
     | 
    
         
            +
                switch(NUM2INT(eventID)) {
         
     | 
| 
      
 737 
     | 
    
         
            +
                case VIR_DOMAIN_EVENT_ID_LIFECYCLE:
         
     | 
| 
      
 738 
     | 
    
         
            +
                    internalcb = VIR_DOMAIN_EVENT_CALLBACK(domain_event_lifecycle_callback);
         
     | 
| 
      
 739 
     | 
    
         
            +
                    break;
         
     | 
| 
      
 740 
     | 
    
         
            +
                case VIR_DOMAIN_EVENT_ID_REBOOT:
         
     | 
| 
      
 741 
     | 
    
         
            +
                    internalcb = VIR_DOMAIN_EVENT_CALLBACK(domain_event_reboot_callback);
         
     | 
| 
      
 742 
     | 
    
         
            +
                    break;
         
     | 
| 
      
 743 
     | 
    
         
            +
                case VIR_DOMAIN_EVENT_ID_RTC_CHANGE:
         
     | 
| 
      
 744 
     | 
    
         
            +
                    internalcb = VIR_DOMAIN_EVENT_CALLBACK(domain_event_rtc_callback);
         
     | 
| 
      
 745 
     | 
    
         
            +
                    break;
         
     | 
| 
      
 746 
     | 
    
         
            +
                case VIR_DOMAIN_EVENT_ID_WATCHDOG:
         
     | 
| 
      
 747 
     | 
    
         
            +
                    internalcb = VIR_DOMAIN_EVENT_CALLBACK(domain_event_watchdog_callback);
         
     | 
| 
      
 748 
     | 
    
         
            +
                    break;
         
     | 
| 
      
 749 
     | 
    
         
            +
                case VIR_DOMAIN_EVENT_ID_IO_ERROR:
         
     | 
| 
      
 750 
     | 
    
         
            +
                    internalcb = VIR_DOMAIN_EVENT_CALLBACK(domain_event_io_error_callback);
         
     | 
| 
      
 751 
     | 
    
         
            +
                    break;
         
     | 
| 
      
 752 
     | 
    
         
            +
                case VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON:
         
     | 
| 
      
 753 
     | 
    
         
            +
                    internalcb = VIR_DOMAIN_EVENT_CALLBACK(domain_event_io_error_reason_callback);
         
     | 
| 
      
 754 
     | 
    
         
            +
                    break;
         
     | 
| 
      
 755 
     | 
    
         
            +
                case VIR_DOMAIN_EVENT_ID_GRAPHICS:
         
     | 
| 
      
 756 
     | 
    
         
            +
                    internalcb = VIR_DOMAIN_EVENT_CALLBACK(domain_event_graphics_callback);
         
     | 
| 
      
 757 
     | 
    
         
            +
                    break;
         
     | 
| 
      
 758 
     | 
    
         
            +
                default:
         
     | 
| 
      
 759 
     | 
    
         
            +
                    rb_raise(rb_eArgError, "invalid eventID argument %d",
         
     | 
| 
      
 760 
     | 
    
         
            +
                             NUM2INT(eventID));
         
     | 
| 
      
 761 
     | 
    
         
            +
                    break;
         
     | 
| 
      
 762 
     | 
    
         
            +
                }
         
     | 
| 
      
 763 
     | 
    
         
            +
             
     | 
| 
      
 764 
     | 
    
         
            +
                passthrough = rb_ary_new();
         
     | 
| 
      
 765 
     | 
    
         
            +
                rb_ary_store(passthrough, 0, cb);
         
     | 
| 
      
 766 
     | 
    
         
            +
                rb_ary_store(passthrough, 1, opaque);
         
     | 
| 
      
 767 
     | 
    
         
            +
             
     | 
| 
      
 768 
     | 
    
         
            +
                gen_call_int(virConnectDomainEventRegisterAny, conn(c), connect_get(c),
         
     | 
| 
      
 769 
     | 
    
         
            +
                             domain, NUM2INT(eventID), internalcb, (void *)passthrough,
         
     | 
| 
      
 770 
     | 
    
         
            +
                             NULL);
         
     | 
| 
      
 771 
     | 
    
         
            +
            }
         
     | 
| 
      
 772 
     | 
    
         
            +
             
     | 
| 
      
 773 
     | 
    
         
            +
            /*
         
     | 
| 
      
 774 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 775 
     | 
    
         
            +
             *   conn.domain_event_deregister_any(callbackID) -> nil
         
     | 
| 
      
 776 
     | 
    
         
            +
             *
         
     | 
| 
      
 777 
     | 
    
         
            +
             * Call +virConnectDomainEventDeregisterAny+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectDomainEventDeregisterAny]
         
     | 
| 
      
 778 
     | 
    
         
            +
             * to deregister a callback from libvirt.  The callbackID must be a
         
     | 
| 
      
 779 
     | 
    
         
            +
             * libvirt-specific handle returned by domain_event_register_any.
         
     | 
| 
      
 780 
     | 
    
         
            +
             */
         
     | 
| 
      
 781 
     | 
    
         
            +
            static VALUE libvirt_conn_domain_event_deregister_any(VALUE c,
         
     | 
| 
      
 782 
     | 
    
         
            +
                                                                  VALUE callbackID) {
         
     | 
| 
      
 783 
     | 
    
         
            +
                gen_call_void(virConnectDomainEventDeregisterAny, conn(c), connect_get(c),
         
     | 
| 
      
 784 
     | 
    
         
            +
                              NUM2INT(callbackID));
         
     | 
| 
      
 785 
     | 
    
         
            +
            }
         
     | 
| 
       377 
786 
     | 
    
         
             
            #endif
         
     | 
| 
       378 
     | 
    
         
            -
                rb_define_method(c_connect, "capabilities", libvirt_conn_capabilities, 0);
         
     | 
| 
       379 
787 
     | 
    
         | 
| 
       380 
     | 
    
         
            -
             
     | 
| 
       381 
     | 
    
         
            -
             
     | 
| 
       382 
     | 
    
         
            -
             
     | 
| 
       383 
     | 
    
         
            -
             
     | 
| 
       384 
     | 
    
         
            -
             
     | 
| 
       385 
     | 
    
         
            -
             
     | 
| 
       386 
     | 
    
         
            -
             
     | 
| 
       387 
     | 
    
         
            -
             
     | 
| 
       388 
     | 
    
         
            -
             
     | 
| 
       389 
     | 
    
         
            -
             
     | 
| 
       390 
     | 
    
         
            -
             
     | 
| 
       391 
     | 
    
         
            -
                 
     | 
| 
      
 788 
     | 
    
         
            +
            #if HAVE_VIRCONNECTDOMAINEVENTREGISTER
         
     | 
| 
      
 789 
     | 
    
         
            +
            /*
         
     | 
| 
      
 790 
     | 
    
         
            +
             * this is a bit of silliness.  Because libvirt internals track the address
         
     | 
| 
      
 791 
     | 
    
         
            +
             * of the function pointer, trying to use domain_event_lifecycle_callback
         
     | 
| 
      
 792 
     | 
    
         
            +
             * for both register and register_any would mean that we could only register
         
     | 
| 
      
 793 
     | 
    
         
            +
             * one or the other for lifecycle callbacks.  Instead we do a simple wrapper
         
     | 
| 
      
 794 
     | 
    
         
            +
             * so that the addresses are different
         
     | 
| 
      
 795 
     | 
    
         
            +
             */
         
     | 
| 
      
 796 
     | 
    
         
            +
            static int domain_event_callback(virConnectPtr conn,
         
     | 
| 
      
 797 
     | 
    
         
            +
                                             virDomainPtr dom, int event,
         
     | 
| 
      
 798 
     | 
    
         
            +
                                             int detail, void *opaque) {
         
     | 
| 
      
 799 
     | 
    
         
            +
                return domain_event_lifecycle_callback(conn, dom, event, detail, opaque);
         
     | 
| 
      
 800 
     | 
    
         
            +
            }
         
     | 
| 
      
 801 
     | 
    
         
            +
            /*
         
     | 
| 
      
 802 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 803 
     | 
    
         
            +
             *   conn.domain_event_register(callback, opaque=nil) -> nil
         
     | 
| 
      
 804 
     | 
    
         
            +
             *
         
     | 
| 
      
 805 
     | 
    
         
            +
             * Call +virConnectDomainEventRegister+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectDomainEventRegister]
         
     | 
| 
      
 806 
     | 
    
         
            +
             * to register callback for domain lifecycle events with libvirt.  The
         
     | 
| 
      
 807 
     | 
    
         
            +
             * callback can either by a Symbol (that is the name of a method to callback)
         
     | 
| 
      
 808 
     | 
    
         
            +
             * or a Proc.  The callback must accept 5 parameters: Libvirt::Connect,
         
     | 
| 
      
 809 
     | 
    
         
            +
             * Libvirt::Domain, event, detail, opaque.  The opaque parameter to
         
     | 
| 
      
 810 
     | 
    
         
            +
             * domain_event_register can be any valid ruby type, and will be passed into
         
     | 
| 
      
 811 
     | 
    
         
            +
             * callback as "opaque".  This method is deprecated in favor of
         
     | 
| 
      
 812 
     | 
    
         
            +
             * domain_event_register_any.
         
     | 
| 
      
 813 
     | 
    
         
            +
             */
         
     | 
| 
      
 814 
     | 
    
         
            +
            static VALUE libvirt_conn_domain_event_register(int argc, VALUE *argv,
         
     | 
| 
      
 815 
     | 
    
         
            +
                                                            VALUE c) {
         
     | 
| 
      
 816 
     | 
    
         
            +
                VALUE cb, opaque;
         
     | 
| 
      
 817 
     | 
    
         
            +
                VALUE passthrough;
         
     | 
| 
      
 818 
     | 
    
         
            +
             
     | 
| 
      
 819 
     | 
    
         
            +
                rb_scan_args(argc, argv, "11", &cb, &opaque);
         
     | 
| 
      
 820 
     | 
    
         
            +
             
     | 
| 
      
 821 
     | 
    
         
            +
                if (!is_symbol_or_proc(cb))
         
     | 
| 
      
 822 
     | 
    
         
            +
                    rb_raise(rb_eTypeError, "wrong argument type (expected Symbol or Proc)");
         
     | 
| 
      
 823 
     | 
    
         
            +
             
     | 
| 
      
 824 
     | 
    
         
            +
                passthrough = rb_ary_new();
         
     | 
| 
      
 825 
     | 
    
         
            +
                rb_ary_store(passthrough, 0, cb);
         
     | 
| 
      
 826 
     | 
    
         
            +
                rb_ary_store(passthrough, 1, opaque);
         
     | 
| 
      
 827 
     | 
    
         
            +
             
     | 
| 
      
 828 
     | 
    
         
            +
                gen_call_void(virConnectDomainEventRegister, conn(c), connect_get(c),
         
     | 
| 
      
 829 
     | 
    
         
            +
                              domain_event_callback, (void *)passthrough, NULL);
         
     | 
| 
      
 830 
     | 
    
         
            +
            }
         
     | 
| 
      
 831 
     | 
    
         
            +
             
     | 
| 
      
 832 
     | 
    
         
            +
            /*
         
     | 
| 
      
 833 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 834 
     | 
    
         
            +
             *   conn.domain_event_deregister(callback) -> nil
         
     | 
| 
      
 835 
     | 
    
         
            +
             *
         
     | 
| 
      
 836 
     | 
    
         
            +
             * Call +virConnectDomainEventDeregister+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectDomainEventDeregister]
         
     | 
| 
      
 837 
     | 
    
         
            +
             * to deregister the event callback from libvirt.  This method is deprecated
         
     | 
| 
      
 838 
     | 
    
         
            +
             * in favor of domain_event_deregister_any (though they cannot be mixed; if
         
     | 
| 
      
 839 
     | 
    
         
            +
             * the callback was registered with domain_event_register, it must be
         
     | 
| 
      
 840 
     | 
    
         
            +
             * deregistered with domain_event_deregister).
         
     | 
| 
      
 841 
     | 
    
         
            +
             */
         
     | 
| 
      
 842 
     | 
    
         
            +
            static VALUE libvirt_conn_domain_event_deregister(VALUE c) {
         
     | 
| 
      
 843 
     | 
    
         
            +
                gen_call_void(virConnectDomainEventDeregister, conn(c), connect_get(c),
         
     | 
| 
      
 844 
     | 
    
         
            +
                              domain_event_callback);
         
     | 
| 
      
 845 
     | 
    
         
            +
            }
         
     | 
| 
      
 846 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 847 
     | 
    
         
            +
             
     | 
| 
      
 848 
     | 
    
         
            +
            /*
         
     | 
| 
      
 849 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 850 
     | 
    
         
            +
             *   conn.num_of_domains -> fixnum
         
     | 
| 
      
 851 
     | 
    
         
            +
             *
         
     | 
| 
      
 852 
     | 
    
         
            +
             * Call +virConnectNumOfDomains+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectNumOfDomains]
         
     | 
| 
      
 853 
     | 
    
         
            +
             * to retrieve the number of active domains on this connection.
         
     | 
| 
      
 854 
     | 
    
         
            +
             */
         
     | 
| 
      
 855 
     | 
    
         
            +
            static VALUE libvirt_conn_num_of_domains(VALUE s) {
         
     | 
| 
      
 856 
     | 
    
         
            +
                gen_conn_num_of(s, Domains);
         
     | 
| 
      
 857 
     | 
    
         
            +
            }
         
     | 
| 
      
 858 
     | 
    
         
            +
             
     | 
| 
      
 859 
     | 
    
         
            +
            /*
         
     | 
| 
      
 860 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 861 
     | 
    
         
            +
             *   conn.list_domains -> list
         
     | 
| 
      
 862 
     | 
    
         
            +
             *
         
     | 
| 
      
 863 
     | 
    
         
            +
             * Call +virConnectListDomains+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectListDomains]
         
     | 
| 
      
 864 
     | 
    
         
            +
             * to retrieve a list of active domain IDs on this connection.
         
     | 
| 
      
 865 
     | 
    
         
            +
             */
         
     | 
| 
      
 866 
     | 
    
         
            +
            static VALUE libvirt_conn_list_domains(VALUE s) {
         
     | 
| 
      
 867 
     | 
    
         
            +
                int i, r, num, *ids;
         
     | 
| 
      
 868 
     | 
    
         
            +
                virConnectPtr conn = connect_get(s);
         
     | 
| 
      
 869 
     | 
    
         
            +
                VALUE result;
         
     | 
| 
      
 870 
     | 
    
         
            +
                int exception = 0;
         
     | 
| 
      
 871 
     | 
    
         
            +
                struct rb_ary_push_arg args;
         
     | 
| 
      
 872 
     | 
    
         
            +
             
     | 
| 
      
 873 
     | 
    
         
            +
                num = virConnectNumOfDomains(conn);
         
     | 
| 
      
 874 
     | 
    
         
            +
                _E(num < 0, create_error(e_RetrieveError, "virConnectNumOfDomains", conn));
         
     | 
| 
      
 875 
     | 
    
         
            +
                if (num == 0) {
         
     | 
| 
      
 876 
     | 
    
         
            +
                    result = rb_ary_new2(num);
         
     | 
| 
      
 877 
     | 
    
         
            +
                    return result;
         
     | 
| 
      
 878 
     | 
    
         
            +
                }
         
     | 
| 
      
 879 
     | 
    
         
            +
             
     | 
| 
      
 880 
     | 
    
         
            +
                ids = ALLOC_N(int, num);
         
     | 
| 
      
 881 
     | 
    
         
            +
                r = virConnectListDomains(conn, ids, num);
         
     | 
| 
      
 882 
     | 
    
         
            +
                if (r < 0) {
         
     | 
| 
      
 883 
     | 
    
         
            +
                    xfree(ids);
         
     | 
| 
      
 884 
     | 
    
         
            +
                    rb_exc_raise(create_error(e_RetrieveError, "virConnectListDomains",
         
     | 
| 
      
 885 
     | 
    
         
            +
                                              conn));
         
     | 
| 
      
 886 
     | 
    
         
            +
                }
         
     | 
| 
      
 887 
     | 
    
         
            +
             
     | 
| 
      
 888 
     | 
    
         
            +
                result = rb_protect(rb_ary_new2_wrap, (VALUE)&num, &exception);
         
     | 
| 
      
 889 
     | 
    
         
            +
                if (exception) {
         
     | 
| 
      
 890 
     | 
    
         
            +
                    xfree(ids);
         
     | 
| 
      
 891 
     | 
    
         
            +
                    rb_jump_tag(exception);
         
     | 
| 
      
 892 
     | 
    
         
            +
                }
         
     | 
| 
      
 893 
     | 
    
         
            +
             
     | 
| 
      
 894 
     | 
    
         
            +
                for (i = 0; i < num; i++) {
         
     | 
| 
      
 895 
     | 
    
         
            +
                    args.arr = result;
         
     | 
| 
      
 896 
     | 
    
         
            +
                    args. value = INT2NUM(ids[i]);
         
     | 
| 
      
 897 
     | 
    
         
            +
                    rb_protect(rb_ary_push_wrap, (VALUE)&args, &exception);
         
     | 
| 
      
 898 
     | 
    
         
            +
                    if (exception) {
         
     | 
| 
      
 899 
     | 
    
         
            +
                        xfree(ids);
         
     | 
| 
      
 900 
     | 
    
         
            +
                        rb_jump_tag(exception);
         
     | 
| 
      
 901 
     | 
    
         
            +
                    }
         
     | 
| 
      
 902 
     | 
    
         
            +
                }
         
     | 
| 
      
 903 
     | 
    
         
            +
                xfree(ids);
         
     | 
| 
      
 904 
     | 
    
         
            +
                return result;
         
     | 
| 
      
 905 
     | 
    
         
            +
            }
         
     | 
| 
      
 906 
     | 
    
         
            +
             
     | 
| 
      
 907 
     | 
    
         
            +
            /*
         
     | 
| 
      
 908 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 909 
     | 
    
         
            +
             *   conn.num_of_defined_domains -> fixnum
         
     | 
| 
      
 910 
     | 
    
         
            +
             *
         
     | 
| 
      
 911 
     | 
    
         
            +
             * Call +virConnectNumOfDefinedDomains+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectNumOfDefinedDomains]
         
     | 
| 
      
 912 
     | 
    
         
            +
             * to retrieve the number of inactive domains on this connection.
         
     | 
| 
      
 913 
     | 
    
         
            +
             */
         
     | 
| 
      
 914 
     | 
    
         
            +
            static VALUE libvirt_conn_num_of_defined_domains(VALUE s) {
         
     | 
| 
      
 915 
     | 
    
         
            +
                gen_conn_num_of(s, DefinedDomains);
         
     | 
| 
      
 916 
     | 
    
         
            +
            }
         
     | 
| 
      
 917 
     | 
    
         
            +
             
     | 
| 
      
 918 
     | 
    
         
            +
            /*
         
     | 
| 
      
 919 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 920 
     | 
    
         
            +
             *   conn.list_defined_domains -> list
         
     | 
| 
      
 921 
     | 
    
         
            +
             *
         
     | 
| 
      
 922 
     | 
    
         
            +
             * Call +virConnectListDefinedDomains+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectListDefinedDomains]
         
     | 
| 
      
 923 
     | 
    
         
            +
             * to retrieve a list of inactive domain names on this connection.
         
     | 
| 
      
 924 
     | 
    
         
            +
             */
         
     | 
| 
      
 925 
     | 
    
         
            +
            static VALUE libvirt_conn_list_defined_domains(VALUE s) {
         
     | 
| 
      
 926 
     | 
    
         
            +
                gen_conn_list_names(s, DefinedDomains);
         
     | 
| 
      
 927 
     | 
    
         
            +
            }
         
     | 
| 
      
 928 
     | 
    
         
            +
             
     | 
| 
      
 929 
     | 
    
         
            +
            /*
         
     | 
| 
      
 930 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 931 
     | 
    
         
            +
             *   conn.create_domain_linux(xml, flags=0) -> Libvirt::Domain
         
     | 
| 
      
 932 
     | 
    
         
            +
             *
         
     | 
| 
      
 933 
     | 
    
         
            +
             * Call +virDomainCreateLinux+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainCreateLinux]
         
     | 
| 
      
 934 
     | 
    
         
            +
             * to start a transient domain from the given XML.  Deprecated; use
         
     | 
| 
      
 935 
     | 
    
         
            +
             * dom.create_xml instead.
         
     | 
| 
      
 936 
     | 
    
         
            +
             */
         
     | 
| 
      
 937 
     | 
    
         
            +
            static VALUE libvirt_conn_create_linux(int argc, VALUE *argv, VALUE c) {
         
     | 
| 
      
 938 
     | 
    
         
            +
                virDomainPtr dom;
         
     | 
| 
      
 939 
     | 
    
         
            +
                virConnectPtr conn = connect_get(c);
         
     | 
| 
      
 940 
     | 
    
         
            +
                VALUE flags, xml;
         
     | 
| 
      
 941 
     | 
    
         
            +
             
     | 
| 
      
 942 
     | 
    
         
            +
                rb_scan_args(argc, argv, "11", &xml, &flags);
         
     | 
| 
      
 943 
     | 
    
         
            +
             
     | 
| 
      
 944 
     | 
    
         
            +
                if (NIL_P(flags))
         
     | 
| 
      
 945 
     | 
    
         
            +
                    flags = INT2FIX(0);
         
     | 
| 
      
 946 
     | 
    
         
            +
             
     | 
| 
      
 947 
     | 
    
         
            +
                dom = virDomainCreateLinux(conn, StringValueCStr(xml), NUM2UINT(flags));
         
     | 
| 
      
 948 
     | 
    
         
            +
                _E(dom == NULL, create_error(e_Error, "virDomainCreateLinux", conn));
         
     | 
| 
      
 949 
     | 
    
         
            +
             
     | 
| 
      
 950 
     | 
    
         
            +
                return domain_new(dom, c);
         
     | 
| 
      
 951 
     | 
    
         
            +
            }
         
     | 
| 
      
 952 
     | 
    
         
            +
             
     | 
| 
      
 953 
     | 
    
         
            +
            #if HAVE_VIRDOMAINCREATEXML
         
     | 
| 
      
 954 
     | 
    
         
            +
            /*
         
     | 
| 
      
 955 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 956 
     | 
    
         
            +
             *   conn.create_domain_xml(xml, flags=0) -> Libvirt::Domain
         
     | 
| 
      
 957 
     | 
    
         
            +
             *
         
     | 
| 
      
 958 
     | 
    
         
            +
             * Call +virDomainCreateXML+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainCreateXML]
         
     | 
| 
      
 959 
     | 
    
         
            +
             * to start a transient domain from the given XML.
         
     | 
| 
      
 960 
     | 
    
         
            +
             */
         
     | 
| 
      
 961 
     | 
    
         
            +
            static VALUE libvirt_conn_create_xml(int argc, VALUE *argv, VALUE c) {
         
     | 
| 
      
 962 
     | 
    
         
            +
                virDomainPtr dom;
         
     | 
| 
      
 963 
     | 
    
         
            +
                virConnectPtr conn = connect_get(c);
         
     | 
| 
      
 964 
     | 
    
         
            +
                VALUE flags, xml;
         
     | 
| 
      
 965 
     | 
    
         
            +
             
     | 
| 
      
 966 
     | 
    
         
            +
                rb_scan_args(argc, argv, "11", &xml, &flags);
         
     | 
| 
      
 967 
     | 
    
         
            +
             
     | 
| 
      
 968 
     | 
    
         
            +
                if (NIL_P(flags))
         
     | 
| 
      
 969 
     | 
    
         
            +
                    flags = INT2FIX(0);
         
     | 
| 
      
 970 
     | 
    
         
            +
             
     | 
| 
      
 971 
     | 
    
         
            +
                dom = virDomainCreateXML(conn, StringValueCStr(xml), NUM2UINT(flags));
         
     | 
| 
      
 972 
     | 
    
         
            +
                _E(dom == NULL, create_error(e_Error, "virDomainCreateXML", conn));
         
     | 
| 
      
 973 
     | 
    
         
            +
             
     | 
| 
      
 974 
     | 
    
         
            +
                return domain_new(dom, c);
         
     | 
| 
      
 975 
     | 
    
         
            +
            }
         
     | 
| 
      
 976 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 977 
     | 
    
         
            +
             
     | 
| 
      
 978 
     | 
    
         
            +
            /*
         
     | 
| 
      
 979 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 980 
     | 
    
         
            +
             *   conn.lookup_domain_by_name(name) -> Libvirt::Domain
         
     | 
| 
      
 981 
     | 
    
         
            +
             *
         
     | 
| 
      
 982 
     | 
    
         
            +
             * Call +virDomainLookupByName+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainLookupByName]
         
     | 
| 
      
 983 
     | 
    
         
            +
             * to retrieve a domain object for name.
         
     | 
| 
      
 984 
     | 
    
         
            +
             */
         
     | 
| 
      
 985 
     | 
    
         
            +
            static VALUE libvirt_conn_lookup_domain_by_name(VALUE c, VALUE name) {
         
     | 
| 
      
 986 
     | 
    
         
            +
                virDomainPtr dom;
         
     | 
| 
      
 987 
     | 
    
         
            +
                virConnectPtr conn = connect_get(c);
         
     | 
| 
      
 988 
     | 
    
         
            +
             
     | 
| 
      
 989 
     | 
    
         
            +
                dom = virDomainLookupByName(conn, StringValueCStr(name));
         
     | 
| 
      
 990 
     | 
    
         
            +
                _E(dom == NULL, create_error(e_RetrieveError, "virDomainLookupByName",
         
     | 
| 
      
 991 
     | 
    
         
            +
                                             conn));
         
     | 
| 
      
 992 
     | 
    
         
            +
             
     | 
| 
      
 993 
     | 
    
         
            +
                return domain_new(dom, c);
         
     | 
| 
      
 994 
     | 
    
         
            +
            }
         
     | 
| 
      
 995 
     | 
    
         
            +
             
     | 
| 
      
 996 
     | 
    
         
            +
            /*
         
     | 
| 
      
 997 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 998 
     | 
    
         
            +
             *   conn.lookup_domain_by_id(id) -> Libvirt::Domain
         
     | 
| 
      
 999 
     | 
    
         
            +
             *
         
     | 
| 
      
 1000 
     | 
    
         
            +
             * Call +virDomainLookupByID+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainLookupByID]
         
     | 
| 
      
 1001 
     | 
    
         
            +
             * to retrieve a domain object for id.
         
     | 
| 
      
 1002 
     | 
    
         
            +
             */
         
     | 
| 
      
 1003 
     | 
    
         
            +
            static VALUE libvirt_conn_lookup_domain_by_id(VALUE c, VALUE id) {
         
     | 
| 
      
 1004 
     | 
    
         
            +
                virDomainPtr dom;
         
     | 
| 
      
 1005 
     | 
    
         
            +
                virConnectPtr conn = connect_get(c);
         
     | 
| 
      
 1006 
     | 
    
         
            +
             
     | 
| 
      
 1007 
     | 
    
         
            +
                dom = virDomainLookupByID(conn, NUM2INT(id));
         
     | 
| 
      
 1008 
     | 
    
         
            +
                _E(dom == NULL, create_error(e_RetrieveError, "virDomainLookupByID",
         
     | 
| 
      
 1009 
     | 
    
         
            +
                                             conn));
         
     | 
| 
      
 1010 
     | 
    
         
            +
             
     | 
| 
      
 1011 
     | 
    
         
            +
                return domain_new(dom, c);
         
     | 
| 
      
 1012 
     | 
    
         
            +
            }
         
     | 
| 
      
 1013 
     | 
    
         
            +
             
     | 
| 
      
 1014 
     | 
    
         
            +
            /*
         
     | 
| 
      
 1015 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 1016 
     | 
    
         
            +
             *   conn.lookup_domain_by_uuid(uuid) -> Libvirt::Domain
         
     | 
| 
      
 1017 
     | 
    
         
            +
             *
         
     | 
| 
      
 1018 
     | 
    
         
            +
             * Call +virDomainLookupByUUIDString+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainLookupByUUIDString]
         
     | 
| 
      
 1019 
     | 
    
         
            +
             * to retrieve a domain object for uuid.
         
     | 
| 
      
 1020 
     | 
    
         
            +
             */
         
     | 
| 
      
 1021 
     | 
    
         
            +
            static VALUE libvirt_conn_lookup_domain_by_uuid(VALUE c, VALUE uuid) {
         
     | 
| 
      
 1022 
     | 
    
         
            +
                virDomainPtr dom;
         
     | 
| 
      
 1023 
     | 
    
         
            +
                virConnectPtr conn = connect_get(c);
         
     | 
| 
      
 1024 
     | 
    
         
            +
             
     | 
| 
      
 1025 
     | 
    
         
            +
                dom = virDomainLookupByUUIDString(conn, StringValueCStr(uuid));
         
     | 
| 
      
 1026 
     | 
    
         
            +
                _E(dom == NULL, create_error(e_RetrieveError, "virDomainLookupByUUID",
         
     | 
| 
      
 1027 
     | 
    
         
            +
                                             conn));
         
     | 
| 
      
 1028 
     | 
    
         
            +
             
     | 
| 
      
 1029 
     | 
    
         
            +
                return domain_new(dom, c);
         
     | 
| 
      
 1030 
     | 
    
         
            +
            }
         
     | 
| 
      
 1031 
     | 
    
         
            +
             
     | 
| 
      
 1032 
     | 
    
         
            +
            /*
         
     | 
| 
      
 1033 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 1034 
     | 
    
         
            +
             *   conn.define_domain_xml(xml) -> Libvirt::Domain
         
     | 
| 
      
 1035 
     | 
    
         
            +
             *
         
     | 
| 
      
 1036 
     | 
    
         
            +
             * Call +virDomainDefineXML+[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainDefineXML]
         
     | 
| 
      
 1037 
     | 
    
         
            +
             * to define a permanent domain on this connection.
         
     | 
| 
      
 1038 
     | 
    
         
            +
             */
         
     | 
| 
      
 1039 
     | 
    
         
            +
            static VALUE libvirt_conn_define_domain_xml(VALUE c, VALUE xml) {
         
     | 
| 
      
 1040 
     | 
    
         
            +
                virDomainPtr dom;
         
     | 
| 
      
 1041 
     | 
    
         
            +
                virConnectPtr conn = connect_get(c);
         
     | 
| 
      
 1042 
     | 
    
         
            +
             
     | 
| 
      
 1043 
     | 
    
         
            +
                dom = virDomainDefineXML(conn, StringValueCStr(xml));
         
     | 
| 
      
 1044 
     | 
    
         
            +
                _E(dom == NULL, create_error(e_DefinitionError, "virDomainDefineXML",
         
     | 
| 
      
 1045 
     | 
    
         
            +
                                             conn));
         
     | 
| 
      
 1046 
     | 
    
         
            +
             
     | 
| 
      
 1047 
     | 
    
         
            +
                return domain_new(dom, c);
         
     | 
| 
      
 1048 
     | 
    
         
            +
            }
         
     | 
| 
      
 1049 
     | 
    
         
            +
             
     | 
| 
      
 1050 
     | 
    
         
            +
            #if HAVE_VIRCONNECTDOMAINXMLFROMNATIVE
         
     | 
| 
      
 1051 
     | 
    
         
            +
            /*
         
     | 
| 
      
 1052 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 1053 
     | 
    
         
            +
             *   conn.domain_xml_from_native(nativeFormat, xml, flags=0) -> string
         
     | 
| 
      
 1054 
     | 
    
         
            +
             *
         
     | 
| 
      
 1055 
     | 
    
         
            +
             * Call +virConnectDomainXMLFromNative+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectDomainXMLFromNative]
         
     | 
| 
      
 1056 
     | 
    
         
            +
             * to convert a native hypervisor domain representation to libvirt XML.
         
     | 
| 
      
 1057 
     | 
    
         
            +
             */
         
     | 
| 
      
 1058 
     | 
    
         
            +
            static VALUE libvirt_conn_domain_xml_from_native(int argc, VALUE *argv, VALUE s) {
         
     | 
| 
      
 1059 
     | 
    
         
            +
                VALUE nativeFormat, xml, flags;
         
     | 
| 
      
 1060 
     | 
    
         
            +
                char *ret;
         
     | 
| 
      
 1061 
     | 
    
         
            +
                VALUE result;
         
     | 
| 
      
 1062 
     | 
    
         
            +
             
     | 
| 
      
 1063 
     | 
    
         
            +
                rb_scan_args(argc, argv, "21", &nativeFormat, &xml, &flags);
         
     | 
| 
      
 1064 
     | 
    
         
            +
             
     | 
| 
      
 1065 
     | 
    
         
            +
                if (NIL_P(flags))
         
     | 
| 
      
 1066 
     | 
    
         
            +
                    flags = INT2FIX(0);
         
     | 
| 
      
 1067 
     | 
    
         
            +
             
     | 
| 
      
 1068 
     | 
    
         
            +
                ret = virConnectDomainXMLFromNative(conn(s), StringValueCStr(nativeFormat),
         
     | 
| 
      
 1069 
     | 
    
         
            +
                                                    StringValueCStr(xml), NUM2UINT(flags));
         
     | 
| 
      
 1070 
     | 
    
         
            +
                _E(ret == NULL, create_error(e_Error, "virConnectDomainXMLFromNative",
         
     | 
| 
      
 1071 
     | 
    
         
            +
                                             conn(s)));
         
     | 
| 
      
 1072 
     | 
    
         
            +
             
     | 
| 
      
 1073 
     | 
    
         
            +
                result = rb_str_new2(ret);
         
     | 
| 
      
 1074 
     | 
    
         
            +
             
     | 
| 
      
 1075 
     | 
    
         
            +
                free(ret);
         
     | 
| 
      
 1076 
     | 
    
         
            +
             
     | 
| 
      
 1077 
     | 
    
         
            +
                return result;
         
     | 
| 
      
 1078 
     | 
    
         
            +
            }
         
     | 
| 
      
 1079 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 1080 
     | 
    
         
            +
             
     | 
| 
      
 1081 
     | 
    
         
            +
            #if HAVE_VIRCONNECTDOMAINXMLTONATIVE
         
     | 
| 
      
 1082 
     | 
    
         
            +
            /*
         
     | 
| 
      
 1083 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 1084 
     | 
    
         
            +
             *   conn.domain_xml_to_native(nativeFormat, xml, flags=0) -> string
         
     | 
| 
      
 1085 
     | 
    
         
            +
             *
         
     | 
| 
      
 1086 
     | 
    
         
            +
             * Call +virConnectDomainXMLToNative+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectDomainXMLToNative]
         
     | 
| 
      
 1087 
     | 
    
         
            +
             * to convert libvirt XML to a native domain hypervisor representation.
         
     | 
| 
      
 1088 
     | 
    
         
            +
             */
         
     | 
| 
      
 1089 
     | 
    
         
            +
            static VALUE libvirt_conn_domain_xml_to_native(int argc, VALUE *argv, VALUE s) {
         
     | 
| 
      
 1090 
     | 
    
         
            +
                VALUE nativeFormat, xml, flags;
         
     | 
| 
      
 1091 
     | 
    
         
            +
                char *ret;
         
     | 
| 
      
 1092 
     | 
    
         
            +
                VALUE result;
         
     | 
| 
      
 1093 
     | 
    
         
            +
             
     | 
| 
      
 1094 
     | 
    
         
            +
                rb_scan_args(argc, argv, "21", &nativeFormat, &xml, &flags);
         
     | 
| 
      
 1095 
     | 
    
         
            +
             
     | 
| 
      
 1096 
     | 
    
         
            +
                if (NIL_P(flags))
         
     | 
| 
      
 1097 
     | 
    
         
            +
                    flags = INT2FIX(0);
         
     | 
| 
      
 1098 
     | 
    
         
            +
             
     | 
| 
      
 1099 
     | 
    
         
            +
                ret = virConnectDomainXMLToNative(conn(s), StringValueCStr(nativeFormat),
         
     | 
| 
      
 1100 
     | 
    
         
            +
                                                  StringValueCStr(xml), NUM2UINT(flags));
         
     | 
| 
      
 1101 
     | 
    
         
            +
                _E(ret == NULL, create_error(e_Error, "virConnectDomainXMLToNative",
         
     | 
| 
      
 1102 
     | 
    
         
            +
                                             conn(s)));
         
     | 
| 
      
 1103 
     | 
    
         
            +
             
     | 
| 
      
 1104 
     | 
    
         
            +
                result = rb_str_new2(ret);
         
     | 
| 
      
 1105 
     | 
    
         
            +
             
     | 
| 
      
 1106 
     | 
    
         
            +
                free(ret);
         
     | 
| 
      
 1107 
     | 
    
         
            +
             
     | 
| 
      
 1108 
     | 
    
         
            +
                return result;
         
     | 
| 
      
 1109 
     | 
    
         
            +
            }
         
     | 
| 
      
 1110 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 1111 
     | 
    
         
            +
             
     | 
| 
      
 1112 
     | 
    
         
            +
            #if HAVE_TYPE_VIRINTERFACEPTR
         
     | 
| 
      
 1113 
     | 
    
         
            +
            /*
         
     | 
| 
      
 1114 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 1115 
     | 
    
         
            +
             *   conn.num_of_interfaces -> fixnum
         
     | 
| 
      
 1116 
     | 
    
         
            +
             *
         
     | 
| 
      
 1117 
     | 
    
         
            +
             * Call +virConnectNumOfInterfaces+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectNumOfInterfaces]
         
     | 
| 
      
 1118 
     | 
    
         
            +
             * to retrieve the number of active interfaces on this connection.
         
     | 
| 
      
 1119 
     | 
    
         
            +
             */
         
     | 
| 
      
 1120 
     | 
    
         
            +
            static VALUE libvirt_conn_num_of_interfaces(VALUE s) {
         
     | 
| 
      
 1121 
     | 
    
         
            +
                gen_conn_num_of(s, Interfaces);
         
     | 
| 
      
 1122 
     | 
    
         
            +
            }
         
     | 
| 
      
 1123 
     | 
    
         
            +
             
     | 
| 
      
 1124 
     | 
    
         
            +
            /*
         
     | 
| 
      
 1125 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 1126 
     | 
    
         
            +
             *   conn.list_interfaces -> list
         
     | 
| 
      
 1127 
     | 
    
         
            +
             *
         
     | 
| 
      
 1128 
     | 
    
         
            +
             * Call +virConnectListInterfaces+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectListInterfaces]
         
     | 
| 
      
 1129 
     | 
    
         
            +
             * to retrieve a list of active interface names on this connection.
         
     | 
| 
      
 1130 
     | 
    
         
            +
             */
         
     | 
| 
      
 1131 
     | 
    
         
            +
            static VALUE libvirt_conn_list_interfaces(VALUE s) {
         
     | 
| 
      
 1132 
     | 
    
         
            +
                gen_conn_list_names(s, Interfaces);
         
     | 
| 
      
 1133 
     | 
    
         
            +
            }
         
     | 
| 
      
 1134 
     | 
    
         
            +
             
     | 
| 
      
 1135 
     | 
    
         
            +
            /*
         
     | 
| 
      
 1136 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 1137 
     | 
    
         
            +
             *   conn.num_of_defined_interfaces -> fixnum
         
     | 
| 
      
 1138 
     | 
    
         
            +
             *
         
     | 
| 
      
 1139 
     | 
    
         
            +
             * Call +virConnectNumOfDefinedInterfaces+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectNumOfDefinedInterfaces]
         
     | 
| 
      
 1140 
     | 
    
         
            +
             * to retrieve the number of inactive interfaces on this connection.
         
     | 
| 
      
 1141 
     | 
    
         
            +
             */
         
     | 
| 
      
 1142 
     | 
    
         
            +
            static VALUE libvirt_conn_num_of_defined_interfaces(VALUE s) {
         
     | 
| 
      
 1143 
     | 
    
         
            +
                gen_conn_num_of(s, DefinedInterfaces);
         
     | 
| 
      
 1144 
     | 
    
         
            +
            }
         
     | 
| 
      
 1145 
     | 
    
         
            +
             
     | 
| 
      
 1146 
     | 
    
         
            +
            /*
         
     | 
| 
      
 1147 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 1148 
     | 
    
         
            +
             *   conn.list_defined_interfaces -> list
         
     | 
| 
      
 1149 
     | 
    
         
            +
             *
         
     | 
| 
      
 1150 
     | 
    
         
            +
             * Call +virConnectListDefinedInterfaces+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectListDefinedInterfaces]
         
     | 
| 
      
 1151 
     | 
    
         
            +
             * to retrieve a list of inactive interface names on this connection.
         
     | 
| 
      
 1152 
     | 
    
         
            +
             */
         
     | 
| 
      
 1153 
     | 
    
         
            +
            static VALUE libvirt_conn_list_defined_interfaces(VALUE s) {
         
     | 
| 
      
 1154 
     | 
    
         
            +
                gen_conn_list_names(s, DefinedInterfaces);
         
     | 
| 
      
 1155 
     | 
    
         
            +
            }
         
     | 
| 
      
 1156 
     | 
    
         
            +
             
     | 
| 
      
 1157 
     | 
    
         
            +
            extern VALUE interface_new(virInterfacePtr i, VALUE conn);
         
     | 
| 
      
 1158 
     | 
    
         
            +
            /*
         
     | 
| 
      
 1159 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 1160 
     | 
    
         
            +
             *   conn.lookup_interface_by_name(name) -> Libvirt::Interface
         
     | 
| 
      
 1161 
     | 
    
         
            +
             *
         
     | 
| 
      
 1162 
     | 
    
         
            +
             * Call +virInterfaceLookupByName+[http://www.libvirt.org/html/libvirt-libvirt.html#virInterfaceLookupByName]
         
     | 
| 
      
 1163 
     | 
    
         
            +
             * to retrieve an interface object by name.
         
     | 
| 
      
 1164 
     | 
    
         
            +
             */
         
     | 
| 
      
 1165 
     | 
    
         
            +
            static VALUE libvirt_conn_lookup_interface_by_name(VALUE c, VALUE name) {
         
     | 
| 
      
 1166 
     | 
    
         
            +
                virInterfacePtr iface;
         
     | 
| 
      
 1167 
     | 
    
         
            +
                virConnectPtr conn = connect_get(c);
         
     | 
| 
      
 1168 
     | 
    
         
            +
             
     | 
| 
      
 1169 
     | 
    
         
            +
                iface = virInterfaceLookupByName(conn, StringValueCStr(name));
         
     | 
| 
      
 1170 
     | 
    
         
            +
                _E(iface == NULL, create_error(e_RetrieveError, "virInterfaceLookupByName",
         
     | 
| 
      
 1171 
     | 
    
         
            +
                                               conn));
         
     | 
| 
      
 1172 
     | 
    
         
            +
             
     | 
| 
      
 1173 
     | 
    
         
            +
                return interface_new(iface, c);
         
     | 
| 
      
 1174 
     | 
    
         
            +
            }
         
     | 
| 
      
 1175 
     | 
    
         
            +
             
     | 
| 
      
 1176 
     | 
    
         
            +
            /*
         
     | 
| 
      
 1177 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 1178 
     | 
    
         
            +
             *   conn.lookup_interface_by_mac(mac) -> Libvirt::Interface
         
     | 
| 
      
 1179 
     | 
    
         
            +
             *
         
     | 
| 
      
 1180 
     | 
    
         
            +
             * Call +virInterfaceLookupByMACString+[http://www.libvirt.org/html/libvirt-libvirt.html#virInterfaceLookupByMACString]
         
     | 
| 
      
 1181 
     | 
    
         
            +
             * to retrieve an interface object by MAC address.
         
     | 
| 
      
 1182 
     | 
    
         
            +
             */
         
     | 
| 
      
 1183 
     | 
    
         
            +
            static VALUE libvirt_conn_lookup_interface_by_mac(VALUE c, VALUE mac) {
         
     | 
| 
      
 1184 
     | 
    
         
            +
                virInterfacePtr iface;
         
     | 
| 
      
 1185 
     | 
    
         
            +
                virConnectPtr conn = connect_get(c);
         
     | 
| 
      
 1186 
     | 
    
         
            +
             
     | 
| 
      
 1187 
     | 
    
         
            +
                iface = virInterfaceLookupByMACString(conn, StringValueCStr(mac));
         
     | 
| 
      
 1188 
     | 
    
         
            +
                _E(iface == NULL, create_error(e_RetrieveError,
         
     | 
| 
      
 1189 
     | 
    
         
            +
                                               "virInterfaceLookupByMACString", conn));
         
     | 
| 
      
 1190 
     | 
    
         
            +
             
     | 
| 
      
 1191 
     | 
    
         
            +
                return interface_new(iface, c);
         
     | 
| 
      
 1192 
     | 
    
         
            +
            }
         
     | 
| 
      
 1193 
     | 
    
         
            +
             
     | 
| 
      
 1194 
     | 
    
         
            +
            /*
         
     | 
| 
      
 1195 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 1196 
     | 
    
         
            +
             *   conn.define_interface_xml(xml, flags=0) -> Libvirt::Interface
         
     | 
| 
      
 1197 
     | 
    
         
            +
             *
         
     | 
| 
      
 1198 
     | 
    
         
            +
             * Call +virInterfaceDefineXML+[http://www.libvirt.org/html/libvirt-libvirt.html#virInterfaceDefineXML]
         
     | 
| 
      
 1199 
     | 
    
         
            +
             * to define a new interface from xml.
         
     | 
| 
      
 1200 
     | 
    
         
            +
             */
         
     | 
| 
      
 1201 
     | 
    
         
            +
            static VALUE libvirt_conn_define_interface_xml(int argc, VALUE *argv, VALUE c) {
         
     | 
| 
      
 1202 
     | 
    
         
            +
                virInterfacePtr iface;
         
     | 
| 
      
 1203 
     | 
    
         
            +
                virConnectPtr conn = connect_get(c);
         
     | 
| 
      
 1204 
     | 
    
         
            +
                VALUE xml, flags;
         
     | 
| 
      
 1205 
     | 
    
         
            +
             
     | 
| 
      
 1206 
     | 
    
         
            +
                rb_scan_args(argc, argv, "11", &xml, &flags);
         
     | 
| 
      
 1207 
     | 
    
         
            +
             
     | 
| 
      
 1208 
     | 
    
         
            +
                if (NIL_P(flags))
         
     | 
| 
      
 1209 
     | 
    
         
            +
                    flags = INT2FIX(0);
         
     | 
| 
      
 1210 
     | 
    
         
            +
             
     | 
| 
      
 1211 
     | 
    
         
            +
                iface = virInterfaceDefineXML(conn, StringValueCStr(xml), NUM2UINT(flags));
         
     | 
| 
      
 1212 
     | 
    
         
            +
                _E(iface == NULL, create_error(e_DefinitionError, "virInterfaceDefineXML",
         
     | 
| 
      
 1213 
     | 
    
         
            +
                                               conn));
         
     | 
| 
      
 1214 
     | 
    
         
            +
             
     | 
| 
      
 1215 
     | 
    
         
            +
                return interface_new(iface, c);
         
     | 
| 
      
 1216 
     | 
    
         
            +
            }
         
     | 
| 
      
 1217 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 1218 
     | 
    
         
            +
             
     | 
| 
      
 1219 
     | 
    
         
            +
            /*
         
     | 
| 
      
 1220 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 1221 
     | 
    
         
            +
             *   conn.num_of_networks -> fixnum
         
     | 
| 
      
 1222 
     | 
    
         
            +
             *
         
     | 
| 
      
 1223 
     | 
    
         
            +
             * Call +virConnectNumOfNetworks+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectNumOfNetworks]
         
     | 
| 
      
 1224 
     | 
    
         
            +
             * to retrieve the number of active networks on this connection.
         
     | 
| 
      
 1225 
     | 
    
         
            +
             */
         
     | 
| 
      
 1226 
     | 
    
         
            +
            static VALUE libvirt_conn_num_of_networks(VALUE s) {
         
     | 
| 
      
 1227 
     | 
    
         
            +
                gen_conn_num_of(s, Networks);
         
     | 
| 
      
 1228 
     | 
    
         
            +
            }
         
     | 
| 
      
 1229 
     | 
    
         
            +
             
     | 
| 
      
 1230 
     | 
    
         
            +
            /*
         
     | 
| 
      
 1231 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 1232 
     | 
    
         
            +
             *   conn.list_networks -> list
         
     | 
| 
      
 1233 
     | 
    
         
            +
             *
         
     | 
| 
      
 1234 
     | 
    
         
            +
             * Call +virConnectListNetworks+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectListNetworks]
         
     | 
| 
      
 1235 
     | 
    
         
            +
             * to retrieve a list of active network names on this connection.
         
     | 
| 
      
 1236 
     | 
    
         
            +
             */
         
     | 
| 
      
 1237 
     | 
    
         
            +
            static VALUE libvirt_conn_list_networks(VALUE s) {
         
     | 
| 
      
 1238 
     | 
    
         
            +
                gen_conn_list_names(s, Networks);
         
     | 
| 
      
 1239 
     | 
    
         
            +
            }
         
     | 
| 
      
 1240 
     | 
    
         
            +
             
     | 
| 
      
 1241 
     | 
    
         
            +
            /*
         
     | 
| 
      
 1242 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 1243 
     | 
    
         
            +
             *   conn.num_of_defined_networks -> fixnum
         
     | 
| 
      
 1244 
     | 
    
         
            +
             *
         
     | 
| 
      
 1245 
     | 
    
         
            +
             * Call +virConnectNumOfDefinedNetworks+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectNumOfDefinedNetworks]
         
     | 
| 
      
 1246 
     | 
    
         
            +
             * to retrieve the number of inactive networks on this connection.
         
     | 
| 
      
 1247 
     | 
    
         
            +
             */
         
     | 
| 
      
 1248 
     | 
    
         
            +
            static VALUE libvirt_conn_num_of_defined_networks(VALUE s) {
         
     | 
| 
      
 1249 
     | 
    
         
            +
                gen_conn_num_of(s, DefinedNetworks);
         
     | 
| 
      
 1250 
     | 
    
         
            +
            }
         
     | 
| 
      
 1251 
     | 
    
         
            +
             
     | 
| 
      
 1252 
     | 
    
         
            +
            /*
         
     | 
| 
      
 1253 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 1254 
     | 
    
         
            +
             *   conn.list_of_defined_networks -> list
         
     | 
| 
      
 1255 
     | 
    
         
            +
             *
         
     | 
| 
      
 1256 
     | 
    
         
            +
             * Call +virConnectListDefinedNetworks+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectListDefinedNetworks]
         
     | 
| 
      
 1257 
     | 
    
         
            +
             * to retrieve a list of inactive network names on this connection.
         
     | 
| 
      
 1258 
     | 
    
         
            +
             */
         
     | 
| 
      
 1259 
     | 
    
         
            +
            static VALUE libvirt_conn_list_defined_networks(VALUE s) {
         
     | 
| 
      
 1260 
     | 
    
         
            +
                gen_conn_list_names(s, DefinedNetworks);
         
     | 
| 
      
 1261 
     | 
    
         
            +
            }
         
     | 
| 
      
 1262 
     | 
    
         
            +
             
     | 
| 
      
 1263 
     | 
    
         
            +
            /*
         
     | 
| 
      
 1264 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 1265 
     | 
    
         
            +
             *   conn.lookup_network_by_name(name) -> Libvirt::Network
         
     | 
| 
      
 1266 
     | 
    
         
            +
             *
         
     | 
| 
      
 1267 
     | 
    
         
            +
             * Call +virNetworkLookupByName+[http://www.libvirt.org/html/libvirt-libvirt.html#virNetworkLookupByName]
         
     | 
| 
      
 1268 
     | 
    
         
            +
             * to retrieve a network object by name.
         
     | 
| 
      
 1269 
     | 
    
         
            +
             */
         
     | 
| 
      
 1270 
     | 
    
         
            +
            static VALUE libvirt_conn_lookup_network_by_name(VALUE c, VALUE name) {
         
     | 
| 
      
 1271 
     | 
    
         
            +
                virNetworkPtr netw;
         
     | 
| 
      
 1272 
     | 
    
         
            +
                virConnectPtr conn = connect_get(c);
         
     | 
| 
      
 1273 
     | 
    
         
            +
             
     | 
| 
      
 1274 
     | 
    
         
            +
                netw = virNetworkLookupByName(conn, StringValueCStr(name));
         
     | 
| 
      
 1275 
     | 
    
         
            +
                _E(netw == NULL, create_error(e_RetrieveError, "virNetworkLookupByName",
         
     | 
| 
      
 1276 
     | 
    
         
            +
                                              conn));
         
     | 
| 
      
 1277 
     | 
    
         
            +
             
     | 
| 
      
 1278 
     | 
    
         
            +
                return network_new(netw, c);
         
     | 
| 
      
 1279 
     | 
    
         
            +
            }
         
     | 
| 
      
 1280 
     | 
    
         
            +
             
     | 
| 
      
 1281 
     | 
    
         
            +
            /*
         
     | 
| 
      
 1282 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 1283 
     | 
    
         
            +
             *   conn.lookup_network_by_uuid(uuid) -> Libvirt::Network
         
     | 
| 
      
 1284 
     | 
    
         
            +
             *
         
     | 
| 
      
 1285 
     | 
    
         
            +
             * Call +virNetworkLookupByUUIDString+[http://www.libvirt.org/html/libvirt-libvirt.html#virNetworkLookupByUUIDString]
         
     | 
| 
      
 1286 
     | 
    
         
            +
             * to retrieve a network object by UUID.
         
     | 
| 
      
 1287 
     | 
    
         
            +
             */
         
     | 
| 
      
 1288 
     | 
    
         
            +
            static VALUE libvirt_conn_lookup_network_by_uuid(VALUE c, VALUE uuid) {
         
     | 
| 
      
 1289 
     | 
    
         
            +
                virNetworkPtr netw;
         
     | 
| 
      
 1290 
     | 
    
         
            +
                virConnectPtr conn = connect_get(c);
         
     | 
| 
      
 1291 
     | 
    
         
            +
             
     | 
| 
      
 1292 
     | 
    
         
            +
                netw = virNetworkLookupByUUIDString(conn, StringValueCStr(uuid));
         
     | 
| 
      
 1293 
     | 
    
         
            +
                _E(netw == NULL, create_error(e_RetrieveError, "virNetworkLookupByUUID",
         
     | 
| 
      
 1294 
     | 
    
         
            +
                                              conn));
         
     | 
| 
      
 1295 
     | 
    
         
            +
             
     | 
| 
      
 1296 
     | 
    
         
            +
                return network_new(netw, c);
         
     | 
| 
      
 1297 
     | 
    
         
            +
            }
         
     | 
| 
      
 1298 
     | 
    
         
            +
             
     | 
| 
      
 1299 
     | 
    
         
            +
            /*
         
     | 
| 
      
 1300 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 1301 
     | 
    
         
            +
             *   conn.create_network_xml(xml) -> Libvirt::Network
         
     | 
| 
      
 1302 
     | 
    
         
            +
             *
         
     | 
| 
      
 1303 
     | 
    
         
            +
             * Call +virNetworkCreateXML+[http://www.libvirt.org/html/libvirt-libvirt.html#virNetworkCreateXML]
         
     | 
| 
      
 1304 
     | 
    
         
            +
             * to start a new transient network from xml.
         
     | 
| 
      
 1305 
     | 
    
         
            +
             */
         
     | 
| 
      
 1306 
     | 
    
         
            +
            static VALUE libvirt_conn_create_network_xml(VALUE c, VALUE xml) {
         
     | 
| 
      
 1307 
     | 
    
         
            +
                virNetworkPtr netw;
         
     | 
| 
      
 1308 
     | 
    
         
            +
                virConnectPtr conn = connect_get(c);
         
     | 
| 
      
 1309 
     | 
    
         
            +
             
     | 
| 
      
 1310 
     | 
    
         
            +
                netw = virNetworkCreateXML(conn, StringValueCStr(xml));
         
     | 
| 
      
 1311 
     | 
    
         
            +
                _E(netw == NULL, create_error(e_Error, "virNetworkCreateXML", conn));
         
     | 
| 
      
 1312 
     | 
    
         
            +
             
     | 
| 
      
 1313 
     | 
    
         
            +
                return network_new(netw, c);
         
     | 
| 
      
 1314 
     | 
    
         
            +
            }
         
     | 
| 
      
 1315 
     | 
    
         
            +
             
     | 
| 
      
 1316 
     | 
    
         
            +
            /*
         
     | 
| 
      
 1317 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 1318 
     | 
    
         
            +
             *   conn.define_network_xml(xml) -> Libvirt::Network
         
     | 
| 
      
 1319 
     | 
    
         
            +
             *
         
     | 
| 
      
 1320 
     | 
    
         
            +
             * Call +virNetworkDefineXML+[http://www.libvirt.org/html/libvirt-libvirt.html#virNetworkDefineXML]
         
     | 
| 
      
 1321 
     | 
    
         
            +
             * to define a new permanent network from xml.
         
     | 
| 
      
 1322 
     | 
    
         
            +
             */
         
     | 
| 
      
 1323 
     | 
    
         
            +
            static VALUE libvirt_conn_define_network_xml(VALUE c, VALUE xml) {
         
     | 
| 
      
 1324 
     | 
    
         
            +
                virNetworkPtr netw;
         
     | 
| 
      
 1325 
     | 
    
         
            +
                virConnectPtr conn = connect_get(c);
         
     | 
| 
      
 1326 
     | 
    
         
            +
             
     | 
| 
      
 1327 
     | 
    
         
            +
                netw = virNetworkDefineXML(conn, StringValueCStr(xml));
         
     | 
| 
      
 1328 
     | 
    
         
            +
                _E(netw == NULL, create_error(e_DefinitionError, "virNetworkDefineXML",
         
     | 
| 
      
 1329 
     | 
    
         
            +
                                              conn));
         
     | 
| 
      
 1330 
     | 
    
         
            +
             
     | 
| 
      
 1331 
     | 
    
         
            +
                return network_new(netw, c);
         
     | 
| 
      
 1332 
     | 
    
         
            +
            }
         
     | 
| 
      
 1333 
     | 
    
         
            +
             
     | 
| 
      
 1334 
     | 
    
         
            +
            #if HAVE_TYPE_VIRNODEDEVICEPTR
         
     | 
| 
      
 1335 
     | 
    
         
            +
            extern VALUE nodedevice_new(virNodeDevicePtr s, VALUE conn);
         
     | 
| 
      
 1336 
     | 
    
         
            +
             
     | 
| 
      
 1337 
     | 
    
         
            +
            /*
         
     | 
| 
      
 1338 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 1339 
     | 
    
         
            +
             *   conn.num_of_nodedevices(cap=nil, flags=0) -> fixnum
         
     | 
| 
      
 1340 
     | 
    
         
            +
             *
         
     | 
| 
      
 1341 
     | 
    
         
            +
             * Call +virNodeNumOfDevices+[http://www.libvirt.org/html/libvirt-libvirt.html#virNodeNumOfDevices]
         
     | 
| 
      
 1342 
     | 
    
         
            +
             * to retrieve the number of node devices on this connection.
         
     | 
| 
      
 1343 
     | 
    
         
            +
             */
         
     | 
| 
      
 1344 
     | 
    
         
            +
            static VALUE libvirt_conn_num_of_nodedevices(int argc, VALUE *argv, VALUE c) {
         
     | 
| 
      
 1345 
     | 
    
         
            +
                int result;
         
     | 
| 
      
 1346 
     | 
    
         
            +
                virConnectPtr conn = connect_get(c);
         
     | 
| 
      
 1347 
     | 
    
         
            +
                VALUE cap, flags;
         
     | 
| 
      
 1348 
     | 
    
         
            +
             
     | 
| 
      
 1349 
     | 
    
         
            +
                rb_scan_args(argc, argv, "02", &cap, &flags);
         
     | 
| 
      
 1350 
     | 
    
         
            +
             
     | 
| 
      
 1351 
     | 
    
         
            +
                if (NIL_P(flags))
         
     | 
| 
      
 1352 
     | 
    
         
            +
                    flags = INT2FIX(0);
         
     | 
| 
      
 1353 
     | 
    
         
            +
             
     | 
| 
      
 1354 
     | 
    
         
            +
                result = virNodeNumOfDevices(conn, get_string_or_nil(cap), NUM2UINT(flags));
         
     | 
| 
      
 1355 
     | 
    
         
            +
                _E(result < 0, create_error(e_RetrieveError, "virNodeNumOfDevices", conn));
         
     | 
| 
      
 1356 
     | 
    
         
            +
             
     | 
| 
      
 1357 
     | 
    
         
            +
                return INT2NUM(result);
         
     | 
| 
      
 1358 
     | 
    
         
            +
            }
         
     | 
| 
      
 1359 
     | 
    
         
            +
             
     | 
| 
      
 1360 
     | 
    
         
            +
            /*
         
     | 
| 
      
 1361 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 1362 
     | 
    
         
            +
             *   conn.list_nodedevices(cap=nil, flags=0) -> list
         
     | 
| 
      
 1363 
     | 
    
         
            +
             *
         
     | 
| 
      
 1364 
     | 
    
         
            +
             * Call +virNodeListDevices+[http://www.libvirt.org/html/libvirt-libvirt.html#virNodeListDevices]
         
     | 
| 
      
 1365 
     | 
    
         
            +
             * to retrieve a list of node device names on this connection.
         
     | 
| 
      
 1366 
     | 
    
         
            +
             */
         
     | 
| 
      
 1367 
     | 
    
         
            +
            static VALUE libvirt_conn_list_nodedevices(int argc, VALUE *argv, VALUE c) {
         
     | 
| 
      
 1368 
     | 
    
         
            +
                int r, num;
         
     | 
| 
      
 1369 
     | 
    
         
            +
                virConnectPtr conn = connect_get(c);
         
     | 
| 
      
 1370 
     | 
    
         
            +
                VALUE cap, flags_val;
         
     | 
| 
      
 1371 
     | 
    
         
            +
                char *capstr;
         
     | 
| 
      
 1372 
     | 
    
         
            +
                char **names;
         
     | 
| 
      
 1373 
     | 
    
         
            +
                unsigned int flags;
         
     | 
| 
      
 1374 
     | 
    
         
            +
             
     | 
| 
      
 1375 
     | 
    
         
            +
                rb_scan_args(argc, argv, "02", &cap, &flags_val);
         
     | 
| 
      
 1376 
     | 
    
         
            +
             
     | 
| 
      
 1377 
     | 
    
         
            +
                if (NIL_P(flags_val))
         
     | 
| 
      
 1378 
     | 
    
         
            +
                    flags = 0;
         
     | 
| 
      
 1379 
     | 
    
         
            +
                else
         
     | 
| 
      
 1380 
     | 
    
         
            +
                    flags = NUM2UINT(flags_val);
         
     | 
| 
      
 1381 
     | 
    
         
            +
             
     | 
| 
      
 1382 
     | 
    
         
            +
                capstr = get_string_or_nil(cap);
         
     | 
| 
      
 1383 
     | 
    
         
            +
             
     | 
| 
      
 1384 
     | 
    
         
            +
                num = virNodeNumOfDevices(conn, capstr, 0);
         
     | 
| 
      
 1385 
     | 
    
         
            +
                _E(num < 0, create_error(e_RetrieveError, "virNodeNumOfDevices", conn));
         
     | 
| 
      
 1386 
     | 
    
         
            +
                if (num == 0)
         
     | 
| 
      
 1387 
     | 
    
         
            +
                    /* if num is 0, don't call virNodeListDevices function */
         
     | 
| 
      
 1388 
     | 
    
         
            +
                    return rb_ary_new2(num);
         
     | 
| 
      
 1389 
     | 
    
         
            +
             
     | 
| 
      
 1390 
     | 
    
         
            +
                names = ALLOC_N(char *, num);
         
     | 
| 
      
 1391 
     | 
    
         
            +
                r = virNodeListDevices(conn, capstr, names, num, flags);
         
     | 
| 
      
 1392 
     | 
    
         
            +
                if (r < 0) {
         
     | 
| 
      
 1393 
     | 
    
         
            +
                    xfree(names);
         
     | 
| 
      
 1394 
     | 
    
         
            +
                    rb_exc_raise(create_error(e_RetrieveError, "virNodeListDevices", conn));
         
     | 
| 
      
 1395 
     | 
    
         
            +
                }
         
     | 
| 
      
 1396 
     | 
    
         
            +
             
     | 
| 
      
 1397 
     | 
    
         
            +
                return gen_list(num, &names);
         
     | 
| 
      
 1398 
     | 
    
         
            +
            }
         
     | 
| 
      
 1399 
     | 
    
         
            +
             
     | 
| 
      
 1400 
     | 
    
         
            +
            /*
         
     | 
| 
      
 1401 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 1402 
     | 
    
         
            +
             *   conn.lookup_nodedevice_by_name(name) -> Libvirt::NodeDevice
         
     | 
| 
      
 1403 
     | 
    
         
            +
             *
         
     | 
| 
      
 1404 
     | 
    
         
            +
             * Call +virNodeDeviceLookupByName+[http://www.libvirt.org/html/libvirt-libvirt.html#virNodeDeviceLookupByName]
         
     | 
| 
      
 1405 
     | 
    
         
            +
             * to retrieve a nodedevice object by name.
         
     | 
| 
      
 1406 
     | 
    
         
            +
             */
         
     | 
| 
      
 1407 
     | 
    
         
            +
            static VALUE libvirt_conn_lookup_nodedevice_by_name(VALUE c, VALUE name) {
         
     | 
| 
      
 1408 
     | 
    
         
            +
                virNodeDevicePtr nodedev;
         
     | 
| 
      
 1409 
     | 
    
         
            +
                virConnectPtr conn = connect_get(c);
         
     | 
| 
      
 1410 
     | 
    
         
            +
             
     | 
| 
      
 1411 
     | 
    
         
            +
                nodedev = virNodeDeviceLookupByName(conn, StringValueCStr(name));
         
     | 
| 
      
 1412 
     | 
    
         
            +
                _E(nodedev == NULL, create_error(e_RetrieveError,
         
     | 
| 
      
 1413 
     | 
    
         
            +
                                                 "virNodeDeviceLookupByName", conn));
         
     | 
| 
      
 1414 
     | 
    
         
            +
             
     | 
| 
      
 1415 
     | 
    
         
            +
                return nodedevice_new(nodedev, c);
         
     | 
| 
      
 1416 
     | 
    
         
            +
             
     | 
| 
      
 1417 
     | 
    
         
            +
            }
         
     | 
| 
      
 1418 
     | 
    
         
            +
             
     | 
| 
      
 1419 
     | 
    
         
            +
            #if HAVE_VIRNODEDEVICECREATEXML
         
     | 
| 
      
 1420 
     | 
    
         
            +
            /*
         
     | 
| 
      
 1421 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 1422 
     | 
    
         
            +
             *   conn.create_nodedevice_xml(xml, flags=0) -> Libvirt::NodeDevice
         
     | 
| 
      
 1423 
     | 
    
         
            +
             *
         
     | 
| 
      
 1424 
     | 
    
         
            +
             * Call +virNodeDeviceCreateXML+[http://www.libvirt.org/html/libvirt-libvirt.html#virNodeDeviceCreateXML]
         
     | 
| 
      
 1425 
     | 
    
         
            +
             * to create a new node device from xml.
         
     | 
| 
      
 1426 
     | 
    
         
            +
             */
         
     | 
| 
      
 1427 
     | 
    
         
            +
            static VALUE libvirt_conn_create_nodedevice_xml(int argc, VALUE *argv, VALUE c) {
         
     | 
| 
      
 1428 
     | 
    
         
            +
                virNodeDevicePtr nodedev;
         
     | 
| 
      
 1429 
     | 
    
         
            +
                virConnectPtr conn = connect_get(c);
         
     | 
| 
      
 1430 
     | 
    
         
            +
                VALUE xml, flags;
         
     | 
| 
      
 1431 
     | 
    
         
            +
             
     | 
| 
      
 1432 
     | 
    
         
            +
                rb_scan_args(argc, argv, "11", &xml, &flags);
         
     | 
| 
      
 1433 
     | 
    
         
            +
             
     | 
| 
      
 1434 
     | 
    
         
            +
                if (NIL_P(flags))
         
     | 
| 
      
 1435 
     | 
    
         
            +
                    flags = INT2FIX(0);
         
     | 
| 
      
 1436 
     | 
    
         
            +
             
     | 
| 
      
 1437 
     | 
    
         
            +
                nodedev = virNodeDeviceCreateXML(conn, StringValueCStr(xml),
         
     | 
| 
      
 1438 
     | 
    
         
            +
                                                 NUM2UINT(flags));
         
     | 
| 
      
 1439 
     | 
    
         
            +
                _E(nodedev == NULL, create_error(e_Error, "virNodeDeviceCreateXML", conn));
         
     | 
| 
      
 1440 
     | 
    
         
            +
             
     | 
| 
      
 1441 
     | 
    
         
            +
                return nodedevice_new(nodedev, c);
         
     | 
| 
      
 1442 
     | 
    
         
            +
            }
         
     | 
| 
      
 1443 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 1444 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 1445 
     | 
    
         
            +
             
     | 
| 
      
 1446 
     | 
    
         
            +
            #if HAVE_TYPE_VIRNWFILTERPTR
         
     | 
| 
      
 1447 
     | 
    
         
            +
            extern VALUE nwfilter_new(virNWFilterPtr nw, VALUE conn);
         
     | 
| 
      
 1448 
     | 
    
         
            +
             
     | 
| 
      
 1449 
     | 
    
         
            +
            /*
         
     | 
| 
      
 1450 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 1451 
     | 
    
         
            +
             *   conn.num_of_nwfilters -> fixnum
         
     | 
| 
      
 1452 
     | 
    
         
            +
             *
         
     | 
| 
      
 1453 
     | 
    
         
            +
             * Call +virConnectNumOfNWFilters+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectNumOfNWFilters]
         
     | 
| 
      
 1454 
     | 
    
         
            +
             * to retrieve the number of network filters on this connection.
         
     | 
| 
      
 1455 
     | 
    
         
            +
             */
         
     | 
| 
      
 1456 
     | 
    
         
            +
            static VALUE libvirt_conn_num_of_nwfilters(VALUE s) {
         
     | 
| 
      
 1457 
     | 
    
         
            +
                gen_conn_num_of(s, NWFilters);
         
     | 
| 
      
 1458 
     | 
    
         
            +
            }
         
     | 
| 
      
 1459 
     | 
    
         
            +
             
     | 
| 
      
 1460 
     | 
    
         
            +
            /*
         
     | 
| 
      
 1461 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 1462 
     | 
    
         
            +
             *   conn.list_nwfilters -> list
         
     | 
| 
      
 1463 
     | 
    
         
            +
             *
         
     | 
| 
      
 1464 
     | 
    
         
            +
             * Call +virConnectListNWFilters+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectListNWFilters]
         
     | 
| 
      
 1465 
     | 
    
         
            +
             * to retrieve a list of network filter names on this connection.
         
     | 
| 
      
 1466 
     | 
    
         
            +
             */
         
     | 
| 
      
 1467 
     | 
    
         
            +
            static VALUE libvirt_conn_list_nwfilters(VALUE s) {
         
     | 
| 
      
 1468 
     | 
    
         
            +
                gen_conn_list_names(s, NWFilters);
         
     | 
| 
      
 1469 
     | 
    
         
            +
            }
         
     | 
| 
      
 1470 
     | 
    
         
            +
             
     | 
| 
      
 1471 
     | 
    
         
            +
            /*
         
     | 
| 
      
 1472 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 1473 
     | 
    
         
            +
             *   conn.lookup_nwfilter_by_name(name) -> Libvirt::NWFilter
         
     | 
| 
      
 1474 
     | 
    
         
            +
             *
         
     | 
| 
      
 1475 
     | 
    
         
            +
             * Call +virNWFilterLookupByName+[http://www.libvirt.org/html/libvirt-libvirt.html#virNWFilterLookupByName]
         
     | 
| 
      
 1476 
     | 
    
         
            +
             * to retrieve a network filter object by name.
         
     | 
| 
      
 1477 
     | 
    
         
            +
             */
         
     | 
| 
      
 1478 
     | 
    
         
            +
            static VALUE libvirt_conn_lookup_nwfilter_by_name(VALUE c, VALUE name) {
         
     | 
| 
      
 1479 
     | 
    
         
            +
                virNWFilterPtr nwfilter;
         
     | 
| 
      
 1480 
     | 
    
         
            +
                virConnectPtr conn = connect_get(c);
         
     | 
| 
      
 1481 
     | 
    
         
            +
             
     | 
| 
      
 1482 
     | 
    
         
            +
                nwfilter = virNWFilterLookupByName(conn, StringValueCStr(name));
         
     | 
| 
      
 1483 
     | 
    
         
            +
                _E(nwfilter == NULL, create_error(e_RetrieveError,
         
     | 
| 
      
 1484 
     | 
    
         
            +
                                                  "virNWFilterLookupByName", conn));
         
     | 
| 
      
 1485 
     | 
    
         
            +
             
     | 
| 
      
 1486 
     | 
    
         
            +
                return nwfilter_new(nwfilter, c);
         
     | 
| 
      
 1487 
     | 
    
         
            +
            }
         
     | 
| 
      
 1488 
     | 
    
         
            +
             
     | 
| 
      
 1489 
     | 
    
         
            +
            /*
         
     | 
| 
      
 1490 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 1491 
     | 
    
         
            +
             *   conn.lookup_nwfilter_by_uuid(uuid) -> Libvirt::NWFilter
         
     | 
| 
      
 1492 
     | 
    
         
            +
             *
         
     | 
| 
      
 1493 
     | 
    
         
            +
             * Call +virNWFilterLookupByUUIDString+[http://www.libvirt.org/html/libvirt-libvirt.html#virNWFilterLookupByUUIDString]
         
     | 
| 
      
 1494 
     | 
    
         
            +
             * to retrieve a network filter object by UUID.
         
     | 
| 
      
 1495 
     | 
    
         
            +
             */
         
     | 
| 
      
 1496 
     | 
    
         
            +
            static VALUE libvirt_conn_lookup_nwfilter_by_uuid(VALUE c, VALUE uuid) {
         
     | 
| 
      
 1497 
     | 
    
         
            +
                virNWFilterPtr nwfilter;
         
     | 
| 
      
 1498 
     | 
    
         
            +
                virConnectPtr conn = connect_get(c);
         
     | 
| 
      
 1499 
     | 
    
         
            +
             
     | 
| 
      
 1500 
     | 
    
         
            +
                nwfilter = virNWFilterLookupByUUIDString(conn, StringValueCStr(uuid));
         
     | 
| 
      
 1501 
     | 
    
         
            +
                _E(nwfilter == NULL, create_error(e_RetrieveError,
         
     | 
| 
      
 1502 
     | 
    
         
            +
                                                  "virNWFilterLookupByUUIDString", conn));
         
     | 
| 
      
 1503 
     | 
    
         
            +
             
     | 
| 
      
 1504 
     | 
    
         
            +
                return nwfilter_new(nwfilter, c);
         
     | 
| 
      
 1505 
     | 
    
         
            +
            }
         
     | 
| 
      
 1506 
     | 
    
         
            +
             
     | 
| 
      
 1507 
     | 
    
         
            +
            /*
         
     | 
| 
      
 1508 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 1509 
     | 
    
         
            +
             *   conn.define_nwfilter_xml(xml) -> Libvirt::NWFilter
         
     | 
| 
      
 1510 
     | 
    
         
            +
             *
         
     | 
| 
      
 1511 
     | 
    
         
            +
             * Call +virNWFilterDefineXML+[http://www.libvirt.org/html/libvirt-libvirt.html#virNWFilterDefineXML]
         
     | 
| 
      
 1512 
     | 
    
         
            +
             * to define a new network filter from xml.
         
     | 
| 
      
 1513 
     | 
    
         
            +
             */
         
     | 
| 
      
 1514 
     | 
    
         
            +
            static VALUE libvirt_conn_define_nwfilter_xml(VALUE c, VALUE xml) {
         
     | 
| 
      
 1515 
     | 
    
         
            +
                virNWFilterPtr nwfilter;
         
     | 
| 
      
 1516 
     | 
    
         
            +
                virConnectPtr conn = connect_get(c);
         
     | 
| 
      
 1517 
     | 
    
         
            +
             
     | 
| 
      
 1518 
     | 
    
         
            +
                nwfilter = virNWFilterDefineXML(conn, StringValueCStr(xml));
         
     | 
| 
      
 1519 
     | 
    
         
            +
                _E(nwfilter == NULL, create_error(e_DefinitionError, "virNWFilterDefineXML",
         
     | 
| 
      
 1520 
     | 
    
         
            +
                                                  conn));
         
     | 
| 
      
 1521 
     | 
    
         
            +
             
     | 
| 
      
 1522 
     | 
    
         
            +
                return nwfilter_new(nwfilter, c);
         
     | 
| 
      
 1523 
     | 
    
         
            +
            }
         
     | 
| 
      
 1524 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 1525 
     | 
    
         
            +
             
     | 
| 
      
 1526 
     | 
    
         
            +
            #if HAVE_TYPE_VIRSECRETPTR
         
     | 
| 
      
 1527 
     | 
    
         
            +
            extern VALUE secret_new(virSecretPtr s, VALUE conn);
         
     | 
| 
      
 1528 
     | 
    
         
            +
             
     | 
| 
      
 1529 
     | 
    
         
            +
            /*
         
     | 
| 
      
 1530 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 1531 
     | 
    
         
            +
             *   conn.num_of_secrets -> fixnum
         
     | 
| 
      
 1532 
     | 
    
         
            +
             *
         
     | 
| 
      
 1533 
     | 
    
         
            +
             * Call +virConnectNumOfSecrets+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectNumOfSecrets]
         
     | 
| 
      
 1534 
     | 
    
         
            +
             * to retrieve the number of secrets on this connection.
         
     | 
| 
      
 1535 
     | 
    
         
            +
             */
         
     | 
| 
      
 1536 
     | 
    
         
            +
            static VALUE libvirt_conn_num_of_secrets(VALUE s) {
         
     | 
| 
      
 1537 
     | 
    
         
            +
                gen_conn_num_of(s, Secrets);
         
     | 
| 
      
 1538 
     | 
    
         
            +
            }
         
     | 
| 
      
 1539 
     | 
    
         
            +
             
     | 
| 
      
 1540 
     | 
    
         
            +
            /*
         
     | 
| 
      
 1541 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 1542 
     | 
    
         
            +
             *   conn.list_secrets -> list
         
     | 
| 
      
 1543 
     | 
    
         
            +
             *
         
     | 
| 
      
 1544 
     | 
    
         
            +
             * Call +virConnectListSecrets+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectListSecrets]
         
     | 
| 
      
 1545 
     | 
    
         
            +
             * to retrieve a list of secret UUIDs on this connection.
         
     | 
| 
      
 1546 
     | 
    
         
            +
             */
         
     | 
| 
      
 1547 
     | 
    
         
            +
            static VALUE libvirt_conn_list_secrets(VALUE s) {
         
     | 
| 
      
 1548 
     | 
    
         
            +
                gen_conn_list_names(s, Secrets);
         
     | 
| 
      
 1549 
     | 
    
         
            +
            }
         
     | 
| 
      
 1550 
     | 
    
         
            +
             
     | 
| 
      
 1551 
     | 
    
         
            +
            /*
         
     | 
| 
      
 1552 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 1553 
     | 
    
         
            +
             *   conn.lookup_secret_by_uuid(uuid) -> Libvirt::Secret
         
     | 
| 
      
 1554 
     | 
    
         
            +
             *
         
     | 
| 
      
 1555 
     | 
    
         
            +
             * Call +virSecretLookupByUUID+[http://www.libvirt.org/html/libvirt-libvirt.html#virSecretLookupByUUID]
         
     | 
| 
      
 1556 
     | 
    
         
            +
             * to retrieve a network object from uuid.
         
     | 
| 
      
 1557 
     | 
    
         
            +
             */
         
     | 
| 
      
 1558 
     | 
    
         
            +
            static VALUE libvirt_conn_lookup_secret_by_uuid(VALUE c, VALUE uuid) {
         
     | 
| 
      
 1559 
     | 
    
         
            +
                virSecretPtr secret;
         
     | 
| 
      
 1560 
     | 
    
         
            +
                virConnectPtr conn = connect_get(c);
         
     | 
| 
      
 1561 
     | 
    
         
            +
             
     | 
| 
      
 1562 
     | 
    
         
            +
                secret = virSecretLookupByUUIDString(conn, StringValueCStr(uuid));
         
     | 
| 
      
 1563 
     | 
    
         
            +
                _E(secret == NULL, create_error(e_RetrieveError, "virSecretLookupByUUID",
         
     | 
| 
      
 1564 
     | 
    
         
            +
                                                conn));
         
     | 
| 
      
 1565 
     | 
    
         
            +
             
     | 
| 
      
 1566 
     | 
    
         
            +
                return secret_new(secret, c);
         
     | 
| 
      
 1567 
     | 
    
         
            +
            }
         
     | 
| 
      
 1568 
     | 
    
         
            +
             
     | 
| 
      
 1569 
     | 
    
         
            +
            /*
         
     | 
| 
      
 1570 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 1571 
     | 
    
         
            +
             *   conn.lookup_secret_by_usage(usagetype, usageID) -> Libvirt::Secret
         
     | 
| 
      
 1572 
     | 
    
         
            +
             *
         
     | 
| 
      
 1573 
     | 
    
         
            +
             * Call +virSecretLookupByUsage+[http://www.libvirt.org/html/libvirt-libvirt.html#virSecretLookupByUsage]
         
     | 
| 
      
 1574 
     | 
    
         
            +
             * to retrieve a secret by usagetype.
         
     | 
| 
      
 1575 
     | 
    
         
            +
             */
         
     | 
| 
      
 1576 
     | 
    
         
            +
            static VALUE libvirt_conn_lookup_secret_by_usage(VALUE c, VALUE usagetype, VALUE usageID) {
         
     | 
| 
      
 1577 
     | 
    
         
            +
                virSecretPtr secret;
         
     | 
| 
      
 1578 
     | 
    
         
            +
                virConnectPtr conn = connect_get(c);
         
     | 
| 
      
 1579 
     | 
    
         
            +
             
     | 
| 
      
 1580 
     | 
    
         
            +
                secret = virSecretLookupByUsage(conn, NUM2UINT(usagetype),
         
     | 
| 
      
 1581 
     | 
    
         
            +
                                                StringValueCStr(usageID));
         
     | 
| 
      
 1582 
     | 
    
         
            +
                _E(secret == NULL, create_error(e_RetrieveError, "virSecretLookupByUsage",
         
     | 
| 
      
 1583 
     | 
    
         
            +
                                                conn));
         
     | 
| 
      
 1584 
     | 
    
         
            +
             
     | 
| 
      
 1585 
     | 
    
         
            +
                return secret_new(secret, c);
         
     | 
| 
      
 1586 
     | 
    
         
            +
            }
         
     | 
| 
      
 1587 
     | 
    
         
            +
             
     | 
| 
      
 1588 
     | 
    
         
            +
            /*
         
     | 
| 
      
 1589 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 1590 
     | 
    
         
            +
             *   conn.define_secret_xml(xml, flags=0) -> Libvirt::Secret
         
     | 
| 
      
 1591 
     | 
    
         
            +
             *
         
     | 
| 
      
 1592 
     | 
    
         
            +
             * Call +virSecretDefineXML+[http://www.libvirt.org/html/libvirt-libvirt.html#virSecretDefineXML]
         
     | 
| 
      
 1593 
     | 
    
         
            +
             * to define a new secret from xml.
         
     | 
| 
      
 1594 
     | 
    
         
            +
             */
         
     | 
| 
      
 1595 
     | 
    
         
            +
            static VALUE libvirt_conn_define_secret_xml(int argc, VALUE *argv, VALUE c) {
         
     | 
| 
      
 1596 
     | 
    
         
            +
                virSecretPtr secret;
         
     | 
| 
      
 1597 
     | 
    
         
            +
                virConnectPtr conn = connect_get(c);
         
     | 
| 
      
 1598 
     | 
    
         
            +
                VALUE xml, flags;
         
     | 
| 
      
 1599 
     | 
    
         
            +
             
     | 
| 
      
 1600 
     | 
    
         
            +
                rb_scan_args(argc, argv, "11", &xml, &flags);
         
     | 
| 
      
 1601 
     | 
    
         
            +
             
     | 
| 
      
 1602 
     | 
    
         
            +
                if (NIL_P(flags))
         
     | 
| 
      
 1603 
     | 
    
         
            +
                    flags = INT2FIX(0);
         
     | 
| 
      
 1604 
     | 
    
         
            +
             
     | 
| 
      
 1605 
     | 
    
         
            +
                secret = virSecretDefineXML(conn, StringValueCStr(xml), NUM2UINT(flags));
         
     | 
| 
      
 1606 
     | 
    
         
            +
                _E(secret == NULL, create_error(e_DefinitionError, "virSecretDefineXML",
         
     | 
| 
      
 1607 
     | 
    
         
            +
                                                conn));
         
     | 
| 
      
 1608 
     | 
    
         
            +
             
     | 
| 
      
 1609 
     | 
    
         
            +
                return secret_new(secret, c);
         
     | 
| 
      
 1610 
     | 
    
         
            +
            }
         
     | 
| 
      
 1611 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 1612 
     | 
    
         
            +
             
     | 
| 
      
 1613 
     | 
    
         
            +
            #if HAVE_TYPE_VIRSTORAGEPOOLPTR
         
     | 
| 
      
 1614 
     | 
    
         
            +
             
     | 
| 
      
 1615 
     | 
    
         
            +
            VALUE pool_new(virStoragePoolPtr n, VALUE conn);
         
     | 
| 
      
 1616 
     | 
    
         
            +
             
     | 
| 
      
 1617 
     | 
    
         
            +
            /*
         
     | 
| 
      
 1618 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 1619 
     | 
    
         
            +
             *   conn.list_storage_pools -> list
         
     | 
| 
      
 1620 
     | 
    
         
            +
             *
         
     | 
| 
      
 1621 
     | 
    
         
            +
             * Call +virConnectListStoragePools+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectListStoragePools]
         
     | 
| 
      
 1622 
     | 
    
         
            +
             * to retrieve a list of active storage pool names on this connection.
         
     | 
| 
      
 1623 
     | 
    
         
            +
             */
         
     | 
| 
      
 1624 
     | 
    
         
            +
            static VALUE libvirt_conn_list_storage_pools(VALUE s) {
         
     | 
| 
      
 1625 
     | 
    
         
            +
                gen_conn_list_names(s, StoragePools);
         
     | 
| 
      
 1626 
     | 
    
         
            +
            }
         
     | 
| 
      
 1627 
     | 
    
         
            +
             
     | 
| 
      
 1628 
     | 
    
         
            +
            /*
         
     | 
| 
      
 1629 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 1630 
     | 
    
         
            +
             *   conn.num_of_storage_pools -> fixnum
         
     | 
| 
      
 1631 
     | 
    
         
            +
             *
         
     | 
| 
      
 1632 
     | 
    
         
            +
             * Call +virConnectNumOfStoragePools+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectNumOfStoragePools]
         
     | 
| 
      
 1633 
     | 
    
         
            +
             * to retrieve the number of active storage pools on this connection.
         
     | 
| 
      
 1634 
     | 
    
         
            +
             */
         
     | 
| 
      
 1635 
     | 
    
         
            +
            static VALUE libvirt_conn_num_of_storage_pools(VALUE s) {
         
     | 
| 
      
 1636 
     | 
    
         
            +
                gen_conn_num_of(s, StoragePools);
         
     | 
| 
      
 1637 
     | 
    
         
            +
            }
         
     | 
| 
      
 1638 
     | 
    
         
            +
             
     | 
| 
      
 1639 
     | 
    
         
            +
            /*
         
     | 
| 
      
 1640 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 1641 
     | 
    
         
            +
             *   conn.list_defined_storage_pools -> list
         
     | 
| 
      
 1642 
     | 
    
         
            +
             *
         
     | 
| 
      
 1643 
     | 
    
         
            +
             * Call +virConnectListDefinedStoragePools+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectListDefinedStoragePools]
         
     | 
| 
      
 1644 
     | 
    
         
            +
             * to retrieve a list of inactive storage pool names on this connection.
         
     | 
| 
      
 1645 
     | 
    
         
            +
             */
         
     | 
| 
      
 1646 
     | 
    
         
            +
            static VALUE libvirt_conn_list_defined_storage_pools(VALUE s) {
         
     | 
| 
      
 1647 
     | 
    
         
            +
                gen_conn_list_names(s, DefinedStoragePools);
         
     | 
| 
      
 1648 
     | 
    
         
            +
            }
         
     | 
| 
      
 1649 
     | 
    
         
            +
             
     | 
| 
      
 1650 
     | 
    
         
            +
            /*
         
     | 
| 
      
 1651 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 1652 
     | 
    
         
            +
             *   conn.num_of_defined_storage_pools -> fixnum
         
     | 
| 
      
 1653 
     | 
    
         
            +
             *
         
     | 
| 
      
 1654 
     | 
    
         
            +
             * Call +virConnectNumOfDefinedStoragePools+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectNumOfDefinedStoragePools]
         
     | 
| 
      
 1655 
     | 
    
         
            +
             * to retrieve the number of inactive storage pools on this connection.
         
     | 
| 
      
 1656 
     | 
    
         
            +
             */
         
     | 
| 
      
 1657 
     | 
    
         
            +
            static VALUE libvirt_conn_num_of_defined_storage_pools(VALUE s) {
         
     | 
| 
      
 1658 
     | 
    
         
            +
                gen_conn_num_of(s, DefinedStoragePools);
         
     | 
| 
      
 1659 
     | 
    
         
            +
            }
         
     | 
| 
      
 1660 
     | 
    
         
            +
             
     | 
| 
      
 1661 
     | 
    
         
            +
            /*
         
     | 
| 
      
 1662 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 1663 
     | 
    
         
            +
             *   conn.lookup_storage_pool_by_name(name) -> Libvirt::StoragePool
         
     | 
| 
      
 1664 
     | 
    
         
            +
             *
         
     | 
| 
      
 1665 
     | 
    
         
            +
             * Call +virStoragePoolLookupByName+[http://www.libvirt.org/html/libvirt-libvirt.html#virStoragePoolLookupByName]
         
     | 
| 
      
 1666 
     | 
    
         
            +
             * to retrieve a storage pool object by name.
         
     | 
| 
      
 1667 
     | 
    
         
            +
             */
         
     | 
| 
      
 1668 
     | 
    
         
            +
            static VALUE libvirt_conn_lookup_pool_by_name(VALUE c, VALUE name) {
         
     | 
| 
      
 1669 
     | 
    
         
            +
                virStoragePoolPtr pool;
         
     | 
| 
      
 1670 
     | 
    
         
            +
                virConnectPtr conn = connect_get(c);
         
     | 
| 
      
 1671 
     | 
    
         
            +
             
     | 
| 
      
 1672 
     | 
    
         
            +
                pool = virStoragePoolLookupByName(conn, StringValueCStr(name));
         
     | 
| 
      
 1673 
     | 
    
         
            +
                _E(pool == NULL, create_error(e_RetrieveError, "virStoragePoolLookupByName",
         
     | 
| 
      
 1674 
     | 
    
         
            +
                                              conn));
         
     | 
| 
      
 1675 
     | 
    
         
            +
             
     | 
| 
      
 1676 
     | 
    
         
            +
                return pool_new(pool, c);
         
     | 
| 
      
 1677 
     | 
    
         
            +
            }
         
     | 
| 
      
 1678 
     | 
    
         
            +
             
     | 
| 
      
 1679 
     | 
    
         
            +
            /*
         
     | 
| 
      
 1680 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 1681 
     | 
    
         
            +
             *   conn.lookup_storage_pool_by_uuid(uuid) -> Libvirt::StoragePool
         
     | 
| 
      
 1682 
     | 
    
         
            +
             *
         
     | 
| 
      
 1683 
     | 
    
         
            +
             * Call +virStoragePoolLookupByUUIDString+[http://www.libvirt.org/html/libvirt-libvirt.html#virStoragePoolLookupByUUIDString]
         
     | 
| 
      
 1684 
     | 
    
         
            +
             * to retrieve a storage pool object by uuid.
         
     | 
| 
      
 1685 
     | 
    
         
            +
             */
         
     | 
| 
      
 1686 
     | 
    
         
            +
            static VALUE libvirt_conn_lookup_pool_by_uuid(VALUE c, VALUE uuid) {
         
     | 
| 
      
 1687 
     | 
    
         
            +
                virStoragePoolPtr pool;
         
     | 
| 
      
 1688 
     | 
    
         
            +
                virConnectPtr conn = connect_get(c);
         
     | 
| 
      
 1689 
     | 
    
         
            +
             
     | 
| 
      
 1690 
     | 
    
         
            +
                pool = virStoragePoolLookupByUUIDString(conn, StringValueCStr(uuid));
         
     | 
| 
      
 1691 
     | 
    
         
            +
                _E(pool == NULL, create_error(e_RetrieveError, "virStoragePoolLookupByUUID",
         
     | 
| 
      
 1692 
     | 
    
         
            +
                                              conn));
         
     | 
| 
      
 1693 
     | 
    
         
            +
             
     | 
| 
      
 1694 
     | 
    
         
            +
                return pool_new(pool, c);
         
     | 
| 
      
 1695 
     | 
    
         
            +
            }
         
     | 
| 
      
 1696 
     | 
    
         
            +
             
     | 
| 
      
 1697 
     | 
    
         
            +
            /*
         
     | 
| 
      
 1698 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 1699 
     | 
    
         
            +
             *   conn.create_storage_pool_xml(xml, flags=0) -> Libvirt::StoragePool
         
     | 
| 
      
 1700 
     | 
    
         
            +
             *
         
     | 
| 
      
 1701 
     | 
    
         
            +
             * Call +virStoragePoolCreateXML+[http://www.libvirt.org/html/libvirt-libvirt.html#virStoragePoolCreateXML]
         
     | 
| 
      
 1702 
     | 
    
         
            +
             * to start a new transient storage pool from xml.
         
     | 
| 
      
 1703 
     | 
    
         
            +
             */
         
     | 
| 
      
 1704 
     | 
    
         
            +
            static VALUE libvirt_conn_create_pool_xml(int argc, VALUE *argv, VALUE c) {
         
     | 
| 
      
 1705 
     | 
    
         
            +
                virStoragePoolPtr pool;
         
     | 
| 
      
 1706 
     | 
    
         
            +
                virConnectPtr conn = connect_get(c);
         
     | 
| 
      
 1707 
     | 
    
         
            +
                VALUE xml, flags;
         
     | 
| 
      
 1708 
     | 
    
         
            +
             
     | 
| 
      
 1709 
     | 
    
         
            +
                rb_scan_args(argc, argv, "11", &xml, &flags);
         
     | 
| 
      
 1710 
     | 
    
         
            +
             
     | 
| 
      
 1711 
     | 
    
         
            +
                if (NIL_P(flags))
         
     | 
| 
      
 1712 
     | 
    
         
            +
                    flags = INT2FIX(0);
         
     | 
| 
      
 1713 
     | 
    
         
            +
             
     | 
| 
      
 1714 
     | 
    
         
            +
                pool = virStoragePoolCreateXML(conn, StringValueCStr(xml), NUM2UINT(flags));
         
     | 
| 
      
 1715 
     | 
    
         
            +
                _E(pool == NULL, create_error(e_Error, "virStoragePoolCreateXML", conn));
         
     | 
| 
      
 1716 
     | 
    
         
            +
             
     | 
| 
      
 1717 
     | 
    
         
            +
                return pool_new(pool, c);
         
     | 
| 
      
 1718 
     | 
    
         
            +
            }
         
     | 
| 
      
 1719 
     | 
    
         
            +
             
     | 
| 
      
 1720 
     | 
    
         
            +
            /*
         
     | 
| 
      
 1721 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 1722 
     | 
    
         
            +
             *   conn.define_storage_pool_xml(xml, flags=0) -> Libvirt::StoragePool
         
     | 
| 
      
 1723 
     | 
    
         
            +
             *
         
     | 
| 
      
 1724 
     | 
    
         
            +
             * Call +virStoragePoolDefineXML+[http://www.libvirt.org/html/libvirt-libvirt.html#virStoragePoolDefineXML]
         
     | 
| 
      
 1725 
     | 
    
         
            +
             * to define a permanent storage pool from xml.
         
     | 
| 
      
 1726 
     | 
    
         
            +
             */
         
     | 
| 
      
 1727 
     | 
    
         
            +
            static VALUE libvirt_conn_define_pool_xml(int argc, VALUE *argv, VALUE c) {
         
     | 
| 
      
 1728 
     | 
    
         
            +
                virStoragePoolPtr pool;
         
     | 
| 
      
 1729 
     | 
    
         
            +
                virConnectPtr conn = connect_get(c);
         
     | 
| 
      
 1730 
     | 
    
         
            +
                VALUE xml, flags;
         
     | 
| 
      
 1731 
     | 
    
         
            +
             
     | 
| 
      
 1732 
     | 
    
         
            +
                rb_scan_args(argc, argv, "11", &xml, &flags);
         
     | 
| 
      
 1733 
     | 
    
         
            +
             
     | 
| 
      
 1734 
     | 
    
         
            +
                if (NIL_P(flags))
         
     | 
| 
      
 1735 
     | 
    
         
            +
                    flags = INT2FIX(0);
         
     | 
| 
      
 1736 
     | 
    
         
            +
             
     | 
| 
      
 1737 
     | 
    
         
            +
                pool = virStoragePoolDefineXML(conn, StringValueCStr(xml), NUM2UINT(flags));
         
     | 
| 
      
 1738 
     | 
    
         
            +
                _E(pool == NULL, create_error(e_DefinitionError, "virStoragePoolDefineXML",
         
     | 
| 
      
 1739 
     | 
    
         
            +
                                              conn));
         
     | 
| 
      
 1740 
     | 
    
         
            +
             
     | 
| 
      
 1741 
     | 
    
         
            +
                return pool_new(pool, c);
         
     | 
| 
      
 1742 
     | 
    
         
            +
            }
         
     | 
| 
      
 1743 
     | 
    
         
            +
             
     | 
| 
      
 1744 
     | 
    
         
            +
            /*
         
     | 
| 
      
 1745 
     | 
    
         
            +
             * call-seq:
         
     | 
| 
      
 1746 
     | 
    
         
            +
             *   conn.discover_storage_pool_sources(type, srcSpec=nil, flags=0) -> string
         
     | 
| 
      
 1747 
     | 
    
         
            +
             *
         
     | 
| 
      
 1748 
     | 
    
         
            +
             * Call +virConnectFindStoragePoolSources+[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectFindStoragePoolSources]
         
     | 
| 
      
 1749 
     | 
    
         
            +
             * to find the storage pool sources corresponding to type.
         
     | 
| 
      
 1750 
     | 
    
         
            +
             */
         
     | 
| 
      
 1751 
     | 
    
         
            +
            static VALUE libvirt_conn_find_storage_pool_sources(int argc, VALUE *argv, VALUE c) {
         
     | 
| 
      
 1752 
     | 
    
         
            +
                VALUE type, srcSpec_val, flags;
         
     | 
| 
      
 1753 
     | 
    
         
            +
             
     | 
| 
      
 1754 
     | 
    
         
            +
                rb_scan_args(argc, argv, "12", &type, &srcSpec_val, &flags);
         
     | 
| 
      
 1755 
     | 
    
         
            +
             
     | 
| 
      
 1756 
     | 
    
         
            +
                if (NIL_P(flags))
         
     | 
| 
      
 1757 
     | 
    
         
            +
                    flags = INT2FIX(0);
         
     | 
| 
      
 1758 
     | 
    
         
            +
             
     | 
| 
      
 1759 
     | 
    
         
            +
                gen_call_string(virConnectFindStoragePoolSources, conn(c), 1,
         
     | 
| 
      
 1760 
     | 
    
         
            +
                                connect_get(c), StringValueCStr(type),
         
     | 
| 
      
 1761 
     | 
    
         
            +
                                get_string_or_nil(srcSpec_val), NUM2UINT(flags));
         
     | 
| 
      
 1762 
     | 
    
         
            +
            }
         
     | 
| 
      
 1763 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 1764 
     | 
    
         
            +
             
     | 
| 
      
 1765 
     | 
    
         
            +
            /*
         
     | 
| 
      
 1766 
     | 
    
         
            +
             * Class Libvirt::Connect
         
     | 
| 
      
 1767 
     | 
    
         
            +
             */
         
     | 
| 
      
 1768 
     | 
    
         
            +
            void init_connect()
         
     | 
| 
      
 1769 
     | 
    
         
            +
            {
         
     | 
| 
      
 1770 
     | 
    
         
            +
                c_connect = rb_define_class_under(m_libvirt, "Connect", rb_cObject);
         
     | 
| 
      
 1771 
     | 
    
         
            +
             
     | 
| 
      
 1772 
     | 
    
         
            +
                /*
         
     | 
| 
      
 1773 
     | 
    
         
            +
                 * Class Libvirt::Connect::Nodeinfo
         
     | 
| 
      
 1774 
     | 
    
         
            +
                 */
         
     | 
| 
      
 1775 
     | 
    
         
            +
                c_node_info = rb_define_class_under(c_connect, "Nodeinfo", rb_cObject);
         
     | 
| 
      
 1776 
     | 
    
         
            +
                rb_define_attr(c_node_info, "model", 1, 0);
         
     | 
| 
      
 1777 
     | 
    
         
            +
                rb_define_attr(c_node_info, "memory", 1, 0);
         
     | 
| 
      
 1778 
     | 
    
         
            +
                rb_define_attr(c_node_info, "cpus", 1, 0);
         
     | 
| 
      
 1779 
     | 
    
         
            +
                rb_define_attr(c_node_info, "mhz", 1, 0);
         
     | 
| 
      
 1780 
     | 
    
         
            +
                rb_define_attr(c_node_info, "nodes", 1, 0);
         
     | 
| 
      
 1781 
     | 
    
         
            +
                rb_define_attr(c_node_info, "sockets", 1, 0);
         
     | 
| 
      
 1782 
     | 
    
         
            +
                rb_define_attr(c_node_info, "cores", 1, 0);
         
     | 
| 
      
 1783 
     | 
    
         
            +
                rb_define_attr(c_node_info, "threads", 1, 0);
         
     | 
| 
      
 1784 
     | 
    
         
            +
             
     | 
| 
      
 1785 
     | 
    
         
            +
                /*
         
     | 
| 
      
 1786 
     | 
    
         
            +
                 * Class Libvirt::Connect::NodeSecurityModel
         
     | 
| 
      
 1787 
     | 
    
         
            +
                 */
         
     | 
| 
      
 1788 
     | 
    
         
            +
                c_node_security_model = rb_define_class_under(c_connect,
         
     | 
| 
      
 1789 
     | 
    
         
            +
                                                              "NodeSecurityModel",
         
     | 
| 
      
 1790 
     | 
    
         
            +
                                                              rb_cObject);
         
     | 
| 
      
 1791 
     | 
    
         
            +
                rb_define_attr(c_node_security_model, "model", 1, 0);
         
     | 
| 
      
 1792 
     | 
    
         
            +
                rb_define_attr(c_node_security_model, "doi", 1, 0);
         
     | 
| 
      
 1793 
     | 
    
         
            +
             
     | 
| 
      
 1794 
     | 
    
         
            +
                rb_define_method(c_connect, "close", libvirt_conn_close, 0);
         
     | 
| 
      
 1795 
     | 
    
         
            +
                rb_define_method(c_connect, "closed?", libvirt_conn_closed_p, 0);
         
     | 
| 
      
 1796 
     | 
    
         
            +
                rb_define_method(c_connect, "type", libvirt_conn_type, 0);
         
     | 
| 
      
 1797 
     | 
    
         
            +
                rb_define_method(c_connect, "version", libvirt_conn_version, 0);
         
     | 
| 
      
 1798 
     | 
    
         
            +
            #if HAVE_VIRCONNECTGETLIBVERSION
         
     | 
| 
      
 1799 
     | 
    
         
            +
                rb_define_method(c_connect, "libversion", libvirt_conn_libversion, 0);
         
     | 
| 
      
 1800 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 1801 
     | 
    
         
            +
                rb_define_method(c_connect, "hostname", libvirt_conn_hostname, 0);
         
     | 
| 
      
 1802 
     | 
    
         
            +
                rb_define_method(c_connect, "uri", libvirt_conn_uri, 0);
         
     | 
| 
      
 1803 
     | 
    
         
            +
                rb_define_method(c_connect, "max_vcpus", libvirt_conn_max_vcpus, -1);
         
     | 
| 
      
 1804 
     | 
    
         
            +
                rb_define_method(c_connect, "node_get_info", libvirt_conn_node_get_info, 0);
         
     | 
| 
      
 1805 
     | 
    
         
            +
                rb_define_method(c_connect, "node_free_memory",
         
     | 
| 
      
 1806 
     | 
    
         
            +
                                 libvirt_conn_node_free_memory, 0);
         
     | 
| 
      
 1807 
     | 
    
         
            +
                rb_define_method(c_connect, "node_cells_free_memory",
         
     | 
| 
      
 1808 
     | 
    
         
            +
                                 libvirt_conn_node_cells_free_memory, -1);
         
     | 
| 
      
 1809 
     | 
    
         
            +
            #if HAVE_VIRNODEGETSECURITYMODEL
         
     | 
| 
      
 1810 
     | 
    
         
            +
                rb_define_method(c_connect, "node_get_security_model",
         
     | 
| 
      
 1811 
     | 
    
         
            +
                                 libvirt_conn_node_get_security_model, 0);
         
     | 
| 
      
 1812 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 1813 
     | 
    
         
            +
            #if HAVE_VIRCONNECTISENCRYPTED
         
     | 
| 
      
 1814 
     | 
    
         
            +
                rb_define_method(c_connect, "encrypted?", libvirt_conn_encrypted_p, 0);
         
     | 
| 
      
 1815 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 1816 
     | 
    
         
            +
            #if HAVE_VIRCONNECTISSECURE
         
     | 
| 
      
 1817 
     | 
    
         
            +
                rb_define_method(c_connect, "secure?", libvirt_conn_secure_p, 0);
         
     | 
| 
      
 1818 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 1819 
     | 
    
         
            +
                rb_define_method(c_connect, "capabilities", libvirt_conn_capabilities, 0);
         
     | 
| 
      
 1820 
     | 
    
         
            +
             
     | 
| 
      
 1821 
     | 
    
         
            +
            #if HAVE_VIRCONNECTCOMPARECPU
         
     | 
| 
      
 1822 
     | 
    
         
            +
                rb_define_const(c_connect, "CPU_COMPARE_ERROR",
         
     | 
| 
      
 1823 
     | 
    
         
            +
                                INT2NUM(VIR_CPU_COMPARE_ERROR));
         
     | 
| 
      
 1824 
     | 
    
         
            +
                rb_define_const(c_connect, "CPU_COMPARE_INCOMPATIBLE",
         
     | 
| 
      
 1825 
     | 
    
         
            +
                                INT2NUM(VIR_CPU_COMPARE_INCOMPATIBLE));
         
     | 
| 
      
 1826 
     | 
    
         
            +
                rb_define_const(c_connect, "CPU_COMPARE_IDENTICAL",
         
     | 
| 
      
 1827 
     | 
    
         
            +
                                INT2NUM(VIR_CPU_COMPARE_IDENTICAL));
         
     | 
| 
      
 1828 
     | 
    
         
            +
                rb_define_const(c_connect, "CPU_COMPARE_SUPERSET",
         
     | 
| 
      
 1829 
     | 
    
         
            +
                                INT2NUM(VIR_CPU_COMPARE_SUPERSET));
         
     | 
| 
      
 1830 
     | 
    
         
            +
             
     | 
| 
      
 1831 
     | 
    
         
            +
                rb_define_method(c_connect, "compare_cpu", libvirt_conn_compare_cpu, -1);
         
     | 
| 
      
 1832 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 1833 
     | 
    
         
            +
             
     | 
| 
      
 1834 
     | 
    
         
            +
            #if HAVE_VIRCONNECTBASELINECPU
         
     | 
| 
      
 1835 
     | 
    
         
            +
                rb_define_method(c_connect, "baseline_cpu", libvirt_conn_baseline_cpu, -1);
         
     | 
| 
      
 1836 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 1837 
     | 
    
         
            +
             
     | 
| 
      
 1838 
     | 
    
         
            +
                /* In the libvirt development history, the events were
         
     | 
| 
      
 1839 
     | 
    
         
            +
                 * first defined in commit 1509b8027fd0b73c30aeab443f81dd5a18d80544,
         
     | 
| 
      
 1840 
     | 
    
         
            +
                 * then ADDED and REMOVED were renamed to DEFINED and UNDEFINED at
         
     | 
| 
      
 1841 
     | 
    
         
            +
                 * the same time that the details were added
         
     | 
| 
      
 1842 
     | 
    
         
            +
                 * (d3d54d2fc92e350f250eda26cee5d0342416a9cf).  What this means is that
         
     | 
| 
      
 1843 
     | 
    
         
            +
                 * if we have to check for HAVE_CONST_VIR_DOMAIN_EVENT_DEFINED and
         
     | 
| 
      
 1844 
     | 
    
         
            +
                 * HAVE_CONST_VIR_DOMAIN_EVENT_STARTED to untangle these, and then we
         
     | 
| 
      
 1845 
     | 
    
         
            +
                 * can make a decision for many of the events based on that.
         
     | 
| 
      
 1846 
     | 
    
         
            +
                 */
         
     | 
| 
      
 1847 
     | 
    
         
            +
            #if HAVE_CONST_VIR_DOMAIN_EVENT_DEFINED
         
     | 
| 
      
 1848 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_DEFINED",
         
     | 
| 
      
 1849 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_DEFINED));
         
     | 
| 
      
 1850 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_DEFINED_ADDED",
         
     | 
| 
      
 1851 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_DEFINED_ADDED));
         
     | 
| 
      
 1852 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_DEFINED_UPDATED",
         
     | 
| 
      
 1853 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_DEFINED_UPDATED));
         
     | 
| 
      
 1854 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_UNDEFINED",
         
     | 
| 
      
 1855 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_UNDEFINED));
         
     | 
| 
      
 1856 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_UNDEFINED_REMOVED",
         
     | 
| 
      
 1857 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_UNDEFINED_REMOVED));
         
     | 
| 
      
 1858 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_STARTED_BOOTED",
         
     | 
| 
      
 1859 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_STARTED_BOOTED));
         
     | 
| 
      
 1860 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_STARTED_MIGRATED",
         
     | 
| 
      
 1861 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_STARTED_MIGRATED));
         
     | 
| 
      
 1862 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_STARTED_RESTORED",
         
     | 
| 
      
 1863 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_STARTED_RESTORED));
         
     | 
| 
      
 1864 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_SUSPENDED_PAUSED",
         
     | 
| 
      
 1865 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_SUSPENDED_PAUSED));
         
     | 
| 
      
 1866 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_SUSPENDED_MIGRATED",
         
     | 
| 
      
 1867 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_SUSPENDED_MIGRATED));
         
     | 
| 
      
 1868 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_RESUMED_UNPAUSED",
         
     | 
| 
      
 1869 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_RESUMED_UNPAUSED));
         
     | 
| 
      
 1870 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_RESUMED_MIGRATED",
         
     | 
| 
      
 1871 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_RESUMED_MIGRATED));
         
     | 
| 
      
 1872 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_STOPPED_SHUTDOWN",
         
     | 
| 
      
 1873 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_STOPPED_SHUTDOWN));
         
     | 
| 
      
 1874 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_STOPPED_DESTROYED",
         
     | 
| 
      
 1875 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_STOPPED_DESTROYED));
         
     | 
| 
      
 1876 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_STOPPED_CRASHED",
         
     | 
| 
      
 1877 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_STOPPED_CRASHED));
         
     | 
| 
      
 1878 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_STOPPED_MIGRATED",
         
     | 
| 
      
 1879 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_STOPPED_MIGRATED));
         
     | 
| 
      
 1880 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_STOPPED_SAVED",
         
     | 
| 
      
 1881 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_STOPPED_SAVED));
         
     | 
| 
      
 1882 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_STOPPED_FAILED",
         
     | 
| 
      
 1883 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_STOPPED_FAILED));
         
     | 
| 
      
 1884 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 1885 
     | 
    
         
            +
            #if HAVE_CONST_VIR_DOMAIN_EVENT_STARTED
         
     | 
| 
      
 1886 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_STARTED",
         
     | 
| 
      
 1887 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_STARTED));
         
     | 
| 
      
 1888 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_SUSPENDED",
         
     | 
| 
      
 1889 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_SUSPENDED));
         
     | 
| 
      
 1890 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_RESUMED",
         
     | 
| 
      
 1891 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_RESUMED));
         
     | 
| 
      
 1892 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_STOPPED",
         
     | 
| 
      
 1893 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_STOPPED));
         
     | 
| 
      
 1894 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 1895 
     | 
    
         
            +
            #if HAVE_TYPE_VIRDOMAINSNAPSHOTPTR
         
     | 
| 
      
 1896 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_STARTED_FROM_SNAPSHOT",
         
     | 
| 
      
 1897 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_STARTED_FROM_SNAPSHOT));
         
     | 
| 
      
 1898 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_STOPPED_FROM_SNAPSHOT",
         
     | 
| 
      
 1899 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_STOPPED_FROM_SNAPSHOT));
         
     | 
| 
      
 1900 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 1901 
     | 
    
         
            +
            #if HAVE_CONST_VIR_DOMAIN_EVENT_SUSPENDED_IOERROR
         
     | 
| 
      
 1902 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_SUSPENDED_IOERROR",
         
     | 
| 
      
 1903 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_SUSPENDED_IOERROR));
         
     | 
| 
      
 1904 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_SUSPENDED_WATCHDOG",
         
     | 
| 
      
 1905 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_SUSPENDED_WATCHDOG));
         
     | 
| 
      
 1906 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 1907 
     | 
    
         
            +
            #if HAVE_CONST_VIR_DOMAIN_EVENT_ID_WATCHDOG
         
     | 
| 
      
 1908 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_ID_WATCHDOG",
         
     | 
| 
      
 1909 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_ID_WATCHDOG));
         
     | 
| 
      
 1910 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_WATCHDOG_NONE",
         
     | 
| 
      
 1911 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_WATCHDOG_NONE));
         
     | 
| 
      
 1912 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_WATCHDOG_PAUSE",
         
     | 
| 
      
 1913 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_WATCHDOG_PAUSE));
         
     | 
| 
      
 1914 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_WATCHDOG_RESET",
         
     | 
| 
      
 1915 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_WATCHDOG_RESET));
         
     | 
| 
      
 1916 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_WATCHDOG_POWEROFF",
         
     | 
| 
      
 1917 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_WATCHDOG_POWEROFF));
         
     | 
| 
      
 1918 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_WATCHDOG_SHUTDOWN",
         
     | 
| 
      
 1919 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_WATCHDOG_SHUTDOWN));
         
     | 
| 
      
 1920 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_WATCHDOG_DEBUG",
         
     | 
| 
      
 1921 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_WATCHDOG_DEBUG));
         
     | 
| 
      
 1922 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 1923 
     | 
    
         
            +
            #if HAVE_CONST_VIR_DOMAIN_EVENT_ID_IO_ERROR
         
     | 
| 
      
 1924 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_ID_IO_ERROR",
         
     | 
| 
      
 1925 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_ID_IO_ERROR));
         
     | 
| 
      
 1926 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_IO_ERROR_NONE",
         
     | 
| 
      
 1927 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_IO_ERROR_NONE));
         
     | 
| 
      
 1928 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_IO_ERROR_PAUSE",
         
     | 
| 
      
 1929 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_IO_ERROR_PAUSE));
         
     | 
| 
      
 1930 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_IO_ERROR_REPORT",
         
     | 
| 
      
 1931 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_IO_ERROR_REPORT));
         
     | 
| 
      
 1932 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 1933 
     | 
    
         
            +
            #if HAVE_CONST_VIR_DOMAIN_EVENT_ID_GRAPHICS
         
     | 
| 
      
 1934 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_ID_GRAPHICS",
         
     | 
| 
      
 1935 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_ID_GRAPHICS));
         
     | 
| 
      
 1936 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_GRAPHICS_CONNECT",
         
     | 
| 
      
 1937 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_GRAPHICS_CONNECT));
         
     | 
| 
      
 1938 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_GRAPHICS_INITIALIZE",
         
     | 
| 
      
 1939 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_GRAPHICS_INITIALIZE));
         
     | 
| 
      
 1940 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_GRAPHICS_DISCONNECT",
         
     | 
| 
      
 1941 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_GRAPHICS_DISCONNECT));
         
     | 
| 
      
 1942 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV4",
         
     | 
| 
      
 1943 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV4));
         
     | 
| 
      
 1944 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV6",
         
     | 
| 
      
 1945 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_IPV6));
         
     | 
| 
      
 1946 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 1947 
     | 
    
         
            +
            #if HAVE_VIRCONNECTDOMAINEVENTREGISTERANY
         
     | 
| 
      
 1948 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_ID_LIFECYCLE",
         
     | 
| 
      
 1949 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_ID_LIFECYCLE));
         
     | 
| 
      
 1950 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 1951 
     | 
    
         
            +
            #if HAVE_CONST_VIR_DOMAIN_EVENT_ID_REBOOT
         
     | 
| 
      
 1952 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_ID_REBOOT",
         
     | 
| 
      
 1953 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_ID_REBOOT));
         
     | 
| 
      
 1954 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 1955 
     | 
    
         
            +
            #if HAVE_CONST_VIR_DOMAIN_EVENT_ID_RTC_CHANGE
         
     | 
| 
      
 1956 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_ID_RTC_CHANGE",
         
     | 
| 
      
 1957 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_ID_RTC_CHANGE));
         
     | 
| 
      
 1958 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 1959 
     | 
    
         
            +
            #if HAVE_CONST_VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON
         
     | 
| 
      
 1960 
     | 
    
         
            +
                rb_define_const(c_connect, "DOMAIN_EVENT_ID_IO_ERROR_REASON",
         
     | 
| 
      
 1961 
     | 
    
         
            +
                                INT2NUM(VIR_DOMAIN_EVENT_ID_IO_ERROR_REASON));
         
     | 
| 
      
 1962 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 1963 
     | 
    
         
            +
             
     | 
| 
      
 1964 
     | 
    
         
            +
            #if HAVE_VIRCONNECTDOMAINEVENTREGISTER
         
     | 
| 
      
 1965 
     | 
    
         
            +
                rb_define_method(c_connect, "domain_event_register",
         
     | 
| 
      
 1966 
     | 
    
         
            +
                                 libvirt_conn_domain_event_register, -1);
         
     | 
| 
      
 1967 
     | 
    
         
            +
                rb_define_method(c_connect, "domain_event_deregister",
         
     | 
| 
      
 1968 
     | 
    
         
            +
                                 libvirt_conn_domain_event_deregister, 0);
         
     | 
| 
      
 1969 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 1970 
     | 
    
         
            +
             
     | 
| 
      
 1971 
     | 
    
         
            +
            #if HAVE_VIRCONNECTDOMAINEVENTREGISTERANY
         
     | 
| 
      
 1972 
     | 
    
         
            +
                rb_define_method(c_connect, "domain_event_register_any",
         
     | 
| 
      
 1973 
     | 
    
         
            +
                                 libvirt_conn_domain_event_register_any, -1);
         
     | 
| 
      
 1974 
     | 
    
         
            +
                rb_define_method(c_connect, "domain_event_deregister_any",
         
     | 
| 
      
 1975 
     | 
    
         
            +
                                 libvirt_conn_domain_event_deregister_any, 1);
         
     | 
| 
      
 1976 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 1977 
     | 
    
         
            +
             
     | 
| 
      
 1978 
     | 
    
         
            +
                /* Domain creation/lookup */
         
     | 
| 
      
 1979 
     | 
    
         
            +
                rb_define_method(c_connect, "num_of_domains",
         
     | 
| 
      
 1980 
     | 
    
         
            +
                                 libvirt_conn_num_of_domains, 0);
         
     | 
| 
      
 1981 
     | 
    
         
            +
                rb_define_method(c_connect, "list_domains", libvirt_conn_list_domains, 0);
         
     | 
| 
      
 1982 
     | 
    
         
            +
                rb_define_method(c_connect, "num_of_defined_domains",
         
     | 
| 
      
 1983 
     | 
    
         
            +
                                 libvirt_conn_num_of_defined_domains, 0);
         
     | 
| 
      
 1984 
     | 
    
         
            +
                rb_define_method(c_connect, "list_defined_domains",
         
     | 
| 
      
 1985 
     | 
    
         
            +
                                 libvirt_conn_list_defined_domains, 0);
         
     | 
| 
      
 1986 
     | 
    
         
            +
                rb_define_method(c_connect, "create_domain_linux",
         
     | 
| 
      
 1987 
     | 
    
         
            +
                                 libvirt_conn_create_linux, -1);
         
     | 
| 
      
 1988 
     | 
    
         
            +
            #if HAVE_VIRDOMAINCREATEXML
         
     | 
| 
      
 1989 
     | 
    
         
            +
                rb_define_method(c_connect, "create_domain_xml",
         
     | 
| 
      
 1990 
     | 
    
         
            +
                                 libvirt_conn_create_xml, -1);
         
     | 
| 
      
 1991 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 1992 
     | 
    
         
            +
                rb_define_method(c_connect, "lookup_domain_by_name",
         
     | 
| 
      
 1993 
     | 
    
         
            +
                                 libvirt_conn_lookup_domain_by_name, 1);
         
     | 
| 
      
 1994 
     | 
    
         
            +
                rb_define_method(c_connect, "lookup_domain_by_id",
         
     | 
| 
      
 1995 
     | 
    
         
            +
                                 libvirt_conn_lookup_domain_by_id, 1);
         
     | 
| 
      
 1996 
     | 
    
         
            +
                rb_define_method(c_connect, "lookup_domain_by_uuid",
         
     | 
| 
      
 1997 
     | 
    
         
            +
                                 libvirt_conn_lookup_domain_by_uuid, 1);
         
     | 
| 
      
 1998 
     | 
    
         
            +
                rb_define_method(c_connect, "define_domain_xml",
         
     | 
| 
      
 1999 
     | 
    
         
            +
                                 libvirt_conn_define_domain_xml, 1);
         
     | 
| 
      
 2000 
     | 
    
         
            +
             
     | 
| 
      
 2001 
     | 
    
         
            +
            #if HAVE_VIRCONNECTDOMAINXMLFROMNATIVE
         
     | 
| 
      
 2002 
     | 
    
         
            +
                rb_define_method(c_connect, "domain_xml_from_native",
         
     | 
| 
      
 2003 
     | 
    
         
            +
                                 libvirt_conn_domain_xml_from_native, -1);
         
     | 
| 
      
 2004 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 2005 
     | 
    
         
            +
            #if HAVE_VIRCONNECTDOMAINXMLTONATIVE
         
     | 
| 
      
 2006 
     | 
    
         
            +
                rb_define_method(c_connect, "domain_xml_to_native",
         
     | 
| 
      
 2007 
     | 
    
         
            +
                                 libvirt_conn_domain_xml_to_native, -1);
         
     | 
| 
      
 2008 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 2009 
     | 
    
         
            +
             
     | 
| 
      
 2010 
     | 
    
         
            +
            #if HAVE_TYPE_VIRINTERFACEPTR
         
     | 
| 
      
 2011 
     | 
    
         
            +
                /* Interface lookup/creation methods */
         
     | 
| 
      
 2012 
     | 
    
         
            +
                rb_define_method(c_connect, "num_of_interfaces",
         
     | 
| 
      
 2013 
     | 
    
         
            +
                                 libvirt_conn_num_of_interfaces, 0);
         
     | 
| 
      
 2014 
     | 
    
         
            +
                rb_define_method(c_connect, "list_interfaces",
         
     | 
| 
      
 2015 
     | 
    
         
            +
                                 libvirt_conn_list_interfaces, 0);
         
     | 
| 
      
 2016 
     | 
    
         
            +
                rb_define_method(c_connect, "num_of_defined_interfaces",
         
     | 
| 
      
 2017 
     | 
    
         
            +
                                 libvirt_conn_num_of_defined_interfaces, 0);
         
     | 
| 
      
 2018 
     | 
    
         
            +
                rb_define_method(c_connect, "list_defined_interfaces",
         
     | 
| 
      
 2019 
     | 
    
         
            +
                                 libvirt_conn_list_defined_interfaces, 0);
         
     | 
| 
      
 2020 
     | 
    
         
            +
                rb_define_method(c_connect, "lookup_interface_by_name",
         
     | 
| 
      
 2021 
     | 
    
         
            +
                                 libvirt_conn_lookup_interface_by_name, 1);
         
     | 
| 
      
 2022 
     | 
    
         
            +
                rb_define_method(c_connect, "lookup_interface_by_mac",
         
     | 
| 
      
 2023 
     | 
    
         
            +
                                 libvirt_conn_lookup_interface_by_mac, 1);
         
     | 
| 
      
 2024 
     | 
    
         
            +
                rb_define_method(c_connect, "define_interface_xml",
         
     | 
| 
      
 2025 
     | 
    
         
            +
                                 libvirt_conn_define_interface_xml, -1);
         
     | 
| 
      
 2026 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 2027 
     | 
    
         
            +
             
     | 
| 
      
 2028 
     | 
    
         
            +
                /* Network lookup/creation methods */
         
     | 
| 
      
 2029 
     | 
    
         
            +
                rb_define_method(c_connect, "num_of_networks",
         
     | 
| 
      
 2030 
     | 
    
         
            +
                                 libvirt_conn_num_of_networks, 0);
         
     | 
| 
      
 2031 
     | 
    
         
            +
                rb_define_method(c_connect, "list_networks", libvirt_conn_list_networks, 0);
         
     | 
| 
      
 2032 
     | 
    
         
            +
                rb_define_method(c_connect, "num_of_defined_networks",
         
     | 
| 
      
 2033 
     | 
    
         
            +
                                 libvirt_conn_num_of_defined_networks, 0);
         
     | 
| 
      
 2034 
     | 
    
         
            +
                rb_define_method(c_connect, "list_defined_networks",
         
     | 
| 
      
 2035 
     | 
    
         
            +
                                 libvirt_conn_list_defined_networks, 0);
         
     | 
| 
      
 2036 
     | 
    
         
            +
                rb_define_method(c_connect, "lookup_network_by_name",
         
     | 
| 
      
 2037 
     | 
    
         
            +
                                 libvirt_conn_lookup_network_by_name, 1);
         
     | 
| 
      
 2038 
     | 
    
         
            +
                rb_define_method(c_connect, "lookup_network_by_uuid",
         
     | 
| 
      
 2039 
     | 
    
         
            +
                                 libvirt_conn_lookup_network_by_uuid, 1);
         
     | 
| 
      
 2040 
     | 
    
         
            +
                rb_define_method(c_connect, "create_network_xml",
         
     | 
| 
      
 2041 
     | 
    
         
            +
                                 libvirt_conn_create_network_xml, 1);
         
     | 
| 
      
 2042 
     | 
    
         
            +
                rb_define_method(c_connect, "define_network_xml",
         
     | 
| 
      
 2043 
     | 
    
         
            +
                                 libvirt_conn_define_network_xml, 1);
         
     | 
| 
      
 2044 
     | 
    
         
            +
             
     | 
| 
      
 2045 
     | 
    
         
            +
                /* Node device lookup/creation methods */
         
     | 
| 
      
 2046 
     | 
    
         
            +
            #if HAVE_TYPE_VIRNODEDEVICEPTR
         
     | 
| 
      
 2047 
     | 
    
         
            +
                rb_define_method(c_connect, "num_of_nodedevices",
         
     | 
| 
      
 2048 
     | 
    
         
            +
                                 libvirt_conn_num_of_nodedevices, -1);
         
     | 
| 
      
 2049 
     | 
    
         
            +
                rb_define_method(c_connect, "list_nodedevices",
         
     | 
| 
      
 2050 
     | 
    
         
            +
                                 libvirt_conn_list_nodedevices, -1);
         
     | 
| 
      
 2051 
     | 
    
         
            +
                rb_define_method(c_connect, "lookup_nodedevice_by_name",
         
     | 
| 
      
 2052 
     | 
    
         
            +
                                 libvirt_conn_lookup_nodedevice_by_name, 1);
         
     | 
| 
      
 2053 
     | 
    
         
            +
            #if HAVE_VIRNODEDEVICECREATEXML
         
     | 
| 
      
 2054 
     | 
    
         
            +
                rb_define_method(c_connect, "create_nodedevice_xml",
         
     | 
| 
      
 2055 
     | 
    
         
            +
                                 libvirt_conn_create_nodedevice_xml, -1);
         
     | 
| 
      
 2056 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 2057 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 2058 
     | 
    
         
            +
             
     | 
| 
      
 2059 
     | 
    
         
            +
            #if HAVE_TYPE_VIRNWFILTERPTR
         
     | 
| 
      
 2060 
     | 
    
         
            +
                /* NWFilter lookup/creation methods */
         
     | 
| 
      
 2061 
     | 
    
         
            +
                rb_define_method(c_connect, "num_of_nwfilters",
         
     | 
| 
      
 2062 
     | 
    
         
            +
                                 libvirt_conn_num_of_nwfilters, 0);
         
     | 
| 
      
 2063 
     | 
    
         
            +
                rb_define_method(c_connect, "list_nwfilters",
         
     | 
| 
      
 2064 
     | 
    
         
            +
                                 libvirt_conn_list_nwfilters, 0);
         
     | 
| 
      
 2065 
     | 
    
         
            +
                rb_define_method(c_connect, "lookup_nwfilter_by_name",
         
     | 
| 
      
 2066 
     | 
    
         
            +
                                 libvirt_conn_lookup_nwfilter_by_name, 1);
         
     | 
| 
      
 2067 
     | 
    
         
            +
                rb_define_method(c_connect, "lookup_nwfilter_by_uuid",
         
     | 
| 
      
 2068 
     | 
    
         
            +
                                 libvirt_conn_lookup_nwfilter_by_uuid, 1);
         
     | 
| 
      
 2069 
     | 
    
         
            +
                rb_define_method(c_connect, "define_nwfilter_xml",
         
     | 
| 
      
 2070 
     | 
    
         
            +
                                 libvirt_conn_define_nwfilter_xml, 1);
         
     | 
| 
      
 2071 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 2072 
     | 
    
         
            +
             
     | 
| 
      
 2073 
     | 
    
         
            +
            #if HAVE_TYPE_VIRSECRETPTR
         
     | 
| 
      
 2074 
     | 
    
         
            +
                /* Secret lookup/creation methods */
         
     | 
| 
      
 2075 
     | 
    
         
            +
                rb_define_method(c_connect, "num_of_secrets",
         
     | 
| 
      
 2076 
     | 
    
         
            +
                                 libvirt_conn_num_of_secrets, 0);
         
     | 
| 
      
 2077 
     | 
    
         
            +
                rb_define_method(c_connect, "list_secrets",
         
     | 
| 
      
 2078 
     | 
    
         
            +
                                 libvirt_conn_list_secrets, 0);
         
     | 
| 
      
 2079 
     | 
    
         
            +
                rb_define_method(c_connect, "lookup_secret_by_uuid",
         
     | 
| 
      
 2080 
     | 
    
         
            +
                                 libvirt_conn_lookup_secret_by_uuid, 1);
         
     | 
| 
      
 2081 
     | 
    
         
            +
                rb_define_method(c_connect, "lookup_secret_by_usage",
         
     | 
| 
      
 2082 
     | 
    
         
            +
                                 libvirt_conn_lookup_secret_by_usage, 2);
         
     | 
| 
      
 2083 
     | 
    
         
            +
                rb_define_method(c_connect, "define_secret_xml",
         
     | 
| 
      
 2084 
     | 
    
         
            +
                                 libvirt_conn_define_secret_xml, -1);
         
     | 
| 
      
 2085 
     | 
    
         
            +
            #endif
         
     | 
| 
      
 2086 
     | 
    
         
            +
             
     | 
| 
      
 2087 
     | 
    
         
            +
            #if HAVE_TYPE_VIRSTORAGEPOOLPTR
         
     | 
| 
      
 2088 
     | 
    
         
            +
                /* StoragePool lookup/creation methods */
         
     | 
| 
      
 2089 
     | 
    
         
            +
                rb_define_method(c_connect, "num_of_storage_pools",
         
     | 
| 
      
 2090 
     | 
    
         
            +
                                 libvirt_conn_num_of_storage_pools, 0);
         
     | 
| 
      
 2091 
     | 
    
         
            +
                rb_define_method(c_connect, "list_storage_pools",
         
     | 
| 
      
 2092 
     | 
    
         
            +
                                 libvirt_conn_list_storage_pools, 0);
         
     | 
| 
      
 2093 
     | 
    
         
            +
                rb_define_method(c_connect, "num_of_defined_storage_pools",
         
     | 
| 
      
 2094 
     | 
    
         
            +
                                 libvirt_conn_num_of_defined_storage_pools, 0);
         
     | 
| 
      
 2095 
     | 
    
         
            +
                rb_define_method(c_connect, "list_defined_storage_pools",
         
     | 
| 
      
 2096 
     | 
    
         
            +
                                 libvirt_conn_list_defined_storage_pools, 0);
         
     | 
| 
      
 2097 
     | 
    
         
            +
                rb_define_method(c_connect, "lookup_storage_pool_by_name",
         
     | 
| 
      
 2098 
     | 
    
         
            +
                                 libvirt_conn_lookup_pool_by_name, 1);
         
     | 
| 
      
 2099 
     | 
    
         
            +
                rb_define_method(c_connect, "lookup_storage_pool_by_uuid",
         
     | 
| 
      
 2100 
     | 
    
         
            +
                                 libvirt_conn_lookup_pool_by_uuid, 1);
         
     | 
| 
      
 2101 
     | 
    
         
            +
                rb_define_method(c_connect, "create_storage_pool_xml",
         
     | 
| 
      
 2102 
     | 
    
         
            +
                                 libvirt_conn_create_pool_xml, -1);
         
     | 
| 
      
 2103 
     | 
    
         
            +
                rb_define_method(c_connect, "define_storage_pool_xml",
         
     | 
| 
      
 2104 
     | 
    
         
            +
                                 libvirt_conn_define_pool_xml, -1);
         
     | 
| 
      
 2105 
     | 
    
         
            +
                rb_define_method(c_connect, "discover_storage_pool_sources",
         
     | 
| 
      
 2106 
     | 
    
         
            +
                                 libvirt_conn_find_storage_pool_sources, -1);
         
     | 
| 
      
 2107 
     | 
    
         
            +
            #endif
         
     | 
| 
       392 
2108 
     | 
    
         
             
            }
         
     |