Commit Graph

54 Commits

Author SHA1 Message Date
Daniel P. Berrange
946c489c68 Refactor cgroups to allow a group per driver to be managed directly
Allow the driver level cgroup to be managed explicitly by the
hypervisor drivers, in order to detect whether to enable or
disable cgroup support for domains. Provides better error
reporting of failures. Also allow for creation of cgroups for
unprivileged drivers if controller is accessible by the user.

* src/cgroup.c, src/cgroup.h: Add an API to obtain a driver cgroup
* src/lxc_conf.h, src/lxc_controller.c, src/lxc_driver.c:
  Obtain a driver cgroup at startup and use that instead of
  re-creating everytime.
* src/util.c, src/util.h, src/libvirt_private.syms: Add a
  virGetUserName() helper
2009-07-23 17:38:06 +01:00
Daniel P. Berrange
899ae0d2b5 Fix misc Win32 compile warnings
GCC >= 4.4 assumes the 'printf' attribute refers to the native
runtime libraries format specifiers. Thanks to gnulib, libvirt
has GNU format specifiers everywhere.  This means we need to
use 'gnu_printf' with GCC >= 4.4 to get correct compiler
checking of printf format specifiers.

* HACKING: Document new rules for ATTRIBUTE_FMT_PRINTF
* autobuild.sh, mingw32-libvirt.spec.in: Disable OpenNebula
  driver on mingw32 builds
* qemud/dispatch.h, qemud/qemu.h, src/buf.h src/internal.h,
  src/logging.h, src/security.h, src/sexpr.h, src/util.h,
  src/virterror_internal.h, src/xend_internal.c: Change
  over to ATTRIBUTE_FMT_PRINTF.
* src/virsh.c: Disable 'cd' and 'pwd' commands on Win32
  since they don't compile
* src/threads-win32.c: Add missing return value check
2009-07-23 16:07:32 +01:00
Daniel P. Berrange
0714b2ba4c Run QEMU guests as an unprivileged user
* configure.in: Add --with-qemu-user and --with-qemu-group args
* libvirt.spec.in: use 'qemu' for user/group for Fedora >= 12
* qemud/libvirtd_qemu.arg, qemud/test_libvirtd_qemu.aug,
  src/qemu.conf: Add 'user' and 'group' args for configuration
* src/Makefile.am: Create %localstatedir/cache/libvirt/qemu
* src/qemu_conf.c, src/qemu_conf.h: Load user/group from config
* src/qemu_driver.c: Change user ID/group ID when launching QEMU
  guests. Change user/group ownership on disks/usb/pci devs.
  Put memory dumps in %localstatedir/cache/libvirt/qemu
* src/util.c, src/util.h: Add convenient APIs for converting
  username/groupname to user ID / group ID
2009-07-16 17:06:55 +01:00
Daniel P. Berrange
96619805cb Use libcap-ng to clear capabilities for many child processes 2009-06-29 17:00:52 +00:00
Daniel Veillard
abed6fca87 find and use kvm-img, qemu-img or qcow-create dynamically
* configure.in src/libvirt_private.syms src/storage_backend_fs.c
  src/util.c src/util.h: find and use kvm-img, qemu-img or qcow-create
  dynamically at runtime, patch by Doug Goldstein
* AUTHORS: add Doug Goldstein
Daniel
2009-06-11 13:18:56 +00:00
Cole Robinson
a331653dad Add pidfile argument to __virExec
virExec will write out the pid of the daemonized process only. Use this
in the QEMU driver, rather than QEMU's pidfile, so we can catch errors we
might miss if the emulator bails early.
2009-05-11 13:50:38 +00:00
Cole Robinson
79d9d2432f Add helper function virExecDaemonize
Wraps __virExec with the VIR_EXEC_DAEMON flag. Waits on the intermediate
process to ensure we don't end up with any zombies, and differentiates between
original process errors and intermediate process errors.
2009-05-11 13:34:37 +00:00
Daniel P. Berrange
220bcb0535 Use a private /dev/pts instance in containers if kernel is new enough 2009-04-22 14:26:50 +00:00
Daniel P. Berrange
dab6391f2d Sanitize symlink resolution 2009-04-01 10:26:22 +00:00
Daniel Veillard
c29d092905 use posix_fallocate() to allocate diskspace faster
* src/libvirt_private.syms src/storage_backend_fs.c src/util.c
  src/util.h: use posix_fallocate() on supported systems to
  allocate diskspace faster, patches by Amit Shah
