ruby-libvirt 0.8.1 → 0.8.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fee786f1797ab1c5a5e8d496b387667786a5f703872a29125fbc0d43f6737b4b
4
- data.tar.gz: e79852df639e0ff830afae0918e2e5e3754e555eb2db8c9641b38cb834793091
3
+ metadata.gz: cedabfb7ce30484b1ee1781d9c54eecc102f3a02ae4e8bb3939dc76048db072d
4
+ data.tar.gz: a5bbc0558a140785b26f7687b3d155767f2813baa51271d7114ff7389761755d
5
5
  SHA512:
6
- metadata.gz: f927ee0ed89539c2db5ae8aa955d4e03960b770e511bec78b5e46972ccc61f8e3d6bcf1d5c34efa84b3573b9f55365bdb6be52534ad7e3777b6d6b926d5001da
7
- data.tar.gz: 933864259c5b508f6956de0c5f99ba3a9ba3c741863e9f9e74fbe2d433f83e68fbf650725598f0c41c3df3c9abe51f3a717ccd27da547a57d359b86071379e03
6
+ metadata.gz: 61db9b3ab4593e7712a96bd740aaf2c4ef825605a6773038f679f120e62f08dc9052421fd0b1b67a98e3d34593f93ef90df7f3fdb09cc34174ba2ececd75062f
7
+ data.tar.gz: 6d8821193b57518149efcda6d2a14c6eadc06895e7388f9b344ae28f56529e4ee70623fcea2fb70683e4541f15e4e72e5baa8071c17bf54cfb2c7273a1174d2e
data/NEWS.rst ADDED
@@ -0,0 +1,229 @@
1
+ =====================
2
+ ruby-libvirt releases
3
+ =====================
4
+
5
+
6
+ 0.8.3 (2024-05-13)
7
+ ==================
8
+
9
+ * Fix runtime warnings with Ruby >= 3.2
10
+ * Improve build system
11
+ * Improve website
12
+
13
+
14
+ 0.8.2 (2024-02-09)
15
+ ==================
16
+
17
+ * Fix ``StoragePool#list_all_volumes``
18
+ * Fix regression in ``Domain#attach_device`` and ``Domain#detach_device``
19
+
20
+
21
+ 0.8.1 (2024-02-08)
22
+ ==================
23
+
24
+ * Add missing ``virDomainUndefineFlagsValues`` constants
25
+ * Require libvirt 2.0.0
26
+ * Always use pkg-config for detecting libvirt
27
+ * Drop most compile-time feature checks
28
+
29
+
30
+ 0.8.0 (2021-11-15)
31
+ ==================
32
+
33
+ * Fix default values for ``node_cpu_stats`` and ``node_memory_stats``
34
+ * Fix cpumap allocation for ``virDomainGetVcpus``
35
+ * Enforce UTF8 for strings and exceptions
36
+ * Drop local ``have_const``
37
+ * Use sensible default for ``libvirt_domain_qemu_agent_command``
38
+
39
+
40
+ 0.7.1 (2018-02-18)
41
+ ==================
42
+
43
+ * Fix a bad bug in block_resize (Marius Rieder)
44
+ * Fix up some problems pointed out by clang
45
+ * Fix up the tests for small semantic differences in how libvirt works
46
+
47
+
48
+ 0.7.0 (2016-09-22)
49
+ ==================
50
+
51
+ * Fix network lease API to allow arguments that libvirt allows
52
+ * Implement ``VIRT_STORAGE_POOL_CREATE`` flags
53
+ * Implement more ``VIR_STORAGE_VOL`` flags
54
+ * Implement ``VIR_DOMAIN_QEMU_AGENT_COMMAND_SHUTDOWN``
55
+ * Implement ``virDomainDefineXMLFlags``
56
+ * Implement ``virDomainRename``
57
+ * Implement ``virDomainSetUserPassword``
58
+ * Implement ``VIR_DOMAIN_TIME_SYNC``
59
+ * Fix the return value from ``virStreamSourceFunc`` so volume upload works
60
+
61
+
62
+ 0.6.0 (2015-11-20)
63
+ ==================
64
+
65
+ * Fix possible buffer overflow
66
+ * Fix storage volume creation error messages
67
+ * Add additional storage pool defines
68
+ * Implement ``Network#dhcp_leases`` method
69
+ * Implement ``Connect#node_alloc_pages`` method
70
+ * Implement ``Domain#time`` method
71
+ * Implement ``Connect#domain_capabilities`` method
72
+ * Implement ``Domain#core_dump_with_format`` method
73
+ * Implement ``Domain#fs_freeze`` method
74
+ * Implement ``Domain#fs_info`` method
75
+ * Implement ``Connect#node_free_pages`` method
76
+
77
+
78
+ 0.5.2 (2014-01-08)
79
+ ==================
80
+
81
+ * Fix to make sure we don't free more entires than retrieved
82
+
83
+
84
+ 0.5.1 (2013-12-15)
85
+ ==================
86
+
87
+ * Fixes to compile against older libvirt
88
+ * Fixes to compile against ruby 1.8
89
+
90
+
91
+ 0.5.0 (2013-12-09)
92
+ ==================
93
+
94
+ * Updated ``Network`` class, implementing almost all libvirt APIs
95
+ * Updated ``Domain`` class, implementing almost all libvirt APIs
96
+ * Updated ``Connection`` class, implementing almost all libvirt APIs
97
+ * Updated ``DomainSnapshot`` class, implementing almost all libvirt APIs
98
+ * Updated ``NodeDevice`` class, implementing almost all libvirt APIs
99
+ * Updated ``Storage`` class, implementing almost all libvirt APIs
100
+ * Add constants for almost all libvirt defines
101
+ * Improved performance in the library by using alloca
102
+
103
+
104
+ 0.4.0 (2011-07-27)
105
+ ==================
106
+
107
+ * Updated ``Domain`` class, implementing ``dom.memory_parameters=``,
108
+ ``dom.memory_parameters``, ``dom.updated?``, ``dom.migrate2``,
109
+ ``dom.migrate_to_uri2``, ``dom.migrate_set_max_speed``,
110
+ ``dom.qemu_monitor_command``, ``dom.blkio_parameters``,
111
+ ``dom.blkio_parameters=``, ``dom.state``, ``dom.open_console``,
112
+ ``dom.screenshot`` and ``dom.inject_nmi``
113
+ * Implementation of the ``Stream`` class, which covers the libvirt
114
+ ``virStream`` APIs
115
+ * Add the ability to build against non-system libvirt libraries
116
+ * Updated ``Error`` object, which now includes the libvirt code, component and
117
+ level of the error, as well as all of the error constants from ``libvirt.h``
118
+ * Updated ``Connect`` class, implementing ``conn.sys_info``, ``conn.stream``,
119
+ ``conn.interface_change_begin``, ``conn.interface_change_commit`` and
120
+ ``conn.interface_change_rollback``
121
+ * Updated ``StorageVol`` class, implementing ``vol.download`` and
122
+ ``vol.upload``
123
+ * Various bugfixes
124
+
125
+
126
+ 0.3.0 (2010-12-12)
127
+ ==================
128
+
129
+ * Implementation of ``Libvirt::open_auth``, ``Libvirt::event_register_impl``
130
+ * Updated ``Connect`` class, implementing ``conn.compare_cpu``,
131
+ ``conn.baseline_cpu``, ``conn.domain_event_register_any``,
132
+ ``conn.domain_event_deregister_any``, ``conn.domain_event_register``,
133
+ ``conn.domain_event_deregister`` and ``conn.create_domain_xml``
134
+ * Updated ``Domain`` class, implementing ``dom.get_vcpus``,
135
+ ``dom.update_device``, ``dom.scheduler_type``, ``dom.scheduler_parameters``,
136
+ ``dom.scheduler_parameters=``, ``dom.num_vcpus``, ``dom.vcpus_flags=`` and
137
+ ``dom.qemu_monitor_command``
138
+ * Updated ``Interface`` class, implementing ``interface.free``
139
+ * Many potential memory leaks have been fixed
140
+ * Many bugfixes
141
+ * Documentation update of many methods, including all of the lookup methods
142
+ that were missing before
143
+
144
+
145
+ 0.2.0 (2010-07-01)
146
+ ==================
147
+
148
+ * Updated ``Storage`` class, implementing ``pool.active?``,
149
+ ``pool.persistent?`` and ``pool.vol_create_xml_from``
150
+ * Updated ``Connect`` class, implementing ``conn.node_free_memory``,
151
+ ``conn.node_cells_free_memory``, ``conn.node_get_security_model``,
152
+ ``conn.encrypted?``, ``conn.libversion`` and ``conn.secure?``
153
+ * Updated ``Network`` class, implementing ``net.active?`` and
154
+ ``net.persistent?``
155
+ * Update ``Domain`` class, implementing ``conn.domain_xml_from_native``,
156
+ ``conn.domain_xml_to_native``, ``dom.migrate_to_uri``,
157
+ ``dom.migrate_set_max_downtime``, ``dom.managed_save``,
158
+ ``dom.has_managed_save?``, ``dom.managed_save_remove``,
159
+ ``dom.security_label``, ``dom.block_stats``, ``dom.memory_stats``,
160
+ ``dom.blockinfo``, ``dom.block_peek``, ``dom.memory_peek``, ``dom.active?``,
161
+ ``dom.persistent?``, ``dom.snapshot_create_xml``, ``dom.num_of_snapshots``,
162
+ ``dom.list_snapshots``, ``dom.lookup_snapshot_by_name``,
163
+ ``dom.has_current_snapshot?``, ``dom.revert_to_snapshot``,
164
+ ``dom.current_snapshot``, ``snapshot.xml_desc``, ``snapshot.delete``,
165
+ ``dom.job_info`` and ``dom.abort_job``
166
+ * Implementation of the ``NodeDevice`` class
167
+ * Implementation of the ``Secret`` class
168
+ * Implementation of the ``NWFilter`` class
169
+ * Implementation of the ``Interface`` class
170
+ * Conversion of the development tree to git
171
+ * New maintainer (Chris Lalancette). David Lutterkort has agreed to transfer
172
+ maintainership since he is not actively involved in their development
173
+ anymore
174
+
175
+
176
+ 0.1.0 (2008-11-18)
177
+ ==================
178
+
179
+ * Add binding for ``virConnectFindStoragePoolSources`` (Chris Lalancette)
180
+ * Fix ``dom_migrate`` (Chris Lalancette)
181
+ * Add the ``MIGRATE_LIVE`` (``enum virDomainMigrateFlags``) flag
182
+ * Slight improvements of the unit tests
183
+
184
+
185
+ 0.0.7 (2008-04-15)
186
+ ==================
187
+
188
+ * Binding for ``virDomainMigrate``
189
+ * Fix crash caused by using ``virResetError``
190
+ * More sensible message included in exceptions
191
+
192
+
193
+ 0.0.6 (2008-04-02)
194
+ ==================
195
+
196
+ * Fix test failure exposed by the Fedora builders
197
+
198
+
199
+ 0.0.5 (2008-04-02)
200
+ ==================
201
+
202
+ * Explicit free methods for various objects (based on a patch by Vadim Zaliva)
203
+ * Make the FLAGS argument for various calls optional, and default it to 0
204
+ (Chris Lalancette)
205
+ * More finegrained exceptions on errors, containing libvirt error message
206
+ (Mohammed Morsi)
207
+
208
+
209
+ 0.0.4 (2008-04-01)
210
+ ==================
211
+
212
+ * Bindings for the libvirt storage API (requires libvirt 0.4.1)
213
+ * Suppress some bindings if the underlying libvirt doesn't support it
214
+ * Bindings for ``virDomainSetMemory``, ``virDomainPinVcpu`` and
215
+ ``virDomainSetVcpus`` (Vadim Zaliva)
216
+
217
+
218
+ 0.0.2 (2007-12-06)
219
+ ==================
220
+
221
+ * Add ``virNodeGetInfo`` binding
222
+ * Convert Ruby API from StudlyCaps to under_score_separation, since that's
223
+ the Ruby convention
224
+
225
+
226
+ 0.0.1 (2007-11-19)
227
+ ==================
228
+
229
+ * Initial release
data/README.rst ADDED
@@ -0,0 +1,45 @@
1
+ ============
2
+ ruby-libvirt
3
+ ============
4
+
5
+ Ruby bindings for `libvirt <https://libvirt.org/>`__.
6
+
7
+
8
+ Usage
9
+ =====
10
+
11
+ Add ``require 'libvirt'`` to your program, then call
12
+ ``Libvirt::open`` or ``Libvirt::open_read_only`` to obtain a
13
+ connection.
14
+
15
+ See ``examples/*.rb`` and ``tests/*.rb`` for more examples.
16
+
17
+
18
+ Hacking
19
+ =======
20
+
21
+ On a Fedora machine, run
22
+
23
+ ::
24
+
25
+ $ yum install libvirt-devel ruby-devel rubygem-rake
26
+
27
+ followed by
28
+
29
+ ::
30
+
31
+ $ rake build
32
+
33
+ To run code against the bindings without having to install them
34
+ first, ``$RUBYLIB`` needs to be set appropriately. For example:
35
+
36
+ ::
37
+
38
+ $ export RUBYLIB="lib:ext/libvirt"
39
+ $ ruby -rlibvirt -e 'puts Libvirt::version[0]'
40
+
41
+
42
+ Contributing
43
+ ============
44
+
45
+ See `CONTRIBUTING.rst <CONTRIBUTING.rst>`__.
data/Rakefile CHANGED
@@ -11,75 +11,96 @@
11
11
 
12
12
  # Rakefile for ruby-rpm -*- ruby -*-
13
13
  require 'rake/clean'
14
- begin
15
- require 'rdoc/task'
16
- rescue LoadError
17
- require 'rake/rdoctask'
18
- end
19
14
  require 'rake/testtask'
15
+ require 'rdoc/task'
20
16
  require 'rubygems/package_task'
21
- require 'rbconfig'
22
17
 
23
18
  PKG_NAME='ruby-libvirt'
24
- PKG_VERSION='0.8.1'
25
-
26
- EXT_CONF='ext/libvirt/extconf.rb'
27
- MAKEFILE="ext/libvirt/Makefile"
28
- LIBVIRT_MODULE="ext/libvirt/_libvirt.so"
29
- SPEC_FILE="ruby-libvirt.spec"
30
- LIBVIRT_SRC=Dir.glob("ext/libvirt/*.c")
31
- LIBVIRT_SRC << MAKEFILE
19
+ PKG_VERSION='0.8.3'
20
+
21
+ EXT_DIR = "ext/libvirt"
22
+ EXTCONF = "#{EXT_DIR}/extconf.rb"
23
+ MAKEFILE = "#{EXT_DIR}/Makefile"
24
+ LIBVIRT_MODULE = "#{EXT_DIR}/_libvirt.so"
25
+ SPEC_FILE = "#{PKG_NAME}.spec"
26
+ SRC_FILES = FileList[
27
+ "#{EXT_DIR}/_libvirt.c",
28
+ "#{EXT_DIR}/common.c",
29
+ "#{EXT_DIR}/common.h",
30
+ "#{EXT_DIR}/connect.c",
31
+ "#{EXT_DIR}/connect.h",
32
+ "#{EXT_DIR}/domain.c",
33
+ "#{EXT_DIR}/domain.h",
34
+ "#{EXT_DIR}/interface.c",
35
+ "#{EXT_DIR}/interface.h",
36
+ "#{EXT_DIR}/network.c",
37
+ "#{EXT_DIR}/network.h",
38
+ "#{EXT_DIR}/nodedevice.c",
39
+ "#{EXT_DIR}/nodedevice.h",
40
+ "#{EXT_DIR}/nwfilter.c",
41
+ "#{EXT_DIR}/nwfilter.h",
42
+ "#{EXT_DIR}/secret.c",
43
+ "#{EXT_DIR}/secret.h",
44
+ "#{EXT_DIR}/storage.c",
45
+ "#{EXT_DIR}/storage.h",
46
+ "#{EXT_DIR}/stream.c",
47
+ "#{EXT_DIR}/stream.h",
48
+ ]
49
+ LIB_FILES = FileList[
50
+ "lib/libvirt.rb",
51
+ ]
52
+ GEN_FILES = FileList[
53
+ MAKEFILE,
54
+ "#{EXT_DIR}/extconf.h",
55
+ ]
32
56
 
33
57
  #
34
58
  # Additional files for clean/clobber
35
59
  #
36
60
 
37
- CLEAN.include [ "ext/**/*.o", LIBVIRT_MODULE, "ext/**/depend", "ext/**/*.gcda",
38
- "ext/**/*.gcno", "ext/**/*.gcov" ]
39
-
40
- CLOBBER.include [ "ext/**/mkmf.log", "ext/**/extconf.h", MAKEFILE ]
41
-
42
- task :default => :build
61
+ CLEAN.include [ "#{EXT_DIR}/*.o", LIBVIRT_MODULE ]
62
+ CLOBBER.include [ "#{EXT_DIR}/mkmf.log" ] + GEN_FILES
43
63
 
