]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
11 years agoLXC: introduce lxcContainerUnmountForSharedRoot
Gao feng [Wed, 11 Sep 2013 08:07:54 +0000 (16:07 +0800)]
LXC: introduce lxcContainerUnmountForSharedRoot

Move the unmounting private or useless filesystems for
container to this function.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
11 years agoLXC: umount the temporary filesystem created by libvirt
Gao feng [Wed, 11 Sep 2013 08:07:53 +0000 (16:07 +0800)]
LXC: umount the temporary filesystem created by libvirt

The devpts, dev and fuse filesystems are mounted temporarily.
there is no need to export them to container if container shares
the root directory with host.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
11 years agoAdd test for the nodemask double free crash
Ján Tomko [Wed, 11 Sep 2013 08:49:39 +0000 (10:49 +0200)]
Add test for the nodemask double free crash

Commit ef5d51d fixed a crash for numatune with auto placement and
nodeset specified:
<numatune>
    <memory mode='preferred' placement='auto' nodeset='0'/>
</numatune>

11 years agoUpdate docs about user namespace for LXC
Daniel P. Berrange [Tue, 10 Sep 2013 09:00:15 +0000 (10:00 +0100)]
Update docs about user namespace for LXC

Mention that user namespace can be enabled using the UID/GID
mapping schema.

Fix typo in link anchor for container args in domain XML docs.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix cgroups when all are mounted on /sys/fs/cgroup
Daniel P. Berrange [Tue, 10 Sep 2013 13:31:53 +0000 (14:31 +0100)]
Fix cgroups when all are mounted on /sys/fs/cgroup

Some users in Ubuntu/Debian seem to have a setup where all the
cgroup controllers are mounted on /sys/fs/cgroup rather than
any /sys/fs/cgroup/<controller> name. In the loop which detects
which controllers are present for a mount point we were modifying
'mnt_dir' field in the 'struct mntent' var, but not always restoring
the original value. This caused detection to break in the all-in-one
mount setup.

Fix that logic bug and add test case coverage for this mount
setup.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agovirDomainDefParseXML: set the argument of virBitmapFree to NULL after calling virBitm...
Liuji (Jeremy) [Wed, 11 Sep 2013 02:13:32 +0000 (22:13 -0400)]
virDomainDefParseXML: set the argument of virBitmapFree to NULL after calling virBitmapFree

After freeing the bitmap pointer, it must set the pointer to NULL.
This will avoid any other use of the freed memory of the bitmap pointer.

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

Signed-off-by: Liuji (Jeremy) <jeremy.liu@huawei.com>
11 years agodocs, comments: minor typo fixes
Oskari Saarenmaa [Tue, 10 Sep 2013 18:10:55 +0000 (21:10 +0300)]
docs, comments: minor typo fixes

Signed-off-by: Oskari Saarenmaa <os@ohmu.fi>
Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: fix regression in requiring yajl for new enough qemu
Eric Blake [Thu, 5 Sep 2013 20:32:25 +0000 (14:32 -0600)]
build: fix regression in requiring yajl for new enough qemu

Jonathan Lebon reported an issue to me off-list about his build
failing to use qemu because he failed to install yajl-devel.  But
I recalled specifically tweaking configure.ac to die in that
situation (commits 350583cba9c38b).  After a bit more
head-scratching, we found the cause of the regression: commit
654c709 rearranged things so that the qemu version check now
occurs before AC_ARG_WITH has had a chance to set either
$with_qemu or $with_yajl.

Coincidentally, this fix aligns with a documentation patch that
was just posted to the autoconf mailing list :)
http://thread.gmane.org/gmane.comp.sysutils.autoconf.patches/8324

* m4/virt-lib.m4 (LIBVIRT_CHECK_LIB, LIBVIRT_CHECK_LIB_ALT)
(LIBVIRT_CHECK_PKG): Populate defaults earlier.
* configure.ac (AC_ARG_WITH): Likewise for drivers.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: avoid obsolete AC_HELP_STRING
Eric Blake [Thu, 5 Sep 2013 21:24:55 +0000 (15:24 -0600)]
build: avoid obsolete AC_HELP_STRING

Autoconf states that AC_HELP_STRING is obsolete, and that new
programs should use AS_HELP_STRING.  We also had instances of
not properly quoting the macro usage, and not relying on autoconf's
word-wrapping abilities to avoid long lines.  I validated that this
commit has no impact to the generated configure file.

* configure.ac (AC_ARG_WITH, AC_ARG_ENABLE): Autoconf recommends
the use of AS_HELP_STRING.  Also, use proper quoting and wrap long
lines.
* m4/virt-apparmor.m4 (LIBVIRT_CHECK_APPARMOR): Likewise.
* m4/virt-selinux.m4 (LIBVIRT_CHECK_SELINUX): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoqemu: endjob returns a bool
Eric Blake [Mon, 9 Sep 2013 19:07:29 +0000 (13:07 -0600)]
qemu: endjob returns a bool

Osier Yang pointed out that ever since commit 31cb030, the
signature of qemuDomainObjEndJob was changed to return a bool.
While comparison against 0 or > 0 still gives the right results,
it looks fishy; we also had one place that was comparing < 0
which is effectively dead code.

* src/qemu/qemu_migration.c (qemuMigrationPrepareAny): Fix dead
code bug.
(qemuMigrationBegin): Use more canonical form of bool check.
* src/qemu/qemu_driver.c (qemuAutostartDomain)
(qemuDomainCreateXML, qemuDomainSuspend, qemuDomainResume)
(qemuDomainShutdownFlags, qemuDomainReboot, qemuDomainReset)
(qemuDomainDestroyFlags, qemuDomainSetMemoryFlags)
(qemuDomainSetMemoryStatsPeriod, qemuDomainInjectNMI)
(qemuDomainSendKey, qemuDomainGetInfo, qemuDomainScreenshot)
(qemuDomainSetVcpusFlags, qemuDomainGetVcpusFlags)
(qemuDomainRestoreFlags, qemuDomainGetXMLDesc)
(qemuDomainCreateWithFlags, qemuDomainAttachDeviceFlags)
(qemuDomainUpdateDeviceFlags, qemuDomainDetachDeviceFlags)
(qemuDomainBlockResize, qemuDomainBlockStats)
(qemuDomainBlockStatsFlags, qemuDomainMemoryStats)
(qemuDomainMemoryPeek, qemuDomainGetBlockInfo)
(qemuDomainAbortJob, qemuDomainMigrateSetMaxDowntime)
(qemuDomainMigrateGetCompressionCache)
(qemuDomainMigrateSetCompressionCache)
(qemuDomainMigrateSetMaxSpeed)
(qemuDomainSnapshotCreateActiveInternal)
(qemuDomainRevertToSnapshot, qemuDomainSnapshotDelete)
(qemuDomainQemuMonitorCommand, qemuDomainQemuAttach)
(qemuDomainBlockJobImpl, qemuDomainBlockCopy)
(qemuDomainBlockCommit, qemuDomainOpenGraphics)
(qemuDomainGetBlockIoTune, qemuDomainGetDiskErrors)
(qemuDomainPMSuspendForDuration, qemuDomainPMWakeup)
(qemuDomainQemuAgentCommand, qemuDomainFSTrim): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: use automake subdir-objects
Eric Blake [Sat, 7 Sep 2013 22:18:06 +0000 (16:18 -0600)]
build: use automake subdir-objects

Automake 2.0 will enable subdir-objects by default; in preparation
for that change, automake 1.14 outputs LOADS of warnings:

daemon/Makefile.am:38: warning: source file '../src/remote/remote_protocol.c' is in a subdirectory,
daemon/Makefile.am:38: but option 'subdir-objects' is disabled
automake-1.14: warning: possible forward-incompatibility.
automake-1.14: At least a source file is in a subdirectory, but the 'subdir-objects'
automake-1.14: automake option hasn't been enabled.  For now, the corresponding output
automake-1.14: object file(s) will be placed in the top-level directory.  However,
automake-1.14: this behaviour will change in future Automake versions: they will
automake-1.14: unconditionally cause object files to be placed in the same subdirectory
automake-1.14: of the corresponding sources.
automake-1.14: You are advised to start using 'subdir-objects' option throughout your
automake-1.14: project, to avoid future incompatibilities.
daemon/Makefile.am:38: warning: source file '../src/remote/lxc_protocol.c' is in a subdirectory,
daemon/Makefile.am:38: but option 'subdir-objects' is disabled
...

As automake 1.9 also supported this option, and the previous patches
fixed up the code base to work with it, it is safe to now turn it on
unconditionally.

* configure.ac (AM_INIT_AUTOMAKE): Enable subdir-objects.
* .gitignore: Ignore .dirstamp directories.
* src/Makefile.am (PDWTAGS, *-protocol-struct): Adjust to
new subdir-object location of .lo files.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agotests: check remaining .x files
Eric Blake [Sat, 7 Sep 2013 21:22:18 +0000 (15:22 -0600)]
tests: check remaining .x files

We have been adding new .x files without keeping the list of
*-structs files up-to-date.  This adds the support for the
recent additions.

In the process of testing this, I also noticed that Fedora 19's
use of dwarves-1.10 (providing pdwtags version 1.9) was producing
a single line on stderr but still giving enough useful info on
stdout that we could check structs; the real goal of checking
stderr separately from stdout was to avoid the bug in dwarves-1.9
where stdout was empty (see bug http://bugzilla.redhat.com/772358).

* src/Makefile.am (struct_prefix, PROTOCOL_STRUCTS): Add missing
struct tests.
(PDWTAGS): Work with Fedora 19 pdwtags.
(lxc_monitor_protocol-struct, lock_protocol-struct): New rules.
* src/lxc_monitor_protocol-structs: New file.
* src/lock_protocol-structs): Likewise.
* cfg.mk (generated_files): Enlarge list.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: use library rather than cross-directory compilation
Eric Blake [Sun, 8 Sep 2013 02:49:17 +0000 (20:49 -0600)]
build: use library rather than cross-directory compilation

If we use subdir-objects with automake, any reference to a
cross-directory .c file will result in automake creating
rules that track dependency in the cross directory.  But this
presents a problem during 'make distclean' - if the cross
directory is cleaned up first, then the daemon directory will
be left with dangling references to .Po dependency files that
no longer exist.

Meanwhile, referring to the cross-directory .c file means
that we are compiling the file twice - once in src, and once
in daemon.  Better is to compile just once in src into a
convenience library, and then use that library from daemon.

The tests directory had a similar situation of a cross-directory
.c file; to solve that, we actually need a convenience library.

* daemon/Makefile.am (DAEMON_SOURCES): Drop .c files...
(libvirtd_LDADD): ...and instead use library.
(libvirtd_conf_la_SOURCES): Declare a new convenience library.
(libvirtd_LDFLAGS): Drop duplicate flag.
* tests/Makefile.am (libvirtdconftest_SOURCES): Drop .c file...
(libvirtdconftest_LDADD): ..and instead use library.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: avoid $(srcdir) in *_SOURCES
Eric Blake [Fri, 6 Sep 2013 22:54:39 +0000 (16:54 -0600)]
build: avoid $(srcdir) in *_SOURCES

Trying to enable automake's subdir-objects option resulted in
the creation of literal directories such as src/$(srcdir)/remote/.
I traced this to the fact that we had used a literal $(srcdir)
in a location that later fed an automake *_SOURCES variable.
This has also been reported as an automake bug:
http://debbugs.gnu.org/cgi/bugreport.cgi?bug=13928
but it's better to fix our code than to wait for an automake fix.

Some things to remember that affect VPATH builds, and where an
in-tree build is blissfully unaware of the issues: if a VPATH
build fails to find a file that was used as a prereq of any
other target, then the rule for that file will expand $@ to
prefer the current build dir (bad because a VPATH build on a
fresh checkout will then stick $@ in the current directory
instead of the desired srcdir); conversely, if a VPATH build
finds the file in srcdir but decides it needs to be rebuilt,
then the rule for that file will expand $@ to include the
directory where it was found out-of-date (bad for an explicit
listing of $(srcdir)/$@ because an incremental VPATH build will
then expand srcdir twice).  As we want these files to go into
srcdir unconditionally, we have to massage or avoid $@ for any
recipe that involves one of these files.

Therefore, this patch removes all uses of $(srcdir) from any
generated file name that later feeds a *_SOURCES variable, and
then rewrites all the recipes to generate those files to
hard-code their creation into srcdir without the use of $@.

