]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
13 years agovirNodeGetCPUStats: Implement linux support
Minoru Usui [Tue, 7 Jun 2011 01:02:55 +0000 (10:02 +0900)]
virNodeGetCPUStats: Implement linux support

Signed-off-by: Minoru Usui <usui@mxm.nes.nec.co.jp>
13 years agovirNodeGetCPUStats: Implement virsh support
Minoru Usui [Tue, 7 Jun 2011 01:02:13 +0000 (10:02 +0900)]
virNodeGetCPUStats: Implement virsh support

Signed-off-by: Minoru Usui <usui@mxm.nes.nec.co.jp>
13 years agovirNodeGetCPUStats: Implement remote protocol
Minoru Usui [Tue, 7 Jun 2011 01:01:12 +0000 (10:01 +0900)]
virNodeGetCPUStats: Implement remote protocol

Signed-off-by: Minoru Usui <usui@mxm.nes.nec.co.jp>
13 years agovirNodeGetCPUTime: Implement public API
Minoru Usui [Tue, 7 Jun 2011 01:00:23 +0000 (10:00 +0900)]
virNodeGetCPUTime: Implement public API

Signed-off-by: Minoru Usui <usui@mxm.nes.nec.co.jp>
13 years agovirNodeGetCPUStats: Define internal driver API
Minoru Usui [Tue, 7 Jun 2011 00:59:44 +0000 (09:59 +0900)]
virNodeGetCPUStats: Define internal driver API

Signed-off-by: Minoru Usui <usui@mxm.nes.nec.co.jp>
13 years agovirNodeGetCPUStats: Expose new API
Minoru Usui [Tue, 7 Jun 2011 00:58:47 +0000 (09:58 +0900)]
virNodeGetCPUStats: Expose new API

Signed-off-by: Minoru Usui <usui@mxm.nes.nec.co.jp>
13 years agoSkip nodeinfo test on non intel architectures
Guido Günther [Sun, 12 Jun 2011 19:57:01 +0000 (21:57 +0200)]
Skip nodeinfo test on non intel architectures

since the testfiles assume a /proc/cpuinfo specific to this
architecture. We e.g. can't parse the number of cores on other
architectures.

13 years agoFix autostart flag when loading running domains
Michael Chapman [Mon, 13 Jun 2011 03:05:45 +0000 (13:05 +1000)]
Fix autostart flag when loading running domains

Drivers load running persistent and transient domain configs before
inactive persistent domain configs, however only the latter would set a
domain's autostart flag. This mismatch between the loaded and on-disk
state could later cause problems with "virsh autostart":

  # virsh autostart example
  error: Failed to mark domain example as autostarted
  error: Failed to create symlink '/etc/libvirt/qemu/autostart/example.xml to '/etc/libvirt/qemu/example.xml': File exists

This patch ensures the autostart flag is set correctly even when the
domain is already defined.

Fixes:

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

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
13 years agosend-key: Implementing the remote protocol
Lai Jiangshan [Tue, 7 Jun 2011 09:11:15 +0000 (17:11 +0800)]
send-key: Implementing the remote protocol

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
13 years agosend-key: Implementing the public API
Lai Jiangshan [Tue, 7 Jun 2011 09:11:14 +0000 (17:11 +0800)]
send-key: Implementing the public API

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
13 years agosend-key: Defining the internal API
Lai Jiangshan [Tue, 7 Jun 2011 09:11:13 +0000 (17:11 +0800)]
send-key: Defining the internal API

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
13 years agosend-key: Defining the public API
Lai Jiangshan [Tue, 7 Jun 2011 09:11:12 +0000 (17:11 +0800)]
send-key: Defining the public API

Add public virDomainSendKey() and enum libvirt_keycode_set
for the @codeset.

Python version of virDomainSendKey() has not been implemented yet,
it will be done soon.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
13 years agoremote generator: Handle (unsigned) int arrays
Lai Jiangshan [Tue, 7 Jun 2011 09:11:11 +0000 (17:11 +0800)]
remote generator: Handle (unsigned) int arrays

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
13 years agoadd VSH_OFLAG_REQ_OPT options
Lai Jiangshan [Tue, 7 Jun 2011 09:11:10 +0000 (17:11 +0800)]
add VSH_OFLAG_REQ_OPT options

A VSH_OFLAG_REQ_OPT option means --optionname is required when used.
It will kill any ambiguity, even a !VSH_OFLAG_REQ option listed before
a VSH_OFLAG_REQ option, if the !VSH_OFLAG_REQ option is a
VSH_OFLAG_REQ_OPT option.

It will help us use optional argument with VSH_OT_ARGV argument.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
13 years agoallow name for VSH_OT_ARGV options
Lai Jiangshan [Tue, 7 Jun 2011 09:11:08 +0000 (17:11 +0800)]
allow name for VSH_OT_ARGV options

A name will improve the usege, example

# virsh help echo
  NAME
    echo - echo arguments

  SYNOPSIS
    echo [--shell] [--xml] [<string>]...

  DESCRIPTION
    Echo back arguments, possibly with quoting.

  OPTIONS
    --shell          escape for shell use
    --xml            escape for XML use
    <string>         arguments to echo

"[<string>]..." is added to SYNOPSIS.
"<string>         arguments to echo" is added to OPTIONS.

