DaanHoogland commented on a change in pull request #3839: FEATURE-3823: kvm 
agent hooks
URL: https://github.com/apache/cloudstack/pull/3839#discussion_r383844434
 
 

 ##########
 File path: 
plugins/hypervisors/kvm/src/main/java/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtStartCommandWrapper.java
 ##########
 @@ -79,7 +79,28 @@ public Answer execute(final StartCommand command, final 
LibvirtComputingResource
             libvirtComputingResource.createVifs(vmSpec, vm);
 
             s_logger.debug("starting " + vmName + ": " + vm.toString());
-            libvirtComputingResource.startVM(conn, vmName, vm.toString());
+            String vmInitialSpecification = vm.toString();
+            String vmFinalSpecification;
+            try {
+                // if transformer fails, everything must go as it's just 
skipped.
+                LibvirtKvmAgentHook t = 
libvirtComputingResource.getTransformer();
+                vmFinalSpecification = (String) 
t.handle(vmInitialSpecification);
+                if (null == vmFinalSpecification) {
+                    s_logger.warn("Libvirt XML transformer returned NULL, will 
use XML specification unchanged.");
+                    vmFinalSpecification = vmInitialSpecification;
+                }
+            } catch(Exception e) {
+                s_logger.warn("Exception occured when handling LibVirt XML 
transformer hook: {}", e);
+                vmFinalSpecification = vmInitialSpecification;
+            }
+            libvirtComputingResource.startVM(conn, vmName, 
vmFinalSpecification);
+
+            try {
+                LibvirtKvmAgentHook onStartHook = 
libvirtComputingResource.getStartHook();
+                onStartHook.handle(vmName);
+            } catch (Exception e) {
+                s_logger.warn("Exception occured when handling LibVirt VM 
onStart hook: {}", e);
+            }
 
 Review comment:
   and performAgentStartHook(..) here?

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to