Commit Graph

9765 Commits

Author SHA1 Message Date
Eric Blake
2e2a81be22 snapshot: avoid virsh crash with older servers
Commits 51082301, 16d7b39, and 521cc447 introduced support for
'virsh snapshot-list --from' when talking to a server older than
0.9.5, but broke support for plain 'virsh snapshot-list' for the
same old server in the process.  Because the code is not properly
gated, we end up with a SIGSEGV during a strcmp with a NULL argument.

* tools/virsh.c (cmdSnapshotList): Don't waste time on fallbacks
when --from is not present.
(cherry picked from commit d9f6066598)
2012-06-14 18:38:27 -04:00
Osier Yang
a52a99f5d3 Update AUTHORS
Commit a80bb970 forgot to update authors.
(cherry picked from commit d41d252694)
2012-06-14 18:38:26 -04:00
Gao feng
a25ac3ac7e LXC: fix memory leak in lxcContainerMountFSBlockAuto
we forgot to free fslist,just add VIR_FREE(fslist).

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
(cherry picked from commit e49d792f29)
2012-06-14 18:38:26 -04:00
Gao feng
a9846e98c7 LXC: fix incorrect parameter of mount in lxcContainerMountFSBind
when do remount,the source and target should be the same
values specified in the initial mount() call.

So change fs->dst to src.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
(cherry picked from commit 0cb787bd3c)
2012-06-14 18:38:26 -04:00
Guido Günther
95ae1a06bc Only check for cluster fs if we're using a filesystem
otherwise migration fails for e.g. network filesystems like sheepdog
with:

   error: Invalid relative path 'virt-name': Invalid argument

while we should fail with:

    Migration may lead to data corruption if disks use cache != none

References:

    http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=676328
    https://www.redhat.com/archives/libvirt-users/2012-May/msg00088.html
(cherry picked from commit 3ac8fb54f4)
2012-06-14 18:38:26 -04:00
Cole Robinson
84daddb0b9 Fix missing ) in 2 strings
https://bugzilla.redhat.com/show_bug.cgi?id=801656
(cherry picked from commit 9ec6f818de)
2012-06-14 18:38:26 -04:00
Li Zhang
5840d413ad Assign correct address type to spapr-vlan and spapr-vty.
For pseries guest, spapr-vlan and spapr-vty is based
on spapr-vio address. According to model of network
device, the address type should be assigned automatically.
For serial device, serial pty device is recognized as
spapr-vty device, which is also on spapr-vio.

So this patch is to correct the address type of
spapr-vlan and spapr-vty, and build correct
command line of spapr-vty.

Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com>
Reviewed-by:   Michael Ellerman<michaele@au1.ibm.com>
(cherry picked from commit 04a319ba4e)
2012-06-14 18:38:26 -04:00
Eric Blake
29263ec243 maint: make it easier to copy FORTIFY_SOURCE snippet
While libvirt intentionally avoids -Wundef (after all, C99
guarantees sane semantics of treating undefined macros as 0),
the glibc insanity of #warning on _FORTIFY_SOURCE coupled with
what some people feel is the black magic of autoconf means
that other projects are likely to copy our snippet verbatim.
We can be nicer to other projects by making it easier to
integrate into projects that use -Wundef.

Suggested by Christophe Fergeau.

* m4/virt-compile-warnings.m4 (LIBVIRT_COMPILE_WARNINGS): Be nice
to other projects using -Wundef.
(cherry picked from commit 1c2edf0fbd)
2012-06-14 18:38:26 -04:00
Eric Blake
55157abb0b command: avoid potential deadlock on handshake
There is a theoretical problem of an extreme bug where we can get
into deadlock due to command handshaking.  Thanks to a pair of pipes,
we have a situation where the parent thinks the child reported an
error and is waiting for a message from the child to explain the
error; but at the same time the child thinks it reported success
and is waiting for the parent to acknowledge the success; so both
processes are now blocked.

Thankfully, I don't think this deadlock is possible without at
least one other bug in the code, but I did see exactly that sort
of situation prior to commit da831af - I saw a backtrace where a
double close bug in the parent caused the parent to read from the
wrong fd and assume the child failed, even though the child really
sent success.

This potential deadlock is not quite like commit 858c247 (a deadlock
due to multiple readers on one pipe preventing a write from completing),
although the solution is similar - always close unused pipe fds before
blocking, rather than after.

* src/util/command.c (virCommandHandshakeWait): Close unused fds
sooner.
(cherry picked from commit 5e8ab3915b)
2012-06-14 18:38:26 -04:00
Cole Robinson
c7bd2b052f spec: Build against systemd for udev
They have now merged. Fedora details here:

https://lists.fedoraproject.org/pipermail/devel/2012-June/168227.html
(cherry picked from commit dd7bc51bc4)

Conflicts:

	libvirt.spec.in
2012-06-14 18:38:26 -04:00
Osier Yang
4b5a793070 virsh: Back out if the argument for vol-create-as is malformed
(cherry picked from commit ee58b581c4)

Conflicts:

	tools/virsh.c
2012-06-14 18:38:26 -04:00
Osier Yang
9274256d5b virsh: Accept UUID as an argument for net-info and net-start
(cherry picked from commit 68fcfdb8bd)
2012-06-14 18:38:26 -04:00
Osier Yang
65a405dd04 virsh: Accept UUID as an argument for storage commands
Affected commands are: pool-start, vol-create-from.
(cherry picked from commit 05f8917f96)
2012-06-14 18:38:26 -04:00
Beat Jörg
b24a9f3e12 Fix for parallel port passthrough for QEMU
I came across a bug that the command line generated for passthrough
of the host parallel port /dev/parport0 by libvirt for QEMU is incorrect.

It currently produces:
-chardev tty,id=charparallel0,path=/dev/parport0
-device isa-parallel,chardev=charparallel0,id=parallel0

The first parameter is "tty". It sould be "parport".

If I launch qemu with -chardev parport,... it works as expected.

I have already filled a bug report (
https://bugzilla.redhat.com/show_bug.cgi?id=823879 ), the topic was
already on the list some months ago:

https://www.redhat.com/archives/libvirt-users/2011-September/msg00095.html

Signed-off-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit 7508338ff3)
2012-06-14 18:38:26 -04:00
Eric Blake
33ada8f147 maint: command.c whitespace cleanups
Noticed during the previous commit.

* src/util/command.c: Fix some spacing and break long lines.
(cherry picked from commit a3bc393e3a)
2012-06-14 18:38:25 -04:00
Eric Blake
07fdce4fd3 command: avoid deadlock on EPIPE situation
It is possible to deadlock libvirt by having a domain with XML
longer than PIPE_BUF, and by writing a hook script that closes
stdin early.  This is because libvirt was keeping a copy of the
child's stdin read fd open, which means the write fd in the
parent will never see EPIPE (remember, libvirt should always be
run with SIGPIPE ignored, so we should never get a SIGPIPE signal).
Since there is no error, libvirt blocks waiting for a write to
complete, even though the only reader is also libvirt.  The
solution is to ensure that only the child can act as a reader
before the parent does any writes; and then dealing with the
fallout of dealing with EPIPE.

Thankfully, this is not a security hole - since the only way to
trigger the deadlock is to install a custom hook script, anyone
that already has privileges to install a hook script already has
privileges to do any number of other equally disruptive things
to libvirt; it would only be a security hole if an unprivileged
user could install a hook script to DoS a privileged user.

* src/util/command.c (virCommandRun): Close parent's copy of child
read fd earlier.
(virCommandProcessIO): Don't let EPIPE be fatal; the child may
be done parsing input.
* tests/commandhelper.c (main): Set up a SIGPIPE situation.
* tests/commandtest.c (test20): Trigger it.
* tests/commanddata/test20.log: New file.
(cherry picked from commit 858c2476d9)
2012-06-14 18:38:25 -04:00
Eric Blake
f6e7865d27 build: allow building with newer glibc-headers and -O0
glibc 2.15 (on Fedora 17) coupled with explicit disabling of
optimization during development dies a painful death:

In file included from /usr/include/limits.h:27:0,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.7.0/include/limits.h:169,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.7.0/include/syslimits.h:7,
                 from /usr/lib/gcc/x86_64-redhat-linux/4.7.0/include/limits.h:34,
                 from util/bitmap.c:26:
/usr/include/features.h:314:4: error: #warning _FORTIFY_SOURCE requires compiling with optimization (-O) [-Werror=cpp]
cc1: all warnings being treated as errors

Work around this by only conditionally defining _FORTIFY_SOURCE,
in the case where glibc can actually use it.  The trick is using
AH_VERBATIM instead of AC_DEFINE.

* m4/virt-compile-warnings.m4 (LIBVIRT_COMPILE_WARNINGS): Squelch
_FORTIFY_SOURCE when needed to avoid glibc #warnings.
(cherry picked from commit 2af63b1c34)
2012-06-14 18:23:21 -04:00
Jiri Denemark
2a75b756d0 command: Fix debug message during handshake
Probably a result of copy&paste...
(cherry picked from commit 461ed4210f)
2012-06-14 18:23:21 -04:00
Radu Caragea
25a35c9ce5 Fix sync issue in virNetClientStreamEventRemoveCallback
The stream lock is unlocked twice instead of being locked and then
unlocked. Probably a typo.
(cherry picked from commit 107f51b69c)