Signed-off-by: Lai Jiangshan <laijs@cn.fujitsu.com>
13 years agodocs: updated list of applications using libvirt.
Ohad Levy [Tue, 14 Jun 2011 16:17:09 +0000 (19:17 +0300)]
docs: updated list of applications using libvirt.

Added:
* Virt ruby bindings
* Foreman for provisioning and webui.

13 years agostorage: avoid an intermediate malloc
Eric Blake [Mon, 13 Jun 2011 22:17:46 +0000 (16:17 -0600)]
storage: avoid an intermediate malloc

Suggested here:
https://www.redhat.com/archives/libvir-list/2011-May/msg00594.html

* src/storage/storage_backend.c (virStorageBackendCreateQemuImg):
Generate size inline.

13 years agocommand: avoid double close
Eric Blake [Mon, 13 Jun 2011 21:47:45 +0000 (15:47 -0600)]
command: avoid double close

Previously, the parent process opened 'null' to /dev/null, then
the child process closes 'null' as well as 'childout'.  But if
childout was set to be null, then this is a double close.  At
least the double close was confined to the child process after a
fork, and therefore there is no risk of another thread opening
an fd of the same value to be bitten by the double close, but it
is always better to avoid double-close to begin with.

Additionally, if all three fds were specified, then opening
'null' was wasted.

This patch fixes things to lazily open null on the first use,
then guarantees it gets closed exactly once.

* src/util/command.c (getDevNull): New helper function.
(virExecWithHook): Use it to avoid spurious opens and double close.

13 years agocommand: reduce duplicated debug messages
Eric Blake [Mon, 13 Jun 2011 21:20:03 +0000 (15:20 -0600)]
command: reduce duplicated debug messages

This also reduces malloc pressure for invoking a child when
VIR_DEBUG is enabled.

* src/util/command.c (virExecWithHook): Drop debug, since the only
caller (virCommandRunAsync) also prints debug info.

13 years agodocs: improve VIR_DOMAIN_AFFECT_CURRENT description
Eric Blake [Fri, 3 Jun 2011 16:06:33 +0000 (10:06 -0600)]
docs: improve VIR_DOMAIN_AFFECT_CURRENT description

* include/libvirt/libvirt.h.in (virDomainModificationImpact): Reword.

13 years agoqemu: Fix parsing 'info chardev'
Cole Robinson [Wed, 8 Jun 2011 16:25:11 +0000 (12:25 -0400)]
qemu: Fix parsing 'info chardev'

If qemu supports -chardev, our char frontend aliases are ex. 'charserial0'
not just 'serial0'. Typically we don't use this code path because the
pty's are scraped from stdout.

13 years agoqemu: Scrape stdout for virtio console pty
Cole Robinson [Wed, 8 Jun 2011 16:27:18 +0000 (12:27 -0400)]
qemu: Scrape stdout for virtio console pty

Currently we forget to do this and have to fallback to info chardev (which
also fails, see following patch)

13 years agovirsh: Add daemon version reporting
Michal Privoznik [Thu, 2 Jun 2011 13:59:02 +0000 (15:59 +0200)]
virsh: Add daemon version reporting

'virsh version' might report against which version of libvirtd is
running.

13 years agonodeinfo: remove superflous braces
Guido Günther [Sat, 11 Jun 2011 16:10:40 +0000 (18:10 +0200)]
nodeinfo: remove superflous braces

that break compilation on non intel architectures:

mips:
https://buildd.debian.org/status/fetch.php?pkg=libvirt&arch=mips&ver=0.9.2-1&stamp=1307570195
powerpc:
https://buildd.debian.org/status/fetch.php?pkg=libvirt&arch=powerpc&ver=0.9.2-1&stamp=1307550913
s390:
https://buildd.debian.org/status/fetch.php?pkg=libvirt&arch=s390&ver=0.9.2-1&stamp=1307641748
sparc:
https://buildd.debian.org/status/fetch.php?pkg=libvirt&arch=sparc&ver=0.9.2-1&stamp=1307552926

13 years agoutil: Cleanup indention problem in virterror.c
Osier Yang [Tue, 14 Jun 2011 07:03:12 +0000 (15:03 +0800)]
util: Cleanup indention problem in virterror.c

Push under trivial rule.

13 years agoqemu: Parse current balloon value returned by query_balloon
Osier Yang [Tue, 14 Jun 2011 03:21:35 +0000 (11:21 +0800)]
qemu: Parse current balloon value returned by query_balloon

Qemu once supported following memory stats which will returned by
"query_balloon":

    stat_put(dict, "actual", actual);
    stat_put(dict, "mem_swapped_in", dev->stats[VIRTIO_BALLOON_S_SWAP_IN]);
    stat_put(dict, "mem_swapped_out", dev->stats[VIRTIO_BALLOON_S_SWAP_OUT]);
    stat_put(dict, "major_page_faults", dev->stats[VIRTIO_BALLOON_S_MAJFLT]);
    stat_put(dict, "minor_page_faults", dev->stats[VIRTIO_BALLOON_S_MINFLT]);
    stat_put(dict, "free_mem", dev->stats[VIRTIO_BALLOON_S_MEMFREE]);
    stat_put(dict, "total_mem", dev->stats[VIRTIO_BALLOON_S_MEMTOT]);

But it later disabled all the stats except "actual" by commit
07b0403dfc2b2ac179ae5b48105096cc2d03375a.

