]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
10 years agoDo not crash on gluster snapshots with no host name
Ján Tomko [Wed, 12 Nov 2014 08:34:28 +0000 (09:34 +0100)]
Do not crash on gluster snapshots with no host name

virStorageFileBackendGlusterInit did not check nhosts.

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

10 years agoDisplay nicer error message for unsupported chardev hotplug
Ján Tomko [Mon, 10 Nov 2014 15:52:49 +0000 (16:52 +0100)]
Display nicer error message for unsupported chardev hotplug

Use the device type name if we know it instead of its number,
even if we can't hotplug it:
qemuMonitorJSONAttachCharDevCommand:6094 : operation failed: Unsupported
char device type '10'

10 years agoFix virDomainChrEquals for spicevmc
Ján Tomko [Mon, 10 Nov 2014 15:40:49 +0000 (16:40 +0100)]
Fix virDomainChrEquals for spicevmc

virDomainChrSourceDefIsEqual should return 'true' for
identical SPICEVMC chardevs, and those that have no source
specification.

After this change, a failed hotplug no longer leaves a stale
pointer in the domain definition.

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

10 years agoqemu: fix domain startup failing with 'strict' mode in numatune
Wang Rui [Mon, 10 Nov 2014 13:53:19 +0000 (21:53 +0800)]
qemu: fix domain startup failing with 'strict' mode in numatune

If the memory mode is specified as 'strict' and with one node, we
get the following error when starting domain.

error: Unable to write to '$cgroup_path/cpuset.mems': Device or resource busy

XML is configured with numatune as follows:
  <numatune>
    <memory mode='strict' nodeset='0'/>
  </numatune>

It's broken by Commit 411cea638f6ec8503b7142a31e58b1cd85dbeaba
which moved qemuSetupCgroupForEmulator() before setting cpuset.mems
in qemuSetupCgroupPostInit.

Directory '$cgroup_path/emulator/' is created in qemuSetupCgroupForEmulator.
But '$cgroup_path/emulator/cpuset.mems' it not set and has a default value
(all nodes, such as 0-1). Then we setup '$cgroup_path/cpuset.mems' to the
nodemask (in this case it's '0') in qemuSetupCgroupPostInit. It must fail.

This patch makes '$cgroup_path/emulator/cpuset.mems' is set before
'$cgroup_path/cpuset.mems'. The action is similar with that in
qemuDomainSetNumaParamsLive.

Signed-off-by: Wang Rui <moon.wangrui@huawei.com>
10 years agolxc: don't setup cpuset.mems if memory mode in numatune is not 'strict'
Wang Rui [Mon, 10 Nov 2014 13:53:18 +0000 (21:53 +0800)]
lxc: don't setup cpuset.mems if memory mode in numatune is not 'strict'

If the memory mode in numatune is not 'strict', we should not setup
cpuset.mems. Before commit 1a7be8c600905aa07ac2d78293336ba8523ad48e
we have checked the memory mode in virDomainNumatuneGetNodeset. This
patch adds the check as before.

Signed-off-by: Wang Rui <moon.wangrui@huawei.com>
10 years agoqemu: don't setup cpuset.mems if memory mode in numatune is not 'strict'
Wang Rui [Mon, 10 Nov 2014 13:53:17 +0000 (21:53 +0800)]
qemu: don't setup cpuset.mems if memory mode in numatune is not 'strict'

If the memory mode in numatune is specified as 'preferred' with one node
(such as nodeset='0'), domain's memory is not all in node 0 absolutely.
Assumption that node 0 doesn't have enough memory, memory can be allocated
on node 1 when qemu process startup. Then if we set cpuset.mems to '0',
it may invoke OOM.

Commit 1a7be8c600905aa07ac2d78293336ba8523ad48e changed the former logic of
checking memory mode in virDomainNumatuneGetNodeset. This patch adds the
check as before.

Signed-off-by: Wang Rui <moon.wangrui@huawei.com>
10 years agoFix invalid log, misused option types and a typo
Hao Liu [Tue, 11 Nov 2014 02:12:20 +0000 (10:12 +0800)]
Fix invalid log, misused option types and a typo

This patch fixes the following issues.

1)  When an invalid wwn is introduced, libvirt reports
    "Malformed wwn: %s". The template won't be replaced.

2)  "target" option for dompmsuspend and "xml" option for
    save-image-define are required options and should use
    VSH_OT_DATA instead of VSH_OT_STRING as an option type.

3)  A typo.

Signed-off-by: Hao Liu <hliu@redhat.com>
10 years agophyp: Fix NULL dereference in phypConnectOpen
Martin Kletzander [Fri, 7 Nov 2014 18:52:33 +0000 (19:52 +0100)]
phyp: Fix NULL dereference in phypConnectOpen

Coverity found out that commit cd490086 caused a possible NULL pointer
dereference.  This is due to the fact, that phyp_driver is NULL at the
time of closing the socket, instead of connection_data, which kept the
socket before the mentioned commit, could not be NULL.

However, internal_socket is still the local socket that can be
closed, even unconditionally, if we initialize it to -1.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agovirsh: Add bps_max and friends to virsh
Matthias Gatto [Wed, 29 Oct 2014 12:16:05 +0000 (13:16 +0100)]
virsh: Add bps_max and friends to virsh

Add the new throttle options to virsh, and send them to libvirt.

Signed-off-by: Matthias Gatto <matthias.gatto@outscale.com>
10 years agoqemu: Add bps_max and friends to qemu command generation
Matthias Gatto [Wed, 29 Oct 2014 12:16:04 +0000 (13:16 +0100)]
qemu: Add bps_max and friends to qemu command generation

Check the arability of the options with the current qemu binary,
add them in the varable opt if yes, print a message if not.

Signed-off-by: Matthias Gatto <matthias.gatto@outscale.com>
10 years agoqemu: Add bps_max and friends QMP suport
Matthias Gatto [Wed, 29 Oct 2014 12:16:03 +0000 (13:16 +0100)]
qemu: Add bps_max and friends QMP suport

Detect if the the qemu binary currently in use support the bps_max option,
If yes add it to the command, if not, just ignore the option.
We don't print error here, because the check for invalide arguments
has alerady been made in qemu_driver.c

Signed-off-by: Matthias Gatto <matthias.gatto@outscale.com>
10 years agoqemu: Add bps_max and friends qemu driver
Matthias Gatto [Mon, 10 Nov 2014 15:19:09 +0000 (16:19 +0100)]
qemu: Add bps_max and friends qemu driver

Add support for bps_max and friends in the driver part.
In the part checking if a qemu is running, check if the running binary
support bps_max, if not print an error message, if yes add it to
"info" variable

Signed-off-by: Matthias Gatto <matthias.gatto@outscale.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoqemu: Add Qemu capability for bps_max and friends
Matthias Gatto [Wed, 29 Oct 2014 12:16:01 +0000 (13:16 +0100)]
qemu: Add Qemu capability for bps_max and friends

Add the capability to detect if the qemu binary have the capability
to use bps_max and friends
Add a value in the enum virQEMUCapsFlags for the qemu capability.
Set it with virQEMUCapsSet if the binary suport bps_max and they friends.

Signed-off-by: Matthias Gatto <matthias.gatto@outscale.com>
10 years agoqemu: Modify the structure _virDomainBlockIoTuneInfo.
Matthias Gatto [Wed, 29 Oct 2014 12:16:00 +0000 (13:16 +0100)]
qemu: Modify the structure _virDomainBlockIoTuneInfo.

Modify the structure _virDomainBlockIoTuneInfo to support these the new
options.
Change the initialization of the variable expectedInfo in qemumonitorjsontest.c
to avoid compiling problem.
Add documentation about the new xml options

Signed-off-by: Matthias Gatto <matthias.gatto@outscale.com>
10 years agoqemu: Add define for the new throttle options
Matthias Gatto [Wed, 29 Oct 2014 12:15:59 +0000 (13:15 +0100)]
qemu: Add define for the new throttle options

Add defines for the new options total_bytes_sec_max, write_bytes_sec_max,
read_bytes_sec_max, total_iops_sec_max, write_iops_sec_max, read_iops_sec_max,
size_iops_sec.

Signed-off-by: Matthias Gatto <matthias.gatto@outscale.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agonodeinfo: report error when failure in nodeSetMemoryParameters
Jincheng Miao [Fri, 7 Nov 2014 10:27:00 +0000 (11:27 +0100)]
nodeinfo: report error when failure in nodeSetMemoryParameters

nodeSetMemoryParameters() will call nodeSetMemoryParameterValue()
to set parameters. But it just filter the return code '-2' as
failure. Indeed we should report error when rc is negative.

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

Signed-off-by: Jincheng Miao <jmiao@redhat.com>
10 years agocpu_conf: Allow specification of 'units' for @memory on numa nodes.
Prerna Saxena [Mon, 10 Nov 2014 11:52:58 +0000 (17:22 +0530)]
cpu_conf: Allow specification of 'units' for @memory on numa nodes.

CPU numa topology implicitly allows memory specification in 'KiB'.

Enabling this to accept the 'unit' in which memory needs to be specified.
This now allows users to specify memory in units of choice, and
lists the same in 'KiB' -- just like other 'memory' elements in XML.

    <numa>
      <cell cpus='0-3' memory='1024' unit='MiB' />
      <cell cpus='4-7' memory='1024' unit='MiB' />
    </numa>

Also augment test cases to correctly model NUMA memory specification.
This adds the tag 'unit="KiB"' for memory attribute in NUMA cells.

Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoconf: Expose virDomainParseMemory for use outside domain_conf
Prerna Saxena [Mon, 10 Nov 2014 11:52:05 +0000 (17:22 +0530)]
conf: Expose virDomainParseMemory for use outside domain_conf

Commit 01b4de2b9f5ca82 abstracts virDomainParseMemory()
for use by other functions in domain_conf.c
Extend the same for use, for functions outside of this file.

Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoesx: Simplify VI (vSphere) API and VMware product version handling
Matthias Bolte [Sat, 18 Oct 2014 22:11:13 +0000 (00:11 +0200)]
esx: Simplify VI (vSphere) API and VMware product version handling

Store version numbers in this format

version = 1000000 * major + 1000 * minor + micro

produced by virParseVersionString instead of dedicated enums.

Split the complex esxVI_ProductVersion enum into a simpler
esxVI_ProductLine enum and a product version number.

Relax API and product version number checks to accept everything that
is equal or greater than the supported minimum version. VMware ESX
went through 3 major versions and the vSphere API always stayed
backward compatible. This commit assumes that this will also be true
for future VMware ESX versions.

Also reword error messages in esxConnectTo* to say what was expected
and what was found instead (suggested by Richard W.M. Jones).

10 years agodomain_conf: Use virDomainParseMemory more widely
Michal Privoznik [Fri, 7 Nov 2014 14:14:11 +0000 (15:14 +0100)]
domain_conf: Use virDomainParseMemory more widely

As reviewing patches upstream it occurred to me, that we have two
functions doing nearly the same: virDomainParseMemory which
expects XML in the following format:

  <memory unit='MiB'>1337</memory>

The other function being virDomainHugepagesParseXML expecting the
following format:

  <someElement size='1337' unit='MiB'/>

It wouldn't matter to have two functions handle two different
scenarios like this if we could only not copy code that handles
32bit arches around. So this code merges the common parts into
one by inventing new @units_xpath argument to
virDomainParseMemory which allows overriding the default location
of @unit attribute in XML. With this change both scenarios above
can be parsed with virDomainParseMemory.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoTransform VIR_ERROR into VIR_WARN in detect_scsi_host_caps
Cédric Bosdonnat [Tue, 4 Nov 2014 14:12:39 +0000 (15:12 +0100)]
Transform VIR_ERROR into VIR_WARN in detect_scsi_host_caps

If detect_scsi_host_caps reports errors but keeps libvirtd going on
startup, the user is misled by the error messages. Transforming them
into warning still shows the problems, but indicates this is not fatal.

10 years agovbox: Remove useless condition branches
Martin Kletzander [Thu, 6 Nov 2014 15:44:19 +0000 (16:44 +0100)]
vbox: Remove useless condition branches

These were probably left there after some code movement.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agovirnuma: add nodeset NULL check in virNumaSetupMemoryPolicy
Chen Fan [Fri, 7 Nov 2014 08:54:56 +0000 (16:54 +0800)]
virnuma: add nodeset NULL check in virNumaSetupMemoryPolicy

Introduced by commit c63ef0452b, when nodeset is NULL, validation will
pass in virNumaSetupMemoryPolicy, but virBitmapNextSetBit must ensure
bitmap is not NULL, otherwise that might cause a segmentation fault.
This patch fixes it.

Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
10 years agoRemove use of networkPrivateData from netcf driver
Daniel P. Berrange [Thu, 23 Oct 2014 14:17:18 +0000 (15:17 +0100)]
Remove use of networkPrivateData from netcf driver

The shared netcf driver is stateful and inside the daemon so
there is no need to use the networkPrivateData field to get the
driver handle. Just access the global driver handle directly.

10 years agoRemove use of networkPrivateData from network driver
Daniel P. Berrange [Thu, 23 Oct 2014 14:17:18 +0000 (15:17 +0100)]
Remove use of networkPrivateData from network driver

The shared network driver is stateful and inside the daemon so
there is no need to use the networkPrivateData field to get the
driver handle. Just access the global driver handle directly.

Many places already directly accessed the global driver handle
in any case, so the code could never work without relying on
this.

10 years agoRemove use of storagePrivateData from storage driver
Daniel P. Berrange [Thu, 23 Oct 2014 14:17:18 +0000 (15:17 +0100)]
Remove use of storagePrivateData from storage driver

The shared storage driver is stateful and inside the daemon so
there is no need to use the storagePrivateData field to get the
driver handle. Just access the global driver handle directly.

10 years agoUpdate Test driver to always use privateData
Daniel P. Berrange [Thu, 23 Oct 2014 13:33:11 +0000 (14:33 +0100)]
Update Test driver to always use privateData

Since the secondary drivers are only active when the primary
driver is also the Test driver, there is no need to use the
different type specific privateData fields.

10 years agoUpdate Parallels driver to always use privateData
Daniel P. Berrange [Thu, 23 Oct 2014 13:33:11 +0000 (14:33 +0100)]
Update Parallels driver to always use privateData

Since the secondary drivers are only active when the primary
driver is also the Parallels driver, there is no need to use the
different type specific privateData fields. The object that was
being stored in the storagePrivateData can easily be kept in the
parallelsConn struct instead.

10 years agoRemove abuse of networkPrivateData in phyp driver
Daniel P. Berrange [Thu, 23 Oct 2014 13:54:41 +0000 (14:54 +0100)]
Remove abuse of networkPrivateData in phyp driver

For inexplicable reasons the phyp driver defined two separate
structs for holding its private data. One it keeps in privateData
and the other it keeps in networkPrivateData. It uses them both
from all API driver methods. Merge the two separate structs
into one to remove this horrible abuse.

10 years agoMove phyp internal info out of the header file
Daniel P. Berrange [Thu, 23 Oct 2014 13:46:25 +0000 (14:46 +0100)]
Move phyp internal info out of the header file

The phyp_driver.h file has various declarations that are only
ever used from phyp_driver.c, so they should be in the .c file
only.

10 years agoUpdate Hyper-V driver to always use privateData
Daniel P. Berrange [Thu, 23 Oct 2014 13:33:11 +0000 (14:33 +0100)]
Update Hyper-V driver to always use privateData

Since the secondary drivers are only active when the primary
driver is also the Hyper-V driver, there is no need to use the
different type specific privateData fields.

10 years agoUpdate ESX driver to always use privateData
Daniel P. Berrange [Thu, 23 Oct 2014 13:33:11 +0000 (14:33 +0100)]
Update ESX driver to always use privateData

Since the secondary drivers are only active when the primary
driver is also the ESX driver, there is no need to use the
different type specific privateData fields.

10 years agoUpdate remote driver to always use privateData
Daniel P. Berrange [Thu, 23 Oct 2014 13:33:11 +0000 (14:33 +0100)]
Update remote driver to always use privateData

Since the secondary drivers are only active when the primary
driver is also the remote driver, there is no need to use the
different type specific privateData fields.

10 years agoClean up remote driver connection open code
Daniel P. Berrange [Thu, 23 Oct 2014 13:25:07 +0000 (14:25 +0100)]
Clean up remote driver connection open code

The remote driver has had a long term hack to deal with the fact
that the old Xen driver worked outside libvirtd, but the rest
of the drivers worked inside. So you could have a local hypervisor
driver but everything else go via the remote driver. The Xen driver
long ago moved inside libvirtd, so this hack is no longer needed.
Thus we should open use the remote driver for secondary drivers
if the primary driver is already the remote driver.

10 years agodoc: fix mismatched ACL attribute name
Luyao Huang [Fri, 7 Nov 2014 09:35:33 +0000 (17:35 +0800)]
doc: fix mismatched ACL attribute name

As documented in https://bugzilla.redhat.com/show_bug.cgi?id=1161358,
the ACL attribute should be named: interface_macaddr

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoTest: Add a testcase for PowerPC compat mode cpu specification.
Prerna Saxena [Tue, 4 Nov 2014 17:32:15 +0000 (23:02 +0530)]
Test: Add a testcase for PowerPC compat mode cpu specification.

This introduces a testcase for PowerPC compat mode cpu specification.

Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 years agodocs: Add documentation for compat mode.
Prerna Saxena [Tue, 4 Nov 2014 17:30:36 +0000 (23:00 +0530)]
docs: Add documentation for compat mode.

Add documentation to explain how compat-mode can be invoked with libvirt
running on PowerPC architecture.
It also mentions that this change is available libvirt 1.2.11 onwards.

Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoPowerPC:Improve PVR handling to fall back to cpu generation.
Prerna Saxena [Tue, 4 Nov 2014 17:28:33 +0000 (22:58 +0530)]
PowerPC:Improve PVR handling to fall back to cpu generation.

IBM Power processors differ uniquely across generations (such as power6,
power7, power8). Each generation signifies a new PowerISA version
that exhibits features unique to that generation.
The higher 16 bits of PVR for IBM Power processors encode the CPU
generation, while the CPU chip (sub)version is encoded in lower 16 bits.

For all practical purposes of launching a VM, we care about the
generation which the vCPU will belong to, and not specifically the chip
version. This patch updates the libvirt PVR check to reflect this
relationship. It allows libvirt to select the right CPU generation
in case the exact match for a a specific CPU is not found.
Hence, there will no longer be a need to add each PowerPC CPU model to
cpu_map.xml; just adding entry for the matching ISA generation will
suffice.

It also contains changes to cpu_map.xml since processor generations
as understood by QEMU compat mode go as "power6", "power7" or "power8"
[Reference : QEMU commit 8dfa3a5e85 ]

Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
Signed-off-by: Pradipta Kr. Banerjee <bpradip@in.ibm.com>
Signed-off-by: Anton Blanchard <anton@samba.org>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoPowerPC : Add support for launching VM in 'compat' mode.
Prerna Saxena [Tue, 4 Nov 2014 17:22:44 +0000 (22:52 +0530)]
PowerPC : Add support for launching VM in 'compat' mode.

PowerISA allows processors to run VMs in binary compatibility ("compat")
mode supporting an older version of ISA. QEMU has recently added support to
explicitly denote a VM running in compatibility mode through commit 6d9412ea
8dfa3a5e85. Now, a "compat" mode VM can be run by invoking this qemu
commandline on a POWER8 host:  -cpu host,compat=power7.

This patch allows libvirt to exploit cpu mode 'host-model' to describe this
new mode for PowerKVM guests. For example, when a user wants to request a
power7 vm to run in compatibility mode on a Power8 host, this can be
described in XML as follows :

  <cpu mode='host-model'>
    <model>power7</model>
  </cpu>

Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com>
Signed-off-by: Pradipta Kr. Banerjee <bpradip@in.ibm.com>
Acked-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoCpu: Add support for Power LE Architecture.
Prerna Saxena [Tue, 4 Nov 2014 17:21:26 +0000 (22:51 +0530)]
Cpu: Add support for Power LE Architecture.

