]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
12 years agodaemon: Fix LIBVIRT_DEBUG=1 default output
Cole Robinson [Wed, 24 Oct 2012 20:51:44 +0000 (16:51 -0400)]
daemon: Fix LIBVIRT_DEBUG=1 default output

This commit changes the behavior of LIBVIRT_DEBUG=1 libvirtd:

$ git show 7022b09111d4322d21396a70d58320a9ad773962
commit 7022b09111d4322d21396a70d58320a9ad773962
Author: Daniel P. Berrange <berrange@redhat.com>
Date:   Thu Sep 27 13:13:09 2012 +0100

    Automatically enable systemd journal logging

    Probe to see if the systemd journal is accessible, and if
    so enable logging to the journal by default, rather than
    stderr (current default under systemd).

Previously  'LIBVIRT_DEBUG=1 /usr/sbin/libvirtd' would show all debug
output to stderr, now it send debug output to the journal.

Only use the journal by default if running in daemon mode, or
if stdin is _not_ a tty. This should make libvirtd launched from
systemd use the journal, but preserve the old behavior in most
situations.

12 years agonetwork: fix networkValidate check for default portgroup and vlan
Laine Stump [Thu, 25 Oct 2012 15:13:52 +0000 (11:13 -0400)]
network: fix networkValidate check for default portgroup and vlan

This was found during testing of the fix for:

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

networkValidate was supposed to check for the existence of multiple
portgroups and report an error if this was encountered. It did, but
there were two problems:

1) even though it logged an error, it still returned success, allowing
the operation to continue.

2) It could exit the portgroup checking loop early (or possibly not
even do it once) if a vlan tag was supplied in the base network config
or one of the portgroups.

This patch fixes networkValidate to return failure in addition to
logging the error, and also changes it to not exit the portgroup
checking loop early. The logic was a bit off in the checking for vlan
anyway, and it's intertwined with fixing the early loop exit, so I
fixed that as well. Now it correctly checks for combinations where a
<virtualport> is specified in the base network def and <vlan> is given
in a portgroup, as well as the opposite (<vlan> in base network def
and <virtualport> in portgroup), and ignores the case of a disallowed
vlan when using *no* portgroup if there is a default portgroup (since
in that case there is no way to not use any portgroup).

12 years agomaint: consistent whitespace after 'if'
Eric Blake [Thu, 25 Oct 2012 17:36:43 +0000 (11:36 -0600)]
maint: consistent whitespace after 'if'

Noticed during the review of the previous patch.

* python/libvirt-override.c: Use space between 'if ('.

12 years agovirNodeGetCPUMap: Add python binding
Viktor Mihajlovski [Thu, 25 Oct 2012 14:59:08 +0000 (16:59 +0200)]
virNodeGetCPUMap: Add python binding

Added a method getCPUMap to virConnect.
It can be used as follows:

import libvirt
import sys
import os

conn = libvirt.openReadOnly(None)
if conn == None:
    print 'Failed to open connection to the hypervisor'
    sys.exit(1)

try:
    (cpus, cpumap, online) = conn.getCPUMap(0)
except:
    print 'Failed to extract the node cpu map information'
    sys.exit(1)

print 'CPUs total %d, online %d' % (cpus, online)
print 'CPU map %s' % str(cpumap)

del conn
print "OK"

sys.exit(0)

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
12 years agovirNodeGetCPUMap: Implement driver support
Viktor Mihajlovski [Tue, 16 Oct 2012 14:05:15 +0000 (16:05 +0200)]
virNodeGetCPUMap: Implement driver support

Driver support added for:
- test: pretending 8 host CPUS, 3 being online
- qemu, lxc, openvz, uml: using nodeGetCPUMap

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
12 years agovirNodeGetCPUMap: Implement support function in nodeinfo
Viktor Mihajlovski [Tue, 16 Oct 2012 14:05:14 +0000 (16:05 +0200)]
virNodeGetCPUMap: Implement support function in nodeinfo

Added an implemention of virNodeGetCPUMap to nodeinfo.c,
(nodeGetCPUMap) which can be used by all drivers for a Linux
hypervisor host.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
12 years agonodeinfo: improve probing node cpu bitmap
Eric Blake [Wed, 24 Oct 2012 22:43:26 +0000 (16:43 -0600)]
nodeinfo: improve probing node cpu bitmap

Callers should not need to know what the name of the file to
be read in the Linux-specific version of nodeGetCPUmap;
furthermore, qemu cares about online cpus, not present cpus,
when determining which cpus to skip.

While at it, I fixed the fact that we were computing the maximum
online cpu id by doing a slow iteration, when what we really want
to know is the max available cpu.

* src/nodeinfo.h (nodeGetCPUmap): Rename...
(nodeGetCPUBitmap): ...and simplify signature.
* src/nodeinfo.c (linuxParseCPUmax): New function.
(linuxParseCPUmap): Simplify and alter signature.
(nodeGetCPUBitmap): Change implementation.
* src/libvirt_private.syms (nodeinfo.h): Reflect rename.
* src/qemu/qemu_driver.c (qemuDomainGetPercpuStats): Update
caller.

12 years agobitmap: add virBitmapCountBits
Eric Blake [Thu, 25 Oct 2012 00:44:27 +0000 (18:44 -0600)]
bitmap: add virBitmapCountBits

Sometimes it's handy to know how many bits are set.

* src/util/bitmap.h (virBitmapCountBits): New prototype.
(virBitmapNextSetBit): Use correct type.
* src/util/bitmap.c (virBitmapNextSetBit): Likewise.
(virBitmapSetAll): Maintain invariant of clear tail bits.
(virBitmapCountBits): New function.
* src/libvirt_private.syms (bitmap.h): Export it.
* tests/virbitmaptest.c (test2): Test it.

12 years agoFix build with apparmor
Jiri Denemark [Wed, 24 Oct 2012 10:13:48 +0000 (12:13 +0200)]
Fix build with apparmor

Recent storage patches changed signature of virStorageFileGetMetadata
and replaced chain with backingChain in virDomainDiskDef.

12 years agoesx: Update version checks for vSphere 5.1
Matthias Bolte [Wed, 24 Oct 2012 17:50:15 +0000 (19:50 +0200)]
esx: Update version checks for vSphere 5.1

Also remove warnings for upcoming versions. There hadn't been any
compatibility problems with new ESX version over the whole lifetime
of the ESX driver, so I don't expect any in the future.

Update documentation to mention vSphere 5.x support.

12 years agocpu: Add recently added cpu feature flags.
Peter Krempa [Wed, 24 Oct 2012 13:10:51 +0000 (15:10 +0200)]
cpu: Add recently added cpu feature flags.

Qemu has added some new feature flags. This patch adds them to libvirt.

The new features are for the cpuid function 0x7 that takes an argument
in the ecx register. Currently only 0x0 is used as the argument so I was
lazy and I just clear the registers to 0 before calling cpuid. In future
when there maybe will be some other possible arguments, we will need to
improve the cpu detection code to take this into account.

12 years agoqemu: Prohibit chaning affinity of domain process if placement is 'auto'
Osier Yang [Wed, 24 Oct 2012 09:46:00 +0000 (17:46 +0800)]
qemu: Prohibit chaning affinity of domain process if placement is 'auto'

On one hand, numad probably will manage the affinity of domain process
dynamically in future. On the other hand, even numad won't manage it,
it still could confusion. Let's make things simpler enough to avoid
the lair for now.