libvirt doesn't parse "actual", so user will always see a empty result
with "virsh dommemstat $domain". Even qemu haven't disabled the stats,
we should support parsing "actual".

13 years agovcpupin: Fix cpu affinity setting bug of qemu driver
Taku Izumi [Tue, 14 Jun 2011 03:13:11 +0000 (11:13 +0800)]
vcpupin: Fix cpu affinity setting bug of qemu driver

There is the case where cpu affinites for vcpu of qemu doesn't work
correctly. For example, if only one vcpupin setting entry is provided
and its setting is not for vcpu0, it doesn't work.

   # virsh dumpxml VM
   ...
   <vcpu>4</vcpu>
   <cputune>
     <vcpupin vcpu='3' cpuset='9-11'/>
   </cputune>
   ...

   # virsh start VM
   Domain VM started

   # virsh vcpuinfo VM
   VCPU:           0
   CPU:            31
   State:          running
   CPU time:       2.5s
   CPU Affinity:   yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy

   VCPU:           1
   CPU:            12
   State:          running
   CPU time:       0.9s
   CPU Affinity:   yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy

   VCPU:           2
   CPU:            30
   State:          running
   CPU time:       1.5s
   CPU Affinity:   yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy

   VCPU:           3
   CPU:            13
   State:          running
   CPU time:       1.7s
   CPU Affinity:   yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy

This patch fixes this problem.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
13 years agoFix dlopen dependency
Matthias Bolte [Thu, 9 Jun 2011 19:47:43 +0000 (21:47 +0200)]
Fix dlopen dependency

Since the addition of the lock manager framework in 6a943419c528fdd7
dlopen is always required, but the checks in configure wasn't changed
to reflect that. This didn't show up directly because the VirtualBox
driver linking dlopen in covered it. But disabling the VirtualBox
driver makes the build fail due to missing dlopen.

Change the dlopen check in configure to pick up dlopen when available.

Reported by Ruben Kerkhof.

13 years agoDeprecate several CURRENT/LIVE/CONFIG enums
Hu Tao [Wed, 8 Jun 2011 06:33:33 +0000 (14:33 +0800)]
Deprecate several CURRENT/LIVE/CONFIG enums

This patch deprecates following enums:

VIR_DOMAIN_MEM_CURRENT
VIR_DOMAIN_MEM_LIVE
VIR_DOMAIN_MEM_CONFIG

VIR_DOMAIN_VCPU_LIVE
VIR_DOMAIN_VCPU_CONFIG

VIR_DOMAIN_DEVICE_MODIFY_CURRENT
VIR_DOMAIN_DEVICE_MODIFY_LIVE
VIR_DOMAIN_DEVICE_MODIFY_CONFIG

And modify internal codes to use virDomainModificationImpact.

13 years agoqemu: Faster response time to qemu startup errors
Stefan Berger [Mon, 13 Jun 2011 19:59:58 +0000 (15:59 -0400)]
qemu: Faster response time to qemu startup errors

The below patch decreases the response time of libvirt to errors reported by Qemu upon startup by checking whether the qemu process is still alive while polling for the local socket to show up.

This patch also introduces a special handling of signal for the Win32 part of virKillProcess.

13 years agobuild: update to latest gnulib
Eric Blake [Wed, 8 Jun 2011 13:15:00 +0000 (07:15 -0600)]
build: update to latest gnulib

* .gnulib: Update to latest, for more strerror_r fixes.

13 years agovcpupin: add the new option to "virsh vcpupin" command
Taku Izumi [Mon, 13 Jun 2011 15:51:04 +0000 (23:51 +0800)]
vcpupin: add the new option to "virsh vcpupin" command

This patch adds the new option (--live, --config and --current) to
"virsh vcpupin" command. The behavior of above aption is the same as
that of "virsh setmem", "virsh setvcpus", and whatnot.
When the --config option is specified, the command affects a persistent
domain, while --live option is specified, it affects a running (live) domain.
The --current option cannot be used with --config or --live at the same
time, and when --current is specified, it affects a "current" domain.

13 years agovcpupin: implement the remote protocol to address the new API
Taku Izumi [Mon, 13 Jun 2011 15:45:29 +0000 (23:45 +0800)]
vcpupin: implement the remote protocol to address the new API

This patch implements the remote protocol for the new API
(virDomainPinVcpuFlags).

13 years agovcpupin: implement the code to address the new API in the qemu driver
Taku Izumi [Mon, 13 Jun 2011 15:42:09 +0000 (23:42 +0800)]
vcpupin: implement the code to address the new API in the qemu driver

This patch implements the new API (virDomainPinVcpuFlags) in the qemu
driver.

13 years agovcpupin: introduce a new libvirt API (virDomainPinVcpuFlags)
Taku Izumi [Mon, 13 Jun 2011 15:35:54 +0000 (23:35 +0800)]
vcpupin: introduce a new libvirt API (virDomainPinVcpuFlags)

This patch introduces a new libvirt API virDomainPinVcpuFlags,
a direct extension from the existing virDomainPinVcpu

13 years agoUse virTimeMs when appropriate
Jiri Denemark [Wed, 1 Jun 2011 10:35:18 +0000 (12:35 +0200)]
Use virTimeMs when appropriate

