Commit Graph

5075 Commits

Author SHA1 Message Date
Osier Yang
d61820df98 qemu: Fix memory leak in qemuProcessWaitForMonitor
Move "VIR_FREE(buf) into label "closelog", so that "buf" could be
freed before returning.
2011-06-23 18:15:25 +08:00
Jiri Denemark
6a15cc6b90 qemu: Only check for NUMA availability if required
We only care about NUMA availability if NUMA configuration is requested
in domain XML.
2011-06-23 09:39:54 +02:00
Matthew Booth
10208cc503 storage: fix volDelete return when volume still being allocated
volDelete used to return VIR_ERR_INTERNAL_ERROR when attempting to
delete a volume which was still being allocated. It should return
VIR_ERR_OPERATION_INVALID.

* src/storage/storage_driver.c: Fix return of volDelete.
2011-06-23 11:28:29 +08:00
Eric Blake
60bfd5b565 util: avoid PATH_MAX-sized array
See previous patch for why this is good...

* src/util/pci.c (struct _pciDevice, pciGetDevice, pciFreeDevice):
Manage path dynamically.  Report snprintf overflow.
* src/util/hostusb.c (struct _usbDevice, usbGetDevice)
(usbFreeDevice): Likewise.
2011-06-22 17:13:58 -06:00
Eric Blake
565c975f9b xen: avoid PATH_MAX-sized array
See previous patch for why this is good...

* src/xen/xen_driver.h (xenXMConfCache): Manage filename
dynamically.
* src/xen/xm_internal.c (xenXMConfigCacheAddFile)
(xenXMConfigFree, xenXMDomainDefineXML): Likewise.
2011-06-22 17:13:58 -06:00
Eric Blake
ca8b4cec6d tests: avoid PATH_MAX-sized array
See previous patch for why this is good...

* src/test/test_driver.c (struct _testConn, testOpenFromFile)
(testClose): Manage path dynamically.
2011-06-22 17:13:58 -06:00
Eric Blake
aa286e537d virStorageVol: avoid PATH_MAX-sized array
POSIX allows implementations where PATH_MAX is undefined, leading
to compilation error.  Not to mention that even if it is defined,
it is often wasteful in relation to the amount of data being stored.

All clients of vol->key were audited, and found not to care about
whether key is static or dynamic, except for these offenders:

* src/datatypes.h (struct _virStorageVol): Manage key dynamically.
* src/datatypes.c (virReleaseStorageVol): Free key.
(virGetStorageVol): Copy key.
2011-06-22 17:13:58 -06:00
Eric Blake
26dc216ae8 maint: add omitted copyright header
Bug introduced in commit 6a597883.

* src/util/netlink.h: Add boilerplate.
2011-06-22 15:42:51 -06:00
Eric Blake
dbcd8c5967 docs: fix docs to match behavior of virConnectClose
* src/libvirt.c (virConnectClose): Mention reference count return.
Reported by Michal Novotny, analyzed by Matthias Bolte.
2011-06-22 13:25:56 -06:00
Stefan Berger
df3d8c362d cleanup: make several interface functions commonly available
In a second cleanup step this patch makes several interface functions from macvtap.c commonly available by moving them into interface.c and prefixing their names with 'iface'. Those functions taking Linux-specific structures as parameters are only visible on Linux.

ifaceRestoreMacAddress returns the return code from the ifaceSetMacAddr call and display an error message if setting the MAC address did not work. The caller is unchanged and still ignores the return code (which is ok).
2011-06-22 14:28:57 -04:00
Stefan Berger
6a5978833a cleanup: make nlComm commonly available
In a first cleanup step, make nlComm from macvtap.c commonly available
for other code to use. Since nlComm uses Linux-specific structures as
parameters it's prototype is only visible on Linux.
2011-06-22 14:17:36 -04:00
Daniel P. Berrange
abb82f53ed Fix use-after-free in handling domain taint flags
* src/conf/domain_conf.c: Fix use after free
2011-06-22 17:39:45 +01:00
Daniel P. Berrange
caf808c790 Remove macvtap dependency on domain configuration
Files under src/util must not depend on src/conf
Solve the macvtap problem by moving the definition
of macvtap modes from domain_conf.h into macvtap.h

* src/util/macvtap.c, src/util/macvtap.h: Add enum
  for macvtap modes
* src/conf/domain_conf.c, src/conf/domain_conf.h: Remove
  enum for macvtap modes
