]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
10 years agoIntroduce virBitmapDataToString
Ján Tomko [Thu, 5 Jun 2014 09:23:28 +0000 (11:23 +0200)]
Introduce virBitmapDataToString

For converting bitmap data to human-readable strings.

10 years agoAlways report an error if virBitmapFormat fails
Ján Tomko [Thu, 5 Jun 2014 09:24:24 +0000 (11:24 +0200)]
Always report an error if virBitmapFormat fails

It already reports an error if STRDUP fails.

10 years agoFormat NULL bitmap as an empty string
Ján Tomko [Thu, 5 Jun 2014 10:42:40 +0000 (12:42 +0200)]
Format NULL bitmap as an empty string

This simplifies the usage in {libxl,qemu}DomainGetNumaParameters
and it's needed for consistent error reporting in virBitmapFormat.

Also remove the forgotten ATTRIBUTE_NONNULL marker.

10 years agovirsh: Separate API calls and result printing in cmdVcpuinfo
Ján Tomko [Thu, 5 Jun 2014 08:42:23 +0000 (10:42 +0200)]
virsh: Separate API calls and result printing in cmdVcpuinfo

This allows reuse of the result printing code.

10 years agovirsh: Invert logic in cmdVcpuinfo
Ján Tomko [Thu, 5 Jun 2014 08:42:19 +0000 (10:42 +0200)]
virsh: Invert logic in cmdVcpuinfo

Initialize 'ret' to false and introduce a cleanup label.

10 years agoParallels: Include CPU info in the capabilities XML
Alexander Burluka [Thu, 5 Jun 2014 05:50:06 +0000 (09:50 +0400)]
Parallels: Include CPU info in the capabilities XML

Openstack uses (or will start to using) CPU info from the
capabilities XML. So this section is expanded, added CPU info
about arch, type and info about number of cores, sockets and threads.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoParallels: add connectBaselineCPU()
Alexander Burluka [Thu, 5 Jun 2014 05:50:05 +0000 (09:50 +0400)]
Parallels: add connectBaselineCPU()

Openstack Nova (starting at Icehouse release) requires this function
to start VM.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoParallels: add domainGetVcpus()
Alexander Burluka [Thu, 5 Jun 2014 05:50:04 +0000 (09:50 +0400)]
Parallels: add domainGetVcpus()

OpenStack Nova requires this function
to start VM instance. Cpumask info is obtained via prlctl utility.
Unlike KVM, Parallels Cloud Server is unable to set cpu affinity
mask for every VCpu. Mask is unique for all VCpu. You can set it
using 'prlctl set <vm_id|vm_name> --cpumask <{n[,n,n1-n2]|all}>'
command. For example, 'prlctl set SomeDomain --cpumask 0,1,5-7'
would set this mask to yy---yyy.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agomaint: prohibit empty first lines
Martin Kletzander [Tue, 18 Mar 2014 10:29:12 +0000 (11:29 +0100)]
maint: prohibit empty first lines

Based on discussion with Eric:

https://www.redhat.com/archives/libvir-list/2014-March/msg01001.html

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoRemove unnecessary empty first lines
Martin Kletzander [Fri, 6 Jun 2014 08:51:52 +0000 (10:51 +0200)]
Remove unnecessary empty first lines

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agotranslations: Don't leave default template fields in .po files
Martin Kletzander [Tue, 3 Jun 2014 15:18:33 +0000 (17:18 +0200)]
translations: Don't leave default template fields in .po files

New gettext-0.19 doesn't like it and we can't build without it.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoFix storage format probing
Ján Tomko [Thu, 5 Jun 2014 16:47:21 +0000 (18:47 +0200)]
Fix storage format probing

Commit fff74b2 moved the probing into virStorageFileGetMetadataFromBuf
but didn't update the format in volume definition.

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

10 years agoSimplify conditions in virStorageBackendProbeTarget
Ján Tomko [Thu, 5 Jun 2014 16:22:48 +0000 (18:22 +0200)]
Simplify conditions in virStorageBackendProbeTarget

Jump out early if no metadata was detected (for directories).
Join the error and cleanup labels.

10 years agoDon't reuse 'ret' variable in virStorageBackendProbeTarget
Ján Tomko [Thu, 5 Jun 2014 16:19:16 +0000 (18:19 +0200)]
Don't reuse 'ret' variable in virStorageBackendProbeTarget

To match the convention:
ret - current function's return value
rc - other function's return values

10 years agoformatcaps: Rework and add stubs to document
Michal Privoznik [Thu, 5 Jun 2014 11:53:17 +0000 (13:53 +0200)]
formatcaps: Rework and add stubs to document

