]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
13 years agoModify the tests/nodeinfotest.c to use sysfs in addition
Prerna Saxena [Thu, 1 Dec 2011 07:17:52 +0000 (12:47 +0530)]
Modify the tests/nodeinfotest.c to use sysfs in addition

 to proc/cpuinfo

This patch creates a new sysfs hierarchy under
tests/nodeinfodata/linux-nodeinfo-sysfs-test-1.
Output files and /proc/cpuinfo files are also respectively added for
both x86 and ppc64.

Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
13 years agoUse sysfs to gather host topology, in place of
Prerna Saxena [Mon, 3 Oct 2011 12:45:30 +0000 (05:45 -0700)]
Use sysfs to gather host topology, in place of

 /proc/cpuinfo

Libvirt at present depends on /proc/cpuinfo to gather host
details such as CPUs, cores, threads, etc. This is an architecture-
dependent approach. An alternative is to use 'Sysfs', which provides
a platform-agnostic interface to parse host CPU topology.

Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
13 years agomaint: move my name to commiters
Christophe Fergeau [Thu, 8 Dec 2011 10:13:01 +0000 (11:13 +0100)]
maint: move my name to commiters

Since I have commit rights on libvirt-glib, I can also push to
libvirt, Eric Blake told to move my name up to committers to better
reflect reality.

13 years agoRelease of libvirt-0.9.8
Daniel Veillard [Thu, 8 Dec 2011 07:13:50 +0000 (15:13 +0800)]
Release of libvirt-0.9.8

