]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
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.

13 years agoAdd virsh command to initiate suspend on the host
Srivatsa S. Bhat [Mon, 28 Nov 2011 21:42:44 +0000 (03:12 +0530)]
Add virsh command to initiate suspend on the host

Add a new command 'nodesuspend' to perform a timed suspend on the host.

Signed-off-by: Srivatsa S. Bhat <srivatsa.bhat@linux.vnet.ibm.com>
13 years agoImplement the core API to suspend/resume the host
Srivatsa S. Bhat [Tue, 29 Nov 2011 09:07:38 +0000 (17:07 +0800)]
Implement the core API to suspend/resume the host

Add the core functions that implement the functionality of the API.
Suspend is done by using an asynchronous mechanism so that we can return
the status to the caller before the host gets suspended. This asynchronous
operation is achieved by suspending the host in a separate thread of
execution. However, returning the status to the caller is only best-effort,
but not guaranteed.

To resume the host, an RTC alarm is set up (based on how long we want to
suspend) before suspending the host. When this alarm fires, the host
gets woken up.

Suspend-to-RAM operation on a host running Linux can take upto more than 20
seconds, depending on the load of the system. (Freezing of tasks, an operation
preceding any suspend operation, is given up after a 20 second timeout).
And Suspend-to-Disk can take even more time, considering the time required
for compaction, creating the memory image and writing it to disk etc.
So, we do not allow the user to specify a suspend duration of less than 60
seconds, to be on the safer side, since we don't want to prematurely declare
failure when we only had to wait for some more time.

13 years agoAdd the remote protocol implementation for virNodeSuspendForDuration
Srivatsa S. Bhat [Tue, 29 Nov 2011 07:15:14 +0000 (15:15 +0800)]
Add the remote protocol implementation for virNodeSuspendForDuration

Implement the remote protocol for virNodeSuspendForDuration() API.

13 years agoAdd a public API to invoke suspend/resume on the host
Srivatsa S. Bhat [Tue, 29 Nov 2011 06:37:06 +0000 (14:37 +0800)]
Add a public API to invoke suspend/resume on the host

Implement the public definitions for the new API
virNodeSuspendForDuration() which will be subsequently used to
do a timed suspend on the host.

13 years agoAdd 'Hybrid-Suspend' power management discovery for the host
Srivatsa S. Bhat [Tue, 29 Nov 2011 06:56:10 +0000 (14:56 +0800)]
Add 'Hybrid-Suspend' power management discovery for the host

Some systems support a feature known as 'Hybrid-Suspend', apart from the
usual system-wide sleep states such as Suspend-to-RAM (S3) or Suspend-to-Disk
(S4). Add the functionality to discover this power management feature and
export it in the capabilities XML under the <power_management> tag.

13 years agorpc: Really send non-blocking calls while waiting for another call
Jiri Denemark [Mon, 28 Nov 2011 16:41:25 +0000 (17:41 +0100)]
rpc: Really send non-blocking calls while waiting for another call

When another thread was dispatching while we wanted to send a
non-blocking call, we correctly queued the call and woke up the thread
but the thread just threw the call away since it forgot to recheck if
its socket was writable.

13 years agovirsh: Don't traverse childless nodes in vshNodeIsSuperset
Michal Privoznik [Mon, 28 Nov 2011 16:43:51 +0000 (17:43 +0100)]
virsh: Don't traverse childless nodes in vshNodeIsSuperset

If both nodes do not have any children, we pass zero to
virBitmapAlloc which returns NULL. In turn we report OOM error
and return false (meaning nodes are different). This is not true.

13 years agovirnetsocket: pass XAUTORITY for ssh connection
Christian Franke [Mon, 28 Nov 2011 12:15:25 +0000 (13:15 +0100)]
virnetsocket: pass XAUTORITY for ssh connection

When spawning an ssh connection, the environment variables
DISPLAY, SSH_ASKPASS, ... are passed. However XAUTHORITY,
which is necessary if the .Xauthority is in a non default
place, was not passed.

Signed-off-by: Christian Franke <nobody@nowhere.ws>
13 years agoconf: make virt-xml-validate work with vbox domains
Lorin Hochstein [Mon, 28 Nov 2011 14:26:57 +0000 (09:26 -0500)]
conf: make virt-xml-validate work with vbox domains