Conflicts:

	AUTHORS
2012-06-14 18:23:21 -04:00
Laine Stump
5b3c356015 qemu: fix netdev alias name assignment wrt type='hostdev'
This patch resolves:

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

The problem is that an interface with type='hostdev' will have an
alias of the form "hostdev%d", while the function that looks through
existing netdevs to determine the name to use for a new addition will
fail if there's an existing entry that does not match the form
"net%d".

This is another of the handful of places that need an exception due to
the hybrid nature of <interface type='hostdev'> (which is not exactly
an <interface> or a <hostdev>, but is both at the same time).
(cherry picked from commit 6734ce7bc8)
2012-06-14 18:23:21 -04:00
Martin Kletzander
114b726f0d tools: make virt-pki-validate work with acls and xattrs
This patch makes virt-pki-validate work with certificates that have
acl or xattr set. Otherwise it failing due to wrong permissions.
(cherry picked from commit d4fb6694a4)
2012-06-14 18:23:21 -04:00
Wen Congyang
4e1e20c3a7 qemu: avoid closing fd more than once
If we migrate to fd, spec->fwdType is not MIGRATION_FWD_DIRECT,
we will close spec->dest.fd.local in qemuMigrationRun(). So we
should set spec->dest.fd.local to -1 in qemuMigrationRun().

Bug present since 0.9.5 (commit 326176179).
(cherry picked from commit b19c236d69)
2012-06-14 18:23:21 -04:00
Wen Congyang
b5df0ffe74 command: check for fork error before closing fd
We should not set *outfd or *errfd if virExecWithHook() failed
because the caller may close these fds.

Bug present since v0.4.5 (commit 60ed1d2a).
(cherry picked from commit 746ff701e8)
2012-06-14 18:23:21 -04:00
Eric Blake
bd670db3f0 fdstream: avoid double close bug
Wen Congyang reported that we have a double-close bug if we fail
virFDStreamOpenInternal, since childfd duplicated one of the fds[]
array contents.  In truth, since we always transfer both members
of fds to other variables, we should close the fds through those
other names, and just use fds[] for pipe().

Bug present since 0.9.0 (commit e886237a).

* src/fdstream.c (virFDStreamOpenFileInternal): Swap scope of
childfd and fds[], to avoid a double close.
(cherry picked from commit f3cfc7c884)
2012-06-14 18:23:21 -04:00
Eric Blake
1ae2604552 command: avoid double close bugs
KAMEZAWA Hiroyuki reported a nasty double-free bug when virCommand
is used to convert a string into input to a child command.  The
problem is that the poll() loop of virCommandProcessIO would close()
the write end of the pipe in order to let the child see EOF, then
the caller virCommandRun() would also close the same fd number, with
the second close possibly nuking an fd opened by some other thread
in the meantime.  This in turn can have all sorts of bad effects.

The bug has been present since the introduction of virCommand in
commit f16ad06f.

This is based on his first attempt at a patch, at
https://bugzilla.redhat.com/show_bug.cgi?id=823716

* src/util/command.c (_virCommand): Drop inpipe member.
(virCommandProcessIO): Add argument, to avoid closing caller's fd
without informing caller.
(virCommandRun, virCommandNewArgs): Adjust clients.
(cherry picked from commit da831afcf2)
2012-06-14 18:23:21 -04:00
Wen Congyang
aa7d50ce82 avoid fd leak
virCommandRunAsync() will set errfd if it succeed. We should
close it if virFDStreamOpenInternal() fails.
(cherry picked from commit 655cffa0f2)
2012-06-14 18:23:21 -04:00
Wen Congyang
ab73fe59be avoid closing uninitialized fd
If the system does not support bypass cache, we will close fd,
but it is uninitialized.
(cherry picked from commit 0a045f01cf)
2012-06-14 18:23:21 -04:00
Eric Blake
37b07d90bb build: silence warning from autoconf
Autoconf 2.60 and later insist on using ${datarootdir}, rather than
the derived ${datadir} (although the latter defaults to the former,
it is possible to set configure arguments so that they differ):

config.status: creating libvirt.pc
config.status: WARNING:  'libvirt.pc.in' seems to ignore the --datarootdir setting

This patch follows the autoconf manual's suggestions for how to
support 2.59 (RHEL 5) and newer simultaneously.

