File virtinst-dont-create-storage-pool-for-dryrun.patch of Package virt-manager.37148

Reference: bsc#1228384
Don't create a storage pool for a dry run

Index: virt-manager-4.1.0/virtinst/cli.py
===================================================================
--- virt-manager-4.1.0.orig/virtinst/cli.py
+++ virt-manager-4.1.0/virtinst/cli.py
@@ -1330,6 +1330,7 @@ class VirtCLIParser(metaclass=_InitClass
     _virtargs = []
     aliases = {}
     supports_clearxml = True
+    dryrun = False
 
     @classmethod
     def add_arg(cls, cliname, propname, *args, **kwargs):
@@ -3615,7 +3616,7 @@ class ParserDisk(VirtCLIParser):
     ###################
 
     def set_path_cb(self, inst, val, virtarg):
-        inst.set_source_path(val)
+        inst.set_source_path(val, self.dryrun)
     def path_lookup_cb(self, inst, val, virtarg):
         return inst.get_source_path() == val
 
@@ -4840,6 +4841,8 @@ def run_parser(options, guest, parsercla
     ret = []
     optstr_list = xmlutil.listify(getattr(options, parserclass.cli_arg_name))
 
+    if hasattr(options, "dry"):
+        parserclass.dryrun = options.dry
     for optstr in optstr_list:
         parserobj = parserclass(optstr, guest=guest, editing=bool(editinst))
         parseret = parserobj.parse(editinst)
Index: virt-manager-4.1.0/virtinst/devices/disk.py
===================================================================
--- virt-manager-4.1.0.orig/virtinst/devices/disk.py
+++ virt-manager-4.1.0/virtinst/devices/disk.py
@@ -635,7 +635,7 @@ class DeviceDisk(Device):
             self._resolve_storage_backend()
         return self._storage_backend.get_path()
 
-    def set_source_path(self, newpath):
+    def set_source_path(self, newpath, dryrun=False):
         if self._storage_backend.will_create_storage():
             raise xmlutil.DevError(
                     "Can't change disk path if storage creation info "
@@ -644,7 +644,7 @@ class DeviceDisk(Device):
         # User explicitly changed 'path', so try to lookup its storage
         # object since we may need it
         (newpath, vol_object, parent_pool) = diskbackend.manage_path(
-                self.conn, newpath)
+                self.conn, newpath, dryrun)
 
         self._change_backend(newpath, vol_object, parent_pool)
         self._set_xmlpath(self.get_source_path())
Index: virt-manager-4.1.0/virtinst/diskbackend.py
===================================================================
--- virt-manager-4.1.0.orig/virtinst/diskbackend.py
+++ virt-manager-4.1.0/virtinst/diskbackend.py
@@ -136,7 +136,7 @@ def _get_storage_search_path(path):
     return path
 
 
-def manage_path(conn, path):
+def manage_path(conn, path, dryrun=False):
     """
     If path is not managed, try to create a storage pool to probe the path
     """
@@ -150,7 +150,7 @@ def manage_path(conn, path):
 
     searchpath = _get_storage_search_path(path)
     vol, pool = _check_if_path_managed(conn, searchpath)
-    if vol or pool or not _can_auto_manage(path):
+    if vol or pool or not _can_auto_manage(path) or dryrun is True:
         return path, vol, pool
 
     dirname = os.path.dirname(path)
openSUSE Build Service is sponsored by