virt-xml-validate fails when run on a domain XML file of type 'vbox'.

For failing test case, see https://bugzilla.redhat.com/show_bug.cgi?id=757097

This patch updates the XML schema to accept all valid hypervisor
types, as well as dropping hypervisor types that are not in use
by the current code base.

Signed-off-by: Eric Blake <eblake@redhat.com>
13 years agoconf: Improve incorrect root element error messages
Michal Privoznik [Fri, 25 Nov 2011 12:23:03 +0000 (13:23 +0100)]
conf: Improve incorrect root element error messages

When user pass wrong root element, it is not 'internal error' and
we can give him hint what we are expecting.

13 years agoRefactor initial LXC mem tune / device ACL code
Daniel P. Berrange [Thu, 10 Nov 2011 12:38:24 +0000 (12:38 +0000)]
Refactor initial LXC mem tune / device ACL code

To make lxcSetContainerResources smaller, pull the mem tune
and device ACL setup code out into separate methods

* src/lxc/lxc_controller.c: Introduce lxcSetContainerMemTune
  and lxcSetContainerDeviceACL

13 years agoAdd support for blkio tuning of LXC containers
Daniel P. Berrange [Thu, 10 Nov 2011 12:35:38 +0000 (12:35 +0000)]
Add support for blkio tuning of LXC containers

* src/lxc/lxc_controller.c: Refactor setting of initial blkio
  tuning parameters
* src/lxc/lxc_driver.c: Enable live change of blkio tuning

13 years agoAdd support for CPU quota/period to LXC driver
Daniel P. Berrange [Thu, 10 Nov 2011 12:16:26 +0000 (12:16 +0000)]
Add support for CPU quota/period to LXC driver

* src/lxc/lxc_driver.c: Support changing quota/period for LXC
  containers
* src/lxc/lxc_controller.c: Set initial quota/period at startup

13 years agoSupport CPU placement in LXC driver
Daniel P. Berrange [Thu, 10 Nov 2011 11:54:53 +0000 (11:54 +0000)]
Support CPU placement in LXC driver

While LXC does not have the concept of VCPUS, so we can't do
per-VCPU pCPU placement, we can support the VM level CPU
placement. Todo this simply set the CPU affinity of the LXC
controller at startup. All child processes will inherit this
affinity.

* src/lxc/lxc_controller.c: Set process affinity

13 years agoSupport NUMA memory placement for LXC containers
Daniel P. Berrange [Thu, 10 Nov 2011 11:51:32 +0000 (11:51 +0000)]
Support NUMA memory placement for LXC containers

Use numactl to set NUMA memory placement for LXC containers

* src/lxc/lxc_controller.c: Support NUMA memory placement

13 years agostorage: Refetch file status after open
Michal Privoznik [Fri, 25 Nov 2011 12:25:19 +0000 (13:25 +0100)]
storage: Refetch file status after open

This partly reverts my previous patch f88de3eb. We need to
get file status after open, as given path could have been symlink,
so fstat() will operate on different file than lstat().

13 years agoutil: fix thinko in runIO
Paolo Bonzini [Thu, 24 Nov 2011 15:36:50 +0000 (16:36 +0100)]
util: fix thinko in runIO

When aligning you need to clear the bits in the mask and leave the
others aside.  Likely this code has never run, and will never run.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
13 years agostorage: Skip socket and fifo on pool-start
Michal Privoznik [Thu, 24 Nov 2011 14:16:19 +0000 (15:16 +0100)]
storage: Skip socket and fifo on pool-start

If pool directory contains special files like FIFO or sockets
we want to skip those on pool-start or pool-refresh otherwise
open() will get an error.

13 years agoconf: Don't drop console definition on domain restart
Michal Privoznik [Thu, 24 Nov 2011 15:53:30 +0000 (16:53 +0100)]
conf: Don't drop console definition on domain restart

One of my latest patches 2e37bf42d28d8bb5d045b206587c64643c64d02a
copy serial console definition. On domain shutdown we save this
info into state XML. However, later on the daemon start we simply
drop this info and since we are not re-reading qemu log,
vm->def->consoles[0] does not get populated with copy. Therefore
we need to avoid dropping console definition if it is just alias
for serial console.

