提交 d2a57815 编写于 作者: L Laine Stump

node device: prepare node_device_linux_sysfs.c to add more functions

This file contains only a single function, detect_scsi_host_caps(),
which is declared in node_device_driver.h and called from both the hal
and udev backends. Other things common to the hal and udev drivers
can be placed in that file though. As a prelude to adding further
functions, this patch renames the existing function to something
closer in line with other internal libvirt function names
(nodeDeviceSysfsGetSCSIHostCaps()), and puts the declarations into a
separate .h file.
上级 3c93419b
## Process this file with automake to produce Makefile.in
## Copyright (C) 2005-2014 Red Hat, Inc.
## Copyright (C) 2005-2015 Red Hat, Inc.
##
## This library is free software; you can redistribute it and/or
## modify it under the terms of the GNU Lesser General Public
......@@ -966,7 +966,8 @@ ACCESS_DRIVER_POLKIT_POLICY = \
NODE_DEVICE_DRIVER_SOURCES = \
node_device/node_device_driver.c \
node_device/node_device_driver.h \
node_device/node_device_linux_sysfs.c
node_device/node_device_linux_sysfs.c \
node_device/node_device_linux_sysfs.h
NODE_DEVICE_DRIVER_HAL_SOURCES = \
node_device/node_device_hal.c \
......
......@@ -35,8 +35,9 @@
#include "virfile.h"
#include "virstring.h"
#include "node_device_conf.h"
#include "node_device_hal.h"
#include "node_device_driver.h"
#include "node_device_hal.h"
#include "node_device_linux_sysfs.h"
#include "virutil.h"
#include "viraccessapicheck.h"
#include "virnetdev.h"
......@@ -52,7 +53,7 @@ static int update_caps(virNodeDeviceObjPtr dev)
while (cap) {
switch (cap->data.type) {
case VIR_NODE_DEV_CAP_SCSI_HOST:
detect_scsi_host_caps(&dev->def->caps->data);
nodeDeviceSysfsGetSCSIHostCaps(&dev->def->caps->data);
break;
case VIR_NODE_DEV_CAP_NET:
if (virNetDevGetLinkInfo(cap->data.net.ifname, &cap->data.net.lnk) < 0)
......@@ -282,7 +283,7 @@ nodeDeviceLookupSCSIHostByWWN(virConnectPtr conn,
while (cap) {
if (cap->data.type == VIR_NODE_DEV_CAP_SCSI_HOST) {
detect_scsi_host_caps(&cap->data);
nodeDeviceSysfsGetSCSIHostCaps(&cap->data);
if (cap->data.scsi_host.flags &
VIR_NODE_DEV_CAP_FLAG_HBA_FC_HOST) {
if (STREQ(cap->data.scsi_host.wwnn, wwnn) &&
......
......@@ -44,8 +44,6 @@ extern virNodeDeviceDriverStatePtr driver;
int nodedevRegister(void);
int detect_scsi_host_caps(virNodeDevCapDataPtr d);
int nodeNumOfDevices(virConnectPtr conn, const char *cap, unsigned int flags);
int nodeListDevices(virConnectPtr conn, const char *cap, char **const names,
int maxnames, unsigned int flags);
......
/*
* node_device_hal.c: node device enumeration - HAL-based implementation
*
* Copyright (C) 2011-2014 Red Hat, Inc.
* Copyright (C) 2011-2015 Red Hat, Inc.
* Copyright (C) 2008 Virtual Iron Software, Inc.
* Copyright (C) 2008 David F. Lively
*
......@@ -29,7 +29,9 @@
#include <libhal.h>
#include "node_device_conf.h"
#include "node_device_driver.h"
#include "node_device_hal.h"
#include "node_device_linux_sysfs.h"
#include "virerror.h"
#include "driver.h"
#include "datatypes.h"
......@@ -37,7 +39,6 @@
#include "viruuid.h"
#include "virpci.h"
#include "virlog.h"
#include "node_device_driver.h"
#include "virdbus.h"
#include "virstring.h"
......@@ -248,7 +249,7 @@ gather_scsi_host_cap(LibHalContext *ctx, const char *udi,
(void)get_int_prop(ctx, udi, "scsi_host.host", (int *)&d->scsi_host.host);
retval = detect_scsi_host_caps(d);
retval = nodeDeviceSysfsGetSCSIHostCaps(d);
if (retval == -1)
goto out;
......
/*
* node_device_linux_sysfs.c: Linux specific code to gather device data
* not available through HAL.
* that is available from sysfs (but not from UDEV or HAL).
*
* Copyright (C) 2009-2015 Red Hat, Inc.
*
......@@ -28,6 +28,7 @@
#include "node_device_driver.h"
#include "node_device_hal.h"
#include "node_device_linux_sysfs.h"
#include "virerror.h"
#include "viralloc.h"
#include "virlog.h"
......@@ -41,7 +42,7 @@
VIR_LOG_INIT("node_device.node_device_linux_sysfs");
int
detect_scsi_host_caps(virNodeDevCapDataPtr d)
nodeDeviceSysfsGetSCSIHostCaps(virNodeDevCapDataPtr d)
{
char *max_vports = NULL;
char *vports = NULL;
......@@ -139,7 +140,7 @@ detect_scsi_host_caps(virNodeDevCapDataPtr d)
#else
int
detect_scsi_host_caps(virNodeDevCapDataPtr d ATTRIBUTE_UNUSED)
nodeDeviceSysfsGetSCSIHostCaps(virNodeDevCapDataPtr d ATTRIBUTE_UNUSED)
{
return -1;
}
......
/*
* node_device_linux_sysfs.h: Linux specific code to gather device data
* that is available from sysfs (but not from UDEV or HAL).
*
* Copyright (C) 2015 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library. If not, see
* <http://www.gnu.org/licenses/>.
*
*/
#ifndef __VIR_NODE_DEVICE_LINUX_SYSFS_H__
# define __VIR_NODE_DEVICE_LINUX_SYSFS_H__
# include "node_device_conf.h"
int nodeDeviceSysfsGetSCSIHostCaps(virNodeDevCapDataPtr d);
#endif /* __VIR_NODE_DEVICE_LINUX_SYSFS_H__ */
/*
* node_device_udev.c: node device enumeration - libudev implementation
*
* Copyright (C) 2009-2014 Red Hat, Inc.
* Copyright (C) 2009-2015 Red Hat, Inc.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
......@@ -27,10 +27,11 @@
#include <c-ctype.h>
#include "dirname.h"
#include "node_device_udev.h"
#include "virerror.h"
#include "node_device_conf.h"
#include "node_device_driver.h"
#include "node_device_linux_sysfs.h"
#include "node_device_udev.h"
#include "virerror.h"
#include "driver.h"
#include "datatypes.h"
#include "virlog.h"
......@@ -749,7 +750,7 @@ static int udevProcessSCSIHost(struct udev_device *device ATTRIBUTE_UNUSED,
goto out;
}
detect_scsi_host_caps(&def->caps->data);
nodeDeviceSysfsGetSCSIHostCaps(&def->caps->data);
if (udevGenerateDeviceName(device, def, NULL) != 0)
goto out;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册