2011-06-22 17:39:06 +01:00
Osier Yang
73b9246df9 util: Correct the error prompt string
virCommandProcessIO: It's reading from stdout or stderr of child,
but not writing.
2011-06-22 19:33:24 +08:00
Osier Yang
20d5e9db82 qemu: Fix one memory leak
* src/qemu/qemu_domain.c: (qemuDomainAppendLog)

  Free "message" in "cleanup".
2011-06-22 19:32:04 +08:00
Michal Privoznik
017abcbb1a qemu: domain I/O asynchronous handling
For virtio disks and interfaces, qemu allows users to enable or disable
ioeventfd feature. This means, qemu can execute domain code, while
another thread waits for I/O event. Basically, in some cases it is win,
in some loss. This feature is available via 'ioeventfd' attribute in disk
and interface <driver> element. It accepts 'on' and 'off'. Leaving this
attribute out defaults to hypervisor decision.
2011-06-22 09:26:24 +02:00
Dirk Herrendoerfer
cbd8227ee0 set and restore MAC address of a NIC when using PASSTHROUGH mode
The following patch addresses the problem that when a PASSTHROUGH
mode DIRECT NIC connection is made the MAC address of the NIC is
not automatically set and reset to the configured VM MAC and
back again.

The attached patch fixes this problem by setting and resetting the MAC
while remembering the previous setting while the VM is running.
This also works if libvirtd is restarted while the VM is running.

the patch passes make syntax-check
2011-06-21 11:49:40 -04:00
Cole Robinson
27e47955a0 events: Correct virEventAddTimeout docs 2011-06-21 10:08:47 -04:00
Cole Robinson
6094ad7bd7 Promote virEvent*Handle/Timeout to public API
Since we virEventRegisterDefaultImpl is now a public API, callers need
a way to invoke the default registered Handle and Timeout functions. We
already have general functions for these internally, so promote
them to the public API.

v2:
    Actually add APIs to libvirt.h
2011-06-21 10:08:47 -04:00
Osier Yang
a22dbe0d66 conf: Make full use of goto label
* virDomainDefParse: There is a goto label "no_memory", which
reports OOM error, and then fallthrough label "error". This
patch changes things like following:

    virReportOOMError();
    goto error;

into:

    goto no_memory;
2011-06-21 16:20:15 +08:00
Osier Yang
9a2ac25a63 conf: Fix one memory leak
Free def->numatune.memory.nodemask in virDomainDefFree.
2011-06-21 16:03:59 +08:00
Matthias Bolte
272ead559c remote generator: Allow to annotate arrays with typecasts
Removes special case code from the generator and handle additional
methods.

The generated version of remoteDispatchDomainPinVcpu(Flags) has no
length check, but this check was useless anyway as it was applied to
data that was already deserialized from its XDR form.
2011-06-20 11:23:34 +02:00
Matthias Bolte
ac77cbaeae remote: Handle functions that return optional strings 2011-06-20 11:23:34 +02:00
Matthias Bolte
6be35f5fef remote: Generate virDomainGetBlockPullInfo
It was already generatable but skipped.
2011-06-20 11:23:34 +02:00
Taku Izumi
7ea9778c8a vcpupin: add vcpupin resetting feature to qemu driver
Pinning to all physical cpus means resetting, hence it is preferable to
delete vcpupin setting of XML.

This patch changes qemu driver to delete vcpupin setting by invoking
virDomainVcpupinDel API when pinning the specified virtual cpu to
all host physical cpus.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
2011-06-20 18:14:54 +08:00
Taku Izumi
3711c0b051 vcpupin: add virDomainVcpupinDel function
This patch add the private API (virDomainVcpupinDel).
This API can delete the vcpupin setting of a specified virtual cpu.

Signed-off-by: Taku Izumi <izumi.taku@jp.fujitsu.com>
2011-06-20 18:14:54 +08:00
Matthias Bolte
d967a8bfa4 Fix preprocessor indentation in nodeinfo.c 2011-06-20 10:39:09 +02:00
Osier Yang
a6f5c9b600 numatune: Support NUMA memory tuning in qemu driver
Implemented as setting NUMA policy between fork and exec as a hook,
using libnuma. Only support memory tuning on domain process currently.

For the nodemask out of range, will report soft warning instead of
hard error in libvirt layer. (Kernel will be silent as long as one
of set bit in the nodemask is valid on the host. E.g. For a host
has two NUMA nodes, kernel will be silent for nodemask "01010101").
So, soft warning is the only thing libvirt can do, as one might want
to specify the numa policy prior to a node that doesn't exist yet,
however, it may come as hotplug soon.
2011-06-20 15:16:16 +08:00
Osier Yang
d7edaf5d8c numatune: Support persistent XML for numatune
* src/conf/domain_conf.h: Introduce one new struct for representing
NUMA tuning related stuffs.