44
64
  #
45
65
  # Build locally
46
66
  #
47
- file MAKEFILE => EXT_CONF do |t|
48
- Dir::chdir(File::dirname(EXT_CONF)) do
49
- extra = ""
50
- args = ARGV.grep(/^--with-libvirt-include=/)
51
- extra += args[0].chomp unless args.empty?
52
- args = ARGV.grep(/^--with-libvirt-lib=/)
53
- extra += " " + args[0].chomp unless args.empty?
54
-
55
- unless sh "ruby #{File::basename(EXT_CONF)} #{extra}"
56
- $stderr.puts "Failed to run extconf"
57
- break
58
- end
67
+
68
+ task :default => :build
69
+
70
+ file MAKEFILE => EXTCONF do |t|
71
+ Dir::chdir(File::dirname(EXTCONF)) do
72
+ sh "ruby #{File::basename(EXTCONF)}"
59
73
  end
60
74
  end
61
- file LIBVIRT_MODULE => LIBVIRT_SRC do |t|
62
- Dir::chdir(File::dirname(EXT_CONF)) do
63
- unless sh "make"
64
- $stderr.puts "make failed"
65
- break
66
- end
67
- end
75
+ file LIBVIRT_MODULE => SRC_FILES + [ MAKEFILE ] do |t|
76
+ Dir::chdir(File::dirname(EXTCONF)) do
77
+ sh "make"
78
+ end
68
79
  end
