]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/log
people/liuw/libxenctrl-split/libvirt.git
10 years agoutil: storage: Add helper to resolve relative path difference
Peter Krempa [Tue, 13 May 2014 08:10:56 +0000 (10:10 +0200)]
util: storage: Add helper to resolve relative path difference

This patch introduces a function that will allow us to resolve a
relative difference between two elements of a disk backing chain. This
function will be used to allow relative block commit and block pull
where we need to specify the new relative name of the image to qemu.

This patch also adds unit tests for the function to verify that it works
correctly.

10 years agoLXC: check whether we get MemSwap[Total|Usage]
Chen Hanxiao [Wed, 25 Jun 2014 01:57:32 +0000 (09:57 +0800)]
LXC: check whether we get MemSwap[Total|Usage]

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
10 years agoqemu: enum cleanups in "src/qemu/*"
Julio Faracco [Sun, 15 Jun 2014 16:32:56 +0000 (13:32 -0300)]
qemu: enum cleanups in "src/qemu/*"

As we are doing with the enum structures, a cleanup in "src/qemu/"
directory was done now. All the enums that were defined in the
header files were converted to typedefs in this directory. This
patch includes all the adjustments to remove conflicts when you do
this kind of change. "Enum-to-typedef"'s conversions were made in
"src/qemu/qemu_{capabilities, domain, migration, hotplug}.h".

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
10 years agolibxl: fix version annotation of migration functions
Jim Fehlig [Tue, 24 Jun 2014 17:12:21 +0000 (11:12 -0600)]
libxl: fix version annotation of migration functions

Commit 9b8d6e1e missed updating the libvirt version which
introduced support for domainMigrate*3Params functions.

10 years agobridge: leases: Fix potential crash caused by use after free
Peter Krempa [Tue, 24 Jun 2014 11:52:57 +0000 (13:52 +0200)]
bridge: leases: Fix potential crash caused by use after free

Don't free individual JSON array members as the array will be freed at
the end. This may potentially lead to a crash although it didn't crash
on my setup.

10 years agoFree DHCP leases file in networkGetDHCPLeasesHelper
Ján Tomko [Tue, 24 Jun 2014 12:40:14 +0000 (14:40 +0200)]
Free DHCP leases file in networkGetDHCPLeasesHelper

Introduced by commit ba51398

10 years agoRework remoteSerializeDHCPLease
Ján Tomko [Tue, 24 Jun 2014 12:37:55 +0000 (14:37 +0200)]
Rework remoteSerializeDHCPLease

Don't leak the temporary variables on success if NULL is returned
for that field.

Don't dereference NULL on failure to allocate some of the temporaries.

Introduced by commit 990c3b6

10 years agoFree file header in virStorageFileGetMetadataRecurse
Ján Tomko [Tue, 24 Jun 2014 12:35:59 +0000 (14:35 +0200)]
Free file header in virStorageFileGetMetadataRecurse

Introduced by commit 2bdb8b9

10 years agoChange 'interface' to 'iface' in virNetworkDHCPLease
Daniel P. Berrange [Tue, 24 Jun 2014 12:23:59 +0000 (13:23 +0100)]
Change 'interface' to 'iface' in virNetworkDHCPLease

Variables/fields named 'interface' clash with system
header symbols on some platforms.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
10 years agographics: remember graphics not auto allocated ports
Giuseppe Scrivano [Tue, 24 Jun 2014 11:34:18 +0000 (13:34 +0200)]
graphics: remember graphics not auto allocated ports

When looking for a port to allocate, the port allocator didn't take in
consideration ports that are statically set by the user.  Defining
these two graphics elements in the XML would cause an error, as the
port allocator would try to use the same port for the spice graphics
element:

    <graphics type='spice' autoport='yes'/>
    <graphics type='vnc' port='5900' autoport='no'/>

The new *[pP]ortReserved variables keep track of the ports that were
successfully tracked as used by the port allocator but that weren't
bound.

Closes: https://bugzilla.redhat.com/show_bug.cgi?id=1081881
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
10 years agovirtportallocator: new function "virPortAllocatorSetUsed"
Giuseppe Scrivano [Tue, 24 Jun 2014 11:34:17 +0000 (13:34 +0200)]
virtportallocator: new function "virPortAllocatorSetUsed"

virPortAllocatorSetUsed permits to set a port as already used and
prevent the port allocator to use it without any attempt to bind it.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agonet-dhcp-leases: Add virsh support
Nehal J Wani [Mon, 23 Jun 2014 21:01:52 +0000 (02:31 +0530)]
net-dhcp-leases: Add virsh support

Use virNetworkGetDHCPLeases and virNetworkGetDHCPLeasesForMAC in virsh.

The new feature supports the follwing methods:

1. Retrieve leases info for a given virtual network

2. Retrieve leases info for given network interface

tools/virsh-domain-monitor.c
   * Introduce new command : net-dhcp-leases
     Example Usage: net-dhcp-leases <network> [mac]

   virsh # net-dhcp-leases --network default6
   Expiry Time          MAC address        Protocol  IP address                Hostname        Client ID or DUID
   -------------------------------------------------------------------------------------------------------------------
   2014-06-16 03:40:14  52:54:00:85:90:e2  ipv4      192.168.150.231/24        fedora20-test   01:52:54:00:85:90:e2
   2014-06-16 03:40:17  52:54:00:85:90:e2  ipv6      2001:db8:ca2:2:1::c0/64   fedora20-test   00:04:b1:d8:86:42:e1:6a:aa:cf:d5:86:94:23:6f:94:04:cd
   2014-06-16 03:34:42  52:54:00:e8:73:eb  ipv4      192.168.150.181/24        ubuntu14-vm     -
   2014-06-16 03:34:46  52:54:00:e8:73:eb  ipv6      2001:db8:ca2:2:1::5b/64   -               00:01:00:01:1b:30:c6:aa:52:54:00:e8:73:eb

tools/virsh.pod
   * Document new command

src/internal.h
   * Introduce new macro: EMPTYSTR

10 years agonet-dhcp-leases: Private implementation inside network
Nehal J Wani [Mon, 23 Jun 2014 21:01:51 +0000 (02:31 +0530)]
net-dhcp-leases: Private implementation inside network

Query the network driver for the path of the custom leases file for the given
virtual network and parse it to retrieve info.

src/network/bridge_driver.c:
* Implement networkGetDHCPLeases
* Implement networkGetDHCPLeasesForMAC
* Implement networkGetDHCPLeasesHelper

10 years agonet-dhcp-leases: Implement the remote protocol
Nehal J Wani [Mon, 23 Jun 2014 21:01:50 +0000 (02:31 +0530)]
net-dhcp-leases: Implement the remote protocol

Implement RPC calls for virNetworkGetDHCPLeases, virNetworkGetDHCPLeasesForMAC

daemon/remote.c
   * Define remoteSerializeNetworkDHCPLeases,
            remoteDispatchNetworkGetDHCPLeases
   * Define remoteDispatchNetworkGetDHCPLeasesForMAC
   * Define helper function remoteSerializeDHCPLease

