mirror of
https://github.com/virt-manager/virt-manager.git
synced 2025-03-09 08:58:27 +03:00
diskbackend: Mandate parent_pool when vol_object is passed
We will need parent pool for looking up info about network volumes
This commit is contained in:
parent
208672eea9
commit
f7c17d4c46
@ -1579,7 +1579,7 @@ class ParserDisk(VirtCLIParser):
|
||||
|
||||
if volname:
|
||||
vol_object = poolobj.storageVolLookupByName(volname)
|
||||
inst.set_vol_object(vol_object)
|
||||
inst.set_vol_object(vol_object, poolobj)
|
||||
poolobj = None
|
||||
|
||||
if ((poolobj or inst.wants_storage_creation()) and
|
||||
|
@ -536,8 +536,8 @@ class VirtualDisk(VirtualDevice):
|
||||
self._set_xmlpath(self.path)
|
||||
path = property(_get_path, _set_path)
|
||||
|
||||
def set_vol_object(self, vol_object):
|
||||
self._change_backend(None, vol_object, None)
|
||||
def set_vol_object(self, vol_object, parent_pool):
|
||||
self._change_backend(None, vol_object, parent_pool)
|
||||
self._set_xmlpath(self.path)
|
||||
|
||||
def set_vol_install(self, vol_install):
|
||||
@ -856,9 +856,12 @@ class VirtualDisk(VirtualDevice):
|
||||
if not self._storage_backend.will_create_storage():
|
||||
return
|
||||
|
||||
volobj = self._storage_backend.create(meter)
|
||||
if volobj:
|
||||
self._change_backend(None, volobj, None)
|
||||
vol_object = self._storage_backend.create(meter)
|
||||
if not vol_object:
|
||||
return
|
||||
|
||||
parent_pool = self.get_vol_install().pool
|
||||
self._change_backend(None, vol_object, parent_pool)
|
||||
|
||||
def set_defaults(self, guest):
|
||||
if self.is_cdrom():
|
||||
|
@ -81,7 +81,7 @@ def check_if_path_managed(conn, path):
|
||||
"""
|
||||
vol, ignore = _lookup_vol_by_path(conn, path)
|
||||
if vol:
|
||||
return vol, None
|
||||
return vol, vol.storagePoolLookupByVolume()
|
||||
|
||||
pool = _lookup_pool_by_dirname(conn, path)
|
||||
if not pool:
|
||||
@ -107,8 +107,6 @@ def check_if_path_managed(conn, path):
|
||||
raise ValueError(_("Cannot use storage %(path)s: %(err)s") %
|
||||
{'path' : path, 'err' : verr})
|
||||
|
||||
if vol:
|
||||
pool = None
|
||||
return vol, pool
|
||||
|
||||
|
||||
@ -434,6 +432,9 @@ class StorageBackend(_StorageBase):
|
||||
if self._vol_object is not None:
|
||||
self._path = None
|
||||
|
||||
if self._vol_object and not self._parent_pool:
|
||||
raise RuntimeError(
|
||||
"programming error: parent_pool must be specified")
|
||||
|
||||
# Cached bits
|
||||
self._vol_xml = None
|
||||
|
Loading…
x
Reference in New Issue
Block a user