69
80
  desc "Build the native library"
70
81
  task :build => LIBVIRT_MODULE
71
82
 
72
83
  #
73
- # Test task
84
+ # Test tasks
74
85
  #
75
86
 
87
+ TEST_FILES = FileList[
88
+ "tests/test_conn.rb",
89
+ "tests/test_domain.rb",
90
+ "tests/test_interface.rb",
91
+ "tests/test_network.rb",
92
+ "tests/test_nodedevice.rb",
93
+ "tests/test_nwfilter.rb",
94
+ "tests/test_open.rb",
95
+ "tests/test_secret.rb",
96
+ "tests/test_storage.rb",
97
+ "tests/test_stream.rb",
98
+ "tests/test_utils.rb",
99
+ ]
100
+
76
101
  Rake::TestTask.new(:test) do |t|
77
- t.test_files = [ 'tests/test_conn.rb', 'tests/test_domain.rb',
78
- 'tests/test_interface.rb', 'tests/test_network.rb',
79
- 'tests/test_nodedevice.rb', 'tests/test_nwfilter.rb',
80
- 'tests/test_open.rb', 'tests/test_secret.rb',
81
- 'tests/test_storage.rb', 'tests/test_stream.rb' ]
82
- t.libs = [ 'lib', 'ext/libvirt' ]
102
+ t.test_files = TEST_FILES
103
+ t.libs << EXT_DIR
83
104
  end
