From 8c0704a921ddb69d8cf9be7bc6bc7221a3dd1b90 Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Wed, 29 Jan 2020 19:06:12 -0500 Subject: [PATCH] diskbackend: Treat /dev paths on remote connections as 'block' Currently if the path isn't managed on a remote connection we treat it as file. Add this simple heuristic to improve the common case. https://bugzilla.redhat.com/show_bug.cgi?id=1726202 Signed-off-by: Cole Robinson --- .../compare/virt-install-remote-storage.xml | 92 +++++++++++++++++++ tests/test_cli.py | 5 +- virtinst/diskbackend.py | 9 +- 3 files changed, 103 insertions(+), 3 deletions(-) create mode 100644 tests/data/cli/compare/virt-install-remote-storage.xml diff --git a/tests/data/cli/compare/virt-install-remote-storage.xml b/tests/data/cli/compare/virt-install-remote-storage.xml new file mode 100644 index 00000000..306fa83e --- /dev/null +++ b/tests/data/cli/compare/virt-install-remote-storage.xml @@ -0,0 +1,92 @@ + + vm1 + 00000000-1111-2222-3333-444444444444 + 65536 + 65536 + 1 + + hvm + + + + + + + + destroy + + + + + + /usr/bin/test-hv + + + + + + + + + + + + + + + + + + + + + + + + + + + vm1 + 00000000-1111-2222-3333-444444444444 + 65536 + 65536 + 1 + + hvm + + + + + + + + + + + + /usr/bin/test-hv + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/test_cli.py b/tests/test_cli.py index 0392fac4..83a2c59b 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -931,9 +931,10 @@ c.add_invalid("--install fedora29 --unattended user-login=root", grep="as user-l c = vinst.add_category("remote", "--connect %(URI-TEST-REMOTE)s --nographics --noautoconsole") c.add_valid("--nodisks --pxe") # Simple pxe nodisks -c.add_valid("--pxe --disk /foo/bar/baz,size=.01") # Creating any random path on the remote host -c.add_valid("--pxe --disk /dev/zde") # /dev file that we just pass through to the remote VM c.add_valid("--cdrom %(EXISTIMG1)s --disk none --livecd --dry") # remote cdrom install +c.add_compare("--pxe " +"--pxe --disk /foo/bar/baz,size=.01 " # Creating any random path on the remote host +"--disk /dev/zde ", "remote-storage") # /dev file that we just pass through to the remote VM c.add_invalid("--pxe --disk /foo/bar/baz") # File that doesn't exist after auto storage setup c.add_invalid("--nodisks --location /tmp") # Use of --location c.add_invalid("--file /foo/bar/baz --pxe") # Trying to use unmanaged storage without size argument diff --git a/virtinst/diskbackend.py b/virtinst/diskbackend.py index e85b8216..5bb97550 100644 --- a/virtinst/diskbackend.py +++ b/virtinst/diskbackend.py @@ -203,7 +203,14 @@ def _get_dev_type(path, vol_xml, vol_object, pool_xml, remote): if path_is_url(path): return "network" - if not remote: + if remote: + if not _can_auto_manage(path): + # Just a heurisitic, if this path is one of the ones + # we don't try to auto-import, then consider it a + # block device, because managing those correctly is difficult + return "block" + + else: if os.path.isdir(path): return "dir" elif _stat_is_block(path):