[Pkg-libvirt-commits] [Git][libvirt-team/ruby-libvirt][upstream/latest] New upstream version 0.8.4

Pino Toscano (@pino) gitlab at salsa.debian.org
Fri Aug 9 04:59:46 BST 2024



Pino Toscano pushed to branch upstream/latest at Libvirt Packaging Team / ruby-libvirt


Commits:
dae785f9 by Pino Toscano at 2024-08-09T05:57:54+02:00
New upstream version 0.8.4
- - - - -


14 changed files:

- NEWS.rst
- Rakefile
- ext/libvirt/common.c
- ext/libvirt/common.h
- ext/libvirt/connect.c
- ext/libvirt/domain.c
- ext/libvirt/extconf.rb
- ext/libvirt/interface.c
- ext/libvirt/network.c
- ext/libvirt/nodedevice.c
- ext/libvirt/nwfilter.c
- ext/libvirt/secret.c
- ext/libvirt/storage.c
- ext/libvirt/stream.c


Changes:

=====================================
NEWS.rst
=====================================
@@ -3,6 +3,12 @@ ruby-libvirt releases
 =====================
 
 
+0.8.4 (2024-08-01)
+==================
+
+* Explicitly disallow use of ``new`` for wrapper classes
+
+
 0.8.3 (2024-05-13)
 ==================
 


=====================================
Rakefile
=====================================
@@ -16,7 +16,7 @@ require 'rdoc/task'
 require 'rubygems/package_task'
 
 PKG_NAME='ruby-libvirt'
-PKG_VERSION='0.8.3'
+PKG_VERSION='0.8.4'
 
 EXT_DIR = "ext/libvirt"
 EXTCONF = "#{EXT_DIR}/extconf.rb"


=====================================
ext/libvirt/common.c
=====================================
@@ -491,3 +491,14 @@ int ruby_libvirt_get_maxcpus(virConnectPtr conn)
 
     return maxcpu;
 }
+
+/* For classes where Ruby objects are just wrappers around C pointers,
+ * the only acceptable way to create new instances is to use
+ * Connect.create_domain_xml and similar. The use of Domain.new and
+ * friends is explicitly disallowed by providing this functions as
+ * implementation when defining the class
+ */
+VALUE ruby_libvirt_new_not_allowed(int argc, VALUE *argv, VALUE obj)
+{
+    rb_raise(rb_eTypeError, "Not allowed for this class");
+}


=====================================
ext/libvirt/common.h
=====================================
@@ -268,6 +268,8 @@ struct ruby_libvirt_str_new2_and_ary_store_arg {
 };
 VALUE ruby_libvirt_str_new2_and_ary_store_wrap(VALUE arg);
 
+VALUE ruby_libvirt_new_not_allowed(int argc, VALUE *argv, VALUE obj);
+
 #ifndef RARRAY_LEN
 #define RARRAY_LEN(ar) (RARRAY(ar)->len)
 #endif