13 years agoIntroduce virTimeMs for getting current time in ms
Jiri Denemark [Wed, 1 Jun 2011 09:38:56 +0000 (11:38 +0200)]
Introduce virTimeMs for getting current time in ms

13 years agotest: Remove unused timeval
Jiri Denemark [Wed, 1 Jun 2011 11:47:33 +0000 (13:47 +0200)]
test: Remove unused timeval

13 years agotests: add a test for multi function PCI device
Wen Congyang [Wed, 8 Jun 2011 04:34:04 +0000 (12:34 +0800)]
tests: add a test for multi function PCI device

13 years agosupport multifunction PCI device
Wen Congyang [Mon, 23 May 2011 06:42:21 +0000 (14:42 +0800)]
support multifunction PCI device

If qemu supports multi function PCI device, the format of the PCI address passed
to qemu is "bus=pci.0,multifunction=on,addr=slot.function".

If qemu does not support multi function PCI device, the format of the PCI address
passed to qemu is "bus=pci.0,addr=slot".

13 years agothe hotplugged PCI device should use the whole slot
Wen Congyang [Mon, 23 May 2011 07:43:35 +0000 (15:43 +0800)]
the hotplugged PCI device should use the whole slot

Hot pluging/unpluging multi PCI device is not supported now. So the function
of hotplugged PCI device must be 0. When we hot unplug it, we should set release
all functions in the slot.

13 years agoassign the whole slot to the PCI device that has no address
Wen Congyang [Mon, 23 May 2011 07:50:13 +0000 (15:50 +0800)]
assign the whole slot to the PCI device that has no address

If user does not specify the PCI address, we should auto assign an unused slot.

13 years agoReimplement qemuDomainPCIAddressReserveSlot(): reserve all functions in the slot
Wen Congyang [Tue, 24 May 2011 05:23:39 +0000 (13:23 +0800)]
Reimplement qemuDomainPCIAddressReserveSlot(): reserve all functions in the slot

We will support multi function PCI device. So we should reserve all functions in
the slot if we want to reserve a slot.

13 years agothe key of hash table should include the function value
Wen Congyang [Mon, 23 May 2011 03:22:54 +0000 (11:22 +0800)]
the key of hash table should include the function value

We save all used PCI address in the hash table. The key is generated by domain,
bus and slot now. We will support multi function PCI device, so the key should
be generated by domain, bus, slot and function.

13 years agoprevent hot unplugging multi function PCI device
Wen Congyang [Mon, 9 May 2011 06:59:16 +0000 (14:59 +0800)]
prevent hot unplugging multi function PCI device

We do not support to hot unplug multi function PCI device now. If the device is
one function of multi function PCI device, we shoul not allow to hot unplugg
it.

13 years agocheck whether qemu supports multi function PCI device
Wen Congyang [Mon, 9 May 2011 06:59:16 +0000 (14:59 +0800)]
check whether qemu supports multi function PCI device

qemu supports multi function PCI device at least version 0.13.0.

13 years agoxenapi: Improve error message on session failure
Matthew Booth [Fri, 10 Jun 2011 09:18:01 +0000 (17:18 +0800)]
xenapi: Improve error message on session failure

XenAPI session login can fail for a number of reasons, but currently no
specific
reason is displayed to the user, e.g.:

virsh -c XenAPI://citrix-xen.example.com/
Enter username for citrix-xen.example.com: root
Enter root's password for citrix-xen.example.com:
error: authentication failed: (null)
error: failed to connect to the hypervisor

This patch displays the session error description on failure.

13 years agoqemu: Fix one type in the error prompt string
Osier Yang [Fri, 10 Jun 2011 03:29:06 +0000 (11:29 +0800)]
qemu: Fix one type in the error prompt string

s/hostdevwork/hostdev/

13 years agoMove VMware Workstation/Player driver to correct spec file section
Matthias Bolte [Thu, 9 Jun 2011 18:28:18 +0000 (20:28 +0200)]
Move VMware Workstation/Player driver to correct spec file section

The VMware driver works like the OpenVZ driver by using a commandline
tool for management. It dosen't use it's own remote protocol.

13 years agovirt-aa-helper: add missing include
Eric Blake [Wed, 8 Jun 2011 13:17:17 +0000 (07:17 -0600)]
virt-aa-helper: add missing include

Regression introduced in commit 02e8691.

* src/security/virt-aa-helper.c (includes): Reflect move of virRun.

13 years agodaemon: plug memory leak
Eric Blake [Mon, 6 Jun 2011 21:03:26 +0000 (15:03 -0600)]
daemon: plug memory leak

Detected by Coverity.  Commit ef21beda was incomplete; it solved
a leak one one path, but not on the other.

* daemon/libvirtd.c (qemudSetLogging): Avoid leak on success.

13 years agobuild: break some long lines
Eric Blake [Mon, 6 Jun 2011 19:35:41 +0000 (13:35 -0600)]
build: break some long lines

As long as I was already touching the function...

* src/qemu/qemu_hotplug.c (qemuDomainChangeGraphics): Line wrap.

13 years agoqemu: add missing break statement
Eric Blake [Mon, 6 Jun 2011 19:30:52 +0000 (13:30 -0600)]
qemu: add missing break statement

Detected by Coverity.  Bug introduced in commit 9d73efd (v0.8.8).

* src/qemu/qemu_hotplug.c (qemuDomainChangeGraphics): Don't report
error on success.