Daniel
2009-03-20 12:17:56 +00:00
Daniel P. Berrange
2e187bcbca Add support for a exec callback in virExecWithHook 2009-02-26 16:27:51 +00:00
Mark McLoughlin
0bb6f816e3 Add virFileWriteStr()
Re-factor the code from networkEnableIpForwarding() into a
utility function in preparation for code which writes to
sysfs files.
2009-02-13 19:13:06 +00:00
Jim Meyering
b0d49913d5 remove duplicate *SetCloseExec and *SetNonBlock functions
* src/qemu_driver.c: Use virSetCloseExec and virSetNonBlock,
rather than qemuSet* functions.  Suggested by Daniel P. Berrange.
* src/util.c (virSetCloseExec): Publicize.
* src/util.h (virSetCloseExec): Declare
* src/libvirt_private.syms: Add virSetCloseExec.
2009-02-05 16:27:17 +00:00
Jim Meyering
dff2114795 build: enable redundant-const check
* Makefile.cfg (local-checks-to-skip): Remove sc_redundant_const.
* src/lxc_controller.c: Remove redundant "const"(s).
* src/storage_backend_fs.c: Likewise.
* src/util.h: Likewise.
* src/xen_internal.c: Likewise.
* tests/qparamtest.c: Likewise.
2009-02-03 13:08:59 +00:00
Daniel P. Berrange
c4985e9419 use the gnulib random_r function 2009-01-22 20:27:01 +00:00
Daniel P. Berrange
1b745219c7 Remove use of non-reentrant POSIX apis 2009-01-22 19:41:48 +00:00
Daniel P. Berrange
61674cc17d Make RPC call dispatch threaded 2009-01-20 16:36:34 +00:00
Daniel Veillard
fbba4423e9 * src/libvirt_private.syms src/qemu_driver.c src/test.c
src/uml_driver.c src/util.c src/util.h src/xen_unified.c:
  unify hostname lookup using virGetHostname convenience function,
  patch by David Lutterkort
