ruby-libvirt 0.5.2 → 0.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: fbcf087680f4524b1c5e1faba3dfad5bbc22f281
4
- data.tar.gz: 298b6f117bd8b15acc809c70954b38341d7ace4c
3
+ metadata.gz: 3ce28a7acf62c75daca90571b9d7cc7beb97840b
4
+ data.tar.gz: be65964253ac857f6c13d0d911328fc85d324bfd
5
5
  SHA512:
6
- metadata.gz: 9d8508cf6a4033efb7d0fb19451f19ed8efc79ebfd4ecfd6e601f7c1504d1007ce729da33245aab5d6563ae85e42cb98656f5b83091c049392af12f4d80eee4f
7
- data.tar.gz: 0151aa217bfa464c7f08755b8d586e262b89ce196ac26c0024b0c8741cc1043a93c8ed70eb2ec082fd21dea3bdea5899cf5766c4ae86dbb478841bbe8c18c58a
6
+ metadata.gz: a0528322015406a30845559328ee61d150b5048d3c49db7c70bc4a973af46d43c28dfbb926d3897dcafccedd1b0c67f6aef63110ba8835927fbe82df544bd568
7
+ data.tar.gz: 73fec1c760666644057b4c2361641f042e236f299f91b98aae79f89dcab1005bb74686122929e64c06722da55c0d24e9d09e3ea1a0fb87a7eafbaddb3103ba89
data/NEWS CHANGED
@@ -1,7 +1,20 @@
1
- 2014-01-08
1
+ 2015-11-20 0.6.0
2
+ * Fix possible buffer overflow
3
+ * Fix storage volume creation error messages
4
+ * Add additional storage pool defines
5
+ * Implement Network dhcp_leases method
6
+ * Implement Connect node_alloc_pages method
7
+ * Implement Domain time method
8
+ * Implement Connect domain_capabilities method
9
+ * Implement Domain core_dump_with_format method
10
+ * Implement Domain fs_freeze method
11
+ * Implement Domain fs_info method
12
+ * Implement Connect node_free_pages method
13
+
14
+ 2014-01-08 0.5.2
2
15
  * Fix to make sure we don't free more entires than retrieved
3
16
 
4
- 2013-12-15
17
+ 2013-12-15 0.5.1
5
18
  * Fixes to compile against older libvirt
6
19
  * Fixes to compile against ruby 1.8
7
20
 
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.5.2'
24
+ PKG_VERSION='0.6.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 [ "config.save", "ext/**/mkmf.log", "ext/**/extconf.h",
41
- MAKEFILE ]
40
+ CLOBBER.include [ "ext/**/mkmf.log", "ext/**/extconf.h", MAKEFILE ]
42
41
 
43
42
  task :default => :build
44
43
 
@@ -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,2014 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
@@ -84,6 +84,15 @@ VALUE ruby_libvirt_hash_aset_wrap(VALUE arg)
84
84
  return rb_hash_aset(e->hash, rb_str_new2(e->name), e->val);
85
85
  }
86
86
 
87
+ VALUE ruby_libvirt_str_new2_and_ary_store_wrap(VALUE arg)
88
+ {
89
+ struct ruby_libvirt_str_new2_and_ary_store_arg *e = (struct ruby_libvirt_str_new2_and_ary_store_arg *)arg;
90
+
91
+ rb_ary_store(e->arr, e->index, rb_str_new2(e->value));
92
+
93
+ return Qnil;
94
+ }
95
+
87
96
  void ruby_libvirt_raise_error_if(const int condition, VALUE error,
88
97
  const char *method, virConnectPtr conn)
89
98
  {
@@ -186,7 +195,7 @@ VALUE ruby_libvirt_generate_list(int num, char **list)
186
195
  VALUE result;
187
196
  int exception = 0;
188
197
  int i, j;
189
- struct ruby_libvirt_ary_store_arg arg;
198
+ struct ruby_libvirt_str_new2_and_ary_store_arg arg;
190
199
 
191
200
  i = 0;
192
201
 
@@ -197,15 +206,13 @@ VALUE ruby_libvirt_generate_list(int num, char **list)
197
206
  for (i = 0; i < num; i++) {
198
207
  arg.arr = result;
199
208
  arg.index = i;
200
- arg.elem = rb_protect(ruby_libvirt_str_new2_wrap, (VALUE)&(list[i]),
201
- &exception);
202
- if (exception) {
203
- goto exception;
204
- }
205
- rb_protect(ruby_libvirt_ary_store_wrap, (VALUE)&arg, &exception);
209
+ arg.value = list[i];
210
+ rb_protect(ruby_libvirt_str_new2_and_ary_store_wrap, (VALUE)&arg,
211
+ &exception);
206
212
  if (exception) {
207
213
  goto exception;
208
214
  }
215
+
209
216
  xfree(list[i]);
210
217
  }
211
218
 
@@ -373,8 +380,10 @@ int ruby_libvirt_typed_parameter_assign(VALUE key, VALUE val, VALUE in)
373
380
  default:
374
381
  rb_raise(rb_eArgError, "Invalid parameter type");
375
382
  }