* libvirt.pc.in (datarootdir): Define, so ${datadir} will not ignore
datarootdir when using newer autoconf.
(cherry picked from commit aabf77aa41)
2012-06-14 18:23:21 -04:00
Michal Privoznik
b3f0d2ecba virCommand: Extend debug message for handshake
Currently, we are logging only one side of pipes we
create in virCommandRequireHandshake(); This is enough
in cases where pipe2() returns two consecutive FDs. However,
it is not guaranteed and it may return any FDs.
Therefore, it's wise to log the other ends as well.
(cherry picked from commit 7454849ec5)
2012-06-14 18:23:21 -04:00
Martin Kletzander
0089a2058f lxc: return correct number of CPUs
When getting number of CPUs the host has assigned, there was always
number "1" returned. Even though all lxc domains with no pinning
launched by libvirt run on all pCPUs (by default, no matter what's the
number), we should at least return the same number as the user
specified when creating the domain.
(cherry picked from commit 87dfdb0b92)
2012-06-14 18:23:21 -04:00
Dave Allan
dfa1548496 examples: add consolecallback example python script
A while back I wrote the attached code to demonstrate how to use
events and serial console to create a serial console that stays up
even when the VM is down.  It might need some work, as I am not
terribly strong with Python.

* examples/python/consolecallback.py: New file.
* examples/python/Makefile.am (EXTRA_DIST): Ship it.
(cherry picked from commit ffc9f7ab4f)
2012-06-14 18:23:20 -04:00
Stefan Berger
c82cbf1d48 leak_fix.diff
==3240== 23 bytes in 1 blocks are definitely lost in loss record 242 of 744
==3240==    at 0x4C2A4CD: malloc (vg_replace_malloc.c:236)
==3240==    by 0x8077537: __vasprintf_chk (vasprintf_chk.c:82)
==3240==    by 0x509C677: virVasprintf (stdio2.h:199)
==3240==    by 0x509C733: virAsprintf (util.c:1912)
==3240==    by 0x1906583A: qemudStartup (qemu_driver.c:679)
==3240==    by 0x511991D: virStateInitialize (libvirt.c:809)
==3240==    by 0x40CD84: daemonRunStateInit (libvirtd.c:751)
==3240==    by 0x5098745: virThreadHelper (threads-pthread.c:161)
==3240==    by 0x7953D8F: start_thread (pthread_create.c:309)
==3240==    by 0x805FF5C: clone (clone.S:115)

(cherry picked from commit 67dd486f20)
2012-06-14 18:23:20 -04:00
Martin Kletzander
da5eb7f119 docs: typo in acceleration element
"accel3d" was specified twice, the second one is obviously "accel2d"
(also from the text down below.
(cherry picked from commit 94618eb66a)
2012-06-14 18:23:20 -04:00
Daniel P. Berrange
9096dc1a5f Re-order config options in qemu driver augeas lens
Currently all the config options are listed under a 'vnc_entry'
group. Create a bunch of new groups & move options to the
right place

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit 6c10c04c39)
2012-06-14 18:23:20 -04:00
Daniel P. Berrange
cb724f8d13 Fix mistakes in augeas lens
Add nmissing 'host_uuid' entry to libvirtd.conf lens and
rename spice_passwd to spice_password in qemu.conf lens

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit a9c779caf3)
2012-06-14 18:23:20 -04:00
Daniel P. Berrange
af57c143d4 Standardize whitespace used in example config files
Instead of doing

  # example_config

use

  #example_config

so it is possible to programatically uncomment example config
options, as distinct from their comment/descriptions

Also delete rogue trailing comma not allowed by lens

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit c5c3278e9b)

(crobinso: Fix spacing to appease tests/daemon-conf, which is
 still in -maint branch)