13 years agoFix version numbers for isAlive and setKeepAlive driver APIs
Jiri Denemark [Thu, 24 Nov 2011 13:44:59 +0000 (14:44 +0100)]
Fix version numbers for isAlive and setKeepAlive driver APIs

13 years agobuild: Properly generate and check virkeepaliveprotocol-structs
Jiri Denemark [Thu, 24 Nov 2011 13:16:36 +0000 (14:16 +0100)]
build: Properly generate and check virkeepaliveprotocol-structs

This fixes make dist broken by recent keepalive series

13 years agoexamples: Use virConnectOpenAuth in events-c
Jiri Denemark [Tue, 22 Nov 2011 11:09:13 +0000 (12:09 +0100)]
examples: Use virConnectOpenAuth in events-c

13 years agoqemu: Cancel p2p migration when connection breaks
Jiri Denemark [Fri, 23 Sep 2011 06:56:56 +0000 (08:56 +0200)]
qemu: Cancel p2p migration when connection breaks

If a connection to destination host is lost during peer-to-peer
migration (because keepalive protocol timed out), we won't be able to
finish the migration and it doesn't make sense to wait for qemu to
transmit all data. This patch automatically cancels such migration
without waiting for virDomainAbortJob to be called.

13 years agoqemu: Add support for keepalive messages during p2p migration
Jiri Denemark [Fri, 16 Sep 2011 11:50:56 +0000 (13:50 +0200)]
qemu: Add support for keepalive messages during p2p migration

13 years agoAdd keepalive support into domain-events examples
Jiri Denemark [Fri, 16 Sep 2011 09:04:22 +0000 (11:04 +0200)]
Add keepalive support into domain-events examples

13 years agoImplement virConnectIsAlive in all drivers
Jiri Denemark [Fri, 23 Sep 2011 06:56:13 +0000 (08:56 +0200)]
Implement virConnectIsAlive in all drivers

13 years agoIntroduce virConnectIsAlive API
Jiri Denemark [Fri, 23 Sep 2011 06:47:59 +0000 (08:47 +0200)]
Introduce virConnectIsAlive API