84
105
  task :test => :build
85
106
 
@@ -87,65 +108,55 @@ task :test => :build
87
108
  # Documentation tasks
88
109
  #
89
110
 
90
- RDOC_FILES = FileList[ "README.rdoc", "lib/libvirt.rb",
91
- "ext/libvirt/_libvirt.c", "ext/libvirt/connect.c",
92
- "ext/libvirt/domain.c", "ext/libvirt/interface.c",
93
- "ext/libvirt/network.c", "ext/libvirt/nodedevice.c",
94
- "ext/libvirt/nwfilter.c", "ext/libvirt/secret.c",
95
- "ext/libvirt/storage.c", "ext/libvirt/stream.c" ]
111
+ RDOC_MAIN = "doc/main.rdoc"
112
+ RDOC_FILES = FileList[ RDOC_MAIN ] + SRC_FILES + LIB_FILES
96
113
 
97
- Rake::RDocTask.new do |rd|
98
- rd.main = "README.rdoc"
114
+ RDoc::Task.new do |rd|
115
+ rd.main = RDOC_MAIN
99
116
  rd.rdoc_dir = "doc/site/api"
100
117
  rd.rdoc_files.include(RDOC_FILES)
101
118
  end
102
119
 
103
- Rake::RDocTask.new(:ri) do |rd|
104
- rd.main = "README.rdoc"
120
+ RDoc::Task.new(:ri) do |rd|
121
+ rd.main = RDOC_MAIN
105
122
  rd.rdoc_dir = "doc/ri"
