[ 
https://issues.apache.org/jira/browse/CLOUDSTACK-8746?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14973970#comment-14973970
 ] 

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_r42975042
  
    --- Diff: 
plugins/hypervisors/kvm/src/com/cloud/hypervisor/kvm/resource/LibvirtComputingResource.java
 ---
    @@ -3388,4 +3419,83 @@ public String mapRbdDevice(final KVMPhysicalDisk 
disk){
             }
             return device;
         }
    +
    +    public List<Ternary<String, Boolean, String>> 
cleanVMSnapshotMetadata(Domain dm) throws LibvirtException {
    +        s_logger.debug("Cleaning the metadata of vm snapshots of vm " + 
dm.getName());
    +        List<Ternary<String, Boolean, String>> vmsnapshots = new 
ArrayList<Ternary<String, Boolean, String>>();
    +        String currentSnapshotName = null;
    +        try {
    +            DomainSnapshot snapshotCurrent = dm.snapshotCurrent();
    +            String snapshotXML = snapshotCurrent.getXMLDesc();
    +            snapshotCurrent.free();
    +            DocumentBuilder builder;
    +            try {
    +                builder = 
DocumentBuilderFactory.newInstance().newDocumentBuilder();
    +
    +                InputSource is = new InputSource();
    +                is.setCharacterStream(new StringReader(snapshotXML));
    +                Document doc = builder.parse(is);
    +                Element rootElement = doc.getDocumentElement();
    +
    +                currentSnapshotName = getTagValue("name", rootElement);
    +            } catch (ParserConfigurationException e) {
    +                s_logger.debug(e.toString());
    +            } catch (SAXException e) {
    +                s_logger.debug(e.toString());
    +            } catch (IOException e) {
    +                s_logger.debug(e.toString());
    +            }
    +        } catch (LibvirtException e) {
    +            s_logger.debug("Fail to get the current vm snapshot for vm: " 
+ dm.getName() + ", continue");
    +        }
    +        for (String snapshotName: dm.snapshotListNames()) {
    +            DomainSnapshot snapshot = 
dm.snapshotLookupByName(snapshotName);
    +            Boolean isCurrent = (currentSnapshotName != null && 
currentSnapshotName.equals(snapshotName)) ? true: false;
    +            vmsnapshots.add(new Ternary<String, Boolean, 
String>(snapshotName, isCurrent, snapshot.getXMLDesc()));
    +            snapshot.free();
    +        }
    +        for (String snapshotName: dm.snapshotListNames()) {
    +            String cmdvirsh = "virsh snapshot-delete --metadata " + 
dm.getName() + " " + snapshotName;
    +            int cmdout = Script.runSimpleBashScriptForExitValue(cmdvirsh);
    --- End diff --
    
    Same goes for this, see my comment above about libvirt-java.


> 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)

Reply via email to