13 years agobuild: silence coverity false positives
Eric Blake [Mon, 6 Jun 2011 19:23:24 +0000 (13:23 -0600)]
build: silence coverity false positives

Coverity complained about these intentional fallthrough cases, but
not about other cases that were explicitly marked with nice comments.

For some reason, Coverity doesn't seem smart enough to parse the
up-front English comment in virsh about intentional fallthrough :)

* tools/virsh.c (cmdVolSize): Mark fallthrough in a more typical
fashion.
* src/conf/nwfilter_conf.c (virNWFilterRuleDefDetailsFormat)
(virNWFilterRuleDetailsParse): Mark explicit fallthrough.

13 years agoesx: avoid dead code
Eric Blake [Mon, 6 Jun 2011 19:19:38 +0000 (13:19 -0600)]
esx: avoid dead code

Detected by Coverity.  The beginning of the function already filtered
out NULL objectContentList as invalid.  Further investigation shows:

esxVI_RetrieveProperties is generated and returns a list of objects
that match the given propertyFilterSpec.
esxVI_LookupObjectContentByType then tests whether the result
corresponds to the expected occurrence and reports an error otherwise.
This simplifies the callers of  esxVI_LookupObjectContentByType, but
due to the missing dereference the check was never performed because
the code thought that at least one item was obtained. NULL represents
an empty list. This is a potential segfault fix because callers of
esxVI_LookupObjectContentByType that specified "required" occurrence
assume *objectContentList to be non-NULL when
esxVI_LookupObjectContentByType succeeds.

* src/esx/esx_vi.c (esxVI_LookupObjectContentByType): Check
correct pointer.

13 years agosecret: drop dead code
Eric Blake [Mon, 6 Jun 2011 19:14:48 +0000 (13:14 -0600)]
secret: drop dead code

Detected by Coverity.  The only ways to get to the cleanup label
were by an early abort (list still unassigned) or after successfully
transferring list to dest, so there is no list to clean up.

* src/secret/secret_driver.c (loadSecrets): Kill dead code.

13 years agoqemu: reorder checks for safety
Eric Blake [Mon, 6 Jun 2011 19:07:11 +0000 (13:07 -0600)]
qemu: reorder checks for safety

Detected by Coverity.  All existing callers happen to be in
range, so this isn't too serious.

* src/qemu/qemu_cgroup.c (qemuCgroupControllerActive): Check
bounds before dereference.

13 years agouuid: annotate non-null requirements
Eric Blake [Mon, 6 Jun 2011 19:03:15 +0000 (13:03 -0600)]
uuid: annotate non-null requirements

Coverity already saw through a NULL dereference without these
annotations, and gcc is still too puny to do good NULL analysis.
But clang still benefits (and is easier to run than coverity),
not to mention that adding this bit of documentation to the code
may help future developers remember the constraints.

* src/util/uuid.h (virGetHostUUID, virUUIDFormat): Document
restrictions, for improved static analysis.

13 years agodebug: avoid null dereference on uuid lookup api
Eric Blake [Mon, 6 Jun 2011 17:55:43 +0000 (11:55 -0600)]
debug: avoid null dereference on uuid lookup api

Detected by Coverity.  Commit a98d8f0d tried to make uuid debugging
more robust, but missed some APIs.  And on the APIs that it visited,
the mere act of preparing the debug message ends up dereferencing
uuid prior to the null check.  Which means the APIs which are supposed
to gracefully reject NULL arguments now end up with SIGSEGV.

* src/libvirt.c (VIR_UUID_DEBUG): New macro.
(virDomainLookupByUUID, virDomainLookupByUUIDString)
(virNetworkLookupByUUID, virNetworkLookupByUUIDString)
(virStoragePoolLookupByUUID, virStoragePoolLookupByUUIDString)
(virSecretLookupByUUID, virSecretLookupByUUIDString)
(virNWFilterLookupByUUID, virNWFilterLookupByUUIDString): Avoid
null dereference.

13 years agopython: avoid unlikely sign extension bug
Eric Blake [Fri, 3 Jun 2011 19:53:26 +0000 (13:53 -0600)]
python: avoid unlikely sign extension bug

Detected by Coverity.  cpumap was allocated with a value of
(unsigned short)*(int), which is an int computation, and then
promotes to size_t.  On a 64-bit platform, this fails if bit
32 of the product is set (because of sign extension giving
a HUGE value to malloc), even though a naive programmer would
assume that since the first value is unsigned, the product
is also unsigned and at most 4GB would be allocated.

Won't bite in practice (the product should never be that large),
but worth using the right types to begin with, so that we are
now computing (unsigned short)*(size_t).

* python/libvirt-override.c (libvirt_virDomainGetVcpus): Use
correct type.

13 years agobuild: silence coverity false positive
Eric Blake [Wed, 8 Jun 2011 11:23:00 +0000 (05:23 -0600)]
build: silence coverity false positive

Similar in nature to commit fd21ecfd, which shut up valgrind.

sigaction is apparently a nasty interface for analyzer tools,
at least for how many false positives it generates.

* src/util/command.c (virExecWithHook): Initialize entire var, since
coverity gripes about the (unused and non-standard) sa_restorer.

13 years agostorage: avoid mishandling backing store > 2GB
Eric Blake [Thu, 2 Jun 2011 23:52:16 +0000 (17:52 -0600)]
storage: avoid mishandling backing store > 2GB

