d759b5
From 62bd04e98582005d38a17850afbd25465015ae1b Mon Sep 17 00:00:00 2001
d759b5
Message-Id: <62bd04e98582005d38a17850afbd25465015ae1b@dist-git>
e00e43
From: Michal Privoznik <mprivozn@redhat.com>
d759b5
Date: Thu, 24 Oct 2019 08:45:49 +0200
e00e43
Subject: [PATCH] domain_conf: Make virDomainDeviceFindSCSIController accept
e00e43
 virDomainDeviceDriveAddress struct
e00e43
MIME-Version: 1.0
e00e43
Content-Type: text/plain; charset=UTF-8
e00e43
Content-Transfer-Encoding: 8bit
e00e43
e00e43
So far, the virDomainDeviceFindSCSIController() takes
e00e43
virDomainDeviceInfo structure which is an overkill. It assumes
e00e43
that the passed structure is type of
e00e43
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE which is not obvious.
e00e43
e00e43
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
e00e43
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
e00e43
(cherry picked from commit 9cddc6e8ee9d9ce62dd20a6317c3148f4cd1c0e9)
e00e43
d759b5
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1741782
e00e43
e00e43
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
d759b5
Message-Id: <ee6d546175c25f26c3f95fd5bc4de47be66ae603.1571899509.git.mprivozn@redhat.com>
e00e43
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
e00e43
---
e00e43
 src/conf/domain_conf.c         | 6 +++---
e00e43
 src/conf/domain_conf.h         | 2 +-
e00e43
 src/qemu/qemu_domain_address.c | 2 +-
e00e43
 src/vbox/vbox_common.c         | 2 +-
e00e43
 4 files changed, 6 insertions(+), 6 deletions(-)
e00e43
e00e43
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
d759b5
index 60f426df04..333d9836c1 100644
e00e43
--- a/src/conf/domain_conf.c
e00e43
+++ b/src/conf/domain_conf.c
e00e43
@@ -8235,13 +8235,13 @@ virDomainHostdevDefParseXMLCaps(xmlNodePtr node ATTRIBUTE_UNUSED,
e00e43
 
e00e43
 virDomainControllerDefPtr
e00e43
 virDomainDeviceFindSCSIController(const virDomainDef *def,
e00e43
-                                  virDomainDeviceInfoPtr info)
e00e43
+                                  const virDomainDeviceDriveAddress *addr)
e00e43
 {
e00e43
     size_t i;
e00e43
 
e00e43
     for (i = 0; i < def->ncontrollers; i++) {
e00e43
         if (def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI &&
e00e43
-            def->controllers[i]->idx == info->addr.drive.controller)
e00e43
+            def->controllers[i]->idx == addr->controller)
e00e43
             return def->controllers[i];
e00e43
     }
e00e43
 
d759b5
@@ -18606,7 +18606,7 @@ virDomainDefMaybeAddHostdevSCSIcontroller(virDomainDefPtr def)
e00e43
              * So let's grab the model from it and update the model we're
e00e43
              * going to add as long as this one isn't undefined. The premise
e00e43
              * being keeping the same controller model for all SCSI hostdevs. */
e00e43
-            cont = virDomainDeviceFindSCSIController(def, hostdev->info);
e00e43
+            cont = virDomainDeviceFindSCSIController(def, &hostdev->info->addr.drive);
e00e43
             if (cont && cont->model != -1)
e00e43
                 newModel = cont->model;
e00e43
         }
e00e43
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
d759b5
index ef8f061ae2..5eb9b257a7 100644
e00e43
--- a/src/conf/domain_conf.h
e00e43
+++ b/src/conf/domain_conf.h
e00e43
@@ -2866,7 +2866,7 @@ int virDomainDiskGetFormat(virDomainDiskDefPtr def);
e00e43
 void virDomainDiskSetFormat(virDomainDiskDefPtr def, int format);
e00e43
 virDomainControllerDefPtr
e00e43
 virDomainDeviceFindSCSIController(const virDomainDef *def,
e00e43
-                                  virDomainDeviceInfoPtr info);
e00e43
+                                  const virDomainDeviceDriveAddress *addr);
e00e43
 virDomainDiskDefPtr virDomainDiskFindByBusAndDst(virDomainDefPtr def,
e00e43
                                                  int bus,
e00e43
                                                  char *dst);
e00e43
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
e00e43
index 0cb5af4a87..4f0278d348 100644
e00e43
--- a/src/qemu/qemu_domain_address.c
e00e43
+++ b/src/qemu/qemu_domain_address.c
e00e43
@@ -113,7 +113,7 @@ qemuDomainFindSCSIControllerModel(const virDomainDef *def,
e00e43
 {
e00e43
     virDomainControllerDefPtr cont;
e00e43
 
e00e43
-    if (!(cont = virDomainDeviceFindSCSIController(def, info))) {
e00e43
+    if (!(cont = virDomainDeviceFindSCSIController(def, &info->addr.drive))) {
e00e43
         virReportError(VIR_ERR_INTERNAL_ERROR,
e00e43
                        _("unable to find a SCSI controller for idx=%d"),
e00e43
                        info->addr.drive.controller);
e00e43
diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
e00e43
index eed7c83913..fe3c3ab2aa 100644
e00e43
--- a/src/vbox/vbox_common.c
e00e43
+++ b/src/vbox/vbox_common.c
e00e43
@@ -1118,7 +1118,7 @@ vboxAttachDrives(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine)
e00e43
         case VIR_DOMAIN_DISK_BUS_SCSI:
e00e43
             VBOX_UTF8_TO_UTF16(VBOX_CONTROLLER_SCSI_NAME, &storageCtlName);
e00e43
 
e00e43
-            cont = virDomainDeviceFindSCSIController(def, &disk->info);
e00e43
+            cont = virDomainDeviceFindSCSIController(def, &disk->info.addr.drive);
e00e43
             if (cont && cont->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1068) {
e00e43
                 VBOX_UTF16_FREE(storageCtlName);
e00e43
                 VBOX_UTF8_TO_UTF16(VBOX_CONTROLLER_SAS_NAME, &storageCtlName);
e00e43
-- 
e00e43
2.23.0
e00e43