mirror of
https://github.com/virt-manager/virt-manager.git
synced 2024-12-21 09:34:12 +03:00
virt-clone: try harder to allow nonexisting images with --preserve
Input XML can have non-existent disk images as long as `--preserve` is used, or those disks are skipped for any reason. We already handle that correctly in some cases, but others we fail. This covers another one. Resolves: https://github.com/virt-manager/virt-manager/issues/563 Signed-off-by: Cole Robinson <crobinso@redhat.com>
This commit is contained in:
parent
058d8b4ccd
commit
8fb78739e7
@ -19,7 +19,7 @@
|
||||
<devices>
|
||||
<emulator>/usr/lib/xen/bin/qemu-dm</emulator>
|
||||
<disk type='block' device='disk'>
|
||||
<source dev='/i/really/dont/exist'/>
|
||||
<source dev='/virtinst-testsuite-fail-pool-install/fooey'/>
|
||||
<target dev='sda' bus='scsi'/>
|
||||
</disk>
|
||||
<interface type='network'>
|
||||
|
@ -1654,14 +1654,14 @@ c.add_valid(_CLONE_UNMANAGED + " --file %(NEWCLONEIMG1)s --file %(NEWCLONEIMG2)s
|
||||
c.add_valid(_CLONE_UNMANAGED + " --file %(NEWCLONEIMG1)s --file %(NEWCLONEIMG2)s --force-copy=fda") # XML w/ disks, force copy a target with no media
|
||||
c.add_valid(_CLONE_MANAGED + " --file %(NEWIMG1)s") # XML w/ managed storage, specify managed path
|
||||
c.add_valid(_CLONE_MANAGED + " --file %(NEWIMG1)s --reflink") # XML w/ managed storage, specify managed path, use --reflink option
|
||||
c.add_valid(_CLONE_NOEXIST + " --file %(EXISTIMG1)s --preserve") # XML w/ managed storage, specify managed path across pools
|
||||
c.add_compare("--connect %(URI-TEST-FULL)s -o test-clone -n test --auto-clone --replace", "replace") # Overwriting existing running VM
|
||||
c.add_valid(_CLONE_MANAGED + " --auto-clone --force-copy fda") # force copy empty floppy drive
|
||||
c.add_invalid("-o idontexist --auto-clone", grep="Domain 'idontexist' was not found") # Non-existent vm name
|
||||
c.add_invalid(_CLONE_UNMANAGED, grep="Either --auto-clone or --file") # XML file with several disks, but non specified
|
||||
c.add_invalid(_CLONE_UNMANAGED + " --file virt-install", grep="overwrite the existing path") # XML w/ disks, overwriting existing files with no --preserve
|
||||
c.add_invalid(_CLONE_MANAGED + " --file /tmp/clonevol", grep="matching name 'default-vol'") # will attempt to clone across pools, which test driver doesn't support
|
||||
c.add_invalid(_CLONE_NOEXIST + " --auto-clone", grep="'/i/really/dont/exist' does not exist.") # XML w/ non-existent storage, WITHOUT --preserve
|
||||
c.add_valid(_CLONE_NOEXIST + " --file %(EXISTIMG1)s --preserve") # XML w/ non-existent storage, but using --preserve flag shouldn't raise an error
|
||||
c.add_invalid(_CLONE_NOEXIST + " --file %(EXISTIMG1)s", grep="StoragePool.install testsuite mocked failure") # XML w/ non-existent storage, WITHOUT --preserve, so it _should_ error
|
||||
|
||||
|
||||
|
||||
|
@ -214,11 +214,18 @@ class _CloneDiskInfo:
|
||||
|
||||
def __init__(self, srcdisk):
|
||||
self.disk = DeviceDisk(srcdisk.conn, parsexml=srcdisk.get_xml())
|
||||
self.disk.set_backend_for_existing_path()
|
||||
self.new_disk = None
|
||||
|
||||
self._share_msg = _get_shareable_msg(self.disk)
|
||||
self._cloneable_msg = -1
|
||||
try:
|
||||
# Failure here means source path may not exist. Sometimes
|
||||
# that's fatal, sometimes it's not (like with `--preserve`),
|
||||
# but we don't know for sure until later.
|
||||
self.disk.set_backend_for_existing_path()
|
||||
except Exception as e:
|
||||
self._cloneable_msg = str(e)
|
||||
|
||||
self._share_msg = _get_shareable_msg(self.disk)
|
||||
self._newpath_msg = None
|
||||
|
||||
self._action = None
|
||||
|
Loading…
Reference in New Issue
Block a user