From 9b2e6886d027625eb2ff1666e398bae6c4a328ec Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Tue, 22 Jan 2019 10:28:38 -0500 Subject: [PATCH] disk: Fix virt-xml --add-device --disk size=X --- .../compare/virt-xml-add-disk-default-storage.xml | 13 +++++++++++++ tests/clitest.py | 1 + virtinst/devices/disk.py | 2 ++ 3 files changed, 16 insertions(+) create mode 100644 tests/cli-test-xml/compare/virt-xml-add-disk-default-storage.xml diff --git a/tests/cli-test-xml/compare/virt-xml-add-disk-default-storage.xml b/tests/cli-test-xml/compare/virt-xml-add-disk-default-storage.xml new file mode 100644 index 000000000..a15a709ab --- /dev/null +++ b/tests/cli-test-xml/compare/virt-xml-add-disk-default-storage.xml @@ -0,0 +1,13 @@ + +
+ ++ ++ ++ ++ + + + + +Domain 'test-for-virtxml' defined successfully. +Changes will take effect after the domain is fully powered off. \ No newline at end of file diff --git a/tests/clitest.py b/tests/clitest.py index 240f208e0..71a79d791 100644 --- a/tests/clitest.py +++ b/tests/clitest.py @@ -967,6 +967,7 @@ c.add_compare("--add-device --sound pcspk", "add-sound") c.add_compare("--add-device --disk %(EXISTIMG1)s,bus=virtio,target=vdf", "add-disk-basic") c.add_compare("--add-device --disk %(EXISTIMG1)s", "add-disk-notarget") # filling in acceptable target c.add_compare("--add-device --disk %(NEWIMG1)s,size=.01", "add-disk-create-storage") +c.add_compare("--add-device --disk size=.01", "add-disk-default-storage") c.add_compare("--remove-device --sound ich6", "remove-sound-model", check_version="1.3.5") # check_version=new graphics listen output c.add_compare("--remove-device --disk 3", "remove-disk-index") c.add_compare("--remove-device --disk /dev/null", "remove-disk-path") diff --git a/virtinst/devices/disk.py b/virtinst/devices/disk.py index dd33ca97c..533631eb0 100644 --- a/virtinst/devices/disk.py +++ b/virtinst/devices/disk.py @@ -413,6 +413,8 @@ class DeviceDisk(Device): def get_vol_object(self): return self._storage_backend.get_vol_object() def get_vol_install(self): + if not self._storage_backend: + return None return self._storage_backend.get_vol_install() def get_parent_pool(self): if self.get_vol_install():