383
+ /* ensure that the field is NULL-terminated */
384
+ args->params[args->i].field[VIR_TYPED_PARAM_FIELD_LENGTH - 1] = '\0';
376
385
  strncpy(args->params[args->i].field, keyname,
377
- VIR_TYPED_PARAM_FIELD_LENGTH);
386
+ VIR_TYPED_PARAM_FIELD_LENGTH - 1);
378
387
  (args->i)++;
379
388
  found = 1;
380
389
  break;
@@ -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
@@ -2,7 +2,7 @@
2
2
  * connect.c: virConnect methods
3
3
  *
4
4
  * Copyright (C) 2007,2010 Red Hat Inc.
5
- * Copyright (C) 2013 Chris Lalancette <clalancette@gmail.com>
5
+ * Copyright (C) 2013,2014 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
@@ -143,7 +143,7 @@ static VALUE libvirt_connect_closed_p(VALUE c)
143
143
 
144
144
  /*
145
145
  * call-seq:
146
- * conn.type -> string
146
+ * conn.type -> String
147
147
  *
148
148
  * Call virConnectGetType[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectGetType]
149
149
  * to retrieve the type of hypervisor for this connection.
@@ -157,7 +157,7 @@ static VALUE libvirt_connect_type(VALUE c)
157
157
 
158
158
  /*
159
159
  * call-seq:
160
- * conn.version -> fixnum
160
+ * conn.version -> Fixnum
161
161
  *
162
162
  * Call virConnectGetVersion[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectGetVersion]
163
163
  * to retrieve the version of the hypervisor for this connection.
@@ -177,7 +177,7 @@ static VALUE libvirt_connect_version(VALUE c)
177
177
  #if HAVE_VIRCONNECTGETLIBVERSION
178
178
  /*
179
179
  * call-seq:
180
- * conn.libversion -> fixnum
180
+ * conn.libversion -> Fixnum
181
181
  *
182
182
  * Call virConnectGetLibVersion[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectGetLibVersion]
183
183
  * to retrieve the version of the libvirt library for this connection.
@@ -198,7 +198,7 @@ static VALUE libvirt_connect_libversion(VALUE c)
198
198
 
199
199
  /*
200
200
  * call-seq:
201
- * conn.hostname -> string
201
+ * conn.hostname -> String
202
202
  *
203
203
  * Call virConnectGetHostname[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectGetHostname]
204
204
  * to retrieve the hostname of the hypervisor for this connection.
@@ -212,7 +212,7 @@ static VALUE libvirt_connect_hostname(VALUE c)
212
212
 
213
213
  /*
214
214
  * call-seq:
215
- * conn.uri -> string
215
+ * conn.uri -> String
216
216
  *
217
217
  * Call virConnectGetURI[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectGetURI]
218
218
  * to retrieve the canonical URI for this connection.
@@ -226,7 +226,7 @@ static VALUE libvirt_connect_uri(VALUE c)
226
226
 
227
227
  /*
228
228
  * call-seq:
229
- * conn.max_vcpus(type=nil) -> fixnum
229
+ * conn.max_vcpus(type=nil) -> Fixnum
230
230
  *
231
231
  * Call virConnectGetMaxVcpus[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectGetMaxVcpus]
232
232
  * to retrieve the maximum number of virtual cpus supported by the hypervisor
@@ -276,7 +276,7 @@ static VALUE libvirt_connect_node_info(VALUE c)
276
276
 
277
277
  /*
278
278
  * call-seq:
279
- * conn.node_free_memory -> fixnum
279
+ * conn.node_free_memory -> Fixnum
280
280
  *
281
281
  * Call virNodeGetFreeMemory[http://www.libvirt.org/html/libvirt-libvirt.html#virNodeGetFreeMemory]
282
282
  * to retrieve the amount of free memory available on the host for this
@@ -408,7 +408,7 @@ static VALUE libvirt_connect_secure_p(VALUE c)
408
408
 
409
409
  /*
410
410
  * call-seq:
411
- * conn.capabilities -> string
411
+ * conn.capabilities -> String
412
412
  *
413
413
  * Call virConnectGetCapabilities[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectGetCapabilities]
414
414
  * to retrieve the capabilities XML for this connection.
@@ -786,7 +786,7 @@ static int domain_event_graphics_callback(virConnectPtr conn, virDomainPtr dom,
786
786
 
787
787
  /*
788
788
  * call-seq:
789
- * conn.domain_event_register_any(eventID, callback, dom=nil, opaque=nil) -> fixnum
789
+ * conn.domain_event_register_any(eventID, callback, dom=nil, opaque=nil) -> Fixnum
790
790
  *
791
791
  * Call virConnectDomainEventRegisterAny[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectDomainEventRegisterAny]
792
792
  * to register callback for eventID with libvirt. The eventID must be one of
@@ -958,7 +958,7 @@ static VALUE libvirt_connect_domain_event_deregister(VALUE c)
958
958
 
959
959
  /*
960
960
  * call-seq:
961
- * conn.num_of_domains -> fixnum
961
+ * conn.num_of_domains -> Fixnum
962
962
  *
963
963
  * Call virConnectNumOfDomains[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectNumOfDomains]
964
964
  * to retrieve the number of active domains on this connection.
@@ -1006,7 +1006,7 @@ static VALUE libvirt_connect_list_domains(VALUE c)
1006
1006
 
1007
1007
  /*
1008
1008
  * call-seq:
1009
- * conn.num_of_defined_domains -> fixnum
1009
+ * conn.num_of_defined_domains -> Fixnum
1010
1010
  *
1011
1011
  * Call virConnectNumOfDefinedDomains[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectNumOfDefinedDomains]
1012
1012
  * to retrieve the number of inactive domains on this connection.
@@ -1157,7 +1157,7 @@ static VALUE libvirt_connect_define_domain_xml(VALUE c, VALUE xml)
1157
1157
  #if HAVE_VIRCONNECTDOMAINXMLFROMNATIVE
1158
1158
  /*
1159
1159
  * call-seq:
1160
- * conn.domain_xml_from_native(nativeFormat, xml, flags=0) -> string
1160
+ * conn.domain_xml_from_native(nativeFormat, xml, flags=0) -> String
1161
1161
  *
1162
1162
  * Call virConnectDomainXMLFromNative[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectDomainXMLFromNative]
1163
1163
  * to convert a native hypervisor domain representation to libvirt XML.
@@ -1181,7 +1181,7 @@ static VALUE libvirt_connect_domain_xml_from_native(int argc, VALUE *argv,
1181
1181
  #if HAVE_VIRCONNECTDOMAINXMLTONATIVE
1182
1182
  /*
1183
1183
  * call-seq:
1184
- * conn.domain_xml_to_native(nativeFormat, xml, flags=0) -> string
1184
+ * conn.domain_xml_to_native(nativeFormat, xml, flags=0) -> String
1185
1185
  *
1186
1186
  * Call virConnectDomainXMLToNative[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectDomainXMLToNative]
1187
1187
  * to convert libvirt XML to a native domain hypervisor representation.
@@ -1205,7 +1205,7 @@ static VALUE libvirt_connect_domain_xml_to_native(int argc, VALUE *argv,
1205
1205
  #if HAVE_TYPE_VIRINTERFACEPTR
1206
1206
  /*
1207
1207
  * call-seq:
1208
- * conn.num_of_interfaces -> fixnum
1208
+ * conn.num_of_interfaces -> Fixnum
1209
1209
  *
1210
1210
  * Call virConnectNumOfInterfaces[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectNumOfInterfaces]
1211
1211
  * to retrieve the number of active interfaces on this connection.
@@ -1229,7 +1229,7 @@ static VALUE libvirt_connect_list_interfaces(VALUE c)
1229
1229
 
1230
1230
  /*
1231
1231
  * call-seq:
1232
- * conn.num_of_defined_interfaces -> fixnum
1232
+ * conn.num_of_defined_interfaces -> Fixnum
1233
1233
  *
1234
1234
  * Call virConnectNumOfDefinedInterfaces[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectNumOfDefinedInterfaces]
1235
1235
  * to retrieve the number of inactive interfaces on this connection.
@@ -1319,7 +1319,7 @@ static VALUE libvirt_connect_define_interface_xml(int argc, VALUE *argv,
1319
1319
 
1320
1320
  /*
1321
1321
  * call-seq:
1322
- * conn.num_of_networks -> fixnum
1322
+ * conn.num_of_networks -> Fixnum
1323
1323
  *
1324
1324
  * Call virConnectNumOfNetworks[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectNumOfNetworks]
1325
1325
  * to retrieve the number of active networks on this connection.
@@ -1343,7 +1343,7 @@ static VALUE libvirt_connect_list_networks(VALUE c)
1343
1343
 
1344
1344
  /*
1345
1345
  * call-seq:
1346
- * conn.num_of_defined_networks -> fixnum
1346
+ * conn.num_of_defined_networks -> Fixnum
1347
1347
  *
1348
1348
  * Call virConnectNumOfDefinedNetworks[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectNumOfDefinedNetworks]
1349
1349
  * to retrieve the number of inactive networks on this connection.
@@ -1448,7 +1448,7 @@ static VALUE libvirt_connect_define_network_xml(VALUE c, VALUE xml)
1448
1448
 
1449
1449
  /*
1450
1450
  * call-seq:
1451
- * conn.num_of_nodedevices(cap=nil, flags=0) -> fixnum
1451
+ * conn.num_of_nodedevices(cap=nil, flags=0) -> Fixnum
1452
1452
  *
1453
1453
  * Call virNodeNumOfDevices[http://www.libvirt.org/html/libvirt-libvirt.html#virNodeNumOfDevices]
1454
1454
  * to retrieve the number of node devices on this connection.
@@ -1564,7 +1564,7 @@ static VALUE libvirt_connect_create_nodedevice_xml(int argc, VALUE *argv,
1564
1564
 
1565
1565
  /*
1566
1566
  * call-seq:
1567
- * conn.num_of_nwfilters -> fixnum
1567
+ * conn.num_of_nwfilters -> Fixnum
1568
1568
  *
1569
1569
  * Call virConnectNumOfNWFilters[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectNumOfNWFilters]
1570
1570
  * to retrieve the number of network filters on this connection.
@@ -1651,7 +1651,7 @@ static VALUE libvirt_connect_define_nwfilter_xml(VALUE c, VALUE xml)
1651
1651
 
1652
1652
  /*
1653
1653
  * call-seq:
1654
- * conn.num_of_secrets -> fixnum
1654
+ * conn.num_of_secrets -> Fixnum
1655
1655
  *
1656
1656
  * Call virConnectNumOfSecrets[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectNumOfSecrets]
1657
1657
  * to retrieve the number of secrets on this connection.
@@ -1758,7 +1758,7 @@ static VALUE libvirt_connect_list_storage_pools(VALUE c)
1758
1758
 
1759
1759
  /*
1760
1760
  * call-seq:
1761
- * conn.num_of_storage_pools -> fixnum
1761
+ * conn.num_of_storage_pools -> Fixnum
1762
1762
  *
1763
1763
  * Call virConnectNumOfStoragePools[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectNumOfStoragePools]
1764
1764
  * to retrieve the number of active storage pools on this connection.
@@ -1782,7 +1782,7 @@ static VALUE libvirt_connect_list_defined_storage_pools(VALUE c)
1782
1782
 
1783
1783
  /*
1784
1784
  * call-seq:
1785
- * conn.num_of_defined_storage_pools -> fixnum
1785
+ * conn.num_of_defined_storage_pools -> Fixnum
1786
1786
  *
1787
1787
  * Call virConnectNumOfDefinedStoragePools[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectNumOfDefinedStoragePools]
1788
1788
  * to retrieve the number of inactive storage pools on this connection.
@@ -1882,7 +1882,7 @@ static VALUE libvirt_connect_define_pool_xml(int argc, VALUE *argv, VALUE c)
1882
1882
 
1883
1883
  /*
1884
1884
  * call-seq:
1885
- * conn.discover_storage_pool_sources(type, srcSpec=nil, flags=0) -> string
1885
+ * conn.discover_storage_pool_sources(type, srcSpec=nil, flags=0) -> String
1886
1886
  *
1887
1887
  * Call virConnectFindStoragePoolSources[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectFindStoragePoolSources]
1888
1888
  * to find the storage pool sources corresponding to type.
@@ -1906,7 +1906,7 @@ static VALUE libvirt_connect_find_storage_pool_sources(int argc, VALUE *argv,
1906
1906
  #if HAVE_VIRCONNECTGETSYSINFO
1907
1907
  /*
1908
1908
  * call-seq:
1909
- * conn.sys_info(flags=0) -> string
1909
+ * conn.sys_info(flags=0) -> String
1910
1910
  *
1911
1911
  * Call virConnectGetSysinfo[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectGetSysinfo]
1912
1912
  * to get machine-specific information about the hypervisor. This may include
@@ -2137,7 +2137,7 @@ static VALUE libvirt_connect_node_memory_stats(int argc, VALUE *argv, VALUE c)
2137
2137
  #if HAVE_VIRDOMAINSAVEIMAGEGETXMLDESC
2138
2138
  /*
2139
2139
  * call-seq:
2140
- * conn.save_image_xml_desc(filename, flags=0) -> string
2140
+ * conn.save_image_xml_desc(filename, flags=0) -> String
2141
2141
  *
2142
2142
  * Call virDomainSaveImageGetXMLDesc[http://www.libvirt.org/html/libvirt-libvirt.html#virDomainSaveImageGetXMLDesc]
2143
2143
  * to get the XML corresponding to a save file.
@@ -2353,7 +2353,7 @@ static VALUE libvirt_connect_node_cpu_map(int argc, VALUE *argv, VALUE c)
2353
2353
  #if HAVE_VIRCONNECTSETKEEPALIVE
2354
2354
  /*
2355
2355
  * call-seq:
2356
- * conn.set_keepalive(interval, count) -> fixnum
2356
+ * conn.set_keepalive(interval, count) -> Fixnum
2357
2357
  *
2358
2358
  * Call virConnectSetKeepAlive[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectSetKeepAlive]
2359
2359
  * to start sending keepalive messages. Deprecated; use conn.keepalive=
@@ -2398,7 +2398,7 @@ static VALUE libvirt_connect_keepalive_equal(VALUE c, VALUE in)
2398
2398
  #if HAVE_VIRCONNECTLISTALLDOMAINS
2399
2399
  /*
2400
2400
  * call-seq:
2401
- * conn.list_all_domains(flags=0) -> array
2401
+ * conn.list_all_domains(flags=0) -> Array
2402
2402
  *
2403
2403
  * Call virConnectListAllDomains[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectListAllDomains]
2404
2404
  * to get an array of domain objects for all domains.
@@ -2415,7 +2415,7 @@ static VALUE libvirt_connect_list_all_domains(int argc, VALUE *argv, VALUE c)
2415
2415
  #if HAVE_VIRCONNECTLISTALLNETWORKS
2416
2416
  /*
2417
2417
  * call-seq:
2418
- * conn.list_all_networks(flags=0) -> array
2418
+ * conn.list_all_networks(flags=0) -> Array
2419
2419
  *
2420
2420
  * Call virConnectListAllNetworks[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectListAllNetworks]
2421
2421
  * to get an array of network objects for all networks.
@@ -2433,7 +2433,7 @@ static VALUE libvirt_connect_list_all_networks(int argc, VALUE *argv, VALUE c)
2433
2433
  #if HAVE_VIRCONNECTLISTALLINTERFACES
2434
2434
  /*
2435
2435
  * call-seq:
2436
- * conn.list_all_interfaces(flags=0) -> array
2436
+ * conn.list_all_interfaces(flags=0) -> Array
2437
2437
  *
2438
2438
  * Call virConnectListAllInterfaces[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectListAllInterfaces]
2439
2439
  * to get an array of interface objects for all interfaces.
@@ -2451,7 +2451,7 @@ static VALUE libvirt_connect_list_all_interfaces(int argc, VALUE *argv, VALUE c)
2451
2451
  #if HAVE_VIRCONNECTLISTALLSECRETS
2452
2452
  /*
2453
2453
  * call-seq:
2454
- * conn.list_all_secrets(flags=0) -> array
2454
+ * conn.list_all_secrets(flags=0) -> Array
2455
2455
  *
2456
2456
  * Call virConnectListAllSecrets[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectListAllSecrets]
2457
2457
  * to get an array of secret objects for all secrets.
@@ -2468,7 +2468,7 @@ static VALUE libvirt_connect_list_all_secrets(int argc, VALUE *argv, VALUE c)
2468
2468
  #if HAVE_VIRCONNECTLISTALLNODEDEVICES
2469
2469
  /*
2470
2470
  * call-seq:
2471
- * conn.list_all_nodedevices(flags=0) -> array
2471
+ * conn.list_all_nodedevices(flags=0) -> Array
2472
2472
  *
2473
2473
  * Call virConnectListAllNodeDevices[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectListAllNodeDevices]
2474
2474
  * to get an array of nodedevice objects for all nodedevices.
@@ -2487,7 +2487,7 @@ static VALUE libvirt_connect_list_all_nodedevices(int argc, VALUE *argv,
2487
2487
  #if HAVE_VIRCONNECTLISTALLSTORAGEPOOLS
2488
2488
  /*
2489
2489
  * call-seq:
2490
- * conn.list_all_storage_pools(flags=0) -> array
2490
+ * conn.list_all_storage_pools(flags=0) -> Array
2491
2491
  *
2492
2492
  * Call virConnectListAllStoragePools[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectListAllStoragePools]
2493
2493
  * to get an array of storage pool objects for all storage pools.
@@ -2505,7 +2505,7 @@ static VALUE libvirt_connect_list_all_storage_pools(int argc, VALUE *argv,
2505
2505
  #if HAVE_VIRCONNECTLISTALLNWFILTERS
2506
2506
  /*
2507
2507
  * call-seq:
2508
- * conn.list_all_nwfilters(flags=0) -> array
2508
+ * conn.list_all_nwfilters(flags=0) -> Array
2509
2509
  *
2510
2510
  * Call virConnectListAllNWFilters[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectListAllNWFilters]
2511
2511
  * to get an array of nwfilters for all nwfilter objects.
@@ -2608,24 +2608,6 @@ static VALUE libvirt_connect_qemu_attach(int argc, VALUE *argv, VALUE c)
2608
2608
  #endif
2609
2609
 
2610
2610
  #if HAVE_VIRCONNECTGETCPUMODELNAMES
2611
- struct model_name_args {
2612
- VALUE result;
2613
- int i;
2614
- char *value;
2615
- };
2616
-
2617
- static VALUE model_name_wrap(VALUE arg)
2618
- {
2619
- struct model_name_args *e = (struct model_name_args *)arg;
2620
- VALUE elem;
2621
-
2622
- elem = rb_str_new2(e->value);
2623
-
2624
- rb_ary_store(e->result, e->i, elem);
2625
-
2626
- return Qnil;
2627
- }
2628
-
2629
2611
  /*
2630
2612
  * call-seq:
2631
2613
  * conn.cpu_model_names(arch, flags=0) -> Array
@@ -2638,7 +2620,7 @@ static VALUE libvirt_connect_cpu_model_names(int argc, VALUE *argv, VALUE c)
2638
2620
  VALUE arch, flags, result;
2639
2621
  char **models;
2640
2622
  int i = 0, j, elems = 0;
2641
- struct model_name_args args;
2623
+ struct ruby_libvirt_str_new2_and_ary_store_arg args;
2642
2624
  int exception;
2643
2625
 
2644
2626
  rb_scan_args(argc, argv, "11", &arch, &flags);
@@ -2656,11 +2638,12 @@ static VALUE libvirt_connect_cpu_model_names(int argc, VALUE *argv, VALUE c)
2656
2638
  }
2657
2639
 
2658
2640
  for (i = 0; i < elems; i++) {
2659
- args.result = result;
2660
- args.i = i;
2641
+ args.arr = result;
2642
+ args.index = i;
2661
2643
  args.value = models[i];
2662
2644
 
2663
- rb_protect(model_name_wrap, (VALUE)&args, &exception);
2645
+ rb_protect(ruby_libvirt_str_new2_and_ary_store_wrap, (VALUE)&args,
2646
+ &exception);
2664
2647
  if (exception) {
2665
2648
  goto error;
2666
2649
  }
@@ -2681,6 +2664,145 @@ error:
2681
2664
  }
2682
2665
  #endif
2683
2666
 
2667
+ #if HAVE_VIRNODEALLOCPAGES
2668
+ /*
2669
+ * call-seq:
2670
+ * conn.node_alloc_pages(page_arr, cells=nil, flags=0) -> Fixnum
2671
+ *
2672
+ * Call virNodeAllocPages[http://www.libvirt.org/html/libvirt-libvirt.html#virNodeAllocPages]
2673
+ * to reserve huge pages in the system pool.
2674
+ */
2675
+ static VALUE libvirt_connect_node_alloc_pages(int argc, VALUE *argv, VALUE c)
2676
+ {
2677
+ VALUE page_arr, cells, flags, entry, size, count, tmp;
2678
+ int i, arraylen, start_cell, ret;
2679
+ unsigned int *page_sizes;
2680
+ unsigned long long *page_counts;
2681
+ unsigned int cell_count;
2682
+
2683
+ rb_scan_args(argc, argv, "12", &page_arr, &cells, &flags);
2684
+
2685
+ Check_Type(page_arr, T_ARRAY);
2686
+
2687
+ arraylen = RARRAY_LEN(page_arr);
2688
+
2689
+ page_sizes = alloca(arraylen * sizeof(unsigned int));
2690
+ page_counts = alloca(arraylen * sizeof(unsigned long long));
2691
+
2692
+ for (i = 0; i < arraylen; i++) {
2693
+ entry = rb_ary_entry(page_arr, i);
2694
+ Check_Type(entry, T_HASH);
2695
+
2696
+ size = rb_hash_aref(entry, rb_str_new2("size"));
2697
+ Check_Type(size, T_FIXNUM);
2698
+
2699
+ count = rb_hash_aref(entry, rb_str_new2("count"));
2700
+ Check_Type(count, T_FIXNUM);
2701
+
2702
+ page_sizes[i] = NUM2UINT(size);
2703
+ page_counts[i] = NUM2ULL(count);
2704
+ }
2705
+
2706
+ if (NIL_P(cells)) {
2707
+ start_cell = -1;
2708
+ cell_count = 0;
2709
+ }
2710
+ else {
2711
+ Check_Type(cells, T_HASH);
2712
+
2713
+ tmp = rb_hash_aref(cells, rb_str_new2("start"));
2714
+ Check_Type(tmp, T_FIXNUM);
2715
+ start_cell = NUM2INT(tmp);
2716
+
2717
+ tmp = rb_hash_aref(cells, rb_str_new2("count"));
2718
+ Check_Type(tmp, T_FIXNUM);
2719
+ cell_count = NUM2UINT(tmp);
2720
+ }
2721
+
2722
+ ret = virNodeAllocPages(ruby_libvirt_connect_get(c), arraylen, page_sizes,
2723
+ page_counts, start_cell, cell_count,
2724
+ ruby_libvirt_value_to_uint(flags));
2725
+ ruby_libvirt_raise_error_if(ret < 0, e_Error,
2726
+ "virNodeAllocPages",
2727
+ ruby_libvirt_connect_get(c));
2728
+
2729
+ return INT2NUM(ret);
2730
+ }
2731
+ #endif
2732
+
2733
+ #if HAVE_VIRCONNECTGETDOMAINCAPABILITIES
2734
+ /*
2735
+ * call-seq:
2736
+ * conn.domain_capabilities(emulatorbin, arch, machine, virttype, flags=0) -> String
2737
+ *
2738
+ * Call virNodeAllocPages[http://www.libvirt.org/html/libvirt-libvirt.html#virConnectGetDomainCapabilities]
2739
+ * to get the capabilities of the underlying emulator.
2740
+ */
2741
+ static VALUE libvirt_connect_domain_capabilities(int argc, VALUE *argv, VALUE c)
2742
+ {
2743
+ VALUE emulatorbin, arch, machine, virttype, flags;
2744
+
2745
+ rb_scan_args(argc, argv, "41", &emulatorbin, &arch, &machine, &virttype,
2746
+ &flags);
2747
+
2748
+ ruby_libvirt_generate_call_string(virConnectGetDomainCapabilities,
2749
+ ruby_libvirt_connect_get(c), 1,
2750
+ ruby_libvirt_connect_get(c),
2751
+ ruby_libvirt_get_cstring_or_null(emulatorbin),
2752
+ ruby_libvirt_get_cstring_or_null(arch),
2753
+ ruby_libvirt_get_cstring_or_null(machine),
2754
+ ruby_libvirt_get_cstring_or_null(virttype),
2755
+ NUM2UINT(flags));
2756
+ }
2757
+ #endif
2758
+
2759
+ #if HAVE_VIRNODEGETFREEPAGES
2760
+ /*
2761
+ * call-seq:
2762
+ * conn.node_free_pages(pages, cells, flags=0) -> Hash
2763
+ *
2764
+ * Call virNodeGetFreePages[http://www.libvirt.org/html/libvirt-libvirt.html#virNodeGetFreePages]
2765
+ * to query the host system on free pages of specified size.
2766
+ */
2767
+ static VALUE libvirt_connect_node_free_pages(int argc, VALUE *argv, VALUE c)
2768
+ {
2769
+ VALUE pageArr, cells, flags, result;
2770
+ unsigned int *pages;
2771
+ unsigned int npages, i, cellCount;
2772
+ int startCell, ret;
2773
+ unsigned long long *counts;
2774
+
2775
+ rb_scan_args(argc, argv, "21", &pageArr, &cells, &flags);
2776
+
2777
+ Check_Type(pageArr, T_ARRAY);
2778
+ Check_Type(cells, T_HASH);
2779
+
2780
+ npages = RARRAY_LEN(pageArr);
2781
+ pages = alloca(npages);
2782
+ for (i = 0; i < npages; i++) {
2783
+ pages[i] = NUM2UINT(rb_ary_entry(pageArr, i));
2784
+ }
2785
+
2786
+ startCell = NUM2INT(rb_hash_aref(cells, rb_str_new2("startCell")));
2787
+ cellCount = NUM2UINT(rb_hash_aref(cells, rb_str_new2("cellCount")));
2788
+
2789
+ counts = alloca(npages * cellCount * sizeof(long long));
2790
+
2791
+ ret = virNodeGetFreePages(ruby_libvirt_connect_get(c), npages, pages,
2792
+ startCell, cellCount, counts,
2793
+ ruby_libvirt_value_to_uint(flags));
2794
+ ruby_libvirt_raise_error_if(ret < 0, e_Error, "virNodeGetFreePages",
2795
+ ruby_libvirt_connect_get(c));
2796
+
2797
+ result = rb_hash_new();
2798
+ for (i = 0; i < npages; i++) {
2799
+ rb_hash_aset(result, UINT2NUM(pages[i]), ULL2NUM(counts[i]));
2800
+ }
2801
+
2802
+ return result;
2803
+ }
2804
+ #endif
2805
+
2684
2806
  /*
2685
2807
  * Class Libvirt::Connect
2686
2808
  */