106
123
  rd.options << "--ri-system"
107
124
  rd.rdoc_files.include(RDOC_FILES)
108
125
  end
109
126
 
110
- #
111
- # Splint task
112
- #
113
-
114
- task :splint => [ MAKEFILE ] do |t|
115
- Dir::chdir(File::dirname(EXT_CONF)) do
116
- unless sh "splint -I" + Config::CONFIG['vendorarchdir'] + " *.c"
117
- $stderr.puts "Failed to run splint"
118
- break
119
- end
120
- end
121
- end
122
-
123
127
  #
124
128
  # Package tasks
125
129
  #
126
130
 
127
- PKG_FILES = FileList[ "Rakefile", "COPYING", "README", "NEWS", "README.rdoc",
128
- "lib/**/*.rb",
129
- "ext/**/*.[ch]", "ext/**/MANIFEST", "ext/**/extconf.rb",
130
- "tests/**/*",
131
- "spec/**/*" ]
132
-
133
- DIST_FILES = FileList[ "pkg/*.src.rpm", "pkg/*.gem", "pkg/*.zip",
134
- "pkg/*.tgz" ]
131
+ PKG_FILES = FileList[
132
+ "Rakefile",
133
+ "COPYING",
134
+ "README.rst",
135
+ "NEWS.rst",
136
+ EXTCONF,
137
+ RDOC_MAIN,
138
+ ] + SRC_FILES + LIB_FILES + TEST_FILES
135
139
 