12 years agoqemu: Keep the affinity when creating cgroup for emulator thread
Osier Yang [Wed, 24 Oct 2012 09:27:56 +0000 (17:27 +0800)]
qemu: Keep the affinity when creating cgroup for emulator thread

When the cpu placement model is "auto", it sets the affinity for
domain process with the advisory nodeset from numad, however,
creating cgroup for the domain process (called emulator thread
in some contexts) later overrides that with pinning it to all
available pCPUs.

How to reproduce:

  * Configure the domain with "auto" placement for <vcpu>, e.g.
    <vcpu placement='auto'>4</vcpu>
  * % virsh start dom
  * % cat /proc/$dompid/status

Though the emulator cgroup cause conflicts, but we can't simply
prohibit creating it, as other tunables are still useful, such
as "emulator_period", which is used by API
virDomainSetSchedulerParameter. So this patch doesn't prohibit
creating the emulator cgroup, but inherit the nodeset from numad,
and reset the affinity for domain process.

* src/qemu/qemu_cgroup.h: Modify definition of qemuSetupCgroupForEmulator
                          to accept the passed nodenet
* src/qemu/qemu_cgroup.c: Set the affinity with the passed nodeset

12 years agoqemu: Add helper to prepare cpumap for affinity setting
Osier Yang [Wed, 24 Oct 2012 09:22:52 +0000 (17:22 +0800)]
qemu: Add helper to prepare cpumap for affinity setting

Abstract the codes to prepare cpumap into a helper a function,
which can be used later.

* src/qemu/qemu_process.h: Declare qemuPrepareCpumap
* src/qemu/qemu_process.c: Implement qemuPrepareCpumap, and use it.

12 years agovirNodeGetCPUMap: Implement virsh support.
Viktor Mihajlovski [Tue, 16 Oct 2012 14:05:13 +0000 (16:05 +0200)]
virNodeGetCPUMap: Implement virsh support.

- Added a new host command nodecpumap
- Added documentation

Example:
$ virsh nodecpumap
CPUs present:  8
CPUs online:   3
CPU map:       y-y-y---

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
12 years agolibvirt.h.in: Add new cpumap macro VIR_CPU_USED
Viktor Mihajlovski [Tue, 16 Oct 2012 14:05:12 +0000 (16:05 +0200)]
libvirt.h.in: Add new cpumap macro VIR_CPU_USED

New macro VIR_CPU_USED added to facilitate the interpretation of
cpu maps.
Further, hardened the other cpumap macros against invocations
like VIR_CPU_USE(cpumap + 1, cpu)

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
12 years agovirNodeGetCPUMap: Implement wire protocol.
Viktor Mihajlovski [Tue, 16 Oct 2012 14:05:11 +0000 (16:05 +0200)]
virNodeGetCPUMap: Implement wire protocol.

- Defined the wire protocol format for virNodeGetCPUMap and its
  arguments
- Implemented remote method invocation (remoteNodeGetCPUMap)
- Implemented method dispatcher (remoteDispatchNodeGetCPUMap)

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
12 years agovirNodeGetCPUMap: Define public API.
Viktor Mihajlovski [Tue, 23 Oct 2012 20:34:53 +0000 (14:34 -0600)]
virNodeGetCPUMap: Define public API.

Adding a new API to obtain information about the
host node's present, online and offline CPUs.

int virNodeGetCPUMap(virConnectPtr conn,
                     unsigned char **cpumap,
                     unsigned int *online,
                     unsigned int flags);

The function will return the number of CPUs present on the host
or -1 on failure;
If cpumap is non-NULL virNodeGetCPUMap will allocate an array
containing a bit map representation of the online CPUs. It's
the callers responsibility to deallocate cpumap using free().
If online is non-NULL, the variable pointed to will contain
the number of online host node CPUs.
The variable flags has been added to support future extensions
and must be set to 0.

Extend the driver structure by nodeGetCPUMap entry in support of the
new API virNodeGetCPUMap.
Added implementation of virNodeGetCPUMap to libvirt.c

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
12 years agoheader: declare node memory parameter handling earlier
Eric Blake [Tue, 23 Oct 2012 17:47:46 +0000 (11:47 -0600)]
header: declare node memory parameter handling earlier

Commit 12ad7435 added new functions (virNodeGetMemoryParameters,
virNodeSetMemoryParameters) into the section of the file reserved
for deprecated names.  Fix this by moving things earlier; split
into two patches to make git diff easier to read.

* include/libvirt/libvirt.h.in: Move virNodeGetMemoryParameters
and friends earlier, add a note to prevent relapse.

12 years agoheader: declare typed parameter handling earlier
Eric Blake [Tue, 23 Oct 2012 17:47:46 +0000 (11:47 -0600)]
header: declare typed parameter handling earlier

Commit 12ad7435 added new functions (virNodeGetMemoryParameters,
virNodeSetMemoryParameters) into the section of the file reserved
for deprecated names.  Fix this by moving things earlier; split
into two patches to make git diff easier to read.

* include/libvirt/libvirt.h.in: Move virTypedParameter earlier.

12 years agobuild: improve FORTIFY_SOURCE usage
Eric Blake [Tue, 23 Oct 2012 20:00:32 +0000 (14:00 -0600)]
build: improve FORTIFY_SOURCE usage

Based on this coreutils bug report, since coreutils copied what
libvirt had done:
https://lists.gnu.org/archive/html/bug-coreutils/2012-10/msg00121.html

* m4/virt-compile-warnings.m4 (LIBVIRT_COMPILE_WARNINGS): Allow
for user to pre-define _FORTIFY_SOURCE.

12 years agoqemu_migration: Transport OVS per-port data during live migration
Kyle Mestery [Mon, 1 Oct 2012 15:18:22 +0000 (11:18 -0400)]
qemu_migration: Transport OVS per-port data during live migration

Transport Open vSwitch per-port data during live
migration by using the utility functions
virNetDevOpenvswitchGetMigrateData() and
virNetDevOpenvswitchSetMigrateData().

Signed-off-by: Kyle Mestery <kmestery@cisco.com>
12 years agoopenvswitch: Add utility functions for getting and setting Open vSwitch per-port...
Kyle Mestery [Mon, 1 Oct 2012 15:18:21 +0000 (11:18 -0400)]
openvswitch: Add utility functions for getting and setting Open vSwitch per-port data

Add utility functions for Open vSwitch to both save
per-port data before a live migration, and restore the
per-port data after a live migration.

Signed-off-by: Kyle Mestery <kmestery@cisco.com>
12 years agoqemu_migration: Add hooks to transport network data during migration
Kyle Mestery [Mon, 1 Oct 2012 15:18:20 +0000 (11:18 -0400)]
qemu_migration: Add hooks to transport network data during migration

Add the ability for the Qemu V3 migration protocol to
include transporting network configuration. A generic
framework is proposed with this patch to allow for the
transfer of opaque data.

Signed-off-by: Kyle Mestery <kmestery@cisco.com>
Signed-off-by: Laine Stump <laine@laine.org>
12 years agoFix detection of Xen sysctl version 9
Jim Fehlig [Tue, 23 Oct 2012 17:18:20 +0000 (11:18 -0600)]
Fix detection of Xen sysctl version 9

In commit 371ddc98, I mistakenly added the check for sysctl
version 9 after setting the hypercall version to 1, which will
fail with

error : xenHypervisorDoV1Op:967 : Unable to issue hypervisor
ioctl 3166208: Function not implemented

This check should be included along with the others that use
hypercall version 2.

