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

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/