@@ -2754,6 +2876,11 @@ void ruby_libvirt_connect_init(void)
2754
2876
  rb_define_method(c_connect, "compare_cpu", libvirt_connect_compare_cpu, -1);
2755
2877
  #endif
2756
2878
 
2879
+ #if HAVE_CONST_VIR_CONNECT_COMPARE_CPU_FAIL_INCOMPATIBLE
2880
+ rb_define_const(c_connect, "COMPARE_CPU_FAIL_INCOMPATIBLE",
2881
+ INT2NUM(VIR_CONNECT_COMPARE_CPU_FAIL_INCOMPATIBLE));
2882
+ #endif
2883
+
2757
2884
  #if HAVE_VIRCONNECTBASELINECPU
2758
2885
  rb_define_method(c_connect, "baseline_cpu", libvirt_connect_baseline_cpu,
2759
2886
  -1);
@@ -3301,6 +3428,14 @@ void ruby_libvirt_connect_init(void)
3301
3428
  rb_define_method(c_connect, "list_all_storage_pools",
3302
3429
  libvirt_connect_list_all_storage_pools, -1);
3303
3430
  #endif
3431
+ #if HAVE_CONST_VIR_CONNECT_LIST_STORAGE_POOLS_GLUSTER
3432
+ rb_define_const(c_connect, "LIST_STORAGE_POOLS_GLUSTER",
3433
+ INT2NUM(VIR_CONNECT_LIST_STORAGE_POOLS_GLUSTER));
3434
+ #endif
3435
+ #if HAVE_CONST_VIR_CONNECT_LIST_STORAGE_POOLS_ZFS
3436
+ rb_define_const(c_connect, "LIST_STORAGE_POOLS_ZFS",
3437
+ INT2NUM(VIR_CONNECT_LIST_STORAGE_POOLS_ZFS));
3438
+ #endif
3304
3439
  #if HAVE_VIRCONNECTLISTALLNWFILTERS