At the moment we are missing even basic documentation on our
capabilities XML. Without demand on completeness, I'm
reorganizing the document structure and adding very basic
documentation to two major components of the capabilities XML.
These stubs are intended to be enhanced in the future.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovircaps2xmltest: Introduce basic testing
Michal Privoznik [Thu, 5 Jun 2014 11:53:16 +0000 (13:53 +0200)]
vircaps2xmltest: Introduce basic testing

For now only one test is introduced. It's purpose in life
is to check we don't break NUMA host distances XML format.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agolibxl: add migration support
Jim Fehlig [Thu, 8 May 2014 21:56:51 +0000 (15:56 -0600)]
libxl: add migration support

This patch adds initial migration support to the libxl driver,
using the VIR_DRV_FEATURE_MIGRATION_PARAMS family of migration
functions.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
10 years agolibxl: introduce libxlDomainDefCheckABIStability
Jim Fehlig [Wed, 4 Jun 2014 20:02:27 +0000 (14:02 -0600)]
libxl: introduce libxlDomainDefCheckABIStability

Introduce a simple libxlDomainDefCheckABIStability() function that
can be used check ABI stability between two virDomainDef objects.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
10 years agomaint: detect VPATH builds when checking for gnulib update
Eric Blake [Wed, 4 Jun 2014 21:48:20 +0000 (15:48 -0600)]
maint: detect VPATH builds when checking for gnulib update

I accidentally typed 'make' in the srcdir of a VPATH build, and
was surprised to see this:

$ make
/bin/sh: s/^[ +-]//;s/ .*//: No such file or directory
INFO: gnulib update required; running ./autogen.sh first
make: -n: Command not found
./autogen.sh
I am going to run ./configure with no arguments - if you wish
to pass any to it, please specify them on the ./autogen.sh command line.
running bootstrap...
./bootstrap: Bootstrapping from checked-out libvirt sources...
./bootstrap: getting gnulib files...

Oops - we're trying to execute some fairly bogus command names,
and then trying to configure in-tree (which breaks all existing
VPATH builds, since automake refuses to do a VPATH build if it
detects an in-tree configure).  The third line (executing "-n")
is fixed by updating to the latest gnulib; the rest of the problem
is fixed by copying the same filtering in our cfg.mk as what
gnulib just added, so that we avoid any $(shell) invocations which
in turn depend on variables that are only populated by a working
Makefile.  With that in place, we are back to the much nicer:

$ make
There seems to be no Makefile in this directory.
You must run ./configure before running 'make'.
make: *** [abort-due-to-no-makefile] Error 1

Additionally, although harder to see - there was a trailing space in
the message warning us that autogen would run an in-tree configure.

* .gnulib: Update to latest, in part for maint.mk improvements.
* cfg.mk (_update_required): Don't check for update in
unconfigured directory.
* autogen.sh (no_git): Drop trailing space.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agomaint: optimize locale.h syntax check
Eric Blake [Wed, 4 Jun 2014 17:07:59 +0000 (11:07 -0600)]
maint: optimize locale.h syntax check

Reusing the maint.mk code allows for a more efficient syntax check
(fewer grep processes), and a more compact representation of what
we are really checking for in commit 1919e35.

* cfg.mk (sc_require_locale_h): Use maint.mk loop instead of
rolling our own.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agovirnuma: Check for numa_bitmask_isbitset presence
Michal Privoznik [Wed, 4 Jun 2014 12:39:01 +0000 (14:39 +0200)]
virnuma: Check for numa_bitmask_isbitset presence

On some systems, libnuma can be present but it's so ancient that
it misses some symbols that virNumaGetDistances() needs. To be
more precise: numa_bitmask_isbitset() and numa_nodes_ptr are the
symbols in question. Fortunately, they were both introduced in
the same release so it's sufficient for us to check for only one
of them. And the winner is numa_bitmask_isbitset().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agocfg.mk: Introduce rule for setlocale()
Michal Privoznik [Wed, 4 Jun 2014 08:57:21 +0000 (10:57 +0200)]
cfg.mk: Introduce rule for setlocale()

In the past we had some issues where setlocale() was called without
corresponding include of locale.h. While on some systems this may
work, on others the compilation failed. We should have a syntax-check
rule for that to prevent this from happening again.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirnuma: Implement virNumaGetDistances stub for non-NUMA
Michal Privoznik [Wed, 4 Jun 2014 09:05:34 +0000 (11:05 +0200)]
virnuma: Implement virNumaGetDistances stub for non-NUMA

In case the libvirt is built without numactl support, we're
missing the virNumaGetDistances() stub so the linking fails:

  CCLD     libvirt_lxc
libvirt_lxc-nodeinfo.o: In function `virNodeCapsGetSiblingInfo':
/home/zippy/tmp/libvirt.git/src/nodeinfo.c:1763: undefined reference to `virNumaGetDistances'
collect2: error: ld returned 1 exit status
make[3]: *** [libvirt_lxc] Error 1

The issue was introduced in 77c830d8c4.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
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)