* src/conf/domain_conf.c: Parse and format numatune XML.
2011-06-20 15:15:44 +08:00
Hu Tao
8485e5a256 Update qemuDomainSetBlkioParameters to use flags 2011-06-20 15:52:11 +08:00
Hu Tao
100c39ca03 update qemuDomainGetBlkioParameters to use flags 2011-06-20 15:52:11 +08:00
Wen Congyang
34e3ec90f6 build: fix building error when building without libvirtd
When building libvirt without libvirtd, we will receive the following error
message:

make[3]: Entering directory `/home/wency/rpmbuild/BUILD/libvirt-0.9.2/tools'
  CC     virsh-virsh.o
  CC     virsh-console.o
  GEN    virt-xml-validate
  GEN    virt-pki-validate
  CCLD   virsh
./src/.libs/libvirt.so: undefined reference to `numa_available'
./src/.libs/libvirt.so: undefined reference to `numa_max_node'
collect2: ld returned 1 exit status

The reason is that: we check numactl only when building qemu driver, and qemu
driver will not be built when bulding without libvirtd. So with_numactl's
value is check and we will not link libnuma.so.

In the other function, we call numa_available() and numa_max_node() only
when HAVE_NUMACTL is 1. We should do the same check in the function nodeGetMemoryStats().
2011-06-20 15:52:11 +08:00
Jamie Strandboge
b9757fea30 apparmor: implement AppArmorSetFDLabel()
During a savevm operation, libvirt will now use fd migration if qemu
supports it. When the AppArmor driver is enabled, AppArmorSetFDLabel()
is used but since this function simply returns '0', the dynamic AppArmor
profile is not updated and AppArmor blocks access to the save file. This
patch implements AppArmorSetFDLabel() to get the pathname of the file by
resolving the fd symlink in /proc, and then gives that pathname to
reload_profile(), which fixes 'virsh save' when AppArmor is enabled.

Reference: https://launchpad.net/bugs/795800
2011-06-20 11:53:24 +08:00
Daniel P. Berrange
cc743e2314 Add missing checks for NULL in domain lock manager
The domain lock manager forgot to include a bunch of checks
for NULL which could occur on OOM

* src/locking/domain_lock.c: Add checks for NULL
2011-06-17 11:02:23 +01:00
Daniel P. Berrange
a81822063d Fix errno return in safezero()
Most of the safezero() implementations return -1 on error,
setting errno. The safezero() impl using posix_fallocate()
though returned a positive errno value on error (due to
the unusual API contract of posix_fallocate() compared to
most syscall APIs).

* src/util/util.c: Ensure safezero() returns -1 and sets
  errno on error.
* src/storage/storage_backend.c: Change safezero != 0 to
  < 0 for detecting errors
2011-06-17 11:02:18 +01:00
Daniel P. Berrange
c24c07f40b Add missing error reporting when loading mac filter config for QEMU
If the 'mac_filter' configuration parameter is enabled, and there
is a failure to enable filtering, no error is reported back to
the caller. Also fix some bogus whitespace indentation for
hugetlbfs_mount

* src/qemu/qemu_conf.c: Add missing error reporting
2011-06-17 11:02:13 +01:00
Jiri Denemark
559fcf8a24 qemu: Implement virDomainGetControlInfo 2011-06-16 18:47:12 +02:00
Jiri Denemark
6301ce5235 Wire protocol and remote driver for virDomainGetControlInfo 2011-06-16 18:47:12 +02:00
Jiri Denemark
67cc825dda Introduce virDomainGetControlInfo API
The API can be used to query current state of an interface to VMM used
to control a domain. In QEMU world this translates into monitor
connection.
2011-06-16 18:26:12 +02:00
Matthias Bolte
be757a3f7b Fix documentation of virStreamRecv
virStreamRecv is for reading.

Also add some missing punctuation to virStreamSend's documentation.
2011-06-16 11:31:07 +02:00
Eric Blake
1d57562942 sendkey: use consistent API convention
Even though rpc uses 'unsigned int' for the _len parameter that
passes the length of item<length>, the public libvirt APIs all
use 'int' and filter out lengths < 0, except for virDomainSendKey.

* include/libvirt/libvirt.h.in (virDomainSendKey): All other APIs
use int for array length.
* src/libvirt.c (virDomainSendKey): Adjust.
* src/driver.h (virDrvDomainSendKey): Likewise.
* daemon/remote_generator.pl: Likewise.
2011-06-15 11:25:53 -06:00
Eric Blake
b33cd5e349 build: export correct function names
Detected by autobuild.sh, when targetting mingw.
Introduced in commit 98bfdff.

* src/libvirt_private.syms: Fix typos.
2011-06-15 11:25:32 -06:00
Eric Blake
a1df7054ce build: avoid compiler warning on non-Linux
Detected by autobuild.sh when cross-building for mingw.
Introduced in commits ce76e85 and af35cec.

* src/nodeinfo.c (nodeGetCPUStats, nodeGetMemoryStats): Mark
parameters as potentially unused.
2011-06-15 11:25:02 -06:00
Matthias Bolte
64000eabed remote generator: Handle struct returning functions better
The position of the struct parameter in the function signature
differs. Instead of hardcoding the handling for this add an annotation
to the .x file to define the position.
2011-06-15 16:55:42 +02:00
Daniel Gollub
c4bd6d96f4 support for Xen HVM Viridian (Hyper-V) enlightenment interface
Introduce libvirt support for Xen HVM Viridian (Hyper-V) enlightenment
interface guest feature.

 src/conf/domain_conf.c     |    3 ++-
 src/conf/domain_conf.h     |    1 +
 src/xen/xen_hypervisor.c   |   11 +++++++++++
 src/xenapi/xenapi_driver.c |    2 ++
 src/xenapi/xenapi_utils.c  |    2 ++
 src/xenxs/xen_sxpr.c       |    4 ++++
 src/xenxs/xen_xm.c         |   12 +++++++++++-
 7 files changed, 33 insertions(+), 2 deletions(-)
2011-06-15 08:02:47 -06:00
Daniel P. Berrange
b86524e8d5 Add support for network filter code in LXC driver
The LXC driver networking uses veth device pairs. These can
be easily hooked into the network filtering code.

* src/lxc/lxc_driver.c: Add calls to setup/teardown nwfilter
2011-06-15 10:56:08 +01:00
Daniel P. Berrange
b4728dd43e Fix allocation of veth's to not skip an index
The algorithm for autoassigning vethXXX devices, was always
skipping over the starting dev index when finding a free
name for the guest device. This should only be done if the host
device was autoallocated.

* src/lxc/veth.c: Don't skip over veth indexes
2011-06-15 10:56:08 +01:00
Jiri Denemark
c3068d4d23 qemu: Translate boot config into bootindex if possible
Prefer bootindex=N option for -device over the old way -boot ORDER
possibly accompanied with boot=on option for -drive. This gives us full
control over which device will actually be used for booting guest OS.
Moreover, if qemu doesn't support boot=on, this is the only way to boot
of certain disks in some configurations (such as virtio disks when used
together IDE disks) without transforming domain XML to use per device
boot elements.
2011-06-15 11:29:09 +02:00
Adam Litke
12cd77a0c5 Asynchronous event for BlockPull completion
When an operation started by virDomainBlockPullAll completes (either with
success or with failure), raise an event to indicate the final status.  This
allows an API user to avoid polling on virDomainBlockPullInfo if they would
prefer to use the event mechanism.

* daemon/remote.c: Dispatch events to client
* include/libvirt/libvirt.h.in: Define event ID and callback signature
* src/conf/domain_event.c, src/conf/domain_event.h,
  src/libvirt_private.syms: Extend API to handle the new event
* src/qemu/qemu_driver.c: Connect to the QEMU monitor event
  for block_stream completion and emit a libvirt block pull event
* src/remote/remote_driver.c: Receive and dispatch events to application
* src/remote/remote_protocol.x: Wire protocol definition for the event
* src/qemu/qemu_monitor.c, src/qemu/qemu_monitor.h,
  src/qemu/qemu_monitor_json.c: Watch for BLOCK_STREAM_COMPLETED event
  from QEMU monitor

Signed-off-by: Adam Litke <agl@us.ibm.com>
2011-06-14 22:48:42 -06:00
Adam Litke
784ee08d22 Implement virDomainBlockPull for the qemu driver
The virDomainBlockPull* family of commands are enabled by the
'block_stream' and 'info block_stream' qemu monitor commands.

* src/qemu/qemu_driver.c src/qemu/qemu_monitor_text.[ch]: implement disk
  streaming by using the stream and info stream text monitor commands
* src/qemu/qemu_monitor_json.[ch]: implement commands using the qmp monitor

Signed-off-by: Adam Litke <agl@us.ibm.com>
Acked-by: Daniel P. Berrange <berrange@redhat.com>
2011-06-14 22:02:06 -06:00