This adds support for PowerPC Little Endian architecture.,
and allows libvirt to spawn VMs based on 'ppc64le' architecture.

Signed-off-by: Pradipta Kr. Banerjee <bpradip@in.ibm.com>
Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
10 years agogitignore: use wildcard for configure's temporary files
Martin Kletzander [Thu, 6 Nov 2014 15:53:28 +0000 (16:53 +0100)]
gitignore: use wildcard for configure's temporary files

Pushed as trivial and pre-ACK'd here:

https://www.redhat.com/archives/libvir-list/2014-November/msg00180.html

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoFix build-time pkg-config files in VPATH
Jiri Denemark [Thu, 6 Nov 2014 09:59:44 +0000 (10:59 +0100)]
Fix build-time pkg-config files in VPATH

Since libvirt.h was split into several files, it is impossible to
compile anything against a VPATH-built libvirt. In VPATH, only libvirt.h
is in build/include/libvirt while all other libvirt-*.h files are in
source/include/libvirt.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agovirnetdevbandwidth: Include virutil.h
Michal Privoznik [Thu, 6 Nov 2014 14:30:13 +0000 (15:30 +0100)]
virnetdevbandwidth: Include virutil.h

One of the latest patches (9a8fc3efc2470) introduced call of
geteuid(). However, not all systems have the function
implemented, e.g. mingw. Therefore, we fail to build on those
system. The fix consist of including virutil.h which defines
geteuid in needed. Sigh.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoqemu: Update fsfreeze status on domain state transitions
Michal Privoznik [Mon, 3 Nov 2014 11:57:44 +0000 (12:57 +0100)]
qemu: Update fsfreeze status on domain state transitions

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

As of b6d4dad1 (1.2.5) libvirt keeps track if domain disks have been
frozen. However, this falls into that set of information which don't
survive domain restart. Therefore, we need to clear the flag upon some
state transitions. Moreover, once we clear the flag we must update the
status file too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoqemu: Allow use of iothreads for virtio ccw disk definitions
Boris Fiuczynski [Thu, 6 Nov 2014 14:04:05 +0000 (15:04 +0100)]
qemu: Allow use of iothreads for virtio ccw disk definitions

Extending the iothread disk support from pci to pci and ccw.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Reviewed-by: Christian Borntraeger <borntraeger@de.ibm.com>
10 years agoqemu: Correct disk type checking logic for iothreads
Boris Fiuczynski [Thu, 6 Nov 2014 14:04:04 +0000 (15:04 +0100)]
qemu: Correct disk type checking logic for iothreads

Finding the right type of disk should check for virtio as bus and
pci as device address type.

Signed-off-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
Reviewed-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
10 years agovirsh: fix net-dhcp-leases no output in quiet mode
Luyao Huang [Sat, 1 Nov 2014 10:41:20 +0000 (18:41 +0800)]
virsh: fix net-dhcp-leases no output in quiet mode

When run net-dhcp-leases in quiet mode, cannot get
any output.

 # virsh -q net-dhcp-leases default

Signed-off-by: Luyao Huang <lhuang@redhat.com>
10 years agonetwork: fix call virNetworkEventLifecycleNew when networkStartNetwork fail
Luyao Huang [Sat, 1 Nov 2014 10:03:23 +0000 (18:03 +0800)]
network: fix call virNetworkEventLifecycleNew when networkStartNetwork fail

When start a network fail, libvirt still call virNetworkEventLifecycleNew
to send a event.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
10 years agonuma: fix assumption in virNumaNodeIsAvailable()
Martin Kletzander [Thu, 6 Nov 2014 11:17:10 +0000 (12:17 +0100)]
numa: fix assumption in virNumaNodeIsAvailable()

When compiled without full numa support, the stub function for
virNumaNodeIsAvailable() just checks whether specified node is in range
<0, max); where max is maximum NUMA node available on the host.  But
because the maximum node number is the highest usabe number (and not the
count of nodes), the check is incorrect as it should check whether the
specified node is in range <0, max> instead.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agonuma: split util/ and conf/ and support non-contiguous nodesets
Martin Kletzander [Thu, 6 Nov 2014 11:16:54 +0000 (12:16 +0100)]
numa: split util/ and conf/ and support non-contiguous nodesets

This is a reaction to Michal's fix [1] for non-NUMA systems that also
splits out conf/ out of util/ because libvirt_util shouldn't require
libvirt_conf if it is the other way around.  This particular use case
worked, but we're trying to avoid it as mentioned [2], many times.

The only functions from virnuma.c that needed numatune_conf were
virDomainNumatuneNodesetIsAvailable() and virNumaSetupMemoryPolicy().
The first one should be in numatune_conf as it works with
virDomainNumatune, the second one just needs nodeset and mode, both of
which can be passed without the need of numatune_conf.

Apart from fixing that, this patch also fixes recently added
code (between commits d2460f85^..5c8515620) that doesn't support
non-contiguous nodesets.  It uses new function
virNumaNodesetIsAvailable(), which doesn't need a stub as it doesn't use
any libnuma functions, to check if every specified nodeset is available.

[1] https://www.redhat.com/archives/libvir-list/2014-November/msg00118.html
[2] http://www.redhat.com/archives/libvir-list/2011-June/msg01040.html

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoadd temporary compilation files into .gitignore
Martin Kletzander [Thu, 6 Nov 2014 11:17:19 +0000 (12:17 +0100)]
add temporary compilation files into .gitignore

When using git-status during configure phase, three additional files are
shown as untracked.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoIface: disallow network tuning in session mode globally
Erik Skultety [Thu, 6 Nov 2014 11:38:52 +0000 (12:38 +0100)]
Iface: disallow network tuning in session mode globally

Patch 43b67f2e disallowed network tuning only with qemu driver, however
this patch moved the check for root privileges into
virNetDevBandwidthSet function, so the call should now
fail in all possible cases. A mock function was created so that the test
suite doesn't fail because of unsufficient privileges.

10 years agoqemu: revert patch - bandwidth tuning in session mode
Erik Skultety [Thu, 6 Nov 2014 11:38:51 +0000 (12:38 +0100)]
qemu: revert patch - bandwidth tuning in session mode

Since there was a valid note to patch 43b67f2e about the best spot to
check for bandwidth set call while having libvirt daemon run in session
mode, this patch reverts previous changes dealing with bandwith
(also reverts adding variable @cfg in qemuDomainGetNumaParameters which
 does not have any use at the moment, but getting and unreferencing
 driver's config) in qemu_driver.c and qemu_command.c. There will be
another patch in the series which introduces the fix itself.

10 years agoFree job statistics from the migration cookie
Ján Tomko [Thu, 6 Nov 2014 11:24:46 +0000 (12:24 +0100)]
Free job statistics from the migration cookie

==404== 232 bytes in 1 blocks are definitely lost in loss record 669 of 758
==404==    at 0x4C2B934: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==404==    by 0x52A2BF3: virAlloc (viralloc.c:144)
==404==    by 0x1D49AD70: qemuMigrationCookieAddStatistics (qemu_migration.c:554)
==404==    by 0x1D49AD70: qemuMigrationBakeCookie (qemu_migration.c:1228)
==404==    by 0x1D4A43B8: qemuMigrationFinish (qemu_migration.c:5002)
==404==    by 0x1D4C9339: qemuDomainMigrateFinish3Params (qemu_driver.c:11526)

Introduced by commit 5d6fb96

10 years agovirsh: Fix types for option bandwidth in block*
Hao Liu [Thu, 6 Nov 2014 08:01:00 +0000 (09:01 +0100)]
virsh: Fix types for option bandwidth in block*

Bandwidth options in blockcommit, blockcopy, blockjob and blockpull
are parsed by vshCommandOptULWrap() and should be shown as a number
type option.

And a typo is fixed.

Signed-off-by: Hao Liu <hliu@redhat.com>
10 years agoprivate.syms: Export virDomainNumatuneSpecifiedMaxNode
Michal Privoznik [Wed, 5 Nov 2014 16:58:30 +0000 (17:58 +0100)]
private.syms: Export virDomainNumatuneSpecifiedMaxNode

As of 90286418 the function is introduced. However, it's missing
an entry in the libvirt_private.syms so it can't be mocked.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirnuma: Add some more comments
Michal Privoznik [Wed, 5 Nov 2014 16:51:27 +0000 (17:51 +0100)]
virnuma: Add some more comments

Well, in fact only add comments to mark ifdef,
else and endif sections.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoCVE-2014-7823: dumpxml: security hole with migratable flag
Eric Blake [Sat, 1 Nov 2014 04:14:07 +0000 (22:14 -0600)]
CVE-2014-7823: dumpxml: security hole with migratable flag

Commit 28f8dfd (v1.0.0) introduced a security hole: in at least
the qemu implementation of virDomainGetXMLDesc, the use of the
flag VIR_DOMAIN_XML_MIGRATABLE (which is usable from a read-only
connection) triggers the implicit use of VIR_DOMAIN_XML_SECURE
prior to calling qemuDomainFormatXML.  However, the use of
VIR_DOMAIN_XML_SECURE is supposed to be restricted to read-write
clients only.  This patch treats the migratable flag as requiring
the same permissions, rather than analyzing what might break if
migratable xml no longer includes secret information.

Fortunately, the information leak is low-risk: all that is gated
by the VIR_DOMAIN_XML_SECURE flag is the VNC connection password;
but VNC passwords are already weak (FIPS forbids their use, and
on a non-FIPS machine, anyone stupid enough to trust a max-8-byte
password sent in plaintext over the network deserves what they
get).  SPICE offers better security than VNC, and all other
secrets are properly protected by use of virSecret associations
rather than direct output in domain XML.

* src/remote/remote_protocol.x (REMOTE_PROC_DOMAIN_GET_XML_DESC):
Tighten rules on use of migratable flag.
* src/libvirt-domain.c (virDomainGetXMLDesc): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoqemuDomainUpdateDeviceConfig: Allow startupPolicy update
Michal Privoznik [Tue, 28 Oct 2014 18:50:43 +0000 (19:50 +0100)]
qemuDomainUpdateDeviceConfig: Allow startupPolicy update

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

Users might want to update startupPolicy via the
virDomainUpdateDeviceFlags API too. This patch
implements the feature on config layer.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoremote: Fix memory leak in remoteConnectGetAllDomainStats
Peter Krempa [Wed, 5 Nov 2014 11:34:51 +0000 (12:34 +0100)]
remote: Fix memory leak in remoteConnectGetAllDomainStats

The remote call actually doesn't free the arguments array so we leak
memory in case a domain list is specified. As the remote domain list
array consists only of stolen pointers from the actual domain objects
it's sufficient just to free the array.

Valgrind message:
==1081452== 64 bytes in 1 blocks are definitely lost in loss record 632 of 726
==1081452==    at 0x4C296D0: calloc (vg_replace_malloc.c:618)
==1081452==    by 0x4EA5CB4: virAllocN (viralloc.c:191)
==1081452==    by 0x505D21E: remoteConnectGetAllDomainStats (remote_driver.c:7785)
==1081452==    by 0x50081AA: virDomainListGetStats (libvirt-domain.c:11080)
==1081452==    by 0x155249: cmdDomstats (virsh-domain-monitor.c:2147)
==1081452==    by 0x12FB73: vshCommandRun (virsh.c:1935)
==1081452==    by 0x133FEB: main (virsh.c:3719)

10 years agoMemory: Use consistent type for all memory elements.
Prerna Saxena [Fri, 31 Oct 2014 10:37:21 +0000 (16:07 +0530)]
Memory: Use consistent type for all memory elements.

Domain memory elements such as max_balloon and cur_balloon are
implemented as 'unsigned long long', whereas the 'memory' element
in NUMA cells is implemented as 'unsigned int'.

Use the same data type (unsigned long long) for 'memory' element
in NUMA cells.

Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
10 years agoRequire at least one console for LXC domain
Ján Tomko [Fri, 31 Oct 2014 08:51:23 +0000 (09:51 +0100)]
Require at least one console for LXC domain

A domain without a console quietly dies soon after start,
because we try to set /dev/null as a controlling TTY
2014-10-30 15:10:59.705+0000: 1: error : lxcContainerSetupFDs:283 :
ioctl(TIOCSCTTY) failed: Inappropriate ioctl for device

Report an error early instead of trying to start it.

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

10 years agoDo not probe for power mgmt capabilities in lxc emulator
Ján Tomko [Fri, 31 Oct 2014 09:02:22 +0000 (10:02 +0100)]
Do not probe for power mgmt capabilities in lxc emulator

It fails after 30 seconds with this error:
error : virDBusCall:1429 : error from service: CanSuspend:
Did not receive a reply. Possible causes include: the remote
application did not send a reply, the message bus security
policy blocked the reply, the reply timeout expired, or the
network connection was broken.

Only probe for the power mgmt capabilities when driver is non-NULL.
This speeds up domain startup by 30 seconds.

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

10 years agoutil: fix releasing pidfile in cleanup
Martin Kletzander [Tue, 4 Nov 2014 09:46:41 +0000 (10:46 +0100)]
util: fix releasing pidfile in cleanup

Coverity found out the very obvious problem in the code.  That is that
virPidFileReleasePath() was called only if
virPidFileAcquirePath() returned 0.  But virPidFileAcquirePath() doesn't
return only 0 on success, but the FD that needs to be closed.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoqemu: stop NBD server after successful migration
Weiwei Li [Tue, 4 Nov 2014 09:52:10 +0000 (10:52 +0100)]
qemu: stop NBD server after successful migration

In qemuMigrationFinish mig->nbd can not be initialized by
qemuMigrationEatCookie without the QEMU_MIGRATION_COOKIE_NBD flag.
That causes qemuMigrationStopNBDServer to return early without
stopping the NBD server properly.

Signed-off-by: Weiwei Li <nuonuoli@tencent.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
10 years agovirnuma: use virNumaNodesetIsAvailable checking nodeset in virNumaSetupMemoryPolicy
Chen Fan [Tue, 4 Nov 2014 02:44:41 +0000 (10:44 +0800)]
virnuma: use virNumaNodesetIsAvailable checking nodeset in virNumaSetupMemoryPolicy

Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
10 years agonumatune: add check for numatune nodeset range
Chen Fan [Tue, 4 Nov 2014 02:44:40 +0000 (10:44 +0800)]
numatune: add check for numatune nodeset range

There was no check for 'nodeset' attribute in numatune-related
elements.  This patch adds validation that any nodeset specified does
not exceed maximum host node.

Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
10 years agobitmap: add virBitmapLastSetBit for finding the last bit position of bitmap
Chen Fan [Tue, 4 Nov 2014 02:44:39 +0000 (10:44 +0800)]
bitmap: add virBitmapLastSetBit for finding the last bit position of bitmap

Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
10 years agoexamples: add systemtap script to ease lock debugging
Martin Kletzander [Wed, 13 Aug 2014 13:52:34 +0000 (15:52 +0200)]
examples: add systemtap script to ease lock debugging

As discussed before, this simple script should help with debugging
deadlocks, although there are still some caveats.  RWLocks are not
handled by this and if your deadlock if very racy, it may not lock
up when running with this script due to the slowdown.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoqemu: avoid rare race when undefining domain
Martin Kletzander [Thu, 30 Oct 2014 13:38:35 +0000 (14:38 +0100)]
qemu: avoid rare race when undefining domain

When one domain is being undefined and at the same time started, for
example, there is a possibility of a rare problem occuring.

 - Thread 1 does virDomainUndefine(), has the lock, checks that the
   domain is active and because it's not, calls
   virDomainObjListRemove().

 - Thread 2 does virDomainCreate() and tries to lock the domain.

 - Thread 1 needs to lock domain list in order to remove the domain from
   it, but must unlock domain first (proper order is to lock domain list
   first and the domain itself second).

 - Thread 2 grabs the lock, starts the domain and releases the lock.

 - Thread 1 grabs the lock and removes the domain from list.

With this patch:

 - qemuDomainRemoveInactive() creates a QEMU_JOB_MODIFY if that's
   possible, but since it must remove the domain from list either way,
   it continues even when starting the job failed.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agovirsh: don't list unknown domains
Martin Kletzander [Thu, 30 Oct 2014 13:39:04 +0000 (14:39 +0100)]
virsh: don't list unknown domains

When the list of domains is fetched and being printed, but in the
meantime one domain was undefined before its status was fetched, the
output then includes domain with "no state".  With this patch, such
domain is skipped over as consecutive 'virsh list --all' (or the same
one ran a second later) wouldn't list it anyway.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agolxc: improve error message for invalid blkiotune settings
Martin Kletzander [Wed, 29 Oct 2014 15:36:39 +0000 (16:36 +0100)]
lxc: improve error message for invalid blkiotune settings

Before:
  $ virsh blkiotune dummy --device-read-bytes-sec /dev/sda,-1
  error: Unable to change blkio parameters
  error: invalid argument: unable to parse blkio device
  'device_read_bytes_sec' '/dev/sda,-1'

After:
  $ virsh blkiotune dummy --device-read-bytes-sec /dev/sda,-1
  error: Unable to change blkio parameters
  error: invalid argument: invalid value '-1' for parameter
  'device_read_bytes_sec' of device '/dev/sda'

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoqemu: improve error message for invalid blkiotune settings
Martin Kletzander [Wed, 29 Oct 2014 15:36:39 +0000 (16:36 +0100)]
qemu: improve error message for invalid blkiotune settings

Before:
  $ virsh blkiotune dummy --device-read-bytes-sec /dev/sda,-1
  error: Unable to change blkio parameters
  error: invalid argument: unable to parse blkio device
  'device_read_bytes_sec' '/dev/sda,-1'

After:
  $ virsh blkiotune dummy --device-read-bytes-sec /dev/sda,-1
  error: Unable to change blkio parameters
  error: invalid argument: invalid value '-1' for parameter
  'device_read_bytes_sec' of device '/dev/sda'

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoqemu: make sure capability probing process can start
Martin Kletzander [Thu, 9 Oct 2014 06:18:33 +0000 (08:18 +0200)]
qemu: make sure capability probing process can start

When daemon is killed right in the middle of probing a qemu binary for
its capabilities, the qemu process is left running.  Next time the
daemon is starting, it cannot start the probing qemu process because the
one that's already running does have the pidfile flock()'d.

Reported-by: Wang Yufei <james.wangyufei@huawei.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoutil: Introduce virPidFileForceCleanupPath
Martin Kletzander [Sun, 12 Oct 2014 11:40:36 +0000 (13:40 +0200)]
util: Introduce virPidFileForceCleanupPath

This function is used to cleanup a pidfile doing whatever it takes, even
killing the owning process.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agovbox: don't register NULL driver
Martin Kletzander [Thu, 30 Oct 2014 08:56:26 +0000 (09:56 +0100)]
vbox: don't register NULL driver

We were missing check for the fact that the storage driver was found and
in case there is no vbox storage driver available, daemon raised the
following error each start:

  error : virRegisterStorageDriver:592 : driver in
  virRegisterStorageDriver must not be NULL

Fixing this makes the condition unified with networkDriver registration
in vbox as well.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoqemu: make advice from numad available when building commandline
Martin Kletzander [Thu, 30 Oct 2014 06:34:30 +0000 (07:34 +0100)]
qemu: make advice from numad available when building commandline

Particularly in qemuBuildNumaArgStr(), there was a need for the advice
due to memory backing, which needs to know the nodeset it will be pinned
to.  With newer qemu this caused the following error when starting
domain:

  error: internal error: Advice from numad is needed in case of
  automatic numa placement

even when starting perfectly valid domain, e.g.:

  ...
  <vcpu placement='auto'>4</vcpu>
  <numatune>
    <memory mode='strict' placement='auto'/>
  </numatune>
  <cpu>
    <numa>
      <cell id='0' cpus='0' memory='524288'/>
      <cell id='1' cpus='1' memory='524288'/>
    </numa>
  </cpu>
  ...

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoPost-release version bump for new dev cycle
John Ferlan [Mon, 3 Nov 2014 15:40:44 +0000 (10:40 -0500)]
Post-release version bump for new dev cycle

10 years agoRelease of libvirt-1.2.10
Daniel Veillard [Mon, 3 Nov 2014 06:32:39 +0000 (14:32 +0800)]
Release of libvirt-1.2.10

- docs/news.html.in libvirt.spec.in: update for release
- po/*.po*: fetched loclalization and regenerated

10 years agohotplug: fix char device detach
Pavel Hrdina [Fri, 31 Oct 2014 13:59:55 +0000 (14:59 +0100)]
hotplug: fix char device detach

Hotplugging and hotunplugging char devices is only supported through
'-device' and the check for device capability should be independently.

Coverity also complains about 'tmpChr->info.alias' could be NULL and we
are dereferencing it but it somehow only in this case don't recognize
that the value is set by 'qemuAssignDeviceChrAlias' so it's clearly
false positive. Add sa_assert to make coverity happy.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agovbox_storage: fix coverity issue with overwriting value
Pavel Hrdina [Fri, 31 Oct 2014 12:08:43 +0000 (13:08 +0100)]
vbox_storage: fix coverity issue with overwriting value

Coverity is complaining about overwriting value in 'rc' variable
without using the old value because it somehow doesn't recognize that
the value is used by MACRO. The 'rc' variable is there only for checking
return code so it's save to remove it and make coverity happy.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agoRelax duplicate SCSI host pool checking
Ján Tomko [Sat, 1 Nov 2014 11:11:38 +0000 (12:11 +0100)]
Relax duplicate SCSI host pool checking

Since commit 3f99d64 no new scsi_host pools can be defined
if one of the already defined scsi_host pools does not refer
to an accessible scsi_host adapter.

Relax the check by skipping over these inaccessible pools
when checking for duplicates.

10 years agoMatch scsi_host pools by parent address first
Ján Tomko [Sat, 1 Nov 2014 11:10:17 +0000 (12:10 +0100)]
Match scsi_host pools by parent address first

If both source adapters are specified by a parent address,
just comparing the address is faster and catches even addresses
that do not refer to valid adapters.

10 years agomingw: fix build failure
Pavel Hrdina [Fri, 31 Oct 2014 18:00:19 +0000 (19:00 +0100)]
mingw: fix build failure

This macro seems to be defined only on linux/unix and it fails during
mingw build. Its value is '16' (taken from net/if.h) so define it if
it's not defined.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agodomain: fix parsing of memory tunables on 32-bit machines
Eric Blake [Thu, 30 Oct 2014 19:42:44 +0000 (13:42 -0600)]
domain: fix parsing of memory tunables on 32-bit machines

Commit 6c9a8a4 (Oct 2014) exposed a long-standing issue on 32-bit
machines: code related to virDomainSetMemoryParameters has always
been documented as using a 64-bit limit, but it was implemented by
calling virDomainParseMemory which enforced an 'unsigned long'
limit.  Since VIR_DOMAIN_MEMORY_PARAM_UNLIMITED capped to a
long is -1, but virDomainParseScaledValue no longer accepts
negative values, an attempt to use 2^53-1 as a hard memory limit
started failing the testsuite.  However, the problem with capping
things artificially low has existed for much longer - ever since
commits 4888f0fb and 2e22f23 (Mar 2012) switched internal tracking
from 'unsigned long' to 'unsigned long long' (prior to that time,
the cap was a side-effect of the choice of types).  We _have_ to
cap the balloon memory values, (no thanks to baked in 'unsigned long'
of API such as virDomainSetMaxMemory or virDomainGetInfo with no
counterpart API that guarantees 64-bit access to those numbers)
but memory parameters have never needed the artificial limit.

At any rate, the solution is to make the parser function gain a
parameter, and only do the reduced 32-bit cap for the values that
are constrained due to API.

* src/conf/domain_conf.h (_virDomainMemtune): Add comments.
* src/conf/domain_conf.c (virDomainParseMemory): Add parameter.
(virDomainDefParseXML): Adjust callers.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoqemu: Release nbd port from migrationPorts instead of remotePorts
weiwei li [Fri, 31 Oct 2014 08:16:22 +0000 (16:16 +0800)]
qemu: Release nbd port from migrationPorts instead of remotePorts

commit 3e1e16aa8d4238241a1806cb9bdb3b9ad60db777 (Use a port from the
migration range for NBD as well) changed ndb port allocation from
remotePorts to migrationPorts, but did not change the port releasing
process, which makes an error when migrating several times (above 64):
error: internal error: Unable to find an unused port in range
'migration' (49152-49215)

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

Signed-off-by: Weiwei Li <nuonuoli@tencent.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
10 years agolibxl: fix double-free of libxl_domain_build_info
Jim Fehlig [Fri, 10 Oct 2014 21:39:46 +0000 (15:39 -0600)]
libxl: fix double-free of libxl_domain_build_info

On error, libxlMakeDomBuildInfo() frees the caller-provided
libxl_domain_build_info struct embedded in libxl_domain_config,
causing a segfault

Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7f9c13020700 (LWP 40988)]
(gdb) bt
0  0x00007f9c162f95b4 in free () from /lib64/libc.so.6
1  0x00007f9c0d0965ad in libxl_bitmap_dispose () from
   /usr/lib64/libxenlight.so.4.4
2  0x00007f9c0d0a73bf in libxl_domain_build_info_dispose ()
   from /usr/lib64/libxenlight.so.4.4
3  0x00007f9c0d0a7974 in libxl_domain_config_dispose () from
   /usr/lib64/libxenlight.so.4.4
4  0x00007f9c0d2e00c5 in libxlDomainStart (driver=0x7f9c0400e4e0,
   vm=0x7f9c0412b0d0, start_paused=false, restore_fd=-1) at
   libxl/libxl_domain.c:1323
5  0x00007f9c0d2e1d4b in libxlDomainCreateXML (conn=0x7f9c000009a0,...)
   at libxl/libxl_driver.c:660

Remove the call to libxl_domain_build_info_dispose() from
libxlMakeDomBuildInfo().  On error, callers will dispose the
libxl_domain_config object, which in turn disposes the build info.

10 years agolibxl: Support user-specified <emulator>
Jim Fehlig [Fri, 19 Sep 2014 19:03:18 +0000 (13:03 -0600)]
libxl: Support user-specified <emulator>

With the introduction of the libxlDomainGetEmulatorType function,
it is trivial to support a user-specfied <emulator> in the libxl
driver.  This patch is based loosely on David Scott's old patch
to do the same

https://www.redhat.com/archives/libvir-list/2013-April/msg02119.html
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
10 years agoSpell TIOCSCTTY right in the error message
Ján Tomko [Thu, 30 Oct 2014 16:13:00 +0000 (17:13 +0100)]
Spell TIOCSCTTY right in the error message

10 years agoReject live update of offloading options
Ján Tomko [Thu, 30 Oct 2014 12:32:00 +0000 (13:32 +0100)]
Reject live update of offloading options

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

10 years agoconf: forbid negative values in virDomainParseScaledValue
Martin Kletzander [Wed, 29 Oct 2014 16:29:40 +0000 (17:29 +0100)]
conf: forbid negative values in virDomainParseScaledValue

It makes sense for none of the callers to have negative value as an
output and, fortunately, if anyone tried defining domain with negative
memory or any other value parsed by virDomainParseScaledValue(), the
resulting value was 0.  That means we can error out during parsing as
it won't break anything.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agovirsh: Fix memory leak in cmdNetworkDHCPLeases
Luyao Huang [Thu, 30 Oct 2014 02:35:14 +0000 (10:35 +0800)]
virsh: Fix memory leak in cmdNetworkDHCPLeases

After cidr_format is allocated by virAsprintf and used by vshPrintExtra
it needs to be freed.

Fix the following memory leak from valgrind:
 18 bytes in 1 blocks are definitely lost in loss record 41 of 192
    at 0x4C29BBD: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
    by 0x85CE36F: __vasprintf_chk (vasprintf_chk.c:80)
    by 0x4EE52D5: UnknownInlinedFun (stdio2.h:210)
    by 0x4EE52D5: virVasprintfInternal (virstring.c:459)
    by 0x4EE53CA: virAsprintfInternal (virstring.c:480)
    by 0x14FE96: cmdNetworkDHCPLeases (virsh-network.c:1378)
    by 0x13006B: vshCommandRun (virsh.c:1915)
    by 0x12A9E1: main (virsh.c:3699)

Signed-off-by: Luyao Huang <lhuang@redhat.com>
10 years agovirutil: fix virGetSCSIHostNumber stub return type
Roman Bogorodskiy [Wed, 29 Oct 2014 18:20:48 +0000 (21:20 +0300)]
virutil: fix virGetSCSIHostNumber stub return type

The virGetSCSIHostNumber function return type is int, however
its stubbed version returns NULL. That results in a build fail
on systems that use the stubbed version. Fix by using a proper
return type.

10 years agovirnetdev: stub virNetDev{Add,Del}Multi on FreeBSD
Roman Bogorodskiy [Wed, 29 Oct 2014 18:20:47 +0000 (21:20 +0300)]
virnetdev: stub virNetDev{Add,Del}Multi on FreeBSD

Currently, build fails on FreeBSD because its struct ifreq does not
have ifr_hwaddr member. In order to fix that, check if this member
is present, otherwise fall back to the stub version of the
virNetDev{Add,Del}Multi functions.

10 years agovirnetdev: Resolve Coverity RESOURCE_LEAK
John Ferlan [Wed, 29 Oct 2014 22:29:43 +0000 (18:29 -0400)]
virnetdev: Resolve Coverity RESOURCE_LEAK

virFileReadAll returns a chunk of memory that needs to be free'd when
done

10 years agovirnetdev: Resolve Coverity FORWARD_NULL
John Ferlan [Wed, 29 Oct 2014 22:21:17 +0000 (18:21 -0400)]
virnetdev: Resolve Coverity FORWARD_NULL

The complaint is that if cleanup is called when virFileReadAll fails,
then mcast->entries is NULL and could be dereferenced in the clear
function. After following the code some - I saw that the caller to
the function (virNetDevGetMulticastTable) will also call
virNetDevMcastListClear if this function returns -1, so this
isn't necessary, so I removed the call.

10 years agovirnetdev: Resolve Coverity DEADCODE
John Ferlan [Wed, 29 Oct 2014 20:57:58 +0000 (16:57 -0400)]
virnetdev: Resolve Coverity DEADCODE

Coverity complains that because the for loop is from 0 to 5 (max tokens)
and the impending switch/case statements used each of the #define values
that the 'default' wouldn't reachable. This patch will convert the #define's
into enum's and add the obligatory dead_error_begin marker for these type
situations.

Signed-off-by: John Ferlan <jferlan@redhat.com>
10 years agoTeach virt-aa-helper to use TEMPLATE.qemu if the domain is kvm or kqemu
Cédric Bosdonnat [Tue, 28 Oct 2014 20:42:34 +0000 (14:42 -0600)]
Teach virt-aa-helper to use TEMPLATE.qemu if the domain is kvm or kqemu

10 years agoqemu: better error message when block job can't succeed
Eric Blake [Fri, 24 Oct 2014 20:49:13 +0000 (14:49 -0600)]
qemu: better error message when block job can't succeed

https://bugzilla.redhat.com/show_bug.cgi?id=1140981 reports that
the qemu-kvm shipped as part of RHEL 7.0 intentionally[1] cripples
block jobs by removing the 'block-stream' QMP command, while still
leaving 'block-job-cancel' as an unusable no-op.  Meanwhile, we
already had existing code that checked whether block jobs were
completely missing (such as qemu 0.15), old style (cancel is
synchronous, and all commands spelled with '_'), or new style
(cancel is asynchronous, and all commands spelled with '-'), and
used that three-way probe to give decent error messages.  At the
time that code was added, all existing qemu versions fell in one
of three buckets, and the code was using the presence of
'block-job-cancel' as the witness of which of the three buckets.
But now that RHEL qemu has shipped with intentionally crippled
'block-stream', we have a fourth bucket, which results in ugly
error messages when trying 'virsh blockpull':

 error: Requested operation is not valid: Command 'block-stream' is not found

In reality, the fourth bucket should be treated the same as the
first bucket (no block job support); we can do that by realizing
that no existing build of qemu has working block-stream while
lacking block-job-cancel, so it is easiest to change our witness
to the command that starts a job rather than ends one.  We still
act correctly regarding command spelling and whether cancel is
asynchronous.  And on crippled RHEL builds, we now get the desired:

 error: unsupported configuration: block jobs not supported with this qemu binary

[1] The intentional cripple is limited to qemu-kvm of RHEL; when using
qemu-kvm-rhev of RHEV, block job functionality is supported.  Don't ask
me to explain the "why" behind it all - I'm just dealing with fallout
from someone else's decision.

* src/qemu/qemu_capabilities.h (QEMU_CAPS_BLOCKJOB_SYNC): Tweak comment.
* src/qemu/qemu_capabilities.c (virQEMUCapsCommands): Look for stream
rather than cancel when determining the flavor of block jobs supported.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agotest: Add test to verify helpers used for backing file name parsing
Peter Krempa [Wed, 29 Oct 2014 10:01:48 +0000 (11:01 +0100)]
test: Add test to verify helpers used for backing file name parsing

Add two test cases to verify that the helpers split and parse the
backing store components properly.