daniel
2009-01-07 10:43:16 +00:00
Guido Günther
83467de3ed add virKillProcess 2009-01-06 17:46:46 +00:00
Guido Günther
830ba76c3e let qemu/kvm instances write a pid file 2008-12-18 15:22:49 +00:00
Daniel P. Berrange
7c4bc3f92f Use pid_t for all PID tracking variables (John Levon) 2008-12-18 11:58:28 +00:00
Jim Meyering
e4c7e12300 let gcc's -Wformat do its job; avoid "make syntax-check" failure
* src/util.c (virAsprintf): Remove trailing space.
* src/util.h (virAsprintf): Use ATTRIBUTE_FORMAT.
* HACKING (Printf-style functions): New section.
2008-12-17 17:22:43 +00:00
Guido Günther
36c612b21c add virAsprintf 2008-12-15 20:09:29 +00:00
Daniel P. Berrange
25047e7cf8 Use a versioned linker script 2008-11-17 11:03:25 +00:00
Cole Robinson
f1ca068666 Move local argvToString to virArgvToString in util. 2008-11-05 18:22:10 +00:00
Daniel P. Berrange
bdd50bc7f3 Centralize domain mac address handling in domain_conf.c/util.c 2008-10-24 11:20:08 +00:00
Daniel P. Berrange
542039fab0 Fully support mingw builds 2008-09-05 12:03:45 +00:00
Jim Meyering
d2ac46f2b0 util.c: add a file-descriptor-based wrapper for fread_file_lim
* src/util.c (virFileReadLimFP): New function.
(__virFileReadLimFD): New function.
* src/util.h (__virFileReadLimFD): Declare.
(virFileReadLimFD): Define.
(virFileReadAll): Rewrite to use virFileReadLimFP.
2008-09-02 10:29:51 +00:00
Daniel P. Berrange
da1963381b Fix QEMU domain creation by allowing virExec to preserve certain FDs 2008-08-27 11:42:52 +00:00
Daniel P. Berrange
6334cd16df Remove configFile/autostartLink vars from virDomainObj struct 2008-08-20 19:42:36 +00:00
Daniel P. Berrange
1b4bb7d4ab Allow non-blocking/daemon mode to be specified via virExec flags 2008-08-20 09:24:14 +00:00
Daniel P. Berrange
763dacda97 Make LXC I/O controller process a parent of the container process 2008-08-13 10:52:15 +00:00
Daniel P. Berrange
b3728d7d72 Fix const-correctness of virRUn and virExec 2008-08-08 15:43:38 +00:00
Daniel P. Berrange
d1304583d6 Added generic domain XML APIs 2008-07-11 16:23:36 +00:00
Daniel P. Berrange
47605e1dfa Added helpers for dealing with enumerations 2008-06-24 15:00:15 +00:00
Richard W.M. Jones
1d8d4f86b6 Standardize use of header files, making internal.h primary.
* qemud/internal.h, qemud/qemud.h: Rename this file so it
	doesn't conflict with src/internal.h.
	* HACKING: Document how header files should be used.
	* qemud/Makefile.am: Add src/ directory to includes.
	* qemud/event.c, qemud/mdns.c, qemud/qemud.c, qemud/remote.c,
	qemud/remote_protocol.c, qemud/remote_protocol.h,
	qemud/remote_protocol.x, src/buf.c, src/libvirt.c,
	src/nodeinfo.c, src/qemu_conf.c, src/qemu_driver.c,
	src/stats_linux.c, src/storage_backend.c, src/storage_backend_fs.c,
	src/storage_backend_iscsi.c, src/storage_backend_logical.c,
	src/storage_conf.c, src/storage_driver.c, src/util.c,
	src/util.h, src/virsh.c, src/virterror.c, src/xend_internal.c,
	src/xml.c, tests/reconnect.c, tests/xmlrpctest.c,
	tests/qparamtest.c: Standardize	use of header files.
	* docs/*, po/*: Rebuild docs.
2008-05-23 08:24:41 +00:00
Daniel P. Berrange
098ba1a433 Add support for -drive QEMU syntax, and virtio bus / disk type 2008-05-09 16:41:19 +00:00
Jim Meyering
25534052bc Use gnulib's c-ctype.h, not <ctype.h>.
# Convert uses of isspace to c_isspace, isdigit to c_isdigit, etc.
re=$(man isspace|grep is.....,.is|sed 's/ -.*//' \
  |tr -s ', \n' \||sed 's/^|//;s/|$//')
git grep -l -E "$re"|grep -Ev 'Chan|gnulib' \
  |xargs perl -pi -e 's/\b('"$re"')\b/c_$1/g'
# Remove all uses of to_uchar
git grep -l to_uchar|xargs perl -pi -e 's/to_uchar\((.*?)\)/$1/g'
* src/util.h (to_uchar): Remove definition.
(TOLOWER): Remove definition.
(__virMacAddrCompare): Use c_tolower, not TOLOWER.
Globally:
  Where needed, change <ctype.h> to <c-ctype.h>.
  Remove unnecessary inclusion of <ctype.h>.
Ensure the global changes are never needed again:
* Makefile.maint (sc_avoid_ctype_macros): Prohibit use of ctype
macros.   Recommend c-ctype.h instead.
(sc_prohibit_c_ctype_without_use): New rule.
(sc_prohibit_ctype_h): New rule.  Disallow use of <ctype.h>.
2008-05-09 13:50:14 +00:00
Jim Meyering
225ba3f0af avoid problems with sign-extended "char" operand to is* functions
* src/util.h (to_uchar): Define function.
* src/nodeinfo.c (linuxNodeInfoCPUPopulate): Apply to_uchar to is* operand.
* src/qemu_driver.c (qemudExtractMonitorPath): Likewise.
* src/sexpr.c (_string2sexpr): Likewise.
* src/stats_linux.c (xenLinuxDomainDeviceID): Likewise.
* src/util.c (TOLOWER, __virMacAddrCompare, virParseMacAddr): Likewise.
* src/virsh.c (cmdVcpupin, vshCommandGetToken): Likewise.
2008-04-25 14:53:05 +00:00
Jim Meyering
5bf824ea10 convert TAB-based indentation in C sources to use only spaces
Done using this command (also includes .c.in and .h.in files):
for i in $(g ls-files|grep -E '\.[ch](\.in)?$'|grep -v gnulib); do
  expand -i $i > j && mv j $i;done
