public DomainWrapper cloneWithBackingStore ( String cloneName , List < Filesystem > mappings ) { logger . info ( "Creating clone from {}" , getName ( ) ) ; try { // duplicate definition of base Document cloneXmlDocument = domainXml . clone ( ) ; setDomainName ( cloneXmlDocument , cloneName ) ; prepareForCloning ( cloneXmlDocument ) ; // keep track of who we are a clone from... updateCloneMetadata ( cloneXmlDocument , getName ( ) , new Date ( ) ) ; cloneDisks ( cloneXmlDocument , cloneName ) ; updateFilesystemMappings ( cloneXmlDocument , mappings ) ; String cloneXml = documentToString ( cloneXmlDocument ) ; logger . debug ( "Clone xml={}" , cloneXml ) ; // Domain cloneDomain = domain.getConnect().domainCreateXML(cloneXml, 0); Domain cloneDomain = domain . getConnect ( ) . domainDefineXML ( cloneXml ) ; String createdCloneXml = cloneDomain . getXMLDesc ( 0 ) ; logger . debug ( "Created clone xml: {}" , createdCloneXml ) ; cloneDomain . create ( ) ; logger . debug ( "Starting clone: '{}'" , cloneDomain . getName ( ) ) ; return newWrapper ( cloneDomain ) ; } catch ( IOException | LibvirtException e ) { throw new LibvirtRuntimeException ( "Unable to clone domain" , e ) ; } }
Clone the domain . All disks are cloned using the original disk as backing store . The names of the disks are created by suffixing the original disk name with a number .