Commit Graph

8911 Commits

Author SHA1 Message Date
Lei Li
6df7ccb10e 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>
2011-11-30 11:36:09 -07:00
Lei Li
115a2a3fbb 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>
2011-11-30 11:36:09 -07:00
Daniel P. Berrange
87e8ff1be1 Fix leak build config file path
* src/libvirt.c: Free user directory path
2011-11-30 11:43:50 +00:00
Daniel P. Berrange
a8bb75a3e6 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
2011-11-30 11:43:50 +00:00
Daniel P. Berrange
32d3ec7466 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
2011-11-30 11:43:50 +00:00
Daniel P. Berrange
3ec1289896 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
2011-11-30 11:43:49 +00:00
Daniel P. Berrange
380110cf08 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
2011-11-30 11:42:57 +00:00
Daniel P. Berrange
a82ed6a0c3 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
2011-11-30 10:12:30 +00:00
Daniel P. Berrange
9ae0b8349c 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
2011-11-30 10:12:30 +00:00
Daniel P. Berrange
8c60bc169f 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
2011-11-30 10:12:30 +00:00
Daniel P. Berrange
2fc056c1ba 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
2011-11-30 10:12:30 +00:00
Daniel P. Berrange
f1f28611f1 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
2011-11-30 10:12:30 +00:00
Daniel P. Berrange
f5272027c3 Add export of node suspend capabilities APIs
* src/libvirt_private.syms: Export virNodeSuspendSupportsTarget
  and virNodeSuspendGetTargetMask
2011-11-30 10:12:29 +00:00
Daniel P. Berrange
c92653f4dd 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
2011-11-30 10:12:29 +00:00
Daniel P. Berrange
53c2aad88b 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
2011-11-30 10:12:29 +00:00
Daniel P. Berrange
33386276a9 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
2011-11-30 10:12:29 +00:00
Daniel P. Berrange
6ea25cd975 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
2011-11-30 10:12:29 +00:00
Daniel P. Berrange
ae5e55289d 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
2011-11-30 10:12:29 +00:00
Daniel P. Berrange
6fb5400fc6 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
2011-11-30 10:12:29 +00:00
Daniel P. Berrange
866b0a7069 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
2011-11-30 10:12:29 +00:00
Alex Jia
a001a5e28b 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>
2011-11-30 11:05:13 +01:00
Alex Jia
d082e1b966 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>
2011-11-30 11:04:13 +01:00
Lei Li
1f8a339dee 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>
2011-11-29 17:29:33 -07:00
Hu Tao
93ab58595d blkiotune: add qemu support for blkiotune.device_weight
Implement setting/getting per-device blkio weights in qemu,
using the cgroups blkio.weight_device tunable.
2011-11-29 12:26:21 -07:00
Hu Tao
6ac81c8ec8 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>
2011-11-29 12:26:21 -07:00
Eric Blake
659ded58ed 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.
2011-11-29 10:54:29 -07:00
Eric Blake
51727c1dc0 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.
2011-11-29 10:54:29 -07:00
Eric Blake
4199f3de2e 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.
2011-11-29 10:53:26 -07:00
Eric Blake
80eaa56561 build: fix typo in last patch
* src/remote_protocol-structs: Use correct RPC name.
2011-11-29 09:48:43 -07:00
Osier Yang
2524c8434b block_resize: Update test file for RPC
Pushed under build failure rule.
2011-11-29 23:18:30 +08:00
Osier Yang
72908c7403 block_resize: Expose the new API to virsh 2011-11-29 21:45:22 +08:00
Osier Yang
d1a6c77aca 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.
2011-11-29 21:45:18 +08:00
Osier Yang
4fa36f1392 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.
2011-11-29 21:45:11 +08:00
Osier Yang
7c80d07414 block_resize: Wire up the remote protocol 2011-11-29 21:44:36 +08:00
Osier Yang
caef87d557 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.
2011-11-29 21:40:43 +08:00
Michal Privoznik
dee901c1ff bandwidth: Fix funky identation 2011-11-29 14:26:14 +01:00
Jiri Denemark
6b84ee3370 virsh: Fix typos in man page 2011-11-29 14:16:42 +01:00
Jiri Denemark
54bf875aa6 lxc: Fix suspend/resume with freezer cgroup 2011-11-29 14:16:42 +01:00
Osier Yang
4b7de948f9 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.
2011-11-29 18:43:20 +08:00
Srivatsa S. Bhat
34401a8b42 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>
2011-11-29 17:29:17 +08:00
Srivatsa S. Bhat
4ddb37c395 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.
2011-11-29 17:29:17 +08:00
Srivatsa S. Bhat
76da40a820 Add the remote protocol implementation for virNodeSuspendForDuration
Implement the remote protocol for virNodeSuspendForDuration() API.
2011-11-29 17:29:17 +08:00
Srivatsa S. Bhat
979676e3db 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.
2011-11-29 17:29:16 +08:00
Srivatsa S. Bhat
302743f177 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.
2011-11-29 17:29:16 +08:00
Jiri Denemark
4e511fcc18 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.
2011-11-29 08:43:00 +01:00
Michal Privoznik
2d0fc93fdd 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.
2011-11-28 18:17:14 +01:00
Christian Franke
d360795d60 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>
2011-11-28 09:30:49 -07:00
Lorin Hochstein
8078a90a24 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>
2011-11-28 09:16:07 -07:00
Michal Privoznik
a6916977bb 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.
2011-11-28 15:12:37 +01:00
Daniel P. Berrange
508aef9b0e 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
2011-11-28 12:06:51 +00:00