* configure.ac docs/news.html.in libvirt.spec.in: updated for the release
* po/*.po*: fetched localization update and regenerated

13 years agospec: don't use chkconfig --list
Eric Blake [Tue, 6 Dec 2011 23:16:34 +0000 (16:16 -0700)]
spec: don't use chkconfig --list

https://bugzilla.redhat.com/show_bug.cgi?id=694403 reports that
the specfile is incorrectly checking for a running libvirt-guests
service.  For example,

$ LC_ALL=es_ES chkconfig --list libvirt-guests
libvirt-guests    0:desactivado  1:desactivado    2:desactivado     3:activo  4:activo  5:activo     6:desactivado

will fail to find 5:on, even though it is active.  But chkconfig
already has a mode where you can silently use the exit status to
check for an active service.

* libvirt.spec.in (%post): Use simpler chkconfig options, to avoid
issues with localization.

13 years agobuild: fix build with older libxml2
Eric Blake [Wed, 7 Dec 2011 22:06:18 +0000 (15:06 -0700)]
build: fix build with older libxml2

On RHEL 5, with libxml2-2.6.26, the build failed with:
virsh.c: In function 'vshNodeIsSuperset':
virsh.c:11951: warning: implicit declaration of function 'xmlChildElementCount'

(or if warnings aren't errors, a link failure later on).

* src/util/xml.h (virXMLChildElementCount): New prototype.
* src/util/xml.c (virXMLChildElementCount): New function.
* src/libvirt_private.syms (xml.h): Export it.
* tools/virsh.c (vshNodeIsSuperset): Use it.

13 years agoFix updating of haveTheBuck in RPC client to be race-free
Daniel P. Berrange [Wed, 7 Dec 2011 14:46:39 +0000 (14:46 +0000)]
Fix updating of haveTheBuck in RPC client to be race-free

When one thread passes the buck to another thread, it uses
virCondSignal to wake up the target thread. The variable
'haveTheBuck' is not updated in a race-free manner when
this occurs. The current thread sets it to false, and the
woken up thread sets it to true. There is a window where
a 3rd thread can come in and grab the buck.

Even if this didn't lead to crashes & deadlocks, this would
still result in unfairness in the buckpassing algorithm.

A better solution is to *never* set haveTheBuck to false
when we're passing the buck. Only set it to false when there
is no further thread waiting for the buck.

* src/rpc/virnetclient.c: Only set haveTheBuck to false
  if no thread is waiting

13 years agoRevert fd066925440ba48acc95d8f31b2c98b1cc9d582d
Daniel P. Berrange [Wed, 7 Dec 2011 14:46:38 +0000 (14:46 +0000)]
Revert fd066925440ba48acc95d8f31b2c98b1cc9d582d

Commit fd066925440ba48acc95d8f31b2c98b1cc9d582d tried to fix
a race condition in

  commit fa9595003d043df9f2efe95521c00898cef27106
  Author: Daniel P. Berrange <berrange@redhat.com>
  Date:   Fri Nov 11 15:28:41 2011 +0000

    Explicitly track whether the buck is held in remote client

Unfortunately there is a second race condition whereby the
event loop can trigger due to incoming data to read. Revert
this fix, so a complete fix for the problem can be cleanly
applied

* src/rpc/virnetclient.c: Revert fd066925440ba48acc95d8f31b2c98b1cc9d582d

13 years agoPrevent crash of libvirtd when attaching to existing qemu process
Jim Fehlig [Wed, 7 Dec 2011 18:23:03 +0000 (11:23 -0700)]
Prevent crash of libvirtd when attaching to existing qemu process

With security_driver set to "none" in /etc/libvirt/qemu.conf,
libvirtd would crash when attempted to attach to an existing
qemu process.  Only copy the security model if it actually exists.

13 years agoAdd documentation for <disk><source type="dir">
Christophe Fergeau [Wed, 7 Dec 2011 16:55:41 +0000 (17:55 +0100)]
Add documentation for <disk><source type="dir">

13 years agoFix typo in virDomainResume API doc
Christophe Fergeau [Wed, 7 Dec 2011 16:55:40 +0000 (17:55 +0100)]
Fix typo in virDomainResume API doc

It's referring to virSuspendDomain instead of
virDomainSuspend.

13 years agoqemu: Ignore shutdown event from destroyed domain
Jiri Denemark [Wed, 7 Dec 2011 11:52:59 +0000 (12:52 +0100)]
qemu: Ignore shutdown event from destroyed domain

During virDomainDestroy, QEMU may emit SHUTDOWN event as a response to
SIGTERM and since domain object is still locked, the event is processed
after the domain is destroyed. We need to ignore this event in such case
to avoid changing domain state from shutoff to shutdown.

13 years agonpiv: Expose fabric_name outside
Osier Yang [Tue, 6 Dec 2011 12:09:03 +0000 (07:09 -0500)]
npiv: Expose fabric_name outside

This patch is to expose the fabric_name of fc_host class, which
might be useful for users who wants to known which fabric the
(v)HBA connects to.

The patch also adds the missed capabilities' XML schema of scsi_host,
(of course, with fabric_wwn added), and update the documents
(docs/formatnode.html.in)

13 years agoConditionalize daemonPath decl for Win32 which lacks UNIX sockets
Daniel P. Berrange [Wed, 7 Dec 2011 10:39:14 +0000 (10:39 +0000)]
Conditionalize daemonPath decl for Win32 which lacks UNIX sockets

13 years agoImprove error reporting when libvirtd is not installed
Daniel P. Berrange [Tue, 6 Dec 2011 21:46:22 +0000 (21:46 +0000)]
Improve error reporting when libvirtd is not installed

Currently if you try to connect to a local libvirtd when
libvirtd is not in $PATH, you'll get an error

  error: internal error invalid use of command API

This is because remoteFindDaemonPath() returns NULL, which
causes us to pass NULL into virNetSocketConnectUNIX which
in turn causes us to pass NULL into virCommandNewArgList.

Adding missing error checks improves this to

  error: internal error Unable to locate libvirtd daemon in $PATH

* src/remote/remote_driver.c: Report error if libvirtd
  cannot be found
* src/rpc/virnetsocket.c: Report error if caller requested
  spawning of daemon, but provided no binary path

13 years agospec: fix sanlock dependency
Eric Blake [Mon, 5 Dec 2011 17:37:33 +0000 (10:37 -0700)]
spec: fix sanlock dependency

* libvirt.spec.in (with_sanlock): On RHEL, don't force sanlock
on architectures where it isn't available.

13 years agospec: add dmidecode as prereq
Eric Blake [Mon, 5 Dec 2011 17:32:41 +0000 (10:32 -0700)]
spec: add dmidecode as prereq

https://bugzilla.redhat.com/show_bug.cgi?id=754909 complains that
because libvirt didn't require dmidecode, that the logs are noisy
and virConnectGetSysinfo needlessly fails.  Even 'virt-what' requires
dmidecode, so it's not that onerous of a dependency.  We may be
able to drop this in the future when we move to parsing sysfs data,
but for now, listing the dependency will help matters.

* libvirt.spec.in (Requires): Sort Requires before BuildRequires.
Add dmidecode.

13 years agobuild: reduce warnings from older gcc
Eric Blake [Mon, 5 Dec 2011 17:14:55 +0000 (10:14 -0700)]
build: reduce warnings from older gcc

Older gcc warns (on every file!) that -Wabi and -Wdeprecated only
make sense on C++ projects.  Newer gcc accepts these warnings for
C, but it is not clear that they can do anything useful, so it
is easier to just drop the warnings altogether.

* m4/virt-compile-warnings.m4 (LIBVIRT_COMPILE_WARNINGS): Silence
-Wabi and -Wdeprecated on older gcc.
Reported by Peter Krempa.

13 years agoexamples: Update event tests for shutdown event
Jiri Denemark [Mon, 5 Dec 2011 12:59:13 +0000 (13:59 +0100)]
examples: Update event tests for shutdown event

13 years agoFix incorrect symbols for virtime.h module breaking Mingw32
Daniel P. Berrange [Mon, 5 Dec 2011 14:04:25 +0000 (14:04 +0000)]
Fix incorrect symbols for virtime.h module breaking Mingw32

The Mingw32 linker highlighted that the symbols for virtime.h
declared in libvirt_private.syms were incorrect

* src/libvirt_private.syms: Fix virtime.h symbols

13 years agoqemu: Rework handling of shutdown event
Jiri Denemark [Wed, 30 Nov 2011 14:31:45 +0000 (15:31 +0100)]
qemu: Rework handling of shutdown event

When QEMU guest finishes its shutdown sequence, qemu stops virtual CPUs
and when started with -no-shutdown waits for us to kill it using
SGITERM. Since QEMU is flushing its internal buffers, some time may pass
before QEMU actually dies. We mistakenly used "paused" state (and
events) for this which is quite confusing since users may see a domain
going to pause while they expect it to shutdown. Since we already have
"shutdown" state with "the domain is being shut down" semantics, we
should use it for this state.

However, the state didn't have a corresponding event so I created one
and called its detail as VIR_DOMAIN_EVENT_SHUTDOWN_FINISHED (guest OS
finished its shutdown sequence) with the intent to add
VIR_DOMAIN_EVENT_SHUTDOWN_STARTED in the future if we have a
sufficiently capable guest agent that can notify us when guest OS starts
to shutdown.

13 years agoremote_driver: don't fail if keepalive check fails
Guido Günther [Sun, 4 Dec 2011 14:26:23 +0000 (15:26 +0100)]
remote_driver: don't fail if keepalive check fails

Otherwise connections to older libvirt abort with:

$ virsh -c qemu+ssh://host.example.com/system list
error: invalid connection pointer in virDrvSupportsFeature
error: failed to connect to the hypervisor

Tested against 0.8.3 and 0.9.8-rc2.

13 years agoAdd support for QEMU 1.0
Jiri Denemark [Fri, 2 Dec 2011 20:20:15 +0000 (21:20 +0100)]
Add support for QEMU 1.0

13 years agopython: Expose binding for virNodeGetMemoryStats()
Peter Krempa [Mon, 28 Nov 2011 17:19:28 +0000 (18:19 +0100)]
python: Expose binding for virNodeGetMemoryStats()

This patch adds binding for virNodeGetMemoryStats method of libvirtd.
Return value is represented as a python dictionary mapping field
names to values.

13 years agopython: Expose binding for virNodeGetCPUStats()
Peter Krempa [Mon, 28 Nov 2011 17:19:27 +0000 (18:19 +0100)]
python: Expose binding for virNodeGetCPUStats()

This patch adds binding for virNodeGetCPUStats method of libvirtd.
Return value is represented as a python dictionary mapping field names
to values.

13 years agomaint: fix improper use of 'an'
Eric Blake [Sun, 4 Dec 2011 00:06:07 +0000 (17:06 -0700)]
maint: fix improper use of 'an'

https://bugzilla.redhat.com/show_bug.cgi?id=648855 mentioned a
misuse of 'an' where 'a' is proper; that has since been fixed,
but a search found other problems (some were a spelling error for
'and', while most were fixed by 'a').

* daemon/stream.c: Fix grammar.
* src/conf/domain_conf.c: Likewise.
* src/conf/domain_event.c: Likewise.
* src/esx/esx_driver.c: Likewise.
* src/esx/esx_vi.c: Likewise.
* src/rpc/virnetclient.c: Likewise.
* src/rpc/virnetserverprogram.c: Likewise.
* src/storage/storage_backend_fs.c: Likewise.
* src/util/conf.c: Likewise.
* src/util/dnsmasq.c: Likewise.
* src/util/iptables.c: Likewise.
* src/xen/xen_hypervisor.c: Likewise.
* src/xen/xend_internal.c: Likewise.
* src/xen/xs_internal.c: Likewise.
* tools/virsh.c: Likewise.

13 years agobuild: require more tools from maintainers
Eric Blake [Fri, 18 Nov 2011 23:35:54 +0000 (16:35 -0700)]
build: require more tools from maintainers

We want our tarballs to be complete - this means that any
generated file that gets shipped as part of the tarball so that
ordinary users don't have to rebuild it must be something
that the maintainer can generate.  There have been various
reports of random build failures when using libvirt.git
instead of a tarball, and often it is due to missing a
maintainer-specific tool to produce one of these generated
files.  This patch raises the bar for what you must have
installed to build libvirt.git, but does not impact what
you can get away with for building tarballs.

Note: It still remains possible to do a successful 'make dist'
without these tools, when starting from a release tarball.

* bootstrap.conf (buildreq): Add tools that maintainers need for a
successful 'make dist' from a fresh git checkout.

13 years agocommand: handle empty buffer argument correctly
Eric Blake [Thu, 10 Nov 2011 00:19:33 +0000 (17:19 -0700)]
command: handle empty buffer argument correctly

virBufferContentAndReset (intentionally) returns NULL for a buffer
with no content, but it is feasible to invoke a command with an
explicit empty string.

* src/util/command.c (virCommandAddEnvBuffer): Reject empty string.
(virCommandAddArgBuffer): Allow explicit empty argument.
* tests/commandtest.c (test9): Test it.
* tests/commanddata/test9.log: Adjust.

13 years agobuild: fix build on Cygwin
Eric Blake [Mon, 13 Jun 2011 23:50:09 +0000 (17:50 -0600)]
build: fix build on Cygwin

The RPC fixups needed on Linux are also needed on cygwin, and
worked without further tweaking to the list of fixups.  Also,
unlike BSD, Cygwin exports 'struct ifreq', but unlike Linux,
Cygwin lacks the ioctls that we were using 'struct ifreq' to
access.  This patch allows compilation under cygwin.

* src/rpc/genprotocol.pl: Also perform fixups on cygwin.
* src/util/virnetdev.c (HAVE_STRUCT_IFREQ): Also require AF_PACKET
definition.
* src/util/virnetdevbridge.c (virNetDevSetupControlFull): Only
compile if SIOCBRADDBR works.

13 years agobuild: fix build at -O2 on rawhide
Eric Blake [Fri, 2 Dec 2011 18:56:58 +0000 (11:56 -0700)]
build: fix build at -O2 on rawhide

I had previously tested commit 059d746 with -O intentionally omitted
from my CFLAGS; but that means that I missed out on this warning
from gcc 4.6.2 when optimizations are enabled:

util/buf.c: In function 'virBufferGetIndent':
util/buf.c:86:1: error: function might be candidate for attribute 'pure' [-Werror=suggest-attribute=pure]

While it is probably a good idea to add the attributes and silence
this warning, it's also invasive; 'make -k' found more than 75 such
complaints.  And it doesn't help that gcc 4.6.2 is still buggy
(coreutils reported a case where gcc 4.6.2 incorrectly suggested
marking a function pure that incremented a global variable; fixed
in gcc 4.7).  So the best fix for now is to disable the warning.

It also doesn't help that I stumbled across another problem - gcc
documents that -Wsuggest-attribute=pure only warns if you use -O,
or if you use -fipa-pure-const.  But in practice, when I omitted -O
but added -fipa-pure-const, the warnings are fickle - I got warnings
for simple compilation that disappeared when I also added -fPIC.
And the way libtool compiles things is with -fPIC first, then without
-fPIC but with errors sent to /dev/null - which meant that without
disabling -Wsuggest-attribute=pure, I got a compile error with no
message.  :(  See http://debbugs.gnu.org/cgi/bugreport.cgi?bug=10197

* m4/virt-compile-warnings.m4 (LIBVIRT_COMPILE_WARNINGS): Silence
-Wsuggest-attribute warnings for now.

13 years agoapparmor: allow tunnelled migrations.
Serge Hallyn [Fri, 2 Dec 2011 19:10:58 +0000 (13:10 -0600)]
apparmor: allow tunnelled migrations.

The pathname for the pipe for tunnelled migration is unresolvable.  The
libvirt apparmor driver therefore refuses access, causing migration to
fail.  If we can't resolve the path, the worst that can happen is that
we should have given permission to the file but didn't.  Otherwise
(especially since this is a /proc/$$/fd/N file) the file is already open
and libvirt won't be refused access by apparmor anyway.

Also adjust virt-aa-helper to allow access to the
*.tunnelmigrate.dest.name files.

For more information, see https://launchpad.net/bugs/869553.

Signed-off-by: Serge Hallyn <serge.hallyn@canonical.com>
13 years agoclient: Check if other thread claims it has the buck before claiming it.
Peter Krempa [Fri, 2 Dec 2011 12:51:59 +0000 (13:51 +0100)]
client: Check if other thread claims it has the buck before claiming it.

Originaly, the code checked if another client is the queue and infered
ownership of the buck from that. Commit fa9595003d043df9f2efe95521c008
added a separate variable to track the buck. That caused, that a new
call might enter claiming it has the buck, while another thread was
signalled to take the buck. This ends in two threads claiming they hold
the buck and entering poll(). This happens due to a race on waking up
threads on the client lock mutex.

This caused multi-threaded clients to hang, most prominently visible and
reproducible on python based clients, like virt-manager.

This patch causes threads, that have been signalled to take the buck to
re-check if buck is held by another thread.

13 years agoUpdate of filters to handle multiple IP addresses
Stefan Berger [Fri, 2 Dec 2011 01:34:36 +0000 (20:34 -0500)]
Update of filters to handle multiple IP addresses

With fragments borrowed from David Steven's previous submission and some
further modifications:

A set of modifications to filters to handle multiple IP addresses
(and MAC addresses) per interface.

Also:
- enable DHCP traffic from VM to any DHCP server
- will require an update to a libvirt-tck data file

Signed-off-by: David L Stevens <dlstevens@us.ibm.com>
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
13 years agovirsh: translate net-info help
Eric Blake [Thu, 1 Dec 2011 23:55:47 +0000 (16:55 -0700)]
virsh: translate net-info help

Reported by kato.tomoyuki@jp.fujitsu.com at
https://bugzilla.redhat.com/show_bug.cgi?id=749564

* tools/virsh.c (info_network_info): Mark string for translation.

13 years agomaint: typo fixes
Eric Blake [Thu, 1 Dec 2011 23:08:34 +0000 (16:08 -0700)]
maint: typo fixes

Many of these were mentioned by Yuri Chornoivan in:
https://bugzilla.redhat.com/show_bug.cgi?id=669506

* src/esx/esx_vi.c (esxVI_WaitForTaskCompletion): Fix spelling.
* src/conf/netdev_vport_profile_conf.c
(virNetDevVPortProfileParse): Likewise.
* src/xen/xend_internal.c (xenDaemonDomainSetVcpusFlags):
Likewise.
* src/xen/xm_internal.c (xenXMDomainSetVcpusFlags): Likewise.
* src/esx/esx_util.c (esxUtil_ResolveHostname): Likewise.
* src/storage/storage_backend_fs.c
(virStorageBackendFileSystemBuild): Likewise.
* daemon/libvirtd.conf: Likewise.
* src/util/logging.c (virLogMessage): Likewise.
* src/uml/uml_conf.c (umlBuildCommandLineNet): Likewise.
* src/vmx/vmx.c (virVMXFormatEthernet): Likewise.

13 years agobuild: update to latest gnulib
Eric Blake [Tue, 29 Nov 2011 23:42:23 +0000 (16:42 -0700)]
build: update to latest gnulib

* .gnulib: Update to latest, for improved 'make syntax-check' and
compiler warnings.
* m4/virt-compile-warnings.m4 (LIBVIRT_COMPILE_WARNINGS):
Re-silence -Wformat-nonliteral.
* cfg.mk (_test_script_regex): Recognize our test scripts.
* gnulib/local/lib/*.diff: Drop, now that gnulib has this.
* tests/virsh-optparse: Fix use of compare.
* tests/virsh-schedinfo: Likewise.

13 years agobuild: properly skip tests
Eric Blake [Thu, 1 Dec 2011 20:47:34 +0000 (13:47 -0700)]
build: properly skip tests

I got this failure on FreeBSD:

shunloadtest.c: In function 'main':
shunloadtest.c:150: error: 'EXIT_AM_SKIP' undeclared (first use in this function)

but inspection showed several other problems, all fixed here.

* tests/domainsnapshotxml2xmltest.c [!WITH_QEMU]: Ensure
EXIT_AM_SKIP is defined.
* tests/esxutilstest.c [!WITH_ESX]: Likewise.
* tests/openvzutilstest.c [!WITH_OPENVZ]: Likewise.
* tests/qemuargv2xmltest.c [!WITH_QEMU]: Likewise.
* tests/qemuhelptest.c [!WITH_QEMU]: Likewise.
* tests/qemuxml2argvtest.c [!WITH_QEMU]: Likewise.
* tests/qemuxml2xmltest.c [!WITH_QEMU]: Likewise.
* tests/qemuxmlnstest.c [!WITH_QEMU]: Likewise.
* tests/shunloadtest.c [!linux]: Likewise.
* tests/vmx2xmltest.c [!WITH_VMX]: Likewise.
* tests/xml2vmxtest.c [!WITH_VMX]: Likewise.

13 years agoAvoid crash in shunloadtest
Daniel P. Berrange [Thu, 1 Dec 2011 16:33:50 +0000 (11:33 -0500)]
Avoid crash in shunloadtest

For unknown reasons, the shunloadtest will crash on Fedora 16
inside dlopen()

 (gdb) bt
 #0  0x00000000000050e6 in ?? ()
 #1  0x00007ff61a77b9d5 in floor () from /lib64/libm.so.6
 #2  0x00007ff61e522963 in _dl_relocate_object () from /lib64/ld-linux-x86-64.so.2
 #3  0x00007ff61e5297e6 in dl_open_worker () from /lib64/ld-linux-x86-64.so.2
 #4  0x00007ff61e525006 in _dl_catch_error () from /lib64/ld-linux-x86-64.so.2
 #5  0x00007ff61e52917a in _dl_open () from /lib64/ld-linux-x86-64.so.2
 #6  0x00007ff61e0f6f26 in dlopen_doit () from /lib64/libdl.so.2
 #7  0x00007ff61e525006 in _dl_catch_error () from /lib64/ld-linux-x86-64.so.2
 #8  0x00007ff61e0f752f in _dlerror_run () from /lib64/libdl.so.2
 #9  0x00007ff61e0f6fc1 in dlopen@@GLIBC_2.2.5 () from /lib64/libdl.so.2
 #10 0x0000000000400a15 in main (argc=<optimized out>, argv=<optimized out>) at shunloadtest.c:105

Changing from RTLD_NOW to RTLD_LAZY avoids this problem,
but quite possibly does not fix the root cause.

* shunloadtest.c: s/NOW/LAZY/

13 years agoFix build for platforms lacking struct ifreq
Daniel P. Berrange [Thu, 1 Dec 2011 13:31:18 +0000 (13:31 +0000)]
Fix build for platforms lacking struct ifreq

This ought to fix the build if you have net/if.h but do
not have struct ifreq

* configure.ac: Check for struct ifreq in net/if.h
* src/util/virnetdev.c: Conditionalize to avoid use of
  struct ifreq if it does not exist

13 years agobuild: fix 'make dist' without dtrace
Eric Blake [Thu, 1 Dec 2011 16:02:53 +0000 (09:02 -0700)]
build: fix 'make dist' without dtrace

probes.h can only be generated on Linux, and then only with dtrace
installed.  If it is part of the tarball, then either 'make dist'
will fail if you don't have that setup, or we would have to start
keeping probes.h in libvirt.git.  Since we only need it to be
generated when dtrace is in use, it's better to avoid shipping
it in the first place, and avoid tracking it in git.

Meanwhile, there is a build dependency - since the RPC code is
generated, it can be built early; but when dtrace is enabled, we
must ensure probes.h is built even earlier.  Commit 1afcfbdd tried
to fix this, but did so in a way that added probes.h into the
tarball, and broke VPATH as well.  Commit ecbca767 fixed VPATH,
but didn't fix the more fundamental problem.  This patch solves
the issue by adding a dependency instead.

Tested with 'make dist' in a clean VPATH builds, for both
'./configure --without-dtrace' and './configure --with-dtrace';
all configurations were able to correctly build a tarball, and
the dtrace configuration no longer sticks probes.h in the tarball.

* src/Makefile.am (REMOTE_DRIVER_GENERATED): Don't ship probes.h;
rather, make it a dependency.

13 years agoFix a logic error for setting block I/O
Lei Li [Thu, 1 Dec 2011 07:55:26 +0000 (15:55 +0800)]
Fix a logic error for setting block I/O

Fix a logic error, the initial value of ret = -1, if just set --config,
it will goto endjob directly without doing its really job here.

Signed-off-by: Lei Li <lilei@linux.vnet.ibm.com>
13 years agoDon't use undocumented __isleap macro
Daniel P. Berrange [Thu, 1 Dec 2011 13:28:44 +0000 (13:28 +0000)]
Don't use undocumented __isleap macro

The glibc time.h header has an undocumented __isleap macro
that we are using. Since it is undocumented & does not appear
on any other OS, stop using it and just define the macro in
libvirt code instead.

* src/util/virtime.c: Remove __isleap usage

13 years agovirsh: Allow other escape characters for console
Michal Privoznik [Tue, 22 Nov 2011 16:08:05 +0000 (17:08 +0100)]
virsh: Allow other escape characters for console

Currently virsh supports only ^] as escape character for console.
However, some users might want to use something else. This patch
creates such ability by specifying '-e' switch on virsh command
line.

13 years agobridge_driver: Don't define network if XML contains more IPv4 adreses.
Peter Krempa [Wed, 30 Nov 2011 14:26:25 +0000 (15:26 +0100)]
bridge_driver: Don't define network if XML contains more IPv4 adreses.

Only one IPv4 DHCP definition is supported. Originally the code checked
for a multiple definition and returned an error, but the new domain
definition was already added to networks. This patch moves the check
before the newly defined network is added to active networks.

 *src/network/bridge_driver.c: networkDefine(): - move multiple IPv4
                                                  addresses check before
                                                  definition is used.

13 years agospec: mark directories in /var/run as ghosts
Eric Blake [Wed, 30 Nov 2011 22:34:42 +0000 (15:34 -0700)]
spec: mark directories in /var/run as ghosts

We have several directories that are created on the fly, and which
only contain state relevant to a running libvirtd process (all
located in /var/run).  Since the directories are created as needed,
and make no sense without a running libvirtd, we want them deleted
if libvirt is uninstalled.  And in F15 and newer, /var/run is on
tmpfs (forcing us to recreate on the fly); which means that someone
trying to verify a complete rpm will fail if the directory does not
currently exist because libvirtd has not been started since boot.
The solution, then, is to mark the directories as %ghost, so that
rpm knows that we own them and will clean it up if libvirt is
uninstalled, but will no longer create the directory for us at
install, nor complain at verify time if the directory does not exist.

See https://bugzilla.redhat.com/show_bug.cgi?id=656611.

* libvirt.spec.in (%files): Add %ghost to temporary directories
that we don't install, but want cleaned up on libvirt removal.

13 years agovirsh: Fix possible deadlock when virsh is about to exit
Jiri Denemark [Wed, 30 Nov 2011 19:42:20 +0000 (20:42 +0100)]
virsh: Fix possible deadlock when virsh is about to exit

Not only was ctl->quit accessed without a mutex but unfortunately,
virEventAddTimeout only interrupts the poll when event loop is running
so the hack needs to add a timeout that will make next poll return
immediately without blocking.

13 years agoutil: Plug memory leak on virNetDevMacVLanCreateWithVPortProfile() error path
Alex Jia [Wed, 30 Nov 2011 05:57:12 +0000 (13:57 +0800)]
util: Plug memory leak on virNetDevMacVLanCreateWithVPortProfile() error path

Detected by Coverity. Leak introduced in commit 90074ec.

Signed-off-by: Alex Jia <ajia@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
13 years agoutil: Plug memory leak on virNetDevBridgeGet() sucessful path
Alex Jia [Wed, 30 Nov 2011 05:57:11 +0000 (13:57 +0800)]
util: Plug memory leak on virNetDevBridgeGet() sucessful path

Detected by Coverity. Leak introduced in commit c1df2c1.

Two bugs here:
1. memory leak on successful parse
2. failure to parse still returned success

Signed-off-by: Alex Jia <ajia@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
13 years agouml: Plug memory leak on umlStartVMDaemon() error path
Alex Jia [Wed, 30 Nov 2011 05:57:10 +0000 (13:57 +0800)]
uml: Plug memory leak on umlStartVMDaemon() error path

Detected by Coverity.  Leak introduced in commit 8866eed.

Two bugs here:
1. logfd wasn't closed on all return paths
2. if we failed to mark a domain autodestroy, then the domain
was not made transient but we still returned success

Signed-off-by: Alex Jia <ajia@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
13 years agorpc: Plug memory leak on virNetClientSendInternal() error path
Alex Jia [Wed, 30 Nov 2011 05:57:09 +0000 (13:57 +0800)]
rpc: Plug memory leak on virNetClientSendInternal() error path

Detected by Coverity. Leak introduced in commit 673adba.

Two separate bugs here:
1. call was not freed on all error paths
2. virCondDestroy was called even if virCondInit failed

Signed-off-by: Alex Jia <ajia@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
13 years agoconf: Plug memory leak on virDomainDefParseXML() error path
Alex Jia [Wed, 30 Nov 2011 05:57:07 +0000 (13:57 +0800)]
conf: Plug memory leak on virDomainDefParseXML() error path

Detected by Coverity. Leak introduced in commit 0873b68.

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agoqemu: Plug memory leak onqemuProcessWaitForMonitor() error path
Alex Jia [Wed, 30 Nov 2011 06:49:51 +0000 (14:49 +0800)]
qemu: Plug memory leak onqemuProcessWaitForMonitor() error path

Detected by Coverity. Leak introduced in commit 109efd7.

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agoAdd PPC cpu driver.
Prerna Saxena [Mon, 3 Oct 2011 12:56:20 +0000 (05:56 -0700)]
Add PPC cpu driver.

To add support for running libvirt on PowerPC, a CPU driver for the
PowerPC platform must be added.
Most generic cpu driver routines such as CPU compare, decode, etc
are based on CPUID comparison and are not relevant for non-x86
platforms.
Here, we introduce stubs for relevant PowerPC routines invoked by libvirt.

Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
Signed-off-by: Anton Blanchard <anton@au.ibm.com>
13 years agoqemu: filter blkio 0-device-weight at two other places
Hu Tao [Wed, 30 Nov 2011 02:11:08 +0000 (10:11 +0800)]
qemu: filter blkio 0-device-weight at two other places

filter 0-device-weight when:

  - getting blkio parameters with --config
  - starting up a domain

When testing with blkio, I found these issues:

  (dom is down)
  virsh blkiotune dom --device-weights /dev/sda,300,/dev/sdb,500
  virsh blkiotune dom --device-weights /dev/sda,300,/dev/sdb,0
  virsh blkiotune dom
  weight         : 800
  device_weight  : /dev/sda,200,/dev/sdb,0

  # issue 1: shows 0 device weight of /dev/sdb that may confuse user

  (continued)
  virsh start dom

  # issue 2: If /dev/sdb doesn't exist, libvirt refuses to bring the
  # dom up because it wants to set the device weight to 0 of a
  # non-existing device. Since 0 means no weight-limit, we really don't
  # have to set it.

13 years agoqemu: amend existing table of device weights
Eric Blake [Tue, 29 Nov 2011 21:00:17 +0000 (14:00 -0700)]
qemu: amend existing table of device weights

Prior to this patch, for a running dom, the commands:

$ virsh blkiotune dom --device-weights /dev/sda,502,/dev/sdb,498
$ virsh blkiotune dom --device-weights /dev/sda,503
$ virsh blkiotune dom
weight         : 500
device_weight  : /dev/sda,503

claim that /dev/sdb no longer has a non-default weight, but
directly querying cgroups says otherwise:

$ cat /cgroup/blkio/libvirt/qemu/dom/blkio.weight_device
8:0     503
8:16    498

After this patch, an explicit 0 is required to remove a device path
from the XML, and omitting a device path that was previously
specified leaves that device path untouched in the XML, to match
cgroups behavior.

* src/qemu/qemu_driver.c (parseBlkioWeightDeviceStr): Rename...
(qemuDomainParseDeviceWeightStr): ...and use correct type.
(qemuDomainSetBlkioParameters): After parsing string, modify
rather than replacing existing table.
* tools/virsh.pod (blkiotune): Tweak wording.

13 years agoconf: reject duplicate paths in device weights
Eric Blake [Tue, 29 Nov 2011 20:23:17 +0000 (13:23 -0700)]
conf: reject duplicate paths in device weights

The next patch will make it possible to have virDomainSetBlkioParameters
leave device weights unchanged if they are not mentioned in the incoming
string, but this only works if the list of block weights does not allow
duplicate paths.  Technically, a user can still confuse libvirt by
passing alternate spellings that resolve to the same device, but it
is not worth worrying about working around that kind of abuse.

* src/conf/domain_conf.c (virDomainDefParseXML): Require unique
paths.

13 years agovirsh: fix setting weight and device-weights at the same time
Hu Tao [Wed, 30 Nov 2011 07:26:25 +0000 (15:26 +0800)]
virsh: fix setting weight and device-weights at the same time

When setting both blkio weight and device-weights at the same time, the weight
is lost. Fix it.

13 years agoAdd tests for blkdeviotune
Lei Li [Tue, 15 Nov 2011 09:02:50 +0000 (17:02 +0800)]
Add tests for blkdeviotune

Signed-off-by: Lei Li <lilei@linux.vnet.ibm.com>
Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
13 years agoSupport virDomain{Set, Get}BlockIoTune in the python API
Lei Li [Tue, 15 Nov 2011 09:02:49 +0000 (17:02 +0800)]
Support virDomain{Set, Get}BlockIoTune in the python API

Python support for both setting and getting block I/O throttle.

Signed-off-by: Lei Li <lilei@linux.vnet.ibm.com>
Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
13 years agoEnable the blkdeviotune command in virsh
Lei Li [Tue, 15 Nov 2011 09:02:47 +0000 (17:02 +0800)]
Enable the blkdeviotune command in virsh

Support virsh command blkdeviotune. Can set or query a block disk
I/O throttle setting.

Signed-off-by: Lei Li <lilei@linux.vnet.ibm.com>
Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
13 years agoImplement virDomain{Set, Get}BlockIoTune for the qemu driver
Lei Li [Tue, 15 Nov 2011 09:02:45 +0000 (17:02 +0800)]
Implement virDomain{Set, Get}BlockIoTune for the qemu driver

Implement the block I/O throttle setting and getting support to qemu
driver.

Signed-off-by: Lei Li <lilei@linux.vnet.ibm.com>
Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
13 years agoSupport block I/O throttle in XML
Lei Li [Tue, 15 Nov 2011 09:02:46 +0000 (17:02 +0800)]
Support block I/O throttle in XML

Enable block I/O throttle for per-disk in XML, as the first
per-disk IO tuning parameter.

Signed-off-by: Lei Li <lilei@linux.vnet.ibm.com>
Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
13 years agoAdd virDomain{Set, Get}BlockIoTune support to the remote driver
Lei Li [Tue, 15 Nov 2011 09:02:44 +0000 (17:02 +0800)]
Add virDomain{Set, Get}BlockIoTune support to the remote driver

Support Block I/O Throttle setting and query to remote driver.

Signed-off-by: Lei Li <lilei@linux.vnet.ibm.com>
Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
13 years agoFix leak build config file path
Daniel P. Berrange [Tue, 29 Nov 2011 16:19:40 +0000 (16:19 +0000)]
Fix leak build config file path

* src/libvirt.c: Free user directory path

13 years agoRemove time APIs from src/util/util.h
Daniel P. Berrange [Tue, 29 Nov 2011 12:33:23 +0000 (12:33 +0000)]
Remove time APIs from src/util/util.h

The virTimestamp and virTimeMs functions in src/util/util.h
duplicate functionality from virtime.h, in a non-async signal
safe manner. Remove them, and convert all code over to the new
APIs.

* src/util/util.c, src/util/util.h: Delete virTimeMs and virTimestamp
* src/lxc/lxc_driver.c, src/qemu/qemu_domain.c,
  src/qemu/qemu_driver.c, src/qemu/qemu_migration.c,
  src/qemu/qemu_process.c, src/util/event_poll.c: Convert to use
  virtime APIs

13 years agoMake logging async signal safe wrt time stamp generation
Daniel P. Berrange [Tue, 29 Nov 2011 12:32:31 +0000 (12:32 +0000)]
Make logging async signal safe wrt time stamp generation

Use the new virTimeStringNowRaw() API for generating log timestamps
in an async signal safe manner

* src/util/logging.c: Use virTimeStringNowRaw

13 years agoAdd internal APIs for dealing with time
Daniel P. Berrange [Tue, 29 Nov 2011 12:11:01 +0000 (12:11 +0000)]
Add internal APIs for dealing with time

The logging APIs need to be able to generate formatted timestamps
using only async signal safe functions. This rules out using
gmtime/localtime/malloc/gettimeday(!) and much more.

Introduce a new internal API which is async signal safe.

  virTimeMillisNowRaw replacement for gettimeofday. Uses clock_gettime
                      where available, otherwise falls back to the unsafe
                      gettimeofday

  virTimeFieldsNowRaw  replacements for gmtime(), convert a timestamp
  virTimeFieldsThenRaw into a broken out set of fields. No localtime()
                       replacement is provided, because converting to
                       local time is not practical with only async signal
                       safe APIs.

  virTimeStringNowRaw  replacements for strftime() which print a timestamp
  virTimeStringThenRaw into a string, using a pre-determined format, with
                       a fixed size buffer (VIR_TIME_STRING_BUFLEN)

For each of these there is also a version without the Raw postfix
which raises a full libvirt error. These versions are not async
signal safe

* src/Makefile.am, src/util/virtime.c, src/util/virtime.h: New files
* src/libvirt_private.syms: New APis
* configure.ac: Check for clock_gettime in -lrt
* tests/virtimetest.c, tests/Makefile.am: Test new APIs

13 years agoRemove obsolete virGetPMCapabilities sym from private symbols file
Daniel P. Berrange [Wed, 30 Nov 2011 11:42:57 +0000 (11:42 +0000)]
Remove obsolete virGetPMCapabilities sym from private symbols file

Fix the build on Mingw32 by removing the now obsolete
virGetPMCapabilities symbol from the private exports file

* src/libvirt_private.syms: Remove virGetPMCapabilities

13 years agoDon't mark suspend as active until we know it is running
Daniel P. Berrange [Tue, 29 Nov 2011 15:31:19 +0000 (15:31 +0000)]
Don't mark suspend as active until we know it is running

If suspend failed for some reason (e.g. too short duration) then
subsequent attempts to trigger suspend were rejected because we
had already marked a suspend as being in progress

* src/util/virnodesuspend.c: Don't mark suspend as active
  until we've successfully triggered it

13 years agoAdd suspend info to Xen, LXC and UML hypervisor capabilities
Daniel P. Berrange [Tue, 29 Nov 2011 15:28:26 +0000 (15:28 +0000)]
Add suspend info to Xen, LXC and UML hypervisor capabilities

* src/lxc/lxc_conf.c, src/uml/uml_conf.c,
  src/xen/xen_hypervisor.c: Initialize suspend capabilities
* tests/xencapsdata/*xml: Add empty powermgmt capabilities

13 years agoRemove pointless strdup in node suspend code
Daniel P. Berrange [Tue, 29 Nov 2011 15:22:53 +0000 (15:22 +0000)]
Remove pointless strdup in node suspend code

The command name for the suspend action does not need to be
strdup'd. The constant string can be used directly. This
also means the code can be trivially rearranged to make the
switch clearer

* src/util/virnodesuspend.c: Remove strdup of cmdString

13 years agoDo lazy init of host PM features
Daniel P. Berrange [Tue, 29 Nov 2011 15:20:03 +0000 (15:20 +0000)]
Do lazy init of host PM features

To avoid probing the host power management features on any
call to virInitialize, only initialize the mutex in
virNodeSuspendInit. Do lazy load of the supported PM target
mask when it is actually needed

* src/util/virnodesuspend.c: Lazy init of supported features

13 years agoRemove powerMgmt_valid field from capabilities struct
Daniel P. Berrange [Tue, 29 Nov 2011 14:50:04 +0000 (14:50 +0000)]
Remove powerMgmt_valid field from capabilities struct

If we ensure that virNodeSuspendGetTargetMask always resets
*bitmask to zero upon failure, there is no need for the
powerMgmt_valid field.

* src/util/virnodesuspend.c: Ensure *bitmask is zero upon
  failure
* src/conf/capabilities.c, src/conf/capabilities.h: Remove
  powerMgmt_valid field
* src/qemu/qemu_capabilities.c: Remove powerMgmt_valid

13 years agoAdd export of node suspend capabilities APIs
Daniel P. Berrange [Tue, 29 Nov 2011 14:44:28 +0000 (14:44 +0000)]
Add export of node suspend capabilities APIs

* src/libvirt_private.syms: Export virNodeSuspendSupportsTarget
  and virNodeSuspendGetTargetMask

13 years agoMove suspend capabilities APIs out of util.h into virnodesuspend.c
Daniel P. Berrange [Tue, 29 Nov 2011 14:42:58 +0000 (14:42 +0000)]
Move suspend capabilities APIs out of util.h into virnodesuspend.c

The node suspend capabilities APIs should not have been put into
util.[ch]. Instead move them into virnodesuspend.[ch]

* src/util/util.c, src/util/util.h: Remove suspend capabilities APIs
* src/util/virnodesuspend.c, src/util/virnodesuspend.h: Add
  suspend capabilities APIs
* src/qemu/qemu_capabilities.c: Include virnodesuspend.h

13 years agoRename suspend capabilities APIs
Daniel P. Berrange [Tue, 29 Nov 2011 14:37:42 +0000 (14:37 +0000)]
Rename suspend capabilities APIs

Rename virGetPMCapabilities to virNodeSuspendGetTargetMask and
virDiscoverHostPMFeature to virNodeSuspendSupportsTarget.

* src/util/util.c, src/util/util.h: Rename APIs
* src/qemu/qemu_capabilities.c, src/util/virnodesuspend.c: Adjust
  for new names

13 years agoSanitize virDiscoverHostPMFeature to return a boolean
Daniel P. Berrange [Tue, 29 Nov 2011 14:29:28 +0000 (14:29 +0000)]
Sanitize virDiscoverHostPMFeature to return a boolean

Since virDiscoverHostPMFeature is just checking one feature,
there is no reason for it to return a bitmask. Change it to
return a boolean

* src/util/util.c, src/util/util.h: Make virDiscoverHostPMFeature
  return a boolean

13 years agoMove the virHostPMCapability enum helpers into capabilities.c
Daniel P. Berrange [Tue, 29 Nov 2011 14:22:21 +0000 (14:22 +0000)]
Move the virHostPMCapability enum helpers into capabilities.c

The virHostPMCapability enum helper was declared in util.h
but implemented in capabilities.c, which is in a completely
separate library at link time. Move the declaration into the
capabilities.c file and rename it to match normal conventions

* src/util/util.h: Remove virHostPMCapability enum decl
* src/conf/capabilities.c: Add virCapsHostPMTarget enum

13 years agoFix capabilities XML to use generic terms for suspend targets
Daniel P. Berrange [Tue, 29 Nov 2011 14:14:03 +0000 (14:14 +0000)]
Fix capabilities XML to use generic terms for suspend targets

The capabilities XML uses the x86 specific terms 'S3', 'S4'
and 'Hybrid-Syspend'. Switch it to use the same terminology
as the API constants and virsh options, eg 'suspend_mem'
'suspend_disk' and 'suspend_hybrid'

* docs/formatcaps.html.in, docs/schemas/capability.rng,
  src/conf/capabilities.c: Rename suspend constants

13 years agoRemove internal only virHostPMCapability enum
Daniel P. Berrange [Tue, 29 Nov 2011 14:11:14 +0000 (14:11 +0000)]
Remove internal only virHostPMCapability enum

The internal virHostPMCapability enum just duplicates the
public virNodeSuspendTarget enum, but with different names.

* src/util/util.c: Use VIR_NODE_SUSPEND_TARGET constants
* src/util/util.h: Remove virHostPMCapability enum
* src/conf/capabilities.c: Use VIR_NODE_SUSPEND_TARGET_LAST

13 years agoFix values of PM target type constants
Daniel P. Berrange [Tue, 29 Nov 2011 13:58:32 +0000 (13:58 +0000)]
Fix values of PM target type constants

The VIR_NODE_SUSPEND_TARGET constants are not flags, so they
should just be assigned straightforward incrementing values.

* include/libvirt/libvirt.h.in: Change VIR_NODE_SUSPEND_TARGET
  values
* src/util/virnodesuspend.c: Fix suspend target checks

13 years agoutil: avoid null deref on qcowXGetBackingStore
Alex Jia [Wed, 30 Nov 2011 07:50:44 +0000 (15:50 +0800)]
util: avoid null deref on qcowXGetBackingStore

Detected by Coverity. the only case is caller passes a NULL to 'format' variable,
then taking 'if (format)' false branch, the function qcow2GetBackingStoreFormat
will directly dereferences the NULL 'format' pointer variable.

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agovirsh: correct return value error
Alex Jia [Wed, 30 Nov 2011 08:25:07 +0000 (16:25 +0800)]
virsh: correct return value error

Fix cmdDomblklist to return 'true' on success instead of '0'

https://bugzilla.redhat.com/show_bug.cgi?id=758590

Signed-off-by: Alex Jia <ajia@redhat.com>
13 years agoAdd new API virDomain{Set, Get}BlockIoTune
Lei Li [Tue, 15 Nov 2011 09:02:43 +0000 (17:02 +0800)]
Add new API virDomain{Set, Get}BlockIoTune

This patch add new pulic API virDomainSetBlockIoTune and
virDomainGetBlockIoTune.

Signed-off-by: Lei Li <lilei@linux.vnet.ibm.com>
Signed-off-by: Zhi Yong Wu <wuzhy@linux.vnet.ibm.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
13 years agoblkiotune: add qemu support for blkiotune.device_weight
Hu Tao [Tue, 8 Nov 2011 11:00:34 +0000 (19:00 +0800)]
blkiotune: add qemu support for blkiotune.device_weight

Implement setting/getting per-device blkio weights in qemu,
using the cgroups blkio.weight_device tunable.

13 years agoblkiotune: add interface for blkiotune.device_weight
Hu Tao [Tue, 8 Nov 2011 11:00:33 +0000 (19:00 +0800)]
blkiotune: add interface for blkiotune.device_weight

This adds per-device weights to <blkiotune>.  Note that the
cgroups implementation only supports weights per block device,
and not per-file within the device; hence this option must be
global to the domain definition rather than tied to individual
<devices>/<disk> entries:

<domain ...>
  <blkiotune>
    <device>
      <path>/path/to/block</path>
      <weight>1000</weight>
    </device>
  </blkiotune>
..

This patch also adds a parameter --device-weights to virsh command
blkiotune for setting/getting blkiotune.weight_device for any
hypervisor that supports it.  All <device> entries under
<blkiotune> are concatenated into a single string attribute under
virDomain{Get,Set}BlkioParameters, named "device_weight".

Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
13 years agoqemu: fix blkiotune --live --config
Eric Blake [Tue, 15 Nov 2011 00:18:15 +0000 (17:18 -0700)]
qemu: fix blkiotune --live --config

Without this,  'virsh blkiotune --live --config --weight=n'
only affected live.

* src/qemu/qemu_driver.c (qemuDomainSetBlkioParameters): Allow
setting both configurations at once.

13 years agoqemu, lxc: drop redundant checks
Eric Blake [Tue, 29 Nov 2011 17:40:19 +0000 (10:40 -0700)]
qemu, lxc: drop redundant checks

After the previous patch, there are now some redundant checks.

* src/qemu/qemu_driver.c (qemudDomainGetVcpuPinInfo)
(qemuGetSchedulerParametersFlags): Drop checks now guaranteed by
libvirt.c.
* src/lxc/lxc_driver.c (lxcGetSchedulerParametersFlags):
Likewise.

13 years agoAPI: prevent query of --live and --config at once
Eric Blake [Tue, 15 Nov 2011 00:11:18 +0000 (17:11 -0700)]
API: prevent query of --live and --config at once

Drivers were inconsistent when presented both --live and --config
at once.  For example, within qemu, getting memory parameters
favored live, getting blkio tuning favored config, and getting
scheduler parameters errored out.  Also, some, but not all,
attempts to mix flags on query were filtered at the virsh level.
We shouldn't have to duplicate efforts in every client app, nor
in every driver.  So, it is simpler to just enforce that the two
flags cannot both be used at once on query operations, which has
precedent in libvirt.c, and which matches the documentation of
virDomainModificationImpact.

* src/libvirt.c (virDomainGetMemoryParameters)
(virDomainGetBlkioParameters)
(virDomainGetSchedulerParametersFlags, virDomainGetVcpuPinInfo):
Borrow sanity checking from virDomainGetVcpusFlags.

13 years agobuild: fix typo in last patch
Eric Blake [Tue, 29 Nov 2011 16:48:43 +0000 (09:48 -0700)]
build: fix typo in last patch

* src/remote_protocol-structs: Use correct RPC name.

13 years agoblock_resize: Update test file for RPC
Osier Yang [Tue, 29 Nov 2011 15:18:30 +0000 (23:18 +0800)]
block_resize: Update test file for RPC

Pushed under build failure rule.

13 years agoblock_resize: Expose the new API to virsh
Osier Yang [Tue, 29 Nov 2011 07:37:09 +0000 (15:37 +0800)]
block_resize: Expose the new API to virsh

13 years agoblock_resize: Implement qemu driver method
Osier Yang [Tue, 29 Nov 2011 07:36:00 +0000 (15:36 +0800)]
block_resize: Implement qemu driver method

It requires the domain is running, otherwise fails. Resize to a lower
size is supported, but should be used with extreme caution.

In order to prohibit the "size" overflowing after multiplied by
1024. We do checking in the codes. For QMP mode, the default units
is Bytes, the passed size needs to be multiplied by 1024, however,
for HMP mode, the default units is "Megabytes", the passed "size"
needs to be divided by 1024 then.

13 years agoblock_resize: Implement qemu monitor functions
Osier Yang [Tue, 29 Nov 2011 07:34:53 +0000 (15:34 +0800)]
block_resize: Implement qemu monitor functions

Implements functions for both HMP and QMP mode.

For HMP mode, qemu uses "M" as the units by default, so the passed "sized"
is divided by 1024.

For QMP mode, qemu uses "Bytes" as the units by default, the passed "sized"
is multiplied by 1024.

All of the monitor functions return -1 on failure, 0 on success, or -2 if
not supported.

13 years agoblock_resize: Wire up the remote protocol
Osier Yang [Tue, 29 Nov 2011 13:44:36 +0000 (21:44 +0800)]
block_resize: Wire up the remote protocol

13 years agoblock_resize: Define the new API
Osier Yang [Tue, 29 Nov 2011 09:59:15 +0000 (17:59 +0800)]
block_resize: Define the new API

The new API is named as "virDomainBlockResize", intending to add
support for qemu monitor command "block_resize" (both HMP and QMP).

Similar with APIs like "virDomainSetMemoryFlags", the units for
argument "size" is kilobytes.

13 years agobandwidth: Fix funky identation
Michal Privoznik [Tue, 29 Nov 2011 13:25:40 +0000 (14:25 +0100)]
bandwidth: Fix funky identation

13 years agovirsh: Fix typos in man page
Jiri Denemark [Tue, 29 Nov 2011 11:45:18 +0000 (12:45 +0100)]
virsh: Fix typos in man page

13 years agolxc: Fix suspend/resume with freezer cgroup
Jiri Denemark [Tue, 29 Nov 2011 11:28:09 +0000 (12:28 +0100)]
lxc: Fix suspend/resume with freezer cgroup

13 years agoexamples: Correct the example command to use testnode.xml
Osier Yang [Tue, 29 Nov 2011 10:39:04 +0000 (18:39 +0800)]
examples: Correct the example command to use testnode.xml

 * s/-connection/-c/
 * Removes the redundant '/'.
 * Add "absolute" so that it's more clear.

Pushed under trivial rule.