Detected by Coverity.  The code was doing math on shifted unsigned
char (which promotes to int), then promoting that to unsigned long
during assignment to size.  On 64-bit platforms, this risks sign
extending values of size > 2GiB.  Bug present since commit
489fd3 (v0.6.0).

I'm not sure if a specially-crafted bogus qcow2 image could
exploit this, although it's probably not possible, since we
were already checking for the computed results being within
range of our fixed-size buffer.

* src/util/storage_file.c (qcowXGetBackingStore): Avoid sign
extension.

13 years agobuild: detect Coverity 5.3.0
Eric Blake [Fri, 3 Jun 2011 19:43:15 +0000 (13:43 -0600)]
build: detect Coverity 5.3.0

Coverity 5.3.0 still outputs lots of COVERITY_* variables, but no
longer modifies COVERITY_BUILD_COMMAND in the environment.  Pick
one that seems likely to stay around.

* configure.ac (STATIC_ANALYSIS): Detect newer Coverity.

13 years agobuild: Fix typos in configure.ac
Osier Yang [Wed, 8 Jun 2011 07:07:24 +0000 (15:07 +0800)]
build: Fix typos in configure.ac

13 years agovirsh: Expose virDomainMigrateSetMaxSpeed API to virsh
Osier Yang [Wed, 8 Jun 2011 02:40:57 +0000 (10:40 +0800)]
virsh: Expose virDomainMigrateSetMaxSpeed API to virsh

API virDomainMigrateSetMaxSpeed was introduced since 0.9.0, but
no command in virsh yet.

13 years agolxc: Ensure container <init> actually exists
Cole Robinson [Thu, 2 Jun 2011 19:25:21 +0000 (15:25 -0400)]
lxc: Ensure container <init> actually exists

Since we can't really get useful error reporting from virCommandExec since
it needs to be the last thing we do.

13 years agolxc: Verify root fs exists before mounting
Cole Robinson [Thu, 2 Jun 2011 18:25:25 +0000 (14:25 -0400)]
lxc: Verify root fs exists before mounting

Otherwise the following virFileMakePath will create the directory for
us and fail further ahead, which probably isn't intended.

13 years agolxc: controller: Improve container error reporting
Cole Robinson [Thu, 2 Jun 2011 15:52:32 +0000 (11:52 -0400)]
lxc: controller: Improve container error reporting

Add a handshake with the cloned container process to try and detect
if it fails to start.

13 years agolxc: Improve guest startup error reporting
Cole Robinson [Wed, 1 Jun 2011 22:17:00 +0000 (18:17 -0400)]
lxc: Improve guest startup error reporting

Add a simple handshake with the lxc_controller process so we can detect
process startup failures. We do this by adding a new --handshake cli arg
to lxc_controller for passing a file descriptor. If the process fails to
launch, we scrape all output from the logfile and report it to the user.

13 years agolxc: Refactor controller command building
Cole Robinson [Wed, 1 Jun 2011 20:38:09 +0000 (16:38 -0400)]
lxc: Refactor controller command building

Arranges things similar to the qemu driver. Will allow us to more easily
report command error output.

13 years agolxc: Don't report error in Wait/SendContinue
Cole Robinson [Thu, 2 Jun 2011 15:18:14 +0000 (11:18 -0400)]
lxc: Don't report error in Wait/SendContinue

We will reuse these shortly, and each use should have a different error
message.

13 years agolxc: Drop container stdio as late as possible
Cole Robinson [Thu, 2 Jun 2011 15:01:36 +0000 (11:01 -0400)]
lxc: Drop container stdio as late as possible

Makes it more likely we get useful error output in the logs

13 years agoMove virRun, virExec*, virFork to util/command
Cole Robinson [Tue, 10 May 2011 18:42:59 +0000 (14:42 -0400)]
Move virRun, virExec*, virFork to util/command

Seems reasonable to have all command wrappers in the same place

v2:
    Dont move SetInherit

v3:
    Comment spelling fix
    Adjust WARN0 comment
    Remove spurious #include movement
    Don't include sys/types.h
    Combine virExec enums

Signed-off-by: Cole Robinson <crobinso@redhat.com>
13 years agoutil: Implement virRun as a wrapper around virCommand
Cole Robinson [Fri, 6 May 2011 20:41:03 +0000 (16:41 -0400)]
util: Implement virRun as a wrapper around virCommand

v2:
    Simplify command building
    Handle command building failure

v3:
    Remove unneeded NULL check

Signed-off-by: Cole Robinson <crobinso@redhat.com>
13 years agoutil: Remove unused virExec wrapper
Cole Robinson [Fri, 6 May 2011 20:36:16 +0000 (16:36 -0400)]
util: Remove unused virExec wrapper

v3:
    Remove obsolete comment

Signed-off-by: Cole Robinson <crobinso@redhat.com>
13 years agoqemu: Convert virExec usage to virCommand
Cole Robinson [Fri, 6 May 2011 20:10:40 +0000 (16:10 -0400)]
qemu: Convert virExec usage to virCommand

v2:
    Have virCommand cleanup intermediate process for us

v3:
    Preserve original FD closing behavior

