ruby-libvirt 0.7.1 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/NEWS +13 -0
- data/README +1 -1
- data/README.rdoc +1 -1
- data/Rakefile +3 -3
- data/ext/libvirt/_libvirt.c +10 -100
- data/ext/libvirt/common.c +9 -6
- data/ext/libvirt/common.h +1 -1
- data/ext/libvirt/connect.c +122 -358
- data/ext/libvirt/domain.c +267 -961
- data/ext/libvirt/extconf.h +0 -389
- data/ext/libvirt/extconf.rb +6 -490
- data/ext/libvirt/interface.c +8 -18
- data/ext/libvirt/network.c +15 -46
- data/ext/libvirt/nodedevice.c +22 -41
- data/ext/libvirt/nwfilter.c +5 -9
- data/ext/libvirt/secret.c +9 -20
- data/ext/libvirt/storage.c +36 -129
- data/ext/libvirt/stream.c +10 -14
- data/tests/test_domain.rb +2 -0
- data/tests/test_utils.rb +18 -0
- metadata +8 -9
data/ext/libvirt/stream.c
CHANGED
@@ -26,7 +26,6 @@
|
|
26
26
|
#include "connect.h"
|
27
27
|
#include "extconf.h"
|
28
28
|
|
29
|
-
#if HAVE_TYPE_VIRSTREAMPTR
|
30
29
|
static VALUE c_stream;
|
31
30
|
|
32
31
|
static void stream_free(void *s)
|
@@ -48,7 +47,7 @@ VALUE ruby_libvirt_stream_new(virStreamPtr s, VALUE conn)
|
|
48
47
|
* call-seq:
|
49
48
|
* stream.send(buffer) -> Fixnum
|
50
49
|
*
|
51
|
-
* Call virStreamSend[
|
50
|
+
* Call virStreamSend[https://libvirt.org/html/libvirt-libvirt-stream.html#virStreamSend]
|
52
51
|
* to send the data in buffer out to the stream. The return value is the
|
53
52
|
* number of bytes sent, which may be less than the size of the buffer. If
|
54
53
|
* an error occurred, -1 is returned. If the transmit buffers are full and the
|
@@ -72,7 +71,7 @@ static VALUE libvirt_stream_send(VALUE s, VALUE buffer)
|
|
72
71
|
* call-seq:
|
73
72
|
* stream.recv(bytes) -> [return_value, data]
|
74
73
|
*
|
75
|
-
* Call virStreamRecv[
|
74
|
+
* Call virStreamRecv[https://libvirt.org/html/libvirt-libvirt-stream.html#virStreamRecv]
|
76
75
|
* to receive up to bytes amount of data from the stream. The return is an
|
77
76
|
* array with two elements; the return code from the virStreamRecv call and
|
78
77
|
* the data (as a String) read from the stream. If an error occurred, the
|
@@ -138,7 +137,7 @@ static int internal_sendall(virStreamPtr RUBY_LIBVIRT_UNUSED(st), char *data,
|
|
138
137
|
* call-seq:
|
139
138
|
* stream.sendall(opaque=nil){|opaque, nbytes| send block} -> nil
|
140
139
|
*
|
141
|
-
* Call virStreamSendAll[
|
140
|
+
* Call virStreamSendAll[https://libvirt.org/html/libvirt-libvirt-stream.html#virStreamSendAll]
|
142
141
|
* to send the entire data stream. The send block is required and is executed
|
143
142
|
* one or more times to send data. Each invocation of the send block yields
|
144
143
|
* the opaque data passed into the initial call and the number of bytes this
|
@@ -184,7 +183,7 @@ static int internal_recvall(virStreamPtr RUBY_LIBVIRT_UNUSED(st),
|
|
184
183
|
* call-seq:
|
185
184
|
* stream.recvall(opaque){|data, opaque| receive block} -> nil
|
186
185
|
*
|
187
|
-
* Call virStreamRecvAll[
|
186
|
+
* Call virStreamRecvAll[https://libvirt.org/html/libvirt-libvirt-stream.html#virStreamRecvAll]
|
188
187
|
* to receive the entire data stream. The receive block is required and is
|
189
188
|
* called one or more times to receive data. Each invocation of the receive
|
190
189
|
* block yields the data received and the opaque data passed into the initial
|
@@ -246,7 +245,7 @@ static void stream_event_callback(virStreamPtr st, int events, void *opaque)
|
|
246
245
|
* call-seq:
|
247
246
|
* stream.event_add_callback(events, callback, opaque=nil) -> nil
|
248
247
|
*
|
249
|
-
* Call virStreamEventAddCallback[
|
248
|
+
* Call virStreamEventAddCallback[https://libvirt.org/html/libvirt-libvirt-stream.html#virStreamEventAddCallback]
|
250
249
|
* to register a callback to be notified when a stream becomes readable or
|
251
250
|
* writeable. The events parameter is an integer representing the events the
|
252
251
|
* user is interested in; it should be one or more of EVENT_READABLE,
|
@@ -288,7 +287,7 @@ static VALUE libvirt_stream_event_add_callback(int argc, VALUE *argv, VALUE s)
|
|
288
287
|
* call-seq:
|
289
288
|
* stream.event_update_callback(events) -> nil
|
290
289
|
*
|
291
|
-
* Call virStreamEventUpdateCallback[
|
290
|
+
* Call virStreamEventUpdateCallback[https://libvirt.org/html/libvirt-libvirt-stream.html#virStreamEventUpdateCallback]
|
292
291
|
* to change the events that the event callback is looking for. The events
|
293
292
|
* parameter is an integer representing the events the user is interested in;
|
294
293
|
* it should be one or more of EVENT_READABLE, EVENT_WRITABLE, EVENT_ERROR,
|
@@ -305,7 +304,7 @@ static VALUE libvirt_stream_event_update_callback(VALUE s, VALUE events)
|
|
305
304
|
* call-seq:
|
306
305
|
* stream.event_remove_callback -> nil
|
307
306
|
*
|
308
|
-
* Call virStreamEventRemoveCallback[
|
307
|
+
* Call virStreamEventRemoveCallback[https://libvirt.org/html/libvirt-libvirt-stream.html#virStreamEventRemoveCallback]
|
309
308
|
* to remove the event callback currently registered to this stream.
|
310
309
|
*/
|
311
310
|
static VALUE libvirt_stream_event_remove_callback(VALUE s)
|
@@ -319,7 +318,7 @@ static VALUE libvirt_stream_event_remove_callback(VALUE s)
|
|
319
318
|
* call-seq:
|
320
319
|
* stream.finish -> nil
|
321
320
|
*
|
322
|
-
* Call virStreamFinish[
|
321
|
+
* Call virStreamFinish[https://libvirt.org/html/libvirt-libvirt-stream.html#virStreamFinish]
|
323
322
|
* to finish this stream. Finish is typically used when the stream is no
|
324
323
|
* longer needed and needs to be cleaned up.
|
325
324
|
*/
|
@@ -333,7 +332,7 @@ static VALUE libvirt_stream_finish(VALUE s)
|
|
333
332
|
* call-seq:
|
334
333
|
* stream.abort -> nil
|
335
334
|
*
|
336
|
-
* Call virStreamAbort[
|
335
|
+
* Call virStreamAbort[https://libvirt.org/html/libvirt-libvirt-stream.html#virStreamAbort]
|
337
336
|
* to abort this stream. Abort is typically used when something on the stream
|
338
337
|
* has failed, and the stream needs to be cleaned up.
|
339
338
|
*/
|
@@ -347,21 +346,19 @@ static VALUE libvirt_stream_abort(VALUE s)
|
|
347
346
|
* call-seq:
|
348
347
|
* stream.free -> nil
|
349
348
|
*
|
350
|
-
* Call virStreamFree[
|
349
|
+
* Call virStreamFree[https://libvirt.org/html/libvirt-libvirt-stream.html#virStreamFree]
|
351
350
|
* to free this stream. The object will no longer be valid after this call.
|
352
351
|
*/
|
353
352
|
static VALUE libvirt_stream_free(VALUE s)
|
354
353
|
{
|
355
354
|
ruby_libvirt_generate_call_free(Stream, s);
|
356
355
|
}
|
357
|
-
#endif
|
358
356
|
|
359
357
|
/*
|
360
358
|
* Class Libvirt::Stream
|
361
359
|
*/
|
362
360
|
void ruby_libvirt_stream_init(void)
|
363
361
|
{
|
364
|
-
#if HAVE_TYPE_VIRSTREAMPTR
|
365
362
|
c_stream = rb_define_class_under(m_libvirt, "Stream", rb_cObject);
|
366
363
|
|
367
364
|
rb_define_attr(c_stream, "connection", 1, 0);
|
@@ -388,5 +385,4 @@ void ruby_libvirt_stream_init(void)
|
|
388
385
|
rb_define_method(c_stream, "finish", libvirt_stream_finish, 0);
|
389
386
|
rb_define_method(c_stream, "abort", libvirt_stream_abort, 0);
|
390
387
|
rb_define_method(c_stream, "free", libvirt_stream_free, 0);
|
391
|
-
#endif
|
392
388
|
}
|
data/tests/test_domain.rb
CHANGED
@@ -606,6 +606,7 @@ sleep 1
|
|
606
606
|
expect_too_many_args(newdom, "name", 1)
|
607
607
|
|
608
608
|
expect_success(newdom, "no args", "name") {|x| x == "rb-libvirt-test"}
|
609
|
+
expect_success(newdom, "is UTF-8", "name") {|x| x.encoding.name == "UTF-8"}
|
609
610
|
|
610
611
|
newdom.destroy
|
611
612
|
|
@@ -909,6 +910,7 @@ expect_too_many_args(newdom, "lookup_snapshot_by_name", 1, 2, 3)
|
|
909
910
|
expect_too_few_args(newdom, "lookup_snapshot_by_name")
|
910
911
|
expect_invalid_arg_type(newdom, "lookup_snapshot_by_name", 1)
|
911
912
|
expect_invalid_arg_type(newdom, "lookup_snapshot_by_name", 'foo', 'bar')
|
913
|
+
expect_utf8_exception_msg(newdom, Libvirt::RetrieveError, "lookup_snapshot_by_name", "__non_existing_snapshot")
|
912
914
|
|
913
915
|
expect_success(newdom, "name arg", "lookup_snapshot_by_name", "foo")
|
914
916
|
|
data/tests/test_utils.rb
CHANGED
@@ -166,6 +166,24 @@ def expect_fail(object, errtype, errmsg, func, *args)
|
|
166
166
|
end
|
167
167
|
end
|
168
168
|
|
169
|
+
def expect_utf8_exception_msg(object, errtype, func, *args)
|
170
|
+
begin
|
171
|
+
object.__send__(func, *args)
|
172
|
+
rescue NoMethodError
|
173
|
+
puts_skipped "#{$test_object}.#{func} does not exist"
|
174
|
+
rescue errtype => e
|
175
|
+
if e.message.encoding.name == 'UTF-8'
|
176
|
+
puts_ok "#{$test_object}.#{func} threw #{errtype.to_s} with UTF-8 encoding"
|
177
|
+
else
|
178
|
+
puts_fail "#{$test_object}.#{func} threw #{errtype.to_s} with #{e.message.encoding.name} encoding"
|
179
|
+
end
|
180
|
+
rescue => e
|
181
|
+
puts_fail "#{$test_object}.#{func} expected to throw #{errtype.to_s}, but instead threw #{e.class.to_s}: #{e.to_s}"
|
182
|
+
else
|
183
|
+
puts_fail "#{$test_object}.#{func} expected to throw #{errtype.to_s}, but threw nothing"
|
184
|
+
end
|
185
|
+
end
|
186
|
+
|
169
187
|
def expect_too_many_args(object, func, *args)
|
170
188
|
expect_fail(object, ArgumentError, "too many args", func, *args)
|
171
189
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby-libvirt
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.8.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Lutterkort, Chris Lalancette
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2024-02-08 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: Ruby bindings for libvirt.
|
14
14
|
email: libvir-list@redhat.com
|
@@ -57,11 +57,11 @@ files:
|
|
57
57
|
- tests/test_storage.rb
|
58
58
|
- tests/test_stream.rb
|
59
59
|
- tests/test_utils.rb
|
60
|
-
homepage:
|
60
|
+
homepage: https://ruby.libvirt.org/
|
61
61
|
licenses:
|
62
|
-
-
|
62
|
+
- LGPL-2.1-or-later
|
63
63
|
metadata: {}
|
64
|
-
post_install_message:
|
64
|
+
post_install_message:
|
65
65
|
rdoc_options: []
|
66
66
|
require_paths:
|
67
67
|
- lib
|
@@ -76,9 +76,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
76
76
|
- !ruby/object:Gem::Version
|
77
77
|
version: '0'
|
78
78
|
requirements: []
|
79
|
-
|
80
|
-
|
81
|
-
signing_key:
|
79
|
+
rubygems_version: 3.4.10
|
80
|
+
signing_key:
|
82
81
|
specification_version: 4
|
83
82
|
summary: Ruby bindings for LIBVIRT
|
84
83
|
test_files: []
|