136
140
  SPEC = Gem::Specification.new do |s|
137
141
  s.name = PKG_NAME
138
142
  s.version = PKG_VERSION
139
- s.email = "libvir-list@redhat.com"
140
- s.homepage = "https://ruby.libvirt.org/"
141
- s.summary = "Ruby bindings for LIBVIRT"
142
143
  s.files = PKG_FILES
143
- s.required_ruby_version = '>= 1.8.1'
144
- s.extensions = "ext/libvirt/extconf.rb"
145
- s.author = "David Lutterkort, Chris Lalancette"
146
- s.rubyforge_project = "None"
147
- s.description = "Ruby bindings for libvirt."
144
+ s.extensions = EXTCONF
145
+ s.required_ruby_version = ">= 1.8.1"
146
+ s.summary = "Ruby bindings for libvirt"
147
+ s.description = <<~EOF
148
+ ruby-libvirt allows applications written in Ruby to use the
149
+ libvirt API.
150
+ EOF
151
+ s.authors = ["David Lutterkort", "Chris Lalancette"]
148
152
  s.license = "LGPL-2.1-or-later"
153
+ s.email = "devel@lists.libvirt.org"
154
+ s.homepage = "https://ruby.libvirt.org/"
155
+ s.metadata = {
156
+ "source_code_uri" => "https://gitlab.com/libvirt/libvirt-ruby",
157
+ "bug_tracker_uri" => "https://gitlab.com/libvirt/libvirt-ruby/-/issues",
158
+ "documentation_uri" => "https://ruby.libvirt.org/api/index.html",
159
+ }
149
160
  end
150
161
 
151
162
  Gem::PackageTask.new(SPEC) do |pkg|
@@ -155,12 +166,22 @@ end
155
166
 
156
167
  desc "Build (S)RPM for #{PKG_NAME}"
157
168
  task :rpm => [ :package ] do |t|
