From 9cddc6e8ee9d9ce62dd20a6317c3148f4cd1c0e9 Mon Sep 17 00:00:00 2001 From: Michal Privoznik Date: Tue, 10 Sep 2019 16:45:47 +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 Reviewed-by: Daniel P. Berrangé --- src/conf/domain_conf.c | 6 +++--- src/conf/domain_conf.h | 5 ++++- src/qemu/qemu_domain_address.c | 2 +- src/vbox/vbox_common.c | 2 +- 4 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 80e19a15df..5940f05013 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -8528,13 +8528,13 @@ virDomainHostdevDefParseXMLCaps(xmlNodePtr node G_GNUC_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]; } @@ -18560,7 +18560,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 a481389925..c69d1b7ef5 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2858,7 +2858,10 @@ 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); virDomainControllerDefPtr virDomainControllerDefNew(virDomainControllerType type); void virDomainControllerDefFree(virDomainControllerDefPtr def); diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index fa40ba4f7d..82db62e988 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -111,7 +111,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 475b3a3147..5486e5ff3b 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -1110,7 +1110,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);