2008-04-10 16:54:54 +00:00
Daniel Veillard
ccb19376f7 * src/util.c src/util.h src/xml.c: applied patch from Hiroyuki Kaguchi
fixing Ethernet MAC addresses parsingand separating as an util
  function, with added comments from Jim Meyering
Daniel
2008-03-20 11:24:30 +00:00
Richard W.M. Jones
92a1e14b0b virMacAddrCompare for comparing MAC addresses
* src/util.c, src/util.h, src/libvirt_sym.version: Added
	  virMacAddrCompare utility function for comparing MAC
	  addresses.
	* src/virsh.c, src/xm_internal.c: Use virMacAddrCompare
	  to compare addresses.  (Shigeki Sakamoto and Richard Jones).
2008-02-27 16:14:44 +00:00
Daniel P. Berrange
63bc5dd3e1 Add formal internal capabilities API and update drivers to use it 2008-02-27 04:35:08 +00:00
Daniel Veillard
36c6bfa63d * src/driver.h src/libvirt.c src/openvz_driver.c src/qemu_driver.c
src/remote_internal.c src/test.c src/util.c src/util.h
  src/xen_unified.c: added probe interface at the driver level,
  use that to improve default hypervisor selection in the absence
  of a given URI when connecting
Daniel
2008-02-26 07:05:18 +00:00
Jim Meyering
a178a4e7bf Move safewrite and saferead to a separate file.
We currently use safewrite from inside libvirt and don't want to publish
any such function name.  However, we do want to use it in applications
like virsh, libvirtd and libvirt_proxy that link with libvirt.  To that
end, this change moves that function definition (along with the nearly
identical saferead) into a new file, util-lib.c.  To avoid maintaining
separate copies of even such small functions, we simply include that new
file from util.c.  Then, the separate applications that need to use
safewrite simply compile and link with util-lib.c.

Of course, this does mean that each of those applications will
containing two copies of these functions.  However, the functions
are so small that it's not worth worrying about that.

* src/util.c (saferead, safewrite): Move function definitions to
util-lib.c and include that .c file.
* src/util-lib.c (saferead, safewrite): New file.  Functions from src/util.c
with slight change (s/int r =/ssize_t r =/) to reflect read/write return type.
* src/util-lib.h: Declare the two moved functions.
* src/util.h: Remove declarations.  Include src/util-lib.h.
* proxy/Makefile.am (libvirt_proxy_SOURCES): Add src/util-lib.c.
* qemud/Makefile.am (libvirtd_SOURCES): Likewise.
* src/Makefile.am (virsh_SOURCES): Add util-lib.c.  Remove some SP-before-TAB.
2008-02-22 15:53:13 +00:00
Daniel P. Berrange
f43e709842 Added convenience virsh command for creating pools/volumes without XML 2008-02-20 15:29:13 +00:00
Mark McLoughlin
3da5504e68 Fix gcc-4.3.0 "inlining failed" warning.
* src/internal.h: move xstrol() variants from here ...

* src/util.[ch]: ... to here and rename to virStrToLong()

* src/libvirt_sym.version: export __virStrToLong_i() for
virsh and qemud.

* src/nodeinfo.c, src/stats_linux.c, src/virsh.c,
  src/xend_internal.c, qemud/qemud.c: replace xstrtol()
calls with virStrToLong()

* src/nodeinfo.h: don't include internal.h, which was only
needed for xstrtol(), but instead include libvirt.h which
is suffificient for the declarations in the header.
2008-02-08 09:15:16 +00:00
Daniel P. Berrange
45738083a6 Use virFileReadAll in virsh.c 2008-01-21 15:27:14 +00:00
Mark McLoughlin
77a2fc0061 Add virRun() helper function (Dan Berrange) 2008-01-10 13:46:10 +00:00
Daniel P. Berrange
94e49e3f0e Fix config file reading to not truncate large files 2008-01-07 15:21:33 +00:00