2012-06-14 18:22:52 -04:00
Daniel P. Berrange
eb6ef1f53e Fix check for socket existance / daemon spawn
When you try to connect to a socket in the abstract namespace,
the error will be ECONNREFUSED for a non-listening daemon. With
the non-abstract namespace though, you instead get ENOENT. Add
a check for this extra errno when auto-spawning the daemon

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit 54c4d9d90b)
2012-06-14 18:22:52 -04:00
Daniel P. Berrange
b4bbe640ef Remove last usage of PATH_MAX and ban its future use
Remove a number of pointless checks against PATH_MAX and
add a syntax-check rule to prevent its use in future

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit ebbcc02639)
2012-06-14 18:22:52 -04:00
Jim Meyering
0f031d181f maint: avoid new automake warning about AM_PROG_CC_STDC
* configure.ac (AM_PROG_CC_STDC): Stop using this macro.
It provokes warnings from newer automake and is superseded by
autoconf's AC_PROG_CC, which we're already using.
(cherry picked from commit 0d07aa512c)
2012-06-14 18:22:52 -04:00
Daniel P. Berrange
99f07394f4 Improve docs about compiling libvirt from GIT
Add a note about setting the LIBVIRT_DRIVER_DIR env variable,
explain --system and fix example to use --disable-werror
(cherry picked from commit 4878a33125)
2012-06-14 18:22:52 -04:00
Eric Blake
52ab82bd1c tests: run valgrind on real executables, not libtool wrappers
* tests/Makefile.am (valgrind): Use libtool's ability to bypass
libtool wrappers when running valgrind.
(cherry picked from commit 428fc2bf31)
2012-06-14 18:22:52 -04:00
Douglas Schilling Landgraf
7fba39bc52 qemu augeas: Add spice_tls/spice_tls_x509_cert_dir
If vdsm is installed and configured in Fedora 17, we add the following
items into qemu.conf:

spice_tls=1
spice_tls_x509_cert_dir="/etc/pki/vdsm/libvirt-spice"

However, after this changes, augtool cannot identify qemu.conf anymore.
(cherry picked from commit cdd762e425)
2012-06-14 18:22:52 -04:00
Eric Blake
e39afdb898 tests: back to short test names
With the switch to modules by default, I was getting super long
test output:

TEST: /home/remote/eblake/libvirt/tests/.libs/lt-interfacexml2xmltest

compared to the former:

TEST: interfacexml2xmltest

* tests/testutils.c (virtTestMain): Trim off libtool goop.
(cherry picked from commit ee40725510)
2012-06-14 18:22:52 -04:00
Daniel P. Berrange
3e416ba91f Add parsing for VIR_ENUM_IMPL & VIR_ENUM_DECL in apibuild.py
The apibuild.py parser needs to be able to parse & ignore
any VIR_ENUM_IMPL/VIR_ENUM_DECL macros in the source. Add
some special case code to deal with this rather than trying
to figure out a generic syntax for parsing macros.

* apibuild.py: Special case  VIR_ENUM_IMPL & VIR_ENUM_DECL
(cherry picked from commit 45b43a8cab)
2012-06-14 18:22:52 -04:00
Daniel P. Berrange
f44e18ed93 Add stub impl of virNetlinkEventServiceLocalPid for Win32
The libvirt_private.syms file exports virNetlinkEventServiceLocalPid
so there needs to be a no-op stub for Win32 to avoid linker errors

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit 2d191e8e27)
2012-06-14 18:22:52 -04:00
Daniel P. Berrange
328d7da106 Fix dep from libvirt-lock-sanlock RPM
The libvirt-lock-sanlock RPM requires libvirtd, so its RPM dep
should be on libvirt-daemon, not libvirt
(cherry picked from commit aad1625da6)
2012-06-14 18:22:52 -04:00
Daniel P. Berrange
158e70fc3b Remove more bogus systemd service dependencies
Adding syslog.target is obsolete, avahi.target does not
exist and dbus.target is also obsolete

Reported-by: Lennart Poettering <lpoetter@redhat.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
(cherry picked from commit 4c7973e184)
2012-06-14 18:22:51 -04:00
Jiri Denemark
d4d8774468 Revert "rpc: Discard non-blocking calls only when necessary"
This reverts commit b1e374a7ac, which was
rather bad since I failed to consider all sides of the issue. The main
things I didn't consider properly are:

- a thread which sends a non-blocking call waits for the thread with
  the buck to process the call
- the code doesn't expect non-blocking calls to remain in the queue
  unless they were already partially sent

Thus, the reverted patch actually breaks more than what it fixes and
clients (which may even be libvirtd during p2p migrations) will likely
end up in a deadlock.
(cherry picked from commit 63643f67ab)
2012-06-14 18:22:51 -04:00
Peter Krempa
3600eec4d1 qemu_hotplug: Don't free the PCI device structure after hot-unplug
The pciDevice structure corresponding to the device being hot-unplugged
was freed after it was "stolen" from activeList. The pointer was still
used for eg-inactive list. This patch removes the free of the structure
and frees it only if reset fails on the device.
(cherry picked from commit db19417fc0)
2012-06-14 18:22:51 -04:00
Eric Blake
67f5578681 build: fix unused variable after last patch
The previous commit (2cb0899) left a dead variable behind.

* src/libxl/libxl_driver.c (libxlClose): Drop dead variable.
(cherry picked from commit b8e6021e7b)
2012-06-14 18:22:51 -04:00