ruby-libvirt 0.5.2 → 0.8.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/COPYING +1 -1
- data/NEWS +38 -2
- data/Rakefile +3 -4
- data/ext/libvirt/_libvirt.c +8 -8
- data/ext/libvirt/common.c +27 -13
- data/ext/libvirt/common.h +12 -2
- data/ext/libvirt/connect.c +336 -159
- data/ext/libvirt/domain.c +571 -185
- data/ext/libvirt/extconf.h +393 -0
- data/ext/libvirt/extconf.rb +53 -44
- data/ext/libvirt/interface.c +15 -15
- data/ext/libvirt/network.c +120 -19
- data/ext/libvirt/nodedevice.c +19 -19
- data/ext/libvirt/nwfilter.c +10 -10
- data/ext/libvirt/secret.c +18 -18
- data/ext/libvirt/storage.c +90 -62
- data/ext/libvirt/stream.c +15 -15
- data/tests/test_conn.rb +13 -15
- data/tests/test_domain.rb +18 -13
- data/tests/test_interface.rb +4 -4
- data/tests/test_network.rb +1 -1
- data/tests/test_nwfilter.rb +1 -1
- data/tests/test_storage.rb +5 -5
- data/tests/test_stream.rb +1 -1
- data/tests/test_utils.rb +29 -10
- metadata +14 -14
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: ca7edd355f3679b48ebacb442e8d9c3d77af72a88681064e06a247ceabd4e391
|
4
|
+
data.tar.gz: dd4253fb78b7e584396aec931be145bc236db2e86a56eb275fe7c5675e7cd3f1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bf2f9cb3c62d5fb51e919eac7513603bbae31b23b7c712238fc98064c11563451963f5d6bdaa8e6c25f9680bdec14dcc651184d52001cb3d6c24a56134d7535f
|
7
|
+
data.tar.gz: 5561b660c8ec0ce8d61c363a6f1c467c3563277c55998661b75e24936fb6c11708e774a1aab859bfe48fc4f54c1864c371f620cb54bfabe9c9a2ae55d8d33c47
|
data/COPYING
CHANGED
@@ -3,7 +3,7 @@
|
|
3
3
|
Version 2.1, February 1999
|
4
4
|
|
5
5
|
Copyright (C) 1991, 1999 Free Software Foundation, Inc.
|
6
|
-
|
6
|
+
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
7
7
|
Everyone is permitted to copy and distribute verbatim copies
|
8
8
|
of this license document, but changing it is not allowed.
|
9
9
|
|
data/NEWS
CHANGED
@@ -1,7 +1,43 @@
|
|
1
|
-
|
1
|
+
2021-11-15 0.8.0
|
2
|
+
* Fix default values for node_cpu_stats and node_memory_stats
|
3
|
+
* Fix cpumap allocation for virDomainGetVcpus
|
4
|
+
* Enforce UTF8 for strings and exceptions
|
5
|
+
* Drop local have_const
|
6
|
+
* Use sensible default for libvirt_domain_qemu_agent_command
|
7
|
+
|
8
|
+
2018-02-18 0.7.1
|
9
|
+
* Fix a bad bug in block_resize (Marius Rieder)
|
10
|
+
* Fix up some problems pointed out by clang
|
11
|
+
* Fix up the tests for small semantic differences in how libvirt works
|
12
|
+
|
13
|
+
2016-09-22 0.7.0
|
14
|
+
* Fix network lease API to allow arguments that libvirt allows
|
15
|
+
* Implement VIRT_STORAGE_POOL_CREATE flags
|
16
|
+
* Implement more VIR_STORAGE_VOL flags
|
17
|
+
* Implement VIR_DOMAIN_QEMU_AGENT_COMMAND_SHUTDOWN
|
18
|
+
* Implement virDomainDefineXMLFlags
|
19
|
+
* Implement virDomainRename
|
20
|
+
* Implement virDomainSetUserPassword
|
21
|
+
* Implement VIR_DOMAIN_TIME_SYNC
|
22
|
+
* Fix the return value from virStreamSourceFunc so volume upload works
|
23
|
+
|
24
|
+
2015-11-20 0.6.0
|
25
|
+
* Fix possible buffer overflow
|
26
|
+
* Fix storage volume creation error messages
|
27
|
+
* Add additional storage pool defines
|
28
|
+
* Implement Network dhcp_leases method
|
29
|
+
* Implement Connect node_alloc_pages method
|
30
|
+
* Implement Domain time method
|
31
|
+
* Implement Connect domain_capabilities method
|
32
|
+
* Implement Domain core_dump_with_format method
|
33
|
+
* Implement Domain fs_freeze method
|
34
|
+
* Implement Domain fs_info method
|
35
|
+
* Implement Connect node_free_pages method
|
36
|
+
|
37
|
+
2014-01-08 0.5.2
|
2
38
|
* Fix to make sure we don't free more entires than retrieved
|
3
39
|
|
4
|
-
2013-12-15
|
40
|
+
2013-12-15 0.5.1
|
5
41
|
* Fixes to compile against older libvirt
|
6
42
|
* Fixes to compile against ruby 1.8
|
7
43
|
|
data/Rakefile
CHANGED
@@ -21,7 +21,7 @@ require 'rubygems/package_task'
|
|
21
21
|
require 'rbconfig'
|
22
22
|
|
23
23
|
PKG_NAME='ruby-libvirt'
|
24
|
-
PKG_VERSION='0.
|
24
|
+
PKG_VERSION='0.8.0'
|
25
25
|
|
26
26
|
EXT_CONF='ext/libvirt/extconf.rb'
|
27
27
|
MAKEFILE="ext/libvirt/Makefile"
|
@@ -37,8 +37,7 @@ LIBVIRT_SRC << MAKEFILE
|
|
37
37
|
CLEAN.include [ "ext/**/*.o", LIBVIRT_MODULE, "ext/**/depend", "ext/**/*.gcda",
|
38
38
|
"ext/**/*.gcno", "ext/**/*.gcov" ]
|
39
39
|
|
40
|
-
CLOBBER.include [ "
|
41
|
-
MAKEFILE ]
|
40
|
+
CLOBBER.include [ "ext/**/mkmf.log", "ext/**/extconf.h", MAKEFILE ]
|
42
41
|
|
43
42
|
task :default => :build
|
44
43
|
|
@@ -146,7 +145,7 @@ SPEC = Gem::Specification.new do |s|
|
|
146
145
|
s.author = "David Lutterkort, Chris Lalancette"
|
147
146
|
s.rubyforge_project = "None"
|
148
147
|
s.description = "Ruby bindings for libvirt."
|
149
|
-
s.license = "
|
148
|
+
s.license = "LGPL-2.1-or-later"
|
150
149
|
end
|
151
150
|
|
152
151
|
Gem::PackageTask.new(SPEC) do |pkg|
|
data/ext/libvirt/_libvirt.c
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
* libvirt.c: Ruby bindings for libvirt
|
3
3
|
*
|
4
4
|
* Copyright (C) 2007,2010 Red Hat Inc.
|
5
|
-
* Copyright (C) 2013 Chris Lalancette <clalancette@gmail.com>
|
5
|
+
* Copyright (C) 2013-2016 Chris Lalancette <clalancette@gmail.com>
|
6
6
|
*
|
7
7
|
* This library is free software; you can redistribute it and/or
|
8
8
|
* modify it under the terms of the GNU Lesser General Public
|
@@ -60,7 +60,7 @@ static void rubyLibvirtErrorFunc(void *RUBY_LIBVIRT_UNUSED(userdata),
|
|
60
60
|
* call-seq:
|
61
61
|
* Libvirt::version(type=nil) -> [ libvirt_version, type_version ]
|
62
62
|
*
|
63
|
-
* Call virGetVersion[http://www.libvirt.org/html/libvirt-libvirt.html#virGetVersion]
|
63
|
+
* Call virGetVersion[http://www.libvirt.org/html/libvirt-libvirt-host.html#virGetVersion]
|
64
64
|
* to get the version of libvirt and of the hypervisor TYPE.
|
65
65
|
*/
|
66
66
|
static VALUE libvirt_version(int argc, VALUE *argv,
|
@@ -90,7 +90,7 @@ static VALUE libvirt_version(int argc, VALUE *argv,
|
|
90
90
|
* call-seq:
|
91
91
|
* Libvirt::open(uri=nil) -> Libvirt::Connect
|
92
92
|
*
|
93
|
-
* Call virConnectOpen[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectOpen]
|
93
|
+
* Call virConnectOpen[http://www.libvirt.org/html/libvirt-libvirt-host.html#virConnectOpen]
|
94
94
|
* to open a connection to a URL.
|
95
95
|
*/
|
96
96
|
static VALUE libvirt_open(int argc, VALUE *argv, VALUE RUBY_LIBVIRT_UNUSED(m))
|
@@ -111,7 +111,7 @@ static VALUE libvirt_open(int argc, VALUE *argv, VALUE RUBY_LIBVIRT_UNUSED(m))
|
|
111
111
|
* call-seq:
|
112
112
|
* Libvirt::open_read_only(uri=nil) -> Libvirt::Connect
|
113
113
|
*
|
114
|
-
* Call virConnectOpenReadOnly[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectOpenReadOnly]
|
114
|
+
* Call virConnectOpenReadOnly[http://www.libvirt.org/html/libvirt-libvirt-host.html#virConnectOpenReadOnly]
|
115
115
|
* to open a read-only connection to a URL.
|
116
116
|
*/
|
117
117
|
static VALUE libvirt_open_read_only(int argc, VALUE *argv,
|
@@ -184,7 +184,7 @@ static int libvirt_auth_callback_wrapper(virConnectCredentialPtr cred,
|
|
184
184
|
* call-seq:
|
185
185
|
* Libvirt::open_auth(uri=nil, credlist=nil, userdata=nil, flags=0) {|...| authentication block} -> Libvirt::Connect
|
186
186
|
*
|
187
|
-
* Call virConnectOpenAuth[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectOpenAuth]
|
187
|
+
* Call virConnectOpenAuth[http://www.libvirt.org/html/libvirt-libvirt-host.html#virConnectOpenAuth]
|
188
188
|
* to open a connection to a libvirt URI, with a possible authentication block.
|
189
189
|
* If an authentication block is desired, then credlist should be an array that
|
190
190
|
* specifies which credentials the authentication block is willing to support;
|
@@ -575,7 +575,7 @@ static int is_symbol_proc_or_nil(VALUE handle)
|
|
575
575
|
* call-seq:
|
576
576
|
* Libvirt::event_register_impl(add_handle=nil, update_handle=nil, remove_handle=nil, add_timeout=nil, update_timeout=nil, remove_timeout=nil) -> Qnil
|
577
577
|
*
|
578
|
-
* Call virEventRegisterImpl[http://www.libvirt.org/html/libvirt-libvirt.html#virEventRegisterImpl]
|
578
|
+
* Call virEventRegisterImpl[http://www.libvirt.org/html/libvirt-libvirt-event.html#virEventRegisterImpl]
|
579
579
|
* to register callback handlers for handles and timeouts. These handles and
|
580
580
|
* timeouts are used as part of the libvirt infrastructure for generating
|
581
581
|
* domain events. Each callback must be a Symbol (that is the name of a
|
@@ -652,7 +652,7 @@ static VALUE libvirt_conn_event_register_impl(int argc, VALUE *argv,
|
|
652
652
|
* call-seq:
|
653
653
|
* Libvirt::lxc_enter_security_label(model, label, flags=0) -> Libvirt::Domain::SecurityLabel
|
654
654
|
*
|
655
|
-
* Call virDomainLxcEnterSecurityLabel
|
655
|
+
* Call virDomainLxcEnterSecurityLabel
|
656
656
|
* to attach to the security label specified by label in the security model
|
657
657
|
* specified by model. The return object is a Libvirt::Domain::SecurityLabel
|
658
658
|
* which may be able to be used to move back to the previous label.
|
@@ -660,7 +660,7 @@ static VALUE libvirt_conn_event_register_impl(int argc, VALUE *argv,
|
|
660
660
|
static VALUE libvirt_domain_lxc_enter_security_label(int argc, VALUE *argv,
|
661
661
|
VALUE RUBY_LIBVIRT_UNUSED(c))
|
662
662
|
{
|
663
|
-
VALUE model, label, flags, result, modiv, doiiv, labiv;
|
663
|
+
VALUE model = RUBY_Qnil, label = RUBY_Qnil, flags = RUBY_Qnil, result, modiv, doiiv, labiv;
|
664
664
|
virSecurityModel mod;
|
665
665
|
char *modstr, *doistr, *labstr;
|
666
666
|
virSecurityLabel lab, oldlab;
|
data/ext/libvirt/common.c
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
* common.c: Common utilities for the ruby libvirt bindings
|
3
3
|
*
|
4
4
|
* Copyright (C) 2007,2010 Red Hat Inc.
|
5
|
-
* Copyright (C) 2013 Chris Lalancette <clalancette@gmail.com>
|
5
|
+
* Copyright (C) 2013-2016 Chris Lalancette <clalancette@gmail.com>
|
6
6
|
*
|
7
7
|
* This library is free software; you can redistribute it and/or
|
8
8
|
* modify it under the terms of the GNU Lesser General Public
|
@@ -24,7 +24,8 @@
|
|
24
24
|
#endif
|
25
25
|
#include <stdio.h>
|
26
26
|
#include <ruby.h>
|
27
|
-
#include <
|
27
|
+
#include <ruby/encoding.h>
|
28
|
+
#include <ruby/st.h>
|
28
29
|
#include <libvirt/libvirt.h>
|
29
30
|
#include <libvirt/virterror.h>
|
30
31
|
#include "common.h"
|
@@ -38,8 +39,9 @@ struct rb_exc_new2_arg {
|
|
38
39
|
static VALUE ruby_libvirt_exc_new2_wrap(VALUE arg)
|
39
40
|
{
|
40
41
|
struct rb_exc_new2_arg *e = (struct rb_exc_new2_arg *)arg;
|
42
|
+
VALUE ruby_msg = ruby_libvirt_str_new2_wrap((VALUE)&e->msg);
|
41
43
|
|
42
|
-
return
|
44
|
+
return rb_exc_new3(e->error, ruby_msg);
|
43
45
|
}
|
44
46
|
|
45
47
|
VALUE ruby_libvirt_ary_new2_wrap(VALUE arg)
|
@@ -66,8 +68,11 @@ VALUE ruby_libvirt_ary_store_wrap(VALUE arg)
|
|
66
68
|
VALUE ruby_libvirt_str_new2_wrap(VALUE arg)
|
67
69
|
{
|
68
70
|
char **str = (char **)arg;
|
71
|
+
VALUE ruby_msg = rb_str_new2(*str);
|
72
|
+
int enc = rb_enc_find_index("UTF-8");
|
69
73
|
|
70
|
-
|
74
|
+
rb_enc_associate_index(ruby_msg, enc);
|
75
|
+
return ruby_msg;
|
71
76
|
}
|
72
77
|
|
73
78
|
VALUE ruby_libvirt_str_new_wrap(VALUE arg)
|
@@ -84,6 +89,15 @@ VALUE ruby_libvirt_hash_aset_wrap(VALUE arg)
|
|
84
89
|
return rb_hash_aset(e->hash, rb_str_new2(e->name), e->val);
|
85
90
|
}
|
86
91
|
|
92
|
+
VALUE ruby_libvirt_str_new2_and_ary_store_wrap(VALUE arg)
|
93
|
+
{
|
94
|
+
struct ruby_libvirt_str_new2_and_ary_store_arg *e = (struct ruby_libvirt_str_new2_and_ary_store_arg *)arg;
|
95
|
+
|
96
|
+
rb_ary_store(e->arr, e->index, rb_str_new2(e->value));
|
97
|
+
|
98
|
+
return Qnil;
|
99
|
+
}
|
100
|
+
|
87
101
|
void ruby_libvirt_raise_error_if(const int condition, VALUE error,
|
88
102
|
const char *method, virConnectPtr conn)
|
89
103
|
{
|
@@ -135,7 +149,7 @@ void ruby_libvirt_raise_error_if(const int condition, VALUE error,
|
|
135
149
|
rb_iv_set(ruby_errinfo, "@libvirt_level", INT2NUM(err->level));
|
136
150
|
if (err->message != NULL) {
|
137
151
|
rb_iv_set(ruby_errinfo, "@libvirt_message",
|
138
|
-
|
152
|
+
ruby_libvirt_str_new2_wrap((VALUE)&err->message));
|
139
153
|
}
|
140
154
|
}
|
141
155
|
|
@@ -186,7 +200,7 @@ VALUE ruby_libvirt_generate_list(int num, char **list)
|
|
186
200
|
VALUE result;
|
187
201
|
int exception = 0;
|
188
202
|
int i, j;
|
189
|
-
struct
|
203
|
+
struct ruby_libvirt_str_new2_and_ary_store_arg arg;
|
190
204
|
|
191
205
|
i = 0;
|
192
206
|
|
@@ -197,15 +211,13 @@ VALUE ruby_libvirt_generate_list(int num, char **list)
|
|
197
211
|
for (i = 0; i < num; i++) {
|
198
212
|
arg.arr = result;
|
199
213
|
arg.index = i;
|
200
|
-
arg.
|
201
|
-
|
202
|
-
|
203
|
-
goto exception;
|
204
|
-
}
|
205
|
-
rb_protect(ruby_libvirt_ary_store_wrap, (VALUE)&arg, &exception);
|
214
|
+
arg.value = list[i];
|
215
|
+
rb_protect(ruby_libvirt_str_new2_and_ary_store_wrap, (VALUE)&arg,
|
216
|
+
&exception);
|
206
217
|
if (exception) {
|
207
218
|
goto exception;
|
208
219
|
}
|
220
|
+
|
209
221
|
xfree(list[i]);
|
210
222
|
}
|
211
223
|
|
@@ -373,8 +385,10 @@ int ruby_libvirt_typed_parameter_assign(VALUE key, VALUE val, VALUE in)
|
|
373
385
|
default:
|
374
386
|
rb_raise(rb_eArgError, "Invalid parameter type");
|
375
387
|
}
|
388
|
+
/* ensure that the field is NULL-terminated */
|
389
|
+
args->params[args->i].field[VIR_TYPED_PARAM_FIELD_LENGTH - 1] = '\0';
|
376
390
|
strncpy(args->params[args->i].field, keyname,
|
377
|
-
VIR_TYPED_PARAM_FIELD_LENGTH);
|
391
|
+
VIR_TYPED_PARAM_FIELD_LENGTH - 1);
|
378
392
|
(args->i)++;
|
379
393
|
found = 1;
|
380
394
|
break;
|
data/ext/libvirt/common.h
CHANGED
@@ -56,7 +56,7 @@ void ruby_libvirt_raise_error_if(const int condition, VALUE error,
|
|
56
56
|
} \
|
57
57
|
} \
|
58
58
|
else { \
|
59
|
-
result =
|
59
|
+
result = ruby_libvirt_str_new2_wrap((VALUE)&str); \
|
60
60
|
} \
|
61
61
|
return result; \
|
62
62
|
} while(0)
|
@@ -123,7 +123,7 @@ void ruby_libvirt_raise_error_if(const int condition, VALUE error,
|
|
123
123
|
|
124
124
|
#define ruby_libvirt_generate_call_list_all(type, argc, argv, listfunc, object, val, newfunc, freefunc) \
|
125
125
|
do { \
|
126
|
-
VALUE flags;
|
126
|
+
VALUE flags = RUBY_Qnil; \
|
127
127
|
type *list; \
|
128
128
|
int i; \
|
129
129
|
int ret; \
|
@@ -232,11 +232,13 @@ unsigned long ruby_libvirt_value_to_ulong(VALUE in);
|
|
232
232
|
unsigned long long ruby_libvirt_value_to_ulonglong(VALUE in);
|
233
233
|
|
234
234
|
VALUE ruby_libvirt_ary_new2_wrap(VALUE arg);
|
235
|
+
|
235
236
|
struct ruby_libvirt_ary_push_arg {
|
236
237
|
VALUE arr;
|
237
238
|
VALUE value;
|
238
239
|
};
|
239
240
|
VALUE ruby_libvirt_ary_push_wrap(VALUE arg);
|
241
|
+
|
240
242
|
struct ruby_libvirt_ary_store_arg {
|
241
243
|
VALUE arr;
|
242
244
|
long index;
|
@@ -245,6 +247,7 @@ struct ruby_libvirt_ary_store_arg {
|
|
245
247
|
VALUE ruby_libvirt_ary_store_wrap(VALUE arg);
|
246
248
|
|
247
249
|
VALUE ruby_libvirt_str_new2_wrap(VALUE arg);
|
250
|
+
|
248
251
|
struct ruby_libvirt_str_new_arg {
|
249
252
|
char *val;
|
250
253
|
size_t size;
|
@@ -258,6 +261,13 @@ struct ruby_libvirt_hash_aset_arg {
|
|
258
261
|
};
|
259
262
|
VALUE ruby_libvirt_hash_aset_wrap(VALUE arg);
|
260
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
|
+
|
261
271
|
#ifndef RARRAY_LEN
|
262
272
|
#define RARRAY_LEN(ar) (RARRAY(ar)->len)
|
263
273
|
#endif
|