158
- system("sed -e 's/@VERSION@/#{PKG_VERSION}/' #{SPEC_FILE} > pkg/#{SPEC_FILE}")
159
- Dir::chdir("pkg") do |dir|
160
- dir = File::expand_path(".")
161
- system("rpmbuild --define '_topdir #{dir}' --define '_sourcedir #{dir}' --define '_srcrpmdir #{dir}' --define '_rpmdir #{dir}' --define '_builddir #{dir}' -ba #{SPEC_FILE} > rpmbuild.log 2>&1")
162
- if $? != 0
163
- raise "rpmbuild failed"
164
- end
165
- end
169
+ pkg_dir = File::expand_path("pkg")
170
+ sed = [
171
+ "sed",
172
+ "-e", "'s/@VERSION@/#{PKG_VERSION}/'",
173
+ "#{SPEC_FILE}.in", ">#{pkg_dir}/#{SPEC_FILE}",
174
+ ]
175
+ sh sed.join(" ")
176
+ rpmbuild = [
177
+ "rpmbuild",
178
+ "--clean",
179
+ "--define", "'_topdir #{pkg_dir}'",
180
+ "--define", "'_sourcedir #{pkg_dir}'",
181
+ "--define", "'_srcrpmdir #{pkg_dir}'",
182
+ "--define", "'_rpmdir #{pkg_dir}'",
183
+ "--define", "'_builddir #{pkg_dir}'",
184
+ "-ba", "#{pkg_dir}/#{SPEC_FILE}",
185
+ ]
186
+ sh rpmbuild.join(" ")
166
187
  end
@@ -2741,6 +2741,7 @@ static VALUE libvirt_connect_node_free_pages(int argc, VALUE *argv, VALUE c)
2741
2741
  void ruby_libvirt_connect_init(void)
2742
2742
  {
2743
2743
  c_connect = rb_define_class_under(m_libvirt, "Connect", rb_cObject);
2744
+ rb_undef_alloc_func(c_connect);
2744
2745
 
2745
2746
  /*
2746
2747
  * Class Libvirt::Connect::Nodeinfo
data/ext/libvirt/domain.c CHANGED
@@ -1232,7 +1232,7 @@ static VALUE libvirt_domain_autostart_equal(VALUE d, VALUE autostart)
1232
1232
  * call-seq:
1233
1233
  * dom.attach_device(device_xml, flags=0) -> nil
1234
1234
  *
1235
- * Call virDomainAttachDevice[https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainAttachDevice]
1235
+ * Call virDomainAttachDeviceFlags[https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainAttachDeviceFlags]
1236
1236
  * to attach the device described by the device_xml to the domain.
1237
1237
  */
1238
1238
  static VALUE libvirt_domain_attach_device(int argc, VALUE *argv, VALUE d)
@@ -1241,25 +1241,23 @@ static VALUE libvirt_domain_attach_device(int argc, VALUE *argv, VALUE d)
1241
1241
 
1242
1242
  rb_scan_args(argc, argv, "11", &xml, &flags);
1243
1243
 
1244
- if (ruby_libvirt_value_to_uint(flags) != 0) {
1245
- ruby_libvirt_generate_call_nil(virDomainAttachDeviceFlags,
1246
- ruby_libvirt_connect_get(d),
1247
- ruby_libvirt_domain_get(d),
1248
- StringValueCStr(xml),
1249
- ruby_libvirt_value_to_uint(flags));
1250
- } else {
1251
- ruby_libvirt_generate_call_nil(virDomainAttachDevice,
1252
- ruby_libvirt_connect_get(d),
1253
- ruby_libvirt_domain_get(d),
1254
- StringValueCStr(xml));
1255
- }
1244
+ /* NOTE: can't use virDomainAttachDevice() when flags==0 here
1245
+ * because that function only works on active domains and
1246
+ * VIR_DOMAIN_AFFECT_CURRENT==0.
1247
+ *
1248
+ * See https://gitlab.com/libvirt/libvirt-ruby/-/issues/11 */
1249
+ ruby_libvirt_generate_call_nil(virDomainAttachDeviceFlags,
1250
+ ruby_libvirt_connect_get(d),
1251
+ ruby_libvirt_domain_get(d),
1252
+ StringValueCStr(xml),
1253
+ ruby_libvirt_value_to_uint(flags));
1256
1254
  }
1257
1255
 
1258
1256
  /*
1259
1257
  * call-seq:
1260
1258
  * dom.detach_device(device_xml, flags=0) -> nil
1261
1259
  *
1262
- * Call virDomainDetachDevice[https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainDetachDevice]
1260
+ * Call virDomainDetachDeviceFlags[https://libvirt.org/html/libvirt-libvirt-domain.html#virDomainDetachDeviceFlags]
1263
1261
  * to detach the device described by the device_xml from the domain.
1264
1262
  */