src/remote/remote_driver.c
   * Define remoteNetworkGetDHCPLeases
   * Define remoteNetworkGetDHCPLeasesForMAC
   * Define helper function remoteSerializeDHCPLease

src/remote/remote_protocol.x
   * New RPC procedure: REMOTE_PROC_NETWORK_GET_DHCP_LEASES
   * Define structs remote_network_dhcp_leases, remote_network_get_dhcp_leases_args,
                    remote_network_get_dhcp_leases_ret
   * New RPC procedure: REMOTE_PROC_NETWORK_GET_DHCP_LEASES_FOR_MAC
   * Define structs remote_network_dhcp_leases_for_mac, remote_network_get_dhcp_leases_for_mac_args,
                    remote_network_get_dhcp_leases_for_mac_ret

src/remote_protocol-structs
   * New structs added

src/rpc/gendispatch.pl
   * Add exception (s/Dhcp/DHCP) for auto-generating names of the remote functions
     in daemon/remote_dispatch.h

10 years agonet-dhcp-leases: Implement the public APIs
Nehal J Wani [Mon, 23 Jun 2014 21:01:49 +0000 (02:31 +0530)]
net-dhcp-leases: Implement the public APIs

Introduce 3 new APIs, virNetworkGetDHCPLeases, virNetworkGetDHCPLeasesForMAC
and virNetworkDHCPLeaseFree.

* virNetworkGetDHCPLeases: returns the dhcp leases information for a given
     virtual network.

  For DHCPv4, the information returned:
  - Network Interface Name
  - Expiry Time
  - MAC address
  - IAID (NULL)
  - IPv4 address (with type and prefix)
  - Hostname (can be NULL)
  - Client ID (can be NULL)

  For DHCPv6, the information returned:
  - Network Interface Name
  - Expiry Time
  - MAC address
  - IAID (can be NULL, only in rare cases)
  - IPv6 address (with type and prefix)
  - Hostname (can be NULL)
  - Client DUID

  Note: @mac, @iaid, @ipaddr, @clientid are in ASCII form, not raw bytes.
  Note: @expirytime can 0, in case the lease is for infinite time.

* virNetworkGetDHCPLeasesForMAC: returns the dhcp leases information for a
     given virtual network and specified MAC Address.

* virNetworkDHCPLeaseFree: allows the upper layer application to free the
     network interface object conveniently.

There is no support for flags, so user is expected to pass 0 for
both the APIs.

include/libvirt/libvirt.h.in:
  * Define virNetworkGetDHCPLeases
  * Define virNetworkGetDHCPLeasesForMAC
  * Define virNetworkDHCPLeaseFree

src/driver.h:
  * Define networkGetDHCPLeases
  * Define networkGetDHCPLeasesForMAC

src/libvirt.c:
  * Implement virNetworkGetDHCPLeases
  * Implement virNetworkGetDHCPLeasesForMAC
  * Implement virNetworkDHCPLeaseFree

src/libvirt_public.syms:
  * Export the new symbols

10 years agoFix shadowed variable with older gcc
Ján Tomko [Tue, 24 Jun 2014 10:53:44 +0000 (12:53 +0200)]
Fix shadowed variable with older gcc

Commit 2cff94c fixed the shadowed 'link' added by commit 975f0e2,
but forgot the 'link' added by commit 08aa22e.

10 years agoLXC: trivially support flag VIR_DRV_FEATURE_TYPED_PARAM_STRING
Chen Hanxiao [Tue, 24 Jun 2014 09:44:18 +0000 (17:44 +0800)]
LXC: trivially support flag VIR_DRV_FEATURE_TYPED_PARAM_STRING

Fix lxcDomainGetMemoryParameters and lxcDomainGetSchedulerParametersFlags:
virsh -c lxc:/// memtune DOMAIN
error: Unable to get number of memory parameters
error: unsupported flags (0x4) in function lxcDomainGetMemoryParameters

Introduced by commit 399394.

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
10 years agovirNumaGetPages: Don't fail on huge page-less systems
Michal Privoznik [Mon, 23 Jun 2014 13:46:31 +0000 (15:46 +0200)]
virNumaGetPages: Don't fail on huge page-less systems

If we are running on a system that is not capable of huge pages (e.g.
because the kernel is not configured that way) we still try to open
"/sys/kernel/mm/hugepages/" which however does not exist. We should
be tolerant to this specific use case.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirNumaGetPageInfo: Take huge pages into account
Michal Privoznik [Mon, 23 Jun 2014 13:04:11 +0000 (15:04 +0200)]
virNumaGetPageInfo: Take huge pages into account

On the Linux kernel, if huge pages are allocated the size they cut off
from memory is accounted under the 'MemUsed' in the meminfo file.
However, we want the sum to be subtracted from 'MemTotal'. This patch
implements this feature. After this change, we can enable reporting
of the ordinary system pages in the capability XML:

<capabilities>

  <host>
    <uuid>01281cda-f352-cb11-a9db-e905fe22010c</uuid>
    <cpu>
      <arch>x86_64</arch>
      <model>Haswell</model>
      <vendor>Intel</vendor>
      <topology sockets='1' cores='1' threads='1'/>
      <feature/>
      <pages unit='KiB' size='4'/>
      <pages unit='KiB' size='2048'/>
      <pages unit='KiB' size='1048576'/>
    </cpu>
    <power_management/>
    <migration_features/>
    <topology>
      <cells num='4'>
        <cell id='0'>
          <memory unit='KiB'>4048248</memory>
          <pages unit='KiB' size='4'>748382</pages>
          <pages unit='KiB' size='2048'>3</pages>
          <pages unit='KiB' size='1048576'>1</pages>
          <distances/>
          <cpus num='1'>
            <cpu id='0' socket_id='0' core_id='0' siblings='0'/>
          </cpus>
        </cell>
        ...
      </cells>
    </topology>
  </host>
</capabilities>

You can see the beautiful thing about this: if you sum up all the
<pages/> you'll get <memory/>.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agostorage: gluster: Avoid name shadow on older compilers
Peter Krempa [Tue, 24 Jun 2014 09:22:17 +0000 (11:22 +0200)]
storage: gluster: Avoid name shadow on older compilers

s/link/linkpath/g in virStorageFileBackendGlusterReadlinkCallback as
older gcc complains.

10 years agostorage: gluster: Add backend to return unique storage file path
Peter Krempa [Mon, 5 May 2014 16:04:16 +0000 (18:04 +0200)]
storage: gluster: Add backend to return unique storage file path

Use virStorageFileSimplifyPathInternal to canonicalize gluster paths
via a callback and use it for the unique volume path retrieval API.

10 years agoutil: storagefile: Introduce universal function to canonicalize paths
Peter Krempa [Fri, 2 May 2014 17:22:17 +0000 (19:22 +0200)]
util: storagefile: Introduce universal function to canonicalize paths

Introduce a common function that will take a callback to resolve links
that will be used to canonicalize paths on various storage systems and
add extensive tests.

10 years agoutil: string: Add helper to free non-NULL terminated string arrays
Peter Krempa [Mon, 19 May 2014 12:20:09 +0000 (14:20 +0200)]
util: string: Add helper to free non-NULL terminated string arrays

To free string lists with some strings stolen from the middle we need to
walk the complete array. Introduce a new helper that takes the string
list size to free such string lists.

10 years agolibxl: prefer qdisk for <driver name='file'>
Jim Fehlig [Fri, 20 Jun 2014 05:36:25 +0000 (23:36 -0600)]
libxl: prefer qdisk for <driver name='file'>

The libxl driver currently sets the disk backend to
LIBXL_DISK_BACKEND_TAP when <driver name='file'> is specified
in the <disk> config.  qdisk should be prefered with this
configuration, otherwise existing configuration such as the
following, which worked with the old Xen driver, will not work
with the libxl driver

  <disk type='file' device='cdrom'>
    <driver name='file'/>
    <source file='/path/to/some/iso'/>
    <target dev='hdc' bus='ide'/>
    <readonly/>
  </disk>

In addition, tap performs poorly compared to qdisk.

10 years agocmdFreepages: initialize @tmp
Michal Privoznik [Mon, 23 Jun 2014 18:25:22 +0000 (20:25 +0200)]
cmdFreepages: initialize @tmp

In the 404bac14 the @tmp variable was introduced. It's purpose is to
avoid typecasting when parsing --pagesize argument. However, if the
argument is not presented, tmp may be used uninitialized resulting in
bogus virNodeGetFreePages() API call:

virsh freepages --cellno 2
error: Failed to open file '/sys/devices/system/node/node2/hugepages/hugepages-4294967295kB/free_hugepages': No such file or directory

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoFix closedir usage in virNumaGetPages
Roman Bogorodskiy [Sat, 21 Jun 2014 15:24:04 +0000 (19:24 +0400)]
Fix closedir usage in virNumaGetPages

virNumaGetPages calls closedir(dir) in cleanup and dir could
be NULL if we jump there from the failed opendir() call.

While it's not harmful on Linux, FreeBSD libc crashes [1], so
make sure that dir is not NULL before calling closedir.

1: http://lists.freebsd.org/pipermail/freebsd-standards/2014-January/002704.html

10 years agoAdd pkg-config files to allow deps to build against source tree
Daniel P. Berrange [Fri, 20 Jun 2014 16:48:12 +0000 (17:48 +0100)]
Add pkg-config files to allow deps to build against source tree

When testing language bindings it is useful to be able to build
them against an uninstalled libvirt source tree. Add a dummy
set of pkg-config files to allow for this. This can be used by
setting

  export PKG_CONFIG_PATH=/path/to/libvirt/git/src

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
10 years agoAdd pkg-config files for libvirt-qemu & libvirt-lxc
Daniel P. Berrange [Fri, 20 Jun 2014 16:47:15 +0000 (17:47 +0100)]
Add pkg-config files for libvirt-qemu & libvirt-lxc

For some reason there have never been pkg-config files created
for the libvirt-qemu.so and libvirt-lxc.so libraries.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
10 years agoDon't include @LIBS@ in libvirt.pc.in file
Daniel P. Berrange [Fri, 20 Jun 2014 16:45:05 +0000 (17:45 +0100)]
Don't include @LIBS@ in libvirt.pc.in file

The libvirt.pc file we install is ending up polluted with a
load of compiler flags that should be private to the libvirt
build. eg

Libs: -L${libdir} -lvirt -ldl -O2 -g -pipe -Wall \
      -Wp,-D_FORTIFY_SOURCE=2 -fexceptions \
      -fstack-protector-strong --param=ssp-buffer-size=4 \
      -grecord-gcc-switches  -m64 -mtune=generic

this is caused by including @LIBS@ in the Libs: line of the
pkgconfig.pc.in file.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
10 years agovirnuma: Actually build huge page code
Michal Privoznik [Mon, 23 Jun 2014 13:56:46 +0000 (15:56 +0200)]
virnuma: Actually build huge page code

One of previous commits (e6258a33) tried to build the huge page code
only on Linux since it's Linux centric indeed. But it failed miserably
as it used 'WITH_LINUX' which is an automake conditional not a gcc
one. In the sources we need to use __linux__.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoqemu: parse -device virtio-balloon
Laine Stump [Mon, 9 Jun 2014 08:11:25 +0000 (11:11 +0300)]
qemu: parse -device virtio-balloon

There are no options to parse here other than the name of the device,
and all three possible device names have the same prefix
("virtio-balloon" with "-ccw", "-pci", or "-device" appended), so the
code is fairly simple. It has been implemented such that it will be
easier to add handling for other -device entries that aren't otherwise
recognized - just add another "else if (STRPREFIX(opts, ....)" clause.

qemuParseCommandLineString() previously would always add a <memballoon
model='virtio'/> to every result (the comments erroneously say that it
is adding a <memballoon model='none'/>) This has been changed to add
model='none', and 84 test case xml's updated accordingly (so that
qemuxml2argvtest won't fail).

Now that the memballoon device is properly parsed, we can safely add a
test for properly ignoring -nodefconfig and -nodefaults. Rather than
adding an entire new test case for this (and memballoon), we just
randomly pick the clock-utc test and modify it slightly to fulfill the
purpose.

10 years agoReport correct error in virNetDevTapCreate
Ján Tomko [Mon, 23 Jun 2014 10:03:05 +0000 (12:03 +0200)]
Report correct error in virNetDevTapCreate

ioctl returns -1, not the errno value

10 years agoDo not call closedir with NULL argument
Ján Tomko [Mon, 23 Jun 2014 06:58:27 +0000 (08:58 +0200)]
Do not call closedir with NULL argument

Only three other callers possibly call closedir on a NULL argument.
Even though these probably won't be used on FreeBSD where this crashes,
let's be nice and only call closedir on an actual directory stream.

10 years agoFix invalid write in virNumaGetDistances
Ján Tomko [Mon, 23 Jun 2014 09:49:02 +0000 (11:49 +0200)]
Fix invalid write in virNumaGetDistances

==== Invalid write of size 4
====    at 0x52E678C: virNumaGetDistances (virnuma.c:479)
====    by 0x5396890: nodeCapsInitNUMA (nodeinfo.c:1796)
====    by 0x203C2B: virQEMUCapsInit (qemu_capabilities.c:960)
====  Address 0xe10a1e0 is 0 bytes after a block of size 0 alloc'd
====    at 0x4C2A6D0: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
====    by 0x52A10D6: virAllocN (viralloc.c:191)
====    by 0x52E674D: virNumaGetDistances (virnuma.c:470)
====    by 0x5396890: nodeCapsInitNUMA (nodeinfo.c:1796)
====    by 0x203C2B: virQEMUCapsInit (qemu_capabilities.c:960)

10 years agoutil: numa: Stub out hugepage code on non-Linux platforms
Peter Krempa [Mon, 23 Jun 2014 07:25:04 +0000 (09:25 +0200)]
util: numa: Stub out hugepage code on non-Linux platforms

The hugepage sizing and counting code gathers the information from sysfs
and thus isn't portable. Stub it out for non-Linux so that we can report
a better error. This patch also avoids calling sysinfo() on Mingw where
it isn't supported.

10 years agoutil: numa: Catch readdir errors in virNumaGetPages
Peter Krempa [Mon, 23 Jun 2014 07:10:04 +0000 (09:10 +0200)]
util: numa: Catch readdir errors in virNumaGetPages

Don't return possibly incomplete result if virDirRead fails.

10 years agotests: Fix syntax-check after cdd11151791bc9e61538988438980f41c0185681
Peter Krempa [Mon, 23 Jun 2014 11:56:12 +0000 (13:56 +0200)]
tests: Fix syntax-check after cdd11151791bc9e61538988438980f41c0185681

makefile_conditionals
tests/Makefile.am:293:endif
maint.mk: match "if FOO" with "endif FOO" in Makefiles
make: *** [sc_makefile_conditionals] Error 1

10 years agotest: Disable storage test when FS backend isn't compiled in
Peter Krempa [Mon, 23 Jun 2014 10:02:04 +0000 (12:02 +0200)]
test: Disable storage test when FS backend isn't compiled in

'virstoragetest' accesses backing chains of files on local storage with
the help of the storage driver. Disable the test on builds without the
storage driver as the test is crashing otherwise.

Reported by: Roman Bogorodskiy

10 years agoProperly check the return value of CCWAddressAsString
Ján Tomko [Mon, 23 Jun 2014 06:31:53 +0000 (08:31 +0200)]
Properly check the return value of CCWAddressAsString

It returns NULL on failure. Checking if the negation of it
is less than zero makes no sense. (Found by coverity after moving
the code)

In another case, the return value wasn't checked at all.

10 years agoSplit out CCW address allocation
Ján Tomko [Tue, 17 Jun 2014 14:17:41 +0000 (16:17 +0200)]
Split out CCW address allocation

Just code movement and rename.

10 years agolibxl: Use cooperative resume for migration
Jason Andryuk [Fri, 20 Jun 2014 13:10:03 +0000 (09:10 -0400)]
libxl: Use cooperative resume for migration

Migration code specifies the problematic non-cooperative resume mode
which is a known issue with Xen's libxl [1].  Instead, use the better
supported cooperative mode.

Without this, guests BUG() in xen_irq_resume after failing to bind
still-bound event channels.

[1] http://bugs.xenproject.org/xen/bug/30

10 years agocpu_arm: Support all ARM processors we know about
Michal Privoznik [Tue, 17 Jun 2014 13:27:17 +0000 (15:27 +0200)]
cpu_arm: Support all ARM processors we know about

So far three ARM processor families are known to libvirt,
however the cpu driver knows only about one of them. This
make host initialization on the other two fail:

2014-06-17 13:35:41.419+0000: 6840: info : libvirt version: 1.2.6
2014-06-17 13:35:41.419+0000: 6840: error : cpuNodeData:342 : this function is not supported by the connection driver: cannot get node CPU data for armv6l architecture
2014-06-17 13:35:41.433+0000: 6840: warning : virQEMUCapsInit:943 : Failed to get host CPU

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirNodeParseSocket: Take ARM into account
Michal Privoznik [Tue, 17 Jun 2014 09:22:05 +0000 (11:22 +0200)]
virNodeParseSocket: Take ARM into account

The virNodeParseSocket() function tries to get socked ID from
'topology/physical_package_id' file. However, on some architectures
the file contains the -1 constant which makes in turn libvirt think
the info extraction was unsuccessful. If that's the case, we need to
overwrite the obtained integer with zero like we are doing for other
architectures.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agonodeinfotest: Print error if cpuinfo file can't be opened
Michal Privoznik [Tue, 17 Jun 2014 11:22:02 +0000 (13:22 +0200)]
nodeinfotest: Print error if cpuinfo file can't be opened

Currently, we are opening the cpuinfo file via fopen() which if fails
doesn't print any error message. We should do that instead.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirNodeParseNode: Propagate host architecture
Michal Privoznik [Tue, 17 Jun 2014 11:58:48 +0000 (13:58 +0200)]
virNodeParseNode: Propagate host architecture

As in previous commit, there are again some places where we can do
runtime decision instead of compile time. This time it's whether the
'topology/physical_package_id' is allowed to have '-1' within or not.
Then, core ID is pared differently on s390(x) than on the rest of
architectures.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agonodeinfo: Introduce @arch to linuxNodeInfoCPUPopulate
Michal Privoznik [Tue, 17 Jun 2014 10:25:23 +0000 (12:25 +0200)]
nodeinfo: Introduce @arch to linuxNodeInfoCPUPopulate

So far, we are doing compile time decisions on which architecture is
used. However, for testing purposes it's much easier if we pass host
architecture as parameter and then let the function decide which code
snippet for extracting host CPU info will be used.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agointerface: clean up virInterfaceDefDevFormat
Laine Stump [Thu, 19 Jun 2014 09:58:56 +0000 (12:58 +0300)]
interface: clean up virInterfaceDefDevFormat

This modifies the formatting function of virInterface to be a proper
mirror of the parse function, including the addition of a
"parentIfType" arg so that we can decide whether or not it is
appropriate to emit the elements that are only in toplevel interfaces,
as well as the <link> element (which isn't allowed for bridge
interfaces).

Since the restructuring of the code necessarily changes the order of
some of the elements, some test case data had to be updated.

10 years agointerface: clean up virInterfaceDefParseXML
Laine Stump [Thu, 19 Jun 2014 09:51:38 +0000 (12:51 +0300)]
interface: clean up virInterfaceDefParseXML

the switch cases for the 4 different interface types had repetitive
code which has now been pulled out as common. While touching those
lines, some extra usage of "!= NULL" etc has been eliminated to make
things more compact and inline with current coding practices.

NB: parentIfType == VIR_INTERFACE_TYPE_LAST means that this is a
toplevel interface (not a subordinate of a bridge or bond). Only
toplevel interfaces can have a start mode, mtu, or IP address element.

10 years agointerface: move parsing of bridge attributes into appropriate function
Laine Stump [Thu, 19 Jun 2014 09:47:26 +0000 (12:47 +0300)]
interface: move parsing of bridge attributes into appropriate function

For some reason the bridge stp mode and delay were put directly into
the "bridge" case of the switch in virInterfaceDefParseXML(), although
they are inside the <bridge> element, and so should be parsed in the
function created for that purpose - virInterfaceBridgeDefFormat().

10 years agointerface: report link state for bonds and vlans too
Laine Stump [Fri, 13 Jun 2014 14:07:05 +0000 (17:07 +0300)]
interface: report link state for bonds and vlans too

The interface state for bonds and vlans does seem to reflect the state
of the underlying physical devices, at least in some cases, so it
makes sense to allow reporting it (netcf now does).

The link state/speed for bridge devices is meaningless though, so we
don't even look for it.

10 years agosecurity: Rename virSecurityManagerSetImageLabel to *Disk*
Peter Krempa [Wed, 18 Jun 2014 12:46:27 +0000 (14:46 +0200)]
security: Rename virSecurityManagerSetImageLabel to *Disk*

I'm going to add functions that will deal with individual image files
rather than whole disks. Rename the security function to make room for
the new one.

10 years agosecurity: Sanitize type of @migrated in virSecurityManagerRestoreAllLabel
Peter Krempa [Wed, 18 Jun 2014 16:54:48 +0000 (18:54 +0200)]
security: Sanitize type of @migrated in virSecurityManagerRestoreAllLabel

Also remove one spurious ATTRIBUTE_UNUSED guarding the @migrated
argument.

10 years agoutil: Don't require full disk definition when getting imagelabels
Peter Krempa [Wed, 18 Jun 2014 16:39:47 +0000 (18:39 +0200)]
util: Don't require full disk definition when getting imagelabels

The image labels are stored in the virStorageSource struct. Convert the
virDomainDiskDefGetSecurityLabelDef helper not to use the full disk def
and move it appropriately.

10 years agoutil: storagefile: Introduce helper to free storage source perms
Peter Krempa [Thu, 12 Jun 2014 14:11:43 +0000 (16:11 +0200)]
util: storagefile: Introduce helper to free storage source perms

It will also be reused later.

10 years agoutil: seclabel: Add deep copy function for device labels
Peter Krempa [Thu, 12 Jun 2014 14:03:06 +0000 (16:03 +0200)]
util: seclabel: Add deep copy function for device labels

10 years agostorage: encryption: Add deep copy function for storage encryption
Peter Krempa [Thu, 12 Jun 2014 13:26:18 +0000 (15:26 +0200)]
storage: encryption: Add deep copy function for storage encryption

10 years agolibxl: limit support for specifying an interface script
Jim Fehlig [Tue, 10 Jun 2014 20:53:55 +0000 (14:53 -0600)]
libxl: limit support for specifying an interface script

Generally, <interface> ... <script> is only supported for
type='ethernet'.  Due to the long and pervasive use of

  <interface type='bridge'>
    ...
    <script path='foo'/>
  </interface>

in Xen domain configuration, it was agreed to allow the use
of <script> with type='bridge' for backwards compatibility.  See
the following discussion thread

http://www.redhat.com/archives/libvir-list/2013-April/msg00755.html

This patch limits the use of <script> to interface types ethernet
and bridge, raising an unsupported config error if <script> is
specified for all other interface types.

While at it, use VIR_ERR_CONFIG_UNSUPPORTED instead of
VIR_ERR_INTERNAL_ERROR when reporting unsupported interface types.

10 years agolibxl: support interface type=network
Jim Fehlig [Tue, 10 Jun 2014 20:28:07 +0000 (14:28 -0600)]
libxl: support interface type=network

Add support for <interface type='network'> in the libxl driver.

10 years agovirsh: fix broken code in freepages
Eric Blake [Thu, 19 Jun 2014 15:21:08 +0000 (09:21 -0600)]
virsh: fix broken code in freepages

Commit 9e3efe53 broke the build under valgrind or clang, by writing
8 bytes through an allocation of 4 bytes.  It also risks multiplication
overflow when mallocing (that's a pervasive problem that needs an
audit in the rest of the code, but we might as well fix this one while
we are here), and had a typo.

* tools/virsh-host.c (cmdFreepages): Avoid integer overflow and
undefined behavior.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agointerface: allow reordering of elements in xml
Laine Stump [Thu, 19 Jun 2014 10:48:31 +0000 (13:48 +0300)]
interface: allow reordering of elements in xml

The interface xml schema was written with strict rules about the
ordering of the elements. This was never intentional, but just due to
omission of <interleave> in the appropriate places. This patch just
adds in <interleave> wherever there is more than one element, and
re-indents everything else appropriately.

10 years agodocs: fix some typos in formatdomain.html
Jincheng Miao [Thu, 19 Jun 2014 09:45:13 +0000 (17:45 +0800)]
docs: fix some typos in formatdomain.html

In section "Block / character devices" of "Host device assignment",
the description of hostdev element has some error:

For a block device, the type should be "storage", not "block";
For a character device, the type should be "misc", not "char".

Signed-off-by: Jincheng Miao <jmiao@redhat.com>
10 years agonodeinfo: Implement nodeGetFreePages
Michal Privoznik [Tue, 10 Jun 2014 14:16:44 +0000 (16:16 +0200)]
nodeinfo: Implement nodeGetFreePages

And add stubs to other drivers like: lxc, qemu, uml and vbox.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirsh: Expose virNodeGetFreePages
Michal Privoznik [Mon, 9 Jun 2014 15:56:43 +0000 (17:56 +0200)]
virsh: Expose virNodeGetFreePages

The new API is exposed under 'freepages' command.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoIntroduce virNodeGetFreePages
Michal Privoznik [Mon, 9 Jun 2014 15:14:47 +0000 (17:14 +0200)]
Introduce virNodeGetFreePages

The aim of the API is to get information on number of free pages
on the system. The API behaves similar to the
virNodeGetCellsFreeMemory(). User passes starting NUMA cell, the
count of nodes that he's interested in, pages sizes (yes,
multiple sizes can be queried at once) and the counts are
returned in an array.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirCaps: expose pages info
Michal Privoznik [Fri, 6 Jun 2014 16:12:51 +0000 (18:12 +0200)]
virCaps: expose pages info

There are two places where you'll find info on page sizes. The first
one is under <cpu/> element, where all supported pages sizes are
listed. Then the second one is under each <cell/> element which refers
to concrete NUMA node. At this place, the size of page's pool is
reported. So the capabilities XML looks something like this:

<capabilities>

  <host>
    <uuid>01281cda-f352-cb11-a9db-e905fe22010c</uuid>
    <cpu>
      <arch>x86_64</arch>
      <model>Westmere</model>
      <vendor>Intel</vendor>
      <topology sockets='1' cores='1' threads='1'/>
      ...
      <pages unit='KiB' size='4'/>
      <pages unit='KiB' size='2048'/>
      <pages unit='KiB' size='1048576'/>
    </cpu>
    ...
    <topology>
      <cells num='4'>
        <cell id='0'>
          <memory unit='KiB'>4054408</memory>
          <pages unit='KiB' size='4'>1013602</pages>
          <pages unit='KiB' size='2048'>3</pages>
          <pages unit='KiB' size='1048576'>1</pages>
          <distances/>
          <cpus num='1'>
            <cpu id='0' socket_id='0' core_id='0' siblings='0'/>
          </cpus>
        </cell>
        <cell id='1'>
          <memory unit='KiB'>4071072</memory>
          <pages unit='KiB' size='4'>1017768</pages>
          <pages unit='KiB' size='2048'>3</pages>
          <pages unit='KiB' size='1048576'>1</pages>
          <distances/>
          <cpus num='1'>
            <cpu id='1' socket_id='0' core_id='0' siblings='1'/>
          </cpus>
        </cell>
        ...
      </cells>
    </topology>
    ...
  </host>

  <guest/>

</capabilities>

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirnuma: Introduce pages helpers
Michal Privoznik [Fri, 6 Jun 2014 16:09:01 +0000 (18:09 +0200)]
virnuma: Introduce pages helpers

For future work we need two functions that fetches total number of
pages and number of free pages for given NUMA node and page size
(virNumaGetPageInfo()).

Then we need to learn pages of what sizes are supported on given node
(virNumaGetPages()).

Note that system page size is disabled at the moment as there's one
issue connected. If you have a NUMA node with huge pages allocated the
kernel would return the normal size of memory for that node. It
basically ignores the fact that huge pages steal size from the system
memory. Until we resolve this, it's safer to not confuse users and
hence not report any system pages yet.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agonodeinfo: Rename nodeGetFreeMemory to nodeGetMemory
Michal Privoznik [Mon, 16 Jun 2014 12:02:34 +0000 (14:02 +0200)]
nodeinfo: Rename nodeGetFreeMemory to nodeGetMemory

For future work we want to get info for not only the free memory
but overall memory size too. That's why the function must have
new signature too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirnuma: Introduce virNumaNodeIsAvailable
Michal Privoznik [Mon, 16 Jun 2014 12:29:15 +0000 (14:29 +0200)]
virnuma: Introduce virNumaNodeIsAvailable

Not on all hosts the set of NUMA nodes IDs is continuous. This is
critical, because our code currently assumes the set doesn't contain
holes. For instance in nodeGetFreeMemory() we can see the following
pattern:

    if ((max_node = virNumaGetMaxNode()) < 0)
        return 0;

    for (n = 0; n <= max_node; n++) {
        ...
    }

while it should be something like this:

    if ((max_node = virNumaGetMaxNode()) < 0)
        return 0;

    for (n = 0; n <= max_node; n++) {
        if (!virNumaNodeIsAvailable(n))
            continue;
        ...
    }

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirsh: expose new active commit controls
Eric Blake [Wed, 21 May 2014 04:11:29 +0000 (22:11 -0600)]
virsh: expose new active commit controls

Add knobs to virsh to manage a 2-phase active commit of the top
layer, similar to knobs already present on blockcopy.  While this
code will fail until later patches actually implement the new
knobs in the qemu driver, doing it now proves that the API is
usable and also makes it easier for testing the qemu changes as
they are made.

* tools/virsh-domain.c (cmdBlockCommit): Add --active, --pivot,
and --keep-overlay options, modeled after blockcopy.
(blockJobImpl): Support --active flag.
* tools/virsh.pod (blockcommit): Document new flags.
(blockjob): Mention 2-phase commit interaction.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoblockjob: use stable disk string in job event
Eric Blake [Sat, 14 Jun 2014 13:18:04 +0000 (07:18 -0600)]
blockjob: use stable disk string in job event

When the block job event was first added, it was for block pull,
where the active layer of the disk remains the same name.  It was
also in a day where we only cared about local files, and so we
always had a canonical absolute file name.  But two things have
changed since then: we now have network disks, where determining
a single absolute string does not really make sense; and we have
two-phase jobs (copy and active commit) where the name of the
active layer changes between the first event (ready, on the old
name) and second (complete, on the pivoted name).

Adam Litke reported that having an unstable string between events
makes life harder for clients.  Furthermore, all of our API that
operate on a particular disk of a domain accept multiple strings:
not only the absolute name of the active layer, but also the
destination device name (such as 'vda').  As this latter name is
stable, even for network sources, it serves as a better string
to supply in block job events.

But backwards-compatibility demands that we should not change the
name handed to users unless they explicitly request it.  Therefore,
this patch adds a new event, BLOCK_JOB_2 (alas, I couldn't think of
any nicer name - but at least Migrate2 and Migrate3 are precedent
for a number suffix).  We must double up on emitting both old-style
and new-style events according to what clients have registered for
(see also how IOError and IOErrorReason emits double events, but
there the difference was a larger struct rather than changed
meaning of one of the struct members).

Unfortunately, adding a new event isn't something that can easily
be broken into pieces, so the commit is rather large.

* include/libvirt/libvirt.h.in (virDomainEventID): Add a new id
for VIR_DOMAIN_EVENT_ID_BLOCK_JOB_2.
(virConnectDomainEventBlockJobCallback): Document new semantics.
* src/conf/domain_event.c (_virDomainEventBlockJob): Rename field,
to ensure we catch all clients.
(virDomainEventBlockJobNew): Add parameter.
(virDomainEventBlockJobDispose)
(virDomainEventBlockJobNewFromObj)
(virDomainEventBlockJobNewFromDom)
(virDomainEventDispatchDefaultFunc): Adjust clients.
(virDomainEventBlockJob2NewFromObj)
(virDomainEventBlockJob2NewFromDom): New functions.
* src/conf/domain_event.h: Add new prototypes.
* src/libvirt_private.syms (domain_event.h): Export new functions.
* src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Generate two
different events.
* src/qemu/qemu_process.c (qemuProcessHandleBlockJob): Likewise.
* src/remote/remote_protocol.x
(remote_domain_event_block_job_2_msg): New struct.
(REMOTE_PROC_DOMAIN_EVENT_BLOCK_JOB_2): New RPC.
* src/remote/remote_driver.c
(remoteDomainBuildEventBlockJob2): New handler.
(remoteEvents): Register new event.
* daemon/remote.c (remoteRelayDomainEventBlockJob2): New handler.
(domainEventCallbacks): Register new event.
* tools/virsh-domain.c (vshEventCallbacks): Likewise.
(vshEventBlockJobPrint): Adjust client.
* src/remote_protocol-structs: Regenerate.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoFix xmconfigtest
Jim Fehlig [Thu, 19 Jun 2014 05:47:41 +0000 (23:47 -0600)]
Fix xmconfigtest

Commit ac63014c introduced a regression in the conversion of Xen
xm config to XML by emitting an empty <cmdline>.  Prior to this
commit, <cmdline> was omitted if the xm config was missing (or
contained an empty) 'extra='.

10 years agoxen: handle root= in xen-xm configuration files.
Ian Campbell [Wed, 18 Jun 2014 08:58:45 +0000 (09:58 +0100)]
xen: handle root= in xen-xm configuration files.

In addition to extra= xm supported a root= option which was supposed
to be incorporated into the final command line. Handle that for "virsh
domxml-from-native xen-xm". Tested with the libxl backend.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
10 years agovbox_snapshot_conf: fix wrong use of 'xmlSaveFormatFileEnc'
Pavel Hrdina [Wed, 18 Jun 2014 12:13:26 +0000 (14:13 +0200)]
vbox_snapshot_conf: fix wrong use of 'xmlSaveFormatFileEnc'

The function 'xmlSaveFormatFileEnc' has a last option to set
if you want to format dumped xml with whitespaces or not.

Older libxml2, the one used in RHEL6, take this option as it is
but newer libxml2 check this option if it's true or not. This
small difference somehow makes things messy on RHEL6 and generated
xml had extra new line and extra whitespaces.

We should pass 1 instead if -1 because the -1 confuses the libxml2.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agotests: fix vbox snapshot xmls
Pavel Hrdina [Tue, 17 Jun 2014 16:27:37 +0000 (18:27 +0200)]
tests: fix vbox snapshot xmls

On RHEL6 the vboxsnapshotxmltest fails because of wrong xml that
is generated by libvirt. However the core issue is in the xml data
itself with the wrong indentation.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agovirsh: man: Correctly spell QEMU
Peter Krempa [Wed, 18 Jun 2014 09:19:12 +0000 (11:19 +0200)]
virsh: man: Correctly spell QEMU

s/QEemu/QEMU/g

10 years agovirsh: man: Fix examples and docs for virsh version
Peter Krempa [Wed, 18 Jun 2014 09:16:33 +0000 (11:16 +0200)]
virsh: man: Fix examples and docs for virsh version

The version command now takes the --daemon parameter for a while and the
output example was pretty outdated.

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

10 years agovirt-aa-helper: allow access to /dev/vhost-net if needed
Serge Hallyn [Wed, 18 Jun 2014 03:20:59 +0000 (03:20 +0000)]
virt-aa-helper: allow access to /dev/vhost-net if needed

Only allow the access if it is a KVM domain which has a NIC which wants
non-userspace networking.

This addresses https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1322568

Signed-off-by: Serge Hallyn <serge.hallyn@ubuntu.com>
10 years agoAdded example script on how to convert LXC container config
Cédric Bosdonnat [Tue, 17 Jun 2014 07:26:22 +0000 (09:26 +0200)]
Added example script on how to convert LXC container config

10 years agovbox: fix a segfault when taking a snapshot
Yohan BELLEGUIC [Tue, 17 Jun 2014 08:28:41 +0000 (10:28 +0200)]
vbox: fix a segfault when taking a snapshot

there is a segfault in the vbox driver when taking a snapshot in the
following functions:
- vboxDomainGetXMLDesc
- vboxSnapshotGetReadWriteDisks
- vboxSnapshotGetReadOnlyDisks

The virStorageSourcePtr in virDomainDiskDef was not correctly allocated.

(The problem stems from the fact that commit 4dc5d8f and commit bc3f5f1
were written in one order but applied in another; so each tested in
isolation passed, but the combination introduces the problem due to
changed semantics).

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agovbox: snapshot: Avoid memleaks in functions dealing with disk arrays
Peter Krempa [Tue, 17 Jun 2014 09:09:29 +0000 (11:09 +0200)]
vbox: snapshot: Avoid memleaks in functions dealing with disk arrays

In virVBoxSnapshotConfRemoveFakeDisks and
virVBoxSnapshotConfDiskIsInMediaRegistry the disk array constructed from
all the disks would be leaked at the end of the function and on
allocation errors. Also the temporary disk list would be leaked.

Add a cleanup section and free the memory properly.

Found by coverity.

10 years agovbox: snapshot: Avoid memleak in virVBoxSnapshotConfAllChildren
Peter Krempa [Tue, 17 Jun 2014 09:02:54 +0000 (11:02 +0200)]
vbox: snapshot: Avoid memleak in virVBoxSnapshotConfAllChildren

On re-allocation failure the function would leak already allocated
memory.

10 years agouuid: Fix coverity warning of unchecked return value
Peter Krempa [Wed, 11 Jun 2014 09:40:44 +0000 (11:40 +0200)]
uuid: Fix coverity warning of unchecked return value

Coverity checks for patterns of handling return values of functions.
Some recent addition must have tripped a threshold where coverity now
complains that we usually check the return value of virUUIDGenerate but
don't do it in one place. Add a check to make coverity happy.

10 years agonetwork: bridge: Avoid freeing uninitialized pointer on cleanup path
Peter Krempa [Tue, 17 Jun 2014 08:03:53 +0000 (10:03 +0200)]
network: bridge: Avoid freeing uninitialized pointer on cleanup path

The cleanup path in networkBuildDhcpDaemonCommandLine could cause a
crash by freeing uninitialized pointer.

10 years agonet: leaseshelper: Refactor copying of old entries to avoid double free
Peter Krempa [Mon, 16 Jun 2014 15:18:07 +0000 (17:18 +0200)]
net: leaseshelper: Refactor copying of old entries to avoid double free

When copying entries from the old lease file into the new array the old
code would copy the pointer of the json object into the second array
without removing it from the first. Afterwards when both arrays were
freed this might lead to a crash due to access of already freed memory.

Refactor the code to use the new array item stealing helper added to the
json code so that the entry resides just in one array.

10 years agonet: leaseshelper: Ignore corrupted lease file and rewrite it
Peter Krempa [Mon, 16 Jun 2014 14:53:42 +0000 (16:53 +0200)]
net: leaseshelper: Ignore corrupted lease file and rewrite it

Instead of reporting an error and terminating, rewrite the file with
the newly learned info.

10 years agonet: leaseshelper: Don't crash if DNSMASQ doesn't provide lease expiry
Peter Krempa [Mon, 16 Jun 2014 14:03:01 +0000 (16:03 +0200)]
net: leaseshelper: Don't crash if DNSMASQ doesn't provide lease expiry

The value is provided via environment and causes a crash if not defined.

10 years agoutil: json: Add helpers for manipulating json arrays
Peter Krempa [Mon, 16 Jun 2014 13:48:11 +0000 (15:48 +0200)]
util: json: Add helpers for manipulating json arrays

Add a checker to determine whether a JSON object is an array and a
helper to steal objects from a JSON array.

10 years agoutil: json: Unify function header formatting
Peter Krempa [Mon, 16 Jun 2014 13:24:26 +0000 (15:24 +0200)]
util: json: Unify function header formatting

Use consistent formatting of function headers:
- two newlines separating functions
- function return type on separate line
- one argument per line

10 years agoblockjob: don't remove older-style mirror XML
Eric Blake [Mon, 16 Jun 2014 19:34:36 +0000 (13:34 -0600)]
blockjob: don't remove older-style mirror XML

Commit 7c6fc39 introduced a regression in the XML produced for older
clients.  The argument at the time was that clients shouldn't be
depending on output-only data for something that is only going to
be triggered for a transient guest; but John Ferlan reported that
the automated testsuite was such a client.  It's better to be safe
than sorry by guaranteeing back-compat cruft.  Note that later
patches will be using <mirror> for active block commit, but there
we don't have to worry about back-compat.

* src/conf/domain_conf.c (virDomainDiskDefFormat): Restore old
style output when necessary.
* docs/schemas/domaincommon.rng: Validate back-compat style.
* docs/formatdomain.html.in: Update the documentation.
* tests/qemuxml2xmloutdata/qemuxml2xmlout-disk-mirror-old.xml:
Update tests.
* tests/qemuxml2argvdata/qemuxml2argv-disk-mirror.xml: Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoblockjob: avoid compiler uncertainty in info sizing
Eric Blake [Sat, 14 Jun 2014 12:42:41 +0000 (06:42 -0600)]
blockjob: avoid compiler uncertainty in info sizing