=====================================
ext/libvirt/connect.c
=====================================
@@ -2742,6 +2742,8 @@ void ruby_libvirt_connect_init(void)
 {
     c_connect = rb_define_class_under(m_libvirt, "Connect", rb_cObject);
     rb_undef_alloc_func(c_connect);
+    rb_define_singleton_method(c_connect, "new",
+                               ruby_libvirt_new_not_allowed, -1);
 
     /*
      * Class Libvirt::Connect::Nodeinfo


=====================================
ext/libvirt/domain.c
=====================================
@@ -4064,6 +4064,8 @@ void ruby_libvirt_domain_init(void)
 {
     c_domain = rb_define_class_under(m_libvirt, "Domain", rb_cObject);
     rb_undef_alloc_func(c_domain);
+    rb_define_singleton_method(c_domain, "new",
+                               ruby_libvirt_new_not_allowed, -1);
 
     rb_define_const(c_domain, "NOSTATE", INT2NUM(VIR_DOMAIN_NOSTATE));
     rb_define_const(c_domain, "RUNNING", INT2NUM(VIR_DOMAIN_RUNNING));
@@ -4390,6 +4392,8 @@ void ruby_libvirt_domain_init(void)
      */
     c_domain_snapshot = rb_define_class_under(c_domain, "Snapshot", rb_cObject);
     rb_undef_alloc_func(c_domain_snapshot);
+    rb_define_singleton_method(c_domain_snapshot, "new",
+                               ruby_libvirt_new_not_allowed, -1);
 
     rb_define_const(c_domain_snapshot, "DELETE_CHILDREN",
                     INT2NUM(VIR_DOMAIN_SNAPSHOT_DELETE_CHILDREN));


=====================================
ext/libvirt/extconf.rb
=====================================
@@ -1,9 +1,5 @@
 require 'mkmf'
 
-RbConfig::MAKEFILE_CONFIG['CC'] = ENV['CC'] if ENV['CC']
-RbConfig::MAKEFILE_CONFIG['CCDLFLAGS'] = ENV['CFLAGS'] if ENV['CFLAGS']
-RbConfig::MAKEFILE_CONFIG['EXTDLDFLAGS'] = ENV['CFLAGS'] if ENV['CFLAGS']
-
 extension_name = '_libvirt'
 
 unless pkg_config("libvirt")


=====================================
ext/libvirt/interface.c
=====================================
@@ -175,6 +175,8 @@ void ruby_libvirt_interface_init(void)
 {
     c_interface = rb_define_class_under(m_libvirt, "Interface", rb_cObject);
     rb_undef_alloc_func(c_interface);
+    rb_define_singleton_method(c_interface, "new",
+                               ruby_libvirt_new_not_allowed, -1);
 
     rb_define_const(c_interface, "XML_INACTIVE",
                     INT2NUM(VIR_INTERFACE_XML_INACTIVE));


=====================================
ext/libvirt/network.c
=====================================
@@ -330,6 +330,8 @@ void ruby_libvirt_network_init(void)
 {
     c_network = rb_define_class_under(m_libvirt, "Network", rb_cObject);
     rb_undef_alloc_func(c_network);
+    rb_define_singleton_method(c_network, "new",
+                               ruby_libvirt_new_not_allowed, -1);
 
     rb_define_attr(c_network, "connection", 1, 0);
 


=====================================
ext/libvirt/nodedevice.c
=====================================
@@ -261,6 +261,8 @@ void ruby_libvirt_nodedevice_init(void)
 {
     c_nodedevice = rb_define_class_under(m_libvirt, "NodeDevice", rb_cObject);
     rb_undef_alloc_func(c_nodedevice);
+    rb_define_singleton_method(c_nodedevice, "new",
+                               ruby_libvirt_new_not_allowed, -1);
 
     rb_define_attr(c_nodedevice, "connection", 1, 0);
 


=====================================
ext/libvirt/nwfilter.c
=====================================
@@ -124,6 +124,8 @@ void ruby_libvirt_nwfilter_init(void)
 {
     c_nwfilter = rb_define_class_under(m_libvirt, "NWFilter", rb_cObject);
     rb_undef_alloc_func(c_nwfilter);
+    rb_define_singleton_method(c_nwfilter, "new",
+                               ruby_libvirt_new_not_allowed, -1);
 
     rb_define_attr(c_nwfilter, "connection", 1, 0);
 


=====================================
ext/libvirt/secret.c
=====================================
@@ -231,6 +231,8 @@ void ruby_libvirt_secret_init(void)
 {
     c_secret = rb_define_class_under(m_libvirt, "Secret", rb_cObject);
     rb_undef_alloc_func(c_secret);
+    rb_define_singleton_method(c_secret, "new",
+                               ruby_libvirt_new_not_allowed, -1);
 
     rb_define_attr(c_secret, "connection", 1, 0);
 


=====================================
ext/libvirt/storage.c
=====================================
@@ -753,6 +753,8 @@ void ruby_libvirt_storage_init(void)
     c_storage_pool = rb_define_class_under(m_libvirt, "StoragePool",
                                            rb_cObject);
     rb_undef_alloc_func(c_storage_pool);
+    rb_define_singleton_method(c_storage_pool, "new",
+                               ruby_libvirt_new_not_allowed, -1);
 
     rb_define_attr(c_storage_pool, "connection", 1, 0);
 
@@ -866,6 +868,8 @@ void ruby_libvirt_storage_init(void)
     c_storage_vol = rb_define_class_under(m_libvirt, "StorageVol",
                                           rb_cObject);
     rb_undef_alloc_func(c_storage_vol);
+    rb_define_singleton_method(c_storage_vol, "new",
+                               ruby_libvirt_new_not_allowed, -1);
 
     rb_define_const(c_storage_vol, "XML_INACTIVE",
                     INT2NUM(VIR_STORAGE_XML_INACTIVE));


=====================================
ext/libvirt/stream.c
=====================================
@@ -361,6 +361,8 @@ void ruby_libvirt_stream_init(void)
 {
     c_stream = rb_define_class_under(m_libvirt, "Stream", rb_cObject);
     rb_undef_alloc_func(c_stream);
+    rb_define_singleton_method(c_stream, "new",
+                               ruby_libvirt_new_not_allowed, -1);
 
     rb_define_attr(c_stream, "connection", 1, 0);
 



View it on GitLab: https://salsa.debian.org/libvirt-team/ruby-libvirt/-/commit/dae785f923c64972a51ce3865492afd057786691

-- 
View it on GitLab: https://salsa.debian.org/libvirt-team/ruby-libvirt/-/commit/dae785f923c64972a51ce3865492afd057786691
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/pkg-libvirt-commits/attachments/20240809/6968596e/attachment-0001.htm>


More information about the Pkg-libvirt-commits mailing list