Refactoring: Use virHostdevIsSCSIDevice()

Use the util function virHostdevIsSCSIDevice() to simplify if
statements.

Signed-off-by: Marc Hartmayer <mhartmay@linux.vnet.ibm.com>
Reviewed-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
This commit is contained in:
Marc Hartmayer 2016-11-15 19:25:41 +01:00 committed by Michal Privoznik
parent 20bf8ea693
commit 1c122e737e
7 changed files with 15 additions and 26 deletions

View File

@ -1137,7 +1137,8 @@ libvirt_util_la_LIBADD = $(CAPNG_LIBS) $(YAJL_LIBS) $(LIBNL_LIBS) \
noinst_LTLIBRARIES += libvirt_conf.la
libvirt_la_BUILT_LIBADD += libvirt_conf.la
libvirt_conf_la_SOURCES = $(CONF_SOURCES)
libvirt_conf_la_CFLAGS = $(AM_CFLAGS)
libvirt_conf_la_CFLAGS = \
-I$(srcdir)/conf $(AM_CFLAGS)
libvirt_conf_la_LDFLAGS = $(AM_LDFLAGS)
libvirt_conf_la_LIBADD = $(LIBXML_LIBS)

View File

@ -55,6 +55,7 @@
#include "virtpm.h"
#include "virstring.h"
#include "virnetdev.h"
#include "virhostdev.h"
#define VIR_FROM_THIS VIR_FROM_DOMAIN
@ -4247,9 +4248,7 @@ virDomainDeviceDefPostParseInternal(virDomainDeviceDefPtr dev,
if (dev->type == VIR_DOMAIN_DEVICE_HOSTDEV) {
virDomainHostdevDefPtr hdev = dev->data.hostdev;
if (hdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
hdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI) {
if (virHostdevIsSCSIDevice(hdev)) {
if (hdev->info->type == VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE &&
virDomainHostdevAssignAddress(xmlopt, def, hdev) < 0) {
virReportError(VIR_ERR_XML_ERROR, "%s",
@ -15648,8 +15647,7 @@ virDomainDefMaybeAddHostdevSCSIcontroller(virDomainDefPtr def)
for (i = 0; i < def->nhostdevs; i++) {
hostdev = def->hostdevs[i];
if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI &&
if (virHostdevIsSCSIDevice(hostdev) &&
(int)hostdev->info->addr.drive.controller > maxController) {
maxController = hostdev->info->addr.drive.controller;
}

View File

@ -5199,8 +5199,7 @@ qemuBuildHostdevCommandLine(virCommandPtr cmd,
}
/* SCSI */
if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
subsys->type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI) {
if (virHostdevIsSCSIDevice(hostdev)) {
if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_SCSI_GENERIC)) {
char *drvstr;

View File

@ -1187,10 +1187,9 @@ static bool
qemuIsSharedHostdev(virDomainHostdevDefPtr hostdev)
{
return (hostdev->shareable &&
(hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI &&
hostdev->source.subsys.u.scsi.protocol !=
VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI));
(virHostdevIsSCSIDevice(hostdev) &&
hostdev->source.subsys.u.scsi.protocol !=
VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI));
}

View File

@ -1185,12 +1185,9 @@ qemuDomainSecretHostdevPrepare(virConnectPtr conn,
qemuDomainObjPrivatePtr priv,
virDomainHostdevDefPtr hostdev)
{
virDomainHostdevSubsysPtr subsys = &hostdev->source.subsys;
qemuDomainSecretInfoPtr secinfo = NULL;
if (hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
subsys->type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI) {
if (virHostdevIsSCSIDevice(hostdev)) {
virDomainHostdevSubsysSCSIPtr scsisrc = &hostdev->source.subsys.u.scsi;
virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc = &scsisrc->u.iscsi;
@ -4037,8 +4034,7 @@ void qemuDomainObjCheckHostdevTaint(virQEMUDriverPtr driver,
virDomainHostdevDefPtr hostdev,
qemuDomainLogContextPtr logCtxt)
{
if (!(hostdev->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
hostdev->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI))
if (!virHostdevIsSCSIDevice(hostdev))
return;
if (hostdev->source.subsys.u.scsi.rawio == VIR_TRISTATE_BOOL_YES)

View File

@ -4312,8 +4312,7 @@ qemuProcessSetupRawIO(virQEMUDriverPtr driver,
/* If rawio not already set, check hostdevs as well */
if (!rawio) {
for (i = 0; i < vm->def->nhostdevs; i++) {
if (!(vm->def->hostdevs[i]->mode == VIR_DOMAIN_HOSTDEV_MODE_SUBSYS &&
vm->def->hostdevs[i]->source.subsys.type == VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI))
if (!virHostdevIsSCSIDevice(vm->def->hostdevs[i]))
continue;
virDomainHostdevSubsysSCSIPtr scsisrc =

View File

@ -1114,8 +1114,7 @@ virHostdevUpdateActiveSCSIDevices(virHostdevManagerPtr mgr,
hostdev = hostdevs[i];
scsisrc = &hostdev->source.subsys.u.scsi;
if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI)
if (!virHostdevIsSCSIDevice(hostdev))
continue;
if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI) {
@ -1413,8 +1412,7 @@ virHostdevPrepareSCSIDevices(virHostdevManagerPtr mgr,
virDomainHostdevDefPtr hostdev = hostdevs[i];
virDomainHostdevSubsysSCSIPtr scsisrc = &hostdev->source.subsys.u.scsi;
if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI)
if (!virHostdevIsSCSIDevice(hostdev))
continue;
if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI) {
@ -1605,8 +1603,7 @@ virHostdevReAttachSCSIDevices(virHostdevManagerPtr mgr,
virDomainHostdevDefPtr hostdev = hostdevs[i];
virDomainHostdevSubsysSCSIPtr scsisrc = &hostdev->source.subsys.u.scsi;
if (hostdev->mode != VIR_DOMAIN_HOSTDEV_MODE_SUBSYS ||
hostdev->source.subsys.type != VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SCSI)
if (!virHostdevIsSCSIDevice(hostdev))
continue;
if (scsisrc->protocol == VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI)