]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
10 years agovirCaps: Expose distance between host NUMA nodes
Michal Privoznik [Tue, 3 Jun 2014 13:18:27 +0000 (15:18 +0200)]
virCaps: Expose distance between host NUMA nodes

If user or management application wants to create a guest,
it may be useful to know the cost of internode latencies
before the guest resources are pinned. For example:

<capabilities>

  <host>
    ...
    <topology>
      <cells num='2'>
        <cell id='0'>
          <memory unit='KiB'>4004132</memory>
          <distances>
            <sibling id='0' value='10'/>
            <sibling id='1' value='20'/>
          </distances>
          <cpus num='2'>
            <cpu id='0' socket_id='0' core_id='0' siblings='0'/>
            <cpu id='2' socket_id='0' core_id='2' siblings='2'/>
          </cpus>
        </cell>
        <cell id='1'>
          <memory unit='KiB'>4030064</memory>
          <distances>
            <sibling id='0' value='20'/>
            <sibling id='1' value='10'/>
          </distances>
          <cpus num='2'>
            <cpu id='1' socket_id='0' core_id='0' siblings='1'/>
            <cpu id='3' socket_id='0' core_id='2' siblings='3'/>
          </cpus>
        </cell>
      </cells>
    </topology>
    ...
  </host>
  ...
</capabilities>

We can see the distance from node1 to node0 is 20 and within nodes 10.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirnuma: Introduce virNumaGetDistances
Michal Privoznik [Mon, 2 Jun 2014 10:06:56 +0000 (12:06 +0200)]
virnuma: Introduce virNumaGetDistances

The API gets a NUMA node and find distances to other nodes.  The
distances are returned in an array. If an item X within the array
equals to value of zero, then there's no such node as X.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agotests: monitor: json: Fix error message when returning json in json
Peter Krempa [Tue, 3 Jun 2014 15:12:48 +0000 (17:12 +0200)]
tests: monitor: json: Fix error message when returning json in json

The qemu JSON monitor test allows to test also expected command
arguments. As the error from the monitor simulator is returned as a
simulated qemu error (in JSON) all other JSON contained in the error
message needs to be escaped. This will happen if the monitor command
under test receives a JSON array as an argument.

This will improve the error message from:
libvirt:  error : internal error: cannot parse json { "error":  { "desc":
"Invalid value of argument 'keys' of command 'send-key': expected 'ble'
got '[{"type":"number","data":43},{"type":"number","data":26},
{"type":"number","data":46},{"type":"number","data":32}]'",
"class": "UnexpectedCommand" } }: lexical error: invalid string in json text.

To:
libvirt: QEMU Driver error : internal error: unable to execute QEMU
command 'send-key': Invalid value of argument 'keys' of command
'send-key': expected 'ble' got '[{"type":"number","data":43},
{"type":"number","data":26},{"type":"number","data":46},
{"type":"number","data":32}]'

This improvement will not have any effect on tests executing as
expected, but it will help test development.

10 years agonetwork: bridge: Avoid memory leak from networkBuildDhcpDaemonCommandLine
Peter Krempa [Tue, 3 Jun 2014 12:34:23 +0000 (14:34 +0200)]
network: bridge: Avoid memory leak from networkBuildDhcpDaemonCommandLine

If the leasehelper_path couldn't be found the code would leak the
freshly constructed command structure. Re-arrange code to avoid the
problem.

Found by coverity, broken by baafe668fa56767c031468ccd5df3e62eaa11370.

10 years agotests: Build virstoragetest only when storage driver is compiled too
Peter Krempa [Tue, 3 Jun 2014 09:47:31 +0000 (11:47 +0200)]
tests: Build virstoragetest only when storage driver is compiled too

virstoragetest now requires parts of the storage driver to be built.
Without this change the test can't be compiled on platforms that don't
build the storage driver (mingw).

make[2]: *** No rule to make target `../src/libvirt_driver_storage_impl.la', needed by `virstoragetest.exe'.  Stop.

Broken by commit 713cc3b0a7ff8ad42b4c13429b624d1b2b5a99f2

10 years agoqemu: monitor: Fix type of holdtime argument in qemuMonitorJSONSendKey
Peter Krempa [Tue, 3 Jun 2014 09:19:51 +0000 (11:19 +0200)]
qemu: monitor: Fix type of holdtime argument in qemuMonitorJSONSendKey

qemuMonitorJSONSendKey declares the "holdtime" argument as unsigned int
while the command was constructed in qemuMonitorJSONMakeCommand using
the "P" modifier which took a unsigned long from the variable
arguments which then made it possible to access uninitialized memory.

This broke the qemumonitorjsontest on 32bit fedora 20:
64) qemuMonitorJSONSendKey
... libvirt: QEMU Driver error : internal error: unsupported data type 'W' for arg 'WVS\83ì \8bD$0è\91wÿÿ\81ÃAå' FAILED

Uncovered by upstream commit f744b831c66d9e82453f7a96cab5eddf7570c253.

Additionally add test for the hold-time option.

10 years agolibxl: Avoid possible use of uninitialized mem in libxlDomainStart
Daniel P. Berrange [Mon, 2 Jun 2014 10:53:03 +0000 (11:53 +0100)]
libxl: Avoid possible use of uninitialized mem in libxlDomainStart

The 'libxl_domain_config' object is stack allocated which means its
memory contents are undefined. The libxl_domain_config_dispose() call
is only safe if the memory is initialized to a defined state. Not all
code paths which reach libxl_domain_config_dispose() will ensure that
libxl_domain_config_init() is called. Move the libxl_domain_config_init()
call earlier in the function to ensure all codepaths have defined
memory state.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
10 years agolibxl: Move virDomainXMLOptionNew into libxlCreateXMLConf
Daniel P. Berrange [Fri, 30 May 2014 14:53:12 +0000 (15:53 +0100)]
libxl: Move virDomainXMLOptionNew into libxlCreateXMLConf

To allow the test suite to creat the XML option object,
move the virDomainXMLOptionNew call into a libxlCreateXMLConf
method.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
10 years agolibxl: Don't pass libxlDriverPrivatePtr into libxlBuildDomainConfig
Daniel P. Berrange [Fri, 30 May 2014 13:48:56 +0000 (14:48 +0100)]
libxl: Don't pass libxlDriverPrivatePtr into libxlBuildDomainConfig

To make it easier to test, change libxlBuildDomainConfig so
that it takes a virPortAllocatorPtr instead of the larger
libxlDriverPrivatePtr object.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
10 years agolibxl: Don't pass virDomainObjPtr to libxlBuildDomainConfig
Daniel P. Berrange [Fri, 30 May 2014 13:46:35 +0000 (14:46 +0100)]
libxl: Don't pass virDomainObjPtr to libxlBuildDomainConfig

To make it easier to unit test, change libxlBuildDomainConfig
so that it takes 'virDomainDefPtr' and 'libxl_ctx *' objects
as separate parameters.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
10 years agoqemu: Return in from qemuDomainRemove*Device
Jiri Denemark [Tue, 3 Jun 2014 08:18:48 +0000 (10:18 +0200)]
qemu: Return in from qemuDomainRemove*Device

Some of the APIs already return int since they can produce errors that
need to be propagated. For consistency reasons, this patch changes the
rest of the APIs to also return int even though they do not fail or
report any errors.

10 years agoqemu: Remove character device backend only after frontend is gone
Jiri Denemark [Tue, 27 May 2014 11:30:04 +0000 (13:30 +0200)]
qemu: Remove character device backend only after frontend is gone

In general, we should only remove a backend after seeing DEVICE_DELETED
event for a corresponding frontend.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agoqemu: Remove disk backend only after frontend is gone
Jiri Denemark [Tue, 27 May 2014 10:09:09 +0000 (12:09 +0200)]
qemu: Remove disk backend only after frontend is gone

In general, we should only remove a backend after seeing DEVICE_DELETED
event for a corresponding frontend. This doesn't make any difference for
disks attached using -drive or drive_add since QEMU automatically
removes their backends but it's still better to make our code
consistent. And it may start making difference in case we switch to
attaching disks using -blockdev.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agoqemu: Remove interface backend only after frontend is gone
Jiri Denemark [Tue, 27 May 2014 09:50:41 +0000 (11:50 +0200)]
qemu: Remove interface backend only after frontend is gone

[1] reported that we are removing network's backend too early. I didn't
really get the reproducer but libvirt behaves strangely when a guest
does not confirm the removal, e.g., it does not support PCI hotplug. In
such case, detaching a network device leaves its frontend in place but
removes the backend, which makes the device unusable for the guest.
Moreover attaching the same device again succeeds and both the guest and
libvirt will see two network interfaces attached but only one of them is
actually working.

I checked with Paolo Bonzini and he confirmed we should only remove a
backend after seeing DEVICE_DELETED event for a corresponding frontend.

[1] https://www.redhat.com/archives/libvir-list/2014-March/msg01740.html

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agotests: storagetest: Unify and reformat storage chain format string
Peter Krempa [Mon, 26 May 2014 13:38:29 +0000 (15:38 +0200)]
tests: storagetest: Unify and reformat storage chain format string

All the fields crammed into two lines weren't easy to parse by human
eyes. Split up the format string into lines and put it into a central
variable so that changes in two places aren't necessary.

10 years agoqemu: json: Add format strings for optional command arguments
Peter Krempa [Tue, 13 May 2014 15:28:45 +0000 (17:28 +0200)]
qemu: json: Add format strings for optional command arguments

This patch adds option to specify that a json qemu command argument is
optional without the need to use if's or ternary operators to pass the
list. Additionally all the modifier characters are documented to avoid
user confusion.

10 years agoutil: string: Return element count from virStringSplit
Peter Krempa [Mon, 12 May 2014 07:46:37 +0000 (09:46 +0200)]
util: string: Return element count from virStringSplit

To allow using the array manipulation macros on the arrays returned by
virStringSplit we need to know the count of the elements in the array.
Modify virStringSplit to return this value, rename it and add a helper
with the old name so that we don't need to update all the code.

10 years agostorage: Traverse backing chains of network disks
Peter Krempa [Mon, 28 Apr 2014 13:09:32 +0000 (15:09 +0200)]
storage: Traverse backing chains of network disks

Now we don't need to skip backing chain detection for remote disks.

10 years agostorage: Change to new backing store parser
Peter Krempa [Mon, 5 May 2014 16:05:03 +0000 (18:05 +0200)]
storage: Change to new backing store parser

Use the new backing store parser in the backing chain crawler. This
change needs one test change where information about the NBD image are
now parsed differently.

10 years agostorage: Add infrastructure to parse remote network backing names
Peter Krempa [Fri, 25 Apr 2014 11:23:50 +0000 (13:23 +0200)]
storage: Add infrastructure to parse remote network backing names

Add parsers for relative and absolute backing names for local and remote
storage files.

This parser parses relative paths as relative to their parents and
absolute paths according to the protocol or local access.

For remote storage volumes, all URI based backing file names are
supported and for the qemu colon syntax the NBD protocol is supported.

10 years agostorage: Switch metadata crawler to use storage driver file access check
Peter Krempa [Mon, 28 Apr 2014 06:44:42 +0000 (08:44 +0200)]
storage: Switch metadata crawler to use storage driver file access check

Use virStorageFileAccess() to to check whether the file is accessible in
the main part of the metadata crawler.

10 years agostorage: Switch metadata crawler to use storage driver to read headers
Peter Krempa [Fri, 25 Apr 2014 19:38:40 +0000 (21:38 +0200)]
storage: Switch metadata crawler to use storage driver to read headers

Use virStorageFileReadHeader() to read headers of storage files possibly
on remote storage to retrieve the image metadata.

The backend information is now parsed by
virStorageFileGetMetadataInternal which is now exported from the util
source and virStorageFileGetMetadataFromFDInternal now doesn't need to
be exported.

10 years agostorage: Switch metadata crawler to use storage driver to get unique path
Peter Krempa [Thu, 24 Apr 2014 14:59:56 +0000 (16:59 +0200)]
storage: Switch metadata crawler to use storage driver to get unique path

Use the virStorageFileGetUniqueIdentifier() function to get a unique
identifier regardless of the target storage type instead of relying on
canonicalize_path().

A new function that checks whether we support a given image is
introduced to avoid errors for unimplemented backends.

10 years agostorage: backend: Add possibility to suppress errors from backend lookup
Peter Krempa [Thu, 24 Apr 2014 14:21:20 +0000 (16:21 +0200)]
storage: backend: Add possibility to suppress errors from backend lookup

Add a new function wrapper and tweak the storage file backend lookup
function so that it can be used without reporting error. This will be
useful in the metadata crawler code where we need silently break if
metadata retrieval is not supported for the current storage type.

10 years agotest: storage: Initialize storage source to correct type
Peter Krempa [Fri, 25 Apr 2014 19:44:06 +0000 (21:44 +0200)]
test: storage: Initialize storage source to correct type

Stat the path of the storage file being tested to set the correct type
into the virStorageSource. This will avoid breaking the test suite when
inquiring metadata of directory paths in the next patches.

10 years agostorage: Determine the local storage type right away
Peter Krempa [Fri, 25 Apr 2014 13:16:25 +0000 (15:16 +0200)]
storage: Determine the local storage type right away

When walking the backing chain we previously set the storage type to
_FILE and let the virStorageFileGetMetadataFromFDInternal update it to
the correct type later on.

This patch moves the actual storage type determination to the place
where we parse the backing store name so that the code can later be
switched to use virStorageFileReadHeader() directly.

10 years agostorage: Move virStorageFileGetMetadata to the storage driver
Peter Krempa [Thu, 24 Apr 2014 10:14:01 +0000 (12:14 +0200)]
storage: Move virStorageFileGetMetadata to the storage driver

My future work will modify the metadata crawler function to use the
storage driver file APIs to access the files instead of accessing them
directly so that we will be able to request the metadata for remote
files too. To avoid linking the storage driver to every helper file
using the utils code, the backing chain traversal function needs to be
moved to the storage driver source.

Additionally the virt-aa-helper and virstoragetest programs need to be
linked with the storage driver as a result of this change.

10 years agostorage: Add API to check accessibility of storage volumes
Peter Krempa [Sat, 26 Apr 2014 16:15:41 +0000 (18:15 +0200)]
storage: Add API to check accessibility of storage volumes

Add a storage driver API equivalent of the access() function.
Implementations for the filesystem and gluster backends are provided.

10 years agostorage: backend: Add unique id retrieval API
Peter Krempa [Tue, 22 Apr 2014 14:02:54 +0000 (16:02 +0200)]
storage: backend: Add unique id retrieval API

Different protocols have different means to uniquely identify a storage
file. This patch implements a storage driver API to retrieve a unique
string describing a volume. The current implementation works for local
storage only and returns the canonical path of the volume.

To add caching support the local filesystem driver now has a private
structure holding the cached string, which is created only when it's
initially accessed.

This patch provides the implementation for local files only for start.

10 years agoxenapi_utils: Adapt to enum cleanups
Michal Privoznik [Tue, 3 Jun 2014 07:18:58 +0000 (09:18 +0200)]
xenapi_utils: Adapt to enum cleanups

It was just very recently that we transfered from:

  enum virSomeEnumName{
      ...
  };

to:
  typedef enum {
      ...
  } virSomeEnumName;

This change requires some code adaptation, which wasn't done for
xenapi driver. With this fix we are able to build again.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirnuma.c: Fix some comments
Michal Privoznik [Mon, 2 Jun 2014 10:05:28 +0000 (12:05 +0200)]
virnuma.c: Fix some comments

In 9dd02965 the virNumaGetNodeMemory was introduced, however the
comment describing the function mentions virNumaGetNodeMemorySize.
And there's one typo in virNumaIsAvailable() description.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoconf: more enum cleanups in "src/conf/domain_conf.h"
Julio Faracco [Sun, 1 Jun 2014 00:22:30 +0000 (21:22 -0300)]
conf: more enum cleanups in "src/conf/domain_conf.h"

In "src/conf/domain_conf.h" there are many enum declarations. The
cleanup in this header filer was started, but it wasn't enough and
there are many other files that has enum variables declared. So, the
commit was starting to be big. This commit finish the cleanup in this
header file and in other files that has enum variables, parameters,
or functions declared.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoconf: enum cleanups in "src/conf/domain_conf.h"
Julio Faracco [Sun, 1 Jun 2014 00:22:29 +0000 (21:22 -0300)]
conf: enum cleanups in "src/conf/domain_conf.h"

In "src/conf/domain_conf.h" there are many enumerations (enum)
declarations to be converted as a typedef too. As mentioned before,
it's better to use a typedef for variable types, function types and
other usages. I think this file has most of those enum declarations
at "src/conf/". So, me and Eric Blake plan to keep the cleanups all
over the source code. This time, most of the files changed in this
commit are related to part of one file: "src/conf/domain_conf.h".

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
10 years agocpu: use typedefs for enums in "src/cpu/cpu_map.h"
Julio Faracco [Sun, 1 Jun 2014 00:22:28 +0000 (21:22 -0300)]
cpu: use typedefs for enums in "src/cpu/cpu_map.h"

In "src/cpu/" there are some enumerations (enum) declarations.
Similar to the recent cleanup to "src/util", "src/conf" and other
directories, it's better to use a typedef for variable types,
function types and other usages. Other enumeration and folders will
be changed to typedef's in the future. Specially, in files that are
in different places of "src/util" and "src/conf". Most of the files
changed in this commit are related to CPU (cpu_map.h) enums.

Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
10 years agovirsh-nodedev: Avoid spurious errors
Michal Privoznik [Mon, 2 Jun 2014 14:48:22 +0000 (16:48 +0200)]
virsh-nodedev: Avoid spurious errors

Our public free functions explicitly don't accept NULL pointers
(sigh). Therefore, callers must do something like this:

    if (dev)
        virNodeDeviceFree(dev);

And we are not doing that on two places I've found. This leads to
dummy error message thrown by virsh:

    virsh # nodedev-dumpxml nonexistent-device
    error: Could not find matching device 'nonexistent-device'
    error: invalid node device pointer in virNodeDeviceFree

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoDon't use AI_ADDRCONFIG when binding to wildcard addresses
Ján Tomko [Thu, 29 May 2014 09:21:25 +0000 (11:21 +0200)]
Don't use AI_ADDRCONFIG when binding to wildcard addresses

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

With parallel boot, network addresses might not yet be assigned [1],
but binding to wildcard addresses should work.

For non-wildcard addresses, ADDRCONFIG is still used. Document this
in libvirtd.conf.

[1] http://www.freedesktop.org/wiki/Software/systemd/NetworkTarget/

10 years agoqemu: Unref cfg when detaching hostdev interface
Jiri Denemark [Tue, 27 May 2014 09:49:53 +0000 (11:49 +0200)]
qemu: Unref cfg when detaching hostdev interface

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agoqemu: Process DEVICE_DELETED event in a separate thread
Jiri Denemark [Mon, 26 May 2014 15:02:05 +0000 (17:02 +0200)]
qemu: Process DEVICE_DELETED event in a separate thread

Currently, we don not acquire any job when removing a device after
DEVICE_DELETED event was received from QEMU. This means that if there is
another API running at the time DEVICE_DELETED is delivered and the API
acquired a job, we may happily change the definition of the domain the
API is working with whenever it unlocks the domain object (e.g., to talk
with its monitor). That said, we have to acquire a job before finishing
device removal to make things safe. However, doing so in the main event
loop would cause a deadlock so we need to move most of the event handler
into a separate thread.

Another good reason for both acquiring a job and handling the event in a
separate thread is that we currently remove a device backend immediately
after removing its frontend while we should only remove the backend once
we already received DEVICE_DELETED event. That is, we will have to talk
to QEMU monitor from the event handler.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agoqemu: Finish device removal in the original thread
Jiri Denemark [Mon, 26 May 2014 15:01:52 +0000 (17:01 +0200)]
qemu: Finish device removal in the original thread

If QEMU supports DEVICE_DELETED event, we always call
qemuDomainRemoveDevice from the event handler. However, we will need to
push this call away from the main event loop and begin a job for it (see
the following commit), we need to make sure the device is fully removed
by the original thread (and within its existing job) in case the
DEVICE_DELETED event arrives before qemuDomainWaitForDeviceRemoval times
out.

Without this patch, device removals would be guaranteed to never finish
before the timeout because the could would be blocked by the original
job being still active.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agoFix build on freebsd
Pavel Hrdina [Mon, 2 Jun 2014 14:43:11 +0000 (16:43 +0200)]
Fix build on freebsd

On freebsd there isn't known "setlocale" so we have to include locale.h

10 years agoAdd helper program to create custom leases
Nehal J Wani [Mon, 2 Jun 2014 10:19:26 +0000 (11:19 +0100)]
Add helper program to create custom leases

Introduce helper program to catch events from dnsmasq and maintain a custom
lease file per network. It supports dhcpv4 and dhcpv6. The file is saved as
"<interface-name>.status".

Each lease contains the following info:
<expiry-time (epoch time)> <mac> <iaid> <ip-address> <hostname> <clientid>

Example of custom leases file content:
[
    {
        "iaid": "1221229",
        "ip-address": "2001:db8:ca2:2:1::95",
        "mac-address": "52:54:00:12:a2:6d",
        "hostname": "Fedora20",
        "client-id": "00:04:1a:c1:d9:6b:5a:0a:e2:bc:f8:4b:1e:37:2e:38:22:55",
        "expiry-time": 1393244216
    },
    {
        "ip-address": "192.168.150.208",
        "mac-address": "52:54:00:11:56:b3",
        "hostname": "Wani-PC",
        "client-id": "01:52:54:00:11:56:b3",
        "expiry-time": 1393244248
    }
]

src/Makefile.am:
   * Add options to compile the helper program

src/network/bridge_driver.c:
   * Introduce networkDnsmasqLeaseFileNameCustom()
   * Invoke helper program along with dnsmasq
   * Delete the .status file when corresponding n/w is destroyed.

src/network/leaseshelper.c
   * Helper program to create the custom lease file

10 years agovirsh: Check whether found volume is member of the specified storage pool
Peter Krempa [Fri, 30 May 2014 12:44:55 +0000 (14:44 +0200)]
virsh: Check whether found volume is member of the specified storage pool

When looking up storage volumes virsh uses multiple lookup steps. Some
of the steps don't require a pool name specified. This resulted into a
possibility that a volume would be part of a different pool than the
user specified:

Let's have a /var/lib/libvirt/images/test.qcow image in the 'default'
pool and a second pool 'emptypool':

Currently we'd return:
  $ virsh vol-info --pool emptypool /var/lib/libvirt/images/test.qcow
  Name:           test.qcow
  Type:           file
  Capacity:       100.00 MiB
  Allocation:     212.00 KiB

After the fix:
 $ tools/virsh vol-info --pool emptypool /var/lib/libvirt/images/test.qcow
 error: Requested volume '/var/lib/libvirt/images/test.qcow' is not in pool 'emptypool'

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

10 years agoBump version to 1.2.6 for new dev cycle
Daniel Veillard [Mon, 2 Jun 2014 01:53:30 +0000 (09:53 +0800)]
Bump version to 1.2.6 for new dev cycle

10 years agoForgot spec changelog in 1.2.5 commit
Daniel Veillard [Mon, 2 Jun 2014 01:52:44 +0000 (09:52 +0800)]
Forgot spec changelog in 1.2.5 commit

10 years agoRelease of libvirt-1.2.5
Daniel Veillard [Mon, 2 Jun 2014 01:47:05 +0000 (09:47 +0800)]
Release of libvirt-1.2.5

* docs/news.html.in: update for release
* po/*.po*: updated ukrainian localization and regenerated

10 years agodocs: bhyve driver documentation improvements
Roman Bogorodskiy [Sun, 11 May 2014 07:25:08 +0000 (11:25 +0400)]
docs: bhyve driver documentation improvements

- Document 'domxml-to-native' command
- Mention that the nmdm console support needs an appropriate
  kernel module loaded

10 years agoutil: fix DST end date in virtimetest timezones
Laine Stump [Sun, 1 Jun 2014 02:21:19 +0000 (05:21 +0300)]
util: fix DST end date in virtimetest timezones

Reported by: Roman Bogorodskiy <bogorodskiy@gmail.com>

Some of the tests for virTimeLocalOffsetFromUTC set an imaginary
timezone that attempts to force dyalight savings time active all the
time by setting a start date of 0/00:00:00 and end date of
366/23:59:59. Since the day is 0-based, 366 really means "day 367"
which will never occur - this was an attempt to eliminate problems
with DST not being active in some cases right around midnight on
January 1. Even though it didn't completely solve the problem, it
didn't seem to cause harm so it was left in the test timezones.

Although Linux glibc doesn't mind having a DST end date of 366,
FreeBSD refuses to use such timezones, so the tests fail. This patch
changes the 366 to 365.

This may or may not cause failure of the remaining DST tests around
midnight Jan 1. If so, we will need to disable those tests at year's
end too.

10 years agobuild: avoid compiler warning on 32-bit platform
Eric Blake [Fri, 30 May 2014 22:30:07 +0000 (16:30 -0600)]
build: avoid compiler warning on 32-bit platform

On a 32-bit platform:

virstringtest.c: In function 'mymain':
virstringtest.c:673: warning: this decimal constant is unsigned only in ISO C90

I already had a comment in the file about the 64-bit counterpart;
the easiest fix was to make both sites use the standardized macro
that is guaranteed to work.

* tests/virstringtest.c (mymain): Minimum signed integers are a pain.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoqemu: snapshot: Improve detection of mixed snapshots
Peter Krempa [Thu, 29 May 2014 09:02:43 +0000 (11:02 +0200)]
qemu: snapshot: Improve detection of mixed snapshots

Currently we don't support mixed (external + internal) snapshots. The
code detecting the snapshot type didn't make sure that the memory image
was consistent with the snapshot type leading into strange error
message:

 $ virsh snapshot-create-as --domain VM --diskspec vda,snapshot=internal --memspec snapshot=external,file=/tmp/blah
 error: internal error: unexpected code path

Fix the mixed detection code to detect this kind of mistake:

 $ virsh snapshot-create-as --domain VM --diskspec vda,snapshot=internal --memspec snapshot=external,file=/tmp/blah
 error: unsupported configuration: mixing internal and external targets for a snapshot is not yet supported

10 years agoqemu: snapshot: Reject internal active snapshot without memory state
Peter Krempa [Thu, 29 May 2014 08:52:57 +0000 (10:52 +0200)]
qemu: snapshot: Reject internal active snapshot without memory state

A internal snapshot of a active VM with the memory snapshot disabled
explicitly would actually still take the memory snapshot. Reject it
explicitly.

Before:
 $ virsh snapshot-create-as --domain VM --diskspec vda,snapshot=internal --memspec snapshot=no
 Domain snapshot 1401353155 created

After:
 $ virsh snapshot-create-as --domain VM --diskspec vda,snapshot=internal --memspec snapshot=no
 error: Operation not supported: internal snapshot of a running VM must include the memory state

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

10 years agoutil: storage: Fix crash of libvirtd on network backed guest block-pull
Peter Krempa [Thu, 29 May 2014 14:46:38 +0000 (16:46 +0200)]
util: storage: Fix crash of libvirtd on network backed guest block-pull

For guests backed by gluster volumes (or other network storage) we don't
fill the backing chain (see qemuDomainDetermineDiskChain). This leaves
the "relPath" field of the top image NULL. This causes a crash in
virStorageFileChainLookup() when looking up a backing element for such a
disk.

Since I'm working on adding support for network storage and one of the
steps will make the "relPath" field optional let's use STREQ_NULLABLE
instead of STREQ in virStorageFileChainLookup() to avoid the problem.

10 years agoutil: fix virTimeLocalOffsetFromUTC DST processing
Laine Stump [Tue, 27 May 2014 13:35:57 +0000 (16:35 +0300)]
util: fix virTimeLocalOffsetFromUTC DST processing

The original version of virTimeLocalOffsetFromUTC() would fail for
certain times of the day if daylight savings time was active. This
could most easily be seen by uncommenting the TEST_LOCALOFFSET() cases
that include a DST setting.

After a lot of experimenting, I found that the way to solve it in
almost all test cases is to set tm_isdst = -1 in the struct tm prior
to calling mktime(). Once this is done, the correct offset is returned
for all test cases at all times except the two hours just after
00:00:00 Jan 1 UTC - during that time, any timezone that is *behind*
UTC, and that is supposed to always be in DST will not have DST
accounted for in its offset.

I believe that the code of virTimeLocalOffsetFromUTC() actually is
correct for all cases, but the problem still encountered is due to our
inability to come up with a TZ string that properly forces DST to
*always* be active. Since a modfication of the (currently fixed)
expected result data to account for this would necessarily use the
same functions that we're trying to test, I've instead just made the
test program conditionally bypass the problematic cases if the current
date is either December 31 or January 1. This way we get maximum
testing during 363 days of the year, but don't get false failures on
Dec 31 and Jan 1.

10 years agovirsh: fix typos in virsh man page
Eric Blake [Thu, 29 May 2014 02:10:38 +0000 (20:10 -0600)]
virsh: fix typos in virsh man page

* tools/virsh.pod (attach-disk): Drop duplicate --config, fix typo
in --sourcetype.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agomaint: fix typo in previous patch
Eric Blake [Wed, 28 May 2014 22:10:26 +0000 (16:10 -0600)]
maint: fix typo in previous patch

Use correct variable name.

* m4/virt-selinux.m4: Fix one last variable name.

10 years agomaint: cleanup detection of const'ness of selinux ctx
Jim Fehlig [Wed, 28 May 2014 19:48:21 +0000 (13:48 -0600)]
maint: cleanup detection of const'ness of selinux ctx

Commit 292d3f2d fixed the build with libselinux 2.3, but missed
some suggestions by eblake

https://www.redhat.com/archives/libvir-list/2014-May/msg00977.html

This patch changes the macro introduced in 292d3f2d to either be
empty in the case of newer libselinux, or contain 'const' in the
case of older libselinux.  The macro is then used directly in
tests/securityselinuxhelper.c.

10 years agobuild: fix build with libselinux 2.3
Cédric Bosdonnat [Wed, 28 May 2014 12:44:08 +0000 (14:44 +0200)]
build: fix build with libselinux 2.3

Several function signatures changed in libselinux 2.3, now taking
a 'const char *' instead of 'security_context_t'.  The latter is
defined in selinux/selinux.h as

  typedef char *security_context_t;

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoqemu: managedsave: Don't spam logs with warnings about corrupted image
Peter Krempa [Wed, 28 May 2014 14:46:48 +0000 (16:46 +0200)]
qemu: managedsave: Don't spam logs with warnings about corrupted image

Even successful start of a VM from a managed save image would spam the
logs with the following message:

Unable to restore from managed state [path]. Maybe the file is
corrupted?

Re-arrange the logic to output the warning only when the image is
corrupted.

The flaw was introduced in commit cfc28c66.

10 years agoutils: storage: Canonicalize paths only for local filesystems
Peter Krempa [Wed, 28 May 2014 13:17:11 +0000 (15:17 +0200)]
utils: storage: Canonicalize paths only for local filesystems

Now that virStorageFileGetMetadataFromBuf is used only for remote
filesystems, don't canonicalize the path in it.

10 years agostorage: fs: Drop-in replace use of virStorageFileGetMetadataFromBuf
Peter Krempa [Wed, 28 May 2014 12:48:36 +0000 (14:48 +0200)]
storage: fs: Drop-in replace use of virStorageFileGetMetadataFromBuf

Use virStorageFileGetMetadataFromFD instead in
virStorageBackendProbeTarget as it now returns all required data and the
storage file is already open in a filedescriptor.

Also fix improper error code being returned when virFileReadHeaderFD
would fail as virStorageBackendUpdateVolTargetInfoFD would set the
return code to 0.

10 years agostorage: Return backing format from virStorageFileGetMetadataFromFD
Peter Krempa [Wed, 28 May 2014 12:41:24 +0000 (14:41 +0200)]
storage: Return backing format from virStorageFileGetMetadataFromFD

Add argument to return backing file format of a file probed by
virStorageFileGetMetadataFromFD so that it can be used in place of
virStorageFileGetMetadataFromBuf.

10 years agoqemu: reject rather than hang on blockcommit of active layer
Eric Blake [Tue, 27 May 2014 23:07:08 +0000 (17:07 -0600)]
qemu: reject rather than hang on blockcommit of active layer

qemu 2.0 added the ability to commit the active layer, but slightly
differently than what libvirt had been anticipating in its
implementation of the virDomainBlockCommit call.  As a result, if
you attempt to do a 'virsh blockcommit $dom vda', qemu gets into a
state where it is waiting on libvirt to end the job, while libvirt
is waiting on qemu to end the job, and the guest is effectively
hung with regards to further commands for that block device.

I have patches coming down the pipeline that will add full support
for blockcommit of the active layer when coupled with qemu 2.0 or
later; but they depend on Peter's improvements to block job handling
and form enough of a new feature that they are not ready for
inclusion in the 1.2.5 release.  So for now, just reject the
attempt, rather than letting the user get stuck.  This is no worse
than the behavior of qemu 1.7 rejecting the job.

* src/qemu/qemu_driver.c (qemuDomainBlockCommit): Reject active
commit.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agodoc: fix documentation of virDomainSet(Get)Metadata
Dan Kenigsberg [Wed, 28 May 2014 10:15:01 +0000 (11:15 +0100)]
doc: fix documentation of virDomainSet(Get)Metadata

The documentation of the functions should match the argument name in the actual
function signature.

Signed-off-by: Dan Kenigsberg <danken@redhat.com>
10 years agoqemu: Fix specifying char devs for PPC
Olivia Yin [Tue, 27 May 2014 05:44:14 +0000 (13:44 +0800)]
qemu: Fix specifying char devs for PPC

QEMU ppce500 board uses the legacy -serial option.

Other PPC boards don't give any way to explicitly wire in a -chardev
except pseries which uses -device spapr-vty with -chardev.

Add test case for -serial option for ppce500

Signed-off-by: Olivia Yin <Hong-Hua.Yin@freescale.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
10 years agochange machine name ppce500v2 to ppce500
Olivia Yin [Tue, 27 May 2014 05:44:13 +0000 (13:44 +0800)]
change machine name ppce500v2 to ppce500

ppce500v2 is not machine supported by official release of QEMU.
It should be replaced by ppce500.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
10 years agoFix an extra ' in a translated string
Daniel Veillard [Mon, 26 May 2014 13:51:26 +0000 (21:51 +0800)]
Fix an extra ' in a translated string

Raised by ukrainian translator Yuri Chornoivan
https://fedora.transifex.com/projects/p/libvirt/translate/#uk/strings/25483059

10 years agoClean up chardev sockets on QEMU shutdown
Ján Tomko [Tue, 13 May 2014 06:54:20 +0000 (08:54 +0200)]
Clean up chardev sockets on QEMU shutdown

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

Clean up unix socket files for chardevs using mode='bind',
like we clean up the monitor socket.
They are created by QEMU on startup and not really useful
after shutting it down.

10 years agoqemu: fix <clock offset='variable' basis='localtime'/>
Laine Stump [Wed, 21 May 2014 14:20:50 +0000 (17:20 +0300)]
qemu: fix <clock offset='variable' basis='localtime'/>

For a clock element as above, libvirt simply converts current system
time with localtime_r(), then starts qemu with a time string that
doesn't contain any timezone information. So, from qemu's point of
view, the -rtc string it gets for:

   <clock offset='variable' basis='utc' adjustment='10800'/>

is identical to the -rtc string it gets for:

   <clock offset='variable' basis='localtime' adjustment='0'/>

(assuming the host is in a timezone that is 10800 seconds ahead of
UTC, as is the case on the machine where this message is being
written).

Since the commandlines are identical, qemu will behave identically
after this point in either case.

There are two problems in the case of basis='localtime' though:

Problem 1) If the guest modifies its RTC, for example to add 20
seconds, the RTC_CHANGE event from qemu will then contain offset:20 in
both cases. But libvirt will have saved the original adjustment into
adjustment0, and will add that value onto the offset in the
event. This means that in the case of basis=;utc', it will properly
emit an event with offset:10820, but in the case of basis='localtime'
the event will contain offset:20, which is *not* the new offset of the
RTC from UTC (as the event it documented to provide).

Problem 2) If the guest is migrated to another host that is in a
different timezone, or if it is migrated or saved/restored after the
DST status has changed from what it was when the guest was originally
started, the newly restarted guest will have a different RTC (since it
will be based on the new localtime, which could have shifted by
several hours).

The solution to both of these problems is simple - rather than
maintaining the original adjustment value along with
"basis='localtime'" in the domain status, when the domain is started
we convert the adjustment offset to one relative to UTC, and set the
status to "basis='utc'". Thus, whatever the RTC offset was from UTC
when it was initially started, that offset will be maintained when
migrating across timezones and DST settings, and the RTC_CHANGE events
will automatically contain the proper offset (which should by
definition always be relative to UTC).

This fixes a problem that was implied but not openly stated in:

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

10 years agoqemu: fix RTC_CHANGE event for <clock offset='variable' basis='utc'/>
Laine Stump [Wed, 21 May 2014 09:54:34 +0000 (12:54 +0300)]
qemu: fix RTC_CHANGE event for <clock offset='variable' basis='utc'/>

commit e31b5cf393857 attempted to fix libvirt's
VIR_DOMAIN_EVENT_ID_RTC_CHANGE, which is documentated to always
provide the new offset of the domain's real time clock from UTC. The
problem was that, in the case that qemu is provided with an "-rtc
base=x" where x is an absolute time (rather than "utc" or
"localtime"), the offset sent by qemu's RTC_CHANGE event is *not* the
new offset from UTC, but rather is the sum of all changes to the
domain's RTC since it was started with base=x.

So, despite what was said in commit e31b5cf393857, if we assume that
the original value stored in "adjustment" was the offset from UTC at
the time the domain was started, we can always determine the current
offset from UTC by simply adding the most recent (i.e. current) offset
from qemu to that original adjustment.

This patch accomplishes that by storing the initial adjustment in the
domain's status as "adjustment0". Each time a new RTC_CHANGE event is
received from qemu, we simply add adjustment0 to the value sent by
qemu, store that as the new adjustment, and forward that value on to
any event handler.

This patch (*not* e31b5cf393857, which should be reverted prior to
applying this patch) fixes:

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

(for the case where basis='utc'. It does not fix basis='localtime')

10 years agoRevert "qemu: Report the offset from host UTC for RTC_CHANGE event"
Laine Stump [Tue, 20 May 2014 11:43:33 +0000 (14:43 +0300)]
Revert "qemu: Report the offset from host UTC for RTC_CHANGE event"

This reverts commit e31b5cf393857a6ca78d148c19393e28dfb39de1.

This commit attempted to work around a bug in the offset value
reported by qemu's RTC_CHANGE event in the case that a variable base
date was given on the qemu commandline. The patch mixed up the math
involved in arriving at the corrected offset to report, and in the
process added an unnecessary private attribute to the clock
element. Since that element is private/internal and not used by anyone
else, it makes sense to simplify things by removing it.

10 years agoutil: new function virTimeLocalOffsetFromUTC
Laine Stump [Sat, 24 May 2014 14:21:26 +0000 (08:21 -0600)]
util: new function virTimeLocalOffsetFromUTC

Since there isn't a single libc API to get this value, this patch
supplies one which gets the value by grabbing current time, then
converting that into a struct tm with gmtime_r(), then back to a
time_t using mktime.

The returned value is the difference between UTC and localtime in
seconds. If localtime is ahead of UTC (east) the offset will be a
positive number, and if localtime is behind UTC (west) the offset will
be negative.

This function should be POSIX-compliant, and is threadsafe, but not
async signal safe. If it was ever necessary to know this value in a
child process, we could cache it with a one-time init function when
libvirtd starts, then just supply the cached value, but that
complexity isn't needed for current usage; that would also have the
problem that it might not be accurate after a local daylight savings
boundary.

(If it weren't for DST, we could simply replace this entire function
with "-timezone"; timezone contains the offset of the current timezone
(negated from what we want) but doesn't account for DST. And in spite
of being guaranteed by POSIX, it isn't available on older versions of
mingw.)

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agostorage: Add storage file API to read file headers
Peter Krempa [Fri, 7 Mar 2014 10:53:18 +0000 (11:53 +0100)]
storage: Add storage file API to read file headers

Add storage driver based functions to access headers of storage files
for metadata extraction. Along with this patch a local filesystem and
gluster via libgfapi implementation is provided. The gluster
implementation is based on code of the saferead_lim function.

10 years agostorage: Add support for access to files using provided uid/gid
Peter Krempa [Fri, 25 Apr 2014 11:45:48 +0000 (13:45 +0200)]
storage: Add support for access to files using provided uid/gid

To allow using the storage driver APIs to access files on various
storage sources in a universal fashion possibly on storage such as nfs
with root squash we'll need to store the desired uid/gid in the
metadata.

Add new initialisation API that will store the desired uid/gid and a
wrapper for the current use. Additionally add docs for the two APIs.

10 years agostorage: Add NONE protocol type for network disks
Peter Krempa [Thu, 24 Apr 2014 14:11:44 +0000 (16:11 +0200)]
storage: Add NONE protocol type for network disks

Currently the protocol type with index 0 was NBD which made it hard to
distinguish whether the protocol type was actually assigned. Add a new
protocol type with index 0 to distinguish it explicitly.

10 years agoconf: Fix domain disk path iterator to work with networked storage
Peter Krempa [Sat, 26 Apr 2014 09:38:29 +0000 (11:38 +0200)]
conf: Fix domain disk path iterator to work with networked storage

Skip networked storage but continue iteration through backing chain to
iterate through all the local paths in the backing chain.

10 years agostorage: Rework debugging of storage file access through storage driver
Peter Krempa [Fri, 2 May 2014 14:51:48 +0000 (16:51 +0200)]
storage: Rework debugging of storage file access through storage driver

Print the debug statements of individual file access functions from the
main API functions instead of the individual backend functions.

Also enhance initialization debug messages on a per-backend basis.

10 years agostorage: Store gluster volume name separately
Peter Krempa [Fri, 2 May 2014 14:17:42 +0000 (16:17 +0200)]
storage: Store gluster volume name separately

The gluster volume name was previously stored as part of the source path
string. This is unfortunate when we want to do operations on the path as
the volume is used separately.

Parse and store the volume name separately for gluster storage volumes
and use the newly stored variable appropriately.

10 years agoqemu: Make qemuDomainPrepareDiskChainElement aware of remote storage
Peter Krempa [Mon, 5 May 2014 08:34:16 +0000 (10:34 +0200)]
qemu: Make qemuDomainPrepareDiskChainElement aware of remote storage

Refactor the function to accept a virStorageSourcePtr instead of just
the path, add a check to run it only on local storage and fix callers
(possibly by using a newly introduced wrapper that wraps a path in the
 virStorageSource struct for legacy code)

10 years agoqemu: process: Refresh backing chain info when reconnecting to qemu
Peter Krempa [Fri, 16 May 2014 13:16:18 +0000 (15:16 +0200)]
qemu: process: Refresh backing chain info when reconnecting to qemu

Refresh the disk backing chains when reconnecting to a qemu process
after daemon restart. There are a few internal fields that don't get
refreshed from the XML. Until we are able to do that, let's reload all
the metadata by the backing chain crawler.

10 years agoqemu: Properly abort migration to a file
Jiri Denemark [Thu, 22 May 2014 10:38:47 +0000 (12:38 +0200)]
qemu: Properly abort migration to a file

This is similar to the previous commit in that we need to explicitly
send migrate_cancel when libvirt detects an error other than those
reported by query-migrate. However, the possibility to hit such error is
pretty small.

10 years agoqemu: Send migrate_cancel when aborting migration
Jiri Denemark [Thu, 22 May 2014 10:29:20 +0000 (12:29 +0200)]
qemu: Send migrate_cancel when aborting migration

When QEMU reports failed or cancelled migration, we don't need to send
it migrate_cancel QMP command. But in all other error paths, such as if
we detect broken connection to a destination daemon or something else
happens inside libvirt, we need to explicitly send migrate_cancel
command instead of relying on the migration to be implicitly cancelled
when destination QEMU is killed.

Because we were not doing so, one could end up with a paused domain
after failed migration.

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

10 years agoFix error message when TUNNELLED flag is used in non-p2p migration
Jiri Denemark [Thu, 22 May 2014 11:18:21 +0000 (13:18 +0200)]
Fix error message when TUNNELLED flag is used in non-p2p migration

The current error message is

    error: use virDomainMigrateToURI3 for peer-to-peer migration

which is correct but a bit misleading because the client did not specify
VIR_MIGRATE_PEER2PEER flag. This patch changes the error message to

    error: cannot perform tunnelled migration without using peer2peer
    flag

which is consistent with the error reported by older migration APIs.

Reported by Rich Jones in
https://bugzilla.redhat.com/show_bug.cgi?id=1095924

10 years agoconf: fix backing store parse off-by-one
Eric Blake [Thu, 22 May 2014 03:45:02 +0000 (21:45 -0600)]
conf: fix backing store parse off-by-one

Commit 546154e parses the type attribute from a <backingStore>
element, but forgot that the earlier commit 9673418 added a
placeholder element in the same 1.2.3 release; as a result,
the C code was mistakenly allowing "none" as a type.

Similarly, the same commit allows "none" as the <format>
sub-element type, even though that has been a placeholder
since the 0.10.2 release with commit f772b3d.

* src/conf/domain_conf.c (virDomainDiskBackingStoreParse): Require
non-zero types.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoDon't log an internal error when the guest hasn't updated balloon stats
Ján Tomko [Wed, 14 May 2014 07:35:18 +0000 (09:35 +0200)]
Don't log an internal error when the guest hasn't updated balloon stats

If virDomainMemoryStats is called too soon after domain startup,
QEMU returns:
"error":{"class":"GenericError","desc":"guest hasn't updated any stats yet"}
when we try to query balloon stats.

Check for this reply and log it as OPERATION_INVALID instead of
INTERNAL_ERROR. This means the daemon only logs it at the debug level,
without polluting system logs.

Reported by Laszlo Pal:
https://www.redhat.com/archives/libvirt-users/2014-May/msg00023.html

10 years agoqemuSetupCgroupForVcpu: s/virProcessInfoSetAffinity/virProcessSetAffinity/
Michal Privoznik [Thu, 22 May 2014 10:30:20 +0000 (12:30 +0200)]
qemuSetupCgroupForVcpu: s/virProcessInfoSetAffinity/virProcessSetAffinity/

In the f56c773bf we've made the substitution but forgot to fix one
comment which is still referring to the old name. This may be
potentially misleading.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agobhyve: fix virObjectUnlock() usage
Roman Bogorodskiy [Sat, 17 May 2014 19:08:14 +0000 (23:08 +0400)]
bhyve: fix virObjectUnlock() usage

In a number of places in the bhyve driver, virObjectUnlock()
is called with an arg without check if the arg is non-NULL, which
could result in passing NULL value and a warning like:

virObjectUnlock:340 : Object 0x0 ((unknown)) is not a virObjectLockable instance

* src/bhyve/bhyve_driver.c (bhyveDomainGetInfo)
(bhyveDomainGetState, bhyveDomainGetAutostart)
(bhyveDomainSetAutostart, bhyveDomainIsActive)
(bhyveDomainIsPersistent, bhyveDomainGetXMLDesc)
(bhyveDomainUndefine, bhyveDomainLookupByUUID)
(bhyveDomainLookupByName, bhyveDomainLookupByID)
(bhyveDomainCreateWithFlags, bhyveDomainOpenConsole):
Check if arg is not NULL before calling virObjectUnlock on it.

10 years agovirdbus: Show method name in error message
Cole Robinson [Sat, 3 May 2014 19:53:03 +0000 (15:53 -0400)]
virdbus: Show method name in error message

If you trigger bug 1033369, we get the error message:

  error from service: Invalid argument

Which is a bit too generic to pinpoint what is actually failing. This
changes it to:

  error from service: CreateMachine: Invalid argument

Acked-by: Eric Blake <eblake@redhat.com>
10 years agovirdbus: Remove redundant error macro
Cole Robinson [Sat, 3 May 2014 19:46:52 +0000 (15:46 -0400)]
virdbus: Remove redundant error macro

This is the only callsite.

We drop use of localerror.name here, because it's not actually useful
to us: rather than the parameter name which received an invalid value
(which was assumed), it's actually the the dbus errno equivalent.
Just use the error string.

Acked-by: Eric Blake <eblake@redhat.com>
10 years agotests: avoid dlsym mocking on mingw
Eric Blake [Tue, 20 May 2014 21:04:44 +0000 (15:04 -0600)]
tests: avoid dlsym mocking on mingw

I got a build failure when cross-compiling to mingw with the
mingw64-dbus package installed:

  CC       virmockdbus_la-virmockdbus.lo
../../tests/virmockdbus.c:29:6: error: 'dbus_connection_set_change_sigpipe' redeclared without dllimport attribute: previous dllimport ignored [-Werror=attributes]
 VIR_MOCK_STUB_VOID_ARGS(dbus_connection_set_change_sigpipe,
      ^
../../tests/virmockdbus.c:33:18: error: 'dbus_bus_get' redeclared without dllimport attribute: previous dllimport ignored [-Werror=attributes]
 VIR_MOCK_STUB_RET_ARGS(dbus_bus_get,
...

Well duh - mingw lacks dlopen and friends, even if it can support
dbus.  A similar failure occured in virsystemdtest.c; but in that
file, we know that systemd is a Linux-only concept.

* tests/virmockdbus.c: Cripple on mingw.
* tests/virsystemdtest.c: Cripple on non-Linux.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoqemu: snapshot: Fix return value of external checkpoint with no disks
Peter Krempa [Tue, 20 May 2014 13:22:14 +0000 (15:22 +0200)]
qemu: snapshot: Fix return value of external checkpoint with no disks

When doing an external checkpoint of a VM with no disk selected we'd
return failure but not set error code. This was a result of ret not
being set to 0 during walking of the disk array.

Rework early failure checking and set the error code to success before
iterating the array of disks so that we return success if no disks are
snapshotted.

Fixes the following symptom (or without --diskspec for diskless VMs)

 $ virsh snapshot-create-as snapshot-test  --memspec /tmp/asdf --diskspec hda,snapshot=no
 error: An error occurred, but the cause is unknown

10 years agoqemu: snapshot: Forbid empty snapshots
Peter Krempa [Tue, 20 May 2014 12:22:25 +0000 (14:22 +0200)]
qemu: snapshot: Forbid empty snapshots

If neither disks nor memory are selected for snapshot we'd record
metadata in case of external snapshot and do a disk snapshot in case of
external disk snapshot. Forbid this as it doesn't make much sense.

10 years agoqemu: snapshot: Forbid partial internal snapshots
Peter Krempa [Tue, 20 May 2014 12:04:23 +0000 (14:04 +0200)]
qemu: snapshot: Forbid partial internal snapshots

qemu's savevm command does a snapshot of all non readonly disks of a VM.
Libvirt though allowed disabling snapshot for certain disk of a VM.

10 years agoqemu: snapshot: Use typecasted switch in qemuDomainSnapshotPrepare()
Peter Krempa [Tue, 20 May 2014 08:38:42 +0000 (10:38 +0200)]
qemu: snapshot: Use typecasted switch in qemuDomainSnapshotPrepare()

Convert the switch to a typecasted value so that the compiler tracks
additions for us.

10 years agobhyve: domain events support
Roman Bogorodskiy [Wed, 23 Apr 2014 11:55:05 +0000 (15:55 +0400)]
bhyve: domain events support

Support events for these functions:

 - domainDefineXML
 - domainUndefine
 - domainCreate{WithFlags,XML}
 - domainDestroy

10 years agomigration: add support for migrateURI configuration
Chen Fan [Tue, 20 May 2014 06:08:05 +0000 (14:08 +0800)]
migration: add support for migrateURI configuration

For now, we set the migration URI via command line '--migrate_uri' or
construct the URI by looking up the dest host's hostname which could be
solved by DNS automatically.

But in cases the dest host have two or more NICs to reach, we may need to
send the migration data over a specific NIC which is different from the
automatically resolved one for some reason like performance, security, etc.
Thus we must explicitly specify the migrateuri in command line everytime,
but it is too troublesome if there are many such hosts (and don't forget
virt-manager).

This patch adds a configuration file option on dest host to save the
default value set which can be specified to a migration hostname or
one of this host's addresses used for transferring data, thus user doesn't
have to specify it in command line everytime.

Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agoutil: refactor virNetlinkCommand to fix several bugs / style problems
Laine Stump [Tue, 13 May 2014 11:34:43 +0000 (14:34 +0300)]
util: refactor virNetlinkCommand to fix several bugs / style problems

Inspired by a simpler patch from "Wangrui (K) <moon.wangrui@huawei.com>".

A submitted patch pointed out that virNetlinkCommand() was doing an
improper typecast of the return value from nl_recv() (int to
unsigned), causing it to miss error returns, and that even after
remedying that problem, virNetlinkCommand() was calling VIR_FREE() on
the pointer returned from nl_recv() (*resp) even if nl_recv() had
returned an error, and that in this case the pointer was verifiably
invalid, as it was pointing to memory that had been allocated by
libnl, but then freed prior to returning the error.

While reviewing this patch, I noticed several other problems with this
seemingly simple function (at least one of them as serious as the
problem being reported/fixed by the aforementioned patch), and decided
they all deserved to be fixed. Here is the list:

1) The return value from nl_recv() must be assigned to an int (rather
   than unsigned int) in order to detect failure.

2) When nl_recv() returns an error or 0, the contents of *resp is
   invalid, and should be simply set to 0, *not* VIR_FREE()'d.

3) When nl_recv() returns 0, errno is not set, so the logged error
   message should not reference errno (it *is* an error though).

4) The first error return from virNetlinkCommand returns -EINVAL,
   incorrectly implying that the caller can expect the return value to
   be of the "-errno" variety, which is not true in any other case.

5) The 2nd error return returns directly with garbage in *resp. While
   the caller should never use *resp in this case, it's still good
   practice to set it to NULL.

6) For the next 5 (!!) error conditions, *resp will contain garbage,
   and virNetlinkCommand() will goto it's cleanup code which will
   VIR_FREE(*resp), almost surely leading to a segfault.

In addition to fixing these 6 problems, this patch also makes the
following two changes to make the function conform more closely to the
style of other libvirt code:

1) Change the handling of return code from "named rc and defaulted to
0, but changed to -1 on error" to the more common "named ret and
defaulted to -1, but changed to 0 on success".

2) Rename the "error" label to "cleanup", since the code that follows
is executed in success cases as well as failure.

10 years agobuild: nuke more uses of 'sync'
Eric Blake [Mon, 19 May 2014 23:02:42 +0000 (17:02 -0600)]
build: nuke more uses of 'sync'

Commit d5c86278 was incomplete; other functions also triggered
compiler warnings about collisions in the use of 'sync'.

* src/qemu/qemu_driver.c (qemuDomainSetTime): Fix another client.
* tools/virsh-domain-monitor.c (cmdDomTime): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoavoid 'sync' as variable name
Pavel Hrdina [Mon, 19 May 2014 14:36:55 +0000 (16:36 +0200)]
avoid 'sync' as variable name

Old gcc complains about shadowing 'sync' variable:

../../src/qemu/qemu_agent.c: In function 'qemuAgentSetTime':
../../src/qemu/qemu_agent.c:1737: warning: declaration of 'sync'
  shadows a global declaration [-Wshadow]
/usr/include/unistd.h:464: warning: shadowed declaration is here
  [-Wshadow]

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agoReturn error when updating cdrom device
Pavel Hrdina [Mon, 19 May 2014 13:48:43 +0000 (15:48 +0200)]
Return error when updating cdrom device

The commit 84c59ffa improved the way we change ejectable media.
If for any reason the first "eject" didn't open the tray we
should return with error.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agoRevert "maint: prefer enum over int for virstoragefile structs"
Eric Blake [Sat, 17 May 2014 00:50:03 +0000 (18:50 -0600)]
Revert "maint: prefer enum over int for virstoragefile structs"

This partially reverts commits b279e52f7 and ea18f8b2.

It turns out our code base is full of:

if ((struct.member = virBlahFromString(str)) < 0)
    goto error;

Meanwhile, the C standard says it is up to the compiler whether
an enum is signed or unsigned when all of its declared values
happen to be positive.  In my testing (Fedora 20, gcc 4.8.2),
the compiler picked signed, and nothing changed.  But others
testing with gcc 4.7 got compiler warnings, because it picked
the enum to be unsigned, but no unsigned value is less than 0.
Even worse:

if ((struct.member = virBlahFromString(str)) <= 0)
    goto error;

is silently compiled without warning, but incorrectly treats -1
from a bad parse as a large positive number with no warning; and
without the compiler's help to find these instances, it is a
nightmare to maintain correctly.  We could force signed enums
with a dummy negative declaration in each enum, or cast the
result of virBlahFromString back to int after assigning to an
enum value, or use a temporary int for collecting results from
virBlahFromString, but those actions are all uglier than what we
were trying to cure by directly using enum types for struct
values in the first place.  It's better off to just live with int
members, and use 'switch ((virFoo) struct.member)' where we want
the compiler to help, than to track down all the conversions from
string to enum and ensure they don't suffer from type problems.

* src/util/virstorageencryption.h: Revert back to int declarations
with comment about enum usage.
* src/util/virstoragefile.h: Likewise.
* src/conf/domain_conf.c: Restore back to casts in switches.
* src/qemu/qemu_driver.c: Likewise.
* src/qemu/qemu_command.c: Add cast rather than revert.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoFix crash in DAC driver with no seclabels
Ján Tomko [Mon, 19 May 2014 11:50:52 +0000 (13:50 +0200)]
Fix crash in DAC driver with no seclabels

With dynamic_ownership = 1 but no seclabels, RestoreChardevLabel
dereferences the NULL seclabel when checking if norelabel is set.

Remove this check, since it is already done in RestoreSecurityAllLabel
and if norelabel is set, RestoreChardevLabel is never called.