[
https://issues.apache.org/jira/browse/CLOUDSTACK-8746?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14987055#comment-14987055
]
ASF GitHub Bot commented on CLOUDSTACK-8746:
--------------------------------------------
Github user wido commented on a diff in the pull request:
https://github.com/apache/cloudstack/pull/977#discussion_r43734224
--- Diff:
plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/wrapper/LibvirtDeleteVMSnapshotCommandWrapper.java
---
@@ -0,0 +1,108 @@
+//
+// Licensed to the Apache Software Foundation (ASF) under one
+// or more contributor license agreements. See the NOTICE file
+// distributed with this work for additional information
+// regarding copyright ownership. The ASF licenses this file
+// to you under the Apache License, Version 2.0 (the
+// "License"); you may not use this file except in compliance
+// with the License. You may obtain a copy of the License at
+//
+// http://www.apache.org/licenses/LICENSE-2.0
+//
+// Unless required by applicable law or agreed to in writing,
+// software distributed under the License is distributed on an
+// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+// KIND, either express or implied. See the License for the
+// specific language governing permissions and limitations
+// under the License.
+//
+
+package com.cloud.hypervisor.kvm.resource.wrapper;
+
+import org.apache.cloudstack.storage.to.PrimaryDataStoreTO;
+import org.apache.cloudstack.storage.to.VolumeObjectTO;
+import org.apache.log4j.Logger;
+import org.libvirt.Connect;
+import org.libvirt.Domain;
+import org.libvirt.DomainSnapshot;
+import org.libvirt.LibvirtException;
+
+import com.cloud.agent.api.Answer;
+import com.cloud.agent.api.DeleteVMSnapshotAnswer;
+import com.cloud.agent.api.DeleteVMSnapshotCommand;
+import com.cloud.hypervisor.kvm.resource.LibvirtComputingResource;
+import com.cloud.hypervisor.kvm.storage.KVMPhysicalDisk;
+import com.cloud.hypervisor.kvm.storage.KVMStoragePoolManager;
+import com.cloud.resource.CommandWrapper;
+import com.cloud.resource.ResourceWrapper;
+import com.cloud.storage.Volume;
+import com.cloud.utils.script.Script;
+
+@ResourceWrapper(handles = DeleteVMSnapshotCommand.class)
+public final class LibvirtDeleteVMSnapshotCommandWrapper extends
CommandWrapper<DeleteVMSnapshotCommand, Answer, LibvirtComputingResource> {
+
+ private static final Logger s_logger =
Logger.getLogger(LibvirtDeleteVMSnapshotCommandWrapper.class);
+
+ @Override
+ public Answer execute(final DeleteVMSnapshotCommand cmd, final
LibvirtComputingResource libvirtComputingResource) {
+ String vmName = cmd.getVmName();
+
+ final KVMStoragePoolManager storagePoolMgr =
libvirtComputingResource.getStoragePoolMgr();
+ Domain dm = null;
+ try {
+ final LibvirtUtilitiesHelper libvirtUtilitiesHelper =
libvirtComputingResource.getLibvirtUtilitiesHelper();
+ Connect conn = libvirtUtilitiesHelper.getConnection();
+ dm = libvirtComputingResource.getDomain(conn, vmName);
+
+ DomainSnapshot snapshot = null;
+ try {
+ snapshot =
dm.snapshotLookupByName(cmd.getTarget().getSnapshotName());
+ } catch (LibvirtException e) {
+ s_logger.warn("Cannot find vmSnapshot with name: " +
cmd.getTarget().getSnapshotName());
+ return new DeleteVMSnapshotAnswer(cmd, cmd.getVolumeTOs());
+ }
+
+ snapshot.delete(0); // only remove this snapshot, not children
+
+ return new DeleteVMSnapshotAnswer(cmd, cmd.getVolumeTOs());
+ } catch (LibvirtException e) {
+ String msg = " Delete VM snapshot failed due to " +
e.toString();
--- End diff --
Can't you move this down to where you actually throw the Answer back?
> VM Snapshotting implementation for KVM
> --------------------------------------
>
> Key: CLOUDSTACK-8746
> URL: https://issues.apache.org/jira/browse/CLOUDSTACK-8746
> Project: CloudStack
> Issue Type: Improvement
> Security Level: Public(Anyone can view this level - this is the
> default.)
> Reporter: Wei Zhou
> Assignee: Wei Zhou
>
> Currently it is not supported.
> https://cwiki.apache.org/confluence/display/CLOUDSTACK/VM+Snapshots
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)