mirror of
https://github.com/virt-manager/virt-manager.git
synced 2024-12-23 17:34:21 +03:00
devicedisk: Catch --disk /dev/idontexist,size=2
This commit is contained in:
parent
52691c511e
commit
9b62c2260d
@ -1568,16 +1568,17 @@ class ParserDisk(VirtCLIParser):
|
||||
StoragePool.build_default_pool(self.guest.conn)
|
||||
poolobj = self.guest.conn.storagePoolLookupByName(poolname)
|
||||
|
||||
if inst.wants_storage_creation():
|
||||
newvolname = os.path.basename(inst.path)
|
||||
poolobj = inst.get_parent_pool()
|
||||
elif volname:
|
||||
if volname:
|
||||
vol_object = poolobj.storageVolLookupByName(volname)
|
||||
inst.set_vol_object(vol_object)
|
||||
poolobj = None
|
||||
|
||||
if poolobj and (fmt or size or sparse or backing_store):
|
||||
if not fmt:
|
||||
if ((poolobj or inst.wants_storage_creation()) and
|
||||
(fmt or size or sparse or backing_store)):
|
||||
if not poolobj:
|
||||
poolobj = inst.get_parent_pool()
|
||||
newvolname = os.path.basename(inst.path)
|
||||
if poolobj and not fmt:
|
||||
fmt = _get_default_image_format(self.guest.conn, poolobj)
|
||||
if newvolname is None:
|
||||
newvolname = _generate_new_volume_name(self.guest, poolobj,
|
||||
|
@ -410,6 +410,12 @@ class VirtualDisk(VirtualDevice):
|
||||
raise ValueError(_("Size must be specified for non "
|
||||
"existent volume '%s'" % volname))
|
||||
|
||||
# This catches --disk /dev/idontexist,size=1 if /dev is unmanaged
|
||||
if not poolobj:
|
||||
raise RuntimeError(_("Don't know how to create storage for "
|
||||
"path '%s'. Use libvirt APIs to manage the parent directory "
|
||||
"as a pool first.") % volname)
|
||||
|
||||
logging.debug("Creating volume '%s' on pool '%s'",
|
||||
volname, poolobj.name())
|
||||
|
||||
@ -710,9 +716,7 @@ class VirtualDisk(VirtualDevice):
|
||||
If true, this disk needs storage creation parameters or things
|
||||
will error.
|
||||
"""
|
||||
return (self.path and
|
||||
not self._storage_backend.exists() and
|
||||
self.get_parent_pool())
|
||||
return self.path and not self._storage_backend.exists()
|
||||
|
||||
def __managed_storage(self):
|
||||
"""
|
||||
|
Loading…
Reference in New Issue
Block a user