Commit Graph

1526 Commits

Author SHA1 Message Date
Matthew Booth
9899e08b8d Fix typo in network.c function comments
* src/util/network.c: fix a few typo
2009-10-30 16:39:57 +01:00
Daniel Veillard
24c8fc5dff Set of new network related utilities
* src/util/network.h src/util/network.c: utilities to parse network
  addresses, check netmask and compute ranges
2009-10-30 15:44:53 +01:00
Cole Robinson
66c6cc7c5e virterror: Add a missing 'break' for VIR_ERR_INVALID_SECRET 2009-10-28 11:30:42 -04:00
Chris Lalancette
03b5dc14de Tighten up nonreentrant syntax-check.
We can slightly tighten up the regex's used to detect the use of
nonreentrant functions.  We can also check src/util/virterror.c
by modifying a comment; I think it's worth it to get the additional
coverage.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-10-26 10:33:42 +01:00
Daniel Veillard
2f4682a9f8 Consolidate virXPathNodeSet()
virXPathNodeSet() could return -1 when doing an evaluation failure
due to xmlXPathEval() from libxml2 behaviour.
* src/util/xml.c: make sure we always return 0 unless the returned
  XPath type is of the wrong type (meaning the query passed didn't
  evaluate to a node set and code must be fixed)
2009-10-22 10:33:52 +02:00
Daniel P. Berrange
cf577653dc Remove bogus const annotations to hash iterator
Most of the hash iterators need to modify either payload of
data args. The const annotation prevents this.

* src/util/hash.h, src/util/hash.c: Remove const-ness from
  virHashForEach/Iterator
* src/xen/xm_internal.c: Remove bogus casts
2009-10-19 16:24:12 +01:00
Ryota Ozaki
41fa653f32 LXC fix virCgroupGetValueStr problem with \n
A cgroup file returns integer value terminated with '\n' and remaining
it has sometimes harmful effects, for example it leads virStrToLong_ull
to fail.
* src/util/cgroup.c: strip out terminating \n when reading a value
2009-10-19 14:29:42 +02:00
Laine Stump
04e0686262 Avoid crash in virBufferEscapeString
* src/util/buf.c: if virBufferEscapeString was called on a buffer that
  had 0 bytes of space, a size of -1 will be passed to snprintf, resulting
  in a segmentation fault, this preallocate some space.
2009-10-15 14:19:11 +02:00
Daniel P. Berrange
11a36d956c Fix virFileReadLimFD/virFileReadAll to handle EINTR
The fread_file_lim() function uses fread() but never handles
EINTR results, causing unexpected failures when reading QEMU
help arg info. It was unneccessarily using FILE * instead
of plain UNIX file handles, which prevented use of saferead()

* src/util/util.c: Switch fread_file_lim over to use saferead
  instead of fread, remove FILE * use, and rename
2009-10-13 16:28:49 +01:00
Amy Griffis
ab8dd999f5 Add debug for envp[] in virExecWithHook()
* src/util/util.c: output some debug if caller of virExecWithHook have
  set envp[]
2009-10-08 17:11:03 +02:00
Amy Griffis
01e0e98f07 Add accessors for logging filters and outputs
When configuring logging settings, keep more information about the
output destination. Add accessors to retrieve the filter and output
settings in the original string form; this to be used to set up
environment for a child process that also logs.

* src/util/logging.[ch]: add virLogGetFilters and virLogGetOutputs
  accessors and modify the internals (including virLogDefineOutput())
  to save the data needed for the accessors
2009-10-08 17:05:01 +02:00
Amy Griffis
2e812c89e9 Add virFileAbsPath() utility
* src/util/util.[ch]: Add virFileAbsPath() function to ensure an
  absolute path for a potentially realtive path.
* src/libvirt_private.syms: add it in libvirt private symbols
2009-10-08 16:55:58 +02:00
Cole Robinson
f5c65fa192 cgroup: Fix -Werror breakage 2009-10-08 10:26:42 -04:00
Daniel P. Berrange
7b1fe89a5c Misc win32 build fixes
* daemon/Makefile.am: Fix missing sasl rule
* src/datatypes.c: Add unistd.h to avoid gnulib bug
* src/util/cgroup.c: Disable mntent if not available
2009-10-08 11:56:06 +01:00
Ryota Ozaki
3a05dc09ec LXC implement memory control APIs
The patch implements the missing memory control APIs for lxc, i.e.,
domainGetMaxMemory, domainSetMaxMemory, domainSetMemory, and improves
domainGetInfo to return proper amount of used memory via cgroup.

* src/libvirt_private.syms: Export virCgroupGetMemoryUsage
  and add missing virCgroupSetMemory
* src/lxc/lxc_driver.c: Implement missing memory functions
* src/util/cgroup.c, src/util/cgroup.h: Add the function
  to get used memory
2009-10-07 15:26:23 +02:00
Chris Lalancette
47c8709564 Fix up a few typos in the tree.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-09-30 14:05:24 +02:00
Mark McLoughlin
295fd6e833 Add virStorageFileGetMetadata() helper
* src/util/storage_file.c: add virStorageFileGetMetadata() so that
  the caller does not need to open the file
