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