From 0ebda56330b78912d7f83f1c269102ab9b47ae72 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Thu, 10 Jun 2021 09:55:21 +0200 Subject: [PATCH] M #-: Reduce attribute copies on updateconf (cherry picked from commit 99d165856d3132f5d5a495a75c8c80bb0865bfca) --- include/VirtualMachine.h | 13 ++++++++----- src/rm/RequestManagerVirtualMachine.cc | 6 +----- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/include/VirtualMachine.h b/include/VirtualMachine.h index 0b176c97ee..0bec555982 100644 --- a/include/VirtualMachine.h +++ b/include/VirtualMachine.h @@ -1206,13 +1206,16 @@ public: int updateconf(VirtualMachineTemplate* tmpl, std::string &err); /** - * Get the configuration attributes used in an updateconf API call. - * @param err description if any - * @return template with the attributes + * Check if the template includes any restricted attribute, different from + * this VM template. + * @param template to look for for restricted. The resulting tgt template + * will have the same restricted Attributes as this VM. + * @param ra the restricted attribute found to be different + * @return true if a different restricted is found */ - std::unique_ptr get_updateconf_template() const + bool check_restricted(std::string& ra, VirtualMachineTemplate * tgt) const { - return static_cast(obj_template.get())->get_updateconf_template(); + return tgt->check_restricted(ra, obj_template.get()); } // ------------------------------------------------------------------------- diff --git a/src/rm/RequestManagerVirtualMachine.cc b/src/rm/RequestManagerVirtualMachine.cc index 368a557a38..c798c39689 100644 --- a/src/rm/RequestManagerVirtualMachine.cc +++ b/src/rm/RequestManagerVirtualMachine.cc @@ -3076,11 +3076,7 @@ void VirtualMachineUpdateConf::request_execute( { string aname; - auto conf_tmpl = vm->get_updateconf_template(); - - bool has_restricted = uc_tmpl->check_restricted(aname, conf_tmpl.get()); - - if (has_restricted) + if ( vm->check_restricted(aname, uc_tmpl.get()) ) { att.resp_msg = "Template includes a restricted attribute " + aname; failure_response(AUTHORIZATION, att);