3305
3440
  rb_define_method(c_connect, "list_all_nwfilters",
3306
3441
  libvirt_connect_list_all_nwfilters, -1);
@@ -3319,4 +3454,20 @@ void ruby_libvirt_connect_init(void)
3319
3454
  rb_define_method(c_connect, "cpu_model_names",
3320
3455
  libvirt_connect_cpu_model_names, -1);
3321
3456
  #endif
3457
+ #if HAVE_VIRNODEALLOCPAGES
3458
+ rb_define_const(c_connect, "NODE_ALLOC_PAGES_ADD",
3459
+ INT2NUM(VIR_NODE_ALLOC_PAGES_ADD));
3460
+ rb_define_const(c_connect, "NODE_ALLOC_PAGES_SET",
3461
+ INT2NUM(VIR_NODE_ALLOC_PAGES_SET));
3462
+ rb_define_method(c_connect, "node_alloc_pages",
3463
+ libvirt_connect_node_alloc_pages, -1);
3464
+ #endif
3465
+ #if HAVE_VIRCONNECTGETDOMAINCAPABILITIES
3466
+ rb_define_method(c_connect, "domain_capabilities",
3467
+ libvirt_connect_domain_capabilities, -1);
3468
+ #endif
3469
+ #if HAVE_VIRNODEGETFREEPAGES
3470
+ rb_define_method(c_connect, "node_free_pages",
3471
+ libvirt_connect_node_free_pages, -1);
3472
+ #endif
3322
3473
  }