Signed-off-by: Cole Robinson <crobinso@redhat.com>
13 years agoesx: Remove duplicated invalid-argument checks
Matthias Bolte [Tue, 7 Jun 2011 07:35:03 +0000 (09:35 +0200)]
esx: Remove duplicated invalid-argument checks

Those checks are already performed at the public API level.

13 years agodocs: Add doc for video element
Osier Yang [Tue, 7 Jun 2011 08:56:06 +0000 (16:56 +0800)]
docs: Add doc for video element

For backwards compatibility, if no <video> is set but there is a
<graphics> tag, then we add a default <video> according to the
guest type. Add docs to tell the user about this to not make
them confused. Especially if they remove the video (such as via
"virsh edit"), it will be surprised for them to see the video
element is still in domain XML.

13 years agoUse VIR_USE_CPU instead of new wheel
Osier Yang [Tue, 7 Jun 2011 08:51:51 +0000 (16:51 +0800)]
Use VIR_USE_CPU instead of new wheel

13 years agoAvoid virGetVersion failure on specific driver support configurations
Matthias Bolte [Wed, 1 Jun 2011 08:29:13 +0000 (10:29 +0200)]
Avoid virGetVersion failure on specific driver support configurations

virGetVersion itself doesn't take a virConnectPtr, but in order to obtain
the hypervisor version against which libvirt was compiled it is used in
combination with virConnectGetType like this:

hvType = virConnectGetType(conn)
virGetVersion(&libVer, hvType, &typeVer)

When virConnectGetType is called on a remote connection then the remote
driver returns the type of the underlying driver on the server side, for
example QEMU. Then virGetVersion compares hvType to a set of strings that
depend on configure options and returns LIBVIR_VERSION_NUMBER in most
cases. Now this fails in case libvirt on the client side is just compiled
with the remote driver enabled only and the server side has the actual
driver such as the QEMU driver. It just happens to work when the actual
driver is enabled on client and server side. But that's not always true.
I noticed this on FreeBSD:

freebsd# virsh -c qemu+tcp://192.168.178.22/system version
Compiled against library: libvir 0.9.2
error: failed to get the library version
error: this function is not supported by the connection driver: virGetVersion

This is not FreeBSD specific, happens on Windows as well due to the
similar driver support configuration. The problem is that virConnectGetType
returns QEMU, but virGetVersion on the client side only accepts Remote
as hvType due to all other drivers being disabled on the client side.

Daniel P. Berrange suggested to get rid of all the conditional code in
virGetVersion, ignoring the hvType and always setting typeVer to
LIBVIR_VERSION_NUMBER. virConnectGetVersion is supposed to be used to
obtain the hypervisor version.

13 years agodocs: Make hvsupport.pl pick up the host device drivers
Matthias Bolte [Sat, 4 Jun 2011 21:24:54 +0000 (23:24 +0200)]
docs: Make hvsupport.pl pick up the host device drivers

Annotate the ESX device driver dummy.

Refactor the udev and hal device driver strcuts to match the
common annotation pattern.

13 years agoRelease of libvirt-0.9.2
Daniel Veillard [Mon, 6 Jun 2011 03:46:37 +0000 (11:46 +0800)]
Release of libvirt-0.9.2

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

13 years agoesx: Fix driver method version annotations
Matthias Bolte [Mon, 6 Jun 2011 03:08:06 +0000 (11:08 +0800)]
esx: Fix driver method version annotations

Change the driver comments for proper extraction and values by
the scripts used for documentation

13 years agoFix QEMU p2p v2 migration when run from a v3 client
Daniel P. Berrange [Mon, 6 Jun 2011 03:05:34 +0000 (11:05 +0800)]
Fix QEMU p2p v2 migration when run from a v3 client

When peer-2-peer migration was invoked by a client supporting
v3, but where the target server only supported v2, we'd not
correctly shutdown the guest.

* src/qemu/qemu_migration.c: Ensure guest is shutdown in
  v2 peer 2 peer migration

13 years agovbox: Fix typo in error message
Matthias Bolte [Sat, 4 Jun 2011 20:40:57 +0000 (22:40 +0200)]
vbox: Fix typo in error message

13 years agoDon't raise an error if the migration cookie is NULL
Daniel P. Berrange [Sat, 4 Jun 2011 10:14:05 +0000 (06:14 -0400)]
Don't raise an error if the migration cookie is NULL

The v2 migration protocol doesn't use cookies, so we should not
be raising an error if the cookie parameters are NULL.

* src/qemu/qemu_migration.c: Don't raise error if cookie is NULL

13 years agoFix check of virKillProcess return status
Daniel P. Berrange [Sat, 4 Jun 2011 10:05:28 +0000 (06:05 -0400)]
Fix check of virKillProcess return status

The error code for virKillProcess is returned in the errno variable
not the return value. THis mistake caused the logs to be filled with
errors when shutting down QEMU processes

* src/qemu/qemu_process.c: Fix process kill check.

13 years agovbox: Fix version extraction on Windows for newer VirtualBox versions
Matthias Bolte [Sat, 4 Jun 2011 08:50:36 +0000 (10:50 +0200)]
vbox: Fix version extraction on Windows for newer VirtualBox versions

VirtualBox 4.0.8 changed the registry key layout. Before the version
number was in a Version key. Now the Version key contains %VER% and
the actual version number is in VersionExt now.

Move value lookup code into its own function: vboxLookupRegistryValue.