1265
1263
  static VALUE libvirt_domain_detach_device(int argc, VALUE *argv, VALUE d)
@@ -1268,18 +1266,16 @@ static VALUE libvirt_domain_detach_device(int argc, VALUE *argv, VALUE d)
1268
1266
 
1269
1267
  rb_scan_args(argc, argv, "11", &xml, &flags);
1270
1268
 
1271
- if (ruby_libvirt_value_to_uint(flags) != 0) {
1272
- ruby_libvirt_generate_call_nil(virDomainDetachDeviceFlags,
1273
- ruby_libvirt_connect_get(d),
1274
- ruby_libvirt_domain_get(d),
1275
- StringValueCStr(xml),
1276
- ruby_libvirt_value_to_uint(flags));
1277
- } else {
1278
- ruby_libvirt_generate_call_nil(virDomainDetachDevice,
1279
- ruby_libvirt_connect_get(d),
1280
- ruby_libvirt_domain_get(d),
1281
- StringValueCStr(xml));
1282
- }
1269
+ /* NOTE: can't use virDomainDetachDevice() when flags==0 here
1270
+ * because that function only works on active domains and
1271
+ * VIR_DOMAIN_AFFECT_CURRENT==0.
1272
+ *
1273
+ * See https://gitlab.com/libvirt/libvirt-ruby/-/issues/11 */
1274
+ ruby_libvirt_generate_call_nil(virDomainDetachDeviceFlags,
1275
+ ruby_libvirt_connect_get(d),
1276
+ ruby_libvirt_domain_get(d),
1277
+ StringValueCStr(xml),
1278
+ ruby_libvirt_value_to_uint(flags));
1283
1279
  }
1284
1280
 
1285
1281
  /*
@@ -4067,6 +4063,7 @@ static VALUE libvirt_domain_user_password_equal(VALUE d, VALUE in)
4067
4063
  void ruby_libvirt_domain_init(void)
4068
4064
  {
4069
4065
  c_domain = rb_define_class_under(m_libvirt, "Domain", rb_cObject);
4066
+ rb_undef_alloc_func(c_domain);
4070
4067
 
4071
4068
  rb_define_const(c_domain, "NOSTATE", INT2NUM(VIR_DOMAIN_NOSTATE));
4072
4069
  rb_define_const(c_domain, "RUNNING", INT2NUM(VIR_DOMAIN_RUNNING));
@@ -4392,6 +4389,8 @@ void ruby_libvirt_domain_init(void)
4392
4389
  * Class Libvirt::Domain::Snapshot
4393
4390
  */
4394
4391
  c_domain_snapshot = rb_define_class_under(c_domain, "Snapshot", rb_cObject);
4392
+ rb_undef_alloc_func(c_domain_snapshot);
4393
+
4395
4394
  rb_define_const(c_domain_snapshot, "DELETE_CHILDREN",
4396
4395
  INT2NUM(VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN));
4397
4396
  rb_define_method(c_domain_snapshot, "xml_desc",
@@ -174,6 +174,8 @@ static VALUE libvirt_interface_free(VALUE i)
174
174
  void ruby_libvirt_interface_init(void)
175
175
  {
176
176
  c_interface = rb_define_class_under(m_libvirt, "Interface", rb_cObject);
177
+ rb_undef_alloc_func(c_interface);
178
+
177
179
  rb_define_const(c_interface, "XML_INACTIVE",
178
180
  INT2NUM(VIR_INTERFACE_XML_INACTIVE));
179
181
  rb_define_attr(c_interface, "connection", 1, 0);
@@ -329,6 +329,8 @@ static VALUE libvirt_network_get_dhcp_leases(int argc, VALUE *argv, VALUE n)
329
329
  void ruby_libvirt_network_init(void)
330
330
  {
331
331
  c_network = rb_define_class_under(m_libvirt, "Network", rb_cObject);
332
+ rb_undef_alloc_func(c_network);
333
+
332
334
  rb_define_attr(c_network, "connection", 1, 0);
333
335
 
334
336
  rb_define_method(c_network, "undefine", libvirt_network_undefine, 0);