We have a policy of avoiding enum types in structs in our public
API, because it is possible for a client to choose compiler options
that can change the in-memory ABI of that struct based on whether
the enum value occupies an int or a minimal size.  But we missed
this for virDomainBlockJobInfo.  We got lucky on little-endian
machines - if the enum fits minimal size (a char), we still end
up padding to the next long before the next field; but on
big-endian, a client interpreting the enum as a char would always
see 0 when the server supplies contents as an int.

* include/libvirt/libvirt.h.in (virDomainBlockJobInfo): Enforce
particular sizing.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoblockjob: document recent job addition
Eric Blake [Sat, 14 Jun 2014 12:42:41 +0000 (06:42 -0600)]
blockjob: document recent job addition

I noticed that the web page lacked documentation on block jobs:
http://libvirt.org/html/libvirt-libvirt.html#virDomainBlockJobType
not only for the recently added active commit, but also for all
the other job types.

* include/libvirt/libvirt.h.in (virDomainBlockJobType): Document
recent addition.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoIncrease the size of REMOTE_MIGRATE_COOKIE_MAX to REMOTE_STRING_MAX
Shivaprasad G Bhat [Wed, 28 May 2014 12:42:55 +0000 (08:42 -0400)]
Increase the size of REMOTE_MIGRATE_COOKIE_MAX to REMOTE_STRING_MAX

During guest migration, if the domain xml is bigger than 16384 which is
easily possible for a guest with good number of disks, message encode fails
for xdr_remote_domain_migrate_perform3_ret().
So, Increase the COOKIE_MAX to STRING_MAX value.

Signed-off-by: Shivaprasad G Bhat <shivaprasadbhat@gmail.com>
10 years agonodedev: Introduce <pci-express/> to PCI devices
Michal Privoznik [Thu, 15 May 2014 08:13:45 +0000 (10:13 +0200)]
nodedev: Introduce <pci-express/> to PCI devices

This new element is there to represent PCI-Express capabilities
of a PCI devices, like link speed, number of lanes, etc.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirpci: Introduce virPCIDeviceIsPCIExpress and friends
Michal Privoznik [Thu, 15 May 2014 08:04:28 +0000 (10:04 +0200)]
virpci: Introduce virPCIDeviceIsPCIExpress and friends

These functions will handle PCIe devices and their link capabilities
to query some info about it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoblockcommit: require base below top
Eric Blake [Wed, 11 Jun 2014 22:22:57 +0000 (16:22 -0600)]
blockcommit: require base below top

The block commit code looks for an explicit base file relative
to the discovered top file; so for a chain of:
  base <- snap1 <- snap2 <- snap3
and a command of:
  virsh blockcommit $dom vda --base snap2 --top snap1
we got a sane message (here from libvirt 1.0.5):
error: invalid argument: could not find base 'snap2' below 'snap1' in chain for 'vda'

Meanwhile, recent refactoring has slightly reduced the quality of the
libvirt error messages, by losing the phrase 'below xyz':
error: invalid argument: could not find image 'snap2' in chain for 'snap3'

But we had a one-off, where we were not excluding the top file
itself in searching for the base; thankfully qemu still reports
the error, but the quality is worse:
  virsh blockcommit $dom vda --base snap2 --top snap2
error: internal error unable to execute QEMU command 'block-commit': Base '/snap2' not found

Fix the one-off in blockcommit by changing the semantics of name
lookup - if a starting point is specified, then the result must
be below that point, rather than including that point.  The only
other call to chain lookup was blockpull code, which was already
forcing the lookup to omit the active layer and only needs a
tweak to use the new semantics.

This also fixes the bug exposed in the testsuite, where when doing
a lookup pinned to an intermediate point in the chain, we were
unable to return the name of the parent also in the chain.

* src/util/virstoragefile.c (virStorageFileChainLookup): Change
semantics for non-NULL startFrom.
* src/qemu/qemu_driver.c (qemuDomainBlockJobImpl): Adjust caller,
to keep existing semantics.
* tests/virstoragetest.c (mymain): Adjust to expose new semantics.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agostorage: better tests of lookup
Eric Blake [Fri, 13 Jun 2014 15:23:10 +0000 (09:23 -0600)]
storage: better tests of lookup

Add some more tests of what happens when we restrict a lookup
to begin at a point in the middle of a chain.  In particular,
we want to ensure that a parent is not found when starting at
the child.  This commit also demonstrates that we have a slight
difference in behavior on what parent we report when filtering
is in effect; as the determination of the parent affects the
code in block commit, exposing this in the testsuite will help
justify changes in future patches that tweak the semantics of
what lookups are allowed.

* tests/virstoragetest.c (testStorageLookup): Test user input.
(TEST_LOOKUP_TARGET): Add parameter.
(mymain): Add lookup tests.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agostorage: renumber lookup tests
Eric Blake [Fri, 13 Jun 2014 16:01:14 +0000 (10:01 -0600)]
storage: renumber lookup tests

The next patch will be adding tests, including adding a parameter
for testing more conditions.  For ease of review of that patch, I
want to create common context lines that don't change when the new
tests are added (it's easier to visually review additions than it
is to review an entire chunk of tests rewritten into another
larger chunk of tests).

* tests/virstoragetest.c (mymain): Add a parameter and renumber
the lookup tests.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agostorage: add alias for less typing
Eric Blake [Fri, 13 Jun 2014 14:44:09 +0000 (08:44 -0600)]
storage: add alias for less typing

Typing chain->backingStore->backingStore gets old after a while;
introduce some alias variables to make the test more compact.

* tests/virstoragetest.c (mymain): Introduce some shorthand.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoqemu: snapshot: Don't mark all block disks for metadata reuse
Peter Krempa [Mon, 16 Jun 2014 12:05:07 +0000 (14:05 +0200)]
qemu: snapshot: Don't mark all block disks for metadata reuse

For block devices used as snapshot source the new snapshot code would
set the reuse flag. This inhibits to take snapshot without specially
preparing the block image before taking the snapshot.

Fortunately this is not a regression as only the new way of specifying
snapshot source is affected.

For the followin snapshot XML:
 <domainsnapshot>
   <disks>
     <disk name='vda' type='block'>
       <driver type='qcow2'/>
       <source dev="/dev/andariel/testsnap" />
     </disk>
   </disks>
 </domainsnapshot>

You'd get:
error: internal error: unable to execute QEMU command 'transaction': Image is not in qcow2 format

After this patch the snapshot is created successfully.

10 years agoleaseshelper: fix another crash
Pavel Hrdina [Mon, 16 Jun 2014 12:16:22 +0000 (14:16 +0200)]
leaseshelper: fix another crash

We create a 'lease_new' when we are adding new lease entry, then later
in the code we add the 'lease_new' into a 'leases_array_new' which
leads into the crash because we double free the 'lease_new'.

To prevent the double free we set the 'lease_new' to NULL after
successful append into the 'leases_array_new'.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>