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
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: fee786f1797ab1c5a5e8d496b387667786a5f703872a29125fbc0d43f6737b4b
|
4
|
+
data.tar.gz: e79852df639e0ff830afae0918e2e5e3754e555eb2db8c9641b38cb834793091
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f927ee0ed89539c2db5ae8aa955d4e03960b770e511bec78b5e46972ccc61f8e3d6bcf1d5c34efa84b3573b9f55365bdb6be52534ad7e3777b6d6b926d5001da
|
7
|
+
data.tar.gz: 933864259c5b508f6956de0c5f99ba3a9ba3c741863e9f9e74fbe2d433f83e68fbf650725598f0c41c3df3c9abe51f3a717ccd27da547a57d359b86071379e03
|
data/NEWS
CHANGED
@@ -1,3 +1,16 @@
|
|
1
|
+
2024-02-08 0.8.1
|
2
|
+
* Add missing virDomainUndefineFlagsValues constants
|
3
|
+
* Require libvirt 2.0.0
|
4
|
+
* Always use pkg-config for detecting libvirt
|
5
|
+
* Drop most compile-time feature checks
|
6
|
+
|
7
|
+
2021-11-15 0.8.0
|
8
|
+
* Fix default values for node_cpu_stats and node_memory_stats
|
9
|
+
* Fix cpumap allocation for virDomainGetVcpus
|
10
|
+
* Enforce UTF8 for strings and exceptions
|
11
|
+
* Drop local have_const
|
12
|
+
* Use sensible default for libvirt_domain_qemu_agent_command
|
13
|
+
|
1
14
|
2018-02-18 0.7.1
|
2
15
|
* Fix a bad bug in block_resize (Marius Rieder)
|
3
16
|
* Fix up some problems pointed out by clang
|
data/README
CHANGED
data/README.rdoc
CHANGED
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.1'
|
25
25
|
|
26
26
|
EXT_CONF='ext/libvirt/extconf.rb'
|
27
27
|
MAKEFILE="ext/libvirt/Makefile"
|
@@ -137,7 +137,7 @@ SPEC = Gem::Specification.new do |s|
|
|
137
137
|
s.name = PKG_NAME
|
138
138
|
s.version = PKG_VERSION
|
139
139
|
s.email = "libvir-list@redhat.com"
|
140
|
-
s.homepage = "
|
140
|
+
s.homepage = "https://ruby.libvirt.org/"
|
141
141
|
s.summary = "Ruby bindings for LIBVIRT"
|
142
142
|
s.files = PKG_FILES
|
143
143
|
s.required_ruby_version = '>= 1.8.1'
|
@@ -145,7 +145,7 @@ SPEC = Gem::Specification.new do |s|
|
|
145
145
|
s.author = "David Lutterkort, Chris Lalancette"
|
146
146
|
s.rubyforge_project = "None"
|
147
147
|
s.description = "Ruby bindings for libvirt."
|
148
|
-
s.license = "
|
148
|
+
s.license = "LGPL-2.1-or-later"
|
149
149
|
end
|
150
150
|
|
151
151
|
Gem::PackageTask.new(SPEC) do |pkg|
|
data/ext/libvirt/_libvirt.c
CHANGED
@@ -24,9 +24,7 @@
|
|
24
24
|
#include <ruby.h>
|
25
25
|
#include <libvirt/libvirt.h>
|
26
26
|
#include <libvirt/virterror.h>
|
27
|
-
#if HAVE_VIRDOMAINLXCENTERSECURITYLABEL
|
28
27
|
#include <libvirt/libvirt-lxc.h>
|
29
|
-
#endif
|
30
28
|
#include "extconf.h"
|
31
29
|
#include "common.h"
|
32
30
|
#include "storage.h"
|
@@ -39,6 +37,10 @@
|
|
39
37
|
#include "domain.h"
|
40
38
|
#include "stream.h"
|
41
39
|
|
40
|
+
#if !LIBVIR_CHECK_VERSION(2, 0, 0)
|
41
|
+
# error "Libvirt >= 2.0.0 is required for the ruby binding"
|
42
|
+
#endif
|
43
|
+
|
42
44
|
static VALUE c_libvirt_version;
|
43
45
|
|
44
46
|
VALUE m_libvirt;
|
@@ -60,7 +62,7 @@ static void rubyLibvirtErrorFunc(void *RUBY_LIBVIRT_UNUSED(userdata),
|
|
60
62
|
* call-seq:
|
61
63
|
* Libvirt::version(type=nil) -> [ libvirt_version, type_version ]
|
62
64
|
*
|
63
|
-
* Call virGetVersion[
|
65
|
+
* Call virGetVersion[https://libvirt.org/html/libvirt-libvirt-host.html#virGetVersion]
|
64
66
|
* to get the version of libvirt and of the hypervisor TYPE.
|
65
67
|
*/
|
66
68
|
static VALUE libvirt_version(int argc, VALUE *argv,
|
@@ -90,7 +92,7 @@ static VALUE libvirt_version(int argc, VALUE *argv,
|
|
90
92
|
* call-seq:
|
91
93
|
* Libvirt::open(uri=nil) -> Libvirt::Connect
|
92
94
|
*
|
93
|
-
* Call virConnectOpen[
|
95
|
+
* Call virConnectOpen[https://libvirt.org/html/libvirt-libvirt-host.html#virConnectOpen]
|
94
96
|
* to open a connection to a URL.
|
95
97
|
*/
|
96
98
|
static VALUE libvirt_open(int argc, VALUE *argv, VALUE RUBY_LIBVIRT_UNUSED(m))
|
@@ -111,7 +113,7 @@ static VALUE libvirt_open(int argc, VALUE *argv, VALUE RUBY_LIBVIRT_UNUSED(m))
|
|
111
113
|
* call-seq:
|
112
114
|
* Libvirt::open_read_only(uri=nil) -> Libvirt::Connect
|
113
115
|
*
|
114
|
-
* Call virConnectOpenReadOnly[
|
116
|
+
* Call virConnectOpenReadOnly[https://libvirt.org/html/libvirt-libvirt-host.html#virConnectOpenReadOnly]
|
115
117
|
* to open a read-only connection to a URL.
|
116
118
|
*/
|
117
119
|
static VALUE libvirt_open_read_only(int argc, VALUE *argv,
|
@@ -130,7 +132,6 @@ static VALUE libvirt_open_read_only(int argc, VALUE *argv,
|
|
130
132
|
return ruby_libvirt_connect_new(conn);
|
131
133
|
}
|
132
134
|
|
133
|
-
#if HAVE_VIRCONNECTOPENAUTH
|
134
135
|
static int libvirt_auth_callback_wrapper(virConnectCredentialPtr cred,
|
135
136
|
unsigned int ncred, void *cbdata)
|
136
137
|
{
|
@@ -184,11 +185,11 @@ static int libvirt_auth_callback_wrapper(virConnectCredentialPtr cred,
|
|
184
185
|
* call-seq:
|
185
186
|
* Libvirt::open_auth(uri=nil, credlist=nil, userdata=nil, flags=0) {|...| authentication block} -> Libvirt::Connect
|
186
187
|
*
|
187
|
-
* Call virConnectOpenAuth[
|
188
|
+
* Call virConnectOpenAuth[https://libvirt.org/html/libvirt-libvirt-host.html#virConnectOpenAuth]
|
188
189
|
* to open a connection to a libvirt URI, with a possible authentication block.
|
189
190
|
* If an authentication block is desired, then credlist should be an array that
|
190
191
|
* specifies which credentials the authentication block is willing to support;
|
191
|
-
* the full list is available at
|
192
|
+
* the full list is available at https://libvirt.org/html/libvirt-libvirt.html#virConnectCredentialType.
|
192
193
|
* If userdata is not nil and an authentication block is given, userdata will
|
193
194
|
* be passed unaltered into the authentication block. The flags parameter
|
194
195
|
* controls how to open connection. The only options currently available for
|
@@ -262,9 +263,7 @@ static VALUE libvirt_open_auth(int argc, VALUE *argv,
|
|
262
263
|
|
263
264
|
return ruby_libvirt_connect_new(conn);
|
264
265
|
}
|
265
|
-
#endif
|
266
266
|
|
267
|
-
#if HAVE_VIREVENTREGISTERIMPL
|
268
267
|
static VALUE add_handle, update_handle, remove_handle;
|
269
268
|
static VALUE add_timeout, update_timeout, remove_timeout;
|
270
269
|
|
@@ -575,7 +574,7 @@ static int is_symbol_proc_or_nil(VALUE handle)
|
|
575
574
|
* call-seq:
|
576
575
|
* Libvirt::event_register_impl(add_handle=nil, update_handle=nil, remove_handle=nil, add_timeout=nil, update_timeout=nil, remove_timeout=nil) -> Qnil
|
577
576
|
*
|
578
|
-
* Call virEventRegisterImpl[
|
577
|
+
* Call virEventRegisterImpl[https://libvirt.org/html/libvirt-libvirt-event.html#virEventRegisterImpl]
|
579
578
|
* to register callback handlers for handles and timeouts. These handles and
|
580
579
|
* timeouts are used as part of the libvirt infrastructure for generating
|
581
580
|
* domain events. Each callback must be a Symbol (that is the name of a
|
@@ -645,9 +644,7 @@ static VALUE libvirt_conn_event_register_impl(int argc, VALUE *argv,
|
|
645
644
|
|
646
645
|
return Qnil;
|
647
646
|
}
|
648
|
-
#endif
|
649
647
|
|
650
|
-
#if HAVE_VIRDOMAINLXCENTERSECURITYLABEL
|
651
648
|
/*
|
652
649
|
* call-seq:
|
653
650
|
* Libvirt::lxc_enter_security_label(model, label, flags=0) -> Libvirt::Domain::SecurityLabel
|
@@ -701,7 +698,6 @@ static VALUE libvirt_domain_lxc_enter_security_label(int argc, VALUE *argv,
|
|
701
698
|
|
702
699
|
return result;
|
703
700
|
}
|
704
|
-
#endif
|
705
701
|
|
706
702
|
/*
|
707
703
|
* Module Libvirt
|
@@ -712,7 +708,6 @@ void Init__libvirt(void)
|
|
712
708
|
c_libvirt_version = rb_define_class_under(m_libvirt, "Version",
|
713
709
|
rb_cObject);
|
714
710
|
|
715
|
-
#if HAVE_VIRCONNECTOPENAUTH
|
716
711
|
rb_define_const(m_libvirt, "CONNECT_RO", INT2NUM(VIR_CONNECT_RO));
|
717
712
|
|
718
713
|
rb_define_const(m_libvirt, "CRED_USERNAME", INT2NUM(VIR_CRED_USERNAME));
|
@@ -725,12 +720,9 @@ void Init__libvirt(void)
|
|
725
720
|
INT2NUM(VIR_CRED_NOECHOPROMPT));
|
726
721
|
rb_define_const(m_libvirt, "CRED_REALM", INT2NUM(VIR_CRED_REALM));
|
727
722
|
rb_define_const(m_libvirt, "CRED_EXTERNAL", INT2NUM(VIR_CRED_EXTERNAL));
|
728
|
-
#endif
|
729
723
|
|
730
|
-
#if HAVE_CONST_VIR_CONNECT_NO_ALIASES
|
731
724
|
rb_define_const(m_libvirt, "CONNECT_NO_ALIASES",
|
732
725
|
INT2NUM(VIR_CONNECT_NO_ALIASES));
|
733
|
-
#endif
|
734
726
|
|
735
727
|
/*
|
736
728
|
* Libvirt Errors
|
@@ -768,82 +760,32 @@ void Init__libvirt(void)
|
|
768
760
|
rb_define_const(e_Error, "FROM_TEST", INT2NUM(VIR_FROM_TEST));
|
769
761
|
rb_define_const(e_Error, "FROM_REMOTE", INT2NUM(VIR_FROM_REMOTE));
|
770
762
|
rb_define_const(e_Error, "FROM_OPENVZ", INT2NUM(VIR_FROM_OPENVZ));
|
771
|
-
#if HAVE_CONST_VIR_FROM_VMWARE
|
772
763
|
rb_define_const(e_Error, "FROM_VMWARE", INT2NUM(VIR_FROM_VMWARE));
|
773
|
-
#endif
|
774
|
-
#if HAVE_CONST_VIR_FROM_XENXM
|
775
764
|
rb_define_const(e_Error, "FROM_XENXM", INT2NUM(VIR_FROM_XENXM));
|
776
|
-
#endif
|
777
|
-
#if HAVE_CONST_VIR_FROM_STATS_LINUX
|
778
765
|
rb_define_const(e_Error, "FROM_STATS_LINUX", INT2NUM(VIR_FROM_STATS_LINUX));
|
779
|
-
#endif
|
780
|
-
#if HAVE_TYPE_VIR_FROM_LXC
|
781
766
|
rb_define_const(e_Error, "FROM_LXC", INT2NUM(VIR_FROM_LXC));
|
782
|
-
#endif
|
783
|
-
#if HAVE_TYPE_VIRSTORAGEPOOLPTR
|
784
767
|
rb_define_const(e_Error, "FROM_STORAGE", INT2NUM(VIR_FROM_STORAGE));
|
785
|
-
#endif
|
786
|
-
#if HAVE_CONST_VIR_FROM_NETWORK
|
787
768
|
rb_define_const(e_Error, "FROM_NETWORK", INT2NUM(VIR_FROM_NETWORK));
|
788
|
-
#endif
|
789
|
-
#if HAVE_CONST_VIR_FROM_DOMAIN
|
790
769
|
rb_define_const(e_Error, "FROM_DOMAIN", INT2NUM(VIR_FROM_DOMAIN));
|
791
|
-
#endif
|
792
|
-
#if HAVE_CONST_VIR_FROM_UML
|
793
770
|
rb_define_const(e_Error, "FROM_UML", INT2NUM(VIR_FROM_UML));
|
794
|
-
#endif
|
795
|
-
#if HAVE_TYPE_VIRNODEDEVICEPTR
|
796
771
|
rb_define_const(e_Error, "FROM_NODEDEV", INT2NUM(VIR_FROM_NODEDEV));
|
797
|
-
#endif
|
798
|
-
#if HAVE_CONST_VIR_FROM_XEN_INOTIFY
|
799
772
|
rb_define_const(e_Error, "FROM_XEN_INOTIFY", INT2NUM(VIR_FROM_XEN_INOTIFY));
|
800
|
-
#endif
|
801
|
-
#if HAVE_CONST_VIR_FROM_SECURITY
|
802
773
|
rb_define_const(e_Error, "FROM_SECURITY", INT2NUM(VIR_FROM_SECURITY));
|
803
|
-
#endif
|
804
|
-
#if HAVE_CONST_VIR_FROM_VBOX
|
805
774
|
rb_define_const(e_Error, "FROM_VBOX", INT2NUM(VIR_FROM_VBOX));
|
806
|
-
#endif
|
807
|
-
#if HAVE_TYPE_VIRINTERFACEPTR
|
808
775
|
rb_define_const(e_Error, "FROM_INTERFACE", INT2NUM(VIR_FROM_INTERFACE));
|
809
|
-
#endif
|
810
|
-
#if HAVE_CONST_VIR_FROM_ONE
|
811
776
|
rb_define_const(e_Error, "FROM_ONE", INT2NUM(VIR_FROM_ONE));
|
812
|
-
#endif
|
813
|
-
#if HAVE_CONST_VIR_FROM_ESX
|
814
777
|
rb_define_const(e_Error, "FROM_ESX", INT2NUM(VIR_FROM_ESX));
|
815
|
-
#endif
|
816
|
-
#if HAVE_CONST_VIR_FROM_PHYP
|
817
778
|
rb_define_const(e_Error, "FROM_PHYP", INT2NUM(VIR_FROM_PHYP));
|
818
|
-
#endif
|
819
|
-
#if HAVE_TYPE_VIRSECRETPTR
|
820
779
|
rb_define_const(e_Error, "FROM_SECRET", INT2NUM(VIR_FROM_SECRET));
|
821
|
-
#endif
|
822
|
-
#if HAVE_VIRCONNECTCOMPARECPU
|
823
780
|
rb_define_const(e_Error, "FROM_CPU", INT2NUM(VIR_FROM_CPU));
|
824
|
-
#endif
|
825
|
-
#if HAVE_CONST_VIR_FROM_XENAPI
|
826
781
|
rb_define_const(e_Error, "FROM_XENAPI", INT2NUM(VIR_FROM_XENAPI));
|
827
|
-
#endif
|
828
|
-
#if HAVE_TYPE_VIRNWFILTERPTR
|
829
782
|
rb_define_const(e_Error, "FROM_NWFILTER", INT2NUM(VIR_FROM_NWFILTER));
|
830
|
-
#endif
|
831
|
-
#if HAVE_CONST_VIR_FROM_HOOK
|
832
783
|
rb_define_const(e_Error, "FROM_HOOK", INT2NUM(VIR_FROM_HOOK));
|
833
|
-
#endif
|
834
|
-
#if HAVE_TYPE_VIRDOMAINSNAPSHOTPTR
|
835
784
|
rb_define_const(e_Error, "FROM_DOMAIN_SNAPSHOT",
|
836
785
|
INT2NUM(VIR_FROM_DOMAIN_SNAPSHOT));
|
837
|
-
#endif
|
838
|
-
#if HAVE_CONST_VIR_FROM_AUDIT
|
839
786
|
rb_define_const(e_Error, "FROM_AUDIT", INT2NUM(VIR_FROM_AUDIT));
|
840
|
-
#endif
|
841
|
-
#if HAVE_CONST_VIR_FROM_SYSINFO
|
842
787
|
rb_define_const(e_Error, "FROM_SYSINFO", INT2NUM(VIR_FROM_SYSINFO));
|
843
|
-
#endif
|
844
|
-
#if HAVE_CONST_VIR_FROM_STREAMS
|
845
788
|
rb_define_const(e_Error, "FROM_STREAMS", INT2NUM(VIR_FROM_STREAMS));
|
846
|
-
#endif
|
847
789
|
|
848
790
|
/* libvirt error codes */
|
849
791
|
rb_define_const(e_Error, "ERR_OK", INT2NUM(VIR_ERR_OK));
|
@@ -897,10 +839,7 @@ void Init__libvirt(void)
|
|
897
839
|
rb_define_const(e_Error, "ERR_NO_DOMAIN", INT2NUM(VIR_ERR_NO_DOMAIN));
|
898
840
|
rb_define_const(e_Error, "ERR_NO_NETWORK", INT2NUM(VIR_ERR_NO_NETWORK));
|
899
841
|
rb_define_const(e_Error, "ERR_INVALID_MAC", INT2NUM(VIR_ERR_INVALID_MAC));
|
900
|
-
#if HAVE_CONST_VIR_ERR_AUTH_FAILED
|
901
842
|
rb_define_const(e_Error, "ERR_AUTH_FAILED", INT2NUM(VIR_ERR_AUTH_FAILED));
|
902
|
-
#endif
|
903
|
-
#if HAVE_TYPE_VIRSTORAGEPOOLPTR
|
904
843
|
rb_define_const(e_Error, "ERR_INVALID_STORAGE_POOL",
|
905
844
|
INT2NUM(VIR_ERR_INVALID_STORAGE_POOL));
|
906
845
|
rb_define_const(e_Error, "ERR_INVALID_STORAGE_VOL",
|
@@ -910,66 +849,43 @@ void Init__libvirt(void)
|
|
910
849
|
INT2NUM(VIR_ERR_NO_STORAGE_POOL));
|
911
850
|
rb_define_const(e_Error, "ERR_NO_STORAGE_VOL",
|
912
851
|
INT2NUM(VIR_ERR_NO_STORAGE_VOL));
|
913
|
-
#endif
|
914
|
-
#if HAVE_TYPE_VIRNODEDEVICEPTR
|
915
852
|
rb_define_const(e_Error, "WAR_NO_NODE", INT2NUM(VIR_WAR_NO_NODE));
|
916
853
|
rb_define_const(e_Error, "ERR_INVALID_NODE_DEVICE",
|
917
854
|
INT2NUM(VIR_ERR_INVALID_NODE_DEVICE));
|
918
855
|
rb_define_const(e_Error, "ERR_NO_NODE_DEVICE",
|
919
856
|
INT2NUM(VIR_ERR_NO_NODE_DEVICE));
|
920
|
-
#endif
|
921
|
-
#if HAVE_CONST_VIR_ERR_NO_SECURITY_MODEL
|
922
857
|
rb_define_const(e_Error, "ERR_NO_SECURITY_MODEL",
|
923
858
|
INT2NUM(VIR_ERR_NO_SECURITY_MODEL));
|
924
|
-
#endif
|
925
|
-
#if HAVE_CONST_VIR_ERR_OPERATION_INVALID
|
926
859
|
rb_define_const(e_Error, "ERR_OPERATION_INVALID",
|
927
860
|
INT2NUM(VIR_ERR_OPERATION_INVALID));
|
928
|
-
#endif
|
929
|
-
#if HAVE_TYPE_VIRINTERFACEPTR
|
930
861
|
rb_define_const(e_Error, "WAR_NO_INTERFACE", INT2NUM(VIR_WAR_NO_INTERFACE));
|
931
862
|
rb_define_const(e_Error, "ERR_NO_INTERFACE", INT2NUM(VIR_ERR_NO_INTERFACE));
|
932
863
|
rb_define_const(e_Error, "ERR_INVALID_INTERFACE",
|
933
864
|
INT2NUM(VIR_ERR_INVALID_INTERFACE));
|
934
865
|
rb_define_const(e_Error, "ERR_MULTIPLE_INTERFACES",
|
935
866
|
INT2NUM(VIR_ERR_MULTIPLE_INTERFACES));
|
936
|
-
#endif
|
937
|
-
#if HAVE_TYPE_VIRNWFILTERPTR
|
938
867
|
rb_define_const(e_Error, "WAR_NO_NWFILTER", INT2NUM(VIR_WAR_NO_NWFILTER));
|
939
868
|
rb_define_const(e_Error, "ERR_INVALID_NWFILTER",
|
940
869
|
INT2NUM(VIR_ERR_INVALID_NWFILTER));
|
941
870
|
rb_define_const(e_Error, "ERR_NO_NWFILTER", INT2NUM(VIR_ERR_NO_NWFILTER));
|
942
871
|
rb_define_const(e_Error, "ERR_BUILD_FIREWALL",
|
943
872
|
INT2NUM(VIR_ERR_BUILD_FIREWALL));
|
944
|
-
#endif
|
945
|
-
#if HAVE_TYPE_VIRSECRETPTR
|
946
873
|
rb_define_const(e_Error, "WAR_NO_SECRET", INT2NUM(VIR_WAR_NO_SECRET));
|
947
874
|
rb_define_const(e_Error, "ERR_INVALID_SECRET",
|
948
875
|
INT2NUM(VIR_ERR_INVALID_SECRET));
|
949
876
|
rb_define_const(e_Error, "ERR_NO_SECRET", INT2NUM(VIR_ERR_NO_SECRET));
|
950
|
-
#endif
|
951
|
-
#if HAVE_CONST_VIR_ERR_CONFIG_UNSUPPORTED
|
952
877
|
rb_define_const(e_Error, "ERR_CONFIG_UNSUPPORTED",
|
953
878
|
INT2NUM(VIR_ERR_CONFIG_UNSUPPORTED));
|
954
|
-
#endif
|
955
|
-
#if HAVE_CONST_VIR_ERR_OPERATION_TIMEOUT
|
956
879
|
rb_define_const(e_Error, "ERR_OPERATION_TIMEOUT",
|
957
880
|
INT2NUM(VIR_ERR_OPERATION_TIMEOUT));
|
958
|
-
#endif
|
959
|
-
#if HAVE_CONST_VIR_ERR_MIGRATE_PERSIST_FAILED
|
960
881
|
rb_define_const(e_Error, "ERR_MIGRATE_PERSIST_FAILED",
|
961
882
|
INT2NUM(VIR_ERR_MIGRATE_PERSIST_FAILED));
|
962
|
-
#endif
|
963
|
-
#if HAVE_CONST_VIR_ERR_HOOK_SCRIPT_FAILED
|
964
883
|
rb_define_const(e_Error, "ERR_HOOK_SCRIPT_FAILED",
|
965
884
|
INT2NUM(VIR_ERR_HOOK_SCRIPT_FAILED));
|
966
|
-
#endif
|
967
|
-
#if HAVE_TYPE_VIRDOMAINSNAPSHOTPTR
|
968
885
|
rb_define_const(e_Error, "ERR_INVALID_DOMAIN_SNAPSHOT",
|
969
886
|
INT2NUM(VIR_ERR_INVALID_DOMAIN_SNAPSHOT));
|
970
887
|
rb_define_const(e_Error, "ERR_NO_DOMAIN_SNAPSHOT",
|
971
888
|
INT2NUM(VIR_ERR_NO_DOMAIN_SNAPSHOT));
|
972
|
-
#endif
|
973
889
|
|
974
890
|
/* libvirt levels */
|
975
891
|
rb_define_const(e_Error, "LEVEL_NONE", INT2NUM(VIR_ERR_NONE));
|
@@ -980,11 +896,8 @@ void Init__libvirt(void)
|
|
980
896
|
rb_define_module_function(m_libvirt, "open", libvirt_open, -1);
|
981
897
|
rb_define_module_function(m_libvirt, "open_read_only",
|
982
898
|
libvirt_open_read_only, -1);
|
983
|
-
#if HAVE_VIRCONNECTOPENAUTH
|
984
899
|
rb_define_module_function(m_libvirt, "open_auth", libvirt_open_auth, -1);
|
985
|
-
#endif
|
986
900
|
|
987
|
-
#if HAVE_VIREVENTREGISTERIMPL
|
988
901
|
rb_define_const(m_libvirt, "EVENT_HANDLE_READABLE",
|
989
902
|
INT2NUM(VIR_EVENT_HANDLE_READABLE));
|
990
903
|
rb_define_const(m_libvirt, "EVENT_HANDLE_WRITABLE",
|
@@ -1008,12 +921,9 @@ void Init__libvirt(void)
|
|
1008
921
|
libvirt_event_invoke_handle_callback, 4);
|
1009
922
|
rb_define_module_function(m_libvirt, "event_invoke_timeout_callback",
|
1010
923
|
libvirt_event_invoke_timeout_callback, 2);
|
1011
|
-
#endif
|
1012
924
|
|
1013
|
-
#if HAVE_VIRDOMAINLXCENTERSECURITYLABEL
|
1014
925
|
rb_define_method(m_libvirt, "lxc_enter_security_label",
|
1015
926
|
libvirt_domain_lxc_enter_security_label, -1);
|
1016
|
-
#endif
|
1017
927
|
|
1018
928
|
ruby_libvirt_connect_init();
|
1019
929
|
ruby_libvirt_storage_init();
|
data/ext/libvirt/common.c
CHANGED
@@ -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)
|
@@ -144,7 +149,7 @@ void ruby_libvirt_raise_error_if(const int condition, VALUE error,
|
|
144
149
|
rb_iv_set(ruby_errinfo, "@libvirt_level", INT2NUM(err->level));
|
145
150
|
if (err->message != NULL) {
|
146
151
|
rb_iv_set(ruby_errinfo, "@libvirt_message",
|
147
|
-
|
152
|
+
ruby_libvirt_str_new2_wrap((VALUE)&err->message));
|
148
153
|
}
|
149
154
|
}
|
150
155
|
|
@@ -475,9 +480,7 @@ int ruby_libvirt_get_maxcpus(virConnectPtr conn)
|
|
475
480
|
int maxcpu = -1;
|
476
481
|
virNodeInfo nodeinfo;
|
477
482
|
|
478
|
-
#if HAVE_VIRNODEGETCPUMAP
|
479
483
|
maxcpu = virNodeGetCPUMap(conn, NULL, NULL, 0);
|
480
|
-
#endif
|
481
484
|
if (maxcpu < 0) {
|
482
485
|
/* fall back to nodeinfo */
|
483
486
|
ruby_libvirt_raise_error_if(virNodeGetInfo(conn, &nodeinfo) < 0,
|