12 years agoselinux: Don't fail RestoreAll if file doesn't have a default label
Cole Robinson [Sat, 20 Oct 2012 19:57:28 +0000 (15:57 -0400)]
selinux: Don't fail RestoreAll if file doesn't have a default label

When restoring selinux labels after a VM is stopped, any non-standard
path that doesn't have a default selinux label causes the process
to stop and exit early. This isn't really an error condition IMO.

Of course the selinux API could be erroring for some other reason
but hopefully that's rare enough to not need explicit handling.

Common example here is storing disk images in a non-standard location
like under /mnt.

12 years agobuild: print uids as unsigned
Eric Blake [Tue, 23 Oct 2012 14:38:33 +0000 (08:38 -0600)]
build: print uids as unsigned

Reported by Michal Privoznik.

* src/security/security_dac.c (virSecurityDACGenLabel): Use
correct format.

12 years agoxml: omit domain name from comment if it contains double hyphen
Ján Tomko [Tue, 23 Oct 2012 12:16:44 +0000 (14:16 +0200)]
xml: omit domain name from comment if it contains double hyphen

We put a comment containing "virsh edit <domain_name>" at the start of
the XML. W3C recommendation forbids the use of "--" in comments [1] and
libvirt can't parse it either. This patch omits the domain name if it
contains a double hyphen.

[1] http://www.w3.org/TR/REC-xml/#sec-comments

12 years agostorage: don't shadow global 'wait' declaration
Ján Tomko [Tue, 23 Oct 2012 11:33:21 +0000 (13:33 +0200)]
storage: don't shadow global 'wait' declaration

Rename the 'wait' parameter to 'loop'.
This silences the warning:
storage/storage_backend.c:1348:34: error: declaration of 'wait' shadows
a global declaration [-Werror=shadow]
and fixes the build with -Werror.
--
Note: loop is pool backwards.

12 years agoFix disabling of apparmor/selinux security drivers
Christophe Fergeau [Sun, 21 Oct 2012 18:32:39 +0000 (20:32 +0200)]
Fix disabling of apparmor/selinux security drivers

When using --without-$name --without-secdriver-$name with $name being
selinux or apparmor, configure will fail saying that AppArmor/SELinux
development package must be installed.
This is caused by a small bug in --with-secdriver-$name handling in
configure.ac which treats --without-secdriver-$name when $name as if the
user had requested to enable $name when $name couldn't be detected on
the system.

This commit also makes sure the detection checks for disabled
secdrivers do not needlessly get run, especially as this could
cause an error as well in --with-$name --without-secdriver-$name
situations.

12 years agomaint: update to latest gnulib
Eric Blake [Mon, 22 Oct 2012 21:03:31 +0000 (15:03 -0600)]
maint: update to latest gnulib

* .gnulib: Update to latest, prior to freeze.

12 years agosnapshot: sanity check when reusing file for snapshot
Eric Blake [Fri, 6 Apr 2012 16:32:07 +0000 (10:32 -0600)]
snapshot: sanity check when reusing file for snapshot

The snapshot code when reusing an existing file had hard-to-read
logic, as well as a missing sanity check: REUSE_EXT should require
the destination to already be present.

* src/qemu/qemu_driver.c (qemuDomainSnapshotDiskPrepare): Require
destination on REUSE_EXT, rename variable for legibility.

12 years agobuild: use correct printf types for uid/gid
Eric Blake [Mon, 22 Oct 2012 20:39:14 +0000 (14:39 -0600)]
build: use correct printf types for uid/gid

Fixes a build failure on cygwin:
cc1: warnings being treated as errors
security/security_dac.c: In function 'virSecurityDACSetProcessLabel':
security/security_dac.c:862:5: error: format '%u' expects type 'unsigned int', but argument 7 has type 'uid_t' [-Wformat]
security/security_dac.c:862:5: error: format '%u' expects type 'unsigned int', but argument 8 has type 'gid_t' [-Wformat]

* src/security/security_dac.c (virSecurityDACSetProcessLabel)
(virSecurityDACGenLabel): Use proper casts.

12 years agoRemove a couple duplicates from AUTHORS.in
Cole Robinson [Mon, 22 Oct 2012 20:19:38 +0000 (16:19 -0400)]
Remove a couple duplicates from AUTHORS.in

12 years agostorage: Don't do wait loops from VolLookupByPath
Cole Robinson [Sun, 21 Oct 2012 16:53:20 +0000 (12:53 -0400)]
storage: Don't do wait loops from VolLookupByPath

virStorageVolLookupByPath is an API call that virt-manager uses
quite a bit when dealing with storage. This call use BackendStablePath
which has several usleep() heuristics that can be tripped up
and hang virt-manager for a while.

Current example: an empty mpath pool pointing to /dev/mapper makes
_any_ calls to virStorageVolLookupByPath take 5 seconds.

The sleep heuristics are actually only needed in certain cases
when we are waiting for new storage to appear, so let's skip the
timeout steps when calling from LookupByPath.

12 years agospec: Fix multilib issue with systemtap tapsets
Cole Robinson [Sun, 21 Oct 2012 02:46:58 +0000 (22:46 -0400)]
spec: Fix multilib issue with systemtap tapsets

If building on a 64bit host, rename the affected tapsets to <name>-64.stp.
This is similar to what the python package does in fedora.

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

