Blob Blame History Raw
From 9425b5beaa81fe35394942b358e2d343540d5c56 Mon Sep 17 00:00:00 2001
From: Martin Kletzander <mkletzan@redhat.com>
Date: Thu, 27 Feb 2014 13:56:20 +0100
Subject: [PATCH 1/3] addhardware: Move controller addition before target
 generation

https://bugzilla.redhat.com/show_bug.cgi?id=1036716

RHEL-only; upstream this is a part of commit 00d5312b in which there's
a _set_disk_controller() function created with the code that is being
moved in there.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
---
 virtManager/addhardware.py | 36 ++++++++++++++++++------------------
 1 file changed, 18 insertions(+), 18 deletions(-)

diff --git a/virtManager/addhardware.py b/virtManager/addhardware.py
index 7719f8f..90cec84 100644
--- a/virtManager/addhardware.py
+++ b/virtManager/addhardware.py
@@ -1478,6 +1478,24 @@ class vmmAddHardware(vmmGObjectUI):
         for d in disks:
             used.append(d.target)
 
+        # Add a SCSI controller with model virtio-scsi if needed
+        disk.vmm_controller = None
+        if (controller_model == "virtio-scsi") and (bus == "scsi"):
+            controllers = self.vm.get_controller_devices()
+            controller = VirtualControllerSCSI(conn=self.conn.vmm)
+            controller.set_model(controller_model)
+            disk.vmm_controller = controller
+            for d in controllers:
+                if controller.type == d.type:
+                    controller.index += 1
+                if controller_model == d.model:
+                    disk.vmm_controller = None
+                    controller = d
+                    break
+
+            disk.address.type = disk.address.ADDRESS_TYPE_DRIVE
+            disk.address.controller = controller.index
+
         disk.generate_target(used)
 
         isfatal, errmsg = disk.is_size_conflict()
@@ -1498,24 +1516,6 @@ class vmmAddHardware(vmmGObjectUI):
         uihelpers.check_path_search_for_qemu(self.topwin,
                                              self.conn, disk.path)
 
-        # Add a SCSI controller with model virtio-scsi if needed
-        disk.vmm_controller = None
-        if (controller_model == "virtio-scsi") and (bus == "scsi"):
-            controllers = self.vm.get_controller_devices()
-            controller = VirtualControllerSCSI(conn=self.conn.vmm)
-            controller.set_model(controller_model)
-            disk.vmm_controller = controller
-            for d in controllers:
-                if controller.type == d.type:
-                    controller.index += 1
-                if controller_model == d.model:
-                    disk.vmm_controller = None
-                    controller = d
-                    break
-
-            disk.address.type = disk.address.ADDRESS_TYPE_DRIVE
-            disk.address.controller = controller.index
-
         self._dev = disk
         return True
 
-- 
1.8.5.3