* src/Makefile.am (REMOTE_DRIVER_GENERATED): Drop $(srcdir); VPATH
builds know how to find the files, and automake subdir-objects
fails with it in place.
(LXC_MONITOR_PROTOCOL_GENERATED, (LXC_MONITOR_GENERATED)
(ACCESS_DRIVER_GENERATED, LOCK_PROTOCOL_GENERATED): Likewise.
(*_client_bodies.h): Hard-code rules to write into srcdir, as
VPATH tries to build $@ locally if missing.
(util/virkeymaps.h): Likewise.
(lxc/lxc_monitor_dispatch.h): Likewise.
(access/viraccessapi*): Likewise.
(locking/lock_daemon_dispatch_stubs.h): Likewise.
* daemon/Makeflie.am (DAEMON_GENERATED, remote_dispatch.h):
Likewise.

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

11 years agocpu: Cleanup ppcCompute to avoid memory leak
Li Zhang [Mon, 9 Sep 2013 05:56:33 +0000 (13:56 +0800)]
cpu: Cleanup ppcCompute to avoid memory leak

This patch is to Cleanup ppcCompute to avoid memory leak to make
the code better.

Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com>
11 years agoqemu: don't leak vm on failure
Eric Blake [Wed, 28 Aug 2013 20:27:44 +0000 (14:27 -0600)]
qemu: don't leak vm on failure

Failure to attach to a domain during 'virsh qemu-attach' left
the list of domains in an odd state:

$ virsh qemu-attach 4176
error: An error occurred, but the cause is unknown

$ virsh list --all
 Id    Name                           State
----------------------------------------------------
 2     foo                            shut off

$ virsh qemu-attach 4176
error: Requested operation is not valid: domain is already active as 'foo'

$ virsh undefine foo
error: Failed to undefine domain foo
error: Requested operation is not valid: cannot undefine transient domain

$ virsh shutdown foo
error: Failed to shutdown domain foo
error: invalid argument: monitor must not be NULL

It all stems from leaving the list of domains unmodified on
the initial failure; we should follow the lead of createXML
which removes vm on failure (the actual initial failure still
needs to be fixed in a later patch, but at least this patch
gets us to the point where we aren't getting stuck with an
unremovable "shut off" transient domain).

While investigating, I also found a leak in qemuDomainCreateXML;
the two functions should behave similarly.  Note that there are
still two unusual paths: if dom is not allocated, the user will
see an OOM error even though the vm remains registered (but oom
errors already indicate tricky cleanup); and if the vm starts
and then quits again all before the job ends, it is possible
to return a non-NULL dom even though the dom will no longer be
useful for anything (but this at least lets the user know their
short-lived vm ran).

* src/qemu/qemu_driver.c (qemuDomainCreateXML): Don't leak vm on
failure to obtain job.
(qemuDomainQemuAttach): Match cleanup of qemuDomainCreateXML.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoAdd ARM v7 big-endian architecture (armv7b)
Yogesh Tillu [Mon, 9 Sep 2013 09:37:06 +0000 (10:37 +0100)]
Add ARM v7 big-endian architecture (armv7b)

ARM v7 can operate in either little or big endian modes. Add
support for the big-endian version known as armv7b from uname.

Signed-off-by: Yogesh Tillu <tillu.yogesh@gmail.com>
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoqemu: avoid users specifying CPU features for non-x86 plaftorm.
Li Zhang [Fri, 6 Sep 2013 11:15:25 +0000 (12:15 +0100)]
qemu: avoid users specifying CPU features for non-x86 plaftorm.

Currently, only X86 provides users CPU features with CPUID instruction.
If users specify the features for non-x86, it should tell users to
remove them.

This patch is to report one error if features are specified by
users for non-x86 platform.

Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com>
11 years agoLXC: Free variable vroot in lxcDomainDetachDeviceHostdevUSBLive()
Hongwei Bi [Mon, 9 Sep 2013 06:05:20 +0000 (14:05 +0800)]
LXC: Free variable vroot in lxcDomainDetachDeviceHostdevUSBLive()

The variable vroot should be freed in label cleanup.

11 years agoqemu: don't leave shutdown inhibited on attach failure
Eric Blake [Wed, 28 Aug 2013 22:22:46 +0000 (16:22 -0600)]
qemu: don't leave shutdown inhibited on attach failure

While debugging a failure of 'virsh qemu-attach', I noticed that
we were leaking the count of active domains on failure.  This
means that a libvirtd session that is supposed to quit after
active domains disappear will hang around forever.

* src/qemu/qemu_process.c (qemuProcessAttach): Undo count of
active domains on failure.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoqemu: recognize -machine accel=kvm when parsing native
Eric Blake [Wed, 28 Aug 2013 03:45:46 +0000 (21:45 -0600)]
qemu: recognize -machine accel=kvm when parsing native

In Fedora 19, 'qemu-kvm' is a simple wrapper that calls
'qemu-system-x86_64 -machine accel=kvm'.  Attempting
to use 'virsh qemu-attach $pid' to a machine started as:

qemu-kvm -cdrom /var/lib/libvirt/images/foo.img \
 -monitor unix:/tmp/demo,server,nowait -name foo \
 --uuid cece4f9f-dff0-575d-0e8e-01fe380f12ea

was failing with:
error: XML error: No PCI buses available

because we did not see 'kvm' in the executable name read from
/proc/$pid/cmdline, and tried to assign os.machine as
"accel=kvm" instead of "pc"; this in turn led to refusal to
recognize the pci bus.

Noticed while investigating https://bugzilla.redhat.com/995312
although there are still other issues to fix before that bug
will be completely solved.

I've concluded that the existing parser code for native-to-xml
is a horrendous hodge-podge of ad-hoc approaches; I basically
rewrote the -machine section to be a bit saner.

* src/qemu/qemu_command.c (qemuParseCommandLine): Don't assume
-machine argument is always appropriate for os.machine; set
virtType if accel is present.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoqemu: only parse basename when determining emulator properties
Eric Blake [Mon, 26 Aug 2013 22:04:19 +0000 (16:04 -0600)]
qemu: only parse basename when determining emulator properties

'virsh domxml-from-native' and 'virsh qemu-attach' could misbehave
for an emulator installed in (a somewhat unlikely) location
such as /usr/local/qemu-1.6/qemu-system-x86_64 or (an even less
likely) /opt/notxen/qemu-system-x86_64.  Limit the strstr seach
to just the basename of the file where we are assuming details
about the binary based on its name.

While testing, I accidentally triggered a core dump during strcmp
when I forgot to set os.type on one of my code paths; this patch
changes such a coding error to raise a nicer internal error instead.

* src/qemu/qemu_command.c (qemuParseCommandLine): Compute basename
earlier.
* src/conf/domain_conf.c (virDomainDefPostParseInternal): Avoid
NULL deref.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoLXC: fix typos in lxc_container.c
Chen Hanxiao [Fri, 6 Sep 2013 11:14:00 +0000 (12:14 +0100)]
LXC: fix typos in lxc_container.c

Fix docs and error message typos in lxc_container.c

Signed-off-by: Chen Hanxiao <chenhanxiao@cn.fujitsu.com>
11 years agoDocs: fix a typo in virt-login-shell.pod
Alex Jia [Tue, 3 Sep 2013 03:51:32 +0000 (11:51 +0800)]
Docs: fix a typo in virt-login-shell.pod

Signed-off-by: Alex Jia <ajia@redhat.com>
11 years agolibxl: Compile regular expression where it is used
Jim Fehlig [Wed, 4 Sep 2013 22:14:30 +0000 (16:14 -0600)]
libxl: Compile regular expression where it is used

The regular expression used to determine guest capabilities
was compiled in libxlCapsInitHost() but used in libxlCapsInitGuests().
Move compilation to libxlCapsInitGuests() where it is used, and free
the compiled regex after use.  Ensure not to free the regex if
compilation fails.

11 years agoDon't call regfree() if regcomp() fails
Jim Fehlig [Wed, 4 Sep 2013 21:58:27 +0000 (15:58 -0600)]
Don't call regfree() if regcomp() fails

POSIX states that the preg parameter to regcomp() is undefined on
failure, so no need to call regfree() in these cases.

http://pubs.opengroup.org/onlinepubs/009695399/functions/regcomp.html

See also a discussion on the libvirt dev list

https://www.redhat.com/archives/libvir-list/2013-September/msg00262.html

11 years agospec: make client-only testing easier
Eric Blake [Wed, 4 Sep 2013 20:59:49 +0000 (14:59 -0600)]
spec: make client-only testing easier

Several recent patches cleaned up 'make rpm' for the situation
when client_only is true; these were done by manual spec file
editing (since it's relatively hard to come by a RHEL 5 s390
box).  Make it easier to do in the future via a simpler command
line override.

* libvirt.spec.in (client_only): Allow for override.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: shut up automake warnings
Eric Blake [Wed, 4 Sep 2013 16:26:30 +0000 (10:26 -0600)]
build: shut up automake warnings

I'm tired of seeing screenfuls of messages like these when using
automake 1.13 (Fedora 19):

configure.ac:2121: warning: The 'AM_PROG_MKDIR_P' macro is deprecated, and its use is discouraged.
configure.ac:2121: You should use the Autoconf-provided 'AC_PROG_MKDIR_P' macro instead,
configure.ac:2121: and use '$(MKDIR_P)' instead of '$(mkdir_p)'in your Makefile.am files.
daemon/Makefile.am:19: warning: 'INCLUDES' is the old name for 'AM_CPPFLAGS' (or '*_CPPFLAGS')

seeing as how we MUST use those constructs for the benefit of
automake 1.9 (RHEL 5).  Conversely, RHEL 5 automake complained:

aclocal:configure.ac:36: warning: macro `AM_SILENT_RULES' not found in library

Obviously, I tested this patch on both Fedora 19 and RHEL 5.

* configure.ac (AM_INIT_AUTOMAKE): Avoid obsoletion warnings.
(AM_SILENT_RULES): Avoid unknown macro warning.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoFix a typo in network XML docs
Ján Tomko [Thu, 5 Sep 2013 09:32:19 +0000 (11:32 +0200)]
Fix a typo in network XML docs

11 years agoChange 'shortforward' to bool.
Ján Tomko [Thu, 5 Sep 2013 09:27:36 +0000 (11:27 +0200)]
Change 'shortforward' to bool.

11 years agoAdd '<nat>' element to '<forward>' network schemas
Ján Tomko [Thu, 5 Sep 2013 09:08:38 +0000 (11:08 +0200)]
Add '<nat>' element to '<forward>' network schemas

Commits 905629f4 and 1716e7a6 have added support for specifying
an IPv4 range and a port range to be used by NAT:
<forward mode='nat'>
  <nat>
    <address start='10.20.30.40' end='10.20.30.44'/>
    <port start='60000' end='65432'/>
  </nat>
</forward>

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

11 years agocpu: Add cpu test cases for PPC CPU driver.
Li Zhang [Tue, 3 Sep 2013 06:28:25 +0000 (14:28 +0800)]
cpu: Add cpu test cases for PPC CPU driver.

This patch is to add cpu test casses for PPC CPU driver.

Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com>
11 years agocpu: Implement guestData and update for PPC
Li Zhang [Tue, 3 Sep 2013 06:28:24 +0000 (14:28 +0800)]
cpu: Implement guestData and update for PPC

On Power platform, Power7+ can support Power7 guest.
It needs to define XML configuration to specify guest's CPU model.

For exmaple:
  <cpu match='exact'>
    <model>POWER7_v2.1</model>
    <vendor>IBM</vendor>
  </cpu>

Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com>
11 years agoqemu: Remove CPU features functions calling for non-x86 platform.
Li Zhang [Tue, 3 Sep 2013 06:28:23 +0000 (14:28 +0800)]
qemu: Remove CPU features functions calling for non-x86 platform.

CPU features are not supported on non-x86 and hasFeatures will be NULL.

This patch is to remove CPU features functions calling to avoid errors.

Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com>
11 years agoUse loop-control to allocate loop device.
Ian Main [Thu, 5 Sep 2013 11:04:33 +0000 (12:04 +0100)]
Use loop-control to allocate loop device.

This patch changes virFileLoopDeviceOpen() to use the new loop-control
device to allocate a new loop device.  If this behavior is unsupported
we fall back to the previous method of searching /dev for a free device.

With this patch you can start as many image based LXC domains as you
like (well almost).

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

11 years agoLXC: Don't mount securityfs when user namespace enabled
Gao feng [Thu, 5 Sep 2013 10:50:40 +0000 (11:50 +0100)]
LXC: Don't mount securityfs when user namespace enabled

Right now, securityfs is disallowed to be mounted in non-initial
user namespace, so we must avoid trying to mount securityfs in
a container which has user namespace enabled.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
11 years agoStop calling virAllocN directly from ESX code
Daniel P. Berrange [Tue, 3 Sep 2013 15:22:48 +0000 (16:22 +0100)]
Stop calling virAllocN directly from ESX code

The ESX code has a method esxVI_Alloc which would call
virAllocN directly, instead of using the VIR_ALLOC_N
macro. Remove this method and make the callers just
use VIR_ALLOC as is normal practice.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agovirDomainDeviceIsUSB: Drop check for USB controller
Liuji (Jeremy) [Thu, 5 Sep 2013 02:40:25 +0000 (02:40 +0000)]
virDomainDeviceIsUSB: Drop check for USB controller

Delete the USB controller check from the USB Device checklist in
virDomainDeviceIsUSB as USB controller is a PCI device rather than
a USB one.

Signed-off-by: Liu Ji <jeremy.liu@huawei.com>
11 years agoEnsure 'arch' is always set in cpuArchNodeData
Daniel P. Berrange [Wed, 4 Sep 2013 16:41:55 +0000 (17:41 +0100)]
Ensure 'arch' is always set in cpuArchNodeData

The s390, ppc and arm CPU drivers never set the 'arch' field
in their impl of cpuArchNodeData. This leads to error messages
being reported from cpuDataFree later, due to trying to use
VIR_ARCH_NONE.

 #0  virRaiseErrorFull (filename=filename@entry=0x76f94434 "cpu/cpu.c", funcname=funcname@entry=0x76f942dc <__FUNCTION__.18096> "cpuGetSubDriver", linenr=linenr@entry=58,
     domain=domain@entry=31, code=code@entry=1, level=level@entry=VIR_ERR_ERROR, str1=0x76f70e18 "internal error: %s",
     str2=str2@entry=0x7155f2ec "undefined hardware architecture", str3=str3@entry=0x0, int1=int1@entry=-1, int2=int2@entry=-1, fmt=0x76f70e18 "internal error: %s")
     at util/virerror.c:646
 #1  0x76e682ea in virReportErrorHelper (domcode=domcode@entry=31, errorcode=errorcode@entry=1, filename=0x76f94434 "cpu/cpu.c",
     funcname=0x76f942dc <__FUNCTION__.18096> "cpuGetSubDriver", linenr=linenr@entry=58, fmt=0x76f7e7e4 "%s") at util/virerror.c:1292
 #2  0x76ed82d4 in cpuGetSubDriver (arch=<optimized out>) at cpu/cpu.c:57
 #3  cpuGetSubDriver (arch=VIR_ARCH_NONE) at cpu/cpu.c:51
 #4  0x76ed8818 in cpuDataFree (data=data@entry=0x70c22d78) at cpu/cpu.c:216
 #5  0x716aaec0 in virQEMUCapsInitCPU (arch=VIR_ARCH_ARMV7L, caps=0x70c29a08) at qemu/qemu_capabilities.c:867

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoStop free'ing 'const char *' strings
Daniel P. Berrange [Tue, 3 Sep 2013 11:36:22 +0000 (12:36 +0100)]
Stop free'ing 'const char *' strings

The VIR_FREE() macro will cast away any const-ness. This masked a
number of places where we passed a 'const char *' string to
VIR_FREE. Fortunately in all of these cases, the variable was not
in fact const data, but a heap allocated string. Fix all the
variable declarations to reflect this.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoqemu: simplify list cleanup
Eric Blake [Wed, 28 Aug 2013 21:01:23 +0000 (15:01 -0600)]
qemu: simplify list cleanup

No need to open code now that we have a nice function.

Interestingly, our virStringFreeList function is typed correctly
(a malloc'd list of malloc'd strings is NOT const, whether at the
point where it is created, or at the point where it is cleand up),
so using it with a 'const char **' argument would require a cast
to keep the compiler.  I chose instead to remove const from code
even where we don't modify the argument, just to avoid the need
to cast.

* src/qemu/qemu_command.h (qemuParseCommandLine): Drop declaration.
* src/qemu/qemu_command.c (qemuParseProcFileStrings)
(qemuStringToArgvEnv): Don't force malloc'd result to be const.
(qemuParseCommandLinePid, qemuParseCommandLineString): Simplify
cleanup.
(qemuParseCommandLine, qemuFindEnv): Drop const-correctness to
avoid the need to cast in callers.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoconf: Don't deref NULL actual network in virDomainNetGetActualHostdev()
Peter Krempa [Wed, 4 Sep 2013 15:32:12 +0000 (17:32 +0200)]
conf: Don't deref NULL actual network in virDomainNetGetActualHostdev()

In commit 991270db99690 I've used virDomainNetGetActualHostdev() to get
the actual hostdev from a network when removing the network from the
list to avoid leaving the hostdev in the list. I didn't notice that this
function doesn't check if the actual network is allocated and
dereferences it. This crashes the daemon when cleaning up a domain
object in early startup phases when the actual network definition isn't
allocated. When the actual definition isn't present, the hostdev that
might correspond to it won't be present anyways so it's safe to return
NULL.

Thanks to Cole Robinson for noticing this problem.

11 years agolibxl: Unconditionally call virSysinfoRead() on driver init
Jim Fehlig [Wed, 4 Sep 2013 22:59:59 +0000 (16:59 -0600)]
libxl: Unconditionally call virSysinfoRead() on driver init

No need to check if privileged when reading hostsysinfo, since
that check was already done in libxlDriverShouldLoad().  The
libxl driver fails to load if not privileged.

11 years agolibxl: Check for regcomp failure
Jim Fehlig [Wed, 4 Sep 2013 06:21:42 +0000 (00:21 -0600)]
libxl: Check for regcomp failure

Change libxlGetAutoballoonConf() function to return an int
for success/failure, and fail if regcomp fails.

11 years agovirsh: fix build on mingw, which lacks termios stuff
Eric Blake [Wed, 4 Sep 2013 21:57:30 +0000 (15:57 -0600)]
virsh: fix build on mingw, which lacks termios stuff

Recent patches to fix handling of Ctrl-C when interacting with
ssh are not portable to mingw, which lacks termios handling.
The simplest solution is to just compile that code out, and
if someone ever appears that has a serious interest in getting
virsh fully functional even with ssh connections, they can
provide patches at that time.

* tools/virsh.h (_vshControl): Make termattr conditional.
* tools/virsh.c (vshTTYIsInterruptCharacter)
(vshTTYDisableInterrupt, vshTTYRestore, cfmakeraw, vshTTYMakeRaw)
(main): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agolibxl: Fix Coverity warning
Jim Fehlig [Wed, 4 Sep 2013 20:27:20 +0000 (14:27 -0600)]
libxl: Fix Coverity warning

John Ferlan reported the following Coverity warning:

In libxlDomainCoreDump() Coverity has noted a FORWARD_NULL reference:

2004      if ((flags & VIR_DUMP_CRASH) && !vm->persistent) {
2005          virDomainObjListRemove(driver->domains, vm);

(20) Event assign_zero:  Assigning: "vm" = "NULL".
Also see events:  [var_deref_model]

2006          vm = NULL;
2007      }
2008
2009      ret = 0;
2010
2011  cleanup_unpause:

(21) Event var_deref_model:  Passing null pointer "vm" to function
     "virDomainObjIsActive(virDomainObjPtr)", which dereferences it. [details]
Also see events:  [assign_zero]

2012      if (virDomainObjIsActive(vm) && paused) {
2013          if (libxl_domain_unpause(priv->ctx, dom->id) != 0) {
2014              virReportError(VIR_ERR_INTERNAL_ERROR,

Removing the vm from domain obj list and setting it to NULL can be
done in the previous 'if (flags & VIR_DUMP_CRASH)' conditional.  Fix
the Coverity warning by ensuring vm is not NULL before testing if it
is still active.

11 years agospec: default vbox according to libvirtd build
Eric Blake [Tue, 3 Sep 2013 23:08:25 +0000 (17:08 -0600)]
spec: default vbox according to libvirtd build

Commit ba5f3c7 moved virtualBox support into libvirtd, but the spec
file was still unconditionally requesting it even when not building
the server side.  Thankfully there were no ill effects for a
client_only build, as most uses of %{with_vbox} were guarded by
%{with_libvirtd}; but we might as well avoid confusion by more
closely matching the makefile.

* libvirt.spec.in (with_vbox): Hoist to server conditionals.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: avoid stranded polkit file in client-only build
Eric Blake [Wed, 4 Sep 2013 03:00:40 +0000 (21:00 -0600)]
build: avoid stranded polkit file in client-only build

daemon/Makefile.am installs a .policy file if WITH_LIBVIRTD and
WITH_POLKIT are both set.  src/Makefile.am, on the other hand,
installs a .policy file if WITH_POLKIT1 is set, but without checking
WITH_LIBVIRTD.  When running 'make rpm' with client_only manually
set, on a Fedora 19 box, that leads to a failure:

RPM build errors:
    Installed (but unpackaged) file(s) found:
   /usr/share/polkit-1/actions/org.libvirt.api.policy

Fix it by adding another conditional.

* src/Makefile.am (polkitaction_DATA): Make conditional.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: only install nwfilter examples when building nwfilter
Eric Blake [Tue, 3 Sep 2013 23:23:57 +0000 (17:23 -0600)]
build: only install nwfilter examples when building nwfilter

'make rpm' with client_local set to 1 (by manual modification,
or with RHEL 5 on s390) warns:

RPM build errors:
    Installed (but unpackaged) file(s) found:
   /etc/libvirt/nwfilter/allow-arp.xml
   /etc/libvirt/nwfilter/allow-dhcp-server.xml
   /etc/libvirt/nwfilter/allow-dhcp.xml
   /etc/libvirt/nwfilter/allow-incoming-ipv4.xml
   /etc/libvirt/nwfilter/allow-ipv4.xml
   /etc/libvirt/nwfilter/clean-traffic.xml
   /etc/libvirt/nwfilter/no-arp-ip-spoofing.xml
   /etc/libvirt/nwfilter/no-arp-mac-spoofing.xml
   /etc/libvirt/nwfilter/no-arp-spoofing.xml
   /etc/libvirt/nwfilter/no-ip-multicast.xml
   /etc/libvirt/nwfilter/no-ip-spoofing.xml
   /etc/libvirt/nwfilter/no-mac-broadcast.xml
   /etc/libvirt/nwfilter/no-mac-spoofing.xml
   /etc/libvirt/nwfilter/no-other-l2-traffic.xml
   /etc/libvirt/nwfilter/no-other-rarp-traffic.xml
   /etc/libvirt/nwfilter/qemu-announce-self-rarp.xml
   /etc/libvirt/nwfilter/qemu-announce-self.xml
   /usr/share/polkit-1/actions/org.libvirt.api.policy

The bulk of these are fixed with this patch.

* examples/xml/nwfilter/Makefile.am (install-data-local)
(uninstall-local): Make conditional.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agobuild: only run fdstreamtest when libvirtd is built
Eric Blake [Tue, 3 Sep 2013 21:55:21 +0000 (15:55 -0600)]
build: only run fdstreamtest when libvirtd is built

An rpm build with client_only set to 1 (for example, RHEL 5 on
s390, or by modifying libvirt.spec.in) failed with

TEST: fdstreamtest
 1) Stream read blocking                                              ... OK
 2) Stream read non-blocking                                          ... Unexpected EOF block 0 want 128
FAILED
 3) Stream write blocking                                             ... OK
 4) Stream write non-blocking                                         ... Failed to finish stream: internal error: libvirt:  error : cannot execute binary /home/eblake/rpmbuild/BUILD/libvirt-1.1.1/tests/../src/libvirt_iohelper: No such file or directory

Since the test depends on something that was only built for
WITH_LIBVIRTD (see src/Makefile.am), we must do the same for
the test.

* tests/Makefile.am (test_programs): Make fdstreamtest conditional.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agospec: fix rpm build when lxc disabled
Eric Blake [Tue, 3 Sep 2013 21:10:01 +0000 (15:10 -0600)]
spec: fix rpm build when lxc disabled

'make rpm' failed if ~/.rpmmacros contains '%_without_lxc 1',
which simulates the case of not having lxc available.

RPM build errors:
    File not found: /home/eblake/rpmbuild/BUILDROOT/libvirt-1.1.1-1.fc19.x86_64/etc/libvirt/virt-login-shell.conf
    File not found by glob: /home/eblake/rpmbuild/BUILDROOT/libvirt-1.1.1-1.fc19.x86_64/usr/share/man/man1/virt-login-shell.1*
    File not found: /home/eblake/rpmbuild/BUILDROOT/libvirt-1.1.1-1.fc19.x86_64/usr/bin/virt-login-shell
make: *** [rpm] Error 1

Reported by Dan Berrange.

* libvirt.spec.in: Mark virt-login-shell as conditional on lxc.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agovirGet{User,Group}Ent() don't say success on fail
Doug Goldstein [Wed, 4 Sep 2013 16:15:34 +0000 (11:15 -0500)]
virGet{User,Group}Ent() don't say success on fail

When virGetUserEnt() and virGetGroupEnt() fail due to the uid or gid not
existing on the machine they'll print a message like:

$ virsh -c vbox:///session list
error: failed to connect to the hypervisor
error: Failed to find user record for uid '32655': Success

The success at the end is a bit confusing. This changes it to:

$ virsh -c vbox:///session list
error: failed to connect to the hypervisor
error: Failed to find user record for uid '32655'

11 years agobuild: enforce makefile conditional style
Eric Blake [Wed, 4 Sep 2013 02:39:16 +0000 (20:39 -0600)]
build: enforce makefile conditional style

Automake has builtin support to prevent botched conditional nesting,
but only if you use:
if FOO
else !FOO
endif !FOO

An example error message when using the wrong name:

daemon/Makefile.am:378: error: else reminder (LIBVIRT_INIT_SCRIPT_SYSTEMD_TRUE) incompatible with current conditional: LIBVIRT_INIT_SCRIPT_SYSTEMD_FALSE
daemon/Makefile.am:381: error: endif reminder (LIBVIRT_INIT_SCRIPT_SYSTEMD_TRUE) incompatible with current conditional: LIBVIRT_INIT_SCRIPT_SYSTEMD_FALSE

As our makefiles tend to have quite a bit of nested conditionals,
it's better to take advantage of the benefits of the build system
double-checking that our conditionals are well-nested, but that
requires a syntax check to enforce our usage style.

Alas, unlike C preprocessor and spec files, we can't use indentation
to make it easier to see how deeply nesting goes.

* cfg.mk (sc_makefile_conditionals): New rule.
* daemon/Makefile.am: Enforce the style.
* gnulib/tests/Makefile.am: Likewise.
* python/Makefile.am: Likewise.
* src/Makefile.am: Likewise.
* tests/Makefile.am: Likewise.
* tools/Makefile.am: Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agodocs: Add OpenStack into references
Martin Kletzander [Wed, 4 Sep 2013 07:20:59 +0000 (09:20 +0200)]
docs: Add OpenStack into references

11 years agoDon't call VIR_ALLOC on def->uuid in parallels storage driver
Daniel P. Berrange [Tue, 3 Sep 2013 15:23:42 +0000 (16:23 +0100)]
Don't call VIR_ALLOC on def->uuid in parallels storage driver

The 'uuid' field in virDomainDefPtr is not a pointer, it is a
fixed length array. Calling VIR_ALLOC on it is thus wrong and
leaks memory.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoAdd missing 'libvirt_lxc_api' variable in pkg-config file
Daniel P. Berrange [Tue, 3 Sep 2013 11:31:53 +0000 (12:31 +0100)]
Add missing 'libvirt_lxc_api' variable in pkg-config file

The 'libvirt_lxc_api' variable is intended to allow apps to
query the location of the API XML file for libvirt_lxc.so

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
11 years agoFix coding style issues in daemon/remote.c
Nehal J Wani [Tue, 3 Sep 2013 20:36:20 +0000 (02:06 +0530)]
Fix coding style issues in daemon/remote.c

Fixes for argument layouts of various functions in daemon/remote.c

11 years agoconf: Remove the actual hostdev when removing a network
Peter Krempa [Tue, 3 Sep 2013 15:25:56 +0000 (17:25 +0200)]
conf: Remove the actual hostdev when removing a network

Commit 50348e6edfa reused the code to remove the hostdev portion of a
network definition on multiple places but forgot to take into account
that sometimes the "actual" network is passed and in some cases the
parent of that.

This patch uses the virDomainNetGetActualHostdev() helper to acquire the
correct pointer all the time while removing the hostdev portion from the
list.

11 years agoqemu: Make domain renaming work during migration
Jiri Denemark [Tue, 3 Sep 2013 13:17:03 +0000 (15:17 +0200)]
qemu: Make domain renaming work during migration

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

Since commit v1.0.5-56-g449e6b1 (Pull parsing of migration xml up into
QEMU driver APIs) any attempt to rename a domain during migration fails
with the following error message:

    internal error Incoming cookie data had unexpected name DOM vs DOM2

This is because migration cookies always use the original domain name
and the mentioned commit failed to propagate the name back to
qemuMigrationPrepareAny.

11 years agovirFileNBDDeviceAssociate: Avoid use of uninitialized variable
Michal Privoznik [Tue, 3 Sep 2013 16:56:06 +0000 (18:56 +0200)]
virFileNBDDeviceAssociate: Avoid use of uninitialized variable

The @qemunbd variable can be used uninitialized.

11 years agoAppArmorSetSecurityImageLabel: Avoid use of uninitialized variable
Michal Privoznik [Tue, 3 Sep 2013 16:54:58 +0000 (18:54 +0200)]
AppArmorSetSecurityImageLabel: Avoid use of uninitialized variable

The @profile_name variable can be used uninitialized.

11 years agolibxl: Use standard format for source file copyright notice
Jim Fehlig [Wed, 4 Sep 2013 05:43:00 +0000 (23:43 -0600)]
libxl: Use standard format for source file copyright notice

Change source file copyright notice to prevailing libvirt style.

11 years agolibxl: Add libxlDomObjFromDomain
Jim Fehlig [Fri, 30 Aug 2013 20:58:31 +0000 (14:58 -0600)]
libxl: Add libxlDomObjFromDomain

Similar to the QEMU and LXC drivers, add a helper function to
lookup a domain, and use it instead of much copy and paste.

11 years agolibxl: Remove unnecessary driver locking
Jim Fehlig [Fri, 30 Aug 2013 20:57:42 +0000 (14:57 -0600)]
libxl: Remove unnecessary driver locking

Now that most fields of libxlDriverPrivate struct are immutable
or self-locking, there is no need to acquire the driver lock in
much of the libxl driver.

11 years agolibxl: Move driver lock/unlock to libxl_conf
Jim Fehlig [Fri, 30 Aug 2013 20:56:40 +0000 (14:56 -0600)]
libxl: Move driver lock/unlock to libxl_conf

Move the libxl driver lock/unlock functions from libxl_driver.c
to libxl_conf.h so they can be used by other source files.

11 years agolibxl: Add comments to libxlDriverPrivate fields
Jim Fehlig [Fri, 30 Aug 2013 20:55:52 +0000 (14:55 -0600)]
libxl: Add comments to libxlDriverPrivate fields

Similar to the QEMU and LXC drivers, annotate the fields of
libxlDriverPrivate struct to indicate the locking rules for
their use.

11 years agolibxl: Use atomic ops for driver->nactive
Jim Fehlig [Fri, 30 Aug 2013 20:54:50 +0000 (14:54 -0600)]
libxl: Use atomic ops for driver->nactive

11 years agolibxl: Introduce libxlDriverConfig object
Jim Fehlig [Fri, 30 Aug 2013 20:52:14 +0000 (14:52 -0600)]
libxl: Introduce libxlDriverConfig object

The libxlDriverPrivate struct contains an variety of data with
varying access needs. Similar to the QEMU and LXC drivers,
move all the static config data into a dedicated libxlDriverConfig
object. The only locking requirement is to hold the driver lock
while obtaining an instance of libxlDriverConfig. Once a reference
is held on the config object, it can be used completely lockless
since it is immutable.

11 years agolibxl: User per-domain ctx in libxlDomainGetInfo
Jim Fehlig [Fri, 30 Aug 2013 20:36:22 +0000 (14:36 -0600)]
libxl: User per-domain ctx in libxlDomainGetInfo

libxlDomainGetInfo() uses the driver-wide libxl ctx when
it would be more appropriate to use the per-domain ctx
associated with the domain.  Switch to using the per-domain
libxl ctx.

11 years agolibxl: libxl: Use per-domain ctx in libxlMakeDomCreateInfo
Jim Fehlig [Fri, 30 Aug 2013 20:34:10 +0000 (14:34 -0600)]
libxl: libxl: Use per-domain ctx in libxlMakeDomCreateInfo

libxlMakeDomCreateInfo() uses the driver-wide libxl ctx when
it would be more appropriate to use the per-domain ctx
associated with the domain.  Switch to using the per-domain
libxl ctx.

11 years agolibxl: Add libxl_version_info to libxlDriverPrivate
Jim Fehlig [Fri, 30 Aug 2013 20:32:10 +0000 (14:32 -0600)]
libxl: Add libxl_version_info to libxlDriverPrivate

libxl version info is static data as far as the libxl driver
is concerned, so retrieve this info when the driver is initialized
and stash it in the libxlDriverPrivate object.  Subsequently use
the stashed info instead of repeatedly calling libxl_get_version_info().

11 years agolibxl: Earlier detection of not running on Xen
Jim Fehlig [Fri, 30 Aug 2013 18:34:48 +0000 (12:34 -0600)]
libxl: Earlier detection of not running on Xen

Detect early on in libxl driver initialization if the driver
should be loaded at all, avoiding needless initialization steps
that only have to be undone later.  While at it, move the
detection to a helper function to improve readability.

After detecting that the driver should be loaded, subsequent
failures such as initializing the log stream, allocating libxl
ctx, etc. should be treated as failure to initialize the driver.

11 years agolibxl: Introduce libxl_domain.[ch]
Jim Fehlig [Fri, 30 Aug 2013 17:18:31 +0000 (11:18 -0600)]
libxl: Introduce libxl_domain.[ch]

Create libxl_domain.[ch] and move all functions operating on
libxlDomainObjPrivate to these files.  This will be useful for
future patches that e.g. add job support for libxlDomainObjPrivate.

11 years agolibxl: Move detection of autoballoon to libxl_conf
Jim Fehlig [Fri, 30 Aug 2013 17:11:08 +0000 (11:11 -0600)]
libxl: Move detection of autoballoon to libxl_conf

Detecting whether or not to autoballoon is configuration related,
so move the code to libxl_conf.

11 years agobuild: fix typo that broke 'make dist'
Eric Blake [Tue, 3 Sep 2013 22:37:06 +0000 (16:37 -0600)]
build: fix typo that broke 'make dist'

Bug introduced in commit 5c6ff42; 'make dist' fails:

make[3]: Entering directory `/home/eblake/libvirt-tmp/build3/examples/python'
make[3]: *** No rule to make target `topoology.py', needed by `distdir'.  Stop.
make[3]: Leaving directory `/home/eblake/libvirt-tmp/build3/examples/python'

* examples/python/Makefile.am (EXTRA_DIST): Spell topology right.

Signed-off-by: Eric Blake <eblake@redhat.com>
11 years agoesx_driver: Resolve Coverity RESOURCE_LEAK on error paths
John Ferlan [Tue, 3 Sep 2013 11:20:34 +0000 (07:20 -0400)]
esx_driver: Resolve Coverity RESOURCE_LEAK on error paths

New Coverity release found a couple of error paths where memory would be
leaked in an error/goto path before being properly handled.

11 years agoesx_vi: Resolve Coverity RESOURCE_LEAK in error path
John Ferlan [Tue, 3 Sep 2013 11:16:07 +0000 (07:16 -0400)]
esx_vi: Resolve Coverity RESOURCE_LEAK in error path

New coverity installation determined that the muliple if condition for
"*Alloc" and "*AppendToList" could fail during AppendToList thus leaking
memory.

11 years agotest_virtlockd.aug.in: Use the correct file
Michal Privoznik [Tue, 3 Sep 2013 14:41:57 +0000 (16:41 +0200)]
test_virtlockd.aug.in: Use the correct file

The test should refer to Virtlockd.lns, which is the name of
the module + lens in virtlockd.aug.

11 years agoexamples: Add script to parse topology from capabilities output
Peter Krempa [Tue, 27 Aug 2013 10:27:21 +0000 (12:27 +0200)]
examples: Add script to parse topology from capabilities output

Add a demo script originally written by Amador Pahim to parse topology
of the host from data provided in the capabilities XML.

11 years agovirsh-console: Avoid using signal() in multithreaded application
Peter Krempa [Thu, 29 Aug 2013 16:30:06 +0000 (18:30 +0200)]
virsh-console: Avoid using signal() in multithreaded application

Man page for signal states:

 "The effects of signal() in a multithreaded process are unspecified."

Switch signal() to sigaction in virsh console code.

11 years agovirsh: Rename vshMakeStdinRaw to vshTTYMakeRaw and move it to virsh.c
Peter Krempa [Thu, 29 Aug 2013 16:15:07 +0000 (18:15 +0200)]
virsh: Rename vshMakeStdinRaw to vshTTYMakeRaw and move it to virsh.c

Move the function to virsh.c to the rest of the TTY managing functions
and change the code so that it mirrors the rest.

11 years agotools: rename console.[ch] to virsh-console.[ch] and fix coding style
Peter Krempa [Mon, 26 Aug 2013 09:53:43 +0000 (11:53 +0200)]
tools: rename console.[ch] to virsh-console.[ch] and fix coding style

11 years agoqemu: Handle huge number of queues correctly
Michal Privoznik [Mon, 2 Sep 2013 14:06:14 +0000 (16:06 +0200)]
qemu: Handle huge number of queues correctly

Currently, kernel supports up to 8 queues for a multiqueue tap device.
However, if user tries to enter a huge number (e.g. one million) the tap
allocation fails, as expected. But what is not expected is the log full
of warnings:

    warning : virFileClose:83 : Tried to close invalid fd 0

The problem is, upon error we iterate over an array of FDs (handlers to
queues) and VIR_FORCE_CLOSE() over each item. However, the array is
pre-filled with zeros. Hence, we repeatedly close stdin. Ouch.
But there's more. The queues allocation is done in virNetDevTapCreate()
which cleans up the FDs in case of error. Then, its caller, the
virNetDevTapCreateInBridgePort() iterates over the FD array and tries to
close them too. And so does qemuNetworkIfaceConnect() and
qemuBuildInterfaceCommandLine().

11 years agoFix leaks in python bindings
Ján Tomko [Tue, 3 Sep 2013 11:12:37 +0000 (13:12 +0200)]
Fix leaks in python bindings

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

11 years agovirsh-domain: Avoid killing ssh transport tunnels when cancelling job
Peter Krempa [Thu, 29 Aug 2013 13:18:20 +0000 (15:18 +0200)]
virsh-domain: Avoid killing ssh transport tunnels when cancelling job

The vshWatchJob function registers a SIGINT handler that is used to
abort the active job and does not terminate virsh. Unfortunately, this
breaks when using the ssh transport as SIGINT is sent to the foreground
process group including the ssh transport processes which terminate.
This breaks the connection and migration is left in a insane state.

With this patch the terminal is modified to ignore key binding that
sends SIGINT and does the handling manually.

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

11 years agovirsh: Remember terminal state when starting and add helpers
Peter Krempa [Thu, 29 Aug 2013 08:36:00 +0000 (10:36 +0200)]
virsh: Remember terminal state when starting and add helpers

This patch adds instrumentation to allow modification of config of the
terminal in virsh and successful reset of the state afterwards.

The added helpers allow to disable receiving of SIGINT when pressing the
key sequence (Ctrl+C usualy). This normally sends SIGINT to the
foreground process group which kills ssh processes used for transport of
the data.

11 years agoVMX: Add cdrom-raw dev type from VMWare Fusion
Doug Goldstein [Tue, 13 Aug 2013 01:55:57 +0000 (20:55 -0500)]
VMX: Add cdrom-raw dev type from VMWare Fusion

According to VMWare's documentation 'cdrom-raw' is an acceptable value
for deviceType for a CD-ROM drive. The documentation states that the VMX
configuration for a CD-ROM deviceType is as follows:

ide|scsi(n):(n).deviceType = "cdrom-raw|atapi-cdrom|cdrom-image"

From the documentation it appears the following is true:
- cdrom-image = Provides the ISO to the VM
- atapi-cdrom = Provides a NEC emulated ATAPI CD-ROM on top of the host
  CD-ROM
- cdrom-raw = Passthru for a host CD-ROM drive. Allows CD-R burning from
  within the guest.

A CD-ROM prior to this patch would always provide an 'atapi-cdrom' is
modeled as:
  <disk type='block' device='cdrom'>
    <source dev='/dev/scd0'/>
    <target dev='hda' bus='ide'/>
    <address type='drive' controller='0' bus='0' target='0' unit='0'/>
  </disk>

This patch allows the 'device' attribute to be set to 'lun' for a raw
acccess CD-ROM such as:
  <disk type='block' device='lun'>
    <source dev='/dev/scd0'/>
    <target dev='hda' bus='ide'/>
    <address type='drive' controller='0' bus='0' target='0' unit='0'/>
  </disk>

11 years agoVMX: Some serial ports are not actually connected
Doug Goldstein [Mon, 12 Aug 2013 22:29:40 +0000 (17:29 -0500)]
VMX: Some serial ports are not actually connected

Sometimes a serial port might not be actually wired to a device when the
user does not have the VM powered on and we should not consider this a
fatal error.

11 years agoqemu: Support virtio-mmio transport for virtio on ARM
Cole Robinson [Thu, 1 Aug 2013 01:40:35 +0000 (21:40 -0400)]
qemu: Support virtio-mmio transport for virtio on ARM

Starting with qemu 1.6, the qemu-system-arm vexpress-a9 model has a
hardcoded virtio-mmio transport which enables attaching all virtio
devices.

On the command line, we have to use virtio-XXX-device rather than
virtio-XXX-pci, thankfully s390 already set the precedent here so
it's fairly straight forward.

At the XML level, this adds a new device address type virtio-mmio.
The controller and addressing don't have any subelements at the
moment because we they aren't needed for this usecase, but could
be added later if needed.

Add a test case for an ARM guest with one of every virtio device
enabled.

11 years agoqemu: Fix networking for ARM guests
Cole Robinson [Tue, 30 Jul 2013 22:51:30 +0000 (18:51 -0400)]
qemu: Fix networking for ARM guests

Similar to the chardev bit, ARM boards depend on the old style '-net nic'
for actually instantiating net devices. But we can't block out
-netdev altogether since it's needed for upcoming virtio support.

And add tests for working ARM XML with console, disk, and networking.

11 years agodomain_conf: Add disk bus=sd, wire it up for qemu
Cole Robinson [Wed, 31 Jul 2013 13:00:26 +0000 (09:00 -0400)]
domain_conf: Add disk bus=sd, wire it up for qemu

This corresponds to '-sd' and '-drive if=sd' on the qemu command line.
Needed for many ARM boards which don't provide any other way to
pass in storage.

11 years agoqemu: Don't try to allocate PCI addresses for ARM
Cole Robinson [Tue, 30 Jul 2013 22:56:15 +0000 (18:56 -0400)]
qemu: Don't try to allocate PCI addresses for ARM

11 years agoqemu: Fix specifying char devs for ARM
Cole Robinson [Tue, 30 Jul 2013 21:49:11 +0000 (17:49 -0400)]
qemu: Fix specifying char devs for ARM

QEMU ARM boards don't give us any way to explicitly wire in
a -chardev, so use the old style -serial options.

Unfortunately this isn't as simple as just turning off the CHARDEV flag
for qemu-system-arm, as upcoming virtio support _will_ use device/chardev.

11 years agoqemu: Don't add default memballoon device on ARM
Cole Robinson [Tue, 30 Jul 2013 19:41:14 +0000 (15:41 -0400)]
qemu: Don't add default memballoon device on ARM

And add test cases for a basic working ARM guest.

11 years agodomain_conf: Add default memballoon in PostParse callbacks
Cole Robinson [Sat, 17 Aug 2013 00:33:23 +0000 (20:33 -0400)]
domain_conf: Add default memballoon in PostParse callbacks

This should be a no-op change for now.

11 years agoqemu: Set QEMU_AUDIO_DRV=none with -nographic
Cole Robinson [Sat, 17 Aug 2013 19:30:47 +0000 (15:30 -0400)]
qemu: Set QEMU_AUDIO_DRV=none with -nographic

On my machine, a guest fails to boot if it has a sound card, but not
graphical device/display is configured, because pulseaudio fails to
initialize since it can't access $HOME.

A workaround is removing the audio device, however on ARM boards there
isn't any option to do that, so -nographic always fails.

Set QEMU_AUDIO_DRV=none if no <graphics> are configured. Unfortunately
this has massive test suite fallout.

Add a qemu.conf parameter nographics_allow_host_audio, that if enabled
will pass through QEMU_AUDIO_DRV from sysconfig (similar to
vnc_allow_host_audio)

11 years agoPass AM_LDFLAGS to driver modules too
Guido Günther [Sun, 1 Sep 2013 06:50:58 +0000 (08:50 +0200)]
Pass AM_LDFLAGS to driver modules too

This gives us a RO got, otherwise Debian's lintian complains:

W: libvirt-bin: hardening-no-relro usr/lib/libvirt/connection-driver/libvirt_driver_qemu.so
W: libvirt-bin: hardening-no-relro usr/lib/libvirt/connection-driver/libvirt_driver_storage.so
W: libvirt-bin: hardening-no-relro usr/lib/libvirt/connection-driver/libvirt_driver_uml.so
W: libvirt-bin: hardening-no-relro usr/lib/libvirt/connection-driver/libvirt_driver_vbox.so
W: libvirt-bin: hardening-no-relro usr/lib/libvirt/connection-driver/libvirt_driver_xen.so
W: libvirt-bin: hardening-no-relro usr/lib/libvirt/connection-driver/libvirt_driver_nwfilter.so
W: libvirt-bin: hardening-no-relro usr/lib/libvirt/connection-driver/libvirt_driver_storage.so
W: libvirt-bin: hardening-no-relro usr/lib/libvirt/connection-driver/libvirt_driver_uml.so
W: libvirt-sanlock: hardening-no-relro usr/lib/libvirt/lock-driver/sanlock.so

11 years agoFix AM_LDFLAGS typo
Guido Günther [Sun, 1 Sep 2013 07:53:03 +0000 (09:53 +0200)]
Fix AM_LDFLAGS typo

11 years agoqemu: Support setting the 'removable' flag for USB disks
Fred A. Kemp [Fri, 23 Aug 2013 10:38:11 +0000 (12:38 +0200)]
qemu: Support setting the 'removable' flag for USB disks

Add an attribute named 'removable' to the 'target' element of disks,
which controls the removable flag. For instance, on a Linux guest it
controls the value of /sys/block/$dev/removable. This option is only
valid for USB disks (i.e. bus='usb'), and its default value is 'off',
which is the same behaviour as before.

To achieve this, 'removable=on' (or 'off') is appended to the '-device
usb-storage' parameter sent to qemu when adding a USB disk via
'-disk'. A capability flag QEMU_CAPS_USB_STORAGE_REMOVABLE was added
to keep track if this option is supported by the qemu version used.

Bug: https://bugzilla.redhat.com/show_bug.cgi?id=922495
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
11 years agoqemu: Add capability flag for usb-storage
Fred A. Kemp [Fri, 23 Aug 2013 10:38:10 +0000 (12:38 +0200)]
qemu: Add capability flag for usb-storage

Allow use of the usb-storage device only if the new capability flag
QEMU_CAPS_DEVICE_USB_STORAGE is set, which it is for qemu(-kvm)
versions >= 0.12.1.2-rhel62-beta.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>