13 years agoAPI: consolidate common unreleased enums
Eric Blake [Fri, 3 Jun 2011 16:10:58 +0000 (10:10 -0600)]
API: consolidate common unreleased enums

This commit is safe precisely because there has been no release
for any of the enum values being deleted (they were added post-0.9.1).

After the 0.9.2 release, we can then take advantage of
virDomainModificationImpact in more places.

* include/libvirt/libvirt.h.in (virDomainModificationImpact): New
enum.
(virDomainSchedParameterFlags, virMemoryParamFlags): Delete, since
these were never released, and the new enum works fine here.
* src/libvirt.c (virDomainGetMemoryParameters)
(virDomainSetMemoryParameters)
(virDomainGetSchedulerParametersFlags)
(virDomainSetSchedulerParametersFlags): Update documentation.
* src/qemu/qemu_driver.c (qemuDomainSetMemoryParameters)
(qemuDomainGetMemoryParameters, qemuSetSchedulerParametersFlags)
(qemuSetSchedulerParameters, qemuGetSchedulerParametersFlags)
(qemuGetSchedulerParameters): Adjust clients.
* tools/virsh.c (cmdSchedinfo, cmdMemtune): Likewise.
Based on ideas by Daniel Veillard and Hu Tao.

13 years agoqemu: Avoid use after free in qemuCaps parsing
Jiri Denemark [Fri, 3 Jun 2011 14:33:25 +0000 (16:33 +0200)]
qemu: Avoid use after free in qemuCaps parsing

13 years agovirsh: Document nodeinfo output
Jiri Denemark [Thu, 2 Jun 2011 08:56:43 +0000 (10:56 +0200)]
virsh: Document nodeinfo output

13 years agosecurity driver: ignore EINVAL when chowning an image file
Laine Stump [Fri, 3 Jun 2011 15:59:09 +0000 (11:59 -0400)]
security driver: ignore EINVAL when chowning an image file

This fixes:

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

Both of these complain of a failure to use an image file that resides
on a read-only NFS volume. The function in the DAC security driver
that chowns image files to the qemu user:group before using them
already has special cases to ignore failure of chown on read-only file
systems, and in a few other cases, but it hadn't been checking for
EINVAL, which is what is returned if the qemu user doesn't even exist
on the NFS server.

Since the explanation of EINVAL in the chown man page almost exactly
matches the log message already present for the case of EOPNOTSUPP,
I've just added EINVAL to that same conditional.

13 years agoMake dlopen usage in lock manager conditional
Matthias Bolte [Fri, 3 Jun 2011 08:20:49 +0000 (10:20 +0200)]
Make dlopen usage in lock manager conditional

This fixes a build failure on MinGW, due to MinGW not supporting dlopen.

13 years agoCorrect 'cputune' documentation example.
Neil Wilson [Fri, 3 Jun 2011 13:43:30 +0000 (14:43 +0100)]
Correct 'cputune' documentation example.

Signed-off-by: Neil Wilson <neil@aldur.co.uk>
13 years agobuild: silence coverity false positive
Eric Blake [Thu, 2 Jun 2011 21:45:31 +0000 (15:45 -0600)]
build: silence coverity false positive

Coverity couldn't see that priv is NULL on failure.  But on failure,
we might as well guarantee that callers don't try to free uninitialized
memory.

* src/remote/remote_driver.c (remoteGenericOpen): Even on failure,
pass priv back to caller.

13 years agobuild: silence coverity false positive
Eric Blake [Thu, 2 Jun 2011 21:31:48 +0000 (15:31 -0600)]
build: silence coverity false positive

Coverity complained that infd could be -1 at the point where it is
passed to write, when in reality, this code can only be reached if
infd is non-negative.

* src/util/command.c (virCommandProcessIO): Help out coverity.

13 years agomigrate: detect xml incompatibility
Eric Blake [Thu, 2 Jun 2011 23:40:39 +0000 (17:40 -0600)]
migrate: detect xml incompatibility

Detected by Coverity.  Bug introduced in 08106e2044 (unreleased).

* src/conf/domain_conf.c (virDomainChannelDefCheckABIStability):
Use correct sizeof operand.

13 years agoevent: avoid memory leak on cleanup
Eric Blake [Thu, 2 Jun 2011 22:54:09 +0000 (16:54 -0600)]
event: avoid memory leak on cleanup

Detected by Coverity.  Introduced in commit aaf2b70, and turned into
a regression in the next few commits through 4e6e6672 (unreleased).

* src/conf/domain_event.c (virDomainEventStateFree): Free object,
per documentation.

13 years agoqemu: avoid memory leak on vcpupin
Eric Blake [Thu, 2 Jun 2011 22:47:53 +0000 (16:47 -0600)]
qemu: avoid memory leak on vcpupin

Detected by Coverity.  This leaked a cpumap on every iteration
of the loop.  Leak introduced in commit 1cc4d02 (v0.9.0).

* src/qemu/qemu_process.c (qemuProcessSetVcpuAffinites): Plug
leak, and hoist allocation outside loop.

13 years agoremote: avoid leak on failure
Eric Blake [Thu, 2 Jun 2011 22:42:45 +0000 (16:42 -0600)]
remote: avoid leak on failure

Detected by Coverity.  Only possible in OOM situations.

* daemon/remote.c (remoteDispatchDomainScreenshot): Plug leak.