Skip to content

Commit

Permalink
kvm clone: skips disks without sources
Browse files Browse the repository at this point in the history
  • Loading branch information
karmab committed Apr 6, 2024
1 parent d81e65f commit 32f0019
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions kvirt/providers/kvm/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2259,6 +2259,13 @@ def _xmlvolume(self, path, size, pooltype='file', backing=None, diskformat='qcow

def clone(self, old, new, full=False, start=False):
conn = self.conn
try:
conn.lookupByName(new)
msg = f"VM {new} already exists"
error(msg)
return {'result': 'failure', 'reason': msg}
except:
pass
try:
oldvm = conn.lookupByName(old)
except:
Expand All @@ -2280,6 +2287,8 @@ def clone(self, old, new, full=False, start=False):
for disk in list(tree.iter('disk')):
if firstdisk or full:
source = disk.find('source')
if source is None:
continue
oldpath = source.get('file')
oldvolume = self.conn.storageVolLookupByPath(oldpath)
pool = oldvolume.storagePoolLookupByVolume()
Expand Down

0 comments on commit 32f0019

Please sign in to comment.