Blob Blame History Raw
From 62bd04e98582005d38a17850afbd25465015ae1b Mon Sep 17 00:00:00 2001
Message-Id: <62bd04e98582005d38a17850afbd25465015ae1b@dist-git>
From: Michal Privoznik <mprivozn@redhat.com>
Date: Thu, 24 Oct 2019 08:45:49 +0200
Subject: [PATCH] domain_conf: Make virDomainDeviceFindSCSIController accept
 virDomainDeviceDriveAddress struct
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

So far, the virDomainDeviceFindSCSIController() takes
virDomainDeviceInfo structure which is an overkill. It assumes
that the passed structure is type of
VIR_DOMAIN_DEVICE_ADDRESS_TYPE_DRIVE which is not obvious.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
(cherry picked from commit 9cddc6e8ee9d9ce62dd20a6317c3148f4cd1c0e9)

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

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Message-Id: <ee6d546175c25f26c3f95fd5bc4de47be66ae603.1571899509.git.mprivozn@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
---
 src/conf/domain_conf.c         | 6 +++---
 src/conf/domain_conf.h         | 2 +-
 src/qemu/qemu_domain_address.c | 2 +-
 src/vbox/vbox_common.c         | 2 +-
 4 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c
index 60f426df04..333d9836c1 100644
--- a/src/conf/domain_conf.c
+++ b/src/conf/domain_conf.c
@@ -8235,13 +8235,13 @@ virDomainHostdevDefParseXMLCaps(xmlNodePtr node ATTRIBUTE_UNUSED,
 
 virDomainControllerDefPtr
 virDomainDeviceFindSCSIController(const virDomainDef *def,
-                                  virDomainDeviceInfoPtr info)
+                                  const virDomainDeviceDriveAddress *addr)
 {
     size_t i;
 
     for (i = 0; i < def->ncontrollers; i++) {
         if (def->controllers[i]->type == VIR_DOMAIN_CONTROLLER_TYPE_SCSI &&
-            def->controllers[i]->idx == info->addr.drive.controller)
+            def->controllers[i]->idx == addr->controller)
             return def->controllers[i];
     }
 
@@ -18606,7 +18606,7 @@ virDomainDefMaybeAddHostdevSCSIcontroller(virDomainDefPtr def)
              * So let's grab the model from it and update the model we're
              * going to add as long as this one isn't undefined. The premise
              * being keeping the same controller model for all SCSI hostdevs. */
-            cont = virDomainDeviceFindSCSIController(def, hostdev->info);
+            cont = virDomainDeviceFindSCSIController(def, &hostdev->info->addr.drive);
             if (cont && cont->model != -1)
                 newModel = cont->model;
         }
diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h
index ef8f061ae2..5eb9b257a7 100644
--- a/src/conf/domain_conf.h
+++ b/src/conf/domain_conf.h
@@ -2866,7 +2866,7 @@ int virDomainDiskGetFormat(virDomainDiskDefPtr def);
 void virDomainDiskSetFormat(virDomainDiskDefPtr def, int format);
 virDomainControllerDefPtr
 virDomainDeviceFindSCSIController(const virDomainDef *def,
-                                  virDomainDeviceInfoPtr info);
+                                  const virDomainDeviceDriveAddress *addr);
 virDomainDiskDefPtr virDomainDiskFindByBusAndDst(virDomainDefPtr def,
                                                  int bus,
                                                  char *dst);
diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c
index 0cb5af4a87..4f0278d348 100644
--- a/src/qemu/qemu_domain_address.c
+++ b/src/qemu/qemu_domain_address.c
@@ -113,7 +113,7 @@ qemuDomainFindSCSIControllerModel(const virDomainDef *def,
 {
     virDomainControllerDefPtr cont;
 
-    if (!(cont = virDomainDeviceFindSCSIController(def, info))) {
+    if (!(cont = virDomainDeviceFindSCSIController(def, &info->addr.drive))) {
         virReportError(VIR_ERR_INTERNAL_ERROR,
                        _("unable to find a SCSI controller for idx=%d"),
                        info->addr.drive.controller);
diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c
index eed7c83913..fe3c3ab2aa 100644
--- a/src/vbox/vbox_common.c
+++ b/src/vbox/vbox_common.c
@@ -1118,7 +1118,7 @@ vboxAttachDrives(virDomainDefPtr def, vboxDriverPtr data, IMachine *machine)
         case VIR_DOMAIN_DISK_BUS_SCSI:
             VBOX_UTF8_TO_UTF16(VBOX_CONTROLLER_SCSI_NAME, &storageCtlName);
 
-            cont = virDomainDeviceFindSCSIController(def, &disk->info);
+            cont = virDomainDeviceFindSCSIController(def, &disk->info.addr.drive);
             if (cont && cont->model == VIR_DOMAIN_CONTROLLER_MODEL_SCSI_LSISAS1068) {
                 VBOX_UTF16_FREE(storageCtlName);
                 VBOX_UTF8_TO_UTF16(VBOX_CONTROLLER_SAS_NAME, &storageCtlName);
-- 
2.23.0