]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
10 years agoReplace virInterfaceFree with virObjectUnref
John Ferlan [Sun, 30 Nov 2014 17:07:19 +0000 (12:07 -0500)]
Replace virInterfaceFree with virObjectUnref

Since virInterfaceFree will call virObjectUnref anyway, let's just use that
directly so as to avoid the possibility that we inadvertently clear out
a pending error message when using the public API.

10 years agoReplace virNWFilterFree with virObjectUnref
John Ferlan [Sun, 30 Nov 2014 17:03:00 +0000 (12:03 -0500)]
Replace virNWFilterFree with virObjectUnref

Since virNWFilterFree will call virObjectUnref anyway, let's just use that
directly so as to avoid the possibility that we inadvertently clear out
a pending error message when using the public API.

10 years agoReplace virSecretFree with virObjectUnref
John Ferlan [Sun, 30 Nov 2014 16:48:06 +0000 (11:48 -0500)]
Replace virSecretFree with virObjectUnref

Since virSecretFree will call virObjectUnref anyway, let's just use that
directly so as to avoid the possibility that we inadvertently clear out
a pending error message when using the public API.

10 years agoReplace virStreamFree with virObjectUnref
John Ferlan [Sun, 30 Nov 2014 15:19:38 +0000 (10:19 -0500)]
Replace virStreamFree with virObjectUnref

Since virStreamFree will call virObjectUnref anyway, let's just use that
directly so as to avoid the possibility that we inadvertently clear out
a pending error message when using the public API.

10 years agoReplace virStoragePoolFree with virObjectUnref
John Ferlan [Sun, 30 Nov 2014 14:35:12 +0000 (09:35 -0500)]
Replace virStoragePoolFree with virObjectUnref

Since virStoragePoolFree will call virObjectUnref anyway, let's just use that
directly so as to avoid the possibility that we inadvertently clear out
a pending error message when using the public API.

10 years agoReplace virStorageVolFree with virObjectUnref
John Ferlan [Sun, 30 Nov 2014 14:26:02 +0000 (09:26 -0500)]
Replace virStorageVolFree with virObjectUnref

Since virStorageVolFree will call virObjectUnref anyway, let's just use that
directly so as to avoid the possibility that we inadvertently clear out
a pending error message when using the public API.

10 years agoReplace virNodeDeviceFree with virObjectUnref
John Ferlan [Sat, 29 Nov 2014 12:03:35 +0000 (07:03 -0500)]
Replace virNodeDeviceFree with virObjectUnref

Since virNodeDeviceFree will call virObjectUnref anyway, let's just use that
directly so as to avoid the possibility that we inadvertently clear out
a pending error message when using the public API.

10 years agoReplace virNetworkFree with virObjectUnref
John Ferlan [Tue, 25 Nov 2014 12:42:58 +0000 (07:42 -0500)]
Replace virNetworkFree with virObjectUnref

Since virNetworkFree will call virObjectUnref anyway, let's just use that
directly so as to avoid the possibility that we inadvertently clear out
a pending error message when using the public API.

10 years agoReplace virDomainFree with virObjectUnref
John Ferlan [Sun, 30 Nov 2014 14:57:02 +0000 (09:57 -0500)]
Replace virDomainFree with virObjectUnref

Since virDomainFree will call virObjectUnref anyway, let's just use that
directly so as to avoid the possibility that we inadvertently clear out
a pending error message when using the public API.

10 years agorpc: Replace virXXXFree with virObjectUnref
John Ferlan [Sun, 30 Nov 2014 14:40:31 +0000 (09:40 -0500)]
rpc: Replace virXXXFree with virObjectUnref

Modify the various virXXXFree calls to only call virObjectUnref. Calling
the public API will reset the last error thus clearing out a pending error.

10 years agoparallels: fix compilation of parallels_storage.c
Dmitry Guryanov [Tue, 18 Nov 2014 13:02:04 +0000 (16:02 +0300)]
parallels: fix compilation of parallels_storage.c

virConnect.privateData is void *, so we can't access
fields of parallelsConn, pointer to which is stored in
virConnect.privateData. So replace all occurences of
conn->privateData->storageState with privconn->storageState.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
10 years agoGenerate a MAC when loading a config instead of package update
Ján Tomko [Tue, 11 Nov 2014 08:16:09 +0000 (09:16 +0100)]
Generate a MAC when loading a config instead of package update

Partially reverts commit 5754dbd.

The code in the specfile adds a MAC address to every <bridge>,
even for <forward mode='bridge'> for which we don't support
changing MAC addresses.

Remove it completely. For new networks, we have been adding
MAC addresses on definition/creation since the commit mentioned above.
For existing networks (pre-0.9.0), the MAC is added by this commit.

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

10 years agoSilently ignore MAC in NetworkLoadConfig
Ján Tomko [Mon, 10 Nov 2014 16:40:07 +0000 (17:40 +0100)]
Silently ignore MAC in NetworkLoadConfig

Libvirt's RPMs have been adding it to networks which don't support it.

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

10 years agolibvirt.c: Move virDomainGetFSInfo to libvirt-domain.c
Michal Privoznik [Tue, 2 Dec 2014 08:29:21 +0000 (09:29 +0100)]
libvirt.c: Move virDomainGetFSInfo to libvirt-domain.c

Since our big split of libvirt.c there are only a few functions
living there. The majority was moved to corresponding subfile,
e.g. domain functions were moved to libvirt-domain.c. However,
the patches for virDomainGetFSInfo() and virDomainFSInfoFree()
introduction were posted prior the big split and merged after.
This resulted in two domain functions landing in wrong file.
Move them to the correct one.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agonwfilter: fix crash when adding non-existing nwfilter
Pavel Hrdina [Mon, 1 Dec 2014 16:23:00 +0000 (17:23 +0100)]
nwfilter: fix crash when adding non-existing nwfilter

Adding non-existing nwfilter to a network interface device without any
nwfilter specified will crash libvirt daemon with segfault. The reason is
that the nwfilter is not found an libvirt will try to restore old
nwfilter configuration but there is no nwfilter specified.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agoconf: fix a comment typo in virDomainVideoDefaultRAM
Wang Rui [Tue, 2 Dec 2014 03:55:09 +0000 (11:55 +0800)]
conf: fix a comment typo in virDomainVideoDefaultRAM

Signed-off-by: Wang Rui <moon.wangrui@huawei.com>
10 years agoconf: replace call to virNetworkFree() with virObjectUnref()
Laine Stump [Tue, 25 Nov 2014 09:17:51 +0000 (04:17 -0500)]
conf: replace call to virNetworkFree() with virObjectUnref()

The function virNetworkObjListExport() in network_conf.c had a call to
the public API virNetworkFree() which was causing a link error:

CCLD     libvirt_driver_vbox_network_impl.la
 ./.libs/libvirt_conf.a(libvirt_conf_la-network_conf.o): In function `virNetworkObjListExport':
/home/laine/devel/libvirt/src/conf/network_conf.c:4496: undefined reference to `virNetworkFree'

This would happen when I added

  #include "network_conf.h"

into domain_conf.h, then attempted to call a new function from that
file (and enum converter, similar to virNetworkForwardTypeToString())

In the end, virNetworkFree() ends up just calling virObjectUnref(obj)
anyway (after clearing all pending errors, which we probably *don't*
want to do in the cleanup of a utility function), so this is likely
more correct than the original code as well.

10 years agobuild, docs: Let make see the dependencies for html/*.html
Martin Kletzander [Tue, 2 Dec 2014 06:50:18 +0000 (07:50 +0100)]
build, docs: Let make see the dependencies for html/*.html

Make was not able to realize the dependencies for html/*.html files when
running 'make -j9 dist'.  All the files are generated together with
html/index.html, so simply separating them into another variable and
adding one block into the dependency chain solves the issue.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agodocs: Correct invalid hyperlinks
Martin Kletzander [Mon, 1 Dec 2014 13:36:13 +0000 (14:36 +0100)]
docs: Correct invalid hyperlinks

Since libvirt.h was split into multiple files and similarly
docs/libvirt-libvirt.html, docs/hvsupport.html have bad hyperlinks.  The
same happens for all the html.in files that used <code class='docref'>
tag, because page.xsl has no idea where to point the link that's found.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoFix race condition in qemuGetProcessInfo
Eduardo Costa [Mon, 1 Dec 2014 20:24:20 +0000 (18:24 -0200)]
Fix race condition in qemuGetProcessInfo

There is a race condition between the fopen and fscanf calls
in qemuGetProcessInfo. If fopen succeeds, there is a small
possibility that the file no longer exists before reading from it.
Now, if either fopen or fscanf calls fail, the function will behave
just as only fopen had failed.

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

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agolibxl: Resolve Coverity CHECKED_RETURN
John Ferlan [Mon, 1 Dec 2014 16:10:18 +0000 (11:10 -0500)]
libxl: Resolve Coverity CHECKED_RETURN

Commit id 'cb88d433' refactored the calling sequence to use a thread;
however, in doing so "lost" the check for if virNetSocketAccept returns
failure.  Since other code makes that check, Coverity complains. Although
a false positive, adding back the failure check pacifies Coverity

10 years agodomain_conf: Resolve Coverity CHECKED_RETURN
John Ferlan [Wed, 29 Oct 2014 13:25:56 +0000 (09:25 -0400)]
domain_conf: Resolve Coverity CHECKED_RETURN

Commit id '0d36a5d05' modified the code slightly, but removed the
return value check thus causing Coverity to complain that this call
was the only one where the return value wasn't checked. Since nothing
was done previously if there was a failure, just use ignore_value here
to pacify Coverity

10 years agovirhook: Resolve Coverity NULL_RETURNS
John Ferlan [Tue, 30 Sep 2014 11:01:49 +0000 (07:01 -0400)]
virhook: Resolve Coverity NULL_RETURNS

Coverity complains that many other callers to return err from
virGetLastError() will check if err is not NULL before dereferencing
it.  Just do the same here for safety.

10 years agohotplug: Resolve Coverity FORWARD_NULL
John Ferlan [Tue, 30 Sep 2014 10:55:23 +0000 (06:55 -0400)]
hotplug: Resolve Coverity FORWARD_NULL

Coverity complained that because the cfg->macFilter call checked
net->ifname != NULL before calling ebtablesRemoveForwardAllowIn, then
the virNetDevOpenvswitchRemovePort call should have the same check.

However, if I move the ebtables call prior to the check for TYPE_DIRECT
(where there is a VIR_FREE(net->ifname)), then it seems Coverity is
happy.  Since firewall info is tacked on last during setup, removing
it in the opposite order of initialization seems to be natural anyway

10 years agostorage: Add mixed fc_host/scsi_host duplicate adapter source checks
John Ferlan [Fri, 14 Nov 2014 14:50:59 +0000 (09:50 -0500)]
storage: Add mixed fc_host/scsi_host duplicate adapter source checks

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

The virStoragePoolSourceFindDuplicate only checks the incoming definition
against the same type of pool as the def; however, for "scsi_host" and
"fc_host" adapter pools, it's possible that either some pool "scsi_host"
adapter definition is already using the scsi_hostN that the "fc_host"
adapter definition wants to use or some "fc_host" pool adapter definition
is using a vHBA scsi_hostN or parent scsi_hostN that an incoming "scsi_host"
definition is trying to use.

This patch adds the mismatched type checks and adds extraneous comments
to describe what each check is determining.

This patch also modifies the documentation to be describe what scsi_hostN
devices a "scsi_host" source adapter should use and which to avoid. It also
updates the parent definition to specifically call out that for mixed
environments it's better to define which parent to use so that the duplicate
pool checks can be done properly.

10 years agostorage: Move and rename getVhbaSCSIHostParent
John Ferlan [Mon, 17 Nov 2014 13:40:59 +0000 (08:40 -0500)]
storage: Move and rename getVhbaSCSIHostParent

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

Move the API from the backend to storage_conf and rename it to
virStoragePoolGetVhbaSCSIHostParent.  A future patch will need to
use this functionality from storage_conf

10 years agoconf: Don't redefine virDomainTPMDefPtr
Martin Kletzander [Mon, 1 Dec 2014 12:19:55 +0000 (13:19 +0100)]
conf: Don't redefine virDomainTPMDefPtr

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoqemu: Make pid available for security managers in qemuProcessAttach
Luyao Huang [Mon, 1 Dec 2014 09:54:35 +0000 (17:54 +0800)]
qemu: Make pid available for security managers in qemuProcessAttach

There are some small issue in qemuProcessAttach:

1.Fix virSecurityManagerGetProcessLabel always get pid = 0,
move 'vm->pid = pid' before call virSecurityManagerGetProcessLabel.

2.Use virSecurityManagerGenLabel to get image label.

3.Fix always set selinux label for other security driver label.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
10 years agoconf: Add device-related code for panic devices
Martin Kletzander [Sun, 30 Nov 2014 19:54:50 +0000 (20:54 +0100)]
conf: Add device-related code for panic devices

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoconf: Add device-related code for TPM devices
Martin Kletzander [Sun, 30 Nov 2014 19:54:50 +0000 (20:54 +0100)]
conf: Add device-related code for TPM devices

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoqemu: fix block{commit,copy} abort handling
Erik Skultety [Thu, 27 Nov 2014 12:29:42 +0000 (13:29 +0100)]
qemu: fix block{commit,copy} abort handling

When a block{commit,copy} job was aborted on a domain, block job handler
did not process it correctly, leaving a phantom job in the background.
Any further calls to any blockjob causes "block <jobtype> still active"
error. This patch fixes the blockjob handler so that it checks not only
for VIR_DOMAIN_BLOCK_JOB_FAILED status, but VIR_DOMAIN_BLOCK_JOB_CANCELED
status as well, followed by our existing cleanup routine.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agoqemu: set jobinfo type to FAILED if job is failed in qemuMigrationRun
Wang Rui [Mon, 1 Dec 2014 07:05:33 +0000 (15:05 +0800)]
qemu: set jobinfo type to FAILED if job is failed in qemuMigrationRun

If job is failed in qemuMigrationRun, we expect the jobinfo type as
FAILED. But jobinfo type won't be updated until entering
qemuMigrationWaitForCompletion. We should make it updated in all
conditions. Moreover, we can't use qemuMigrationUpdateJobStatus
here because job may fail in libvirt, so we can't query job status
from QEMU.

Signed-off-by: Wang Rui <moon.wangrui@huawei.com>
10 years agoqemu: set jobinfo type to CANCELLED if migration is cancelled in all conditions
Wang Rui [Mon, 1 Dec 2014 07:05:32 +0000 (15:05 +0800)]
qemu: set jobinfo type to CANCELLED if migration is cancelled in all conditions

The migration job status is traced in qemuMigrationUpdateJobStatus
which is called in qemuMigrationRun. But if migration is cancelled
before the trace such as in qemuMigrationDriveMirror, the jobinfo
type won't be updated to CANCELLED. After this patch, we can get
jobinfo type CANCELLED if migration is cancelled during drive
mirror.  Moreover, we can't use qemuMigrationUpdateJobStatus
because from qemu's point of view it's just the drive mirror being
cancelled and the migration hasn't even started yet.

Signed-off-by: Wang Rui <moon.wangrui@huawei.com>
10 years agodocs: Fix missing slashes in XML examples
Luyao Huang [Fri, 28 Nov 2014 06:44:24 +0000 (14:44 +0800)]
docs: Fix missing slashes in XML examples

When I pasted some XML from libvirt.org, I've found a small mistake.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
10 years agoqemu: Don't track quiesced state of FSs
Michal Privoznik [Thu, 27 Nov 2014 10:43:56 +0000 (11:43 +0100)]
qemu: Don't track quiesced state of FSs

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

As of b6d4dad11b (1.2.5) we are trying to keep the status of FSFreeze
in the guest. Even though I've tried to fixed couple of corner cases
(6ea54769ba18), it occurred to me just recently, that the approach is
broken by design. Firstly, there are many other ways to talk to
qemu-ga (even through libvirt) that filesystems can be thawed (e.g.
qemu-agent-command) without libvirt noticing. Moreover, there are
plenty of ways to thaw filesystems without even qemu-ga noticing (yes,
qemu-ga keeps internal track of FSFreeze status). So, instead of
keeping the track ourselves, or asking qemu-ga for stale state, it's
the best to let qemu-ga deal with that (and possibly let guest kernel
propagate an error).

Moreover, there's one bug with the following approach, if fsfreeze
command failed, we've executed fsthaw subsequently. So issuing
domfsfreeze in virsh gave the following result:

virsh # domfsfreeze gentoo
Froze 1 filesystem(s)

virsh # domfsfreeze gentoo
error: Unable to freeze filesystems
error: internal error: unable to execute QEMU agent command 'guest-fsfreeze-freeze': The command guest-fsfreeze-freeze has been disabled for this instance

virsh # domfsfreeze gentoo
Froze 1 filesystem(s)

virsh # domfsfreeze gentoo
error: Unable to freeze filesystems
error: internal error: unable to execute QEMU agent command 'guest-fsfreeze-freeze': The command guest-fsfreeze-freeze has been disabled for this instance

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoFix usage of virReportSystemError
Jiri Denemark [Fri, 28 Nov 2014 08:37:42 +0000 (09:37 +0100)]
Fix usage of virReportSystemError

virReportSystemError is reserved for reporting system errors, calling it
with VIR_ERR_* error codes produces error messages that do not make any
sense, such as

    internal error: guest failed to start: Kernel doesn't support user
    namespace: Link has been severed

We should prohibit wrong usage with a syntax-check rule.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agodocs: fix simple typo in TPM paragraph
Martin Kletzander [Fri, 28 Nov 2014 08:37:09 +0000 (09:37 +0100)]
docs: fix simple typo in TPM paragraph

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agotests: fix documentation for mocking methods
Martin Kletzander [Wed, 26 Nov 2014 10:55:59 +0000 (11:55 +0100)]
tests: fix documentation for mocking methods

It looks like it was copy-pasted, so in case anyone wonders what some of
those methods do without looking at them, and for the sake of
completeness, fix them.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoRevert "ip link needs 'name' in 3.16 to create the veth pair"
Martin Kletzander [Wed, 26 Nov 2014 08:25:43 +0000 (09:25 +0100)]
Revert "ip link needs 'name' in 3.16 to create the veth pair"

This reverts commit 433b427ff853ab72d32573d415e6ec569b77c7cb.

The patch was added in order to overcome a bug in iproute2 and since it
was properly identified as a bug, particularly in openSUSE 13.2, and it
is being worked on [1], the best solution for libvirt seems to be to
keep the old behaviour.

[1] https://bugzilla.novell.com/show_bug.cgi?id=907093

10 years agonetwork: Fix upgrade from libvirt older than 1.2.4
Jiri Denemark [Wed, 26 Nov 2014 15:24:27 +0000 (16:24 +0100)]
network: Fix upgrade from libvirt older than 1.2.4

Starting from libvirt-1.2.4, network state XML files moved to another
directory (see commit b9e95491) and libvirt automatically migrates the
network state files to a new location. However, the code used
dirent.d_type which is not supported by all filesystems. Thus, when
libvirt was upgraded on a host which used such filesystem, network state
XMLs were not properly moved and running networks disappeared from
libvirt.

This patch falls back to lstat() whenever dirent.d_type is DT_UNKNOWN to
fix this issue.

https://bugzilla.redhat.com/show_bug.cgi?id=1167145
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agoutil: Avoid calling closedir(NULL)
Jiri Denemark [Mon, 24 Nov 2014 16:37:13 +0000 (17:37 +0100)]
util: Avoid calling closedir(NULL)

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agovirsh: document block.n.allocation stat
Eric Blake [Mon, 24 Nov 2014 20:58:20 +0000 (13:58 -0700)]
virsh: document block.n.allocation stat

Commit 7557ddf added some additional block.* stats to
virDomainListGetStats, but failed to document them in 'man
virsh'.  Also, I noticed some inconsistent use of commas.

* tools/virsh.pod (domstats): Tweak commas, add missing stats.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agodbus: fix arrays of bools
Eric Blake [Sat, 22 Nov 2014 00:03:34 +0000 (17:03 -0700)]
dbus: fix arrays of bools

Commit 2aa167ca tried to fix the DBus interaction code to allow
callers to use native types instead of 4-byte bools.  But in
fixing the issue, I missed the case of an arrayref; Conrad Meyer
shows the following valid complaint issued by clang:

  CC       util/libvirt_util_la-virdbus.lo
util/virdbus.c:956:13: error: cast from 'bool *' to 'dbus_bool_t *' (aka 'unsigned int *') increases required alignment from 1 to 4 [-Werror,-Wcast-align]
            GET_NEXT_VAL(dbus_bool_t, bool_val, bool, "%d");
            ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
util/virdbus.c:858:17: note: expanded from macro 'GET_NEXT_VAL'
            x = (dbustype *)(*xptrptr + (*narrayptr - 1));              \
                ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 1 error generated.

But fixing that points out that we have NEVER supported arrayrefs
of sub-int types (byte, i16, u16, and now bool).  Again, while raw
types promote, arrays do not; so the macros HAVE to deal with both
size possibilities rather than assuming that an arrayref uses the
same sizing as the promoted raw type.

Obviously, our testsuite wasn't covering as much as it should have.

* src/util/virdbus.c (GET_NEXT_VAL): Also fix array cases.
(SET_NEXT_VAL): Fix uses of sub-int arrays.
* tests/virdbustest.c (testMessageArray, testMessageArrayRef):
Test it.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agoqemu: add the missing jobinfo type in qemuDomainGetJobInfo
Wang Rui [Tue, 25 Nov 2014 11:51:45 +0000 (19:51 +0800)]
qemu: add the missing jobinfo type in qemuDomainGetJobInfo

Commit 6fcddfcd refactored job statistics but missed the jobinfo type updated
in qemuDomainGetJobInfo. After this patch, we can use virDomainGetJobInfo to
get jobinfo type again.

Signed-off-by: Wang Rui <moon.wangrui@huawei.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agoResolve build breaker
John Ferlan [Tue, 25 Nov 2014 12:06:46 +0000 (07:06 -0500)]
Resolve build breaker

Commit 'c264eeaa' didn't do the prerequisite 'make syntax-check' before
pushing. There was a <tab> in the whitespace for the comment.  Replaced
with spaces and aligned.

pushed as build breaker since Jenkins complained loudly

10 years agolxc: don't unmount subtree if it contains the source of the mount
Cédric Bosdonnat [Mon, 24 Nov 2014 14:10:19 +0000 (15:10 +0100)]
lxc: don't unmount subtree if it contains the source of the mount

The typical case where we had a problem is with such a filesystem
definition as created by virt-sandbox-service:

    <filesystem type='bind' accessmode='passthrough'>
      <source dir='/var/lib/libvirt/filesystems/mysshd/var'/>
      <target dir='/var'/>
    </filesystem>

In this case, we don't want to unmount the /var subtree or we may
loose the access to the source folder.

10 years agolxc: be more patient while resolving symlinks
Cédric Bosdonnat [Fri, 21 Nov 2014 16:45:55 +0000 (17:45 +0100)]
lxc: be more patient while resolving symlinks

Resolving symlinks can fail before mounting any file system if one file
system depends on another being mounted. Symlinks are now resolved in
two passes:

  * Before any file system is mounted, but then we are more gentle if
    the source path can't be accessed
  * Right before mounting a file system, so that we are sure that we
    have the resolved path... but then if it can't be accessed we raise
    an error.

10 years agoip link needs 'name' in 3.16 to create the veth pair
Cédric Bosdonnat [Thu, 20 Nov 2014 14:26:35 +0000 (15:26 +0100)]
ip link needs 'name' in 3.16 to create the veth pair

Due to a change (or bug?) in ip link implementation, the command
    'ip link add vnet0...'
is forced into
    'ip link add name vnet0...'
The changed command also works on older versions of iproute2, just the
'name' parameter has been made mandatory.

10 years agovirt-aa-helper: /etc/libvirt-sandbox/services isn't restricted
Cédric Bosdonnat [Thu, 20 Nov 2014 10:32:38 +0000 (11:32 +0100)]
virt-aa-helper: /etc/libvirt-sandbox/services isn't restricted

To get virt-sandbox-service working with AppArmor, virt-aa-helper
needs not to choke on path in /etc/libvirt-sandbox/services.

10 years agovirt-aa-helper wasn't running virErrorInitialize
Cédric Bosdonnat [Thu, 20 Nov 2014 10:31:44 +0000 (11:31 +0100)]
virt-aa-helper wasn't running virErrorInitialize

This turns out to be working by magic but needs to be fixed.

10 years agoqemu-command: introduce new vgamem attribute for QXL video device
Pavel Hrdina [Thu, 20 Nov 2014 18:52:00 +0000 (19:52 +0100)]
qemu-command: introduce new vgamem attribute for QXL video device

Add attribute to set vgamem_mb parameter of QXL device for QEMU. This
value sets the size of VGA framebuffer for QXL device. Default value in
QEMU is 8MB so reuse it also in libvirt to not break things.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agoqemu-command: use vram attribute for all video devices
Pavel Hrdina [Thu, 20 Nov 2014 18:51:12 +0000 (19:51 +0100)]
qemu-command: use vram attribute for all video devices

So far we didn't have any option to set video memory size for qemu video
devices. There was only the vram (ram for QXL) attribute but it was valid
only for the QXL video device.

To provide this feature to users QEMU has a dedicated device attribute
called 'vgamem_mb' to set the video memory size. We will use the 'vram'
attribute for setting video memory size for other QEMU video devices.

For the cirrus device we will ignore the vram value because it has
hardcoded video size in QEMU.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agocaps: introduce new QEMU capability for vgamem_mb device property
Pavel Hrdina [Wed, 12 Nov 2014 12:58:33 +0000 (13:58 +0100)]
caps: introduce new QEMU capability for vgamem_mb device property

Allow setting vgamem size for video devices.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agoQXL: fix setting ram and vram values for QEMU QXL device
Pavel Hrdina [Tue, 18 Nov 2014 16:21:48 +0000 (17:21 +0100)]
QXL: fix setting ram and vram values for QEMU QXL device

QEMU has two different type of QXL display device. The first "qxl-vga"
is for primary video device and second "qxl" is for secondary video
device.

There are also two different ways how to specify those devices on qemu
command line, the first one and obsolete is using "-vga" option and the
current new one is using "-device" option. The "-vga" could be used only
to setup primary video device, so the "-vga qxl" equal to
"-device qxl-vga". Unfortunately the "-vga qxl" doesn't support setting
additional parameters for the device and "-global" option must be used
for this purpose. It's mandatory to use "-global qxl-vga...." to set the
parameters of primary video device previously defined with "-vga qxl".

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agovideo: cleanup usage of vram attribute and update documentation
Pavel Hrdina [Mon, 24 Nov 2014 10:58:53 +0000 (11:58 +0100)]
video: cleanup usage of vram attribute and update documentation

The vram attribute was introduced to set the video memory but it is
usable only for few hypervisors excluding QEMU/KVM and the old XEN
driver. Only in case of QEMU the vram was used for QXL.

This patch updates the documentation to reflect current code in libvirt
and also changes the cases when we will set the default vram attribute.
It also fixes existing strange default value for VGA devices 9MB to 16MB
because the video ram should be rounded to power of two.

The change of default value could affect migrations but I found out that
QEMU always round the video ram to power of two internally so it's safe
to change the default value to the next closest power of two and also
silently correct every domain XML definition. And it's also safe because
we don't pass the value to QEMU.

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

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agointernal: add macro to round value to the next closest power of 2
Pavel Hrdina [Tue, 18 Nov 2014 16:13:38 +0000 (17:13 +0100)]
internal: add macro to round value to the next closest power of 2

There are two special cases, if the input number is 0 or the number is
larger then 2^31 (for 32bit unsigned int). For the special cases the
return value is 0 because they cannot be rounded.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agostorage_driver: fix a comment typo
Chen Hanxiao [Mon, 24 Nov 2014 06:13:20 +0000 (14:13 +0800)]
storage_driver: fix a comment typo

s/rereshed/refreshed

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
10 years agovirsh: expose virDomainGetFSInfo
Tomoki Sekiyama [Sat, 22 Nov 2014 01:27:52 +0000 (20:27 -0500)]
virsh: expose virDomainGetFSInfo

Add a "domfsinfo" command that shows a list of filesystems info mounted in
the guest. For example:

virsh # domfsinfo vm1
Mountpoint                           Name     Type     Target
-------------------------------------------------------------------
/                                    sda1     ext4     hdc
/opt                                 dm-2     vfat     vda,vdb
/mnt/test                            sdb1     xfs      sda

Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
10 years agoqemu: add test for qemuAgentGetFSInfo
Tomoki Sekiyama [Sat, 22 Nov 2014 01:27:45 +0000 (20:27 -0500)]
qemu: add test for qemuAgentGetFSInfo

Add test cases for qemuAgentGetFSInfo, with a sample agent response for
the qemu-get-fsinfo command and a configuration xml.

Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
10 years agoqemu: Implement the qemu driver for virDomainGetFSInfo
Tomoki Sekiyama [Sat, 22 Nov 2014 01:27:38 +0000 (20:27 -0500)]
qemu: Implement the qemu driver for virDomainGetFSInfo

Get mounted filesystems list, which contains hardware info of disks and its
controllers, from QEMU guest agent 2.2+. Then, convert the hardware info
to corresponding device aliases for the disks.

Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
10 years agoremote: Implement the remote protocol for virDomainGetFSInfo
Tomoki Sekiyama [Sat, 22 Nov 2014 01:27:31 +0000 (20:27 -0500)]
remote: Implement the remote protocol for virDomainGetFSInfo

Add daemon and driver code to (de-)serialize virDomainFSInfo.

Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
10 years agoImplement public API for virDomainGetFSInfo
Tomoki Sekiyama [Sat, 22 Nov 2014 01:27:25 +0000 (20:27 -0500)]
Implement public API for virDomainGetFSInfo

virDomainGetFSInfo returns a list of filesystems information mounted in the
guest, which contains mountpoints, device names, filesystem types, and
device aliases named by libvirt. This will be useful, for example, to
specify mountpoints to fsfreeze when taking snapshot of a part of disks.

Signed-off-by: Tomoki Sekiyama <tomoki.sekiyama@hds.com>
10 years agoqemu: Emit the guest agent lifecycle event
Peter Krempa [Wed, 19 Nov 2014 09:31:21 +0000 (10:31 +0100)]
qemu: Emit the guest agent lifecycle event

Add code to emit the event on change of the channel state and reconnect
to the qemu process.

10 years agoexamples: Add support for the guest agent lifecycle event
Peter Krempa [Wed, 19 Nov 2014 09:27:55 +0000 (10:27 +0100)]
examples: Add support for the guest agent lifecycle event

Add code to support the event in the object-event example.

10 years agoevent: Add guest agent lifecycle event
Peter Krempa [Wed, 19 Nov 2014 09:32:20 +0000 (10:32 +0100)]
event: Add guest agent lifecycle event

As qemu is now able to notify us about change of the channel state used
for communication with the guest agent we now can more precisely track
the state of the guest agent.

To allow notifying management apps this patch implements a new event
that will be triggered on changes of the guest agent state.

10 years agospec: Automatically apply all patches with git
Jiri Denemark [Fri, 21 Nov 2014 17:09:36 +0000 (18:09 +0100)]
spec: Automatically apply all patches with git

With this change, any patch declared in libvirt.spec with Patch[0-9]* is
automatically applied in %prep. Unlike with the standard %patch[0-9]*,
patches are applied with "git am" to avoid some unexpected results.
However, as a result of this, all patches must be in the right format
for "git am" to be able to apply them; they should ideally be generated
from git using "git format-patch".

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agoqemu: process: Refresh virtio channel guest state when connecting to mon
Peter Krempa [Thu, 13 Nov 2014 19:16:46 +0000 (20:16 +0100)]
qemu: process: Refresh virtio channel guest state when connecting to mon

Use data provided by "query-chardev" to refresh the guest frontend state
of virtio channels.

10 years agoqemu: chardev: Extract more information about character devices
Peter Krempa [Thu, 13 Nov 2014 18:29:14 +0000 (19:29 +0100)]
qemu: chardev: Extract more information about character devices

Improve the monitor function to also retrieve the guest state of
character device (if provided) so that we can refresh the state of
virtio-serial channels and perhaps react to changes in the state in
future patches.

This patch changes the returned data from qemuMonitorGetChardevInfo to
return a structure containing the pty path and the state for all the
character devices.

The change to the testsuite makes sure that the data is parsed
correctly.

10 years agolibxl: destroy domain in migration finish phase on failure
Jim Fehlig [Thu, 13 Nov 2014 00:52:02 +0000 (17:52 -0700)]
libxl: destroy domain in migration finish phase on failure

This patch contains three domain cleanup improvements in the migration
finish phase, ensuring a domain is properly disposed when a failure is
detected or the migration is cancelled.

The check for virDomainObjIsActive is moved to libxlDomainMigrationFinish,
where cleanup can occur if migration failed and the domain is inactive.

The 'cleanup' label was missplaced in libxlDomainMigrationFinish, causing
a migrated domain to remain in the event of an error or cancelled migration.

In cleanup, the domain was not removed from the driver's list of domains.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
10 years agolibxl: start domain paused on migration dst
Jim Fehlig [Thu, 13 Nov 2014 00:15:37 +0000 (17:15 -0700)]
libxl: start domain paused on migration dst

During the perform phase of migration, the domain is started on
the dst host in a running state if VIR_MIGRATE_PAUSED flag is not
specified.  In the finish phase, the domain is also unpaused if
VIR_MIGRATE_PAUSED flag is unset.  I've noticed this second unpause
fails if the domain was already unpaused following the perform phase.

This patch changes the perform phase to always start the domain
paused, and defers unpausing, if requested, to the finish phase.
Unpausing should occur in the finish phase anyhow, where the domain
can be properly destroyed if the perform phase fails and migration
is cancelled.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
10 years agolibxl: acquire job in migration finish phase
Jim Fehlig [Thu, 13 Nov 2014 21:41:56 +0000 (14:41 -0700)]
libxl: acquire job in migration finish phase

Moving data reception of the perform phase of migration to a
thread introduces a race with the finish phase, where checking
if the domain is active races with the thread finishing the
perform phase.  The race is easily solved by acquiring a job in
the finish phase, which must wait for the perform phase job to
complete.

While wrapping the finish phase in a job, noticed the virDomainObj
was being unlocked in a callee - libxlDomainMigrationFinish.  Move
the unlocking to libxlDomainMigrateFinish3Params, where the lock
is acquired.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
10 years agolibxl: Receive migration data in a thread
Jim Fehlig [Wed, 12 Nov 2014 22:32:02 +0000 (15:32 -0700)]
libxl: Receive migration data in a thread

The libxl driver receives migration data within an IO callback invoked
by the event loop, effectively disabling the event loop while migration
occurs.

This patch moves receving of the migration data to a thread.  The
incoming connection is still accepted in the IO callback, but control
is immediately returned to the event loop after spawning the thread.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
10 years agolibxl: Allow libxl to find pygrub binary.
Ian Campbell [Fri, 21 Nov 2014 14:32:53 +0000 (14:32 +0000)]
libxl: Allow libxl to find pygrub binary.

Specifying an explicit path to pygrub (e.g. BINDIR "/pygrub") only works if
Xen and libvirt happen to be installed to the same prefix. A more flexible
approach is to simply specify "pygrub" which will cause libxl to use the
correct path which it knows (since it is built with the same prefix as pygrub).

This is particular problematic in the Debian packaging, since the Debian Xen
package relocates pygrub into a libexec dir, however I think this change makes
sense upstream.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
10 years agostorage: rbd: Implement support for passing config file option
Peter Krempa [Tue, 11 Nov 2014 16:31:24 +0000 (17:31 +0100)]
storage: rbd: Implement support for passing config file option

To be able to express some use cases of the RBD backing with libvirt, we
need to be able to specify a config file for the RBD client to qemu as
that is one of the commonly used options.

10 years agostorage: rbd: qemu: Add support for specifying internal RBD snapshots
Peter Krempa [Tue, 11 Nov 2014 10:35:25 +0000 (11:35 +0100)]
storage: rbd: qemu: Add support for specifying internal RBD snapshots

Some storage systems have internal support for snapshots. Libvirt should
be able to select a correct snapshot when starting a VM.

This patch adds a XML element to select a storage source snapshot for
the RBD protocol which supports this feature.

10 years agostorage: Allow parsing of RBD backing strings when building backing chain
Peter Krempa [Tue, 4 Nov 2014 16:35:16 +0000 (17:35 +0100)]
storage: Allow parsing of RBD backing strings when building backing chain

As we now have a common function to parse backing store string for RBD
backing store we can reuse it in the backing store walker so that we
don't fail on files backed by RBD storage.

This patch also adds a few tests to verify that the parsing works as
expected.

10 years agoutil: storagefile: Split out parsing of NBD string into a separate func
Peter Krempa [Tue, 4 Nov 2014 13:07:53 +0000 (14:07 +0100)]
util: storagefile: Split out parsing of NBD string into a separate func

Split out the code so that the function looks homogenous after adding
more protocol specific parsers.

10 years agoutil: split out qemuParseRBDString into a common helper
Peter Krempa [Fri, 31 Oct 2014 16:49:56 +0000 (17:49 +0100)]
util: split out qemuParseRBDString into a common helper

To allow reuse this non-trivial parser code in the backing store parser
this part of the command line parser needs to be split out into a
separate funciton.

10 years agotests: Reflow the expected output from RBD disk test
Peter Krempa [Tue, 11 Nov 2014 09:37:27 +0000 (10:37 +0100)]
tests: Reflow the expected output from RBD disk test

Addition of tested cases to the test will be more obvious.

10 years agoqemu: Refactor qemuBuildNetworkDriveURI to take a virStorageSourcePtr
Peter Krempa [Mon, 10 Nov 2014 16:55:26 +0000 (17:55 +0100)]
qemu: Refactor qemuBuildNetworkDriveURI to take a virStorageSourcePtr

Instead of splitting out various fields, pass the complete structure and
let the function pick various things of it.

As one of the callers isn't using virStorageSourcePtr to store the data,
this patch adds glue code that fills the data into a dummy
virStorageSourcePtr before calling the func.

This change will help when adding new fields that need output processing
in the future.

10 years agoutil: storage: Copy hosts of a storage file only if they exist
Peter Krempa [Thu, 30 Oct 2014 10:52:17 +0000 (11:52 +0100)]
util: storage: Copy hosts of a storage file only if they exist

If there are no hosts for a storage source virStorageSourceCopy and
virStorageSourceNewFromBackingRelative would try to copy them anyways.
As the success of virStorageNetHostDefCopy is determined by returning
a pointer and malloc of 0 elements might return NULL according to the
implementation, the result of the copy function may vary.

Fix this by copying the hosts array only if there are hosts defined.

10 years agoutil: storage: Add notice for extension of struct virStorageSource
Peter Krempa [Thu, 30 Oct 2014 10:42:55 +0000 (11:42 +0100)]
util: storage: Add notice for extension of struct virStorageSource

As we now have a deep copy function for struct virStorageSource add a
notice that extensions of the structure require also appropriate changes
to the virStorageSourceCopy func.

10 years agoutil: buffer: Clarify scope of the escape operation in virBufferEscape
Peter Krempa [Tue, 11 Nov 2014 16:23:49 +0000 (17:23 +0100)]
util: buffer: Clarify scope of the escape operation in virBufferEscape

The escaping is applied only to the string, not the format argument.
State this fact in the docs.

10 years agotest: virstoragetest: Add testing of network disk details
Peter Krempa [Tue, 4 Nov 2014 13:26:45 +0000 (14:26 +0100)]
test: virstoragetest: Add testing of network disk details

To be able to fully test parsing of networked storage strings we need to
add a few fields for: hostname, protocol and auth string.

10 years agodocs: domain: Move docs for storage hosts under the <source> element
Peter Krempa [Wed, 12 Nov 2014 12:54:10 +0000 (13:54 +0100)]
docs: domain: Move docs for storage hosts under the <source> element

The docs describing the <host> element that are under the <source>
element in the XML document were incorrectly placed under the <disk>
element. Move them to the correct place.

10 years agovirsh: sync domdisplay help and manual
Martin Kletzander [Fri, 21 Nov 2014 10:10:21 +0000 (11:10 +0100)]
virsh: sync domdisplay help and manual

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoqemu: Add handling for VSERPORT_CHANGE event
Peter Krempa [Thu, 13 Nov 2014 13:09:39 +0000 (14:09 +0100)]
qemu: Add handling for VSERPORT_CHANGE event

New qemu added a new event that is emitted when a virtio serial channel
is opened in the guest OS. This allows us to update the state of the
port in the output-only XML element.

This patch implements the monitor callbacks and necessary handlers to
update the state in the definition.

10 years agoconf: Add channel state for virtio channels to the XML
Peter Krempa [Wed, 29 Oct 2014 15:03:53 +0000 (16:03 +0100)]
conf: Add channel state for virtio channels to the XML

To track state of virtio channels this patch adds a new output-only
attribute called 'state' to the <target> element of virtio channels.

This will be later populated with the guest state of the channel.

10 years agoqemu: monitor: Rename and improve qemuMonitorGetPtyPaths
Peter Krempa [Thu, 13 Nov 2014 15:17:21 +0000 (16:17 +0100)]
qemu: monitor: Rename and improve qemuMonitorGetPtyPaths

To unify future additions that require information from "query-chardev"
rename qemuMonitorGetPtyPaths and friends to qemuMonitorGetChardevInfo
and move the allocation of the returned hash into the top level
function.

10 years agotest: xml2xml: Print full filenames if xml2xml test fails
Peter Krempa [Wed, 29 Oct 2014 14:53:36 +0000 (15:53 +0100)]
test: xml2xml: Print full filenames if xml2xml test fails

To simplify looking for a problem instrument the XML comparator function
with possibility to print the filename of the failed/expected XML
output.

This is necessary as the VIR_TEST_DIFFERENT macro possibly tests two XML
files for the inactive/active state and the resulting error may not be
obvious.

10 years agoconf: Annotate source enums for character device struct members
Peter Krempa [Wed, 29 Oct 2014 12:03:57 +0000 (13:03 +0100)]
conf: Annotate source enums for character device struct members

Add a comment to track which values may be present in certain members of
a struct _virDomainChrDef.

10 years agoqemu: process: report useful error if alias formatting fails
Peter Krempa [Thu, 13 Nov 2014 19:10:51 +0000 (20:10 +0100)]
qemu: process: report useful error if alias formatting fails

When retrieving the paths for PTY devices the alias gets formatted into
a static string. If it doesn't fit we wouldn't report an error.

10 years agodocs: fix a typo in formatdomain.html
Chen Fan [Fri, 21 Nov 2014 05:39:48 +0000 (13:39 +0800)]
docs: fix a typo in formatdomain.html

Signed-off-by: Chen Fan <chen.fan.fnst@cn.fujitsu.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agostorage: qemu: Fix security labelling of new image chain elements
Peter Krempa [Wed, 19 Nov 2014 17:54:43 +0000 (18:54 +0100)]
storage: qemu: Fix security labelling of new image chain elements

When creating a disk image snapshot the libvirt code would blindly copy
the parents label to the newly created image. This runs into problems
when you start a VM from an image hosted on NFS (or other storage system
that doesn't support selinux labels) and the snapshot destination is on
a storage system that does support selinux labels. Libvirt's code in
that case generates a different security label for the image hosted on
NFS. This label is valid only for NFS images and doesn't allow access in
case of a locally stored image.

To fix this issue libvirt needs to refrain from copying security
information in cases where the default domain seclabel is a better
choice.

This patch repurposes the now unused @force argument of
virStorageSourceInitChainElement to denote whether a copy of the
security labelling stuff should be attempted or not. This allows to
fine-control the copy operation for cases where we need to keep the
label of the old disk vs. the cases where we need to keep the label
unset to use the default domain imagelabel.

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

10 years agobuild: fix build when not using dbus
Eric Blake [Thu, 20 Nov 2014 15:48:19 +0000 (08:48 -0700)]
build: fix build when not using dbus

Commit c0e7022 breaks on a machine that lacks dbus headers:

In file included from util/virdbus.c:24:0:
util/virdbuspriv.h:31:3: error: unknown type name 'dbus_int16_t'

* src/util/virdbuspriv.h (DBusBasicValue): Only provide fallback
when dbus is compiled.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agobuild: avoid 32-bit failure on older gcc
Eric Blake [Thu, 20 Nov 2014 15:29:23 +0000 (08:29 -0700)]
build: avoid 32-bit failure on older gcc

On 32-bit platforms with old gcc (hello RHEL 5 gcc 4.1.2), the
build fails with:
virsh-domain.c: In function 'cmdBlockCopy':
virsh-domain.c:2172: warning: comparison is always false due to limited range of data type

Adjust the code to silence the warning.

* tools/virsh-domain.c (cmdBlockCopy): Pacify RHEL 5 gcc.

Signed-off-by: Eric Blake <eblake@redhat.com>
10 years agostorage: Add thread to refresh for createVport
John Ferlan [Tue, 18 Nov 2014 19:51:01 +0000 (14:51 -0500)]
storage: Add thread to refresh for createVport

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

When libvirt create's the vport (VPORT_CREATE) for the vHBA, there isn't
enough "time" between the creation and the running of the following
backend->refreshPool after a backend->startPool in order to find the LU's.
Population of LU's happens asynchronously when udevEventHandleCallback
discovers the "new" vHBA port.  Creation of the infrastructure by udev
is an iterative process creating and discovering actual storage devices and
adjusting the environment.

Because of the time it takes to discover and set things up, the backend
refreshPool call done after the startPool call will generally fail to
find any devices. This leaves the newly started pool appear empty when
querying via 'vol-list' after startup. The "workaround" has always been
to run pool-refresh after startup (or any time thereafter) in order to
find the LU's. Depending on how quickly run after startup, this too may
not find any LUs in the pool. Eventually though given enough time and
retries it will find something if LU's exist for the vHBA.

This patch adds a thread to be executed after the VPORT_CREATE which will
attempt to find the LU's without requiring the external run of refresh-pool.
It does this by waiting for 5 seconds and searching for the LU's. If any
are found, then the thread completes; otherwise, it will retry once more
in another 5 seconds.  If none are found in that second pass, the thread
gives up.

Things learned while investigating this... No need to try and fill the
pool too quickly or too many times. Over the course of creation, the udev
code may 'add', 'change', and 'delete' the same device. So if the refresh
code runs and finds something, it may display it only to have a subsequent
refresh appear to "lose" the device. The udev processing doesn't seem to
have a way to indicate that it's all done with the creation processing of a
newly found vHBA. Only the Lone Ranger has silver bullets to fix everything.

10 years agostorage: Fix issue finding LU's when block doesn't exist
John Ferlan [Wed, 19 Nov 2014 15:06:22 +0000 (10:06 -0500)]
storage: Fix issue finding LU's when block doesn't exist

Fix a problem in the getBlockDevice and processLU where retval initialized
to zero causing some failures to erroneously continue through to the
virStorageBackendSCSINewLun with an attempt to find a path for "/dev/(null)".
This would fail approximately 10 seconds later with debug message:

virStorageBackendSCSINewLun:203 :
     No stable path found for '/dev/(null)' in '/dev/disk/by-path'

The root cause of the issue is for many /sys/bus/scsi/devices/<lun path>
there is no "block*" device found for the vHBA's, where "<lun path>" are
the various paths created for the vHBA, such as "17:0:0:0", "17:0:1:0",
"17:0:2:0", "17:0:3:0", etc.  If the block device isn't found, then the
directory should just be ignored rather than attempting to process it.

The bug was that in getBlockDevice the assumption was "block" would exist
and either getNewStyleBlockDevice or getOldStyleBlockDevice would fill in
@block_device. However, if 'block*' doesn't exist, then the code returned
NULL for block_device *and* a good (zero) retval value.  This caused the
processLU code to attempt the virStorageBackendSCSINewLun which failed
"at some point in time" in the future.

After this change - on test system the refresh-pool didn't have a noticable
pause of about 20 seconds - it completed within a second since no longer
was there an attempt/need to find "/dev/(null)".

Additionally, the virStorageBackendSCSIFindLU's shouldn't be declaring
found unless the processLU actually returns success. This will be
important in the followup patch which relies on whether a LU was found.

10 years agodocs: Remove references to unused libvirt-libvirt.html
Nehal J Wani [Thu, 20 Nov 2014 15:13:11 +0000 (15:13 +0000)]
docs: Remove references to unused libvirt-libvirt.html

The libvirt-libvirt.html file is no longer generated so
should not be referenced by the Makefile.am

10 years agobuild: fix build with older dbus headers
Eric Blake [Wed, 19 Nov 2014 21:57:30 +0000 (14:57 -0700)]
build: fix build with older dbus headers

Compilation on a RHEL 5 host failed, due to the older dbus headers
present on that machine, and triggered by commit 2aa167ca:

util/virdbus.c: In function 'virDBusMessageIterDecode':
util/virdbus.c:952: error: 'DBusBasicValue' undeclared (first use in this function)

* m4/virt-dbus.m4 (LIBVIRT_CHECK_DBUS): Check for DBusBasicValue.
* src/util/virdbuspriv.h (DBusBasicValue): Provide fallback.

Signed-off-by: Eric Blake <eblake@redhat.com>