2009-09-30 10:37:00 +01:00
Mark McLoughlin
a010fb58d6 Move virStorageGetMetadataFromFD() to libvirt_util
Finally, we get to the point of all this.

Move virStorageGetMetadataFromFD() to virStorageFileGetMetadataFromFD()
and move to src/util/storage_file.[ch]

There's no functional changes in this patch, just code movement

* src/storage/storage_backend_fs.c: move code from here ...

* src/util/storage_file.[ch]: ... to here

* src/libvirt_private.syms: export virStorageFileGetMetadataFromFD()
2009-09-30 10:36:59 +01:00
Mark McLoughlin
5fede0a90b Introduce virStorageFileMetadata structure
Introduce a metadata structure and make virStorageGetMetadataFromFD()
fill it in.

* src/util/storage_file.h: add virStorageFileMetadata

* src/backend/storage_backend_fs.c: virStorageGetMetadataFromFD() now
  fills in the virStorageFileMetadata structure
2009-09-30 10:36:59 +01:00
Mark McLoughlin
00fd3ff49b Move file format enum to libvirt_util
Rename virStorageVolFormatFileSystem to virStorageFileFormat and
move to src/util/storage_file.[ch]

* src/Makefile.am: add src/util/storage_file.[ch]

* src/conf/storage_conf.[ch]: move enum from here ...

* src/util/storage_file.[ch]: .. to here

* src/libvirt_private.syms: update To/FromString exports

* src/storage/storage_backend.c, src/storage/storage_backend_fs.c,
  src/vbox/vbox_tmpl.c: update for above changes
2009-09-30 10:36:59 +01:00
Daniel Veillard
237f3bf8da Fix some XPath relative node resets
* src/util/xml.c: The virXPath... function take extra care to preserve
  the XPath context node (ctxt->node) but in the case of virXPathString
  and virXPathBoolean they forgot to do this on the error path. This
  patch fixes this and move all ctxt->node = relnode instuctions just
  after the xmlXPathEval() to make sure this doesn't happen if this code
  is modified.
2009-09-29 11:07:01 +02:00
Mark McLoughlin
25e2857c21 util.h needs libvirt.h for virConnectPtr
Seems standard to include internal.h in order to pull in libvirt.h

* src/util/util.h: include internal.h
2009-09-29 08:34:36 +01:00
Chris Lalancette
03d777f345 Introduce virStrncpy.
Add the virStrncpy function, which takes a dst string, source string,
the number of bytes to copy and the number of bytes available in the
dest string.  If the source string is too large to fit into the
destination string, including the \0 byte, then no data is copied and
the function returns NULL.  Otherwise, this function copies n bytes
from source into dst, including the \0, and returns a pointer to the
dst string.  This function is intended to replace all unsafe uses
of strncpy in the code base, since strncpy does *not* guarantee that
the buffer terminates with a \0.

Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-09-22 20:10:00 +02:00
Ryota Ozaki
c8c9ef2757 lxc: suspend/resume support
* src/conf/domain_conf.c: Don't assume all virDomainObjPtr have
  a non-NULL monitor_chr field in virDomainObjFormat.
* src/lxc/lxc_driver.c: Implement suspend/resume driver APis
* src/util/cgroup.c, src/util/cgroup.h: Support the 'freezer'
  cgroup controller
* src/libvirt_private.syms: Export virCgroupSetFreezerState
  and virCgroupGetFreezerState
2009-09-22 11:30:06 +01:00
Chris Lalancette
58df0daa7f Fix up 'neccessary -> necessary' in a comment.
Signed-off-by: Chris Lalancette <clalance@redhat.com>
2009-09-21 18:16:12 +02:00
Daniel P. Berrange
1355e0552e Move all shared utility files to src/util/
* src/bridge.c, src/bridge.h, src/buf.c, src/buf.h, src/cgroup.c,
  src/cgroup.h, src/conf.c, src/conf.h, src/event.c, src/event.h,
  src/hash.c, src/hash.h, src/hostusb.c, src/hostusb.h,
  src/iptables.c, src/iptables.h, src/logging.c, src/logging.h,
  src/memory.c, src/memory.h, src/pci.c, src/pci.h, src/qparams.c,
  src/qparams.h, src/stats_linux.c, src/stats_linux.h,
  src/threads-pthread.c, src/threads-pthread.h, src/threads-win32.c,
  src/threads-win32.h, src/threads.c, src/threads.h, src/util.c,
  src/util.h, src/uuid.c, src/uuid.h, src/virterror.c,
  src/virterror_internal.h, src/xml.c, src/xml.h: Move all files
  into src/util/
* daemon/Makefile.am: Add -Isrc/util/ to build flags
* src/Makefile.am: Add -Isrc/util/ to build flags and update for
  moved files
* src/libvirt_private.syms: Export cgroup APIs since they're now
  in util rather than linking directly to drivers
* src/xen/xs_internal.c: Disable bogus virEventRemoveHandle call
  when built under PROXY
* proxy/Makefile.am: Update for changed file locations. Remove
  bogus build of event.c
* tools/Makefile.am, tests/Makefile.am: Add -Isrc/util/ to build flags
2009-09-21 14:41:47 +01:00