From 9ae3dbe05b6a38b04ae0c9382496ba618d8ff31d Mon Sep 17 00:00:00 2001 From: Cole Robinson Date: Wed, 10 Dec 2014 12:55:08 -0500 Subject: [PATCH] virt-install: Fix --disk pool=NETPOOL,size=... creation --- .../compare/virt-install-many-devices.xml | 15 +++++++++++---- tests/clitest.py | 1 + virtinst/devicedisk.py | 1 + virtinst/diskbackend.py | 13 ++++++++++--- virtinst/storage.py | 4 ++-- 5 files changed, 25 insertions(+), 9 deletions(-) diff --git a/tests/cli-test-xml/compare/virt-install-many-devices.xml b/tests/cli-test-xml/compare/virt-install-many-devices.xml index 8bca4f78..292d3042 100644 --- a/tests/cli-test-xml/compare/virt-install-many-devices.xml +++ b/tests/cli-test-xml/compare/virt-install-many-devices.xml @@ -76,12 +76,19 @@ + + + + + + + - + @@ -95,7 +102,7 @@ - + @@ -109,14 +116,14 @@ - + - + diff --git a/tests/clitest.py b/tests/clitest.py index 48a2a793..f0177925 100644 --- a/tests/clitest.py +++ b/tests/clitest.py @@ -530,6 +530,7 @@ c.add_compare(""" \ --disk /dev/default-pool/iso-vol \ --disk /dev/default-pool/iso-vol,format=qcow2 \ --disk source_pool=rbd-ceph,source_volume=some-rbd-vol,size=.1 \ +--disk pool=rbd-ceph,size=.1 \ --disk source_protocol=http,source_host_name=example.com,source_host_port=8000,source_name=/path/to/my/file \ --disk source_protocol=nbd,source_host_transport=unix,source_host_socket=/tmp/socket,bus=scsi \ --disk gluster://192.168.1.100/test-volume/test-gluster.qcow2 \ diff --git a/virtinst/devicedisk.py b/virtinst/devicedisk.py index 77200d60..f21dd16d 100644 --- a/virtinst/devicedisk.py +++ b/virtinst/devicedisk.py @@ -630,6 +630,7 @@ class VirtualDisk(VirtualDevice): path += poolxml.source_name + "/" path += volxml.name self.source_name = path + self.type = "network" def _set_network_source_from_backend(self): if (self._storage_backend.get_vol_object() or diff --git a/virtinst/diskbackend.py b/virtinst/diskbackend.py index 864ad1ee..2bcd064b 100644 --- a/virtinst/diskbackend.py +++ b/virtinst/diskbackend.py @@ -233,11 +233,17 @@ class _StorageCreator(_StorageBase): if self._vol_install and not self._path: xmlobj = StoragePool(self._conn, parsexml=self._vol_install.pool.XMLDesc(0)) - self._path = (xmlobj.target_path + "/" + self._vol_install.name) + if self.get_dev_type() == "network": + self._path = self._vol_install.name + else: + self._path = (xmlobj.target_path + "/" + + self._vol_install.name) return self._path def get_vol_install(self): return self._vol_install + def get_vol_xml(self): + return self._vol_install def get_size(self): if self._size is None: @@ -250,6 +256,9 @@ class _StorageCreator(_StorageBase): if self._vol_install: if self._vol_install.file_type == libvirt.VIR_STORAGE_VOL_FILE: self._dev_type = "file" + elif (self._vol_install.file_type == + libvirt.VIR_STORAGE_VOL_NETWORK): + self._dev_type = "network" else: self._dev_type = "block" else: @@ -287,8 +296,6 @@ class _StorageCreator(_StorageBase): return True def get_vol_object(self): return None - def get_vol_xml(self): - return None def get_parent_pool(self): if self._vol_install: return self._vol_install.pool diff --git a/virtinst/storage.py b/virtinst/storage.py index 20571fa9..bdbd064e 100644 --- a/virtinst/storage.py +++ b/virtinst/storage.py @@ -547,8 +547,8 @@ class StorageVolume(_StorageObject): TYPE_FILE = getattr(libvirt, "VIR_STORAGE_VOL_FILE", 0) TYPE_BLOCK = getattr(libvirt, "VIR_STORAGE_VOL_BLOCK", 1) TYPE_DIR = getattr(libvirt, "VIR_STORAGE_VOL_DIR", 2) - TYPE_NETWORK = getattr(libvirt, "VIR_STORAGE_VOL_DIR", 3) - TYPE_NETDIR = getattr(libvirt, "VIR_STORAGE_VOL_DIR", 4) + TYPE_NETWORK = getattr(libvirt, "VIR_STORAGE_VOL_NETWORK", 3) + TYPE_NETDIR = getattr(libvirt, "VIR_STORAGE_VOL_NETDIR", 4) def __init__(self, *args, **kwargs):