This API can be used to check if the socket associated with
virConnectPtr is still open or it was closed (probably because keepalive
protocol timed out). If there the connection is local (i.e., no socket
is associated with the connection, it is trivially always alive.

13 years agoImplement keepalive protocol in remote driver
Jiri Denemark [Thu, 22 Sep 2011 12:59:06 +0000 (14:59 +0200)]
Implement keepalive protocol in remote driver

13 years agoAdd support for async close of client RPC socket
Jiri Denemark [Thu, 22 Sep 2011 13:47:29 +0000 (15:47 +0200)]
Add support for async close of client RPC socket

13 years agoImplement keepalive protocol in libvirt daemon
Jiri Denemark [Wed, 24 Aug 2011 13:33:34 +0000 (15:33 +0200)]
Implement keepalive protocol in libvirt daemon

13 years agovirsh: Always run event loop
Jiri Denemark [Tue, 11 Oct 2011 13:05:52 +0000 (15:05 +0200)]
virsh: Always run event loop

Since virsh already implements event loop, it has to also run it. So far
the event loop was only running during virsh console command.

13 years agoIntroduce virConnectSetKeepAlive
Jiri Denemark [Thu, 22 Sep 2011 11:47:07 +0000 (13:47 +0200)]
Introduce virConnectSetKeepAlive

virConnectSetKeepAlive public API can be used by a client connecting to
remote server to start using keepalive protocol. The API is handled
directly by remote driver and not transmitted over the wire to the
server.

13 years agoImplement common keepalive handling
Jiri Denemark [Thu, 22 Sep 2011 11:40:00 +0000 (13:40 +0200)]
Implement common keepalive handling

These APIs are used by both client and server RPC layer to handle
processing of keepalive messages.

13 years agoDefine keepalive protocol
Jiri Denemark [Thu, 22 Sep 2011 10:51:55 +0000 (12:51 +0200)]
Define keepalive protocol

The keepalive program has two procedures: PING, and PONG.
Both are used only in asynchronous messages and the sender doesn't wait
for any reply. However, the party which receives PING messages is
supposed to react by sending PONG message the other party, but no
explicit binding between PING and PONG messages is made. For backward
compatibility neither server nor client are allowed to send keepalive
messages before checking that remote party supports them.

13 years agorpc: Add some debug messages to virNetClient
Jiri Denemark [Tue, 22 Nov 2011 14:14:43 +0000 (15:14 +0100)]
rpc: Add some debug messages to virNetClient

13 years agorpc: Fix handling of non-blocking calls that could not be sent
Jiri Denemark [Tue, 22 Nov 2011 13:11:02 +0000 (14:11 +0100)]
rpc: Fix handling of non-blocking calls that could not be sent

When virNetClientIOEventLoop is called for a non-blocking call and not
even a single byte can be sent from this call without blocking, we
properly reported that to the caller which properly frees the call. But
we never removed the call from a call queue.

13 years agorpc: Fix a typo in virNetClientSendNonBlock documentation
Jiri Denemark [Tue, 22 Nov 2011 14:12:05 +0000 (15:12 +0100)]
rpc: Fix a typo in virNetClientSendNonBlock documentation

13 years agorpc: Pass the buck only to the first available thread
Jiri Denemark [Tue, 22 Nov 2011 14:10:06 +0000 (15:10 +0100)]
rpc: Pass the buck only to the first available thread

13 years agonwfilter: remove virConnectPtr from internal API calls
Stefan Berger [Wed, 23 Nov 2011 19:13:03 +0000 (14:13 -0500)]
nwfilter: remove virConnectPtr from internal API calls

Remove the virConnectPtr from the nwfilter's internal API calls as
far as possible.

13 years agoqemu: Avoid dereference of NULL pointer
Peter Krempa [Wed, 23 Nov 2011 14:51:28 +0000 (15:51 +0100)]
qemu: Avoid dereference of NULL pointer

If something fails while initializing qemu job object in
qemuDomainObjPrivateAlloc(), memory to the private pointer is freed, but
after that, the pointer is still dereferenced, which may result in a
segfault.

* qemuDomainObjPrivateAlloc() - Don't dereference NULL pointer.

13 years agoqemu: fix a const-correctness issue
Eric Blake [Wed, 23 Nov 2011 14:26:32 +0000 (07:26 -0700)]
qemu: fix a const-correctness issue

Generally, functions which return malloc'd strings should be typed
as 'char *', not 'const char *', to make it obvious that the caller
is responsible to free things.  free(const char *) fails to compile,
and although we have a cast embedded in VIR_FREE to work around poor
code that frees const char *, it's better to not rely on that hack.

* src/qemu/qemu_driver.c (qemuDiskPathToAlias): Change return type.
(qemuDomainBlockJobImpl): Update caller.

13 years agoAPI: prefer 'disk' over 'block' or 'path'
Eric Blake [Wed, 23 Nov 2011 00:15:43 +0000 (17:15 -0700)]
API: prefer 'disk' over 'block' or 'path'

Given that we can now handle the target's disk shorthand, in addition
to an absolute path to the file or block device used on the host,
the term 'disk' fits a bit better as the parameter name than 'path'.

* include/libvirt/libvirt.h.in: Update some parameter names.
* src/libvirt.c (virDomainBlockStats, virDomainBlockStatsFlags)
(virDomainBlockPeek, virDomainGetBlockInfo, virDomainBlockJobAbort)
(virDomainGetBlockJobInfo, virDomainBlockJobSetSpeed)
(virDomainBlockPull): Likewise.

13 years agoblockstats: support lookup by path in blockstats
Eric Blake [Tue, 22 Nov 2011 22:55:30 +0000 (15:55 -0700)]
blockstats: support lookup by path in blockstats

Commit 89b6284f made it possible to pass either a source name or
the target device to most API demanding a disk designation, but
forgot to update the documentation.  It also failed to update
virDomainBlockStats to take both forms. This patch fixes both the
documentation and the remaining function.

Xen continues to use just device shorthand (that is, I did not
implement path lookup there, since xen does not track a domain_conf
to quickly tie a path back to the device shorthand).

* src/libvirt.c (virDomainBlockStats, virDomainBlockStatsFlags)
(virDomainGetBlockInfo, virDomainBlockPeek)
(virDomainBlockJobAbort, virDomainGetBlockJobInfo)
(virDomainBlockJobSetSpeed, virDomainBlockPull): Document
acceptable disk naming conventions.
* src/qemu/qemu_driver.c (qemuDomainBlockStats)
(qemuDomainBlockStatsFlags): Allow lookup by source name.
* src/test/test_driver.c (testDomainBlockStats): Likewise.

13 years agonwfilter: Initialize virNWFilterAddIpAddrForIfname return variable
Michal Privoznik [Wed, 23 Nov 2011 12:43:17 +0000 (07:43 -0500)]
nwfilter: Initialize virNWFilterAddIpAddrForIfname return variable

Latest nwfilter patch ad6c67cf introduced uninitialized return
value. This was spotted by 4.6.2 gcc.

13 years agoFix disabling of virtual port profile code on old hosts
Daniel P. Berrange [Wed, 23 Nov 2011 12:29:37 +0000 (12:29 +0000)]
Fix disabling of virtual port profile code on old hosts

The WITH_VIRTUALPORT macro is defined to 0 when disabled, not
left undefined. So #if must be used instead of #ifdef

* src/util/virnetdevvportprofile.c: s/#ifdef/#if/

13 years agoFix uninitialized variable in NWfilter IP learning code
Daniel P. Berrange [Wed, 23 Nov 2011 12:16:01 +0000 (12:16 +0000)]
Fix uninitialized variable in NWfilter IP learning code

* src/nwfilter/nwfilter_learnipaddr.c: Initialize ret variable

13 years agovirsh: Increase device-detach intelligence
Michal Prívozník [Mon, 6 Jun 2011 10:20:11 +0000 (12:20 +0200)]
virsh: Increase device-detach intelligence

Up to now users have to give a full XML description on input when
device-detaching. If they omitted something it lead to unclear
error messages (like generated MAC wasn't found, etc.).
With this patch users can specify only those information which
specify one device sufficiently precise. Remaining information is
completed from domain.

13 years agoEnable detection of multiple IP addresses
Stefan Berger [Wed, 23 Nov 2011 00:05:45 +0000 (19:05 -0500)]
Enable detection of multiple IP addresses

In preparation of DHCP Snooping and the detection of multiple IP
addresses per interface:

The hash table that is used to collect the detected IP address of an
interface can so far only handle one IP address per interface. With
this patch we extend this to allow it to handle a list of IP addresses.

Above changes the returned variable type of virNWFilterGetIpAddrForIfname()
from char * to virNWFilterVarValuePtr; adapt all existing functions calling
this function.

13 years agofix error message when using wrong URI alias
Eli Qiao [Tue, 22 Nov 2011 22:08:14 +0000 (15:08 -0700)]
fix error message when using wrong URI alias

Signed-off-by: Eli Qiao <taget@linux.vnet.ibm.com>
When configuring a URI alias like this in 'libvirt.conf':

uri_aliases = [
  "jj#j=qemu+ssh://root@127.0.0.1/system",
  "sleet=qemu+ssh://root@sleet.cloud.example.com/system",
]
virsh -c jj#j

It will show this error message:
'no connection driver available for No connection for URI jj#j'
Actually,we expect this message below:
Malformed 'uri_aliases' config entry 'jj#j=qemu+ssh://root@127.0.0.1/system', aliases may only contain 'a-Z, 0-9, _, -'

Give this patch to fix this error.

13 years agoPass additional parameter into applyDHCPOnly function
Stefan Berger [Tue, 22 Nov 2011 20:59:26 +0000 (15:59 -0500)]
Pass additional parameter into applyDHCPOnly function

In preparation for the DHCP Snooping code:
Pass an additional parameter into the applyDHCPOnly function
of the 'techdriver'.

13 years agonwfilter: use shell variable to invoke 'ip(6)tables' command
Stefan Berger [Tue, 22 Nov 2011 20:12:04 +0000 (15:12 -0500)]
nwfilter: use shell variable to invoke 'ip(6)tables' command

Introduce a shell variable 'IBT' to invoke the ip(6)tables command.

Tested with libvirt-tck.

13 years agonwfilter: use shell variable to invoke 'ebtables' command
Stefan Berger [Tue, 22 Nov 2011 20:12:04 +0000 (15:12 -0500)]
nwfilter: use shell variable to invoke 'ebtables' command

Introduce a shell variable 'EBT' to invoke the ebtables command.
Hard-code the used ebtables table to '-t nat'.

Tested with libvirt-tck.

13 years agoImprove error reporting of failures to apply filtering rules
Stefan Berger [Tue, 22 Nov 2011 20:12:04 +0000 (15:12 -0500)]
Improve error reporting of failures to apply filtering rules

Display the executed command and failure message if a command failed to
execute.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
13 years agoAdd documentation for STP filtering support
Stefan Berger [Tue, 22 Nov 2011 20:12:03 +0000 (15:12 -0500)]
Add documentation for STP filtering support

Add documentation for the STP filtering support. Describe the XML attributes
that are supported.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
13 years agoAdd test cases for STP traffic filtering
Stefan Berger [Tue, 22 Nov 2011 20:12:03 +0000 (15:12 -0500)]
Add test cases for STP traffic filtering

This patch adds a few test cases for the XML parsing of STP filtering nodes.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
13 years agoAdd support for STP filtering
Stefan Berger [Tue, 22 Nov 2011 20:12:03 +0000 (15:12 -0500)]
Add support for STP filtering

This patch adds support for filtering of STP (spanning tree protocol) traffic
to the parser and makes us of the ebtables support for STP filtering. This code
now enables the filtering of traffic in chains with prefix 'stp'.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
13 years agoAdd a 'mac' chain
Stefan Berger [Tue, 22 Nov 2011 20:12:03 +0000 (15:12 -0500)]
Add a 'mac' chain

With hunks borrowed from one of David Steven's previous patches, we now
add the capability of having a 'mac' chain which is useful to filter
for multiple valid MAC addresses.

Signed-off-by: David L Stevens <dlstevens@us.ibm.com>
Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
13 years agodocs: fix grammar of capabilities
Eric Blake [Tue, 22 Nov 2011 17:30:07 +0000 (10:30 -0700)]
docs: fix grammar of capabilities

* docs/formatcaps.html.in: Avoid run-on sentence, wrap lines.

13 years agoAdd strings.h include to capabilities.h for ffs() function prototype
Daniel P. Berrange [Tue, 22 Nov 2011 09:45:47 +0000 (09:45 +0000)]
Add strings.h include to capabilities.h for ffs() function prototype

On Mingw32 the ffs() function was not declared due to missing header
include

* src/conf/capabilities.c: The ffs() function lives in strings.h

13 years agobuild: Update AUTHORS
Osier Yang [Tue, 22 Nov 2011 07:34:40 +0000 (15:34 +0800)]
build: Update AUTHORS

Add Chang Liu to the AUTHORS' list.

13 years agostorage: Fallback to use lvchange first if lvremove fails
Chang Liu [Tue, 22 Nov 2011 07:24:25 +0000 (15:24 +0800)]
storage: Fallback to use lvchange first if lvremove fails

virStorageBackendLogicalDeleteVol() could not remove the lv with error
"could not remove open logical volume" sometimes. Generally it's caused
by the volume is still active, even if lvremove tries to remove it with
option "--force".

This patch is to fix it by disbale the lv first using "lvchange -aln"
and "lvremove -f" afterwards if the direct "lvremove -f" failed.

13 years agoExport KVM Host Power Management capabilities
Srivatsa S. Bhat [Tue, 22 Nov 2011 03:31:22 +0000 (11:31 +0800)]
Export KVM Host Power Management capabilities

This patch exports KVM Host Power Management capabilities as XML so that
higher-level systems management software can make use of these features
available in the host.

The script "pm-is-supported" (from pm-utils package) is run to discover if
Suspend-to-RAM (S3) or Suspend-to-Disk (S4) is supported by the host.
If either of them are supported, then a new tag "<power_management>" is
introduced in the XML under the <host> tag.

However in case the query to check for power management features succeeded,
but the host does not support any such feature, then the XML will contain
an empty <power_management/> tag. In the event that the PM query itself
failed, the XML will not contain any "power_management" tag.

To use this, new APIs could be implemented in libvirt to exploit power
management features such as S3/S4.

13 years agoconf: don't modify cpu set string during parsing
Eric Blake [Fri, 18 Nov 2011 18:27:24 +0000 (11:27 -0700)]
conf: don't modify cpu set string during parsing

None of the callers cared if str was updated to point to the next
byte after the parsed cpuset; simplifying this results in quite
a few code simplifications.  Additionally, virCPUDefParseXML was
strdup()'ing a malloc()'d string; avoiding a memory copy resulted
in less code.

* src/conf/domain_conf.h (virDomainCpuSetParse): Alter signature.
* src/conf/domain_conf.c (virDomainCpuSetParse): Don't modify str.
(virDomainVcpuPinDefParseXML, virDomainDefParseXML): Adjust
callers.
* src/conf/cpu_conf.c (virCPUDefParseXML): Likewise.
* src/xen/xend_internal.c (sexpr_to_xend_topology): Likewise.
* src/xen/xm_internal.c (xenXMDomainPinVcpu): Likewise.
* src/xenxs/xen_sxpr.c (xenParseSxpr): Likewise.
* src/xenxs/xen_xm.c (xenParseXM): Likewise.

13 years agoqemu: don't release network actual device twice
Roopa Prabhu [Thu, 17 Nov 2011 02:34:32 +0000 (18:34 -0800)]
qemu: don't release network actual device twice

For direct attach devices, in qemuBuildCommandLine, we seem to be freeing
actual device on error path (with networkReleaseActualDevice). But the actual
device is not deleted.

qemuProcessStop eventually deletes the direct attach device and releases
actual device. But by the time qemuProcessStop is called qemuBuildCommandLine
has already freed actual device, leaving stray macvtap devices behind on error.
So the simplest fix is to remove the networkReleaseActualDevice in
qemuBuildCommandLine. This patch does just that.

Signed-off-by: Roopa Prabhu <roprabhu@cisco.com>
13 years agoqemu: Copy console definition from serial
Michal Privoznik [Tue, 15 Nov 2011 08:01:31 +0000 (09:01 +0100)]
qemu: Copy console definition from serial

Now, when we support multiple consoles per domain,
the vm->def->console[0] can still remain an alias
for vm->def->serial[0]; However, we need to copy
it's source definition as well otherwise we'll regress
on virDomainOpenConsole.

13 years agoFix distribution of .syms files for previous commit
Daniel P. Berrange [Mon, 21 Nov 2011 13:17:26 +0000 (13:17 +0000)]
Fix distribution of .syms files for previous commit

* src/Makefile.am: Remove libvirt_bridge.syms and libvirt_macvtap.syms
  from EXTRA_DIST. Add libvirt_dbus.syms

13 years agoFix build on Mingw32 wrt export of virNetServerGetDBusConn
Daniel P. Berrange [Mon, 21 Nov 2011 11:45:42 +0000 (11:45 +0000)]
Fix build on Mingw32 wrt export of virNetServerGetDBusConn

Mingw32 complains if you request export of a symbol which does
not in fact exist.

* src/libvirt_bridge.syms, src/libvirt_macvtap.syms: Delete
  obsolete files
* src/libvirt_private.syms: Remove virNetServerGetDBusConn
* src/libvirt_dbus.syms: Add virNetServerGetDBusConn

13 years agostorage: Skips backingStore of virtual snapshot lv
Osier Yang [Fri, 18 Nov 2011 11:15:10 +0000 (19:15 +0800)]
storage: Skips backingStore of virtual snapshot lv

lvs outputs "[$lvname_vorigin]" for the virtual snapshot lv
(created with "--virtualsize"), and the original device pointed
by "$lvname_vorigin" is just for lvm internal use, one should
never use it.

Per lvm's nameing rules, "[" is not valid as part of the vg/lv name.
(man 8 lvm).

<quote>
VALID NAMES
The following characters are valid for VG and LV names: a-z A-Z 0-9 + _
. -

VG and LV names cannot begin with a hyphen.   There  are  also  various
reserved  names that are used internally by lvm that can not be used as
LV or VG names.  A VG cannot be called anything that exists in /dev/ at
the time of creation, nor can it be called '.' or '..'.  A LV cannot be
called '.' '..' 'snapshot' or 'pvmove'. The LV name may also  not  con‐
tain the strings '_mlog' or '_mimage'
</quote>

So we can skip the set the lv's backingStore by checking if the name
begins with a "[".

13 years agoAdd documentation for VLAN filtering support
Stefan Berger [Sat, 19 Nov 2011 12:26:56 +0000 (07:26 -0500)]
Add documentation for VLAN filtering support

Add documentation for the VLAN filtering support. Describe the XML attributes
that are supported.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
13 years agoAdd test cases for VLAN traffic filtering
Stefan Berger [Sat, 19 Nov 2011 12:26:56 +0000 (07:26 -0500)]
Add test cases for VLAN traffic filtering

This patch adds a few test cases for the XML parsing of VLAN filtering nodes.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
13 years agoAdd support for VLAN filtering
Stefan Berger [Sat, 19 Nov 2011 12:26:56 +0000 (07:26 -0500)]
Add support for VLAN filtering

This patch adds support for filtering of VLAN (802.1Q) traffic to the
parser and makes us of the ebtables support for VLAN filtering. This code
now enables the filtering of traffic in chains with prefix 'vlan'.

Signed-off-by: Stefan Berger <stefanb@linux.vnet.ibm.com>
13 years agoDon't copy sexpr node value that is an empty string
Jim Fehlig [Fri, 18 Nov 2011 21:54:38 +0000 (14:54 -0700)]
Don't copy sexpr node value that is an empty string

Xen4.1 initializes some unspecified sexpr config items to an empty
string, unlike previous Xen versions that would leave the item unset.
E.g. the kernel item for an HVM guest (non-direct kernel boot):

Xen4.0 and earlier
  ...
  (image
    (hvm
      (kernel )
  ...

Xen4.1
  ...
  (image
    (hvm
      (kernel '')
  ...

The empty string for kernel causes some grief in subsequent parsing
where existence of specified kernel is checked, e.g.

  if (!def->os.kernel)
  ...

This patch solves the problem in sexpr_node_copy() by not copying
a node containing an empty string.

13 years agotests: avoid xend ABRT crash report
Eric Blake [Fri, 18 Nov 2011 21:21:54 +0000 (14:21 -0700)]
tests: avoid xend ABRT crash report

I installed the xen development packages on my non-Xen F16 machine
in order to compile-test xen code and ensure we don't break things
on that front, but being a non-xen machine, /usr/sbin/xend is
obviously not running.  Unfortunately, xen-4.1.2-1.fc16 has a bug
where merely trying to probe xend status on a non-xen kernel causes
xend to issue an ABRT crash report:

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

Even though libvirt (correctly) skips the test, the xend crash report
is unnecessary noise.  Fix this by first filtering out non-xen
kernels even before attempting to probe xend.  The test still runs
and passes on a RHEL 5 xen kernel after this patch.

* tests/reconnect.c (mymain): Skip xend probe on non-xen kernel.
* tests/statstest.c (mymain): Likewise.

13 years agobuild: fix compile error with no macvtap
Eric Blake [Fri, 18 Nov 2011 21:40:32 +0000 (14:40 -0700)]
build: fix compile error with no macvtap

Since commit 6ec8288a, compilation has failed on RHEL 5:

util/virnetdevmacvlan.c:672: error: conflicting types for 'virNetDevMacVLanCreateWithVPortProfile'

* src/util/virnetdevmacvlan.c
(virNetDevMacVLanCreateWithVPortProfile): Add missing parameter.

13 years agoenable cgroup cpuset by default
Hu Tao [Thu, 17 Nov 2011 09:44:12 +0000 (17:44 +0800)]
enable cgroup cpuset by default

This prepares for subsequent patches which introduce dependence
on cgroup cpuset. Enable cgroup cpuset by default so users don't
have to modify configuration file before encountering a cpuset
error.

13 years agobuild: fix accidental POTFILES.in regression
Eric Blake [Fri, 18 Nov 2011 17:36:35 +0000 (10:36 -0700)]
build: fix accidental POTFILES.in regression

The original patch for commit 4789fb2 considered renaming a file,
then backed out the name change, but forgot to back out the POTFILES.in
change, resulting in 'make syntax-check' failure.