12 years agodocs: Fix installation of internals/*.html
Cole Robinson [Sun, 21 Oct 2012 00:29:47 +0000 (20:29 -0400)]
docs: Fix installation of internals/*.html

We were just installing them in the top level html directory, which
broke navigation and overwrote other pages.

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

12 years agoqemu: Don't use -enable-nesting with qemu 1.2.0+
Cole Robinson [Sat, 20 Oct 2012 19:25:31 +0000 (15:25 -0400)]
qemu: Don't use -enable-nesting with qemu 1.2.0+

Since the option doesn't exist. Fixes booting with
cpu mode='host-model' and qemu 1.2.0

12 years agoqemu: Don't blindly assume VNC is supported
Doug Goldstein [Fri, 19 Oct 2012 19:40:52 +0000 (14:40 -0500)]
qemu: Don't blindly assume VNC is supported

Currently it's assumed that qemu always supports VNC, however it is
definitely possible to compile qemu without VNC support so we should at
the very least check for it and handle that correctly.

12 years agotest: Don't assume VNC is always available
Doug Goldstein [Fri, 19 Oct 2012 19:40:51 +0000 (14:40 -0500)]
test: Don't assume VNC is always available

Several tests assume that VNC is always available and include it in
their configs and the expected command line. The tests have nothing to
do with graphics display so they shouldn't rely on VNC.

12 years agostorage: let format probing work on root-squash NFS
Eric Blake [Sat, 20 Oct 2012 19:56:35 +0000 (13:56 -0600)]
storage: let format probing work on root-squash NFS

Yet another instance of where using plain open() mishandles files
that live on root-squash NFS, and where improving the API can
improve the chance of a successful probe.

* src/util/storage_file.h (virStorageFileProbeFormat): Alter
signature.
* src/util/storage_file.c (virStorageFileProbeFormat): Use better
method for opening file.
* src/qemu/qemu_driver.c (qemuDomainGetBlockInfo): Update caller.
* src/storage/storage_backend_fs.c (virStorageBackendProbeTarget):
Likewise.

12 years agovirsh: Fix segfault of snapshot-list
Osier Yang [Mon, 22 Oct 2012 14:28:59 +0000 (22:28 +0800)]
virsh: Fix segfault of snapshot-list

'snaps' is used after free()'ed.

12 years agomigrate: v2: use VIR_DOMAIN_XML_MIGRATABLE when available
Ján Tomko [Fri, 19 Oct 2012 14:58:05 +0000 (16:58 +0200)]
migrate: v2: use VIR_DOMAIN_XML_MIGRATABLE when available

In v2 migration protocol, XML is obtained by calling domainGetXMLDesc.
This includes the default USB controller in XML, which breaks migration
to older libvirt (before 0.9.2).

Commit 409b5f549530e7b3a33f4505f2cad2e26896107c
    qemu: Emit compatible XML when migrating a domain
only fixed this for v3 migration.

This patch uses the new VIR_DOMAIN_XML_MIGRATABLE flag (detected by
VIR_DRV_FEATURE_XML_MIGRATABLE) to obtain XML without the default controller,
enabling backward v2 migration.

12 years agoqemu: set seamless migration capability
Michal Privoznik [Fri, 19 Oct 2012 06:45:04 +0000 (08:45 +0200)]
qemu: set seamless migration capability

As we switched to setting capabilities based on QMP communication,
qemu seamless-migration capability was not set. In the -help output
this knob is called seamless-migration=[on|off]. The equivalent in
QMP world is SPICE_MIGRATE_COMPLETED event (qemu upstream commit
2fdd16e2).

12 years agoqemu: Fix the unused parameter which causes the build failure
Osier Yang [Mon, 22 Oct 2012 07:51:13 +0000 (15:51 +0800)]
qemu: Fix the unused parameter which causes the build failure

12 years agoqemu: Cleanup the unused 'nodeinfo'
Osier Yang [Fri, 19 Oct 2012 04:09:20 +0000 (12:09 +0800)]
qemu: Cleanup the unused 'nodeinfo'

"nodeinfo" is not used in these two functions, and it's waste
of goto in qemuProcessSetEmulatorAffinites

12 years agodocs: virsh: clarify behavior of send-key
Cole Robinson [Sat, 20 Oct 2012 23:55:24 +0000 (19:55 -0400)]
docs: virsh: clarify behavior of send-key

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

12 years agoLog parameters passed to virFileMakePath
Cole Robinson [Sat, 20 Oct 2012 21:11:31 +0000 (17:11 -0400)]
Log parameters passed to virFileMakePath

12 years agoLog file name passed to virConfReadFile
Cole Robinson [Sat, 20 Oct 2012 19:40:41 +0000 (15:40 -0400)]
Log file name passed to virConfReadFile

12 years agodaemon: Avoid 'Could not find keytab file' in syslog
Cole Robinson [Sat, 20 Oct 2012 18:10:03 +0000 (14:10 -0400)]
daemon: Avoid 'Could not find keytab file' in syslog

On F17 at least, every time libvirtd starts we get this in syslog:

libvirtd: Could not find keytab file: /etc/libvirt/krb5.tab: No such file or directory

This comes from cyrus-sasl, and happens regardless of whether the
gssapi plugin is requested, which is what actually uses
/etc/libvirt/krb5.tab.

While cyrus-sasl shouldn't complain, we can easily make it shut up by
commenting out the keytab value by default.

Also update the keytab comment to the more modern one from qemu's
sasl config file.

12 years agonetwork: don't allow multiple default portgroups
Laine Stump [Sat, 20 Oct 2012 08:39:18 +0000 (04:39 -0400)]
network: don't allow multiple default portgroups

This resolves: https://bugzilla.redhat.com/show_bug.cgi?id=868483

virNetworkUpdate, virNetworkDefine, and virNetworkCreate all three
allow network definitions to contain multiple <portgroup> elements
with default='yes'. Only a single default portgroup should be allowed
for each network.

This patch updates networkValidate() (called by both
virNetworkCreate() and virNetworkDefine()) and
virNetworkDefUpdatePortGroup (called by virNetworkUpdate() to not
allow multiple default portgroups.

12 years agonetwork: always create dnsmasq hosts and addnhosts files, even if empty
Laine Stump [Fri, 19 Oct 2012 20:15:44 +0000 (16:15 -0400)]
network: always create dnsmasq hosts and addnhosts files, even if empty

This fixes the problem reported in:

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

Previously, the dnsmasq hosts file (used for static dhcp entries, and
addnhosts file (used for additional dns host entries) were only
created/referenced on the dnsmasq commandline if there was something
to put in them at the time the network was started. Once we can update
a network definition while it's active (which is now possible with
virNetworkUpdate), this is no longer a valid strategy - if there were
0 dhcp static hosts (resulting in no reference to the hosts file on the
commandline), then one was later added, the commandline wouldn't have
linked dnsmasq up to the file, so even though we create it, dnsmasq
doesn't pay any attention.

The solution is to just always create these files and reference them
on the dnsmasq commandline (almost always, anyway). That way dnsmasq
can notice when a new entry is added at runtime (a SIGHUP is sent to
dnsmasq by virNetworkUdpate whenever a host entry is added or removed)

The exception to this is that the dhcp static hosts file isn't created
if there are no lease ranges *and* no static hosts. This is because in
this case dnsmasq won't be setup to listen for dhcp requests anyway -
in that case, if the count of dhcp hosts goes from 0 to 1, dnsmasq
will need to be restarted anyway (to get it listening on the dhcp
port). Likewise, if the dhcp hosts count goes from 1 to 0 (and there
are no dhcp ranges) we need to restart dnsmasq so that it will stop
listening on port 67. These special situations are handled in the
bridge driver's networkUpdate() by checking for ((bool)
nranges||nhosts) both before and after the update, and triggering a
dnsmasq restart if the before and after don't match.

12 years agonetwork: free/null newDef if network fails to start
Laine Stump [Fri, 19 Oct 2012 16:13:49 +0000 (12:13 -0400)]
network: free/null newDef if network fails to start

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

pointed out a crash due to virNetworkObjAssignDef free'ing
network->newDef without NULLing it afterward. A fix for this is in
upstream commit b7e9202401ebaa039b8f05acdefda8c24081537a. While the
NULLing of newDef was a legitimate fix, newDef should have already
been empty (NULL) anyway (as indicated in the comment that was deleted
by that commit).

The reason that newDef had a non-NULL value (i.e. the root cause) was
that networkStartNetwork() had failed after populating
network->newDef, but then neglected to free/NULL newDef in the
cleanup.

(A bit of background here: network->newDef should contain the
persistent config of a network when a network is active (and of course
only when it is persisten), and NULL at all other times. There is also
a network->def which should contain the persistent definition of the
network when it is inactive, and the current live state at all other
times. The idea is that you can make changes to network->newDef which
will take effect the next time the network is restarted, but won't
mess with the current state of the network (virDomainObj has a similar
pair of virDomainDefs that behave in the same fashion). Personally I
think there should be a network->live and network->config, and the
location of the persistent config should *always* be in
network->config, but that's for a later cleanup).

Since I love things to be symmetric, I created a new function called
virNetworkObjUnsetDefTransient(), which reverses the effects of
virNetworkObjSetDefTransient(). I don't really like the name of the
new function, but then I also didn't really like the name of the old
one either (it's just named that way to match a similar function in
the domain conf code).

12 years agoblockjob: avoid segv on early error
Eric Blake [Sat, 20 Oct 2012 03:13:37 +0000 (21:13 -0600)]
blockjob: avoid segv on early error

Gcc with optimization warns:
../../src/qemu/qemu_driver.c: In function 'qemuDomainBlockCommit':
../../src/qemu/qemu_driver.c:12813:46: error: 'disk' may be used uninitialized in this function [-Werror=maybe-uninitialized]
../../src/qemu/qemu_driver.c:12698:25: note: 'disk' was declared here
cc1: all warnings being treated as errors

so obviously I had only been testing with optimization off.

* src/qemu/qemu_driver.c (qemuDomainBlockCommit): Guard cleanup.

12 years agoblockjob: properly label disks for qemu block-commit
Eric Blake [Tue, 16 Oct 2012 14:46:41 +0000 (08:46 -0600)]
blockjob: properly label disks for qemu block-commit

I finally have all the pieces in place to perform a block-commit with
SELinux enforcing.  There's still missing cleanup work when the commit
completes, but doing that requires tracking both the backing chain and
the base and top files within that chain in domain XML across libvirtd
restarts.  Furthermore, from a security standpoint, once you have
granted access, you must assume any damage that can be done will be
done; later revoking access is nice to minimize the window of damage,
but less important as it does not affect the fact that damage can be
done in the first place.  Therefore, deferring the revoke efforts until
we have better XML tracking of what chain operations are in effect,
including across a libvirtd restart, is reasonable.

* src/qemu/qemu_driver.c (qemuDomainBlockCommit): Label disks as
needed.
(qemuDomainPrepareDiskChainElement): Cast away const.

12 years agoblockjob: refactor qemu disk chain permission grants
Eric Blake [Wed, 17 Oct 2012 21:48:14 +0000 (15:48 -0600)]
blockjob: refactor qemu disk chain permission grants

Previously, snapshot code did its own permission granting (lock
manager, cgroup device controller, and security manager labeling)
inline.  But now that we are adding block-commit and block-copy
which also have to change permissions, it's better to reuse
common code for the task.  While snapshot should fall back to
no access if read-write access failed, block-commit will want to
fall back to read-only access.  The common code doesn't know
whether failure to grant read-write access should revert to no
access (snapshot, block-copy) or read-only access (block-commit).
This code can also be used to revoke access to unused files after
block-pull.

It might be nice to clean things up in a future patch by adding
new functions to the lock manager, cgroup manager, and security
manager that takes a single file name and applies context of a
disk to that file, rather than the current semantics of applying
context to the entire chain already associated to a disk.  That
way, we could avoid the games this patch plays of temporarily
swapping out the disk->src and related fields of the disk.  But
that would involve more code changes, so this patch really is
the smallest hack for doing the necessary work; besides, this
patch is more or less code motion (the hack was already employed
by the snapshot creation code, we are just making it reusable).

* src/qemu/qemu_driver.c (qemuDomainSnapshotCreateSingleDiskActive)
(qemuDomainSnapshotUndoSingleDiskActive): Refactor labeling hacks...
(qemuDomainPrepareDiskChainElement): ...into new function.

12 years agoblockjob: implement shallow commit flag in qemu
Eric Blake [Sat, 13 Oct 2012 13:12:31 +0000 (07:12 -0600)]
blockjob: implement shallow commit flag in qemu

Now that we can crawl the chain of backing files, we can do
argument validation and implement the 'shallow' flag.  In
testing this, I discovered that it can be handy to pass the
shallow flag and an explicit base, as a means of validating
that the base is indeed the file we expected.

* src/qemu/qemu_driver.c (qemuDomainBlockCommit): Crawl through
chain to implement shallow flag.
* src/libvirt.c (virDomainBlockCommit): Relax API.

12 years agoblockjob: wire up online qemu block-commit
Eric Blake [Wed, 3 Oct 2012 18:54:09 +0000 (12:54 -0600)]
blockjob: wire up online qemu block-commit

This is the bare minimum to kick off a block commit.  In particular,
flags support is missing (shallow requires us to crawl the backing
chain to determine the file name to pass to the qemu monitor command;
delete requires us to track what needs to be deleted at the time
the completion event fires).  Also, we are relying on qemu to do
error checking (such as validating 'top' and 'base' as being members
of the backing chain), including the fact that the current qemu code
does not support committing the active layer (although it is still
planned to add that before qemu 1.3).  Since the active layer won't
change, we have it easy and do not have to alter the domain XML.
Additionally, this will fail if SELinux is enforcing, because we fail
to grant qemu proper read/write access to the files it will modify.

* src/qemu/qemu_driver.c (qemuDomainBlockCommit): New function.
(qemuDriver): Register it.

12 years agoblockjob: manage qemu block-commit monitor command
Eric Blake [Wed, 3 Oct 2012 21:13:21 +0000 (15:13 -0600)]
blockjob: manage qemu block-commit monitor command

qemu 1.3 will be adding a 'block-commit' monitor command, per
qemu.git commit ed61fc1.  It matches nicely to the libvirt API
virDomainBlockCommit.

* src/qemu/qemu_capabilities.h (QEMU_CAPS_BLOCK_COMMIT): New bit.
* src/qemu/qemu_capabilities.c (qemuCapsProbeQMPCommands): Set it.
* src/qemu/qemu_monitor.h (qemuMonitorBlockCommit): New prototype.
* src/qemu/qemu_monitor_json.h (qemuMonitorJSONBlockCommit):
Likewise.
* src/qemu/qemu_monitor.c (qemuMonitorBlockCommit): Implement it.
* src/qemu/qemu_monitor_json.c (qemuMonitorJSONBlockCommit):
Likewise.
(qemuMonitorJSONHandleBlockJobImpl)
(qemuMonitorJSONGetBlockJobInfoOne): Handle new event type.

12 years agoblockjob: remove unused parameters after previous patch
Eric Blake [Wed, 17 Oct 2012 20:22:24 +0000 (14:22 -0600)]
blockjob: remove unused parameters after previous patch

Minor cleanup made possible by previous simplifications.

* src/qemu/qemu_cgroup.h (qemuSetupDiskCgroup)
(qemuTeardownDiskCgroup): Alter signature.
* src/qemu/qemu_cgroup.c (qemuSetupDiskCgroup)
(qemuTeardownDiskCgroup, qemuSetupCgroup): Update all uses.
* src/qemu/qemu_hotplug.c (qemuDomainDetachPciDiskDevice)
(qemuDomainDetachDiskDevice): Likewise.
* src/qemu/qemu_driver.c (qemuDomainAttachDeviceDiskLive)
(qemuDomainChangeDiskMediaLive)
(qemuDomainSnapshotCreateSingleDiskActive)
(qemuDomainSnapshotUndoSingleDiskActive): Likewise.

12 years agostorage: use cache to walk backing chain
Eric Blake [Tue, 9 Oct 2012 22:08:14 +0000 (16:08 -0600)]
storage: use cache to walk backing chain

We used to walk the backing file chain at least twice per disk,
once to set up cgroup device whitelisting, and once to set up
security labeling.  Rather than walk the chain every iteration,
which possibly includes calls to fork() in order to open root-squashed
NFS files, we can exploit the cache of the previous patch.

* src/conf/domain_conf.h (virDomainDiskDefForeachPath): Alter
signature.
* src/conf/domain_conf.c (virDomainDiskDefForeachPath): Require caller
to supply backing chain via disk, if recursion is desired.
* src/security/security_dac.c
(virSecurityDACSetSecurityImageLabel): Adjust caller.
* src/security/security_selinux.c
(virSecuritySELinuxSetSecurityImageLabel): Likewise.
* src/security/virt-aa-helper.c (get_files): Likewise.
* src/qemu/qemu_cgroup.c (qemuSetupDiskCgroup)
(qemuTeardownDiskCgroup): Likewise.
(qemuSetupCgroup): Pre-populate chain.

12 years agostorage: cache backing chain while qemu domain is live
Eric Blake [Tue, 9 Oct 2012 22:08:14 +0000 (16:08 -0600)]
storage: cache backing chain while qemu domain is live

Technically, we should not be re-probing any file that qemu might
be currently writing to.  As such, we should cache the backing
file chain prior to starting qemu.  This patch adds the cache,
but does not use it until the next patch.

Ultimately, we want to also store the chain in domain XML, so that
it is remembered across libvirtd restarts, and so that the only
kosher way to modify the backing chain of an offline domain will be
through libvirt API calls, but we aren't there yet.  So for now, we
merely invalidate the cache any time we do a live operation that
alters the chain (block-pull, block-commit, external disk snapshot),
as well as tear down the cache when the domain is not running.

* src/conf/domain_conf.h (_virDomainDiskDef): New field.
* src/conf/domain_conf.c (virDomainDiskDefFree): Clean new field.
* src/qemu/qemu_domain.h (qemuDomainDetermineDiskChain): New
prototype.
* src/qemu/qemu_domain.c (qemuDomainDetermineDiskChain): New
function.
* src/qemu/qemu_driver.c (qemuDomainAttachDeviceDiskLive)
(qemuDomainChangeDiskMediaLive): Pre-populate chain.
(qemuDomainSnapshotCreateSingleDiskActive): Uncache chain before
snapshot.
* src/qemu/qemu_process.c (qemuProcessHandleBlockJob): Update
chain after block pull.

12 years agostorage: make it easier to find file within chain
Eric Blake [Fri, 12 Oct 2012 22:29:14 +0000 (16:29 -0600)]
storage: make it easier to find file within chain

In order to temporarily label files read/write during a commit
operation, we need to crawl the backing chain and find the absolute
file name that needs labeling in the first place, as well as the
name of the file that owns the backing file.

* src/util/storage_file.c (virStorageFileChainLookup): New
function.
* src/util/storage_file.h: Declare it.
* src/libvirt_private.syms (storage_file.h): Export it.

12 years agostorage: remember relative names in backing chain
Eric Blake [Tue, 9 Oct 2012 23:47:42 +0000 (17:47 -0600)]
storage: remember relative names in backing chain

In order to search for a backing file name as literally present
in a chain, we need to remember if the chain had relative names.
Also, searching for absolute names is easier if we only have
to canonicalize once, rather than on every iteration.

* src/util/storage_file.h (_virStorageFileMetadata): Add field.
* src/util/storage_file.c (virStorageFileGetMetadataFromBuf):
(virStorageFileFreeMetadata): Manage it
(absolutePathFromBaseFile): Store absolute names in canonical form.

12 years agostorage: don't require caller to pre-allocate metadata struct
Eric Blake [Sat, 13 Oct 2012 17:01:27 +0000 (11:01 -0600)]
storage: don't require caller to pre-allocate metadata struct

Requiring pre-allocation was an unusual idiom.  It allowed iteration
over the backing chain to use fewer mallocs, but made one-shot
clients harder to read.  Also, this makes it easier for a future
patch to move away from opening fds on every iteration over the chain.

* src/util/storage_file.h (virStorageFileGetMetadataFromFD): Alter
signature.
* src/util/storage_file.c (virStorageFileGetMetadataFromFD): Allocate
return value.
 (virStorageFileGetMetadata): Update clients.
* src/conf/domain_conf.c (virDomainDiskDefForeachPath): Likewise.
* src/qemu/qemu_driver.c (qemuDomainGetBlockInfo): Likewise.
* src/storage/storage_backend_fs.c (virStorageBackendProbeTarget):
Likewise.

12 years agostorage: get entire metadata chain in one call
Eric Blake [Sat, 13 Oct 2012 16:47:15 +0000 (10:47 -0600)]
storage: get entire metadata chain in one call

Previously, no one was using virStorageFileGetMetadata, and for good
reason - it couldn't support root-squash NFS.  Change the signature
and make it useful to future patches, including enhancing the metadata
to recursively track the entire chain.

* src/util/storage_file.h (_virStorageFileMetadata): Add field.
(virStorageFileGetMetadata): Alter signature.
* src/util/storage_file.c (virStorageFileGetMetadata): Rewrite.
(virStorageFileGetMetadataRecurse): New function.
(virStorageFileFreeMetadata): Handle recursion.

12 years agostorage: don't probe non-files
Eric Blake [Tue, 9 Oct 2012 23:50:14 +0000 (17:50 -0600)]
storage: don't probe non-files

Backing chains can end on a network protocol, such as nbd:xxx; we
should not attempt to probe the file system in this case.

* src/storage/storage_backend_fs.c (virStorageBackendProbeTarget):
Only probe files.

12 years agostorage: use enum for snapshot driver type
Eric Blake [Tue, 2 Oct 2012 16:57:06 +0000 (10:57 -0600)]
storage: use enum for snapshot driver type

This is the last use of raw strings for disk formats throughout
the src/conf directory.

* src/conf/snapshot_conf.h (_virDomainSnapshotDiskDef): Store enum
rather than string for disk type.
* src/conf/snapshot_conf.c (virDomainSnapshotDiskDefClear)
(virDomainSnapshotDiskDefParseXML, virDomainSnapshotDefFormat):
Adjust users.
* src/qemu/qemu_driver.c (qemuDomainSnapshotDiskPrepare)
(qemuDomainSnapshotCreateSingleDiskActive): Likewise.

12 years agostorage: use enum for disk driver type
Eric Blake [Mon, 15 Oct 2012 21:47:42 +0000 (15:47 -0600)]
storage: use enum for disk driver type

Actually use the enum in the domain conf structure.

* src/conf/domain_conf.h (_virDomainDiskDef): Store enum rather
than string for disk type.
* src/conf/domain_conf.c (virDomainDiskDefFree)
(virDomainDiskDefParseXML, virDomainDiskDefFormat)
(virDomainDiskDefForeachPath): Adjust users.
* src/xenxs/xen_sxpr.c (xenParseSxprDisks, xenFormatSxprDisk):
Likewise.
* src/xenxs/xen_xm.c (xenParseXM, xenFormatXMDisk): Likewise.
* src/vbox/vbox_tmpl.c (vboxAttachDrives): Likewise.
* src/libxl/libxl_conf.c (libxlMakeDisk): Likewise.

12 years agostorage: use enum for default driver type
Eric Blake [Fri, 28 Sep 2012 21:06:33 +0000 (15:06 -0600)]
storage: use enum for default driver type

Express the default disk type as an enum, for easier handling.

* src/conf/capabilities.h (_virCaps): Store enum rather than
string for disk type.
* src/conf/domain_conf.c (virDomainDiskDefParseXML): Adjust
clients.
* src/qemu/qemu_driver.c (qemuCreateCapabilities): Likewise.

12 years agostorage: match RNG to supported driver types
Eric Blake [Fri, 28 Sep 2012 18:57:54 +0000 (12:57 -0600)]
storage: match RNG to supported driver types

At one point, the code passed through arbitrary strings for file
formats, which supposedly lets qemu handle a new file type even
before libvirt has been taught to handle it.  However, to properly
label files, libvirt has to learn the file type anyway, so we
might as well make our life easier by only accepting file types
that we are prepared to handle.  This patch lets the RNG validation
ensure that only known strings are let through.

* docs/schemas/domaincommon.rng (driverFormat): Limit to list of
supported strings.
* docs/schemas/domainsnapshot.rng (driver): Likewise.

12 years agostorage: treat 'aio' like 'raw' at parse time
Eric Blake [Fri, 28 Sep 2012 23:48:58 +0000 (17:48 -0600)]
storage: treat 'aio' like 'raw' at parse time

We have historically allowed 'aio' as a synonym for 'raw' for
back-compat to xen, but since a future patch will move to using
an enum value, we have to pick one to be our preferred output
name.  This is a slight change in the output XML, but the sexpr
and xm outputs should still be identical, and the input XML can
still use either form.

* src/conf/domain_conf.c (virDomainDiskDefForeachPath): Move aio
back-compat...
(virDomainDiskDefParseXML): ...to parse time.
* src/xenxs/xen_sxpr.c (xenParseSxprDisks, xenFormatSxprDisk): ...and
to output time.
* src/xenxs/xen_xm.c (xenParseXM, xenFormatXMDisk): Likewise.
* tests/sexpr2xmldata/sexpr2xml-*.xml: Update tests.

12 years agostorage: list more file types
Eric Blake [Fri, 28 Sep 2012 17:11:07 +0000 (11:11 -0600)]
storage: list more file types

When an image has no backing file, using VIR_STORAGE_FILE_AUTO
for its type is a bit confusing.  Additionally, a future patch
would like to reserve a default value for the case of no file
type specified in the XML, but different from the current use
of -1 to imply probing, since probing is not always safe.

Also, a couple of file types were missing compared to supported
code: libxl supports 'vhd', and qemu supports 'fat' for directories
passed through as a file system.

* src/util/storage_file.h (virStorageFileFormat): Add
VIR_STORAGE_FILE_NONE, VIR_STORAGE_FILE_FAT, VIR_STORAGE_FILE_VHD.
* src/util/storage_file.c (virStorageFileMatchesVersion): Match
documentation when version probing not supported.
(cowGetBackingStore, qcowXGetBackingStore, qcow1GetBackingStore)
(qcow2GetBackingStoreFormat, qedGetBackingStore)
(virStorageFileGetMetadataFromBuf)
(virStorageFileGetMetadataFromFD): Take NONE into account.
* src/conf/domain_conf.c (virDomainDiskDefForeachPath): Likewise.
* src/qemu/qemu_driver.c (qemuDomainGetBlockInfo): Likewise.
* src/conf/storage_conf.c (virStorageVolumeFormatFromString): New
function.
(poolTypeInfo): Use it.

12 years agoAutogenerate AUTHORS
Cole Robinson [Fri, 12 Oct 2012 23:50:19 +0000 (19:50 -0400)]
Autogenerate AUTHORS

AUTHORS.in tracks the maintainers, as well as some folks who were
previously in AUTHORS but don't have a git commit with proper
attribution.

Generated output is sorted alphabetically and lacks pretty spacing, so
tweak AUTHORS.in to follow the same format.

Additionally, drop the syntax-check rule that previously validated
AUTHORS against git log.

12 years agoselinux: relabel tapfd in qemuPhysIfaceConnect
Guannan Ren [Fri, 19 Oct 2012 08:44:30 +0000 (16:44 +0800)]
selinux: relabel tapfd in qemuPhysIfaceConnect

Relabeling tapfd right after the tap device is created.
qemuPhysIfaceConnect is common function called both for static
netdevs and for hotplug netdevs.

12 years agoqemu: Do not require hostuuid in migration cookie
Jiri Denemark [Fri, 19 Oct 2012 13:08:29 +0000 (15:08 +0200)]
qemu: Do not require hostuuid in migration cookie

Having hostuuid in migration cookie is a nice bonus since it provides an
easy way of detecting migration to the same host. However, requiring it
breaks backward compatibility with older libvirt releases.

12 years agoqemu: Allow migration with host USB devices
Jiri Denemark [Fri, 19 Oct 2012 11:36:33 +0000 (13:36 +0200)]
qemu: Allow migration with host USB devices

Recently, patches were added support for (managed)saving, restoring, and
migrating domains with host USB devices. However, qemu driver would
still forbid migration of such domains because qemuMigrationIsAllowed
was not updated.

12 years agoqemu: Set arch to i686 if qemu-system-i386 is found
Guido Günther [Thu, 18 Oct 2012 23:14:15 +0000 (01:14 +0200)]
qemu: Set arch to i686 if qemu-system-i386 is found

If we can't probe the architecture from QMP we parse the architecture
from the qemu binaries name. This results in the architecture being i386
instead of i686 which then results in QEMU_CAPS_PCI_MULTIBUS being unset
which gives a broken qemu command line.

This probably didn't show up earlier since most of the time there's also
a /usr/bin/qemu around which results in i686 capabilities.

12 years agoqemu: Don't fail without emulatorpin or cpumask
Guido Günther [Thu, 18 Oct 2012 22:29:17 +0000 (00:29 +0200)]
qemu: Don't fail without emulatorpin or cpumask

This unbreaks qemu:///session that got broken by
ba63d8f7d843461f77a8206c1ef9da38388713e5.

12 years agonetwork: Set to NULL after virNetworkDefFree()
Michal Privoznik [Thu, 18 Oct 2012 14:28:35 +0000 (16:28 +0200)]
network: Set to NULL after virNetworkDefFree()

which frees all allocated memory but doesn't set the passed pointer to
NULL.  Therefore, we must do it ourselves. This is causing actual
libvirtd crash: Basically, when doing 'virsh net-edit' the newDef should
be dropped.  And the memory is freed, indeed. However, the pointer is
not set to NULL but kept instead. And the next duo of calls 'virsh
net-start' and 'virsh net-destroy' starts the disaster. The latter one
does the same as 'virsh destroy'; it sees that newDef is nonNULL so it
replaces def with newDef (which has been freed already as said a few
lines above). Therefore any subsequent call accessing def will hit the ground.

12 years agodist: added cpu/cpu_ppc_data.h to Makefile.am
Viktor Mihajlovski [Thu, 18 Oct 2012 14:28:04 +0000 (16:28 +0200)]
dist: added cpu/cpu_ppc_data.h to Makefile.am

Missing entry for cpu_ppc_data.h added to fix RPM build.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
12 years agoqemu: Always format CPU topology
Jiri Denemark [Tue, 16 Oct 2012 19:11:29 +0000 (21:11 +0200)]
qemu: Always format CPU topology

When libvirt cannot find a suitable CPU model for host CPU (easily
reproducible by running libvirt in a guest), it would not provide CPU
topology in capabilities XML either. Even though CPU topology is known
and can be queried by virNodeGetInfo. With this patch, CPU topology will
always be provided in capabilities XML regardless on the presence of CPU
model.

12 years agospec: Fix dependency for lock-sanlock subpackage
Jiri Denemark [Thu, 18 Oct 2012 11:03:26 +0000 (13:03 +0200)]
spec: Fix dependency for lock-sanlock subpackage

This should not make a big difference in real world since libvirt-daemon,
which is already required by libvirt-lock-sanlock, requires
libvirt-client and thus libvirt-lock-sanlock gets this dependency
transitively. However, since libvirt-lock-sanlock contains
sanlock_helper binary linked to libvirt.so, we should start requiring
libvirt-client directly.

12 years agoqemu: Add support for HyperV Enlightenment feature "relaxed"
Peter Krempa [Wed, 17 Oct 2012 12:55:18 +0000 (14:55 +0200)]
qemu: Add support for HyperV Enlightenment feature "relaxed"

This patch adds QEMU support for the "relaxed" feature implemented by
previous patch.

12 years agoconf: Add support for HyperV Enlightenment features
Peter Krempa [Tue, 16 Oct 2012 16:25:56 +0000 (18:25 +0200)]
conf: Add support for HyperV Enlightenment features

Hypervisors are starting to support HyperV Enlightenment features that
improve behavior of guests running Microsoft Windows operating systems.

This patch adds support for the "relaxed" feature that improves timer
behavior and also establishes a framework to add these features in
future.

12 years agoconf: Make tri-state feature options more universal
Peter Krempa [Tue, 16 Oct 2012 14:28:22 +0000 (16:28 +0200)]
conf: Make tri-state feature options more universal

The apic-eoi feature enum and implementation can be made more universal
to allow re-use of the enum for other features.

12 years agoqemu: Correctly wait for spice to migrate
Michal Privoznik [Thu, 18 Oct 2012 07:38:41 +0000 (09:38 +0200)]
qemu: Correctly wait for spice to migrate

Currently we query-spice after the main migration has completed
before moving to next state. Qemu reports this as boolean (not
enclosed within quotes). Therefore it is not correct to use
virJSONValueObjectGetString but virJSONValueObjectGetBoolean instead.

12 years agoqemu: Fixed default machine detection in qemuCapsParseMachineTypesStr
Viktor Mihajlovski [Wed, 17 Oct 2012 14:48:42 +0000 (16:48 +0200)]
qemu: Fixed default machine detection in qemuCapsParseMachineTypesStr

The machine in the last output line of <qemu-binary> -M ?
was always reported as default machine even if this wasn't the
actual default. Trivial fix.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
12 years agoqemu: Pin the emulator when only cpuset is specified
Martin Kletzander [Wed, 17 Oct 2012 14:39:31 +0000 (16:39 +0200)]
qemu: Pin the emulator when only cpuset is specified

According to our recent changes (clarifications), we should be pinning
qemu's emulator processes using the <vcpu> 'cpuset' attribute in case
there is no <emulatorpin> specified.  This however doesn't work
entirely as expected and this patch should resolve all the remaining
issues.

12 years agoqemu: Clear async job when p2p migration fails early
Jiri Denemark [Wed, 17 Oct 2012 12:08:17 +0000 (14:08 +0200)]
qemu: Clear async job when p2p migration fails early

When p2p migration fails early because qemuMigrationIsAllowed or
qemuMigrationIsSafe say migration should be cancelled, we fail to clear
the migration-out async job. As a result of that, further APIs called
for the same domain may fail with Timed out during operation: cannot
acquire state change lock.

Reported by Guido Winkelmann.

12 years agointerface: add virInterfaceGetXMLDesc() in udev
Doug Goldstein [Sun, 14 Oct 2012 22:02:33 +0000 (17:02 -0500)]
interface: add virInterfaceGetXMLDesc() in udev

Added support for retrieving the XML defining a specific interface via
the udev based backend to virInterface. Implement the following APIs
for the udev based backend:
* virInterfaceGetXMLDesc()

Note: Does not support bond devices.

12 years agoAUTHORS: Remove double entry
Michal Privoznik [Wed, 17 Oct 2012 09:53:13 +0000 (11:53 +0200)]
AUTHORS: Remove double entry

I've accidentally added Li Zhang <zhlcindy@linux.vnet.ibm.com> to
AUTHORS, even if he already was there.

12 years agoDoc-fix for PowerPC CPU model driver
Li Zhang [Mon, 15 Oct 2012 09:07:51 +0000 (17:07 +0800)]
Doc-fix for PowerPC CPU model driver

There are some descriptions not right in PowerPC CPU model driver.
This patch is to fix them.

Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com>
Acked-by: Michal Privoznik <mprivozn@redhat.com>
12 years agoImplement CPU model driver for PowerPC
Li Zhang [Mon, 15 Oct 2012 09:07:50 +0000 (17:07 +0800)]
Implement CPU model driver for PowerPC

Currently, the CPU model driver is not implemented for PowerPC.
Host's CPU information is needed to exposed to guests' XML file some
time.

This patch is to implement the callback functions of CPU model driver.

Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com>
Acked-by: Michal Privoznik <mprivozn@redhat.com>
12 years agoAdd one file cpu_ppc_data.h to define CPU data for PPC
Li Zhang [Mon, 15 Oct 2012 09:07:49 +0000 (17:07 +0800)]
Add one file cpu_ppc_data.h to define CPU data for PPC

CPU version can be got by PVR on PowerPC. So this PVR is defined in
the CPU data in cpuData structure.

Signed-off-by: Li Zhang <zhlcindy@linux.vnet.ibm.com>
Acked-by: Michal Privoznik <mprivozn@redhat.com>
12 years agoselinux: remove unused variables in socket labelling
Guannan Ren [Wed, 17 Oct 2012 03:28:28 +0000 (11:28 +0800)]
selinux: remove unused variables in socket labelling

12 years agoselinux: fix wrong tapfd relablling
Guannan Ren [Wed, 17 Oct 2012 03:23:19 +0000 (11:23 +0800)]
selinux: fix wrong tapfd relablling

It should relabel tapfd of virtual network of type VIR_DOMAIN_NET_TYPE_DIRECT
rather than VIR_DOMAIN_NET_TYPE_NETWORK and VIR_DOMAIN_NET_TYPE_BRIDGE
(commit ae368ebfcc4923d0b32e83d4ca96a6f599625785 introduced this bug)

Caution: The context of the two hunks is identical other than indentation.
Please be extremely cautious of where the patch gets applied.

12 years agostorage: lvm: lvcreate fails with allocation=0, don't do that
Cole Robinson [Wed, 17 Oct 2012 00:30:23 +0000 (20:30 -0400)]
storage: lvm: lvcreate fails with allocation=0, don't do that

On F17 at least, this command fails:

$ sudo /usr/sbin/lvcreate --name sparsetest -L 0K --virtualsize 16384K vgvirt
  Unable to create new logical volume with no extents

Which is unfortunate since allocation=0 is what virt-manager tries to use
by default.

Rather than telling the user 'don't do that', let's just give them the
smallest allocation possible if alloc=0 is requested.

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

12 years agostorage: lvm: Don't overwrite lvcreate errors
Cole Robinson [Wed, 17 Oct 2012 00:25:41 +0000 (20:25 -0400)]
storage: lvm: Don't overwrite lvcreate errors

Before:
$ sudo virsh vol-create-as --pool vgvirt sparsetest --capacity 16M --allocation 0
error: Failed to create vol sparsetest
error: internal error Child process (/usr/sbin/lvchange -aln vgvirt/sparsetest) unexpected exit status 5:   One or more specified logical volume(s) not found.

After:
$ sudo virsh vol-create-as --pool vgvirt sparsetest --capacity 16M --allocation 0
error: Failed to create vol sparsetest
error: internal error Child process (/usr/sbin/lvcreate --name sparsetest -L 0K --virtualsize 16384K vgvirt) unexpected exit status 5:   Unable to create new logical volume with no extents

12 years agospec: Require newer sanlock on recent distros 2
Jiri Denemark [Tue, 16 Oct 2012 21:54:18 +0000 (23:54 +0200)]
spec: Require newer sanlock on recent distros 2

The previous commit was incomplete. We need to also add explicit
Requires for the newer version since RPM's automatic dependencies won't
work with sanlock.