Commit Graph

47 Commits

Author SHA1 Message Date
Laine Stump
bfe7721d50 util: move virFile* functions from virutil.c to virfile.c
These all existed before virfile.c was created, and for some reason
weren't moved.

This is mostly straightfoward, although the syntax rule prohibiting
write() had to be changed to have an exception for virfile.c instead
of virutil.c.

This movement pointed out that there is a function called
virBuildPath(), and another almost identical function called
virFileBuildPath(). They really should be a single function, which
I'll take care of as soon as I figure out what the arglist should look
like.
2013-05-10 13:09:30 -04:00
Michal Privoznik
be2636fd0b Adapt to VIR_STRDUP and VIR_STRNDUP in src/node_device/* 2013-05-09 14:00:45 +02:00
Daniel P. Berrange
142e6e2784 Fix naming of some node device APIs
In renaming driver API implementations to match the
public API naming scheme, a few cases in the node
device driver were missed.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-08 10:47:47 +01:00
Jim Fehlig
ce45c761d0 build: Fix build when WITH_HAL is defined
Commit 7c9a2d88 missed inclusion of virstring.h in a few places
when WITH_HAL is defined, causing build failures.
2013-05-02 16:00:07 -06:00
Michal Privoznik
7c9a2d88cd virutil: Move string related functions to virstring.c
The source code base needs to be adapted as well. Some files
include virutil.h just for the string related functions (here,
the include is substituted to match the new file), some include
virutil.h without any need (here, the include is removed), and
some require both.
2013-05-02 16:56:55 +02:00
Daniel P. Berrange
07a6b9aac4 Rename 'DeviceMonitor' to 'NodeDeviceDriver'
The driver.h struct for node devices used an inconsistent
naming scheme 'DeviceMonitor' instead of the more usual
'NodeDeviceDriver'. Fix this everywhere it has leaked
out to.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-04-24 10:59:53 +01:00
Osier Yang
96d3086a4f nodedev: Abstract nodeDeviceVportCreateDelete as util function
This abstracts nodeDeviceVportCreateDelete as an util function
virManageVport, which can be further used by later storage patches
(to support persistent vHBA, I don't want to create the vHBA
using the public API, which is not good).
2013-03-25 20:46:05 +08:00
Osier Yang
4360a09844 nodedev: Refactor the helpers
This adds two util functions (virIsCapableFCHost and virIsCapableVport),
and rename helper check_fc_host_linux as detect_scsi_host_caps,
check_capable_vport_linux is removed, as it's abstracted to the util
function virIsCapableVport. detect_scsi_host_caps nows detect both
the fc_host and vport_ops capabilities. "stat(2)" is replaced with
"access(2)" for saving.

* src/util/virutil.h:
  - Declare virIsCapableFCHost and virIsCapableVport
* src/util/virutil.c:
  - Implement virIsCapableFCHost and virIsCapableVport
* src/node_device/node_device_linux_sysfs.c:
  - Remove check_capable_vport_linux
  - Rename check_fc_host_linux as detect_scsi_host_caps, and refactor
    it a bit to detect both fc_host and vport_os capabilities
* src/node_device/node_device_driver.h:
  - Change/remove the related declarations
* src/node_device/node_device_udev.c: (Use detect_scsi_host_caps)
* src/node_device/node_device_hal.c: (Likewise)
* src/node_device/node_device_driver.c (Likewise)
2013-03-25 20:46:05 +08:00
Osier Yang
d91f7dec46 nodedev: Use access instead of stat
The use of 'stat' in nodeDeviceVportCreateDelete is only to check
if the file exists or not, it's a bit overkill, and safe to replace
with the wrapper of access(2) (virFileExists).
2013-03-25 20:46:05 +08:00
Osier Yang
fb2e465362 nodedev: Implement virNodeDeviceLookupSCSIHostByWWN
This just simply changes nodeDeviceLookupByWWN to be not static,
and its name into nodeDeviceLookupSCSIHostByWWN. And use that for
udev and HAL backends.
2013-02-12 00:23:57 +08:00
Daniel P. Berrange
24120066a4 Convert HAVE_HAL to WITH_HAL
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-01-14 13:26:47 +00:00
Daniel P. Berrange
d3b05abfa9 Convert HAVE_UDEV to WITH_UDEV
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-01-14 13:26:47 +00:00
Daniel P. Berrange
f24404a324 Rename virterror.c virterror_internal.h to virerror.{c,h} 2012-12-21 11:19:50 +00:00
Daniel P. Berrange
44f6ae27fe Rename util.{c,h} to virutil.{c,h} 2012-12-21 11:19:49 +00:00
Daniel P. Berrange
ab9b7ec2f6 Rename memory.{c,h} to viralloc.{c,h} 2012-12-21 11:17:14 +00:00
Daniel P. Berrange
936d95d347 Rename logging.{c,h} to virlog.{c,h} 2012-12-21 11:17:14 +00:00
Eric Blake
4ecb723b9e maint: fix up copyright notice inconsistencies
https://www.gnu.org/licenses/gpl-howto.html recommends that
the 'If not, see <url>.' phrase be a separate sentence.

* tests/securityselinuxhelper.c: Remove doubled line.
* tests/securityselinuxtest.c: Likewise.
* globally: s/;  If/.  If/
2012-09-20 16:30:55 -06:00
Osier Yang
c68cd62adb list: Implement listAllNodeDevices
This simply implements listAllNodeDevices using helper virNodeDeviceList

src/node_device/node_device_driver.h:
  * Declare nodeListAllNodeDevices.

src/node_device/node_device_driver.c:
  * Implement nodeListAllNodeDevices.

src/node_device/node_device_hal.c:
  * Hook listAllNodeDevices to nodeListAllNodeDevices.

src/node_device/node_device_udev.c
  * Hook listAllNodeDevices to nodeListAllNodeDevices.
2012-09-17 10:40:31 +08:00
Osier Yang
f9ce7dad60 Desert the FSF address in copyright
Per the FSF address could be changed from time to time, and GNU
recommends the following now: (http://www.gnu.org/licenses/gpl-howto.html)

  You should have received a copy of the GNU General Public License
  along with Foobar.  If not, see <http://www.gnu.org/licenses/>.

This patch removes the explicit FSF address, and uses above instead
(of course, with inserting 'Lesser' before 'General').

Except a bunch of files for security driver, all others are changed
automatically, the copyright for securify files are not complete,
that's why to do it manually:

  src/security/security_selinux.h
  src/security/security_driver.h
  src/security/security_selinux.c
  src/security/security_apparmor.h
  src/security/security_apparmor.c
  src/security/security_driver.c
2012-07-23 10:50:50 +08:00
Daniel P. Berrange
df5232f554 Replace use of virNodeDeviceReportError with virReportError
Update the node device driver to use virReportError instead of
the virNodeDeviceReportError custom macro

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-07-18 19:34:26 +01:00
Osier Yang
7c90026db9 npiv: Auto-generate WWN if it's not specified
The auto-generated WWN comply with the new addressing schema of WWN:

<quote>
the first nibble is either hex 5 or 6 followed by a 3-byte vendor
identifier and 36 bits for a vendor-specified serial number.
</quote>

We choose hex 5 for the first nibble. And for the 3-bytes vendor ID,
we uses the OUI according to underlying hypervisor type, (invoking
virConnectGetType to get the virt type). e.g. If virConnectGetType
returns "QEMU", we use Qumranet's OUI (00:1A:4A), if returns
ESX|VMWARE, we use VMWARE's OUI (00:05:69). Currently it only
supports qemu|xen|libxl|xenapi|hyperv|esx|vmware drivers. The last
36 bits are auto-generated.
2012-02-10 12:53:25 +08:00
Eric Blake
ba78d2cf89 node_device: reject unknown flags
* src/node_device/node_device_driver.c (nodeNumOfDevices)
(nodeListDevices, nodeDeviceGetXMLDesc, nodeDeviceCreateXML):
Reject unknown flags.
* src/node_device/node_device_hal.c (halNodeDrvOpen): Likewise.
* src/node_device/node_device_udev.c (udevNodeDrvOpen): Likewise.
2011-07-13 09:04:54 -06:00
Matthias Bolte
4bf1f33b7e docs: Make hvsupport.pl pick up the host device drivers
Annotate the ESX device driver dummy.

Refactor the udev and hal device driver strcuts to match the
common annotation pattern.
2011-06-06 10:45:59 +02:00
Matthias Bolte
9817604afc Rename internal DumpXML functions to GetXMLDesc
This matches the public API and helps to get rid of some special
case code in the remote generator.

Rename driver API functions and XDR protocol structs.

No functional change included outside of the remote generator.
2011-05-10 20:32:41 +02:00
Jean-Baptiste Rouault
966a1bfe22 Create file in virFileWriteStr() if it doesn't exist
This patch adds a mode_t parameter to virFileWriteStr().
If mode is different from 0, virFileWriteStr() will try
to create the file if it doesn't exist.

* src/util/util.h (virFileWriteStr): Alter signature.
* src/util/util.c (virFileWriteStr): Allow file creation.
* src/network/bridge_driver.c (networkEnableIpForwarding)
(networkDisableIPV6): Adjust clients.
* src/node_device/node_device_driver.c
(nodeDeviceVportCreateDelete): Likewise.
* src/util/cgroup.c (virCgroupSetValueStr): Likewise.
* src/util/pci.c (pciBindDeviceToStub, pciUnBindDeviceFromStub):
Likewise.
2010-12-03 08:08:22 -07:00
Eric Blake
9ba934c640 build: fix compiler warning
node_device/node_device_driver.c: In function 'nodeDeviceVportCreateDelete':
node_device/node_device_driver.c:423: error: implicit declaration of function 'stat' [-Wimplicit-function-declaration]

* src/node_device/node_device_driver.c (includes): Add <sys/stat.h>.
2010-08-18 13:46:09 -06:00
Dave Allan
b31ef77313 nodedev: Fix sysfs paths for vport operations
Some kernels, such as the one used in RHEL-5, have vport_create and
vport_delete operation files in /sys/class/scsi_host/hostN directory
instead of /sys/class/fc_host/hostN. Let's check both paths for
compatibility reasons.

This also removes unnecessary '/' characters from sysfs paths containing
LINUX_SYSFS_FC_HOST_PREFIX.
2010-08-18 17:32:31 +02:00
Daniel P. Berrange
345ff369e5 Prefer UDEV to HAL drivers if both a compiled
HAL is deprecated and UDEV is the future. Thus if both
options are compiled, we should prefer use of UDEV over
HAL

* src/node_device/node_device_driver.c: Switch init
  order to try UDEV first, then HAL
2010-06-08 15:15:02 +01:00
David Allan
2874a683e9 Update nodedev scsi_host data before use
* It appears that the udev event for HBA creation arrives before the
  associated sysfs data is fully populated, resulting in bogus data
  for the nodedev entry until the entry is refreshed.  This problem is
  particularly troublesome when creating NPIV vHBAs because it results
  in libvirt failing to find the newly created adapter and waiting for
  the full timeout period before erroneously failing the create
  operation.  This patch forces an update before any attempt to use
  any scsi_host nodedev entry.
2010-06-03 10:54:39 -04:00
David Allan
d3e43bad98 Fix device destroy return value
* Set return value in error cases
* Clarify error message when parent device is not vport capable
2010-06-03 10:54:29 -04:00
Jim Meyering
d6f9cf4222 maint: don't mark VIR_DEBUG or VIR_DEBUG0 diagnostics for translation
Run this command:
  git grep -l VIR_DEBUG|xargs perl -pi -e \
    's/(VIR_DEBUG0?)\s*\(_\((".*?")\)/$1($2/'
2010-05-20 21:36:26 +02:00
Eric Blake
36d8e7d8d7 build: consistently indent preprocessor directives
* global: patch created by running:
for f in $(git ls-files '*.[ch]') ; do
    cppi $f > $f.t && mv $f.t $f
done
2010-03-09 19:22:28 +01:00
Daniel P. Berrange
99edc443e9 Remove virConnectPtr from all node device XML APIs
The virConnectPtr is no longer required for error reporting since
that is recorded in a thread local. Remove use of virConnectPtr
from all APIs in node_device_conf.{h,c} and update all callers to
match
2010-02-10 13:32:01 +00:00
Matthias Bolte
f972dc2d5c Remove conn parameter from util functions
It was used for error reporting only.
2010-02-09 01:04:54 +01:00
Matthias Bolte
a5ab900d26 Remove conn parameter from virReportSystemError 2010-02-09 01:04:54 +01:00
Matthias Bolte
8ce5e2c1ab Remove conn parameter from virReportOOMError 2010-02-09 01:04:54 +01:00
Matthias Bolte
338e7c3c8d Don't free an uninitalized pointer in update_driver_name()
This invalid free results in heap corruption. Some symptoms I saw
because of this were libvirtd crashing and virt-manager hanging
while trying to enumerate devices.
2010-01-07 01:38:19 +01:00
Jim Meyering
b148318981 node_device_driver.c: don't write beyond EOB for 4K-byte symlink
* src/node_device/node_device_driver.c (update_driver_name): The
previous code would write one byte beyond the end of the 4KiB
stack buffer when presented with a symlink value of exactly that
length (very unlikely).  Remove the automatic buffer and use
virFileResolveLink in place of readlink.  Suggested by Daniel Veillard.
2009-12-14 16:26:38 +01:00
Dave Allan
f2f656d426 Removing devicePath member from dev struct
I realized that I inadvertently added a member to the def struct to
contain each device's sysfs path when there was an existing member in the
dev struct for "OS specific path to device metadat, eg sysfs"  Since the
udev backend needs to record the sysfs path while it's in the process of
creating the device, before the dev struct gets allocated, I chose to
remove the member from the dev struct.

* src/conf/node_device_conf.c src/conf/node_device_conf.h
  src/node_device/node_device_driver.c src/node_device/node_device_hal.c
  src/node_device/node_device_udev.c: remove devicePath from the
  structure and use def->sysfs_path instead
2009-11-19 16:02:18 +01:00
Dave Allan
0fe553744a report OOM in two places in node_device_driver.c
* src/node_device/node_device_driver.c: two places where not calling
  virReportOOMError after strdup failure
2009-11-19 15:44:00 +01:00
David Allan
e99fb5ed9d Remove DevKit node device backend
* configure.in src/Makefile.am: remove the configuration check and
  build instructions
* src/node_device/node_device_devkit.c: removed the module
* src/node_device/node_device_driver.c src/node_device/node_device_driver.h:
  removed references to the old backend
2009-11-12 23:09:24 +01:00
David Allan
3ad6dcf3dc Implement a node device backend using libudev
* configure.in: add new --with-udev, disabled by default, and requiring
  libudev > 145
* src/node_device/node_device_udev.c src/node_device/node_device_udev.h:
  the new node device backend
* src/node_device/node_device_linux_sysfs.c: moved node_device_hal_linux.c
  to a better file name
* src/conf/node_device_conf.c src/conf/node_device_conf.h: add a couple
  of fields in node device definitions, and an API to look them up,
  remove a couple of unused fields from previous patch.
* src/node_device/node_device_driver.c src/node_device/node_device_driver.h:
  plug the new driver
* po/POTFILES.in src/Makefile.am src/libvirt_private.syms: add the new
  files and symbols
* src/util/util.h src/util/util.c: add a new convenience macro
  virBuildPath and virBuildPathInternal() function
2009-11-12 22:48:24 +01:00
Cole Robinson
9e2fe24518 node device: Break out get_wwns and get_parent_node helpers
These will be used by the test driver, so move them to a shareable space.
2009-10-20 14:17:35 -04:00
Cole Robinson
d686056f62 node device: Fix locking issue in virNodeDeviceDestroy
Certain error paths won't unlock the node device object.
2009-10-20 14:17:34 -04:00
Cole Robinson
6e24ccb266 nodedev: Break out virNodeDeviceHasCap to node_conf
Will be used by test driver node device implementation.

Signed-off-by: Cole Robinson <crobinso@redhat.com>
2009-10-05 14:07:16 -04:00
Cole Robinson
112746cdc5 nodedev: Add locking in nodeNumOfDevices
Signed-off-by: Cole Robinson <crobinso@redhat.com>
2009-10-05 14:07:15 -04:00
Daniel P. Berrange
91b56239e0 Move node device drivers to src/node_device/
* daemon/qemud.c, src/Makefile.am: Update for changed paths
* src/node_device*.{h,c}: Move to src/node_device/
* src/storage/storage_backend.c: Remove bogus import of node_device.c
2009-09-21 14:41:43 +01:00