diff options
author | Cole Robinson <crobinso@redhat.com> | 2020-11-03 12:53:25 -0500 |
---|---|---|
committer | Cole Robinson <crobinso@redhat.com> | 2020-11-03 13:03:03 -0500 |
commit | 1a1e4580c0e118e0361e443de464b197d96b73e0 (patch) | |
tree | a834715016ef165790fdeb01ef135a92ca53b231 | |
parent | 2d4b85b5bfad810c9d2ef3e8ed7958becdac8054 (diff) | |
download | virt-manager-1a1e4580c0e118e0361e443de464b197d96b73e0.tar.gz |
cloner: Explicitly reject 'network' disks we don't know how to clone
Signed-off-by: Cole Robinson <crobinso@redhat.com>
-rw-r--r-- | tests/data/cli/virtclone/clone-net.xml | 29 | ||||
-rw-r--r-- | tests/test_cli.py | 3 | ||||
-rw-r--r-- | virtinst/cloner.py | 2 |
3 files changed, 34 insertions, 0 deletions
diff --git a/tests/data/cli/virtclone/clone-net.xml b/tests/data/cli/virtclone/clone-net.xml new file mode 100644 index 00000000..cd1f085e --- /dev/null +++ b/tests/data/cli/virtclone/clone-net.xml @@ -0,0 +1,29 @@ +<domain type='test' id='1'> + <name>origtest</name> + <uuid>db69fa1f-eef0-e567-3c20-3ef16f10376b</uuid> + <memory>8388608</memory> + <currentMemory>2097152</currentMemory> + <vcpu>2</vcpu> + <os> + <type arch='i686'>hvm</type> + <boot dev='hd'/> + </os> + <clock offset='utc'/> + <on_poweroff>destroy</on_poweroff> + <on_reboot>restart</on_reboot> + <on_crash>destroy</on_crash> + <devices> + <disk type='network' device='disk'> + <driver name='qemu' type='raw' cache='none' io='native'/> + <auth username='libvirt'> + <secret type='ceph' uuid='11111111-2222-3333-4444-55556666777'/> + </auth> + <source protocol='rbd' name='vms/foo1'> + <host name='host1' port='6789'/> + <host name='host2' port='6789'/> + <host name='host3' port='6789'/> + </source> + <target dev='vda' bus='virtio'/> + </disk> + </devices> +</domain> diff --git a/tests/test_cli.py b/tests/test_cli.py index b639d08f..51c7c7b4 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -1336,6 +1336,8 @@ _CLONE_NVRAM = "--original-xml %s/clone-nvram-auto.xml" % _CLONEXMLDIR _CLONE_NVRAM_NEWPOOL = "--original-xml %s/clone-nvram-newpool.xml" % _CLONEXMLDIR _CLONE_NVRAM_MISSING = "--original-xml %s/clone-nvram-missing.xml" % _CLONEXMLDIR _CLONE_EMPTY = "--original-xml %s/clone-empty.xml" % _CLONEXMLDIR +_CLONE_NET = "--original-xml %s/clone-net.xml" % _CLONEXMLDIR + vclon = App("virt-clone") c = vclon.add_category("remote", "--connect %(URI-TEST-REMOTE)s") @@ -1371,6 +1373,7 @@ c.add_invalid("-o test --auto-clone", grep="shutoff") # VM is running c.add_invalid("--connect %(URI-TEST-FULL)s -o test-clone-simple -n newvm --file %(EXISTIMG1)s") # Should complain about overwriting existing file c.add_invalid("--connect %(URI-TEST-REMOTE)s -o test-clone-simple --auto-clone --file /dev/default-pool/testvol9.img --check all=off", grep="Clone onto existing storage volume") # hit a specific error message c.add_invalid("--connect %(URI-TEST-FULL)s -o test-clone-full --auto-clone", grep="not enough free space") # catch failure of clone path setting +c.add_invalid(_CLONE_NET + " --auto-clone", grep="'network' is not cloneable") c = vclon.add_category("general", "-n clonetest") diff --git a/virtinst/cloner.py b/virtinst/cloner.py index d73f1b2c..8a69f02f 100644 --- a/virtinst/cloner.py +++ b/virtinst/cloner.py @@ -174,6 +174,8 @@ def _get_cloneable_msg(disk): """ if disk.wants_storage_creation(): return _("Disk path '%s' does not exist.") % disk.path + if (disk.type == "network" and not disk.get_vol_object()): + return _("Disk type '%s' is not cloneable.") % disk.type def _get_shareable_msg(disk): |