diff --git a/PVE/Makefile b/PVE/Makefile index dc173681..440fbe77 100644 --- a/PVE/Makefile +++ b/PVE/Makefile @@ -11,4 +11,5 @@ install: $(MAKE) -C VZDump install $(MAKE) -C API2 install $(MAKE) -C CLI install + $(MAKE) -C QemuConfig install $(MAKE) -C QemuServer install diff --git a/PVE/QemuConfig.pm b/PVE/QemuConfig.pm index ffdf9f03..b60cc398 100644 --- a/PVE/QemuConfig.pm +++ b/PVE/QemuConfig.pm @@ -3,6 +3,8 @@ package PVE::QemuConfig; use strict; use warnings; +use Scalar::Util qw(blessed); + use PVE::AbstractConfig; use PVE::INotify; use PVE::JSONSchema; @@ -561,6 +563,19 @@ sub get_derived_property { } } +sub write_config { + my ($class, $vmid, $conf) = @_; + + # Dispatch to class the object was blessed with if caller invoked the method via the + # 'PVE::QemuConfig' class name explicitly. This is hack, but the code currently doesn't + # generally use blessed config objects. Safeguard against infinite recursion. + if (blessed($conf) && !blessed($class)) { + return $conf->write_config($vmid, $conf); + } + + return $class->SUPER::write_config($vmid, $conf); +} + # END implemented abstract methods from PVE::AbstractConfig sub has_cloudinit { diff --git a/PVE/QemuConfig/Makefile b/PVE/QemuConfig/Makefile new file mode 100644 index 00000000..c3a0d277 --- /dev/null +++ b/PVE/QemuConfig/Makefile @@ -0,0 +1,5 @@ +SOURCES=NoWrite.pm + +.PHONY: install +install: ${SOURCES} + for i in ${SOURCES}; do install -D -m 0644 $$i ${DESTDIR}${PERLDIR}/PVE/QemuConfig/$$i; done diff --git a/PVE/QemuConfig/NoWrite.pm b/PVE/QemuConfig/NoWrite.pm new file mode 100644 index 00000000..f697506f --- /dev/null +++ b/PVE/QemuConfig/NoWrite.pm @@ -0,0 +1,25 @@ +package PVE::QemuConfig::NoWrite; + +use strict; +use warnings; + +use PVE::RESTEnvironment qw(log_warn); + +use base qw(PVE::QemuConfig); + +sub new { + my ($class, $conf) = @_; + + bless($conf, $class); + + return $conf; +} + +sub write_config { + my ($class, $vmid, $conf) = @_; + + log_warn("refusing to write temporary configuration"); + return; +} + +1;