ruby-libvirt 0.4.0 → 0.5.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.
- checksums.yaml +7 -0
- data/NEWS +10 -0
- data/README +188 -21
- data/Rakefile +11 -7
- data/ext/libvirt/_libvirt.c +252 -234
- data/ext/libvirt/common.c +346 -71
- data/ext/libvirt/common.h +171 -111
- data/ext/libvirt/connect.c +1851 -798
- data/ext/libvirt/connect.h +6 -5
- data/ext/libvirt/domain.c +3903 -1060
- data/ext/libvirt/domain.h +5 -3
- data/ext/libvirt/extconf.rb +275 -41
- data/ext/libvirt/interface.c +60 -41
- data/ext/libvirt/interface.h +3 -1
- data/ext/libvirt/network.c +291 -72
- data/ext/libvirt/network.h +3 -2
- data/ext/libvirt/nodedevice.c +138 -59
- data/ext/libvirt/nodedevice.h +3 -1
- data/ext/libvirt/nwfilter.c +39 -34
- data/ext/libvirt/nwfilter.h +3 -1
- data/ext/libvirt/secret.c +122 -64
- data/ext/libvirt/secret.h +3 -1
- data/ext/libvirt/storage.c +451 -233
- data/ext/libvirt/storage.h +1 -1
- data/ext/libvirt/stream.c +120 -122
- data/ext/libvirt/stream.h +4 -2
- data/tests/test_conn.rb +214 -67
- data/tests/test_domain.rb +553 -209
- data/tests/test_interface.rb +4 -10
- data/tests/test_network.rb +21 -12
- data/tests/test_nodedevice.rb +11 -1
- data/tests/test_nwfilter.rb +4 -0
- data/tests/test_open.rb +59 -6
- data/tests/test_secret.rb +25 -0
- data/tests/test_storage.rb +132 -28
- data/tests/test_stream.rb +171 -0
- data/tests/test_utils.rb +86 -15
- metadata +43 -66
data/ext/libvirt/common.h
CHANGED
@@ -2,27 +2,30 @@
|
|
2
2
|
#define COMMON_H
|
3
3
|
|
4
4
|
/* Macros to ease some of the boilerplate */
|
5
|
-
VALUE
|
6
|
-
|
5
|
+
VALUE ruby_libvirt_new_class(VALUE klass, void *ptr, VALUE conn,
|
6
|
+
RUBY_DATA_FUNC free_func);
|
7
7
|
|
8
|
-
#define
|
8
|
+
#define ruby_libvirt_get_struct(kind, v) \
|
9
9
|
do { \
|
10
10
|
vir##kind##Ptr ptr; \
|
11
11
|
Data_Get_Struct(v, vir##kind, ptr); \
|
12
|
-
if (!ptr)
|
12
|
+
if (!ptr) { \
|
13
13
|
rb_raise(rb_eArgError, #kind " has been freed"); \
|
14
|
+
} \
|
14
15
|
return ptr; \
|
15
16
|
} while (0);
|
16
17
|
|
17
|
-
#define
|
18
|
+
#define ruby_libvirt_free_struct(kind, p) \
|
18
19
|
do { \
|
19
20
|
int r; \
|
20
21
|
r = vir##kind##Free((vir##kind##Ptr) p); \
|
21
|
-
if (r < 0)
|
22
|
+
if (r < 0) { \
|
22
23
|
rb_raise(rb_eSystemCallError, # kind " free failed"); \
|
24
|
+
} \
|
23
25
|
} while(0);
|
24
26
|
|
25
|
-
|
27
|
+
void ruby_libvirt_raise_error_if(const int condition, VALUE error,
|
28
|
+
const char *method, virConnectPtr conn);
|
26
29
|
|
27
30
|
/*
|
28
31
|
* Code generating macros.
|
@@ -35,30 +38,37 @@ VALUE create_error(VALUE error, const char* method, virConnectPtr conn);
|
|
35
38
|
* function will return the string on success and throw an exception on
|
36
39
|
* error. The string returned by FUNC is freed if dealloc is true.
|
37
40
|
*/
|
38
|
-
#define
|
39
|
-
do {
|
40
|
-
const char *str;
|
41
|
-
VALUE result;
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
xfree((void *) str);
|
49
|
-
|
41
|
+
#define ruby_libvirt_generate_call_string(func, conn, dealloc, args...) \
|
42
|
+
do { \
|
43
|
+
const char *str; \
|
44
|
+
VALUE result; \
|
45
|
+
int exception; \
|
46
|
+
\
|
47
|
+
str = func(args); \
|
48
|
+
ruby_libvirt_raise_error_if(str == NULL, e_Error, # func, conn); \
|
49
|
+
if (dealloc) { \
|
50
|
+
result = rb_protect(ruby_libvirt_str_new2_wrap, (VALUE)&str, &exception); \
|
51
|
+
xfree((void *) str); \
|
52
|
+
if (exception) { \
|
53
|
+
rb_jump_tag(exception); \
|
54
|
+
} \
|
55
|
+
} \
|
56
|
+
else { \
|
57
|
+
result = rb_str_new2(str); \
|
58
|
+
} \
|
59
|
+
return result; \
|
50
60
|
} while(0)
|
51
61
|
|
52
62
|
/* Generate a call to vir##KIND##Free and return Qnil. Set the the embedded
|
53
63
|
* vir##KIND##Ptr to NULL. If that pointer is already NULL, do nothing.
|
54
64
|
*/
|
55
|
-
#define
|
65
|
+
#define ruby_libvirt_generate_call_free(kind, s) \
|
56
66
|
do { \
|
57
67
|
vir##kind##Ptr ptr; \
|
58
68
|
Data_Get_Struct(s, vir##kind, ptr); \
|
59
69
|
if (ptr != NULL) { \
|
60
70
|
int r = vir##kind##Free(ptr); \
|
61
|
-
|
71
|
+
ruby_libvirt_raise_error_if(r < 0, e_Error, "vir" #kind "Free", ruby_libvirt_connect_get(s)); \
|
62
72
|
DATA_PTR(s) = NULL; \
|
63
73
|
} \
|
64
74
|
return Qnil; \
|
@@ -68,89 +78,89 @@ VALUE create_error(VALUE error, const char* method, virConnectPtr conn);
|
|
68
78
|
* indicates error and 0 success. The Ruby function will return Qnil on
|
69
79
|
* success and throw an exception on error.
|
70
80
|
*/
|
71
|
-
#define
|
72
|
-
do {
|
73
|
-
int _r_##func;
|
74
|
-
_r_##func = func(args);
|
75
|
-
|
76
|
-
return Qnil;
|
77
|
-
} while(0)
|
78
|
-
|
79
|
-
/*
|
80
|
-
* Generate a call to a virConnectNumOf... function. C is the Ruby VALUE
|
81
|
-
* holding the connection and OBJS is a token indicating what objects to
|
82
|
-
* get the number of, e.g. 'Domains'
|
83
|
-
*/
|
84
|
-
#define gen_conn_num_of(c, objs) \
|
85
|
-
do { \
|
86
|
-
int result; \
|
87
|
-
virConnectPtr conn = connect_get(c); \
|
88
|
-
\
|
89
|
-
result = virConnectNumOf##objs(conn); \
|
90
|
-
_E(result < 0, create_error(e_RetrieveError, "virConnectNumOf" # objs, conn)); \
|
91
|
-
\
|
92
|
-
return INT2NUM(result); \
|
93
|
-
} while(0)
|
94
|
-
|
95
|
-
|
96
|
-
VALUE gen_list(int num, char ***list);
|
97
|
-
|
98
|
-
/*
|
99
|
-
* Generate a call to a virConnectList... function. S is the Ruby VALUE
|
100
|
-
* holding the connection and OBJS is a token indicating what objects to
|
101
|
-
* get the number of, e.g. 'Domains' The list function must return an array
|
102
|
-
* of strings, which is returned as a Ruby array
|
103
|
-
*/
|
104
|
-
#define gen_conn_list_names(s, objs) \
|
105
|
-
do { \
|
106
|
-
int r, num; \
|
107
|
-
char **names; \
|
108
|
-
virConnectPtr conn = connect_get(s); \
|
109
|
-
\
|
110
|
-
num = virConnectNumOf##objs(conn); \
|
111
|
-
_E(num < 0, create_error(e_RetrieveError, "virConnectNumOf" # objs, conn)); \
|
112
|
-
if (num == 0) { \
|
113
|
-
/* if num is 0, don't call virConnectList* function */ \
|
114
|
-
return rb_ary_new2(num); \
|
115
|
-
} \
|
116
|
-
names = ALLOC_N(char *, num); \
|
117
|
-
r = virConnectList##objs(conn, names, num); \
|
118
|
-
if (r < 0) { \
|
119
|
-
xfree(names); \
|
120
|
-
_E(r < 0, create_error(e_RetrieveError, "virConnectList" # objs, conn)); \
|
121
|
-
} \
|
122
|
-
\
|
123
|
-
return gen_list(num, &names); \
|
81
|
+
#define ruby_libvirt_generate_call_nil(func, conn, args...) \
|
82
|
+
do { \
|
83
|
+
int _r_##func; \
|
84
|
+
_r_##func = func(args); \
|
85
|
+
ruby_libvirt_raise_error_if(_r_##func < 0, e_Error, #func, conn); \
|
86
|
+
return Qnil; \
|
124
87
|
} while(0)
|
125
88
|
|
126
89
|
/* Generate a call to a function FUNC which returns an int; -1 indicates
|
127
90
|
* error, 0 indicates Qfalse, and 1 indicates Qtrue.
|
128
91
|
*/
|
129
|
-
#define
|
130
|
-
do {
|
131
|
-
int _r_##func;
|
132
|
-
_r_##func = func(args);
|
133
|
-
|
134
|
-
return _r_##func ? Qtrue : Qfalse;
|
92
|
+
#define ruby_libvirt_generate_call_truefalse(func, conn, args...) \
|
93
|
+
do { \
|
94
|
+
int _r_##func; \
|
95
|
+
_r_##func = func(args); \
|
96
|
+
ruby_libvirt_raise_error_if(_r_##func < 0, e_Error, #func, conn); \
|
97
|
+
return _r_##func ? Qtrue : Qfalse; \
|
135
98
|
} while(0)
|
136
99
|
|
137
100
|
/* Generate a call to a function FUNC which returns an int error, where -1
|
138
101
|
* indicates error and >= 0 success. The Ruby function will return the integer
|
139
102
|
* success and throw an exception on error.
|
140
103
|
*/
|
141
|
-
#define
|
104
|
+
#define ruby_libvirt_generate_call_int(func, conn, args...) \
|
142
105
|
do { \
|
143
106
|
int _r_##func; \
|
144
107
|
_r_##func = func(args); \
|
145
|
-
|
108
|
+
ruby_libvirt_raise_error_if(_r_##func < 0, e_RetrieveError, #func, conn); \
|
146
109
|
return INT2NUM(_r_##func); \
|
147
110
|
} while(0)
|
148
111
|
|
149
|
-
|
150
|
-
|
151
|
-
|
112
|
+
#define ruby_libvirt_generate_uuid(func, conn, obj) \
|
113
|
+
do { \
|
114
|
+
char uuid[VIR_UUID_STRING_BUFLEN]; \
|
115
|
+
int _r_##func; \
|
116
|
+
_r_##func = func(obj, uuid); \
|
117
|
+
ruby_libvirt_raise_error_if(_r_##func < 0, e_RetrieveError, #func, conn); \
|
118
|
+
return rb_str_new2((char *) uuid); \
|
119
|
+
} while (0)
|
152
120
|
|
153
|
-
|
121
|
+
|
122
|
+
#define ruby_libvirt_generate_call_list_all(type, argc, argv, listfunc, object, val, newfunc, freefunc) \
|
123
|
+
do { \
|
124
|
+
VALUE flags; \
|
125
|
+
type *list; \
|
126
|
+
size_t i; \
|
127
|
+
int ret; \
|
128
|
+
VALUE result; \
|
129
|
+
int exception = 0; \
|
130
|
+
struct ruby_libvirt_ary_push_arg arg; \
|
131
|
+
\
|
132
|
+
rb_scan_args(argc, argv, "01", &flags); \
|
133
|
+
ret = listfunc(object, &list, ruby_libvirt_value_to_uint(flags)); \
|
134
|
+
ruby_libvirt_raise_error_if(ret < 0, e_RetrieveError, #listfunc, ruby_libvirt_connect_get(val)); \
|
135
|
+
result = rb_protect(ruby_libvirt_ary_new2_wrap, (VALUE)&ret, &exception); \
|
136
|
+
if (exception) { \
|
137
|
+
goto exception; \
|
138
|
+
} \
|
139
|
+
for (i = 0; i < ret; i++) { \
|
140
|
+
arg.arr = result; \
|
141
|
+
arg.value = newfunc(list[i], val); \
|
142
|
+
rb_protect(ruby_libvirt_ary_push_wrap, (VALUE)&arg, &exception); \
|
143
|
+
if (exception) { \
|
144
|
+
goto exception; \
|
145
|
+
} \
|
146
|
+
} \
|
147
|
+
\
|
148
|
+
free(list); \
|
149
|
+
\
|
150
|
+
return result; \
|
151
|
+
\
|
152
|
+
exception: \
|
153
|
+
for (i = 0; i < ret; i++) { \
|
154
|
+
freefunc(list[i]); \
|
155
|
+
} \
|
156
|
+
free(list); \
|
157
|
+
rb_jump_tag(exception); \
|
158
|
+
\
|
159
|
+
/* not needed, but here to shut the compiler up */ \
|
160
|
+
return Qnil; \
|
161
|
+
} while(0)
|
162
|
+
|
163
|
+
int ruby_libvirt_is_symbol_or_proc(VALUE handle);
|
154
164
|
|
155
165
|
extern VALUE e_RetrieveError;
|
156
166
|
extern VALUE e_Error;
|
@@ -159,42 +169,90 @@ extern VALUE e_NoSupportError;
|
|
159
169
|
|
160
170
|
extern VALUE m_libvirt;
|
161
171
|
|
162
|
-
char *
|
172
|
+
char *ruby_libvirt_get_cstring_or_null(VALUE arg);
|
163
173
|
|
164
|
-
|
165
|
-
|
166
|
-
|
174
|
+
VALUE ruby_libvirt_generate_list(int num, char **list);
|
175
|
+
|
176
|
+
VALUE ruby_libvirt_get_parameters(VALUE d, unsigned int flags, void *opaque,
|
177
|
+
unsigned int typesize,
|
178
|
+
char *(*nparams_cb)(VALUE d,
|
179
|
+
unsigned int flags,
|
180
|
+
void *opaque,
|
181
|
+
int *nparams),
|
182
|
+
char *(*get_cb)(VALUE d, unsigned int flags,
|
183
|
+
void *voidparams,
|
184
|
+
int *nparams, void *opaque),
|
185
|
+
void (*hash_set)(void *voidparams, int i,
|
186
|
+
VALUE result));
|
187
|
+
VALUE ruby_libvirt_get_typed_parameters(VALUE d, unsigned int flags,
|
188
|
+
void *opaque,
|
189
|
+
char *(*nparams_cb)(VALUE d,
|
190
|
+
unsigned int flags,
|
191
|
+
void *opaque,
|
192
|
+
int *nparams),
|
193
|
+
char *(*get_cb)(VALUE d,
|
194
|
+
unsigned int flags,
|
195
|
+
void *params,
|
196
|
+
int *nparams,
|
197
|
+
void *opaque));
|
198
|
+
struct ruby_libvirt_typed_param {
|
199
|
+
char *name;
|
200
|
+
int type;
|
167
201
|
};
|
168
|
-
|
169
|
-
|
170
|
-
|
202
|
+
struct ruby_libvirt_parameter_assign_args {
|
203
|
+
struct ruby_libvirt_typed_param *allowed;
|
204
|
+
unsigned int num_allowed;
|
205
|
+
|
206
|
+
virTypedParameter *params;
|
207
|
+
int i;
|
208
|
+
};
|
209
|
+
int ruby_libvirt_typed_parameter_assign(VALUE key, VALUE val, VALUE in);
|
210
|
+
VALUE ruby_libvirt_set_typed_parameters(VALUE d, VALUE input,
|
211
|
+
unsigned int flags, void *opaque,
|
212
|
+
struct ruby_libvirt_typed_param *allowed,
|
213
|
+
unsigned int num_allowed,
|
214
|
+
char *(*set_cb)(VALUE d,
|
215
|
+
unsigned int flags,
|
216
|
+
virTypedParameterPtr params,
|
217
|
+
int nparams,
|
218
|
+
void *opaque));
|
219
|
+
|
220
|
+
int ruby_libvirt_get_maxcpus(virConnectPtr conn);
|
221
|
+
|
222
|
+
void ruby_libvirt_typed_params_to_hash(void *voidparams, int i, VALUE hash);
|
223
|
+
void ruby_libvirt_assign_hash_and_flags(VALUE in, VALUE *hash, VALUE *flags);
|
224
|
+
|
225
|
+
unsigned int ruby_libvirt_value_to_uint(VALUE in);
|
226
|
+
int ruby_libvirt_value_to_int(VALUE in);
|
227
|
+
unsigned long ruby_libvirt_value_to_ulong(VALUE in);
|
228
|
+
unsigned long long ruby_libvirt_value_to_ulonglong(VALUE in);
|
229
|
+
|
230
|
+
VALUE ruby_libvirt_ary_new2_wrap(VALUE arg);
|
231
|
+
struct ruby_libvirt_ary_push_arg {
|
171
232
|
VALUE arr;
|
172
233
|
VALUE value;
|
173
234
|
};
|
174
|
-
VALUE
|
175
|
-
|
235
|
+
VALUE ruby_libvirt_ary_push_wrap(VALUE arg);
|
236
|
+
struct ruby_libvirt_ary_store_arg {
|
237
|
+
VALUE arr;
|
238
|
+
long index;
|
239
|
+
VALUE elem;
|
240
|
+
};
|
241
|
+
VALUE ruby_libvirt_ary_store_wrap(VALUE arg);
|
176
242
|
|
177
|
-
VALUE
|
178
|
-
struct
|
243
|
+
VALUE ruby_libvirt_str_new2_wrap(VALUE arg);
|
244
|
+
struct ruby_libvirt_str_new_arg {
|
179
245
|
char *val;
|
180
246
|
size_t size;
|
181
247
|
};
|
182
|
-
VALUE
|
183
|
-
VALUE rb_string_value_cstr_wrap(VALUE arg);
|
248
|
+
VALUE ruby_libvirt_str_new_wrap(VALUE arg);
|
184
249
|
|
185
|
-
struct
|
186
|
-
VALUE
|
187
|
-
char *
|
188
|
-
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;
|
250
|
+
struct ruby_libvirt_hash_aset_arg {
|
251
|
+
VALUE hash;
|
252
|
+
char *name;
|
253
|
+
VALUE val;
|
196
254
|
};
|
197
|
-
VALUE
|
255
|
+
VALUE ruby_libvirt_hash_aset_wrap(VALUE arg);
|
198
256
|
|
199
257
|
#ifndef RARRAY_LEN
|
200
258
|
#define RARRAY_LEN(ar) (RARRAY(ar)->len)
|
@@ -208,4 +266,6 @@ VALUE rb_class_new_instance_wrap(VALUE arg);
|
|
208
266
|
#define RSTRING_LEN(str) (RSTRING(str)->len)
|
209
267
|
#endif
|
210
268
|
|
269
|
+
#define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]))
|
270
|
+
|
211
271
|
#endif
|
data/ext/libvirt/connect.c
CHANGED
@@ -2,6 +2,7 @@
|
|
2
2
|
* connect.c: virConnect methods
|
3
3
|
*
|
4
4
|
* Copyright (C) 2007,2010 Red Hat Inc.
|
5
|
+
* Copyright (C) 2013 Chris Lalancette <clalancette@gmail.com>
|
5
6
|
*
|
6
7
|
* This library is free software; you can redistribute it and/or
|
7
8
|
* modify it under the terms of the GNU Lesser General Public
|
@@ -20,66 +21,108 @@
|
|
20
21
|
|
21
22
|
#include <ruby.h>
|
22
23
|
#include <libvirt/libvirt.h>
|
24
|
+
#if HAVE_VIRDOMAINQEMUATTACH
|
25
|
+
#include <libvirt/libvirt-qemu.h>
|
26
|
+
#endif
|
23
27
|
#include <libvirt/virterror.h>
|
24
28
|
#include "extconf.h"
|
25
29
|
#include "common.h"
|
26
30
|
#include "domain.h"
|
27
31
|
#include "network.h"
|
32
|
+
#include "interface.h"
|
33
|
+
#include "nodedevice.h"
|
34
|
+
#include "nwfilter.h"
|
35
|
+
#include "secret.h"
|
36
|
+
#include "stream.h"
|
37
|
+
|
38
|
+
/*
|
39
|
+
* Generate a call to a virConnectNumOf... function. C is the Ruby VALUE
|
40
|
+
* holding the connection and OBJS is a token indicating what objects to
|
41
|
+
* get the number of, e.g. 'Domains'
|
42
|
+
*/
|
43
|
+
#define gen_conn_num_of(c, objs) \
|
44
|
+
do { \
|
45
|
+
int r; \
|
46
|
+
r = virConnectNumOf##objs(ruby_libvirt_connect_get(c)); \
|
47
|
+
ruby_libvirt_raise_error_if(r < 0, e_RetrieveError, "virConnectNumOf" # objs, ruby_libvirt_connect_get(c)); \
|
48
|
+
return INT2NUM(r); \
|
49
|
+
} while(0)
|
50
|
+
|
51
|
+
/*
|
52
|
+
* Generate a call to a virConnectList... function. C is the Ruby VALUE
|
53
|
+
* holding the connection and OBJS is a token indicating what objects to
|
54
|
+
* get the number of, e.g. 'Domains' The list function must return an array
|
55
|
+
* of strings, which is returned as a Ruby array
|
56
|
+
*/
|
57
|
+
#define gen_conn_list_names(c, objs) \
|
58
|
+
do { \
|
59
|
+
int r, num; \
|
60
|
+
char **names; \
|
61
|
+
num = virConnectNumOf##objs(ruby_libvirt_connect_get(c)); \
|
62
|
+
ruby_libvirt_raise_error_if(num < 0, e_RetrieveError, "virConnectNumOf" # objs, ruby_libvirt_connect_get(c)); \
|
63
|
+
if (num == 0) { \
|
64
|
+
/* if num is 0, don't call virConnectList* function */ \
|
65
|
+
return rb_ary_new2(num); \
|
66
|
+
} \
|
67
|
+
names = alloca(sizeof(char *) * num); \
|
68
|
+
r = virConnectList##objs(ruby_libvirt_connect_get(c), names, num); \
|
69
|
+
ruby_libvirt_raise_error_if(r < 0, e_RetrieveError, "virConnectList" # objs, ruby_libvirt_connect_get(c)); \
|
70
|
+
return ruby_libvirt_generate_list(num, names); \
|
71
|
+
} while(0)
|
28
72
|
|
29
73
|
static VALUE c_connect;
|
30
|
-
|
74
|
+
VALUE c_node_security_model;
|
31
75
|
static VALUE c_node_info;
|
32
76
|
|
33
|
-
static void connect_close(void *
|
77
|
+
static void connect_close(void *c)
|
78
|
+
{
|
34
79
|
int r;
|
35
80
|
|
36
|
-
if (!
|
81
|
+
if (!c) {
|
37
82
|
return;
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
VALUE connect_new(virConnectPtr p) {
|
43
|
-
return Data_Wrap_Struct(c_connect, NULL, connect_close, p);
|
83
|
+
}
|
84
|
+
r = virConnectClose((virConnectPtr) c);
|
85
|
+
ruby_libvirt_raise_error_if(r < 0, rb_eSystemCallError, "virConnectClose",
|
86
|
+
c);
|
44
87
|
}
|
45
88
|
|
46
|
-
|
47
|
-
|
89
|
+
VALUE ruby_libvirt_connect_new(virConnectPtr c)
|
90
|
+
{
|
91
|
+
return Data_Wrap_Struct(c_connect, NULL, connect_close, c);
|
48
92
|
}
|
49
93
|
|
50
|
-
VALUE
|
51
|
-
|
52
|
-
|
94
|
+
VALUE ruby_libvirt_conn_attr(VALUE c)
|
95
|
+
{
|
96
|
+
if (rb_obj_is_instance_of(c, c_connect) != Qtrue) {
|
97
|
+
c = rb_iv_get(c, "@connection");
|
53
98
|
}
|
54
|
-
if (rb_obj_is_instance_of(
|
99
|
+
if (rb_obj_is_instance_of(c, c_connect) != Qtrue) {
|
55
100
|
rb_raise(rb_eArgError, "Expected Connection object");
|
56
101
|
}
|
57
|
-
return
|
102
|
+
return c;
|
58
103
|
}
|
59
104
|
|
60
|
-
virConnectPtr
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
Data_Get_Struct(s, virConnect, conn);
|
65
|
-
if (!conn)
|
66
|
-
rb_raise(rb_eArgError, "Connection has been closed");
|
67
|
-
return conn;
|
105
|
+
virConnectPtr ruby_libvirt_connect_get(VALUE c)
|
106
|
+
{
|
107
|
+
c = ruby_libvirt_conn_attr(c);
|
108
|
+
ruby_libvirt_get_struct(Connect, c);
|
68
109
|
}
|
69
110
|
|
70
111
|
/*
|
71
112
|
* call-seq:
|
72
113
|
* conn.close -> nil
|
73
114
|
*
|
74
|
-
* Call
|
115
|
+
* Call virConnectClose[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectClose]
|
75
116
|
* to close the connection.
|
76
117
|
*/
|
77
|
-
static VALUE
|
118
|
+
static VALUE libvirt_connect_close(VALUE c)
|
119
|
+
{
|
78
120
|
virConnectPtr conn;
|
79
|
-
|
121
|
+
|
122
|
+
Data_Get_Struct(c, virConnect, conn);
|
80
123
|
if (conn) {
|
81
124
|
connect_close(conn);
|
82
|
-
DATA_PTR(
|
125
|
+
DATA_PTR(c) = NULL;
|
83
126
|
}
|
84
127
|
return Qnil;
|
85
128
|
}
|
@@ -90,38 +133,43 @@ static VALUE libvirt_conn_close(VALUE s) {
|
|
90
133
|
*
|
91
134
|
* Return +true+ if the connection is closed, +false+ if it is open.
|
92
135
|
*/
|
93
|
-
static VALUE
|
136
|
+
static VALUE libvirt_connect_closed_p(VALUE c)
|
137
|
+
{
|
94
138
|
virConnectPtr conn;
|
95
139
|
|
96
|
-
Data_Get_Struct(
|
97
|
-
return (conn==NULL) ? Qtrue : Qfalse;
|
140
|
+
Data_Get_Struct(c, virConnect, conn);
|
141
|
+
return (conn == NULL) ? Qtrue : Qfalse;
|
98
142
|
}
|
99
143
|
|
100
144
|
/*
|
101
145
|
* call-seq:
|
102
146
|
* conn.type -> string
|
103
147
|
*
|
104
|
-
* Call
|
148
|
+
* Call virConnectGetType[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectGetType]
|
105
149
|
* to retrieve the type of hypervisor for this connection.
|
106
150
|
*/
|
107
|
-
static VALUE
|
108
|
-
|
151
|
+
static VALUE libvirt_connect_type(VALUE c)
|
152
|
+
{
|
153
|
+
ruby_libvirt_generate_call_string(virConnectGetType,
|
154
|
+
ruby_libvirt_connect_get(c), 0,
|
155
|
+
ruby_libvirt_connect_get(c));
|
109
156
|
}
|
110
157
|
|
111
158
|
/*
|
112
159
|
* call-seq:
|
113
160
|
* conn.version -> fixnum
|
114
161
|
*
|
115
|
-
* Call
|
162
|
+
* Call virConnectGetVersion[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectGetVersion]
|
116
163
|
* to retrieve the version of the hypervisor for this connection.
|
117
164
|
*/
|
118
|
-
static VALUE
|
165
|
+
static VALUE libvirt_connect_version(VALUE c)
|
166
|
+
{
|
119
167
|
int r;
|
120
168
|
unsigned long v;
|
121
|
-
virConnectPtr conn = connect_get(s);
|
122
169
|
|
123
|
-
r = virConnectGetVersion(
|
124
|
-
|
170
|
+
r = virConnectGetVersion(ruby_libvirt_connect_get(c), &v);
|
171
|
+
ruby_libvirt_raise_error_if(r < 0, e_RetrieveError, "virConnectGetVersion",
|
172
|
+
ruby_libvirt_connect_get(c));
|
125
173
|
|
126
174
|
return ULONG2NUM(v);
|
127
175
|
}
|
@@ -131,16 +179,18 @@ static VALUE libvirt_conn_version(VALUE s) {
|
|
131
179
|
* call-seq:
|
132
180
|
* conn.libversion -> fixnum
|
133
181
|
*
|
134
|
-
* Call
|
182
|
+
* Call virConnectGetLibVersion[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectGetLibVersion]
|
135
183
|
* to retrieve the version of the libvirt library for this connection.
|
136
184
|
*/
|
137
|
-
static VALUE
|
185
|
+
static VALUE libvirt_connect_libversion(VALUE c)
|
186
|
+
{
|
138
187
|
int r;
|
139
188
|
unsigned long v;
|
140
|
-
virConnectPtr conn = connect_get(s);
|
141
189
|
|
142
|
-
r = virConnectGetLibVersion(
|
143
|
-
|
190
|
+
r = virConnectGetLibVersion(ruby_libvirt_connect_get(c), &v);
|
191
|
+
ruby_libvirt_raise_error_if(r < 0, e_RetrieveError,
|
192
|
+
"virConnectGetLibVersion",
|
193
|
+
ruby_libvirt_connect_get(c));
|
144
194
|
|
145
195
|
return ULONG2NUM(v);
|
146
196
|
}
|
@@ -150,56 +200,66 @@ static VALUE libvirt_conn_libversion(VALUE s) {
|
|
150
200
|
* call-seq:
|
151
201
|
* conn.hostname -> string
|
152
202
|
*
|
153
|
-
* Call
|
203
|
+
* Call virConnectGetHostname[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectGetHostname]
|
154
204
|
* to retrieve the hostname of the hypervisor for this connection.
|
155
205
|
*/
|
156
|
-
static VALUE
|
157
|
-
|
206
|
+
static VALUE libvirt_connect_hostname(VALUE c)
|
207
|
+
{
|
208
|
+
ruby_libvirt_generate_call_string(virConnectGetHostname,
|
209
|
+
ruby_libvirt_connect_get(c), 1,
|
210
|
+
ruby_libvirt_connect_get(c));
|
158
211
|
}
|
159
212
|
|
160
213
|
/*
|
161
214
|
* call-seq:
|
162
215
|
* conn.uri -> string
|
163
216
|
*
|
164
|
-
* Call
|
217
|
+
* Call virConnectGetURI[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectGetURI]
|
165
218
|
* to retrieve the canonical URI for this connection.
|
166
219
|
*/
|
167
|
-
static VALUE
|
168
|
-
|
220
|
+
static VALUE libvirt_connect_uri(VALUE c)
|
221
|
+
{
|
222
|
+
ruby_libvirt_generate_call_string(virConnectGetURI,
|
223
|
+
ruby_libvirt_connect_get(c), 1,
|
224
|
+
ruby_libvirt_connect_get(c));
|
169
225
|
}
|
170
226
|
|
171
227
|
/*
|
172
228
|
* call-seq:
|
173
229
|
* conn.max_vcpus(type=nil) -> fixnum
|
174
230
|
*
|
175
|
-
* Call
|
231
|
+
* Call virConnectGetMaxVcpus[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectGetMaxVcpus]
|
176
232
|
* to retrieve the maximum number of virtual cpus supported by the hypervisor
|
177
233
|
* for this connection.
|
178
234
|
*/
|
179
|
-
static VALUE
|
235
|
+
static VALUE libvirt_connect_max_vcpus(int argc, VALUE *argv, VALUE c)
|
236
|
+
{
|
180
237
|
VALUE type;
|
181
238
|
|
182
239
|
rb_scan_args(argc, argv, "01", &type);
|
183
240
|
|
184
|
-
|
185
|
-
|
241
|
+
ruby_libvirt_generate_call_int(virConnectGetMaxVcpus,
|
242
|
+
ruby_libvirt_connect_get(c),
|
243
|
+
ruby_libvirt_connect_get(c),
|
244
|
+
ruby_libvirt_get_cstring_or_null(type));
|
186
245
|
}
|
187
246
|
|
188
247
|
/*
|
189
248
|
* call-seq:
|
190
|
-
* conn.
|
249
|
+
* conn.node_info -> Libvirt::Connect::Nodeinfo
|
191
250
|
*
|
192
|
-
* Call
|
251
|
+
* Call virNodeGetInfo[http://www.libvirt.org/html/libvirt-libvirt.html#virNodeGetInfo]
|
193
252
|
* to retrieve information about the node for this connection.
|
194
253
|
*/
|
195
|
-
static VALUE
|
254
|
+
static VALUE libvirt_connect_node_info(VALUE c)
|
255
|
+
{
|
196
256
|
int r;
|
197
|
-
virConnectPtr conn = connect_get(s);
|
198
257
|
virNodeInfo nodeinfo;
|
199
258
|
VALUE result;
|
200
259
|
|
201
|
-
r = virNodeGetInfo(
|
202
|
-
|
260
|
+
r = virNodeGetInfo(ruby_libvirt_connect_get(c), &nodeinfo);
|
261
|
+
ruby_libvirt_raise_error_if(r < 0, e_RetrieveError, "virNodeGetInfo",
|
262
|
+
ruby_libvirt_connect_get(c));
|
203
263
|
|
204
264
|
result = rb_class_new_instance(0, NULL, c_node_info);
|
205
265
|
rb_iv_set(result, "@model", rb_str_new2(nodeinfo.model));
|
@@ -218,18 +278,19 @@ static VALUE libvirt_conn_node_get_info(VALUE s) {
|
|
218
278
|
* call-seq:
|
219
279
|
* conn.node_free_memory -> fixnum
|
220
280
|
*
|
221
|
-
* Call
|
281
|
+
* Call virNodeGetFreeMemory[http://www.libvirt.org/html/libvirt-libvirt.html#virNodeGetFreeMemory]
|
222
282
|
* to retrieve the amount of free memory available on the host for this
|
223
283
|
* connection.
|
224
284
|
*/
|
225
|
-
static VALUE
|
226
|
-
|
285
|
+
static VALUE libvirt_connect_node_free_memory(VALUE c)
|
286
|
+
{
|
227
287
|
unsigned long long freemem;
|
228
288
|
|
229
|
-
freemem = virNodeGetFreeMemory(
|
289
|
+
freemem = virNodeGetFreeMemory(ruby_libvirt_connect_get(c));
|
230
290
|
|
231
|
-
|
232
|
-
|
291
|
+
ruby_libvirt_raise_error_if(freemem == 0, e_RetrieveError,
|
292
|
+
"virNodeGetFreeMemory",
|
293
|
+
ruby_libvirt_connect_get(c));
|
233
294
|
|
234
295
|
return ULL2NUM(freemem);
|
235
296
|
}
|
@@ -238,49 +299,50 @@ static VALUE libvirt_conn_node_free_memory(VALUE s) {
|
|
238
299
|
* call-seq:
|
239
300
|
* conn.node_cells_free_memory(startCell=0, maxCells=#nodeCells) -> list
|
240
301
|
*
|
241
|
-
* Call
|
302
|
+
* Call virNodeGetCellsFreeMemory[http://www.libvirt.org/html/libvirt-libvirt.html#virNodeGetCellsFreeMemory]
|
242
303
|
* to retrieve the amount of free memory in each NUMA cell on the host for
|
243
304
|
* this connection.
|
244
305
|
*/
|
245
|
-
static VALUE
|
246
|
-
|
247
|
-
|
248
|
-
|
249
|
-
VALUE cells;
|
250
|
-
VALUE start, max;
|
306
|
+
static VALUE libvirt_connect_node_cells_free_memory(int argc, VALUE *argv,
|
307
|
+
VALUE c)
|
308
|
+
{
|
309
|
+
int i, r;
|
310
|
+
VALUE cells, start, max;
|
251
311
|
unsigned long long *freeMems;
|
252
312
|
virNodeInfo nodeinfo;
|
253
|
-
int i;
|
254
313
|
unsigned int startCell, maxCells;
|
255
314
|
|
256
315
|
rb_scan_args(argc, argv, "02", &start, &max);
|
257
316
|
|
258
|
-
if (NIL_P(start))
|
317
|
+
if (NIL_P(start)) {
|
259
318
|
startCell = 0;
|
260
|
-
|
319
|
+
}
|
320
|
+
else {
|
261
321
|
startCell = NUM2UINT(start);
|
322
|
+
}
|
262
323
|
|
263
324
|
if (NIL_P(max)) {
|
264
|
-
r = virNodeGetInfo(
|
265
|
-
|
325
|
+
r = virNodeGetInfo(ruby_libvirt_connect_get(c), &nodeinfo);
|
326
|
+
ruby_libvirt_raise_error_if(r < 0, e_RetrieveError, "virNodeGetInfo",
|
327
|
+
ruby_libvirt_connect_get(c));
|
266
328
|
maxCells = nodeinfo.nodes;
|
267
329
|
}
|
268
|
-
else
|
330
|
+
else {
|
269
331
|
maxCells = NUM2UINT(max);
|
332
|
+
}
|
270
333
|
|
271
|
-
freeMems =
|
334
|
+
freeMems = alloca(sizeof(unsigned long long) * maxCells);
|
272
335
|
|
273
|
-
r = virNodeGetCellsFreeMemory(
|
274
|
-
|
275
|
-
|
276
|
-
|
277
|
-
|
278
|
-
}
|
336
|
+
r = virNodeGetCellsFreeMemory(ruby_libvirt_connect_get(c), freeMems,
|
337
|
+
startCell, maxCells);
|
338
|
+
ruby_libvirt_raise_error_if(r < 0, e_RetrieveError,
|
339
|
+
"virNodeGetCellsFreeMemory",
|
340
|
+
ruby_libvirt_connect_get(c));
|
279
341
|
|
280
342
|
cells = rb_ary_new2(r);
|
281
|
-
for (i = 0; i < r; i++)
|
282
|
-
|
283
|
-
|
343
|
+
for (i = 0; i < r; i++) {
|
344
|
+
rb_ary_store(cells, i, ULL2NUM(freeMems[i]));
|
345
|
+
}
|
284
346
|
|
285
347
|
return cells;
|
286
348
|
}
|
@@ -288,19 +350,21 @@ static VALUE libvirt_conn_node_cells_free_memory(int argc, VALUE *argv,
|
|
288
350
|
#if HAVE_VIRNODEGETSECURITYMODEL
|
289
351
|
/*
|
290
352
|
* call-seq:
|
291
|
-
* conn.
|
353
|
+
* conn.node_security_model -> Libvirt::Connect::NodeSecurityModel
|
292
354
|
*
|
293
|
-
* Call
|
355
|
+
* Call virNodeGetSecurityModel[http://www.libvirt.org/html/libvirt-libvirt.html#virNodeGetSecurityModel]
|
294
356
|
* to retrieve the security model in use on the host for this connection.
|
295
357
|
*/
|
296
|
-
static VALUE
|
358
|
+
static VALUE libvirt_connect_node_security_model(VALUE c)
|
359
|
+
{
|
297
360
|
virSecurityModel secmodel;
|
298
|
-
virConnectPtr conn = connect_get(s);
|
299
361
|
int r;
|
300
362
|
VALUE result;
|
301
363
|
|
302
|
-
r = virNodeGetSecurityModel(
|
303
|
-
|
364
|
+
r = virNodeGetSecurityModel(ruby_libvirt_connect_get(c), &secmodel);
|
365
|
+
ruby_libvirt_raise_error_if(r < 0, e_RetrieveError,
|
366
|
+
"virNodeGetSecurityModel",
|
367
|
+
ruby_libvirt_connect_get(c));
|
304
368
|
|
305
369
|
result = rb_class_new_instance(0, NULL, c_node_security_model);
|
306
370
|
rb_iv_set(result, "@model", rb_str_new2(secmodel.model));
|
@@ -315,11 +379,14 @@ static VALUE libvirt_conn_node_get_security_model(VALUE s) {
|
|
315
379
|
* call-seq:
|
316
380
|
* conn.encrypted? -> [True|False]
|
317
381
|
*
|
318
|
-
* Call
|
382
|
+
* Call virConnectIsEncrypted[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectIsEncrypted]
|
319
383
|
* to determine if the connection is encrypted.
|
320
384
|
*/
|
321
|
-
static VALUE
|
322
|
-
|
385
|
+
static VALUE libvirt_connect_encrypted_p(VALUE c)
|
386
|
+
{
|
387
|
+
ruby_libvirt_generate_call_truefalse(virConnectIsEncrypted,
|
388
|
+
ruby_libvirt_connect_get(c),
|
389
|
+
ruby_libvirt_connect_get(c));
|
323
390
|
}
|
324
391
|
#endif
|
325
392
|
|
@@ -328,11 +395,14 @@ static VALUE libvirt_conn_encrypted_p(VALUE s) {
|
|
328
395
|
* call-seq:
|
329
396
|
* conn.secure? -> [True|False]
|
330
397
|
*
|
331
|
-
* Call
|
398
|
+
* Call virConnectIsSecure[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectIsSecure]
|
332
399
|
* to determine if the connection is secure.
|
333
400
|
*/
|
334
|
-
static VALUE
|
335
|
-
|
401
|
+
static VALUE libvirt_connect_secure_p(VALUE c)
|
402
|
+
{
|
403
|
+
ruby_libvirt_generate_call_truefalse(virConnectIsSecure,
|
404
|
+
ruby_libvirt_connect_get(c),
|
405
|
+
ruby_libvirt_connect_get(c));
|
336
406
|
}
|
337
407
|
#endif
|
338
408
|
|
@@ -340,11 +410,14 @@ static VALUE libvirt_conn_secure_p(VALUE s) {
|
|
340
410
|
* call-seq:
|
341
411
|
* conn.capabilities -> string
|
342
412
|
*
|
343
|
-
* Call
|
413
|
+
* Call virConnectGetCapabilities[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectGetCapabilities]
|
344
414
|
* to retrieve the capabilities XML for this connection.
|
345
415
|
*/
|
346
|
-
static VALUE
|
347
|
-
|
416
|
+
static VALUE libvirt_connect_capabilities(VALUE c)
|
417
|
+
{
|
418
|
+
ruby_libvirt_generate_call_string(virConnectGetCapabilities,
|
419
|
+
ruby_libvirt_connect_get(c), 1,
|
420
|
+
ruby_libvirt_connect_get(c));
|
348
421
|
}
|
349
422
|
|
350
423
|
#if HAVE_VIRCONNECTCOMPARECPU
|
@@ -352,20 +425,22 @@ static VALUE libvirt_conn_capabilities(VALUE s) {
|
|
352
425
|
* call-seq:
|
353
426
|
* conn.compare_cpu(xml, flags=0) -> compareflag
|
354
427
|
*
|
355
|
-
* Call
|
428
|
+
* Call virConnectCompareCPU[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectCompareCPU]
|
356
429
|
* to compare the host CPU with the XML contained in xml. Returns one of
|
357
430
|
* Libvirt::CPU_COMPARE_ERROR, Libvirt::CPU_COMPARE_INCOMPATIBLE,
|
358
431
|
* Libvirt::CPU_COMPARE_IDENTICAL, or Libvirt::CPU_COMPARE_SUPERSET.
|
359
432
|
*/
|
360
|
-
static VALUE
|
433
|
+
static VALUE libvirt_connect_compare_cpu(int argc, VALUE *argv, VALUE c)
|
434
|
+
{
|
361
435
|
VALUE xml, flags;
|
362
436
|
|
363
437
|
rb_scan_args(argc, argv, "11", &xml, &flags);
|
364
|
-
if (NIL_P(flags))
|
365
|
-
flags = INT2NUM(0);
|
366
438
|
|
367
|
-
|
368
|
-
|
439
|
+
ruby_libvirt_generate_call_int(virConnectCompareCPU,
|
440
|
+
ruby_libvirt_connect_get(c),
|
441
|
+
ruby_libvirt_connect_get(c),
|
442
|
+
StringValueCStr(xml),
|
443
|
+
ruby_libvirt_value_to_uint(flags));
|
369
444
|
}
|
370
445
|
#endif
|
371
446
|
|
@@ -375,70 +450,48 @@ static VALUE libvirt_conn_compare_cpu(int argc, VALUE *argv, VALUE s) {
|
|
375
450
|
* call-seq:
|
376
451
|
* conn.baseline_cpu([xml, xml2, ...], flags=0) -> XML
|
377
452
|
*
|
378
|
-
* Call
|
453
|
+
* Call virConnectBaselineCPU[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectBaselineCPU]
|
379
454
|
* to compare the most feature-rich CPU which is compatible with all
|
380
455
|
* given host CPUs.
|
381
456
|
*/
|
382
|
-
static VALUE
|
383
|
-
|
384
|
-
|
457
|
+
static VALUE libvirt_connect_baseline_cpu(int argc, VALUE *argv, VALUE c)
|
458
|
+
{
|
459
|
+
VALUE xmlcpus, flags, retval, entry;
|
385
460
|
char *r;
|
386
|
-
|
387
|
-
unsigned int ncpus, flags;
|
388
|
-
VALUE entry;
|
461
|
+
unsigned int ncpus;
|
389
462
|
const char **xmllist;
|
390
|
-
int i;
|
391
|
-
int exception = 0;
|
392
|
-
struct rb_ary_entry_arg arg;
|
463
|
+
int i, exception = 0;
|
393
464
|
|
394
|
-
rb_scan_args(argc, argv, "11", &xmlcpus, &
|
395
|
-
/*
|
396
|
-
* We check flags up-front here so that we get a TypeError early on if
|
397
|
-
* flags is bogus.
|
398
|
-
*/
|
399
|
-
if (NIL_P(flags_val))
|
400
|
-
flags = 0;
|
401
|
-
else
|
402
|
-
flags = NUM2UINT(flags_val);
|
465
|
+
rb_scan_args(argc, argv, "11", &xmlcpus, &flags);
|
403
466
|
|
404
467
|
Check_Type(xmlcpus, T_ARRAY);
|
405
468
|
|
406
|
-
if (RARRAY_LEN(xmlcpus) < 1)
|
407
|
-
rb_raise(rb_eArgError,
|
469
|
+
if (RARRAY_LEN(xmlcpus) < 1) {
|
470
|
+
rb_raise(rb_eArgError,
|
471
|
+
"wrong number of cpu arguments (%ld for 1 or more)",
|
408
472
|
RARRAY_LEN(xmlcpus));
|
473
|
+
}
|
409
474
|
|
410
475
|
ncpus = RARRAY_LEN(xmlcpus);
|
411
|
-
xmllist =
|
476
|
+
xmllist = alloca(sizeof(const char *) * ncpus);
|
412
477
|
|
413
478
|
for (i = 0; i < ncpus; i++) {
|
414
|
-
|
415
|
-
|
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
|
-
}
|
479
|
+
entry = rb_ary_entry(xmlcpus, i);
|
480
|
+
xmllist[i] = StringValueCStr(entry);
|
428
481
|
}
|
429
482
|
|
430
|
-
r = virConnectBaselineCPU(
|
431
|
-
|
432
|
-
|
483
|
+
r = virConnectBaselineCPU(ruby_libvirt_connect_get(c), xmllist, ncpus,
|
484
|
+
ruby_libvirt_value_to_uint(flags));
|
485
|
+
ruby_libvirt_raise_error_if(r == NULL, e_RetrieveError,
|
486
|
+
"virConnectBaselineCPU",
|
487
|
+
ruby_libvirt_connect_get(c));
|
433
488
|
|
434
|
-
retval = rb_protect(
|
489
|
+
retval = rb_protect(ruby_libvirt_str_new2_wrap, (VALUE)&r, &exception);
|
490
|
+
free(r);
|
435
491
|
if (exception) {
|
436
|
-
free(r);
|
437
492
|
rb_jump_tag(exception);
|
438
493
|
}
|
439
494
|
|
440
|
-
free(r);
|
441
|
-
|
442
495
|
return retval;
|
443
496
|
}
|
444
497
|
#endif
|
@@ -446,34 +499,36 @@ static VALUE libvirt_conn_baseline_cpu(int argc, VALUE *argv, VALUE s) {
|
|
446
499
|
#if HAVE_VIRCONNECTDOMAINEVENTREGISTERANY || HAVE_VIRCONNECTDOMAINEVENTREGISTER
|
447
500
|
static int domain_event_lifecycle_callback(virConnectPtr conn,
|
448
501
|
virDomainPtr dom, int event,
|
449
|
-
int detail, void *opaque)
|
502
|
+
int detail, void *opaque)
|
503
|
+
{
|
450
504
|
VALUE passthrough = (VALUE)opaque;
|
451
|
-
VALUE cb;
|
452
|
-
VALUE cb_opaque;
|
453
|
-
VALUE newc;
|
505
|
+
VALUE cb, cb_opaque, newc;
|
454
506
|
|
455
|
-
|
456
|
-
rb_raise(rb_eTypeError,
|
457
|
-
"wrong domain event lifecycle callback argument type (expected Array)");
|
507
|
+
Check_Type(passthrough, T_ARRAY);
|
458
508
|
|
459
|
-
if (RARRAY_LEN(passthrough) != 2)
|
460
|
-
rb_raise(rb_eArgError, "wrong number of arguments (%
|
509
|
+
if (RARRAY_LEN(passthrough) != 2) {
|
510
|
+
rb_raise(rb_eArgError, "wrong number of arguments (%ld for 2)",
|
461
511
|
RARRAY_LEN(passthrough));
|
512
|
+
}
|
462
513
|
|
463
514
|
cb = rb_ary_entry(passthrough, 0);
|
464
515
|
cb_opaque = rb_ary_entry(passthrough, 1);
|
465
516
|
|
466
|
-
newc =
|
467
|
-
if (strcmp(rb_obj_classname(cb), "Symbol") == 0)
|
517
|
+
newc = ruby_libvirt_connect_new(conn);
|
518
|
+
if (strcmp(rb_obj_classname(cb), "Symbol") == 0) {
|
468
519
|
rb_funcall(rb_class_of(cb), rb_to_id(cb), 5, newc,
|
469
|
-
|
470
|
-
cb_opaque);
|
471
|
-
|
472
|
-
|
473
|
-
|
474
|
-
|
520
|
+
ruby_libvirt_domain_new(dom, newc), INT2NUM(event),
|
521
|
+
INT2NUM(detail), cb_opaque);
|
522
|
+
}
|
523
|
+
else if (strcmp(rb_obj_classname(cb), "Proc") == 0) {
|
524
|
+
rb_funcall(cb, rb_intern("call"), 5, newc,
|
525
|
+
ruby_libvirt_domain_new(dom, newc), INT2NUM(event),
|
526
|
+
INT2NUM(detail), cb_opaque);
|
527
|
+
}
|
528
|
+
else {
|
475
529
|
rb_raise(rb_eTypeError,
|
476
530
|
"wrong domain event lifecycle callback (expected Symbol or Proc)");
|
531
|
+
}
|
477
532
|
|
478
533
|
return 0;
|
479
534
|
}
|
@@ -481,97 +536,104 @@ static int domain_event_lifecycle_callback(virConnectPtr conn,
|
|
481
536
|
|
482
537
|
#if HAVE_VIRCONNECTDOMAINEVENTREGISTERANY
|
483
538
|
static int domain_event_reboot_callback(virConnectPtr conn, virDomainPtr dom,
|
484
|
-
void *opaque)
|
539
|
+
void *opaque)
|
540
|
+
{
|
485
541
|
VALUE passthrough = (VALUE)opaque;
|
486
|
-
VALUE cb;
|
487
|
-
VALUE cb_opaque;
|
488
|
-
VALUE newc;
|
542
|
+
VALUE cb, cb_opaque, newc;
|
489
543
|
|
490
|
-
|
491
|
-
rb_raise(rb_eTypeError,
|
492
|
-
"wrong domain event reboot callback argument type (expected Array)");
|
544
|
+
Check_Type(passthrough, T_ARRAY);
|
493
545
|
|
494
|
-
if (RARRAY_LEN(passthrough) != 2)
|
495
|
-
rb_raise(rb_eArgError, "wrong number of arguments (%
|
546
|
+
if (RARRAY_LEN(passthrough) != 2) {
|
547
|
+
rb_raise(rb_eArgError, "wrong number of arguments (%ld for 2)",
|
496
548
|
RARRAY_LEN(passthrough));
|
549
|
+
}
|
497
550
|
|
498
551
|
cb = rb_ary_entry(passthrough, 0);
|
499
552
|
cb_opaque = rb_ary_entry(passthrough, 1);
|
500
553
|
|
501
|
-
newc =
|
502
|
-
if (strcmp(rb_obj_classname(cb), "Symbol") == 0)
|
554
|
+
newc = ruby_libvirt_connect_new(conn);
|
555
|
+
if (strcmp(rb_obj_classname(cb), "Symbol") == 0) {
|
503
556
|
rb_funcall(rb_class_of(cb), rb_to_id(cb), 3, newc,
|
504
|
-
|
505
|
-
|
506
|
-
|
507
|
-
|
508
|
-
|
557
|
+
ruby_libvirt_domain_new(dom, newc), cb_opaque);
|
558
|
+
}
|
559
|
+
else if (strcmp(rb_obj_classname(cb), "Proc") == 0) {
|
560
|
+
rb_funcall(cb, rb_intern("call"), 3, newc,
|
561
|
+
ruby_libvirt_domain_new(dom, newc), cb_opaque);
|
562
|
+
}
|
563
|
+
else {
|
509
564
|
rb_raise(rb_eTypeError,
|
510
565
|
"wrong domain event reboot callback (expected Symbol or Proc)");
|
566
|
+
}
|
511
567
|
|
512
568
|
return 0;
|
513
569
|
}
|
514
570
|
|
515
571
|
static int domain_event_rtc_callback(virConnectPtr conn, virDomainPtr dom,
|
516
|
-
long long utc_offset, void *opaque)
|
572
|
+
long long utc_offset, void *opaque)
|
573
|
+
{
|
517
574
|
VALUE passthrough = (VALUE)opaque;
|
518
|
-
VALUE cb;
|
519
|
-
VALUE cb_opaque;
|
520
|
-
VALUE newc;
|
575
|
+
VALUE cb, cb_opaque, newc;
|
521
576
|
|
522
|
-
|
523
|
-
rb_raise(rb_eTypeError,
|
524
|
-
"wrong domain event rtc callback argument type (expected Array)");
|
577
|
+
Check_Type(passthrough, T_ARRAY);
|
525
578
|
|
526
|
-
if (RARRAY_LEN(passthrough) != 2)
|
527
|
-
rb_raise(rb_eArgError, "wrong number of arguments (%
|
579
|
+
if (RARRAY_LEN(passthrough) != 2) {
|
580
|
+
rb_raise(rb_eArgError, "wrong number of arguments (%ld for 2)",
|
528
581
|
RARRAY_LEN(passthrough));
|
582
|
+
}
|
529
583
|
|
530
584
|
cb = rb_ary_entry(passthrough, 0);
|
531
585
|
cb_opaque = rb_ary_entry(passthrough, 1);
|
532
586
|
|
533
|
-
newc =
|
534
|
-
if (strcmp(rb_obj_classname(cb), "Symbol") == 0)
|
587
|
+
newc = ruby_libvirt_connect_new(conn);
|
588
|
+
if (strcmp(rb_obj_classname(cb), "Symbol") == 0) {
|
535
589
|
rb_funcall(rb_class_of(cb), rb_to_id(cb), 4, newc,
|
536
|
-
|
537
|
-
|
538
|
-
|
539
|
-
|
540
|
-
|
590
|
+
ruby_libvirt_domain_new(dom, newc), LL2NUM(utc_offset),
|
591
|
+
cb_opaque);
|
592
|
+
}
|
593
|
+
else if (strcmp(rb_obj_classname(cb), "Proc") == 0) {
|
594
|
+
rb_funcall(cb, rb_intern("call"), 4, newc,
|
595
|
+
ruby_libvirt_domain_new(dom, newc), LL2NUM(utc_offset),
|
596
|
+
cb_opaque);
|
597
|
+
}
|
598
|
+
else {
|
541
599
|
rb_raise(rb_eTypeError,
|
542
600
|
"wrong domain event rtc callback (expected Symbol or Proc)");
|
601
|
+
}
|
543
602
|
|
544
603
|
return 0;
|
545
604
|
}
|
546
605
|
|
547
606
|
static int domain_event_watchdog_callback(virConnectPtr conn, virDomainPtr dom,
|
548
|
-
int action, void *opaque)
|
607
|
+
int action, void *opaque)
|
608
|
+
{
|
549
609
|
VALUE passthrough = (VALUE)opaque;
|
550
|
-
VALUE cb;
|
551
|
-
VALUE cb_opaque;
|
552
|
-
VALUE newc;
|
610
|
+
VALUE cb, cb_opaque, newc;
|
553
611
|
|
554
|
-
|
555
|
-
rb_raise(rb_eTypeError,
|
556
|
-
"wrong domain event watchdog callback argument type (expected Array)");
|
612
|
+
Check_Type(passthrough, T_ARRAY);
|
557
613
|
|
558
|
-
if (RARRAY_LEN(passthrough) != 2)
|
559
|
-
rb_raise(rb_eArgError, "wrong number of arguments (%
|
614
|
+
if (RARRAY_LEN(passthrough) != 2) {
|
615
|
+
rb_raise(rb_eArgError, "wrong number of arguments (%ld for 2)",
|
560
616
|
RARRAY_LEN(passthrough));
|
617
|
+
}
|
561
618
|
|
562
619
|
cb = rb_ary_entry(passthrough, 0);
|
563
620
|
cb_opaque = rb_ary_entry(passthrough, 1);
|
564
621
|
|
565
|
-
newc =
|
566
|
-
if (strcmp(rb_obj_classname(cb), "Symbol") == 0)
|
622
|
+
newc = ruby_libvirt_connect_new(conn);
|
623
|
+
if (strcmp(rb_obj_classname(cb), "Symbol") == 0) {
|
567
624
|
rb_funcall(rb_class_of(cb), rb_to_id(cb), 4, newc,
|
568
|
-
|
569
|
-
|
570
|
-
|
571
|
-
|
572
|
-
|
625
|
+
ruby_libvirt_domain_new(dom, newc), INT2NUM(action),
|
626
|
+
cb_opaque);
|
627
|
+
}
|
628
|
+
else if (strcmp(rb_obj_classname(cb), "Proc") == 0) {
|
629
|
+
rb_funcall(cb, rb_intern("call"), 4, newc,
|
630
|
+
ruby_libvirt_domain_new(dom, newc), INT2NUM(action),
|
631
|
+
cb_opaque);
|
632
|
+
}
|
633
|
+
else {
|
573
634
|
rb_raise(rb_eTypeError,
|
574
635
|
"wrong domain event watchdog callback (expected Symbol or Proc)");
|
636
|
+
}
|
575
637
|
|
576
638
|
return 0;
|
577
639
|
}
|
@@ -580,35 +642,37 @@ static int domain_event_io_error_callback(virConnectPtr conn, virDomainPtr dom,
|
|
580
642
|
const char *src_path,
|
581
643
|
const char *dev_alias,
|
582
644
|
int action,
|
583
|
-
void *opaque)
|
645
|
+
void *opaque)
|
646
|
+
{
|
584
647
|
VALUE passthrough = (VALUE)opaque;
|
585
|
-
VALUE cb;
|
586
|
-
VALUE cb_opaque;
|
587
|
-
VALUE newc;
|
648
|
+
VALUE cb, cb_opaque, newc;
|
588
649
|
|
589
|
-
|
590
|
-
rb_raise(rb_eTypeError,
|
591
|
-
"wrong domain event IO error callback argument type (expected Array)");
|
650
|
+
Check_Type(passthrough, T_ARRAY);
|
592
651
|
|
593
|
-
if (RARRAY_LEN(passthrough) != 2)
|
594
|
-
rb_raise(rb_eArgError, "wrong number of arguments (%
|
652
|
+
if (RARRAY_LEN(passthrough) != 2) {
|
653
|
+
rb_raise(rb_eArgError, "wrong number of arguments (%ld for 2)",
|
595
654
|
RARRAY_LEN(passthrough));
|
655
|
+
}
|
596
656
|
|
597
657
|
cb = rb_ary_entry(passthrough, 0);
|
598
658
|
cb_opaque = rb_ary_entry(passthrough, 1);
|
599
659
|
|
600
|
-
newc =
|
601
|
-
if (strcmp(rb_obj_classname(cb), "Symbol") == 0)
|
660
|
+
newc = ruby_libvirt_connect_new(conn);
|
661
|
+
if (strcmp(rb_obj_classname(cb), "Symbol") == 0) {
|
602
662
|
rb_funcall(rb_class_of(cb), rb_to_id(cb), 6, newc,
|
603
|
-
|
663
|
+
ruby_libvirt_domain_new(dom, newc), rb_str_new2(src_path),
|
604
664
|
rb_str_new2(dev_alias), INT2NUM(action), cb_opaque);
|
605
|
-
|
606
|
-
|
665
|
+
}
|
666
|
+
else if (strcmp(rb_obj_classname(cb), "Proc") == 0) {
|
667
|
+
rb_funcall(cb, rb_intern("call"), 6, newc,
|
668
|
+
ruby_libvirt_domain_new(dom, newc),
|
607
669
|
rb_str_new2(src_path), rb_str_new2(dev_alias),
|
608
670
|
INT2NUM(action), cb_opaque);
|
609
|
-
|
671
|
+
}
|
672
|
+
else {
|
610
673
|
rb_raise(rb_eTypeError,
|
611
674
|
"wrong domain event IO error callback (expected Symbol or Proc)");
|
675
|
+
}
|
612
676
|
|
613
677
|
return 0;
|
614
678
|
}
|
@@ -619,36 +683,38 @@ static int domain_event_io_error_reason_callback(virConnectPtr conn,
|
|
619
683
|
const char *dev_alias,
|
620
684
|
int action,
|
621
685
|
const char *reason,
|
622
|
-
void *opaque)
|
686
|
+
void *opaque)
|
687
|
+
{
|
623
688
|
VALUE passthrough = (VALUE)opaque;
|
624
|
-
VALUE cb;
|
625
|
-
VALUE cb_opaque;
|
626
|
-
VALUE newc;
|
689
|
+
VALUE cb, cb_opaque, newc;
|
627
690
|
|
628
|
-
|
629
|
-
rb_raise(rb_eTypeError,
|
630
|
-
"wrong domain event IO error reason callback argument type (expected Array)");
|
691
|
+
Check_Type(passthrough, T_ARRAY);
|
631
692
|
|
632
|
-
if (RARRAY_LEN(passthrough) != 2)
|
633
|
-
rb_raise(rb_eArgError, "wrong number of arguments (%
|
693
|
+
if (RARRAY_LEN(passthrough) != 2) {
|
694
|
+
rb_raise(rb_eArgError, "wrong number of arguments (%ld for 2)",
|
634
695
|
RARRAY_LEN(passthrough));
|
696
|
+
}
|
635
697
|
|
636
698
|
cb = rb_ary_entry(passthrough, 0);
|
637
699
|
cb_opaque = rb_ary_entry(passthrough, 1);
|
638
700
|
|
639
|
-
newc =
|
640
|
-
if (strcmp(rb_obj_classname(cb), "Symbol") == 0)
|
701
|
+
newc = ruby_libvirt_connect_new(conn);
|
702
|
+
if (strcmp(rb_obj_classname(cb), "Symbol") == 0) {
|
641
703
|
rb_funcall(rb_class_of(cb), rb_to_id(cb), 7, newc,
|
642
|
-
|
704
|
+
ruby_libvirt_domain_new(dom, newc), rb_str_new2(src_path),
|
643
705
|
rb_str_new2(dev_alias), INT2NUM(action),
|
644
706
|
rb_str_new2(reason), cb_opaque);
|
645
|
-
|
646
|
-
|
707
|
+
}
|
708
|
+
else if (strcmp(rb_obj_classname(cb), "Proc") == 0) {
|
709
|
+
rb_funcall(cb, rb_intern("call"), 7, newc,
|
710
|
+
ruby_libvirt_domain_new(dom, newc),
|
647
711
|
rb_str_new2(src_path), rb_str_new2(dev_alias),
|
648
712
|
INT2NUM(action), rb_str_new2(reason), cb_opaque);
|
649
|
-
|
713
|
+
}
|
714
|
+
else {
|
650
715
|
rb_raise(rb_eTypeError,
|
651
716
|
"wrong domain event IO error reason callback (expected Symbol or Proc)");
|
717
|
+
}
|
652
718
|
|
653
719
|
return 0;
|
654
720
|
}
|
@@ -659,24 +725,18 @@ static int domain_event_graphics_callback(virConnectPtr conn, virDomainPtr dom,
|
|
659
725
|
virDomainEventGraphicsAddressPtr remote,
|
660
726
|
const char *authScheme,
|
661
727
|
virDomainEventGraphicsSubjectPtr subject,
|
662
|
-
void *opaque)
|
728
|
+
void *opaque)
|
729
|
+
{
|
663
730
|
VALUE passthrough = (VALUE)opaque;
|
664
|
-
VALUE cb;
|
665
|
-
VALUE cb_opaque;
|
666
|
-
VALUE newc;
|
667
|
-
VALUE local_hash;
|
668
|
-
VALUE remote_hash;
|
669
|
-
VALUE subject_array;
|
670
|
-
VALUE pair;
|
731
|
+
VALUE cb, cb_opaque, newc, local_hash, remote_hash, subject_array, pair;
|
671
732
|
int i;
|
672
733
|
|
673
|
-
|
674
|
-
rb_raise(rb_eTypeError,
|
675
|
-
"wrong domain event graphics callback argument type (expected Array)");
|
734
|
+
Check_Type(passthrough, T_ARRAY);
|
676
735
|
|
677
|
-
if (RARRAY_LEN(passthrough) != 2)
|
678
|
-
rb_raise(rb_eArgError, "wrong number of arguments (%
|
736
|
+
if (RARRAY_LEN(passthrough) != 2) {
|
737
|
+
rb_raise(rb_eArgError, "wrong number of arguments (%ld for 2)",
|
679
738
|
RARRAY_LEN(passthrough));
|
739
|
+
}
|
680
740
|
|
681
741
|
cb = rb_ary_entry(passthrough, 0);
|
682
742
|
cb_opaque = rb_ary_entry(passthrough, 1);
|
@@ -702,19 +762,23 @@ static int domain_event_graphics_callback(virConnectPtr conn, virDomainPtr dom,
|
|
702
762
|
rb_ary_store(subject_array, i, pair);
|
703
763
|
}
|
704
764
|
|
705
|
-
newc =
|
706
|
-
if (strcmp(rb_obj_classname(cb), "Symbol") == 0)
|
765
|
+
newc = ruby_libvirt_connect_new(conn);
|
766
|
+
if (strcmp(rb_obj_classname(cb), "Symbol") == 0) {
|
707
767
|
rb_funcall(rb_class_of(cb), rb_to_id(cb), 8, newc,
|
708
|
-
|
709
|
-
remote_hash, rb_str_new2(authScheme),
|
710
|
-
cb_opaque);
|
711
|
-
|
712
|
-
|
713
|
-
|
714
|
-
|
715
|
-
|
768
|
+
ruby_libvirt_domain_new(dom, newc), INT2NUM(phase),
|
769
|
+
local_hash, remote_hash, rb_str_new2(authScheme),
|
770
|
+
subject_array, cb_opaque);
|
771
|
+
}
|
772
|
+
else if (strcmp(rb_obj_classname(cb), "Proc") == 0) {
|
773
|
+
rb_funcall(cb, rb_intern("call"), 8, newc,
|
774
|
+
ruby_libvirt_domain_new(dom, newc), INT2NUM(phase),
|
775
|
+
local_hash, remote_hash, rb_str_new2(authScheme),
|
776
|
+
subject_array, cb_opaque);
|
777
|
+
}
|
778
|
+
else {
|
716
779
|
rb_raise(rb_eTypeError,
|
717
780
|
"wrong domain event graphics callback (expected Symbol or Proc)");
|
781
|
+
}
|
718
782
|
|
719
783
|
return 0;
|
720
784
|
}
|
@@ -723,7 +787,7 @@ static int domain_event_graphics_callback(virConnectPtr conn, virDomainPtr dom,
|
|
723
787
|
* call-seq:
|
724
788
|
* conn.domain_event_register_any(eventID, callback, dom=nil, opaque=nil) -> fixnum
|
725
789
|
*
|
726
|
-
* Call
|
790
|
+
* Call virConnectDomainEventRegisterAny[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectDomainEventRegisterAny]
|
727
791
|
* to register callback for eventID with libvirt. The eventID must be one of
|
728
792
|
* the Libvirt::Connect::DOMAIN_EVENT_ID_* constants. The callback can either
|
729
793
|
* be a Symbol (that is the name of a method to callback) or a Proc. Note that
|
@@ -744,22 +808,26 @@ static int domain_event_graphics_callback(virConnectPtr conn, virDomainPtr dom,
|
|
744
808
|
* libvirt-specific handle, which must be used by the application to
|
745
809
|
* deregister the callback later (see domain_event_deregister_any).
|
746
810
|
*/
|
747
|
-
static VALUE
|
748
|
-
|
749
|
-
|
811
|
+
static VALUE libvirt_connect_domain_event_register_any(int argc, VALUE *argv,
|
812
|
+
VALUE c)
|
813
|
+
{
|
814
|
+
VALUE eventID, cb, dom, opaque, passthrough;
|
750
815
|
virDomainPtr domain;
|
751
816
|
virConnectDomainEventGenericCallback internalcb = NULL;
|
752
|
-
VALUE passthrough;
|
753
817
|
|
754
818
|
rb_scan_args(argc, argv, "22", &eventID, &cb, &dom, &opaque);
|
755
819
|
|
756
|
-
if (!
|
757
|
-
rb_raise(rb_eTypeError,
|
820
|
+
if (!ruby_libvirt_is_symbol_or_proc(cb)) {
|
821
|
+
rb_raise(rb_eTypeError,
|
822
|
+
"wrong argument type (expected Symbol or Proc)");
|
823
|
+
}
|
758
824
|
|
759
|
-
if (NIL_P(dom))
|
825
|
+
if (NIL_P(dom)) {
|
760
826
|
domain = NULL;
|
761
|
-
|
762
|
-
|
827
|
+
}
|
828
|
+
else {
|
829
|
+
domain = ruby_libvirt_domain_get(dom);
|
830
|
+
}
|
763
831
|
|
764
832
|
switch(NUM2INT(eventID)) {
|
765
833
|
case VIR_DOMAIN_EVENT_ID_LIFECYCLE:
|
@@ -793,23 +861,28 @@ static VALUE libvirt_conn_domain_event_register_any(int argc, VALUE *argv,
|
|
793
861
|
rb_ary_store(passthrough, 0, cb);
|
794
862
|
rb_ary_store(passthrough, 1, opaque);
|
795
863
|
|
796
|
-
|
797
|
-
|
798
|
-
|
864
|
+
ruby_libvirt_generate_call_int(virConnectDomainEventRegisterAny,
|
865
|
+
ruby_libvirt_connect_get(c),
|
866
|
+
ruby_libvirt_connect_get(c), domain,
|
867
|
+
NUM2INT(eventID), internalcb,
|
868
|
+
(void *)passthrough, NULL);
|
799
869
|
}
|
800
870
|
|
801
871
|
/*
|
802
872
|
* call-seq:
|
803
873
|
* conn.domain_event_deregister_any(callbackID) -> nil
|
804
874
|
*
|
805
|
-
* Call
|
875
|
+
* Call virConnectDomainEventDeregisterAny[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectDomainEventDeregisterAny]
|
806
876
|
* to deregister a callback from libvirt. The callbackID must be a
|
807
877
|
* libvirt-specific handle returned by domain_event_register_any.
|
808
878
|
*/
|
809
|
-
static VALUE
|
810
|
-
|
811
|
-
|
812
|
-
|
879
|
+
static VALUE libvirt_connect_domain_event_deregister_any(VALUE c,
|
880
|
+
VALUE callbackID)
|
881
|
+
{
|
882
|
+
ruby_libvirt_generate_call_nil(virConnectDomainEventDeregisterAny,
|
883
|
+
ruby_libvirt_connect_get(c),
|
884
|
+
ruby_libvirt_connect_get(c),
|
885
|
+
NUM2INT(callbackID));
|
813
886
|
}
|
814
887
|
#endif
|
815
888
|
|
@@ -823,14 +896,15 @@ static VALUE libvirt_conn_domain_event_deregister_any(VALUE c,
|
|
823
896
|
*/
|
824
897
|
static int domain_event_callback(virConnectPtr conn,
|
825
898
|
virDomainPtr dom, int event,
|
826
|
-
int detail, void *opaque)
|
899
|
+
int detail, void *opaque)
|
900
|
+
{
|
827
901
|
return domain_event_lifecycle_callback(conn, dom, event, detail, opaque);
|
828
902
|
}
|
829
903
|
/*
|
830
904
|
* call-seq:
|
831
905
|
* conn.domain_event_register(callback, opaque=nil) -> nil
|
832
906
|
*
|
833
|
-
* Call
|
907
|
+
* Call virConnectDomainEventRegister[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectDomainEventRegister]
|
834
908
|
* to register callback for domain lifecycle events with libvirt. The
|
835
909
|
* callback can either be a Symbol (that is the name of a method to callback)
|
836
910
|
* or a Proc. The callback must accept 5 parameters: Libvirt::Connect,
|
@@ -839,37 +913,45 @@ static int domain_event_callback(virConnectPtr conn,
|
|
839
913
|
* callback as "opaque". This method is deprecated in favor of
|
840
914
|
* domain_event_register_any.
|
841
915
|
*/
|
842
|
-
static VALUE
|
843
|
-
|
844
|
-
|
845
|
-
VALUE passthrough;
|
916
|
+
static VALUE libvirt_connect_domain_event_register(int argc, VALUE *argv,
|
917
|
+
VALUE c)
|
918
|
+
{
|
919
|
+
VALUE cb, opaque, passthrough;
|
846
920
|
|
847
921
|
rb_scan_args(argc, argv, "11", &cb, &opaque);
|
848
922
|
|
849
|
-
if (!
|
850
|
-
rb_raise(rb_eTypeError,
|
923
|
+
if (!ruby_libvirt_is_symbol_or_proc(cb)) {
|
924
|
+
rb_raise(rb_eTypeError,
|
925
|
+
"wrong argument type (expected Symbol or Proc)");
|
926
|
+
}
|
851
927
|
|
852
928
|
passthrough = rb_ary_new();
|
853
929
|
rb_ary_store(passthrough, 0, cb);
|
854
930
|
rb_ary_store(passthrough, 1, opaque);
|
855
931
|
|
856
|
-
|
857
|
-
|
932
|
+
ruby_libvirt_generate_call_nil(virConnectDomainEventRegister,
|
933
|
+
ruby_libvirt_connect_get(c),
|
934
|
+
ruby_libvirt_connect_get(c),
|
935
|
+
domain_event_callback, (void *)passthrough,
|
936
|
+
NULL);
|
858
937
|
}
|
859
938
|
|
860
939
|
/*
|
861
940
|
* call-seq:
|
862
941
|
* conn.domain_event_deregister(callback) -> nil
|
863
942
|
*
|
864
|
-
* Call
|
943
|
+
* Call virConnectDomainEventDeregister[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectDomainEventDeregister]
|
865
944
|
* to deregister the event callback from libvirt. This method is deprecated
|
866
945
|
* in favor of domain_event_deregister_any (though they cannot be mixed; if
|
867
946
|
* the callback was registered with domain_event_register, it must be
|
868
947
|
* deregistered with domain_event_deregister).
|
869
948
|
*/
|
870
|
-
static VALUE
|
871
|
-
|
872
|
-
|
949
|
+
static VALUE libvirt_connect_domain_event_deregister(VALUE c)
|
950
|
+
{
|
951
|
+
ruby_libvirt_generate_call_nil(virConnectDomainEventDeregister,
|
952
|
+
ruby_libvirt_connect_get(c),
|
953
|
+
ruby_libvirt_connect_get(c),
|
954
|
+
domain_event_callback);
|
873
955
|
}
|
874
956
|
#endif
|
875
957
|
|
@@ -877,58 +959,47 @@ static VALUE libvirt_conn_domain_event_deregister(VALUE c) {
|
|
877
959
|
* call-seq:
|
878
960
|
* conn.num_of_domains -> fixnum
|
879
961
|
*
|
880
|
-
* Call
|
962
|
+
* Call virConnectNumOfDomains[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectNumOfDomains]
|
881
963
|
* to retrieve the number of active domains on this connection.
|
882
964
|
*/
|
883
|
-
static VALUE
|
884
|
-
|
965
|
+
static VALUE libvirt_connect_num_of_domains(VALUE c)
|
966
|
+
{
|
967
|
+
gen_conn_num_of(c, Domains);
|
885
968
|
}
|
886
969
|
|
887
970
|
/*
|
888
971
|
* call-seq:
|
889
972
|
* conn.list_domains -> list
|
890
973
|
*
|
891
|
-
* Call
|
974
|
+
* Call virConnectListDomains[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectListDomains]
|
892
975
|
* to retrieve a list of active domain IDs on this connection.
|
893
976
|
*/
|
894
|
-
static VALUE
|
977
|
+
static VALUE libvirt_connect_list_domains(VALUE c)
|
978
|
+
{
|
895
979
|
int i, r, num, *ids;
|
896
|
-
virConnectPtr conn = connect_get(s);
|
897
980
|
VALUE result;
|
898
|
-
int exception = 0;
|
899
|
-
struct rb_ary_push_arg args;
|
900
981
|
|
901
|
-
num = virConnectNumOfDomains(
|
902
|
-
|
982
|
+
num = virConnectNumOfDomains(ruby_libvirt_connect_get(c));
|
983
|
+
ruby_libvirt_raise_error_if(num < 0, e_RetrieveError,
|
984
|
+
"virConnectNumOfDomains",
|
985
|
+
ruby_libvirt_connect_get(c));
|
986
|
+
|
987
|
+
result = rb_ary_new2(num);
|
988
|
+
|
903
989
|
if (num == 0) {
|
904
|
-
result = rb_ary_new2(num);
|
905
990
|
return result;
|
906
991
|
}
|
907
992
|
|
908
|
-
ids =
|
909
|
-
r = virConnectListDomains(
|
910
|
-
|
911
|
-
|
912
|
-
|
913
|
-
conn));
|
914
|
-
}
|
915
|
-
|
916
|
-
result = rb_protect(rb_ary_new2_wrap, (VALUE)&num, &exception);
|
917
|
-
if (exception) {
|
918
|
-
xfree(ids);
|
919
|
-
rb_jump_tag(exception);
|
920
|
-
}
|
993
|
+
ids = alloca(sizeof(int) * num);
|
994
|
+
r = virConnectListDomains(ruby_libvirt_connect_get(c), ids, num);
|
995
|
+
ruby_libvirt_raise_error_if(r < 0, e_RetrieveError,
|
996
|
+
"virConnectListDomains",
|
997
|
+
ruby_libvirt_connect_get(c));
|
921
998
|
|
922
999
|
for (i = 0; i < num; i++) {
|
923
|
-
|
924
|
-
args. value = INT2NUM(ids[i]);
|
925
|
-
rb_protect(rb_ary_push_wrap, (VALUE)&args, &exception);
|
926
|
-
if (exception) {
|
927
|
-
xfree(ids);
|
928
|
-
rb_jump_tag(exception);
|
929
|
-
}
|
1000
|
+
rb_ary_store(result, i, INT2NUM(ids[i]));
|
930
1001
|
}
|
931
|
-
|
1002
|
+
|
932
1003
|
return result;
|
933
1004
|
}
|
934
1005
|
|
@@ -936,46 +1007,48 @@ static VALUE libvirt_conn_list_domains(VALUE s) {
|
|
936
1007
|
* call-seq:
|
937
1008
|
* conn.num_of_defined_domains -> fixnum
|
938
1009
|
*
|
939
|
-
* Call
|
1010
|
+
* Call virConnectNumOfDefinedDomains[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectNumOfDefinedDomains]
|
940
1011
|
* to retrieve the number of inactive domains on this connection.
|
941
1012
|
*/
|
942
|
-
static VALUE
|
943
|
-
|
1013
|
+
static VALUE libvirt_connect_num_of_defined_domains(VALUE c)
|
1014
|
+
{
|
1015
|
+
gen_conn_num_of(c, DefinedDomains);
|
944
1016
|
}
|
945
1017
|
|
946
1018
|
/*
|
947
1019
|
* call-seq:
|
948
1020
|
* conn.list_defined_domains -> list
|
949
1021
|
*
|
950
|
-
* Call
|
1022
|
+
* Call virConnectListDefinedDomains[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectListDefinedDomains]
|
951
1023
|
* to retrieve a list of inactive domain names on this connection.
|
952
1024
|
*/
|
953
|
-
static VALUE
|
954
|
-
|
1025
|
+
static VALUE libvirt_connect_list_defined_domains(VALUE c)
|
1026
|
+
{
|
1027
|
+
gen_conn_list_names(c, DefinedDomains);
|
955
1028
|
}
|
956
1029
|
|
957
1030
|
/*
|
958
1031
|
* call-seq:
|
959
1032
|
* conn.create_domain_linux(xml, flags=0) -> Libvirt::Domain
|
960
1033
|
*
|
961
|
-
* Call
|
1034
|
+
* Call virDomainCreateLinux[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainCreateLinux]
|
962
1035
|
* to start a transient domain from the given XML. Deprecated; use
|
963
1036
|
* conn.create_domain_xml instead.
|
964
1037
|
*/
|
965
|
-
static VALUE
|
1038
|
+
static VALUE libvirt_connect_create_linux(int argc, VALUE *argv, VALUE c)
|
1039
|
+
{
|
966
1040
|
virDomainPtr dom;
|
967
|
-
virConnectPtr conn = connect_get(c);
|
968
1041
|
VALUE flags, xml;
|
969
1042
|
|
970
1043
|
rb_scan_args(argc, argv, "11", &xml, &flags);
|
971
1044
|
|
972
|
-
|
973
|
-
|
1045
|
+
dom = virDomainCreateLinux(ruby_libvirt_connect_get(c),
|
1046
|
+
StringValueCStr(xml),
|
1047
|
+
ruby_libvirt_value_to_uint(flags));
|
1048
|
+
ruby_libvirt_raise_error_if(dom == NULL, e_Error, "virDomainCreateLinux",
|
1049
|
+
ruby_libvirt_connect_get(c));
|
974
1050
|
|
975
|
-
|
976
|
-
_E(dom == NULL, create_error(e_Error, "virDomainCreateLinux", conn));
|
977
|
-
|
978
|
-
return domain_new(dom, c);
|
1051
|
+
return ruby_libvirt_domain_new(dom, c);
|
979
1052
|
}
|
980
1053
|
|
981
1054
|
#if HAVE_VIRDOMAINCREATEXML
|
@@ -983,23 +1056,22 @@ static VALUE libvirt_conn_create_linux(int argc, VALUE *argv, VALUE c) {
|
|
983
1056
|
* call-seq:
|
984
1057
|
* conn.create_domain_xml(xml, flags=0) -> Libvirt::Domain
|
985
1058
|
*
|
986
|
-
* Call
|
1059
|
+
* Call virDomainCreateXML[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainCreateXML]
|
987
1060
|
* to start a transient domain from the given XML.
|
988
1061
|
*/
|
989
|
-
static VALUE
|
1062
|
+
static VALUE libvirt_connect_create_domain_xml(int argc, VALUE *argv, VALUE c)
|
1063
|
+
{
|
990
1064
|
virDomainPtr dom;
|
991
|
-
virConnectPtr conn = connect_get(c);
|
992
1065
|
VALUE flags, xml;
|
993
1066
|
|
994
1067
|
rb_scan_args(argc, argv, "11", &xml, &flags);
|
995
1068
|
|
996
|
-
|
997
|
-
|
1069
|
+
dom = virDomainCreateXML(ruby_libvirt_connect_get(c), StringValueCStr(xml),
|
1070
|
+
ruby_libvirt_value_to_uint(flags));
|
1071
|
+
ruby_libvirt_raise_error_if(dom == NULL, e_Error, "virDomainCreateXML",
|
1072
|
+
ruby_libvirt_connect_get(c));
|
998
1073
|
|
999
|
-
|
1000
|
-
_E(dom == NULL, create_error(e_Error, "virDomainCreateXML", conn));
|
1001
|
-
|
1002
|
-
return domain_new(dom, c);
|
1074
|
+
return ruby_libvirt_domain_new(dom, c);
|
1003
1075
|
}
|
1004
1076
|
#endif
|
1005
1077
|
|
@@ -1007,72 +1079,78 @@ static VALUE libvirt_conn_create_xml(int argc, VALUE *argv, VALUE c) {
|
|
1007
1079
|
* call-seq:
|
1008
1080
|
* conn.lookup_domain_by_name(name) -> Libvirt::Domain
|
1009
1081
|
*
|
1010
|
-
* Call
|
1082
|
+
* Call virDomainLookupByName[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainLookupByName]
|
1011
1083
|
* to retrieve a domain object for name.
|
1012
1084
|
*/
|
1013
|
-
static VALUE
|
1085
|
+
static VALUE libvirt_connect_lookup_domain_by_name(VALUE c, VALUE name)
|
1086
|
+
{
|
1014
1087
|
virDomainPtr dom;
|
1015
|
-
virConnectPtr conn = connect_get(c);
|
1016
1088
|
|
1017
|
-
dom = virDomainLookupByName(
|
1018
|
-
|
1019
|
-
|
1089
|
+
dom = virDomainLookupByName(ruby_libvirt_connect_get(c),
|
1090
|
+
StringValueCStr(name));
|
1091
|
+
ruby_libvirt_raise_error_if(dom == NULL, e_RetrieveError,
|
1092
|
+
"virDomainLookupByName",
|
1093
|
+
ruby_libvirt_connect_get(c));
|
1020
1094
|
|
1021
|
-
return
|
1095
|
+
return ruby_libvirt_domain_new(dom, c);
|
1022
1096
|
}
|
1023
1097
|
|
1024
1098
|
/*
|
1025
1099
|
* call-seq:
|
1026
1100
|
* conn.lookup_domain_by_id(id) -> Libvirt::Domain
|
1027
1101
|
*
|
1028
|
-
* Call
|
1102
|
+
* Call virDomainLookupByID[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainLookupByID]
|
1029
1103
|
* to retrieve a domain object for id.
|
1030
1104
|
*/
|
1031
|
-
static VALUE
|
1105
|
+
static VALUE libvirt_connect_lookup_domain_by_id(VALUE c, VALUE id)
|
1106
|
+
{
|
1032
1107
|
virDomainPtr dom;
|
1033
|
-
virConnectPtr conn = connect_get(c);
|
1034
1108
|
|
1035
|
-
dom = virDomainLookupByID(
|
1036
|
-
|
1037
|
-
|
1109
|
+
dom = virDomainLookupByID(ruby_libvirt_connect_get(c), NUM2INT(id));
|
1110
|
+
ruby_libvirt_raise_error_if(dom == NULL, e_RetrieveError,
|
1111
|
+
"virDomainLookupByID",
|
1112
|
+
ruby_libvirt_connect_get(c));
|
1038
1113
|
|
1039
|
-
return
|
1114
|
+
return ruby_libvirt_domain_new(dom, c);
|
1040
1115
|
}
|
1041
1116
|
|
1042
1117
|
/*
|
1043
1118
|
* call-seq:
|
1044
1119
|
* conn.lookup_domain_by_uuid(uuid) -> Libvirt::Domain
|
1045
1120
|
*
|
1046
|
-
* Call
|
1121
|
+
* Call virDomainLookupByUUIDString[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainLookupByUUIDString]
|
1047
1122
|
* to retrieve a domain object for uuid.
|
1048
1123
|
*/
|
1049
|
-
static VALUE
|
1124
|
+
static VALUE libvirt_connect_lookup_domain_by_uuid(VALUE c, VALUE uuid)
|
1125
|
+
{
|
1050
1126
|
virDomainPtr dom;
|
1051
|
-
virConnectPtr conn = connect_get(c);
|
1052
1127
|
|
1053
|
-
dom = virDomainLookupByUUIDString(
|
1054
|
-
|
1055
|
-
|
1128
|
+
dom = virDomainLookupByUUIDString(ruby_libvirt_connect_get(c),
|
1129
|
+
StringValueCStr(uuid));
|
1130
|
+
ruby_libvirt_raise_error_if(dom == NULL, e_RetrieveError,
|
1131
|
+
"virDomainLookupByUUID",
|
1132
|
+
ruby_libvirt_connect_get(c));
|
1056
1133
|
|
1057
|
-
return
|
1134
|
+
return ruby_libvirt_domain_new(dom, c);
|
1058
1135
|
}
|
1059
1136
|
|
1060
1137
|
/*
|
1061
1138
|
* call-seq:
|
1062
1139
|
* conn.define_domain_xml(xml) -> Libvirt::Domain
|
1063
1140
|
*
|
1064
|
-
* Call
|
1141
|
+
* Call virDomainDefineXML[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainDefineXML]
|
1065
1142
|
* to define a permanent domain on this connection.
|
1066
1143
|
*/
|
1067
|
-
static VALUE
|
1144
|
+
static VALUE libvirt_connect_define_domain_xml(VALUE c, VALUE xml)
|
1145
|
+
{
|
1068
1146
|
virDomainPtr dom;
|
1069
|
-
virConnectPtr conn = connect_get(c);
|
1070
1147
|
|
1071
|
-
dom = virDomainDefineXML(
|
1072
|
-
|
1073
|
-
|
1148
|
+
dom = virDomainDefineXML(ruby_libvirt_connect_get(c), StringValueCStr(xml));
|
1149
|
+
ruby_libvirt_raise_error_if(dom == NULL, e_DefinitionError,
|
1150
|
+
"virDomainDefineXML",
|
1151
|
+
ruby_libvirt_connect_get(c));
|
1074
1152
|
|
1075
|
-
return
|
1153
|
+
return ruby_libvirt_domain_new(dom, c);
|
1076
1154
|
}
|
1077
1155
|
|
1078
1156
|
#if HAVE_VIRCONNECTDOMAINXMLFROMNATIVE
|
@@ -1080,30 +1158,22 @@ static VALUE libvirt_conn_define_domain_xml(VALUE c, VALUE xml) {
|
|
1080
1158
|
* call-seq:
|
1081
1159
|
* conn.domain_xml_from_native(nativeFormat, xml, flags=0) -> string
|
1082
1160
|
*
|
1083
|
-
* Call
|
1161
|
+
* Call virConnectDomainXMLFromNative[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectDomainXMLFromNative]
|
1084
1162
|
* to convert a native hypervisor domain representation to libvirt XML.
|
1085
1163
|
*/
|
1086
|
-
static VALUE
|
1087
|
-
|
1164
|
+
static VALUE libvirt_connect_domain_xml_from_native(int argc, VALUE *argv,
|
1165
|
+
VALUE c)
|
1166
|
+
{
|
1088
1167
|
VALUE nativeFormat, xml, flags;
|
1089
|
-
char *ret;
|
1090
|
-
VALUE result;
|
1091
1168
|
|
1092
1169
|
rb_scan_args(argc, argv, "21", &nativeFormat, &xml, &flags);
|
1093
1170
|
|
1094
|
-
|
1095
|
-
|
1096
|
-
|
1097
|
-
|
1098
|
-
|
1099
|
-
|
1100
|
-
conn(s)));
|
1101
|
-
|
1102
|
-
result = rb_str_new2(ret);
|
1103
|
-
|
1104
|
-
free(ret);
|
1105
|
-
|
1106
|
-
return result;
|
1171
|
+
ruby_libvirt_generate_call_string(virConnectDomainXMLFromNative,
|
1172
|
+
ruby_libvirt_connect_get(c), 1,
|
1173
|
+
ruby_libvirt_connect_get(c),
|
1174
|
+
StringValueCStr(nativeFormat),
|
1175
|
+
StringValueCStr(xml),
|
1176
|
+
ruby_libvirt_value_to_uint(flags));
|
1107
1177
|
}
|
1108
1178
|
#endif
|
1109
1179
|
|
@@ -1112,29 +1182,22 @@ static VALUE libvirt_conn_domain_xml_from_native(int argc, VALUE *argv,
|
|
1112
1182
|
* call-seq:
|
1113
1183
|
* conn.domain_xml_to_native(nativeFormat, xml, flags=0) -> string
|
1114
1184
|
*
|
1115
|
-
* Call
|
1185
|
+
* Call virConnectDomainXMLToNative[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectDomainXMLToNative]
|
1116
1186
|
* to convert libvirt XML to a native domain hypervisor representation.
|
1117
1187
|
*/
|
1118
|
-
static VALUE
|
1188
|
+
static VALUE libvirt_connect_domain_xml_to_native(int argc, VALUE *argv,
|
1189
|
+
VALUE c)
|
1190
|
+
{
|
1119
1191
|
VALUE nativeFormat, xml, flags;
|
1120
|
-
char *ret;
|
1121
|
-
VALUE result;
|
1122
1192
|
|
1123
1193
|
rb_scan_args(argc, argv, "21", &nativeFormat, &xml, &flags);
|
1124
1194
|
|
1125
|
-
|
1126
|
-
|
1127
|
-
|
1128
|
-
|
1129
|
-
StringValueCStr(xml),
|
1130
|
-
|
1131
|
-
conn(s)));
|
1132
|
-
|
1133
|
-
result = rb_str_new2(ret);
|
1134
|
-
|
1135
|
-
free(ret);
|
1136
|
-
|
1137
|
-
return result;
|
1195
|
+
ruby_libvirt_generate_call_string(virConnectDomainXMLToNative,
|
1196
|
+
ruby_libvirt_connect_get(c), 1,
|
1197
|
+
ruby_libvirt_connect_get(c),
|
1198
|
+
StringValueCStr(nativeFormat),
|
1199
|
+
StringValueCStr(xml),
|
1200
|
+
ruby_libvirt_value_to_uint(flags));
|
1138
1201
|
}
|
1139
1202
|
#endif
|
1140
1203
|
|
@@ -1143,105 +1206,113 @@ static VALUE libvirt_conn_domain_xml_to_native(int argc, VALUE *argv, VALUE s) {
|
|
1143
1206
|
* call-seq:
|
1144
1207
|
* conn.num_of_interfaces -> fixnum
|
1145
1208
|
*
|
1146
|
-
* Call
|
1209
|
+
* Call virConnectNumOfInterfaces[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectNumOfInterfaces]
|
1147
1210
|
* to retrieve the number of active interfaces on this connection.
|
1148
1211
|
*/
|
1149
|
-
static VALUE
|
1150
|
-
|
1212
|
+
static VALUE libvirt_connect_num_of_interfaces(VALUE c)
|
1213
|
+
{
|
1214
|
+
gen_conn_num_of(c, Interfaces);
|
1151
1215
|
}
|
1152
1216
|
|
1153
1217
|
/*
|
1154
1218
|
* call-seq:
|
1155
1219
|
* conn.list_interfaces -> list
|
1156
1220
|
*
|
1157
|
-
* Call
|
1221
|
+
* Call virConnectListInterfaces[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectListInterfaces]
|
1158
1222
|
* to retrieve a list of active interface names on this connection.
|
1159
1223
|
*/
|
1160
|
-
static VALUE
|
1161
|
-
|
1224
|
+
static VALUE libvirt_connect_list_interfaces(VALUE c)
|
1225
|
+
{
|
1226
|
+
gen_conn_list_names(c, Interfaces);
|
1162
1227
|
}
|
1163
1228
|
|
1164
1229
|
/*
|
1165
1230
|
* call-seq:
|
1166
1231
|
* conn.num_of_defined_interfaces -> fixnum
|
1167
1232
|
*
|
1168
|
-
* Call
|
1233
|
+
* Call virConnectNumOfDefinedInterfaces[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectNumOfDefinedInterfaces]
|
1169
1234
|
* to retrieve the number of inactive interfaces on this connection.
|
1170
1235
|
*/
|
1171
|
-
static VALUE
|
1172
|
-
|
1236
|
+
static VALUE libvirt_connect_num_of_defined_interfaces(VALUE c)
|
1237
|
+
{
|
1238
|
+
gen_conn_num_of(c, DefinedInterfaces);
|
1173
1239
|
}
|
1174
1240
|
|
1175
1241
|
/*
|
1176
1242
|
* call-seq:
|
1177
1243
|
* conn.list_defined_interfaces -> list
|
1178
1244
|
*
|
1179
|
-
* Call
|
1245
|
+
* Call virConnectListDefinedInterfaces[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectListDefinedInterfaces]
|
1180
1246
|
* to retrieve a list of inactive interface names on this connection.
|
1181
1247
|
*/
|
1182
|
-
static VALUE
|
1183
|
-
|
1248
|
+
static VALUE libvirt_connect_list_defined_interfaces(VALUE c)
|
1249
|
+
{
|
1250
|
+
gen_conn_list_names(c, DefinedInterfaces);
|
1184
1251
|
}
|
1185
1252
|
|
1186
|
-
extern VALUE interface_new(virInterfacePtr i, VALUE conn);
|
1187
1253
|
/*
|
1188
1254
|
* call-seq:
|
1189
1255
|
* conn.lookup_interface_by_name(name) -> Libvirt::Interface
|
1190
1256
|
*
|
1191
|
-
* Call
|
1257
|
+
* Call virInterfaceLookupByName[http://www.libvirt.org/html/libvirt-libvirt.html#virInterfaceLookupByName]
|
1192
1258
|
* to retrieve an interface object by name.
|
1193
1259
|
*/
|
1194
|
-
static VALUE
|
1260
|
+
static VALUE libvirt_connect_lookup_interface_by_name(VALUE c, VALUE name)
|
1261
|
+
{
|
1195
1262
|
virInterfacePtr iface;
|
1196
|
-
virConnectPtr conn = connect_get(c);
|
1197
1263
|
|
1198
|
-
iface = virInterfaceLookupByName(
|
1199
|
-
|
1200
|
-
|
1264
|
+
iface = virInterfaceLookupByName(ruby_libvirt_connect_get(c),
|
1265
|
+
StringValueCStr(name));
|
1266
|
+
ruby_libvirt_raise_error_if(iface == NULL, e_RetrieveError,
|
1267
|
+
"virInterfaceLookupByName",
|
1268
|
+
ruby_libvirt_connect_get(c));
|
1201
1269
|
|
1202
|
-
return
|
1270
|
+
return ruby_libvirt_interface_new(iface, c);
|
1203
1271
|
}
|
1204
1272
|
|
1205
1273
|
/*
|
1206
1274
|
* call-seq:
|
1207
1275
|
* conn.lookup_interface_by_mac(mac) -> Libvirt::Interface
|
1208
1276
|
*
|
1209
|
-
* Call
|
1277
|
+
* Call virInterfaceLookupByMACString[http://www.libvirt.org/html/libvirt-libvirt.html#virInterfaceLookupByMACString]
|
1210
1278
|
* to retrieve an interface object by MAC address.
|
1211
1279
|
*/
|
1212
|
-
static VALUE
|
1280
|
+
static VALUE libvirt_connect_lookup_interface_by_mac(VALUE c, VALUE mac)
|
1281
|
+
{
|
1213
1282
|
virInterfacePtr iface;
|
1214
|
-
virConnectPtr conn = connect_get(c);
|
1215
1283
|
|
1216
|
-
iface = virInterfaceLookupByMACString(
|
1217
|
-
|
1218
|
-
|
1284
|
+
iface = virInterfaceLookupByMACString(ruby_libvirt_connect_get(c),
|
1285
|
+
StringValueCStr(mac));
|
1286
|
+
ruby_libvirt_raise_error_if(iface == NULL, e_RetrieveError,
|
1287
|
+
"virInterfaceLookupByMACString",
|
1288
|
+
ruby_libvirt_connect_get(c));
|
1219
1289
|
|
1220
|
-
return
|
1290
|
+
return ruby_libvirt_interface_new(iface, c);
|
1221
1291
|
}
|
1222
1292
|
|
1223
1293
|
/*
|
1224
1294
|
* call-seq:
|
1225
1295
|
* conn.define_interface_xml(xml, flags=0) -> Libvirt::Interface
|
1226
1296
|
*
|
1227
|
-
* Call
|
1297
|
+
* Call virInterfaceDefineXML[http://www.libvirt.org/html/libvirt-libvirt.html#virInterfaceDefineXML]
|
1228
1298
|
* to define a new interface from xml.
|
1229
1299
|
*/
|
1230
|
-
static VALUE
|
1300
|
+
static VALUE libvirt_connect_define_interface_xml(int argc, VALUE *argv,
|
1301
|
+
VALUE c)
|
1302
|
+
{
|
1231
1303
|
virInterfacePtr iface;
|
1232
|
-
virConnectPtr conn = connect_get(c);
|
1233
1304
|
VALUE xml, flags;
|
1234
1305
|
|
1235
1306
|
rb_scan_args(argc, argv, "11", &xml, &flags);
|
1236
1307
|
|
1237
|
-
|
1238
|
-
|
1308
|
+
iface = virInterfaceDefineXML(ruby_libvirt_connect_get(c),
|
1309
|
+
StringValueCStr(xml),
|
1310
|
+
ruby_libvirt_value_to_uint(flags));
|
1311
|
+
ruby_libvirt_raise_error_if(iface == NULL, e_DefinitionError,
|
1312
|
+
"virInterfaceDefineXML",
|
1313
|
+
ruby_libvirt_connect_get(c));
|
1239
1314
|
|
1240
|
-
|
1241
|
-
_E(iface == NULL, create_error(e_DefinitionError, "virInterfaceDefineXML",
|
1242
|
-
conn));
|
1243
|
-
|
1244
|
-
return interface_new(iface, c);
|
1315
|
+
return ruby_libvirt_interface_new(iface, c);
|
1245
1316
|
}
|
1246
1317
|
#endif
|
1247
1318
|
|
@@ -1249,139 +1320,151 @@ static VALUE libvirt_conn_define_interface_xml(int argc, VALUE *argv, VALUE c) {
|
|
1249
1320
|
* call-seq:
|
1250
1321
|
* conn.num_of_networks -> fixnum
|
1251
1322
|
*
|
1252
|
-
* Call
|
1323
|
+
* Call virConnectNumOfNetworks[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectNumOfNetworks]
|
1253
1324
|
* to retrieve the number of active networks on this connection.
|
1254
1325
|
*/
|
1255
|
-
static VALUE
|
1256
|
-
|
1326
|
+
static VALUE libvirt_connect_num_of_networks(VALUE c)
|
1327
|
+
{
|
1328
|
+
gen_conn_num_of(c, Networks);
|
1257
1329
|
}
|
1258
1330
|
|
1259
1331
|
/*
|
1260
1332
|
* call-seq:
|
1261
1333
|
* conn.list_networks -> list
|
1262
1334
|
*
|
1263
|
-
* Call
|
1335
|
+
* Call virConnectListNetworks[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectListNetworks]
|
1264
1336
|
* to retrieve a list of active network names on this connection.
|
1265
1337
|
*/
|
1266
|
-
static VALUE
|
1267
|
-
|
1338
|
+
static VALUE libvirt_connect_list_networks(VALUE c)
|
1339
|
+
{
|
1340
|
+
gen_conn_list_names(c, Networks);
|
1268
1341
|
}
|
1269
1342
|
|
1270
1343
|
/*
|
1271
1344
|
* call-seq:
|
1272
1345
|
* conn.num_of_defined_networks -> fixnum
|
1273
1346
|
*
|
1274
|
-
* Call
|
1347
|
+
* Call virConnectNumOfDefinedNetworks[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectNumOfDefinedNetworks]
|
1275
1348
|
* to retrieve the number of inactive networks on this connection.
|
1276
1349
|
*/
|
1277
|
-
static VALUE
|
1278
|
-
|
1350
|
+
static VALUE libvirt_connect_num_of_defined_networks(VALUE c)
|
1351
|
+
{
|
1352
|
+
gen_conn_num_of(c, DefinedNetworks);
|
1279
1353
|
}
|
1280
1354
|
|
1281
1355
|
/*
|
1282
1356
|
* call-seq:
|
1283
1357
|
* conn.list_of_defined_networks -> list
|
1284
1358
|
*
|
1285
|
-
* Call
|
1359
|
+
* Call virConnectListDefinedNetworks[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectListDefinedNetworks]
|
1286
1360
|
* to retrieve a list of inactive network names on this connection.
|
1287
1361
|
*/
|
1288
|
-
static VALUE
|
1289
|
-
|
1362
|
+
static VALUE libvirt_connect_list_defined_networks(VALUE c)
|
1363
|
+
{
|
1364
|
+
gen_conn_list_names(c, DefinedNetworks);
|
1290
1365
|
}
|
1291
1366
|
|
1292
1367
|
/*
|
1293
1368
|
* call-seq:
|
1294
1369
|
* conn.lookup_network_by_name(name) -> Libvirt::Network
|
1295
1370
|
*
|
1296
|
-
* Call
|
1371
|
+
* Call virNetworkLookupByName[http://www.libvirt.org/html/libvirt-libvirt.html#virNetworkLookupByName]
|
1297
1372
|
* to retrieve a network object by name.
|
1298
1373
|
*/
|
1299
|
-
static VALUE
|
1374
|
+
static VALUE libvirt_connect_lookup_network_by_name(VALUE c, VALUE name)
|
1375
|
+
{
|
1300
1376
|
virNetworkPtr netw;
|
1301
|
-
virConnectPtr conn = connect_get(c);
|
1302
1377
|
|
1303
|
-
netw = virNetworkLookupByName(
|
1304
|
-
|
1305
|
-
|
1378
|
+
netw = virNetworkLookupByName(ruby_libvirt_connect_get(c),
|
1379
|
+
StringValueCStr(name));
|
1380
|
+
ruby_libvirt_raise_error_if(netw == NULL, e_RetrieveError,
|
1381
|
+
"virNetworkLookupByName",
|
1382
|
+
ruby_libvirt_connect_get(c));
|
1306
1383
|
|
1307
|
-
return
|
1384
|
+
return ruby_libvirt_network_new(netw, c);
|
1308
1385
|
}
|
1309
1386
|
|
1310
1387
|
/*
|
1311
1388
|
* call-seq:
|
1312
1389
|
* conn.lookup_network_by_uuid(uuid) -> Libvirt::Network
|
1313
1390
|
*
|
1314
|
-
* Call
|
1391
|
+
* Call virNetworkLookupByUUIDString[http://www.libvirt.org/html/libvirt-libvirt.html#virNetworkLookupByUUIDString]
|
1315
1392
|
* to retrieve a network object by UUID.
|
1316
1393
|
*/
|
1317
|
-
static VALUE
|
1394
|
+
static VALUE libvirt_connect_lookup_network_by_uuid(VALUE c, VALUE uuid)
|
1395
|
+
{
|
1318
1396
|
virNetworkPtr netw;
|
1319
|
-
virConnectPtr conn = connect_get(c);
|
1320
1397
|
|
1321
|
-
netw = virNetworkLookupByUUIDString(
|
1322
|
-
|
1323
|
-
|
1398
|
+
netw = virNetworkLookupByUUIDString(ruby_libvirt_connect_get(c),
|
1399
|
+
StringValueCStr(uuid));
|
1400
|
+
ruby_libvirt_raise_error_if(netw == NULL, e_RetrieveError,
|
1401
|
+
"virNetworkLookupByUUID",
|
1402
|
+
ruby_libvirt_connect_get(c));
|
1324
1403
|
|
1325
|
-
return
|
1404
|
+
return ruby_libvirt_network_new(netw, c);
|
1326
1405
|
}
|
1327
1406
|
|
1328
1407
|
/*
|
1329
1408
|
* call-seq:
|
1330
1409
|
* conn.create_network_xml(xml) -> Libvirt::Network
|
1331
1410
|
*
|
1332
|
-
* Call
|
1411
|
+
* Call virNetworkCreateXML[http://www.libvirt.org/html/libvirt-libvirt.html#virNetworkCreateXML]
|
1333
1412
|
* to start a new transient network from xml.
|
1334
1413
|
*/
|
1335
|
-
static VALUE
|
1414
|
+
static VALUE libvirt_connect_create_network_xml(VALUE c, VALUE xml)
|
1415
|
+
{
|
1336
1416
|
virNetworkPtr netw;
|
1337
|
-
virConnectPtr conn = connect_get(c);
|
1338
1417
|
|
1339
|
-
netw = virNetworkCreateXML(
|
1340
|
-
|
1418
|
+
netw = virNetworkCreateXML(ruby_libvirt_connect_get(c),
|
1419
|
+
StringValueCStr(xml));
|
1420
|
+
ruby_libvirt_raise_error_if(netw == NULL, e_Error, "virNetworkCreateXML",
|
1421
|
+
ruby_libvirt_connect_get(c));
|
1341
1422
|
|
1342
|
-
return
|
1423
|
+
return ruby_libvirt_network_new(netw, c);
|
1343
1424
|
}
|
1344
1425
|
|
1345
1426
|
/*
|
1346
1427
|
* call-seq:
|
1347
1428
|
* conn.define_network_xml(xml) -> Libvirt::Network
|
1348
1429
|
*
|
1349
|
-
* Call
|
1430
|
+
* Call virNetworkDefineXML[http://www.libvirt.org/html/libvirt-libvirt.html#virNetworkDefineXML]
|
1350
1431
|
* to define a new permanent network from xml.
|
1351
1432
|
*/
|
1352
|
-
static VALUE
|
1433
|
+
static VALUE libvirt_connect_define_network_xml(VALUE c, VALUE xml)
|
1434
|
+
{
|
1353
1435
|
virNetworkPtr netw;
|
1354
|
-
virConnectPtr conn = connect_get(c);
|
1355
1436
|
|
1356
|
-
netw = virNetworkDefineXML(
|
1357
|
-
|
1358
|
-
|
1437
|
+
netw = virNetworkDefineXML(ruby_libvirt_connect_get(c),
|
1438
|
+
StringValueCStr(xml));
|
1439
|
+
ruby_libvirt_raise_error_if(netw == NULL, e_DefinitionError,
|
1440
|
+
"virNetworkDefineXML",
|
1441
|
+
ruby_libvirt_connect_get(c));
|
1359
1442
|
|
1360
|
-
return
|
1443
|
+
return ruby_libvirt_network_new(netw, c);
|
1361
1444
|
}
|
1362
1445
|
|
1363
1446
|
#if HAVE_TYPE_VIRNODEDEVICEPTR
|
1364
|
-
extern VALUE nodedevice_new(virNodeDevicePtr s, VALUE conn);
|
1365
1447
|
|
1366
1448
|
/*
|
1367
1449
|
* call-seq:
|
1368
1450
|
* conn.num_of_nodedevices(cap=nil, flags=0) -> fixnum
|
1369
1451
|
*
|
1370
|
-
* Call
|
1452
|
+
* Call virNodeNumOfDevices[http://www.libvirt.org/html/libvirt-libvirt.html#virNodeNumOfDevices]
|
1371
1453
|
* to retrieve the number of node devices on this connection.
|
1372
1454
|
*/
|
1373
|
-
static VALUE
|
1455
|
+
static VALUE libvirt_connect_num_of_nodedevices(int argc, VALUE *argv, VALUE c)
|
1456
|
+
{
|
1374
1457
|
int result;
|
1375
|
-
virConnectPtr conn = connect_get(c);
|
1376
1458
|
VALUE cap, flags;
|
1377
1459
|
|
1378
1460
|
rb_scan_args(argc, argv, "02", &cap, &flags);
|
1379
1461
|
|
1380
|
-
|
1381
|
-
|
1382
|
-
|
1383
|
-
result
|
1384
|
-
|
1462
|
+
result = virNodeNumOfDevices(ruby_libvirt_connect_get(c),
|
1463
|
+
ruby_libvirt_get_cstring_or_null(cap),
|
1464
|
+
ruby_libvirt_value_to_uint(flags));
|
1465
|
+
ruby_libvirt_raise_error_if(result < 0, e_RetrieveError,
|
1466
|
+
"virNodeNumOfDevices",
|
1467
|
+
ruby_libvirt_connect_get(c));
|
1385
1468
|
|
1386
1469
|
return INT2NUM(result);
|
1387
1470
|
}
|
@@ -1390,58 +1473,61 @@ static VALUE libvirt_conn_num_of_nodedevices(int argc, VALUE *argv, VALUE c) {
|
|
1390
1473
|
* call-seq:
|
1391
1474
|
* conn.list_nodedevices(cap=nil, flags=0) -> list
|
1392
1475
|
*
|
1393
|
-
* Call
|
1476
|
+
* Call virNodeListDevices[http://www.libvirt.org/html/libvirt-libvirt.html#virNodeListDevices]
|
1394
1477
|
* to retrieve a list of node device names on this connection.
|
1395
1478
|
*/
|
1396
|
-
static VALUE
|
1479
|
+
static VALUE libvirt_connect_list_nodedevices(int argc, VALUE *argv, VALUE c)
|
1480
|
+
{
|
1397
1481
|
int r, num;
|
1398
|
-
|
1399
|
-
VALUE cap, flags_val;
|
1482
|
+
VALUE cap, flags;
|
1400
1483
|
char *capstr;
|
1401
1484
|
char **names;
|
1402
|
-
unsigned int flags;
|
1403
1485
|
|
1404
|
-
rb_scan_args(argc, argv, "02", &cap, &
|
1486
|
+
rb_scan_args(argc, argv, "02", &cap, &flags);
|
1405
1487
|
|
1406
|
-
if (
|
1407
|
-
|
1408
|
-
|
1409
|
-
|
1488
|
+
if (TYPE(flags) != T_NIL && TYPE(flags) != T_FIXNUM) {
|
1489
|
+
rb_raise(rb_eTypeError,
|
1490
|
+
"wrong argument type (expected Number)");
|
1491
|
+
}
|
1410
1492
|
|
1411
|
-
capstr =
|
1493
|
+
capstr = ruby_libvirt_get_cstring_or_null(cap);
|
1412
1494
|
|
1413
|
-
num = virNodeNumOfDevices(
|
1414
|
-
|
1415
|
-
|
1495
|
+
num = virNodeNumOfDevices(ruby_libvirt_connect_get(c), capstr, 0);
|
1496
|
+
ruby_libvirt_raise_error_if(num < 0, e_RetrieveError,
|
1497
|
+
"virNodeNumOfDevices",
|
1498
|
+
ruby_libvirt_connect_get(c));
|
1499
|
+
if (num == 0) {
|
1416
1500
|
/* if num is 0, don't call virNodeListDevices function */
|
1417
1501
|
return rb_ary_new2(num);
|
1418
|
-
|
1419
|
-
names = ALLOC_N(char *, num);
|
1420
|
-
r = virNodeListDevices(conn, capstr, names, num, flags);
|
1421
|
-
if (r < 0) {
|
1422
|
-
xfree(names);
|
1423
|
-
rb_exc_raise(create_error(e_RetrieveError, "virNodeListDevices", conn));
|
1424
1502
|
}
|
1425
1503
|
|
1426
|
-
|
1504
|
+
names = alloca(sizeof(char *) * num);
|
1505
|
+
r = virNodeListDevices(ruby_libvirt_connect_get(c), capstr, names, num,
|
1506
|
+
ruby_libvirt_value_to_uint(flags));
|
1507
|
+
ruby_libvirt_raise_error_if(r < 0, e_RetrieveError, "virNodeListDevices",
|
1508
|
+
ruby_libvirt_connect_get(c));
|
1509
|
+
|
1510
|
+
return ruby_libvirt_generate_list(num, names);
|
1427
1511
|
}
|
1428
1512
|
|
1429
1513
|
/*
|
1430
1514
|
* call-seq:
|
1431
1515
|
* conn.lookup_nodedevice_by_name(name) -> Libvirt::NodeDevice
|
1432
1516
|
*
|
1433
|
-
* Call
|
1517
|
+
* Call virNodeDeviceLookupByName[http://www.libvirt.org/html/libvirt-libvirt.html#virNodeDeviceLookupByName]
|
1434
1518
|
* to retrieve a nodedevice object by name.
|
1435
1519
|
*/
|
1436
|
-
static VALUE
|
1520
|
+
static VALUE libvirt_connect_lookup_nodedevice_by_name(VALUE c, VALUE name)
|
1521
|
+
{
|
1437
1522
|
virNodeDevicePtr nodedev;
|
1438
|
-
virConnectPtr conn = connect_get(c);
|
1439
1523
|
|
1440
|
-
nodedev = virNodeDeviceLookupByName(
|
1441
|
-
|
1442
|
-
|
1524
|
+
nodedev = virNodeDeviceLookupByName(ruby_libvirt_connect_get(c),
|
1525
|
+
StringValueCStr(name));
|
1526
|
+
ruby_libvirt_raise_error_if(nodedev == NULL, e_RetrieveError,
|
1527
|
+
"virNodeDeviceLookupByName",
|
1528
|
+
ruby_libvirt_connect_get(c));
|
1443
1529
|
|
1444
|
-
return
|
1530
|
+
return ruby_libvirt_nodedevice_new(nodedev, c);
|
1445
1531
|
|
1446
1532
|
}
|
1447
1533
|
|
@@ -1450,194 +1536,206 @@ static VALUE libvirt_conn_lookup_nodedevice_by_name(VALUE c, VALUE name) {
|
|
1450
1536
|
* call-seq:
|
1451
1537
|
* conn.create_nodedevice_xml(xml, flags=0) -> Libvirt::NodeDevice
|
1452
1538
|
*
|
1453
|
-
* Call
|
1539
|
+
* Call virNodeDeviceCreateXML[http://www.libvirt.org/html/libvirt-libvirt.html#virNodeDeviceCreateXML]
|
1454
1540
|
* to create a new node device from xml.
|
1455
1541
|
*/
|
1456
|
-
static VALUE
|
1457
|
-
|
1542
|
+
static VALUE libvirt_connect_create_nodedevice_xml(int argc, VALUE *argv,
|
1543
|
+
VALUE c)
|
1544
|
+
{
|
1458
1545
|
virNodeDevicePtr nodedev;
|
1459
|
-
virConnectPtr conn = connect_get(c);
|
1460
1546
|
VALUE xml, flags;
|
1461
1547
|
|
1462
1548
|
rb_scan_args(argc, argv, "11", &xml, &flags);
|
1463
1549
|
|
1464
|
-
|
1465
|
-
|
1466
|
-
|
1467
|
-
nodedev
|
1468
|
-
|
1469
|
-
|
1550
|
+
nodedev = virNodeDeviceCreateXML(ruby_libvirt_connect_get(c),
|
1551
|
+
StringValueCStr(xml),
|
1552
|
+
ruby_libvirt_value_to_uint(flags));
|
1553
|
+
ruby_libvirt_raise_error_if(nodedev == NULL, e_Error,
|
1554
|
+
"virNodeDeviceCreateXML",
|
1555
|
+
ruby_libvirt_connect_get(c));
|
1470
1556
|
|
1471
|
-
return
|
1557
|
+
return ruby_libvirt_nodedevice_new(nodedev, c);
|
1472
1558
|
}
|
1473
1559
|
#endif
|
1474
1560
|
#endif
|
1475
1561
|
|
1476
1562
|
#if HAVE_TYPE_VIRNWFILTERPTR
|
1477
|
-
extern VALUE nwfilter_new(virNWFilterPtr nw, VALUE conn);
|
1478
1563
|
|
1479
1564
|
/*
|
1480
1565
|
* call-seq:
|
1481
1566
|
* conn.num_of_nwfilters -> fixnum
|
1482
1567
|
*
|
1483
|
-
* Call
|
1568
|
+
* Call virConnectNumOfNWFilters[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectNumOfNWFilters]
|
1484
1569
|
* to retrieve the number of network filters on this connection.
|
1485
1570
|
*/
|
1486
|
-
static VALUE
|
1487
|
-
|
1571
|
+
static VALUE libvirt_connect_num_of_nwfilters(VALUE c)
|
1572
|
+
{
|
1573
|
+
gen_conn_num_of(c, NWFilters);
|
1488
1574
|
}
|
1489
1575
|
|
1490
1576
|
/*
|
1491
1577
|
* call-seq:
|
1492
1578
|
* conn.list_nwfilters -> list
|
1493
1579
|
*
|
1494
|
-
* Call
|
1580
|
+
* Call virConnectListNWFilters[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectListNWFilters]
|
1495
1581
|
* to retrieve a list of network filter names on this connection.
|
1496
1582
|
*/
|
1497
|
-
static VALUE
|
1498
|
-
|
1583
|
+
static VALUE libvirt_connect_list_nwfilters(VALUE c)
|
1584
|
+
{
|
1585
|
+
gen_conn_list_names(c, NWFilters);
|
1499
1586
|
}
|
1500
1587
|
|
1501
1588
|
/*
|
1502
1589
|
* call-seq:
|
1503
1590
|
* conn.lookup_nwfilter_by_name(name) -> Libvirt::NWFilter
|
1504
1591
|
*
|
1505
|
-
* Call
|
1592
|
+
* Call virNWFilterLookupByName[http://www.libvirt.org/html/libvirt-libvirt.html#virNWFilterLookupByName]
|
1506
1593
|
* to retrieve a network filter object by name.
|
1507
1594
|
*/
|
1508
|
-
static VALUE
|
1595
|
+
static VALUE libvirt_connect_lookup_nwfilter_by_name(VALUE c, VALUE name)
|
1596
|
+
{
|
1509
1597
|
virNWFilterPtr nwfilter;
|
1510
|
-
virConnectPtr conn = connect_get(c);
|
1511
1598
|
|
1512
|
-
nwfilter = virNWFilterLookupByName(
|
1513
|
-
|
1514
|
-
|
1599
|
+
nwfilter = virNWFilterLookupByName(ruby_libvirt_connect_get(c),
|
1600
|
+
StringValueCStr(name));
|
1601
|
+
ruby_libvirt_raise_error_if(nwfilter == NULL, e_RetrieveError,
|
1602
|
+
"virNWFilterLookupByName",
|
1603
|
+
ruby_libvirt_connect_get(c));
|
1515
1604
|
|
1516
|
-
return
|
1605
|
+
return ruby_libvirt_nwfilter_new(nwfilter, c);
|
1517
1606
|
}
|
1518
1607
|
|
1519
1608
|
/*
|
1520
1609
|
* call-seq:
|
1521
1610
|
* conn.lookup_nwfilter_by_uuid(uuid) -> Libvirt::NWFilter
|
1522
1611
|
*
|
1523
|
-
* Call
|
1612
|
+
* Call virNWFilterLookupByUUIDString[http://www.libvirt.org/html/libvirt-libvirt.html#virNWFilterLookupByUUIDString]
|
1524
1613
|
* to retrieve a network filter object by UUID.
|
1525
1614
|
*/
|
1526
|
-
static VALUE
|
1615
|
+
static VALUE libvirt_connect_lookup_nwfilter_by_uuid(VALUE c, VALUE uuid)
|
1616
|
+
{
|
1527
1617
|
virNWFilterPtr nwfilter;
|
1528
|
-
virConnectPtr conn = connect_get(c);
|
1529
1618
|
|
1530
|
-
nwfilter = virNWFilterLookupByUUIDString(
|
1531
|
-
|
1532
|
-
|
1619
|
+
nwfilter = virNWFilterLookupByUUIDString(ruby_libvirt_connect_get(c),
|
1620
|
+
StringValueCStr(uuid));
|
1621
|
+
ruby_libvirt_raise_error_if(nwfilter == NULL, e_RetrieveError,
|
1622
|
+
"virNWFilterLookupByUUIDString",
|
1623
|
+
ruby_libvirt_connect_get(c));
|
1533
1624
|
|
1534
|
-
return
|
1625
|
+
return ruby_libvirt_nwfilter_new(nwfilter, c);
|
1535
1626
|
}
|
1536
1627
|
|
1537
1628
|
/*
|
1538
1629
|
* call-seq:
|
1539
1630
|
* conn.define_nwfilter_xml(xml) -> Libvirt::NWFilter
|
1540
1631
|
*
|
1541
|
-
* Call
|
1632
|
+
* Call virNWFilterDefineXML[http://www.libvirt.org/html/libvirt-libvirt.html#virNWFilterDefineXML]
|
1542
1633
|
* to define a new network filter from xml.
|
1543
1634
|
*/
|
1544
|
-
static VALUE
|
1635
|
+
static VALUE libvirt_connect_define_nwfilter_xml(VALUE c, VALUE xml)
|
1636
|
+
{
|
1545
1637
|
virNWFilterPtr nwfilter;
|
1546
|
-
virConnectPtr conn = connect_get(c);
|
1547
1638
|
|
1548
|
-
nwfilter = virNWFilterDefineXML(
|
1549
|
-
|
1550
|
-
|
1639
|
+
nwfilter = virNWFilterDefineXML(ruby_libvirt_connect_get(c),
|
1640
|
+
StringValueCStr(xml));
|
1641
|
+
ruby_libvirt_raise_error_if(nwfilter == NULL, e_DefinitionError,
|
1642
|
+
"virNWFilterDefineXML",
|
1643
|
+
ruby_libvirt_connect_get(c));
|
1551
1644
|
|
1552
|
-
return
|
1645
|
+
return ruby_libvirt_nwfilter_new(nwfilter, c);
|
1553
1646
|
}
|
1554
1647
|
#endif
|
1555
1648
|
|
1556
1649
|
#if HAVE_TYPE_VIRSECRETPTR
|
1557
|
-
extern VALUE secret_new(virSecretPtr s, VALUE conn);
|
1558
1650
|
|
1559
1651
|
/*
|
1560
1652
|
* call-seq:
|
1561
1653
|
* conn.num_of_secrets -> fixnum
|
1562
1654
|
*
|
1563
|
-
* Call
|
1655
|
+
* Call virConnectNumOfSecrets[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectNumOfSecrets]
|
1564
1656
|
* to retrieve the number of secrets on this connection.
|
1565
1657
|
*/
|
1566
|
-
static VALUE
|
1567
|
-
|
1658
|
+
static VALUE libvirt_connect_num_of_secrets(VALUE c)
|
1659
|
+
{
|
1660
|
+
gen_conn_num_of(c, Secrets);
|
1568
1661
|
}
|
1569
1662
|
|
1570
1663
|
/*
|
1571
1664
|
* call-seq:
|
1572
1665
|
* conn.list_secrets -> list
|
1573
1666
|
*
|
1574
|
-
* Call
|
1667
|
+
* Call virConnectListSecrets[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectListSecrets]
|
1575
1668
|
* to retrieve a list of secret UUIDs on this connection.
|
1576
1669
|
*/
|
1577
|
-
static VALUE
|
1578
|
-
|
1670
|
+
static VALUE libvirt_connect_list_secrets(VALUE c)
|
1671
|
+
{
|
1672
|
+
gen_conn_list_names(c, Secrets);
|
1579
1673
|
}
|
1580
1674
|
|
1581
1675
|
/*
|
1582
1676
|
* call-seq:
|
1583
1677
|
* conn.lookup_secret_by_uuid(uuid) -> Libvirt::Secret
|
1584
1678
|
*
|
1585
|
-
* Call
|
1679
|
+
* Call virSecretLookupByUUID[http://www.libvirt.org/html/libvirt-libvirt.html#virSecretLookupByUUID]
|
1586
1680
|
* to retrieve a network object from uuid.
|
1587
1681
|
*/
|
1588
|
-
static VALUE
|
1682
|
+
static VALUE libvirt_connect_lookup_secret_by_uuid(VALUE c, VALUE uuid)
|
1683
|
+
{
|
1589
1684
|
virSecretPtr secret;
|
1590
|
-
virConnectPtr conn = connect_get(c);
|
1591
1685
|
|
1592
|
-
secret = virSecretLookupByUUIDString(
|
1593
|
-
|
1594
|
-
|
1686
|
+
secret = virSecretLookupByUUIDString(ruby_libvirt_connect_get(c),
|
1687
|
+
StringValueCStr(uuid));
|
1688
|
+
ruby_libvirt_raise_error_if(secret == NULL, e_RetrieveError,
|
1689
|
+
"virSecretLookupByUUID",
|
1690
|
+
ruby_libvirt_connect_get(c));
|
1595
1691
|
|
1596
|
-
return
|
1692
|
+
return ruby_libvirt_secret_new(secret, c);
|
1597
1693
|
}
|
1598
1694
|
|
1599
1695
|
/*
|
1600
1696
|
* call-seq:
|
1601
1697
|
* conn.lookup_secret_by_usage(usagetype, usageID) -> Libvirt::Secret
|
1602
1698
|
*
|
1603
|
-
* Call
|
1699
|
+
* Call virSecretLookupByUsage[http://www.libvirt.org/html/libvirt-libvirt.html#virSecretLookupByUsage]
|
1604
1700
|
* to retrieve a secret by usagetype.
|
1605
1701
|
*/
|
1606
|
-
static VALUE
|
1607
|
-
|
1702
|
+
static VALUE libvirt_connect_lookup_secret_by_usage(VALUE c, VALUE usagetype,
|
1703
|
+
VALUE usageID)
|
1704
|
+
{
|
1608
1705
|
virSecretPtr secret;
|
1609
|
-
virConnectPtr conn = connect_get(c);
|
1610
1706
|
|
1611
|
-
secret = virSecretLookupByUsage(
|
1707
|
+
secret = virSecretLookupByUsage(ruby_libvirt_connect_get(c),
|
1708
|
+
NUM2UINT(usagetype),
|
1612
1709
|
StringValueCStr(usageID));
|
1613
|
-
|
1614
|
-
|
1710
|
+
ruby_libvirt_raise_error_if(secret == NULL, e_RetrieveError,
|
1711
|
+
"virSecretLookupByUsage",
|
1712
|
+
ruby_libvirt_connect_get(c));
|
1615
1713
|
|
1616
|
-
return
|
1714
|
+
return ruby_libvirt_secret_new(secret, c);
|
1617
1715
|
}
|
1618
1716
|
|
1619
1717
|
/*
|
1620
1718
|
* call-seq:
|
1621
1719
|
* conn.define_secret_xml(xml, flags=0) -> Libvirt::Secret
|
1622
1720
|
*
|
1623
|
-
* Call
|
1721
|
+
* Call virSecretDefineXML[http://www.libvirt.org/html/libvirt-libvirt.html#virSecretDefineXML]
|
1624
1722
|
* to define a new secret from xml.
|
1625
1723
|
*/
|
1626
|
-
static VALUE
|
1724
|
+
static VALUE libvirt_connect_define_secret_xml(int argc, VALUE *argv, VALUE c)
|
1725
|
+
{
|
1627
1726
|
virSecretPtr secret;
|
1628
|
-
virConnectPtr conn = connect_get(c);
|
1629
1727
|
VALUE xml, flags;
|
1630
1728
|
|
1631
1729
|
rb_scan_args(argc, argv, "11", &xml, &flags);
|
1632
1730
|
|
1633
|
-
|
1634
|
-
|
1731
|
+
secret = virSecretDefineXML(ruby_libvirt_connect_get(c),
|
1732
|
+
StringValueCStr(xml),
|
1733
|
+
ruby_libvirt_value_to_uint(flags));
|
1734
|
+
ruby_libvirt_raise_error_if(secret == NULL, e_DefinitionError,
|
1735
|
+
"virSecretDefineXML",
|
1736
|
+
ruby_libvirt_connect_get(c));
|
1635
1737
|
|
1636
|
-
|
1637
|
-
_E(secret == NULL, create_error(e_DefinitionError, "virSecretDefineXML",
|
1638
|
-
conn));
|
1639
|
-
|
1640
|
-
return secret_new(secret, c);
|
1738
|
+
return ruby_libvirt_secret_new(secret, c);
|
1641
1739
|
}
|
1642
1740
|
#endif
|
1643
1741
|
|
@@ -1649,60 +1747,66 @@ VALUE pool_new(virStoragePoolPtr n, VALUE conn);
|
|
1649
1747
|
* call-seq:
|
1650
1748
|
* conn.list_storage_pools -> list
|
1651
1749
|
*
|
1652
|
-
* Call
|
1750
|
+
* Call virConnectListStoragePools[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectListStoragePools]
|
1653
1751
|
* to retrieve a list of active storage pool names on this connection.
|
1654
1752
|
*/
|
1655
|
-
static VALUE
|
1656
|
-
|
1753
|
+
static VALUE libvirt_connect_list_storage_pools(VALUE c)
|
1754
|
+
{
|
1755
|
+
gen_conn_list_names(c, StoragePools);
|
1657
1756
|
}
|
1658
1757
|
|
1659
1758
|
/*
|
1660
1759
|
* call-seq:
|
1661
1760
|
* conn.num_of_storage_pools -> fixnum
|
1662
1761
|
*
|
1663
|
-
* Call
|
1762
|
+
* Call virConnectNumOfStoragePools[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectNumOfStoragePools]
|
1664
1763
|
* to retrieve the number of active storage pools on this connection.
|
1665
1764
|
*/
|
1666
|
-
static VALUE
|
1667
|
-
|
1765
|
+
static VALUE libvirt_connect_num_of_storage_pools(VALUE c)
|
1766
|
+
{
|
1767
|
+
gen_conn_num_of(c, StoragePools);
|
1668
1768
|
}
|
1669
1769
|
|
1670
1770
|
/*
|
1671
1771
|
* call-seq:
|
1672
1772
|
* conn.list_defined_storage_pools -> list
|
1673
1773
|
*
|
1674
|
-
* Call
|
1774
|
+
* Call virConnectListDefinedStoragePools[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectListDefinedStoragePools]
|
1675
1775
|
* to retrieve a list of inactive storage pool names on this connection.
|
1676
1776
|
*/
|
1677
|
-
static VALUE
|
1678
|
-
|
1777
|
+
static VALUE libvirt_connect_list_defined_storage_pools(VALUE c)
|
1778
|
+
{
|
1779
|
+
gen_conn_list_names(c, DefinedStoragePools);
|
1679
1780
|
}
|
1680
1781
|
|
1681
1782
|
/*
|
1682
1783
|
* call-seq:
|
1683
1784
|
* conn.num_of_defined_storage_pools -> fixnum
|
1684
1785
|
*
|
1685
|
-
* Call
|
1786
|
+
* Call virConnectNumOfDefinedStoragePools[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectNumOfDefinedStoragePools]
|
1686
1787
|
* to retrieve the number of inactive storage pools on this connection.
|
1687
1788
|
*/
|
1688
|
-
static VALUE
|
1689
|
-
|
1789
|
+
static VALUE libvirt_connect_num_of_defined_storage_pools(VALUE c)
|
1790
|
+
{
|
1791
|
+
gen_conn_num_of(c, DefinedStoragePools);
|
1690
1792
|
}
|
1691
1793
|
|
1692
1794
|
/*
|
1693
1795
|
* call-seq:
|
1694
1796
|
* conn.lookup_storage_pool_by_name(name) -> Libvirt::StoragePool
|
1695
1797
|
*
|
1696
|
-
* Call
|
1798
|
+
* Call virStoragePoolLookupByName[http://www.libvirt.org/html/libvirt-libvirt.html#virStoragePoolLookupByName]
|
1697
1799
|
* to retrieve a storage pool object by name.
|
1698
1800
|
*/
|
1699
|
-
static VALUE
|
1801
|
+
static VALUE libvirt_connect_lookup_pool_by_name(VALUE c, VALUE name)
|
1802
|
+
{
|
1700
1803
|
virStoragePoolPtr pool;
|
1701
|
-
virConnectPtr conn = connect_get(c);
|
1702
1804
|
|
1703
|
-
pool = virStoragePoolLookupByName(
|
1704
|
-
|
1705
|
-
|
1805
|
+
pool = virStoragePoolLookupByName(ruby_libvirt_connect_get(c),
|
1806
|
+
StringValueCStr(name));
|
1807
|
+
ruby_libvirt_raise_error_if(pool == NULL, e_RetrieveError,
|
1808
|
+
"virStoragePoolLookupByName",
|
1809
|
+
ruby_libvirt_connect_get(c));
|
1706
1810
|
|
1707
1811
|
return pool_new(pool, c);
|
1708
1812
|
}
|
@@ -1711,16 +1815,18 @@ static VALUE libvirt_conn_lookup_pool_by_name(VALUE c, VALUE name) {
|
|
1711
1815
|
* call-seq:
|
1712
1816
|
* conn.lookup_storage_pool_by_uuid(uuid) -> Libvirt::StoragePool
|
1713
1817
|
*
|
1714
|
-
* Call
|
1818
|
+
* Call virStoragePoolLookupByUUIDString[http://www.libvirt.org/html/libvirt-libvirt.html#virStoragePoolLookupByUUIDString]
|
1715
1819
|
* to retrieve a storage pool object by uuid.
|
1716
1820
|
*/
|
1717
|
-
static VALUE
|
1821
|
+
static VALUE libvirt_connect_lookup_pool_by_uuid(VALUE c, VALUE uuid)
|
1822
|
+
{
|
1718
1823
|
virStoragePoolPtr pool;
|
1719
|
-
virConnectPtr conn = connect_get(c);
|
1720
1824
|
|
1721
|
-
pool = virStoragePoolLookupByUUIDString(
|
1722
|
-
|
1723
|
-
|
1825
|
+
pool = virStoragePoolLookupByUUIDString(ruby_libvirt_connect_get(c),
|
1826
|
+
StringValueCStr(uuid));
|
1827
|
+
ruby_libvirt_raise_error_if(pool == NULL, e_RetrieveError,
|
1828
|
+
"virStoragePoolLookupByUUID",
|
1829
|
+
ruby_libvirt_connect_get(c));
|
1724
1830
|
|
1725
1831
|
return pool_new(pool, c);
|
1726
1832
|
}
|
@@ -1729,21 +1835,22 @@ static VALUE libvirt_conn_lookup_pool_by_uuid(VALUE c, VALUE uuid) {
|
|
1729
1835
|
* call-seq:
|
1730
1836
|
* conn.create_storage_pool_xml(xml, flags=0) -> Libvirt::StoragePool
|
1731
1837
|
*
|
1732
|
-
* Call
|
1838
|
+
* Call virStoragePoolCreateXML[http://www.libvirt.org/html/libvirt-libvirt.html#virStoragePoolCreateXML]
|
1733
1839
|
* to start a new transient storage pool from xml.
|
1734
1840
|
*/
|
1735
|
-
static VALUE
|
1841
|
+
static VALUE libvirt_connect_create_pool_xml(int argc, VALUE *argv, VALUE c)
|
1842
|
+
{
|
1736
1843
|
virStoragePoolPtr pool;
|
1737
|
-
virConnectPtr conn = connect_get(c);
|
1738
1844
|
VALUE xml, flags;
|
1739
1845
|
|
1740
1846
|
rb_scan_args(argc, argv, "11", &xml, &flags);
|
1741
1847
|
|
1742
|
-
|
1743
|
-
|
1744
|
-
|
1745
|
-
pool
|
1746
|
-
|
1848
|
+
pool = virStoragePoolCreateXML(ruby_libvirt_connect_get(c),
|
1849
|
+
StringValueCStr(xml),
|
1850
|
+
ruby_libvirt_value_to_uint(flags));
|
1851
|
+
ruby_libvirt_raise_error_if(pool == NULL, e_Error,
|
1852
|
+
"virStoragePoolCreateXML",
|
1853
|
+
ruby_libvirt_connect_get(c));
|
1747
1854
|
|
1748
1855
|
return pool_new(pool, c);
|
1749
1856
|
}
|
@@ -1752,22 +1859,22 @@ static VALUE libvirt_conn_create_pool_xml(int argc, VALUE *argv, VALUE c) {
|
|
1752
1859
|
* call-seq:
|
1753
1860
|
* conn.define_storage_pool_xml(xml, flags=0) -> Libvirt::StoragePool
|
1754
1861
|
*
|
1755
|
-
* Call
|
1862
|
+
* Call virStoragePoolDefineXML[http://www.libvirt.org/html/libvirt-libvirt.html#virStoragePoolDefineXML]
|
1756
1863
|
* to define a permanent storage pool from xml.
|
1757
1864
|
*/
|
1758
|
-
static VALUE
|
1865
|
+
static VALUE libvirt_connect_define_pool_xml(int argc, VALUE *argv, VALUE c)
|
1866
|
+
{
|
1759
1867
|
virStoragePoolPtr pool;
|
1760
|
-
virConnectPtr conn = connect_get(c);
|
1761
1868
|
VALUE xml, flags;
|
1762
1869
|
|
1763
1870
|
rb_scan_args(argc, argv, "11", &xml, &flags);
|
1764
1871
|
|
1765
|
-
|
1766
|
-
|
1767
|
-
|
1768
|
-
pool
|
1769
|
-
|
1770
|
-
|
1872
|
+
pool = virStoragePoolDefineXML(ruby_libvirt_connect_get(c),
|
1873
|
+
StringValueCStr(xml),
|
1874
|
+
ruby_libvirt_value_to_uint(flags));
|
1875
|
+
ruby_libvirt_raise_error_if(pool == NULL, e_DefinitionError,
|
1876
|
+
"virStoragePoolDefineXML",
|
1877
|
+
ruby_libvirt_connect_get(c));
|
1771
1878
|
|
1772
1879
|
return pool_new(pool, c);
|
1773
1880
|
}
|
@@ -1776,21 +1883,22 @@ static VALUE libvirt_conn_define_pool_xml(int argc, VALUE *argv, VALUE c) {
|
|
1776
1883
|
* call-seq:
|
1777
1884
|
* conn.discover_storage_pool_sources(type, srcSpec=nil, flags=0) -> string
|
1778
1885
|
*
|
1779
|
-
* Call
|
1886
|
+
* Call virConnectFindStoragePoolSources[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectFindStoragePoolSources]
|
1780
1887
|
* to find the storage pool sources corresponding to type.
|
1781
1888
|
*/
|
1782
|
-
static VALUE
|
1783
|
-
|
1784
|
-
|
1785
|
-
|
1786
|
-
rb_scan_args(argc, argv, "12", &type, &srcSpec_val, &flags);
|
1889
|
+
static VALUE libvirt_connect_find_storage_pool_sources(int argc, VALUE *argv,
|
1890
|
+
VALUE c)
|
1891
|
+
{
|
1892
|
+
VALUE type, srcSpec, flags;
|
1787
1893
|
|
1788
|
-
|
1789
|
-
flags = INT2NUM(0);
|
1894
|
+
rb_scan_args(argc, argv, "12", &type, &srcSpec, &flags);
|
1790
1895
|
|
1791
|
-
|
1792
|
-
|
1793
|
-
|
1896
|
+
ruby_libvirt_generate_call_string(virConnectFindStoragePoolSources,
|
1897
|
+
ruby_libvirt_connect_get(c), 1,
|
1898
|
+
ruby_libvirt_connect_get(c),
|
1899
|
+
StringValueCStr(type),
|
1900
|
+
ruby_libvirt_get_cstring_or_null(srcSpec),
|
1901
|
+
ruby_libvirt_value_to_uint(flags));
|
1794
1902
|
}
|
1795
1903
|
#endif
|
1796
1904
|
|
@@ -1799,47 +1907,46 @@ static VALUE libvirt_conn_find_storage_pool_sources(int argc, VALUE *argv,
|
|
1799
1907
|
* call-seq:
|
1800
1908
|
* conn.sys_info(flags=0) -> string
|
1801
1909
|
*
|
1802
|
-
* Call
|
1910
|
+
* Call virConnectGetSysinfo[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectGetSysinfo]
|
1803
1911
|
* to get machine-specific information about the hypervisor. This may include
|
1804
1912
|
* data such as the host UUID, the BIOS version, etc.
|
1805
1913
|
*/
|
1806
|
-
static VALUE
|
1914
|
+
static VALUE libvirt_connect_sys_info(int argc, VALUE *argv, VALUE c)
|
1915
|
+
{
|
1807
1916
|
VALUE flags;
|
1808
1917
|
|
1809
1918
|
rb_scan_args(argc, argv, "01", &flags);
|
1810
1919
|
|
1811
|
-
|
1812
|
-
|
1813
|
-
|
1814
|
-
|
1815
|
-
NUM2UINT(flags));
|
1920
|
+
ruby_libvirt_generate_call_string(virConnectGetSysinfo,
|
1921
|
+
ruby_libvirt_connect_get(c), 1,
|
1922
|
+
ruby_libvirt_connect_get(c),
|
1923
|
+
ruby_libvirt_value_to_uint(flags));
|
1816
1924
|
}
|
1817
1925
|
#endif
|
1818
1926
|
|
1819
1927
|
#if HAVE_TYPE_VIRSTREAMPTR
|
1820
|
-
extern VALUE stream_new(virStreamPtr s, VALUE conn);
|
1821
1928
|
|
1822
1929
|
/*
|
1823
1930
|
* call-seq:
|
1824
1931
|
* conn.stream(flags=0) -> Libvirt::Stream
|
1825
1932
|
*
|
1826
|
-
* Call
|
1933
|
+
* Call virStreamNew[http://www.libvirt.org/html/libvirt-libvirt.html#virStreamNew]
|
1827
1934
|
* to create a new stream.
|
1828
1935
|
*/
|
1829
|
-
static VALUE
|
1936
|
+
static VALUE libvirt_connect_stream(int argc, VALUE *argv, VALUE c)
|
1937
|
+
{
|
1830
1938
|
VALUE flags;
|
1831
1939
|
virStreamPtr stream;
|
1832
1940
|
|
1833
1941
|
rb_scan_args(argc, argv, "01", &flags);
|
1834
1942
|
|
1835
|
-
|
1836
|
-
|
1943
|
+
stream = virStreamNew(ruby_libvirt_connect_get(c),
|
1944
|
+
ruby_libvirt_value_to_uint(flags));
|
1837
1945
|
|
1838
|
-
stream
|
1946
|
+
ruby_libvirt_raise_error_if(stream == NULL, e_RetrieveError,
|
1947
|
+
"virStreamNew", ruby_libvirt_connect_get(c));
|
1839
1948
|
|
1840
|
-
|
1841
|
-
|
1842
|
-
return stream_new(stream, c);
|
1949
|
+
return ruby_libvirt_stream_new(stream, c);
|
1843
1950
|
}
|
1844
1951
|
#endif
|
1845
1952
|
|
@@ -1848,111 +1955,787 @@ static VALUE libvirt_conn_stream(int argc, VALUE *argv, VALUE c) {
|
|
1848
1955
|
* call-seq:
|
1849
1956
|
* conn.interface_change_begin(flags=0) -> nil
|
1850
1957
|
*
|
1851
|
-
* Call
|
1958
|
+
* Call virInterfaceChangeBegin[http://www.libvirt.org/html/libvirt-libvirt.html#virInterfaceChangeBegin]
|
1852
1959
|
* to create a restore point for interface changes. Once changes have been
|
1853
1960
|
* made, conn.interface_change_commit can be used to commit the result or
|
1854
1961
|
* conn.interface_change_rollback can be used to rollback to this restore point.
|
1855
1962
|
*/
|
1856
|
-
static VALUE
|
1857
|
-
|
1963
|
+
static VALUE libvirt_connect_interface_change_begin(int argc, VALUE *argv,
|
1964
|
+
VALUE c)
|
1965
|
+
{
|
1858
1966
|
VALUE flags;
|
1859
1967
|
|
1860
1968
|
rb_scan_args(argc, argv, "01", &flags);
|
1861
1969
|
|
1862
|
-
|
1863
|
-
|
1970
|
+
ruby_libvirt_generate_call_nil(virInterfaceChangeBegin,
|
1971
|
+
ruby_libvirt_connect_get(c),
|
1972
|
+
ruby_libvirt_connect_get(c),
|
1973
|
+
ruby_libvirt_value_to_uint(flags));
|
1864
1974
|
}
|
1865
1975
|
|
1866
1976
|
/*
|
1867
1977
|
* call-seq:
|
1868
1978
|
* conn.interface_change_commit(flags=0) -> nil
|
1869
1979
|
*
|
1870
|
-
* Call
|
1980
|
+
* Call virInterfaceChangeCommit[http://www.libvirt.org/html/libvirt-libvirt.html#virInterfaceChangeCommit]
|
1871
1981
|
* to commit the interface changes since the last conn.interface_change_begin.
|
1872
1982
|
*/
|
1873
|
-
static VALUE
|
1874
|
-
|
1983
|
+
static VALUE libvirt_connect_interface_change_commit(int argc, VALUE *argv,
|
1984
|
+
VALUE c)
|
1985
|
+
{
|
1875
1986
|
VALUE flags;
|
1876
1987
|
|
1877
1988
|
rb_scan_args(argc, argv, "01", &flags);
|
1878
1989
|
|
1879
|
-
|
1880
|
-
|
1990
|
+
ruby_libvirt_generate_call_nil(virInterfaceChangeCommit,
|
1991
|
+
ruby_libvirt_connect_get(c),
|
1992
|
+
ruby_libvirt_connect_get(c),
|
1993
|
+
ruby_libvirt_value_to_uint(flags));
|
1881
1994
|
}
|
1882
1995
|
|
1883
1996
|
/*
|
1884
1997
|
* call-seq:
|
1885
1998
|
* conn.interface_change_rollback(flags=0) -> nil
|
1886
1999
|
*
|
1887
|
-
* Call
|
2000
|
+
* Call virInterfaceChangeRollback[http://www.libvirt.org/html/libvirt-libvirt.html#virInterfaceChangeRollback]
|
1888
2001
|
* to rollback to the restore point saved by conn.interface_change_begin.
|
1889
2002
|
*/
|
1890
|
-
static VALUE
|
1891
|
-
|
2003
|
+
static VALUE libvirt_connect_interface_change_rollback(int argc, VALUE *argv,
|
2004
|
+
VALUE c)
|
2005
|
+
{
|
1892
2006
|
VALUE flags;
|
1893
2007
|
|
1894
2008
|
rb_scan_args(argc, argv, "01", &flags);
|
1895
2009
|
|
1896
|
-
|
1897
|
-
|
2010
|
+
ruby_libvirt_generate_call_nil(virInterfaceChangeRollback,
|
2011
|
+
ruby_libvirt_connect_get(c),
|
2012
|
+
ruby_libvirt_connect_get(c),
|
2013
|
+
ruby_libvirt_value_to_uint(flags));
|
1898
2014
|
}
|
1899
2015
|
#endif
|
1900
2016
|
|
2017
|
+
#if HAVE_VIRNODEGETCPUSTATS
|
2018
|
+
static void cpu_stats_set(void *voidparams, int i, VALUE result)
|
2019
|
+
{
|
2020
|
+
virNodeCPUStatsPtr params = (virNodeCPUStatsPtr)voidparams;
|
2021
|
+
|
2022
|
+
rb_hash_aset(result, rb_str_new2(params[i].field),
|
2023
|
+
ULL2NUM(params[i].value));
|
2024
|
+
}
|
2025
|
+
|
2026
|
+
static char *cpu_stats_nparams(VALUE d, unsigned int flags, void *opaque,
|
2027
|
+
int *nparams)
|
2028
|
+
{
|
2029
|
+
int intparam = *((int *)opaque);
|
2030
|
+
|
2031
|
+
if (virNodeGetCPUStats(ruby_libvirt_connect_get(d), intparam, NULL,
|
2032
|
+
nparams, flags) < 0) {
|
2033
|
+
return "virNodeGetCPUStats";
|
2034
|
+
}
|
2035
|
+
|
2036
|
+
return NULL;
|
2037
|
+
}
|
2038
|
+
|
2039
|
+
static char *cpu_stats_get(VALUE d, unsigned int flags, void *voidparams,
|
2040
|
+
int *nparams, void *opaque)
|
2041
|
+
{
|
2042
|
+
int intparam = *((int *)opaque);
|
2043
|
+
virNodeCPUStatsPtr params = (virNodeCPUStatsPtr)voidparams;
|
2044
|
+
|
2045
|
+
if (virNodeGetCPUStats(ruby_libvirt_connect_get(d), intparam, params,
|
2046
|
+
nparams, flags) < 0) {
|
2047
|
+
return "virNodeGetCPUStats";
|
2048
|
+
}
|
2049
|
+
|
2050
|
+
return NULL;
|
2051
|
+
}
|
2052
|
+
|
1901
2053
|
/*
|
1902
|
-
*
|
2054
|
+
* call-seq:
|
2055
|
+
* conn.node_cpu_stats(cpuNum=-1, flags=0) -> Hash
|
2056
|
+
*
|
2057
|
+
* Call virNodeGetCPUStats[http://www.libvirt.org/html/libvirt-libvirt.html#virNodeGetCPUStats]
|
2058
|
+
* to retrieve cpu statistics from the virtualization host.
|
1903
2059
|
*/
|
1904
|
-
|
2060
|
+
static VALUE libvirt_connect_node_cpu_stats(int argc, VALUE *argv, VALUE c)
|
1905
2061
|
{
|
1906
|
-
|
2062
|
+
VALUE intparam, flags;
|
2063
|
+
int tmp;
|
1907
2064
|
|
1908
|
-
|
1909
|
-
* Class Libvirt::Connect::Nodeinfo
|
1910
|
-
*/
|
1911
|
-
c_node_info = rb_define_class_under(c_connect, "Nodeinfo", rb_cObject);
|
1912
|
-
rb_define_attr(c_node_info, "model", 1, 0);
|
1913
|
-
rb_define_attr(c_node_info, "memory", 1, 0);
|
1914
|
-
rb_define_attr(c_node_info, "cpus", 1, 0);
|
1915
|
-
rb_define_attr(c_node_info, "mhz", 1, 0);
|
1916
|
-
rb_define_attr(c_node_info, "nodes", 1, 0);
|
1917
|
-
rb_define_attr(c_node_info, "sockets", 1, 0);
|
1918
|
-
rb_define_attr(c_node_info, "cores", 1, 0);
|
1919
|
-
rb_define_attr(c_node_info, "threads", 1, 0);
|
2065
|
+
rb_scan_args(argc, argv, "02", &intparam, &flags);
|
1920
2066
|
|
1921
|
-
|
1922
|
-
* Class Libvirt::Connect::NodeSecurityModel
|
1923
|
-
*/
|
1924
|
-
c_node_security_model = rb_define_class_under(c_connect,
|
1925
|
-
"NodeSecurityModel",
|
1926
|
-
rb_cObject);
|
1927
|
-
rb_define_attr(c_node_security_model, "model", 1, 0);
|
1928
|
-
rb_define_attr(c_node_security_model, "doi", 1, 0);
|
2067
|
+
tmp = ruby_libvirt_value_to_int(intparam);
|
1929
2068
|
|
1930
|
-
|
1931
|
-
|
1932
|
-
|
1933
|
-
|
1934
|
-
|
1935
|
-
rb_define_method(c_connect, "libversion", libvirt_conn_libversion, 0);
|
1936
|
-
#endif
|
1937
|
-
rb_define_method(c_connect, "hostname", libvirt_conn_hostname, 0);
|
1938
|
-
rb_define_method(c_connect, "uri", libvirt_conn_uri, 0);
|
1939
|
-
rb_define_method(c_connect, "max_vcpus", libvirt_conn_max_vcpus, -1);
|
1940
|
-
rb_define_method(c_connect, "node_get_info", libvirt_conn_node_get_info, 0);
|
1941
|
-
rb_define_method(c_connect, "node_free_memory",
|
1942
|
-
libvirt_conn_node_free_memory, 0);
|
1943
|
-
rb_define_method(c_connect, "node_cells_free_memory",
|
1944
|
-
libvirt_conn_node_cells_free_memory, -1);
|
1945
|
-
#if HAVE_VIRNODEGETSECURITYMODEL
|
1946
|
-
rb_define_method(c_connect, "node_get_security_model",
|
1947
|
-
libvirt_conn_node_get_security_model, 0);
|
1948
|
-
#endif
|
1949
|
-
#if HAVE_VIRCONNECTISENCRYPTED
|
1950
|
-
rb_define_method(c_connect, "encrypted?", libvirt_conn_encrypted_p, 0);
|
1951
|
-
#endif
|
1952
|
-
#if HAVE_VIRCONNECTISSECURE
|
1953
|
-
rb_define_method(c_connect, "secure?", libvirt_conn_secure_p, 0);
|
2069
|
+
return ruby_libvirt_get_parameters(c, ruby_libvirt_value_to_uint(flags),
|
2070
|
+
(void *)&tmp, sizeof(virNodeCPUStats),
|
2071
|
+
cpu_stats_nparams, cpu_stats_get,
|
2072
|
+
cpu_stats_set);
|
2073
|
+
}
|
1954
2074
|
#endif
|
1955
|
-
|
2075
|
+
|
2076
|
+
#if HAVE_VIRNODEGETMEMORYSTATS
|
2077
|
+
static void memory_stats_set(void *voidparams, int i, VALUE result)
|
2078
|
+
{
|
2079
|
+
virNodeMemoryStatsPtr params = (virNodeMemoryStatsPtr)voidparams;
|
2080
|
+
|
2081
|
+
rb_hash_aset(result, rb_str_new2(params[i].field),
|
2082
|
+
ULL2NUM(params[i].value));
|
2083
|
+
}
|
2084
|
+
|
2085
|
+
static char *memory_stats_nparams(VALUE d, unsigned int flags, void *opaque,
|
2086
|
+
int *nparams)
|
2087
|
+
{
|
2088
|
+
int intparam = *((int *)opaque);
|
2089
|
+
|
2090
|
+
if (virNodeGetMemoryStats(ruby_libvirt_connect_get(d), intparam, NULL,
|
2091
|
+
nparams, flags) < 0) {
|
2092
|
+
return "virNodeGetMemoryStats";
|
2093
|
+
}
|
2094
|
+
|
2095
|
+
return NULL;
|
2096
|
+
}
|
2097
|
+
|
2098
|
+
static char *memory_stats_get(VALUE d, unsigned int flags, void *voidparams,
|
2099
|
+
int *nparams, void *opaque)
|
2100
|
+
{
|
2101
|
+
int intparam = *((int *)opaque);
|
2102
|
+
virNodeMemoryStatsPtr params = (virNodeMemoryStatsPtr)voidparams;
|
2103
|
+
|
2104
|
+
if (virNodeGetMemoryStats(ruby_libvirt_connect_get(d), intparam, params,
|
2105
|
+
nparams, flags) < 0) {
|
2106
|
+
return "virNodeGetMemoryStats";
|
2107
|
+
}
|
2108
|
+
|
2109
|
+
return NULL;
|
2110
|
+
}
|
2111
|
+
|
2112
|
+
/*
|
2113
|
+
* call-seq:
|
2114
|
+
* conn.node_memory_stats(cellNum=-1, flags=0) -> Hash
|
2115
|
+
*
|
2116
|
+
* Call virNodeGetMemoryStats[http://www.libvirt.org/html/libvirt-libvirt.html#virNodeGetMemoryStats]
|
2117
|
+
* to retrieve memory statistics from the virtualization host.
|
2118
|
+
*/
|
2119
|
+
static VALUE libvirt_connect_node_memory_stats(int argc, VALUE *argv, VALUE c)
|
2120
|
+
{
|
2121
|
+
VALUE intparam, flags;
|
2122
|
+
int tmp;
|
2123
|
+
|
2124
|
+
rb_scan_args(argc, argv, "02", &intparam, &flags);
|
2125
|
+
|
2126
|
+
tmp = ruby_libvirt_value_to_int(intparam);
|
2127
|
+
|
2128
|
+
return ruby_libvirt_get_parameters(c, ruby_libvirt_value_to_uint(flags),
|
2129
|
+
(void *)&tmp, sizeof(virNodeMemoryStats),
|
2130
|
+
memory_stats_nparams, memory_stats_get,
|
2131
|
+
memory_stats_set);
|
2132
|
+
}
|
2133
|
+
#endif
|
2134
|
+
|
2135
|
+
#if HAVE_VIRDOMAINSAVEIMAGEGETXMLDESC
|
2136
|
+
/*
|
2137
|
+
* call-seq:
|
2138
|
+
* conn.save_image_xml_desc(filename, flags=0) -> string
|
2139
|
+
*
|
2140
|
+
* Call virDomainSaveImageGetXMLDesc[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSaveImageGetXMLDesc]
|
2141
|
+
* to get the XML corresponding to a save file.
|
2142
|
+
*/
|
2143
|
+
static VALUE libvirt_connect_save_image_xml_desc(int argc, VALUE *argv, VALUE c)
|
2144
|
+
{
|
2145
|
+
VALUE filename, flags;
|
2146
|
+
|
2147
|
+
rb_scan_args(argc, argv, "11", &filename, &flags);
|
2148
|
+
|
2149
|
+
ruby_libvirt_generate_call_string(virDomainSaveImageGetXMLDesc,
|
2150
|
+
ruby_libvirt_connect_get(c), 1,
|
2151
|
+
ruby_libvirt_connect_get(c),
|
2152
|
+
StringValueCStr(filename),
|
2153
|
+
ruby_libvirt_value_to_uint(flags));
|
2154
|
+
}
|
2155
|
+
|
2156
|
+
/*
|
2157
|
+
* call-seq:
|
2158
|
+
* conn.define_save_image_xml(filename, newxml, flags=0) -> nil
|
2159
|
+
*
|
2160
|
+
* Call virDomainSaveImageDefineXML[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSaveImageDefineXML]
|
2161
|
+
* to define new XML for a saved image.
|
2162
|
+
*/
|
2163
|
+
static VALUE libvirt_connect_define_save_image_xml(int argc, VALUE *argv,
|
2164
|
+
VALUE c)
|
2165
|
+
{
|
2166
|
+
VALUE filename, newxml, flags;
|
2167
|
+
|
2168
|
+
rb_scan_args(argc, argv, "21", &filename, &newxml, &flags);
|
2169
|
+
|
2170
|
+
ruby_libvirt_generate_call_nil(virDomainSaveImageDefineXML,
|
2171
|
+
ruby_libvirt_connect_get(c),
|
2172
|
+
ruby_libvirt_connect_get(c),
|
2173
|
+
StringValueCStr(filename),
|
2174
|
+
StringValueCStr(newxml),
|
2175
|
+
ruby_libvirt_value_to_uint(flags));
|
2176
|
+
}
|
2177
|
+
#endif
|
2178
|
+
|
2179
|
+
#if HAVE_VIRNODESUSPENDFORDURATION
|
2180
|
+
/*
|
2181
|
+
* call-seq:
|
2182
|
+
* conn.node_suspend_for_duration(target, duration, flags=0) -> nil
|
2183
|
+
*
|
2184
|
+
* Call virNodeSuspendForDuration[http://www.libvirt.org/html/libvirt-libvirt.html#virNodeSuspendForDuration]
|
2185
|
+
* to suspend the hypervisor for the specified duration.
|
2186
|
+
*/
|
2187
|
+
static VALUE libvirt_connect_node_suspend_for_duration(int argc, VALUE *argv,
|
2188
|
+
VALUE c)
|
2189
|
+
{
|
2190
|
+
VALUE target, duration, flags;
|
2191
|
+
|
2192
|
+
rb_scan_args(argc, argv, "21", &target, &duration, &flags);
|
2193
|
+
|
2194
|
+
ruby_libvirt_generate_call_nil(virNodeSuspendForDuration,
|
2195
|
+
ruby_libvirt_connect_get(c),
|
2196
|
+
ruby_libvirt_connect_get(c),
|
2197
|
+
NUM2UINT(target), NUM2ULL(duration),
|
2198
|
+
ruby_libvirt_value_to_uint(flags));
|
2199
|
+
}
|
2200
|
+
#endif
|
2201
|
+
|
2202
|
+
#if HAVE_VIRNODEGETMEMORYPARAMETERS
|
2203
|
+
static char *node_memory_nparams(VALUE d, unsigned int flags, void *opaque,
|
2204
|
+
int *nparams)
|
2205
|
+
{
|
2206
|
+
if (virNodeGetMemoryParameters(ruby_libvirt_connect_get(d), NULL, nparams,
|
2207
|
+
flags) < 0) {
|
2208
|
+
return "virNodeGetMemoryParameters";
|
2209
|
+
}
|
2210
|
+
|
2211
|
+
return NULL;
|
2212
|
+
}
|
2213
|
+
|
2214
|
+
static char *node_memory_get(VALUE d, unsigned int flags, void *voidparams,
|
2215
|
+
int *nparams, void *opaque)
|
2216
|
+
{
|
2217
|
+
virTypedParameterPtr params = (virTypedParameterPtr)voidparams;
|
2218
|
+
|
2219
|
+
if (virNodeGetMemoryParameters(ruby_libvirt_connect_get(d), params, nparams,
|
2220
|
+
flags) < 0) {
|
2221
|
+
return "virNodeGetMemoryParameters";
|
2222
|
+
}
|
2223
|
+
return NULL;
|
2224
|
+
}
|
2225
|
+
|
2226
|
+
static char *node_memory_set(VALUE d, unsigned int flags,
|
2227
|
+
virTypedParameterPtr params, int nparams,
|
2228
|
+
void *opauqe)
|
2229
|
+
{
|
2230
|
+
if (virNodeSetMemoryParameters(ruby_libvirt_connect_get(d), params, nparams,
|
2231
|
+
flags) < 0) {
|
2232
|
+
return "virNodeSetMemoryParameters";
|
2233
|
+
}
|
2234
|
+
return NULL;
|
2235
|
+
}
|
2236
|
+
|
2237
|
+
/*
|
2238
|
+
* call-seq:
|
2239
|
+
* conn.node_memory_parameters(flags=0) -> Hash
|
2240
|
+
*
|
2241
|
+
* Call virNodeGetMemoryParameters[http://www.libvirt.org/html/libvirt-libvirt.html#virNodeGetMemoryParameters]
|
2242
|
+
* to get information about memory on the host node.
|
2243
|
+
*/
|
2244
|
+
static VALUE libvirt_connect_node_memory_parameters(int argc, VALUE *argv,
|
2245
|
+
VALUE c)
|
2246
|
+
{
|
2247
|
+
VALUE flags;
|
2248
|
+
|
2249
|
+
rb_scan_args(argc, argv, "01", &flags);
|
2250
|
+
|
2251
|
+
return ruby_libvirt_get_typed_parameters(c,
|
2252
|
+
ruby_libvirt_value_to_uint(flags),
|
2253
|
+
NULL, node_memory_nparams,
|
2254
|
+
node_memory_get);
|
2255
|
+
}
|
2256
|
+
|
2257
|
+
static struct ruby_libvirt_typed_param memory_allowed[] = {
|
2258
|
+
{VIR_NODE_MEMORY_SHARED_PAGES_TO_SCAN, VIR_TYPED_PARAM_UINT},
|
2259
|
+
{VIR_NODE_MEMORY_SHARED_SLEEP_MILLISECS, VIR_TYPED_PARAM_UINT},
|
2260
|
+
{VIR_NODE_MEMORY_SHARED_PAGES_SHARED, VIR_TYPED_PARAM_ULLONG},
|
2261
|
+
{VIR_NODE_MEMORY_SHARED_PAGES_SHARING, VIR_TYPED_PARAM_ULLONG},
|
2262
|
+
{VIR_NODE_MEMORY_SHARED_PAGES_UNSHARED, VIR_TYPED_PARAM_ULLONG},
|
2263
|
+
{VIR_NODE_MEMORY_SHARED_PAGES_VOLATILE, VIR_TYPED_PARAM_ULLONG},
|
2264
|
+
{VIR_NODE_MEMORY_SHARED_FULL_SCANS, VIR_TYPED_PARAM_ULLONG},
|
2265
|
+
#if HAVE_CONST_VIR_NODE_MEMORY_SHARED_MERGE_ACROSS_NODES
|
2266
|
+
{VIR_NODE_MEMORY_SHARED_MERGE_ACROSS_NODES, VIR_TYPED_PARAM_UINT},
|
2267
|
+
#endif
|
2268
|
+
};
|
2269
|
+
|
2270
|
+
/*
|
2271
|
+
* call-seq:
|
2272
|
+
* conn.node_memory_parameters = Hash,flags=0
|
2273
|
+
*
|
2274
|
+
* Call virNodeSetMemoryParameters[http://www.libvirt.org/html/libvirt-libvirt.html#virNodeSetMemoryParameters]
|
2275
|
+
* to set the memory parameters for this host node.
|
2276
|
+
*/
|
2277
|
+
static VALUE libvirt_connect_node_memory_parameters_equal(VALUE c, VALUE input)
|
2278
|
+
{
|
2279
|
+
VALUE hash, flags;
|
2280
|
+
|
2281
|
+
ruby_libvirt_assign_hash_and_flags(input, &hash, &flags);
|
2282
|
+
|
2283
|
+
return ruby_libvirt_set_typed_parameters(c, hash, NUM2UINT(flags), NULL,
|
2284
|
+
memory_allowed,
|
2285
|
+
ARRAY_SIZE(memory_allowed),
|
2286
|
+
node_memory_set);
|
2287
|
+
}
|
2288
|
+
#endif
|
2289
|
+
|
2290
|
+
#if HAVE_VIRNODEGETCPUMAP
|
2291
|
+
struct cpu_map_field_to_value {
|
2292
|
+
VALUE result;
|
2293
|
+
int cpu;
|
2294
|
+
int used;
|
2295
|
+
};
|
2296
|
+
|
2297
|
+
static VALUE cpu_map_field_to_value(VALUE input)
|
2298
|
+
{
|
2299
|
+
struct cpu_map_field_to_value *ftv = (struct cpu_map_field_to_value *)input;
|
2300
|
+
char cpuname[10];
|
2301
|
+
|
2302
|
+
snprintf(cpuname, sizeof(cpuname), "%d", ftv->cpu);
|
2303
|
+
rb_hash_aset(ftv->result, rb_str_new2(cpuname), ftv->used ? Qtrue : Qfalse);
|
2304
|
+
|
2305
|
+
return Qnil;
|
2306
|
+
}
|
2307
|
+
|
2308
|
+
/*
|
2309
|
+
* call-seq:
|
2310
|
+
* conn.node_cpu_map -> Hash
|
2311
|
+
*
|
2312
|
+
* Call virNodeGetCPUMap[http://www.libvirt.org/html/libvirt-libvirt.html#virNodeGetCPUMap]
|
2313
|
+
* to get a map of online host CPUs.
|
2314
|
+
*/
|
2315
|
+
static VALUE libvirt_connect_node_cpu_map(int argc, VALUE *argv, VALUE c)
|
2316
|
+
{
|
2317
|
+
VALUE flags, result;
|
2318
|
+
unsigned char *map;
|
2319
|
+
unsigned int online;
|
2320
|
+
int ret, i, exception = 0;
|
2321
|
+
struct cpu_map_field_to_value ftv;
|
2322
|
+
|
2323
|
+
rb_scan_args(argc, argv, "01", &flags);
|
2324
|
+
|
2325
|
+
ret = virNodeGetCPUMap(ruby_libvirt_connect_get(c), &map, &online,
|
2326
|
+
ruby_libvirt_value_to_uint(flags));
|
2327
|
+
ruby_libvirt_raise_error_if(ret < 0, e_RetrieveError, "virNodeGetCPUMap",
|
2328
|
+
ruby_libvirt_connect_get(c));
|
2329
|
+
|
2330
|
+
result = rb_hash_new();
|
2331
|
+
|
2332
|
+
for (i = 0; i < ret; i++) {
|
2333
|
+
ftv.result = result;
|
2334
|
+
ftv.cpu = i;
|
2335
|
+
ftv.used = VIR_CPU_USED(map, i);
|
2336
|
+
rb_protect(cpu_map_field_to_value, (VALUE)&ftv, &exception);
|
2337
|
+
if (exception) {
|
2338
|
+
free(map);
|
2339
|
+
rb_jump_tag(exception);
|
2340
|
+
}
|
2341
|
+
}
|
2342
|
+
|
2343
|
+
free(map);
|
2344
|
+
|
2345
|
+
return result;
|
2346
|
+
}
|
2347
|
+
#endif
|
2348
|
+
|
2349
|
+
#if HAVE_VIRCONNECTSETKEEPALIVE
|
2350
|
+
/*
|
2351
|
+
* call-seq:
|
2352
|
+
* conn.set_keepalive(interval, count) -> fixnum
|
2353
|
+
*
|
2354
|
+
* Call virConnectSetKeepAlive[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectSetKeepAlive]
|
2355
|
+
* to start sending keepalive messages. Deprecated; use conn.keepalive=
|
2356
|
+
* instead.
|
2357
|
+
*/
|
2358
|
+
static VALUE libvirt_connect_set_keepalive(VALUE c, VALUE interval, VALUE count)
|
2359
|
+
{
|
2360
|
+
ruby_libvirt_generate_call_int(virConnectSetKeepAlive,
|
2361
|
+
ruby_libvirt_connect_get(c),
|
2362
|
+
ruby_libvirt_connect_get(c),
|
2363
|
+
NUM2INT(interval), NUM2UINT(count));
|
2364
|
+
}
|
2365
|
+
|
2366
|
+
/*
|
2367
|
+
* call-seq:
|
2368
|
+
* conn.keepalive = interval,count
|
2369
|
+
*
|
2370
|
+
* Call virConnectSetKeepAlive[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectSetKeepAlive]
|
2371
|
+
* to start sending keepalive messages.
|
2372
|
+
*/
|
2373
|
+
static VALUE libvirt_connect_keepalive_equal(VALUE c, VALUE in)
|
2374
|
+
{
|
2375
|
+
VALUE interval, count;
|
2376
|
+
|
2377
|
+
Check_Type(in, T_ARRAY);
|
2378
|
+
|
2379
|
+
if (RARRAY_LEN(in) != 2) {
|
2380
|
+
rb_raise(rb_eArgError, "wrong number of arguments (%ld for 2)",
|
2381
|
+
RARRAY_LEN(in));
|
2382
|
+
}
|
2383
|
+
|
2384
|
+
interval = rb_ary_entry(in, 0);
|
2385
|
+
count = rb_ary_entry(in, 1);
|
2386
|
+
|
2387
|
+
ruby_libvirt_generate_call_int(virConnectSetKeepAlive,
|
2388
|
+
ruby_libvirt_connect_get(c),
|
2389
|
+
ruby_libvirt_connect_get(c),
|
2390
|
+
NUM2INT(interval), NUM2UINT(count));
|
2391
|
+
}
|
2392
|
+
#endif
|
2393
|
+
|
2394
|
+
#if HAVE_VIRCONNECTLISTALLDOMAINS
|
2395
|
+
/*
|
2396
|
+
* call-seq:
|
2397
|
+
* conn.list_all_domains(flags=0) -> array
|
2398
|
+
*
|
2399
|
+
* Call virConnectListAllDomains[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectListAllDomains]
|
2400
|
+
* to get an array of domain objects for all domains.
|
2401
|
+
*/
|
2402
|
+
static VALUE libvirt_connect_list_all_domains(int argc, VALUE *argv, VALUE c)
|
2403
|
+
{
|
2404
|
+
ruby_libvirt_generate_call_list_all(virDomainPtr, argc, argv,
|
2405
|
+
virConnectListAllDomains,
|
2406
|
+
ruby_libvirt_connect_get(c), c,
|
2407
|
+
ruby_libvirt_domain_new, virDomainFree);
|
2408
|
+
}
|
2409
|
+
#endif
|
2410
|
+
|
2411
|
+
#if HAVE_VIRCONNECTLISTALLNETWORKS
|
2412
|
+
/*
|
2413
|
+
* call-seq:
|
2414
|
+
* conn.list_all_networks(flags=0) -> array
|
2415
|
+
*
|
2416
|
+
* Call virConnectListAllNetworks[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectListAllNetworks]
|
2417
|
+
* to get an array of network objects for all networks.
|
2418
|
+
*/
|
2419
|
+
static VALUE libvirt_connect_list_all_networks(int argc, VALUE *argv, VALUE c)
|
2420
|
+
{
|
2421
|
+
ruby_libvirt_generate_call_list_all(virNetworkPtr, argc, argv,
|
2422
|
+
virConnectListAllNetworks,
|
2423
|
+
ruby_libvirt_connect_get(c), c,
|
2424
|
+
ruby_libvirt_network_new,
|
2425
|
+
virNetworkFree);
|
2426
|
+
}
|
2427
|
+
#endif
|
2428
|
+
|
2429
|
+
#if HAVE_VIRCONNECTLISTALLINTERFACES
|
2430
|
+
/*
|
2431
|
+
* call-seq:
|
2432
|
+
* conn.list_all_interfaces(flags=0) -> array
|
2433
|
+
*
|
2434
|
+
* Call virConnectListAllInterfaces[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectListAllInterfaces]
|
2435
|
+
* to get an array of interface objects for all interfaces.
|
2436
|
+
*/
|
2437
|
+
static VALUE libvirt_connect_list_all_interfaces(int argc, VALUE *argv, VALUE c)
|
2438
|
+
{
|
2439
|
+
ruby_libvirt_generate_call_list_all(virInterfacePtr, argc, argv,
|
2440
|
+
virConnectListAllInterfaces,
|
2441
|
+
ruby_libvirt_connect_get(c), c,
|
2442
|
+
ruby_libvirt_interface_new,
|
2443
|
+
virInterfaceFree);
|
2444
|
+
}
|
2445
|
+
#endif
|
2446
|
+
|
2447
|
+
#if HAVE_VIRCONNECTLISTALLSECRETS
|
2448
|
+
/*
|
2449
|
+
* call-seq:
|
2450
|
+
* conn.list_all_secrets(flags=0) -> array
|
2451
|
+
*
|
2452
|
+
* Call virConnectListAllSecrets[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectListAllSecrets]
|
2453
|
+
* to get an array of secret objects for all secrets.
|
2454
|
+
*/
|
2455
|
+
static VALUE libvirt_connect_list_all_secrets(int argc, VALUE *argv, VALUE c)
|
2456
|
+
{
|
2457
|
+
ruby_libvirt_generate_call_list_all(virSecretPtr, argc, argv,
|
2458
|
+
virConnectListAllSecrets,
|
2459
|
+
ruby_libvirt_connect_get(c), c,
|
2460
|
+
ruby_libvirt_secret_new, virSecretFree);
|
2461
|
+
}
|
2462
|
+
#endif
|
2463
|
+
|
2464
|
+
#if HAVE_VIRCONNECTLISTALLNODEDEVICES
|
2465
|
+
/*
|
2466
|
+
* call-seq:
|
2467
|
+
* conn.list_all_nodedevices(flags=0) -> array
|
2468
|
+
*
|
2469
|
+
* Call virConnectListAllNodeDevices[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectListAllNodeDevices]
|
2470
|
+
* to get an array of nodedevice objects for all nodedevices.
|
2471
|
+
*/
|
2472
|
+
static VALUE libvirt_connect_list_all_nodedevices(int argc, VALUE *argv,
|
2473
|
+
VALUE c)
|
2474
|
+
{
|
2475
|
+
ruby_libvirt_generate_call_list_all(virNodeDevicePtr, argc, argv,
|
2476
|
+
virConnectListAllNodeDevices,
|
2477
|
+
ruby_libvirt_connect_get(c), c,
|
2478
|
+
ruby_libvirt_nodedevice_new,
|
2479
|
+
virNodeDeviceFree);
|
2480
|
+
}
|
2481
|
+
#endif
|
2482
|
+
|
2483
|
+
#if HAVE_VIRCONNECTLISTALLSTORAGEPOOLS
|
2484
|
+
/*
|
2485
|
+
* call-seq:
|
2486
|
+
* conn.list_all_storage_pools(flags=0) -> array
|
2487
|
+
*
|
2488
|
+
* Call virConnectListAllStoragePools[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectListAllStoragePools]
|
2489
|
+
* to get an array of storage pool objects for all storage pools.
|
2490
|
+
*/
|
2491
|
+
static VALUE libvirt_connect_list_all_storage_pools(int argc, VALUE *argv,
|
2492
|
+
VALUE c)
|
2493
|
+
{
|
2494
|
+
ruby_libvirt_generate_call_list_all(virStoragePoolPtr, argc, argv,
|
2495
|
+
virConnectListAllStoragePools,
|
2496
|
+
ruby_libvirt_connect_get(c), c,
|
2497
|
+
pool_new, virStoragePoolFree);
|
2498
|
+
}
|
2499
|
+
#endif
|
2500
|
+
|
2501
|
+
#if HAVE_VIRCONNECTLISTALLNWFILTERS
|
2502
|
+
/*
|
2503
|
+
* call-seq:
|
2504
|
+
* conn.list_all_nwfilters(flags=0) -> array
|
2505
|
+
*
|
2506
|
+
* Call virConnectListAllNWFilters[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectListAllNWFilters]
|
2507
|
+
* to get an array of nwfilters for all nwfilter objects.
|
2508
|
+
*/
|
2509
|
+
static VALUE libvirt_connect_list_all_nwfilters(int argc, VALUE *argv, VALUE c)
|
2510
|
+
{
|
2511
|
+
ruby_libvirt_generate_call_list_all(virNWFilterPtr, argc, argv,
|
2512
|
+
virConnectListAllNWFilters,
|
2513
|
+
ruby_libvirt_connect_get(c), c,
|
2514
|
+
ruby_libvirt_nwfilter_new,
|
2515
|
+
virNWFilterFree);
|
2516
|
+
}
|
2517
|
+
#endif
|
2518
|
+
|
2519
|
+
#if HAVE_VIRCONNECTISALIVE
|
2520
|
+
/*
|
2521
|
+
* call-seq:
|
2522
|
+
* conn.alive? -> [True|False]
|
2523
|
+
*
|
2524
|
+
* Call virConnectIsAlive[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectIsAlive]
|
2525
|
+
* to determine if the connection is alive.
|
2526
|
+
*/
|
2527
|
+
static VALUE libvirt_connect_alive_p(VALUE c)
|
2528
|
+
{
|
2529
|
+
ruby_libvirt_generate_call_truefalse(virConnectIsAlive,
|
2530
|
+
ruby_libvirt_connect_get(c),
|
2531
|
+
ruby_libvirt_connect_get(c));
|
2532
|
+
}
|
2533
|
+
#endif
|
2534
|
+
|
2535
|
+
#if HAVE_VIRDOMAINCREATEXMLWITHFILES
|
2536
|
+
/*
|
2537
|
+
* call-seq:
|
2538
|
+
* conn.create_domain_xml_with_files(xml, fds=nil, flags=0) -> Libvirt::Domain
|
2539
|
+
*
|
2540
|
+
* Call virDomainCreateXMLWithFiles[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainCreateXMLWithFiles]
|
2541
|
+
* to launch a new guest domain with a set of open file descriptors.
|
2542
|
+
*/
|
2543
|
+
static VALUE libvirt_connect_create_domain_xml_with_files(int argc, VALUE *argv,
|
2544
|
+
VALUE c)
|
2545
|
+
{
|
2546
|
+
VALUE xml, fds, flags;
|
2547
|
+
int *files;
|
2548
|
+
unsigned int numfiles, i;
|
2549
|
+
virDomainPtr dom;
|
2550
|
+
|
2551
|
+
rb_scan_args(argc, argv, "12", &xml, &fds, &flags);
|
2552
|
+
|
2553
|
+
Check_Type(xml, T_STRING);
|
2554
|
+
|
2555
|
+
if (TYPE(fds) == T_NIL) {
|
2556
|
+
files = NULL;
|
2557
|
+
numfiles = 0;
|
2558
|
+
}
|
2559
|
+
else if (TYPE(fds) == T_ARRAY) {
|
2560
|
+
numfiles = RARRAY_LEN(fds);
|
2561
|
+
files = alloca(numfiles * sizeof(int));
|
2562
|
+
for (i = 0; i < numfiles; i++) {
|
2563
|
+
files[i] = NUM2INT(rb_ary_entry(fds, i));
|
2564
|
+
}
|
2565
|
+
}
|
2566
|
+
else {
|
2567
|
+
rb_raise(rb_eTypeError, "wrong argument type (expected Array)");
|
2568
|
+
}
|
2569
|
+
|
2570
|
+
dom = virDomainCreateXMLWithFiles(ruby_libvirt_connect_get(c),
|
2571
|
+
ruby_libvirt_get_cstring_or_null(xml),
|
2572
|
+
numfiles, files,
|
2573
|
+
ruby_libvirt_value_to_uint(flags));
|
2574
|
+
ruby_libvirt_raise_error_if(dom == NULL, e_Error,
|
2575
|
+
"virDomainCreateXMLWithFiles",
|
2576
|
+
ruby_libvirt_connect_get(c));
|
2577
|
+
|
2578
|
+
return ruby_libvirt_domain_new(dom, c);
|
2579
|
+
}
|
2580
|
+
#endif
|
2581
|
+
|
2582
|
+
#if HAVE_VIRDOMAINQEMUATTACH
|
2583
|
+
/*
|
2584
|
+
* call-seq:
|
2585
|
+
* conn.qemu_attach(pid, flags=0) -> Libvirt::Domain
|
2586
|
+
*
|
2587
|
+
* Call virDomainQemuAttach[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainQemuAttach]
|
2588
|
+
* to attach to the Qemu process pid.
|
2589
|
+
*/
|
2590
|
+
static VALUE libvirt_connect_qemu_attach(int argc, VALUE *argv, VALUE c)
|
2591
|
+
{
|
2592
|
+
VALUE pid, flags;
|
2593
|
+
virDomainPtr dom;
|
2594
|
+
|
2595
|
+
rb_scan_args(argc, argv, "11", &pid, &flags);
|
2596
|
+
|
2597
|
+
dom = virDomainQemuAttach(ruby_libvirt_connect_get(c), NUM2UINT(pid),
|
2598
|
+
ruby_libvirt_value_to_uint(flags));
|
2599
|
+
ruby_libvirt_raise_error_if(dom == NULL, e_Error, "virDomainQemuAttach",
|
2600
|
+
ruby_libvirt_connect_get(c));
|
2601
|
+
|
2602
|
+
return ruby_libvirt_domain_new(dom, c);
|
2603
|
+
}
|
2604
|
+
#endif
|
2605
|
+
|
2606
|
+
#if HAVE_VIRCONNECTGETCPUMODELNAMES
|
2607
|
+
struct model_name_args {
|
2608
|
+
VALUE result;
|
2609
|
+
int i;
|
2610
|
+
char *value;
|
2611
|
+
};
|
2612
|
+
|
2613
|
+
static VALUE model_name_wrap(VALUE arg)
|
2614
|
+
{
|
2615
|
+
struct model_name_args *e = (struct model_name_args *)arg;
|
2616
|
+
VALUE elem;
|
2617
|
+
|
2618
|
+
elem = rb_str_new2(e->value);
|
2619
|
+
|
2620
|
+
rb_ary_store(e->result, e->i, elem);
|
2621
|
+
|
2622
|
+
return Qnil;
|
2623
|
+
}
|
2624
|
+
|
2625
|
+
/*
|
2626
|
+
* call-seq:
|
2627
|
+
* conn.cpu_model_names(arch, flags=0) -> Array
|
2628
|
+
*
|
2629
|
+
* Call virConnectGetCPUModelNames[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectGetCPUModelNames]
|
2630
|
+
* to get an array of CPU model names.
|
2631
|
+
*/
|
2632
|
+
static VALUE libvirt_connect_cpu_model_names(int argc, VALUE *argv, VALUE c)
|
2633
|
+
{
|
2634
|
+
VALUE arch, flags, result;
|
2635
|
+
char **models;
|
2636
|
+
int i = 0, j, elems = 0;
|
2637
|
+
struct model_name_args args;
|
2638
|
+
int exception;
|
2639
|
+
|
2640
|
+
rb_scan_args(argc, argv, "11", &arch, &flags);
|
2641
|
+
|
2642
|
+
elems = virConnectGetCPUModelNames(ruby_libvirt_connect_get(c),
|
2643
|
+
StringValueCStr(arch), &models,
|
2644
|
+
ruby_libvirt_value_to_uint(flags));
|
2645
|
+
ruby_libvirt_raise_error_if(elems < 0, e_RetrieveError,
|
2646
|
+
"virConnectGetCPUModelNames",
|
2647
|
+
ruby_libvirt_connect_get(c));
|
2648
|
+
|
2649
|
+
result = rb_protect(ruby_libvirt_ary_new2_wrap, (VALUE)&elems, &exception);
|
2650
|
+
if (exception) {
|
2651
|
+
goto error;
|
2652
|
+
}
|
2653
|
+
|
2654
|
+
for (i = 0; i < elems; i++) {
|
2655
|
+
args.result = result;
|
2656
|
+
args.i = i;
|
2657
|
+
args.value = models[i];
|
2658
|
+
|
2659
|
+
rb_protect(model_name_wrap, (VALUE)&args, &exception);
|
2660
|
+
if (exception) {
|
2661
|
+
goto error;
|
2662
|
+
}
|
2663
|
+
free(models[i]);
|
2664
|
+
}
|
2665
|
+
free(models);
|
2666
|
+
|
2667
|
+
return result;
|
2668
|
+
|
2669
|
+
error:
|
2670
|
+
for (j = i; j < elems; j++) {
|
2671
|
+
free(models[j]);
|
2672
|
+
}
|
2673
|
+
free(models);
|
2674
|
+
|
2675
|
+
rb_jump_tag(exception);
|
2676
|
+
return Qnil;
|
2677
|
+
}
|
2678
|
+
#endif
|
2679
|
+
|
2680
|
+
/*
|
2681
|
+
* Class Libvirt::Connect
|
2682
|
+
*/
|
2683
|
+
void ruby_libvirt_connect_init(void)
|
2684
|
+
{
|
2685
|
+
c_connect = rb_define_class_under(m_libvirt, "Connect", rb_cObject);
|
2686
|
+
|
2687
|
+
/*
|
2688
|
+
* Class Libvirt::Connect::Nodeinfo
|
2689
|
+
*/
|
2690
|
+
c_node_info = rb_define_class_under(c_connect, "Nodeinfo", rb_cObject);
|
2691
|
+
rb_define_attr(c_node_info, "model", 1, 0);
|
2692
|
+
rb_define_attr(c_node_info, "memory", 1, 0);
|
2693
|
+
rb_define_attr(c_node_info, "cpus", 1, 0);
|
2694
|
+
rb_define_attr(c_node_info, "mhz", 1, 0);
|
2695
|
+
rb_define_attr(c_node_info, "nodes", 1, 0);
|
2696
|
+
rb_define_attr(c_node_info, "sockets", 1, 0);
|
2697
|
+
rb_define_attr(c_node_info, "cores", 1, 0);
|
2698
|
+
rb_define_attr(c_node_info, "threads", 1, 0);
|
2699
|
+
|
2700
|
+
/*
|
2701
|
+
* Class Libvirt::Connect::NodeSecurityModel
|
2702
|
+
*/
|
2703
|
+
c_node_security_model = rb_define_class_under(c_connect,
|
2704
|
+
"NodeSecurityModel",
|
2705
|
+
rb_cObject);
|
2706
|
+
rb_define_attr(c_node_security_model, "model", 1, 0);
|
2707
|
+
rb_define_attr(c_node_security_model, "doi", 1, 0);
|
2708
|
+
|
2709
|
+
rb_define_method(c_connect, "close", libvirt_connect_close, 0);
|
2710
|
+
rb_define_method(c_connect, "closed?", libvirt_connect_closed_p, 0);
|
2711
|
+
rb_define_method(c_connect, "type", libvirt_connect_type, 0);
|
2712
|
+
rb_define_method(c_connect, "version", libvirt_connect_version, 0);
|
2713
|
+
#if HAVE_VIRCONNECTGETLIBVERSION
|
2714
|
+
rb_define_method(c_connect, "libversion", libvirt_connect_libversion, 0);
|
2715
|
+
#endif
|
2716
|
+
rb_define_method(c_connect, "hostname", libvirt_connect_hostname, 0);
|
2717
|
+
rb_define_method(c_connect, "uri", libvirt_connect_uri, 0);
|
2718
|
+
rb_define_method(c_connect, "max_vcpus", libvirt_connect_max_vcpus, -1);
|
2719
|
+
rb_define_method(c_connect, "node_info", libvirt_connect_node_info, 0);
|
2720
|
+
rb_define_alias(c_connect, "node_get_info", "node_info");
|
2721
|
+
rb_define_method(c_connect, "node_free_memory",
|
2722
|
+
libvirt_connect_node_free_memory, 0);
|
2723
|
+
rb_define_method(c_connect, "node_cells_free_memory",
|
2724
|
+
libvirt_connect_node_cells_free_memory, -1);
|
2725
|
+
#if HAVE_VIRNODEGETSECURITYMODEL
|
2726
|
+
rb_define_method(c_connect, "node_security_model",
|
2727
|
+
libvirt_connect_node_security_model, 0);
|
2728
|
+
rb_define_alias(c_connect, "node_get_security_model",
|
2729
|
+
"node_security_model");
|
2730
|
+
#endif
|
2731
|
+
#if HAVE_VIRCONNECTISENCRYPTED
|
2732
|
+
rb_define_method(c_connect, "encrypted?", libvirt_connect_encrypted_p, 0);
|
2733
|
+
#endif
|
2734
|
+
#if HAVE_VIRCONNECTISSECURE
|
2735
|
+
rb_define_method(c_connect, "secure?", libvirt_connect_secure_p, 0);
|
2736
|
+
#endif
|
2737
|
+
rb_define_method(c_connect, "capabilities", libvirt_connect_capabilities,
|
2738
|
+
0);
|
1956
2739
|
|
1957
2740
|
#if HAVE_VIRCONNECTCOMPARECPU
|
1958
2741
|
rb_define_const(c_connect, "CPU_COMPARE_ERROR",
|
@@ -1964,11 +2747,16 @@ void init_connect()
|
|
1964
2747
|
rb_define_const(c_connect, "CPU_COMPARE_SUPERSET",
|
1965
2748
|
INT2NUM(VIR_CPU_COMPARE_SUPERSET));
|
1966
2749
|
|
1967
|
-
rb_define_method(c_connect, "compare_cpu",
|
2750
|
+
rb_define_method(c_connect, "compare_cpu", libvirt_connect_compare_cpu, -1);
|
1968
2751
|
#endif
|
1969
2752
|
|
1970
2753
|
#if HAVE_VIRCONNECTBASELINECPU
|
1971
|
-
rb_define_method(c_connect, "baseline_cpu",
|
2754
|
+
rb_define_method(c_connect, "baseline_cpu", libvirt_connect_baseline_cpu,
|
2755
|
+
-1);
|
2756
|
+
#endif
|
2757
|
+
#if HAVE_CONST_VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES
|
2758
|
+
rb_define_const(c_connect, "BASELINE_CPU_EXPAND_FEATURES",
|
2759
|
+
INT2NUM(VIR_CONNECT_BASELINE_CPU_EXPAND_FEATURES));
|
1972
2760
|
#endif
|
1973
2761
|
|
1974
2762
|
/* In the libvirt development history, the events were
|
@@ -2101,165 +2889,430 @@ void init_connect()
|
|
2101
2889
|
rb_define_const(c_connect, "DOMAIN_EVENT_ID_CONTROL_ERROR",
|
2102
2890
|
INT2NUM(VIR_DOMAIN_EVENT_ID_CONTROL_ERROR));
|
2103
2891
|
#endif
|
2892
|
+
#if HAVE_CONST_VIR_DOMAIN_EVENT_SHUTDOWN
|
2893
|
+
rb_define_const(c_connect, "DOMAIN_EVENT_SHUTDOWN",
|
2894
|
+
INT2NUM(VIR_DOMAIN_EVENT_SHUTDOWN));
|
2895
|
+
#endif
|
2896
|
+
#if HAVE_CONST_VIR_DOMAIN_EVENT_PMSUSPENDED
|
2897
|
+
rb_define_const(c_connect, "DOMAIN_EVENT_PMSUSPENDED",
|
2898
|
+
INT2NUM(VIR_DOMAIN_EVENT_PMSUSPENDED));
|
2899
|
+
#endif
|
2900
|
+
#if HAVE_CONST_VIR_DOMAIN_EVENT_CRASHED
|
2901
|
+
rb_define_const(c_connect, "DOMAIN_EVENT_CRASHED",
|
2902
|
+
INT2NUM(VIR_DOMAIN_EVENT_CRASHED));
|
2903
|
+
#endif
|
2904
|
+
#if HAVE_CONST_VIR_DOMAIN_EVENT_STARTED_WAKEUP
|
2905
|
+
rb_define_const(c_connect, "DOMAIN_EVENT_STARTED_WAKEUP",
|
2906
|
+
INT2NUM(VIR_DOMAIN_EVENT_STARTED_WAKEUP));
|
2907
|
+
#endif
|
2908
|
+
#if HAVE_CONST_VIR_DOMAIN_EVENT_SUSPENDED_RESTORED
|
2909
|
+
rb_define_const(c_connect, "DOMAIN_EVENT_SUSPENDED_RESTORED",
|
2910
|
+
INT2NUM(VIR_DOMAIN_EVENT_SUSPENDED_RESTORED));
|
2911
|
+
#endif
|
2912
|
+
#if HAVE_CONST_VIR_DOMAIN_EVENT_SUSPENDED_FROM_SNAPSHOT
|
2913
|
+
rb_define_const(c_connect, "DOMAIN_EVENT_SUSPENDED_FROM_SNAPSHOT",
|
2914
|
+
INT2NUM(VIR_DOMAIN_EVENT_SUSPENDED_FROM_SNAPSHOT));
|
2915
|
+
#endif
|
2916
|
+
#if HAVE_CONST_VIR_DOMAIN_EVENT_SUSPENDED_API_ERROR
|
2917
|
+
rb_define_const(c_connect, "DOMAIN_EVENT_SUSPENDED_API_ERROR",
|
2918
|
+
INT2NUM(VIR_DOMAIN_EVENT_SUSPENDED_API_ERROR));
|
2919
|
+
#endif
|
2920
|
+
#if HAVE_CONST_VIR_DOMAIN_EVENT_RESUMED_FROM_SNAPSHOT
|
2921
|
+
rb_define_const(c_connect, "DOMAIN_EVENT_RESUMED_FROM_SNAPSHOT",
|
2922
|
+
INT2NUM(VIR_DOMAIN_EVENT_RESUMED_FROM_SNAPSHOT));
|
2923
|
+
#endif
|
2924
|
+
#if HAVE_CONST_VIR_DOMAIN_EVENT_SHUTDOWN_FINISHED
|
2925
|
+
rb_define_const(c_connect, "DOMAIN_EVENT_SHUTDOWN_FINISHED",
|
2926
|
+
INT2NUM(VIR_DOMAIN_EVENT_SHUTDOWN_FINISHED));
|
2927
|
+
#endif
|
2928
|
+
#if HAVE_CONST_VIR_DOMAIN_EVENT_PMSUSPENDED_MEMORY
|
2929
|
+
rb_define_const(c_connect, "DOMAIN_EVENT_PMSUSPENDED_MEMORY",
|
2930
|
+
INT2NUM(VIR_DOMAIN_EVENT_PMSUSPENDED_MEMORY));
|
2931
|
+
#endif
|
2932
|
+
#if HAVE_CONST_VIR_DOMAIN_EVENT_PMSUSPENDED_DISK
|
2933
|
+
rb_define_const(c_connect, "DOMAIN_EVENT_PMSUSPENDED_DISK",
|
2934
|
+
INT2NUM(VIR_DOMAIN_EVENT_PMSUSPENDED_DISK));
|
2935
|
+
#endif
|
2936
|
+
#if HAVE_CONST_VIR_DOMAIN_EVENT_CRASHED_PANICKED
|
2937
|
+
rb_define_const(c_connect, "DOMAIN_EVENT_CRASHED_PANICKED",
|
2938
|
+
INT2NUM(VIR_DOMAIN_EVENT_CRASHED_PANICKED));
|
2939
|
+
#endif
|
2940
|
+
#if HAVE_CONST_VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_UNIX
|
2941
|
+
rb_define_const(c_connect, "DOMAIN_EVENT_GRAPHICS_ADDRESS_UNIX",
|
2942
|
+
INT2NUM(VIR_DOMAIN_EVENT_GRAPHICS_ADDRESS_UNIX));
|
2943
|
+
#endif
|
2104
2944
|
|
2105
2945
|
#if HAVE_VIRCONNECTDOMAINEVENTREGISTER
|
2106
2946
|
rb_define_method(c_connect, "domain_event_register",
|
2107
|
-
|
2947
|
+
libvirt_connect_domain_event_register, -1);
|
2108
2948
|
rb_define_method(c_connect, "domain_event_deregister",
|
2109
|
-
|
2949
|
+
libvirt_connect_domain_event_deregister, 0);
|
2110
2950
|
#endif
|
2111
2951
|
|
2112
2952
|
#if HAVE_VIRCONNECTDOMAINEVENTREGISTERANY
|
2113
2953
|
rb_define_method(c_connect, "domain_event_register_any",
|
2114
|
-
|
2954
|
+
libvirt_connect_domain_event_register_any, -1);
|
2115
2955
|
rb_define_method(c_connect, "domain_event_deregister_any",
|
2116
|
-
|
2956
|
+
libvirt_connect_domain_event_deregister_any, 1);
|
2117
2957
|
#endif
|
2118
2958
|
|
2119
2959
|
/* Domain creation/lookup */
|
2120
2960
|
rb_define_method(c_connect, "num_of_domains",
|
2121
|
-
|
2122
|
-
rb_define_method(c_connect, "list_domains",
|
2961
|
+
libvirt_connect_num_of_domains, 0);
|
2962
|
+
rb_define_method(c_connect, "list_domains", libvirt_connect_list_domains,
|
2963
|
+
0);
|
2123
2964
|
rb_define_method(c_connect, "num_of_defined_domains",
|
2124
|
-
|
2965
|
+
libvirt_connect_num_of_defined_domains, 0);
|
2125
2966
|
rb_define_method(c_connect, "list_defined_domains",
|
2126
|
-
|
2967
|
+
libvirt_connect_list_defined_domains, 0);
|
2127
2968
|
rb_define_method(c_connect, "create_domain_linux",
|
2128
|
-
|
2969
|
+
libvirt_connect_create_linux, -1);
|
2129
2970
|
#if HAVE_VIRDOMAINCREATEXML
|
2130
2971
|
rb_define_method(c_connect, "create_domain_xml",
|
2131
|
-
|
2972
|
+
libvirt_connect_create_domain_xml, -1);
|
2132
2973
|
#endif
|
2133
2974
|
rb_define_method(c_connect, "lookup_domain_by_name",
|
2134
|
-
|
2975
|
+
libvirt_connect_lookup_domain_by_name, 1);
|
2135
2976
|
rb_define_method(c_connect, "lookup_domain_by_id",
|
2136
|
-
|
2977
|
+
libvirt_connect_lookup_domain_by_id, 1);
|
2137
2978
|
rb_define_method(c_connect, "lookup_domain_by_uuid",
|
2138
|
-
|
2979
|
+
libvirt_connect_lookup_domain_by_uuid, 1);
|
2139
2980
|
rb_define_method(c_connect, "define_domain_xml",
|
2140
|
-
|
2981
|
+
libvirt_connect_define_domain_xml, 1);
|
2141
2982
|
|
2142
2983
|
#if HAVE_VIRCONNECTDOMAINXMLFROMNATIVE
|
2143
2984
|
rb_define_method(c_connect, "domain_xml_from_native",
|
2144
|
-
|
2985
|
+
libvirt_connect_domain_xml_from_native, -1);
|
2145
2986
|
#endif
|
2146
2987
|
#if HAVE_VIRCONNECTDOMAINXMLTONATIVE
|
2147
2988
|
rb_define_method(c_connect, "domain_xml_to_native",
|
2148
|
-
|
2989
|
+
libvirt_connect_domain_xml_to_native, -1);
|
2149
2990
|
#endif
|
2150
2991
|
|
2151
2992
|
#if HAVE_TYPE_VIRINTERFACEPTR
|
2152
2993
|
/* Interface lookup/creation methods */
|
2153
2994
|
rb_define_method(c_connect, "num_of_interfaces",
|
2154
|
-
|
2995
|
+
libvirt_connect_num_of_interfaces, 0);
|
2155
2996
|
rb_define_method(c_connect, "list_interfaces",
|
2156
|
-
|
2997
|
+
libvirt_connect_list_interfaces, 0);
|
2157
2998
|
rb_define_method(c_connect, "num_of_defined_interfaces",
|
2158
|
-
|
2999
|
+
libvirt_connect_num_of_defined_interfaces, 0);
|
2159
3000
|
rb_define_method(c_connect, "list_defined_interfaces",
|
2160
|
-
|
3001
|
+
libvirt_connect_list_defined_interfaces, 0);
|
2161
3002
|
rb_define_method(c_connect, "lookup_interface_by_name",
|
2162
|
-
|
3003
|
+
libvirt_connect_lookup_interface_by_name, 1);
|
2163
3004
|
rb_define_method(c_connect, "lookup_interface_by_mac",
|
2164
|
-
|
3005
|
+
libvirt_connect_lookup_interface_by_mac, 1);
|
2165
3006
|
rb_define_method(c_connect, "define_interface_xml",
|
2166
|
-
|
3007
|
+
libvirt_connect_define_interface_xml, -1);
|
2167
3008
|
#endif
|
2168
3009
|
|
2169
3010
|
/* Network lookup/creation methods */
|
2170
3011
|
rb_define_method(c_connect, "num_of_networks",
|
2171
|
-
|
2172
|
-
rb_define_method(c_connect, "list_networks",
|
3012
|
+
libvirt_connect_num_of_networks, 0);
|
3013
|
+
rb_define_method(c_connect, "list_networks", libvirt_connect_list_networks,
|
3014
|
+
0);
|
2173
3015
|
rb_define_method(c_connect, "num_of_defined_networks",
|
2174
|
-
|
3016
|
+
libvirt_connect_num_of_defined_networks, 0);
|
2175
3017
|
rb_define_method(c_connect, "list_defined_networks",
|
2176
|
-
|
3018
|
+
libvirt_connect_list_defined_networks, 0);
|
2177
3019
|
rb_define_method(c_connect, "lookup_network_by_name",
|
2178
|
-
|
3020
|
+
libvirt_connect_lookup_network_by_name, 1);
|
2179
3021
|
rb_define_method(c_connect, "lookup_network_by_uuid",
|
2180
|
-
|
3022
|
+
libvirt_connect_lookup_network_by_uuid, 1);
|
2181
3023
|
rb_define_method(c_connect, "create_network_xml",
|
2182
|
-
|
3024
|
+
libvirt_connect_create_network_xml, 1);
|
2183
3025
|
rb_define_method(c_connect, "define_network_xml",
|
2184
|
-
|
3026
|
+
libvirt_connect_define_network_xml, 1);
|
2185
3027
|
|
2186
3028
|
/* Node device lookup/creation methods */
|
2187
3029
|
#if HAVE_TYPE_VIRNODEDEVICEPTR
|
2188
3030
|
rb_define_method(c_connect, "num_of_nodedevices",
|
2189
|
-
|
3031
|
+
libvirt_connect_num_of_nodedevices, -1);
|
2190
3032
|
rb_define_method(c_connect, "list_nodedevices",
|
2191
|
-
|
3033
|
+
libvirt_connect_list_nodedevices, -1);
|
2192
3034
|
rb_define_method(c_connect, "lookup_nodedevice_by_name",
|
2193
|
-
|
3035
|
+
libvirt_connect_lookup_nodedevice_by_name, 1);
|
2194
3036
|
#if HAVE_VIRNODEDEVICECREATEXML
|
2195
3037
|
rb_define_method(c_connect, "create_nodedevice_xml",
|
2196
|
-
|
3038
|
+
libvirt_connect_create_nodedevice_xml, -1);
|
2197
3039
|
#endif
|
2198
3040
|
#endif
|
2199
3041
|
|
2200
3042
|
#if HAVE_TYPE_VIRNWFILTERPTR
|
2201
3043
|
/* NWFilter lookup/creation methods */
|
2202
3044
|
rb_define_method(c_connect, "num_of_nwfilters",
|
2203
|
-
|
3045
|
+
libvirt_connect_num_of_nwfilters, 0);
|
2204
3046
|
rb_define_method(c_connect, "list_nwfilters",
|
2205
|
-
|
3047
|
+
libvirt_connect_list_nwfilters, 0);
|
2206
3048
|
rb_define_method(c_connect, "lookup_nwfilter_by_name",
|
2207
|
-
|
3049
|
+
libvirt_connect_lookup_nwfilter_by_name, 1);
|
2208
3050
|
rb_define_method(c_connect, "lookup_nwfilter_by_uuid",
|
2209
|
-
|
3051
|
+
libvirt_connect_lookup_nwfilter_by_uuid, 1);
|
2210
3052
|
rb_define_method(c_connect, "define_nwfilter_xml",
|
2211
|
-
|
3053
|
+
libvirt_connect_define_nwfilter_xml, 1);
|
2212
3054
|
#endif
|
2213
3055
|
|
2214
3056
|
#if HAVE_TYPE_VIRSECRETPTR
|
2215
3057
|
/* Secret lookup/creation methods */
|
2216
3058
|
rb_define_method(c_connect, "num_of_secrets",
|
2217
|
-
|
3059
|
+
libvirt_connect_num_of_secrets, 0);
|
2218
3060
|
rb_define_method(c_connect, "list_secrets",
|
2219
|
-
|
3061
|
+
libvirt_connect_list_secrets, 0);
|
2220
3062
|
rb_define_method(c_connect, "lookup_secret_by_uuid",
|
2221
|
-
|
3063
|
+
libvirt_connect_lookup_secret_by_uuid, 1);
|
2222
3064
|
rb_define_method(c_connect, "lookup_secret_by_usage",
|
2223
|
-
|
3065
|
+
libvirt_connect_lookup_secret_by_usage, 2);
|
2224
3066
|
rb_define_method(c_connect, "define_secret_xml",
|
2225
|
-
|
3067
|
+
libvirt_connect_define_secret_xml, -1);
|
2226
3068
|
#endif
|
2227
3069
|
|
2228
3070
|
#if HAVE_TYPE_VIRSTORAGEPOOLPTR
|
2229
3071
|
/* StoragePool lookup/creation methods */
|
2230
3072
|
rb_define_method(c_connect, "num_of_storage_pools",
|
2231
|
-
|
3073
|
+
libvirt_connect_num_of_storage_pools, 0);
|
2232
3074
|
rb_define_method(c_connect, "list_storage_pools",
|
2233
|
-
|
3075
|
+
libvirt_connect_list_storage_pools, 0);
|
2234
3076
|
rb_define_method(c_connect, "num_of_defined_storage_pools",
|
2235
|
-
|
3077
|
+
libvirt_connect_num_of_defined_storage_pools, 0);
|
2236
3078
|
rb_define_method(c_connect, "list_defined_storage_pools",
|
2237
|
-
|
3079
|
+
libvirt_connect_list_defined_storage_pools, 0);
|
2238
3080
|
rb_define_method(c_connect, "lookup_storage_pool_by_name",
|
2239
|
-
|
3081
|
+
libvirt_connect_lookup_pool_by_name, 1);
|
2240
3082
|
rb_define_method(c_connect, "lookup_storage_pool_by_uuid",
|
2241
|
-
|
3083
|
+
libvirt_connect_lookup_pool_by_uuid, 1);
|
2242
3084
|
rb_define_method(c_connect, "create_storage_pool_xml",
|
2243
|
-
|
3085
|
+
libvirt_connect_create_pool_xml, -1);
|
2244
3086
|
rb_define_method(c_connect, "define_storage_pool_xml",
|
2245
|
-
|
3087
|
+
libvirt_connect_define_pool_xml, -1);
|
2246
3088
|
rb_define_method(c_connect, "discover_storage_pool_sources",
|
2247
|
-
|
3089
|
+
libvirt_connect_find_storage_pool_sources, -1);
|
2248
3090
|
#endif
|
2249
3091
|
|
2250
3092
|
#if HAVE_VIRCONNECTGETSYSINFO
|
2251
|
-
rb_define_method(c_connect, "sys_info",
|
3093
|
+
rb_define_method(c_connect, "sys_info", libvirt_connect_sys_info, -1);
|
2252
3094
|
#endif
|
2253
3095
|
#if HAVE_TYPE_VIRSTREAMPTR
|
2254
|
-
rb_define_method(c_connect, "stream",
|
3096
|
+
rb_define_method(c_connect, "stream", libvirt_connect_stream, -1);
|
2255
3097
|
#endif
|
2256
3098
|
|
2257
3099
|
#if HAVE_VIRINTERFACECHANGEBEGIN
|
2258
3100
|
rb_define_method(c_connect, "interface_change_begin",
|
2259
|
-
|
3101
|
+
libvirt_connect_interface_change_begin, -1);
|
2260
3102
|
rb_define_method(c_connect, "interface_change_commit",
|
2261
|
-
|
3103
|
+
libvirt_connect_interface_change_commit, -1);
|
2262
3104
|
rb_define_method(c_connect, "interface_change_rollback",
|
2263
|
-
|
3105
|
+
libvirt_connect_interface_change_rollback, -1);
|
3106
|
+
#endif
|
3107
|
+
|
3108
|
+
#if HAVE_VIRNODEGETCPUSTATS
|
3109
|
+
rb_define_method(c_connect, "node_cpu_stats",
|
3110
|
+
libvirt_connect_node_cpu_stats, -1);
|
3111
|
+
#endif
|
3112
|
+
#if HAVE_CONST_VIR_NODE_CPU_STATS_ALL_CPUS
|
3113
|
+
rb_define_const(c_connect, "NODE_CPU_STATS_ALL_CPUS",
|
3114
|
+
INT2NUM(VIR_NODE_CPU_STATS_ALL_CPUS));
|
3115
|
+
#endif
|
3116
|
+
#if HAVE_VIRNODEGETMEMORYSTATS
|
3117
|
+
rb_define_method(c_connect, "node_memory_stats",
|
3118
|
+
libvirt_connect_node_memory_stats, -1);
|
3119
|
+
#endif
|
3120
|
+
#if HAVE_CONST_VIR_NODE_MEMORY_STATS_ALL_CELLS
|
3121
|
+
rb_define_const(c_connect, "NODE_MEMORY_STATS_ALL_CELLS",
|
3122
|
+
INT2NUM(VIR_NODE_MEMORY_STATS_ALL_CELLS));
|
3123
|
+
#endif
|
3124
|
+
|
3125
|
+
#if HAVE_VIRDOMAINSAVEIMAGEGETXMLDESC
|
3126
|
+
rb_define_method(c_connect, "save_image_xml_desc",
|
3127
|
+
libvirt_connect_save_image_xml_desc, -1);
|
3128
|
+
rb_define_method(c_connect, "define_save_image_xml",
|
3129
|
+
libvirt_connect_define_save_image_xml, -1);
|
3130
|
+
#endif
|
3131
|
+
|
3132
|
+
#if HAVE_VIRNODESUSPENDFORDURATION
|
3133
|
+
rb_define_const(c_connect, "NODE_SUSPEND_TARGET_MEM",
|
3134
|
+
INT2NUM(VIR_NODE_SUSPEND_TARGET_MEM));
|
3135
|
+
rb_define_const(c_connect, "NODE_SUSPEND_TARGET_DISK",
|
3136
|
+
INT2NUM(VIR_NODE_SUSPEND_TARGET_DISK));
|
3137
|
+
rb_define_const(c_connect, "NODE_SUSPEND_TARGET_HYBRID",
|
3138
|
+
INT2NUM(VIR_NODE_SUSPEND_TARGET_HYBRID));
|
3139
|
+
|
3140
|
+
rb_define_method(c_connect, "node_suspend_for_duration",
|
3141
|
+
libvirt_connect_node_suspend_for_duration, -1);
|
3142
|
+
#endif
|
3143
|
+
|
3144
|
+
#if HAVE_VIRNODEGETMEMORYPARAMETERS
|
3145
|
+
rb_define_method(c_connect, "node_memory_parameters",
|
3146
|
+
libvirt_connect_node_memory_parameters, -1);
|
3147
|
+
rb_define_method(c_connect, "node_memory_parameters=",
|
3148
|
+
libvirt_connect_node_memory_parameters_equal, 1);
|
3149
|
+
#endif
|
3150
|
+
|
3151
|
+
#if HAVE_VIRNODEGETCPUMAP
|
3152
|
+
rb_define_method(c_connect, "node_cpu_map",
|
3153
|
+
libvirt_connect_node_cpu_map, -1);
|
3154
|
+
rb_define_alias(c_connect, "node_get_cpu_map", "node_cpu_map");
|
3155
|
+
#endif
|
3156
|
+
|
3157
|
+
#if HAVE_VIRCONNECTSETKEEPALIVE
|
3158
|
+
rb_define_method(c_connect, "set_keepalive",
|
3159
|
+
libvirt_connect_set_keepalive, 2);
|
3160
|
+
rb_define_method(c_connect, "keepalive=", libvirt_connect_keepalive_equal,
|
3161
|
+
1);
|
3162
|
+
#endif
|
3163
|
+
|
3164
|
+
#if HAVE_VIRCONNECTLISTALLDOMAINS
|
3165
|
+
rb_define_const(c_connect, "LIST_DOMAINS_ACTIVE",
|
3166
|
+
INT2NUM(VIR_CONNECT_LIST_DOMAINS_ACTIVE));
|
3167
|
+
rb_define_const(c_connect, "LIST_DOMAINS_INACTIVE",
|
3168
|
+
INT2NUM(VIR_CONNECT_LIST_DOMAINS_INACTIVE));
|
3169
|
+
rb_define_const(c_connect, "LIST_DOMAINS_PERSISTENT",
|
3170
|
+
INT2NUM(VIR_CONNECT_LIST_DOMAINS_PERSISTENT));
|
3171
|
+
rb_define_const(c_connect, "LIST_DOMAINS_TRANSIENT",
|
3172
|
+
INT2NUM(VIR_CONNECT_LIST_DOMAINS_TRANSIENT));
|
3173
|
+
rb_define_const(c_connect, "LIST_DOMAINS_RUNNING",
|
3174
|
+
INT2NUM(VIR_CONNECT_LIST_DOMAINS_RUNNING));
|
3175
|
+
rb_define_const(c_connect, "LIST_DOMAINS_PAUSED",
|
3176
|
+
INT2NUM(VIR_CONNECT_LIST_DOMAINS_PAUSED));
|
3177
|
+
rb_define_const(c_connect, "LIST_DOMAINS_SHUTOFF",
|
3178
|
+
INT2NUM(VIR_CONNECT_LIST_DOMAINS_SHUTOFF));
|
3179
|
+
rb_define_const(c_connect, "LIST_DOMAINS_OTHER",
|
3180
|
+
INT2NUM(VIR_CONNECT_LIST_DOMAINS_OTHER));
|
3181
|
+
rb_define_const(c_connect, "LIST_DOMAINS_MANAGEDSAVE",
|
3182
|
+
INT2NUM(VIR_CONNECT_LIST_DOMAINS_MANAGEDSAVE));
|
3183
|
+
rb_define_const(c_connect, "LIST_DOMAINS_NO_MANAGEDSAVE",
|
3184
|
+
INT2NUM(VIR_CONNECT_LIST_DOMAINS_NO_MANAGEDSAVE));
|
3185
|
+
rb_define_const(c_connect, "LIST_DOMAINS_AUTOSTART",
|
3186
|
+
INT2NUM(VIR_CONNECT_LIST_DOMAINS_AUTOSTART));
|
3187
|
+
rb_define_const(c_connect, "LIST_DOMAINS_NO_AUTOSTART",
|
3188
|
+
INT2NUM(VIR_CONNECT_LIST_DOMAINS_NO_AUTOSTART));
|
3189
|
+
rb_define_const(c_connect, "LIST_DOMAINS_HAS_SNAPSHOT",
|
3190
|
+
INT2NUM(VIR_CONNECT_LIST_DOMAINS_HAS_SNAPSHOT));
|
3191
|
+
rb_define_const(c_connect, "LIST_DOMAINS_NO_SNAPSHOT",
|
3192
|
+
INT2NUM(VIR_CONNECT_LIST_DOMAINS_NO_SNAPSHOT));
|
3193
|
+
rb_define_method(c_connect, "list_all_domains",
|
3194
|
+
libvirt_connect_list_all_domains, -1);
|
3195
|
+
#endif
|
3196
|
+
#if HAVE_VIRCONNECTLISTALLNETWORKS
|
3197
|
+
rb_define_const(c_connect, "LIST_NETWORKS_ACTIVE",
|
3198
|
+
INT2NUM(VIR_CONNECT_LIST_NETWORKS_ACTIVE));
|
3199
|
+
rb_define_const(c_connect, "LIST_NETWORKS_INACTIVE",
|
3200
|
+
INT2NUM(VIR_CONNECT_LIST_NETWORKS_INACTIVE));
|
3201
|
+
rb_define_const(c_connect, "LIST_NETWORKS_PERSISTENT",
|
3202
|
+
INT2NUM(VIR_CONNECT_LIST_NETWORKS_PERSISTENT));
|
3203
|
+
rb_define_const(c_connect, "LIST_NETWORKS_TRANSIENT",
|
3204
|
+
INT2NUM(VIR_CONNECT_LIST_NETWORKS_TRANSIENT));
|
3205
|
+
rb_define_const(c_connect, "LIST_NETWORKS_AUTOSTART",
|
3206
|
+
INT2NUM(VIR_CONNECT_LIST_NETWORKS_AUTOSTART));
|
3207
|
+
rb_define_const(c_connect, "LIST_NETWORKS_NO_AUTOSTART",
|
3208
|
+
INT2NUM(VIR_CONNECT_LIST_NETWORKS_NO_AUTOSTART));
|
3209
|
+
rb_define_method(c_connect, "list_all_networks",
|
3210
|
+
libvirt_connect_list_all_networks, -1);
|
3211
|
+
#endif
|
3212
|
+
#if HAVE_VIRCONNECTLISTALLINTERFACES
|
3213
|
+
rb_define_const(c_connect, "LIST_INTERFACES_INACTIVE",
|
3214
|
+
INT2NUM(VIR_CONNECT_LIST_INTERFACES_INACTIVE));
|
3215
|
+
rb_define_const(c_connect, "LIST_INTERFACES_ACTIVE",
|
3216
|
+
INT2NUM(VIR_CONNECT_LIST_INTERFACES_ACTIVE));
|
3217
|
+
rb_define_method(c_connect, "list_all_interfaces",
|
3218
|
+
libvirt_connect_list_all_interfaces, -1);
|
3219
|
+
#endif
|
3220
|
+
#if HAVE_VIRCONNECTLISTALLSECRETS
|
3221
|
+
rb_define_const(c_connect, "LIST_SECRETS_EPHEMERAL",
|
3222
|
+
INT2NUM(VIR_CONNECT_LIST_SECRETS_EPHEMERAL));
|
3223
|
+
rb_define_const(c_connect, "LIST_SECRETS_NO_EPHEMERAL",
|
3224
|
+
INT2NUM(VIR_CONNECT_LIST_SECRETS_NO_EPHEMERAL));
|
3225
|
+
rb_define_const(c_connect, "LIST_SECRETS_PRIVATE",
|
3226
|
+
INT2NUM(VIR_CONNECT_LIST_SECRETS_PRIVATE));
|
3227
|
+
rb_define_const(c_connect, "LIST_SECRETS_NO_PRIVATE",
|
3228
|
+
INT2NUM(VIR_CONNECT_LIST_SECRETS_NO_PRIVATE));
|
3229
|
+
rb_define_method(c_connect, "list_all_secrets",
|
3230
|
+
libvirt_connect_list_all_secrets, -1);
|
3231
|
+
#endif
|
3232
|
+
#if HAVE_VIRCONNECTLISTALLNODEDEVICES
|
3233
|
+
rb_define_const(c_connect, "LIST_NODE_DEVICES_CAP_SYSTEM",
|
3234
|
+
INT2NUM(VIR_CONNECT_LIST_NODE_DEVICES_CAP_SYSTEM));
|
3235
|
+
rb_define_const(c_connect, "LIST_NODE_DEVICES_CAP_PCI_DEV",
|
3236
|
+
INT2NUM(VIR_CONNECT_LIST_NODE_DEVICES_CAP_PCI_DEV));
|
3237
|
+
rb_define_const(c_connect, "LIST_NODE_DEVICES_CAP_USB_DEV",
|
3238
|
+
INT2NUM(VIR_CONNECT_LIST_NODE_DEVICES_CAP_USB_DEV));
|
3239
|
+
rb_define_const(c_connect, "LIST_NODE_DEVICES_CAP_USB_INTERFACE",
|
3240
|
+
INT2NUM(VIR_CONNECT_LIST_NODE_DEVICES_CAP_USB_INTERFACE));
|
3241
|
+
rb_define_const(c_connect, "LIST_NODE_DEVICES_CAP_NET",
|
3242
|
+
INT2NUM(VIR_CONNECT_LIST_NODE_DEVICES_CAP_NET));
|
3243
|
+
rb_define_const(c_connect, "LIST_NODE_DEVICES_CAP_SCSI_HOST",
|
3244
|
+
INT2NUM(VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI_HOST));
|
3245
|
+
rb_define_const(c_connect, "LIST_NODE_DEVICES_CAP_SCSI_TARGET",
|
3246
|
+
INT2NUM(VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI_TARGET));
|
3247
|
+
rb_define_const(c_connect, "LIST_NODE_DEVICES_CAP_SCSI",
|
3248
|
+
INT2NUM(VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI));
|
3249
|
+
rb_define_const(c_connect, "LIST_NODE_DEVICES_CAP_STORAGE",
|
3250
|
+
INT2NUM(VIR_CONNECT_LIST_NODE_DEVICES_CAP_STORAGE));
|
3251
|
+
#if HAVE_CONST_VIR_CONNECT_LIST_NODE_DEVICES_CAP_FC_HOST
|
3252
|
+
rb_define_const(c_connect, "LIST_NODE_DEVICES_CAP_FC_HOST",
|
3253
|
+
INT2NUM(VIR_CONNECT_LIST_NODE_DEVICES_CAP_FC_HOST));
|
3254
|
+
rb_define_const(c_connect, "LIST_NODE_DEVICES_CAP_VPORTS",
|
3255
|
+
INT2NUM(VIR_CONNECT_LIST_NODE_DEVICES_CAP_VPORTS));
|
3256
|
+
#endif
|
3257
|
+
#if HAVE_CONST_VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI_GENERIC
|
3258
|
+
rb_define_const(c_connect, "LIST_NODE_DEVICES_CAP_SCSI_GENERIC",
|
3259
|
+
INT2NUM(VIR_CONNECT_LIST_NODE_DEVICES_CAP_SCSI_GENERIC));
|
3260
|
+
#endif
|
3261
|
+
rb_define_method(c_connect, "list_all_nodedevices",
|
3262
|
+
libvirt_connect_list_all_nodedevices, -1);
|
3263
|
+
#endif
|
3264
|
+
#if HAVE_VIRCONNECTLISTALLSTORAGEPOOLS
|
3265
|
+
rb_define_const(c_connect, "LIST_STORAGE_POOLS_INACTIVE",
|
3266
|
+
INT2NUM(VIR_CONNECT_LIST_STORAGE_POOLS_INACTIVE));
|
3267
|
+
rb_define_const(c_connect, "LIST_STORAGE_POOLS_ACTIVE",
|
3268
|
+
INT2NUM(VIR_CONNECT_LIST_STORAGE_POOLS_ACTIVE));
|
3269
|
+
rb_define_const(c_connect, "LIST_STORAGE_POOLS_PERSISTENT",
|
3270
|
+
INT2NUM(VIR_CONNECT_LIST_STORAGE_POOLS_PERSISTENT));
|
3271
|
+
rb_define_const(c_connect, "LIST_STORAGE_POOLS_TRANSIENT",
|
3272
|
+
INT2NUM(VIR_CONNECT_LIST_STORAGE_POOLS_TRANSIENT));
|
3273
|
+
rb_define_const(c_connect, "LIST_STORAGE_POOLS_AUTOSTART",
|
3274
|
+
INT2NUM(VIR_CONNECT_LIST_STORAGE_POOLS_AUTOSTART));
|
3275
|
+
rb_define_const(c_connect, "LIST_STORAGE_POOLS_NO_AUTOSTART",
|
3276
|
+
INT2NUM(VIR_CONNECT_LIST_STORAGE_POOLS_NO_AUTOSTART));
|
3277
|
+
rb_define_const(c_connect, "LIST_STORAGE_POOLS_DIR",
|
3278
|
+
INT2NUM(VIR_CONNECT_LIST_STORAGE_POOLS_DIR));
|
3279
|
+
rb_define_const(c_connect, "LIST_STORAGE_POOLS_FS",
|
3280
|
+
INT2NUM(VIR_CONNECT_LIST_STORAGE_POOLS_FS));
|
3281
|
+
rb_define_const(c_connect, "LIST_STORAGE_POOLS_NETFS",
|
3282
|
+
INT2NUM(VIR_CONNECT_LIST_STORAGE_POOLS_NETFS));
|
3283
|
+
rb_define_const(c_connect, "LIST_STORAGE_POOLS_LOGICAL",
|
3284
|
+
INT2NUM(VIR_CONNECT_LIST_STORAGE_POOLS_LOGICAL));
|
3285
|
+
rb_define_const(c_connect, "LIST_STORAGE_POOLS_DISK",
|
3286
|
+
INT2NUM(VIR_CONNECT_LIST_STORAGE_POOLS_DISK));
|
3287
|
+
rb_define_const(c_connect, "LIST_STORAGE_POOLS_ISCSI",
|
3288
|
+
INT2NUM(VIR_CONNECT_LIST_STORAGE_POOLS_ISCSI));
|
3289
|
+
rb_define_const(c_connect, "LIST_STORAGE_POOLS_SCSI",
|
3290
|
+
INT2NUM(VIR_CONNECT_LIST_STORAGE_POOLS_SCSI));
|
3291
|
+
rb_define_const(c_connect, "LIST_STORAGE_POOLS_MPATH",
|
3292
|
+
INT2NUM(VIR_CONNECT_LIST_STORAGE_POOLS_MPATH));
|
3293
|
+
rb_define_const(c_connect, "LIST_STORAGE_POOLS_RBD",
|
3294
|
+
INT2NUM(VIR_CONNECT_LIST_STORAGE_POOLS_RBD));
|
3295
|
+
rb_define_const(c_connect, "LIST_STORAGE_POOLS_SHEEPDOG",
|
3296
|
+
INT2NUM(VIR_CONNECT_LIST_STORAGE_POOLS_SHEEPDOG));
|
3297
|
+
rb_define_method(c_connect, "list_all_storage_pools",
|
3298
|
+
libvirt_connect_list_all_storage_pools, -1);
|
3299
|
+
#endif
|
3300
|
+
#if HAVE_VIRCONNECTLISTALLNWFILTERS
|
3301
|
+
rb_define_method(c_connect, "list_all_nwfilters",
|
3302
|
+
libvirt_connect_list_all_nwfilters, -1);
|
3303
|
+
#endif
|
3304
|
+
#if HAVE_VIRCONNECTISALIVE
|
3305
|
+
rb_define_method(c_connect, "alive?", libvirt_connect_alive_p, 0);
|
3306
|
+
#endif
|
3307
|
+
#if HAVE_VIRDOMAINCREATEXMLWITHFILES
|
3308
|
+
rb_define_method(c_connect, "create_domain_xml_with_files",
|
3309
|
+
libvirt_connect_create_domain_xml_with_files, -1);
|
3310
|
+
#endif
|
3311
|
+
#if HAVE_VIRDOMAINQEMUATTACH
|
3312
|
+
rb_define_method(c_connect, "qemu_attach", libvirt_connect_qemu_attach, -1);
|
3313
|
+
#endif
|
3314
|
+
#if HAVE_VIRCONNECTGETCPUMODELNAMES
|
3315
|
+
rb_define_method(c_connect, "cpu_model_names",
|
3316
|
+
libvirt_connect_cpu_model_names, -1);
|
2264
3317
|
#endif
|
2265
3318
|
}
|