]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/log
people/liuw/libxenctrl-split/libvirt.git
12 years agoFix a crash when using Open vSwitch virtual ports
Kyle Mestery [Wed, 29 Aug 2012 18:44:36 +0000 (14:44 -0400)]
Fix a crash when using Open vSwitch virtual ports

Fixup buffer usage when handling VLANs. Also fix the logic
used to determine if the virNetDevVlanPtr is valid or not.
Fixes crashes in the latest code when using Open vSwitch
virtualports.

Signed-off-by: Kyle Mestery <kmestery@cisco.com>
12 years agoqemu: Sort the numa params only when it affects the live config
Osier Yang [Wed, 29 Aug 2012 06:46:06 +0000 (14:46 +0800)]
qemu: Sort the numa params only when it affects the live config

As the next boot doesn't have to worry about the previous numa
params setting (there is no).

12 years agoFix configuration of QEMU security drivers
Daniel P. Berrange [Thu, 30 Aug 2012 00:37:01 +0000 (01:37 +0100)]
Fix configuration of QEMU security drivers

If no 'security_driver' config option was set, then the code
just loaded the 'dac' security driver. This is a regression
on previous behaviour, where we would probe for a possible
security driver. ie default to SELinux if available.

This changes things so that it 'security_driver' is not set,
we once again do probing. For simplicity we also always
create the stack driver, even if there is only one driver
active.

The desired semantics are:

 - security_driver not set
     -> probe for selinux/apparmour/nop
     -> auto-add DAC driver
 - security_driver set to a string
     -> add that one driver
     -> auto-add DAC driver
 - security_driver set to a list
     -> add all drivers in list
     -> auto-add DAC driver

It is not allowed, or possible to specify 'dac' in the
security_driver config param, since that is always
enabled.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoqemu: Refactor initialisation of security drivers.
Peter Krempa [Wed, 29 Aug 2012 12:19:39 +0000 (14:19 +0200)]
qemu: Refactor initialisation of security drivers.

The security driver loading code in qemu has a flaw that causes it to
register the DAC security driver twice. This causes problems (machines
unable to start) as the two DAC drivers clash together.

This patch refactors the code to allow loading the DAC driver even if
its specified in configuration (it can't be registered as a common
security driver), and does not add the driver twice.

12 years agoRevert "security: Add DAC to security_drivers"
Peter Krempa [Wed, 29 Aug 2012 12:29:43 +0000 (14:29 +0200)]
Revert "security: Add DAC to security_drivers"

This reverts commit 9f9b7b85c9b422e8f4e813f3920bf8f433246a4a.

The DAC security driver needs special handling and extra parameters and
can't just be added to regular security drivers.

12 years agoqemu: Fix starting domains with no cpu cgroup
Jiri Denemark [Wed, 29 Aug 2012 13:30:34 +0000 (15:30 +0200)]
qemu: Fix starting domains with no cpu cgroup

If cgroups are enabled in general but cpu cgroup is disabled in
qemu.conf or not mounted at all, libvirt would refuse to start any
domain even though scheduler parameters are not set in domain XML.

This patch makes cpu cgroup mandatory only for domains that actually
want to use it.

12 years agosecurity: remove dead code from virSecurityDACGenLabel
Alex Jia [Wed, 29 Aug 2012 10:00:51 +0000 (18:00 +0800)]
security: remove dead code from virSecurityDACGenLabel

* src/security/security_dac.c: remove useless dead code.

Signed-off-by: Alex Jia <ajia@redhat.com>
12 years agoRelease of libvirt-0.10.0
Daniel Veillard [Wed, 29 Aug 2012 03:57:02 +0000 (11:57 +0800)]
Release of libvirt-0.10.0

* configure.ac docs/news.html.in libvirt.spec.in: updates for the release
* po/*.po*: update localizations for zh_CN, uk, ja, pt_BR, as, sp, mr, zh_TW

12 years agonwfilter: Don't try to acquire DBus context when DBus is disabled
Peter Krempa [Tue, 28 Aug 2012 13:19:31 +0000 (15:19 +0200)]
nwfilter: Don't try to acquire DBus context when DBus is disabled

To silence error if DBus support is not compiled in.

12 years agoDon't require gawk for a simple print expression
Guido Günther [Tue, 28 Aug 2012 08:57:54 +0000 (10:57 +0200)]
Don't require gawk for a simple print expression

Fedora uses gawk as awk so there's no change and in behavior while
Debian/Ubuntu use mawk by default.

This was reported by Luca Capello in
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=636712

12 years agoutil: Prevent libvirtd crash from virNetDevOpenvswitchAddPort()
Alex Jia [Wed, 29 Aug 2012 02:56:04 +0000 (10:56 +0800)]
util: Prevent libvirtd crash from virNetDevOpenvswitchAddPort()

* src/util/virnetdevopenvswitch.c (virNetDevOpenvswitchAddPort): avoid libvirtd
crash due to derefing a NULL virtVlan->tag.

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

Signed-off-by: Alex Jia <ajia@redhat.com>
12 years agoqemu: Set placement when setting numa parameters
Osier Yang [Tue, 28 Aug 2012 12:13:31 +0000 (20:13 +0800)]
qemu: Set placement when setting numa parameters

To keep the internal data structure consistent.

12 years agoPortability fixes for non-linux or old linux platforms
Daniel Veillard [Wed, 29 Aug 2012 01:21:38 +0000 (09:21 +0800)]
Portability fixes for non-linux or old linux platforms

The commits d57567940153147f4d43875fb92c3030b3178b03 and
080bf330e3749d94ebe094f8deca0e3e67d3f2fe made use directly of
macro defined in recent linux netlink version. Make those
part conditional on the definition

* daemon/libvirtd.c: do not use NETLINK_ROUTE and NETLINK_KOBJECT_UEVENT
  without some check first

12 years agosecurity_dac: Don't return uninitialised uid and gid for image labels
Peter Krempa [Tue, 28 Aug 2012 23:15:04 +0000 (01:15 +0200)]
security_dac: Don't return uninitialised uid and gid for image labels

As in the previous commit, images are also chowned to uninitialised
uid and gid if the label is not present.

12 years agosecurity_dac: Don't return uninitialised value when parsing seclabels
Peter Krempa [Tue, 28 Aug 2012 16:29:38 +0000 (18:29 +0200)]
security_dac: Don't return uninitialised value when parsing seclabels

When starting a machine the DAC security driver tries to set the UID and
GID of the newly spawned process. This worked as desired if the desired
label was set. When the label was missing a logical bug in
virSecurityDACGenLabel() caused that uninitialised values were used as
uid and gid for the new process.

With this patch, default values (from qemu driver configuration)
are used if the label is not found.

12 years agosecurity_dac: Avoid segfault when no label is requested
Peter Krempa [Tue, 28 Aug 2012 16:27:31 +0000 (18:27 +0200)]
security_dac: Avoid segfault when no label is requested

When no DAC "label" was requested for a domain the DAC manager tried to
strdup a NULL string causing a segfault.

12 years agoutil: Fix error message when getpwuid_r fails to find the user
Peter Krempa [Tue, 28 Aug 2012 14:51:05 +0000 (16:51 +0200)]
util: Fix error message when getpwuid_r fails to find the user

getpwuid_r returns success but sets the return structure to NULL when it
fails to deliver data about the requested uid. In our helper code this
created following strange error messages:

" ... cannot getpwuid_r(1234): Success"

This patch creates a more helpful message:
" ... getpwuid_r failed to retrieve data for uid '1234'"

12 years agoconf: Fix the problem which cause libvirtd to crash
Osier Yang [Tue, 28 Aug 2012 11:31:56 +0000 (19:31 +0800)]
conf: Fix the problem which cause libvirtd to crash

* src/conf/domain_conf.c: Use STREQ_NULLABLE instead of STREQ,
as def->seclables[i]->model could be NULL.

12 years agobuild: define 'inline' iff HAVE_LIBNL1
Michal Privoznik [Tue, 28 Aug 2012 10:01:50 +0000 (12:01 +0200)]
build: define 'inline' iff HAVE_LIBNL1

Previous commit 0b4b53bb80 defined 'inline' to prevent broken build on
systems with libnl1 headers. However, it broke build on systems with
libnl3 headers. Therefore we must make that fix conditional.

12 years agodocs: CPU allocation and pinning clarification
Martin Kletzander [Mon, 27 Aug 2012 14:26:26 +0000 (16:26 +0200)]
docs: CPU allocation and pinning clarification

There was a request for clarifying this part of the
documentation. This also fixes a case used with CPU.

12 years agobuild: work with older libnl1 headers
Eric Blake [Mon, 27 Aug 2012 21:00:59 +0000 (15:00 -0600)]
build: work with older libnl1 headers

Ubuntu 10.04 shipped with out-of-the-box libnl1 headers, which
assumed the old gcc semantics of 'extern inline' as a C89 extension:
the function will _always_ be inline if it is used, and that
it may be declared extern inline in headers without a definition,
as long as the definition occurs before any use.  But when C99
added 'extern inline' as a mandatory feature of the language, with
slightly different semantics than gcc (the function MUST have
external linkage, and the inline definition MUST be present
alongside any declaration, where the compiler can then choose
which of the two versions to use), this rendered the use of
'inline' in libnl's header obsolete.  Most distros already solved
this by removing 'inline' (the resulting 'extern' is correct,
regardless of gcc semantics), and libnl-3 does not have the
problem (where it has switched to 'static inline' instead, again
with the definition present, and again, our hack will result in
plain 'static' with no ill effects).  But for the case of building
out of the box, we hack around the broken Ubuntu header.

* src/util/virnetlink.h: Work around libnl issue.

12 years agoqemu: Fix define logic
Michal Privoznik [Mon, 27 Aug 2012 15:40:33 +0000 (17:40 +0200)]
qemu: Fix define logic

With current flow in qemudDomainDefine we might lose data
when updating an existing domain. We parse given XML and
overwrite the configuration.  Then we try to save the new
config. However, this step may fail and we don't perform any
roll back.  In fact, we remove the domain from the list of
domains held up by qemu driver. This is okay as long as the
domain was brand new one.

12 years agoqemu_agent: Switch to virReportSystemError() on system error
Michal Privoznik [Mon, 27 Aug 2012 11:49:21 +0000 (13:49 +0200)]
qemu_agent: Switch to virReportSystemError() on system error

Currently, if a syscall in qemu_agent.c fails we report an internal
error even though we should be reporting a system error.

12 years agoIntroduce new VIR_ERR_AGENT_UNRESPONSIVE error code
Michal Privoznik [Mon, 27 Aug 2012 10:24:59 +0000 (12:24 +0200)]
Introduce new VIR_ERR_AGENT_UNRESPONSIVE error code

Currently, when guest agent is configured but not responsive
(e.g. due to appropriate service not running in the guest)
we return VIR_ERR_INTERNAL_ERROR. Both are wrong. Therefore
we need to introduce new error code to reflect this case.

12 years agoconf: prevent NULL pointer access in virSecurityLabelDefsParseXML
Ján Tomko [Mon, 27 Aug 2012 12:51:28 +0000 (14:51 +0200)]
conf: prevent NULL pointer access in virSecurityLabelDefsParseXML

When checking for seclabels without security models, def->nseclabels is
already set to n. In the case of an error def->seclabels is freed but
nseclabels is left untouched. This leads to a segmentation fault when
def is freed in virDomainDefParseXML.

12 years agoqemu: Switch to unified func name
Michal Privoznik [Mon, 27 Aug 2012 08:35:02 +0000 (10:35 +0200)]
qemu: Switch to unified func name

With the latest patches libvirt supports qemu agent monitor
passthrough. However, function in qemu driver is called
qemuDrvDomainAgentCommand. s/Drv// as used in all other names.

12 years agorpc: fix segmentation fault caused by null client-sock
Guannan Ren [Mon, 27 Aug 2012 08:59:25 +0000 (16:59 +0800)]
rpc: fix segmentation fault caused by null client-sock

The client-sock could have been set to NULL by eventloop thread
after async event fired.

12 years agoqemu: fix regression with spice tls port allocation
Martin Kletzander [Mon, 27 Aug 2012 07:41:36 +0000 (09:41 +0200)]
qemu: fix regression with spice tls port allocation

In my quest for reusing variables I failed to edit one variable when
fixing details between two patch versions. That results in a failure
to start qemu with autoport and spice tls, because qemu is trying to
bind two sockets to the same port.

12 years agoqemu: fix regression with pinning
Martin Kletzander [Fri, 24 Aug 2012 15:31:47 +0000 (17:31 +0200)]
qemu: fix regression with pinning

Commit 4b03d59167f4a4c6ec57def315a61d977466e75b changed the pinning
behavior in a way that makes some machines non-startable.

The comment mentioning that we cannot control each vcpu when there is
not VCPU<-> PID mapping available is true, however, this isn't
necessarily an error, because this can be caused by old QEMU without
support for "query-cpus" command as well as a software emulated
machines that don't create more than one process.

12 years agovirsh: fix missing return value
Alex Jia [Mon, 27 Aug 2012 05:58:46 +0000 (13:58 +0800)]
virsh: fix missing return value

Although virsh command raises a correct error information, the command status
returns 0(true), this patch is used for fixing this issue.

Signed-off-by: Alex Jia <ajia@redhat.com>
12 years agospecfile: require libnl3 for Fedora >= 18 and RHEL >= 7
Laine Stump [Fri, 24 Aug 2012 21:57:42 +0000 (17:57 -0400)]
specfile: require libnl3 for Fedora >= 18 and RHEL >= 7

Everything is ready in both netcf and libvirt to switch over to libnl3
in future releases of both Fedora and RHEL. This needs to be done more
or less simultaneously in both packages, though, because you can't mix
libnl1.1 and libnl3 in the same process (e.g. libvirtd using
libnl-3.so and libnetcf.so, while libnetcf.so uses libnl.so)

This patch does two things when fedora >= 18 || rhel >= 7):

  1) requires libnl3-devel
  2) requires netcf-devel-0.2.2 or greater

(the idea is that a similar patch is going into netcf's specfile, so
that when a build of netcf is done on F18 or later (or RHEL7 or later)
netcf will be guaranteed to be built with libnl3 rather than
libnl-1.1)

12 years agobuild: add LIBNL_CFLAGS to build of libvirt_lxc
Laine Stump [Sat, 25 Aug 2012 18:09:55 +0000 (14:09 -0400)]
build: add LIBNL_CFLAGS to build of libvirt_lxc

When libvirt_lxc is built, it uses the utility library and #includes
virnetdev.h, which #includes virnetlink.h, which includes
<netlink/msg.h>.

Normally, the netlink include directory would be just off
/usr/include, so that wouldn't create a problem, but on Fedora and
RHEL systems using libnl3, the libnl includes have been moved into
/usr/include/libnl3 (to allow concurrent installation of libnl-1.1).

All other binaries that need it have added $(LIBNL_CFLAGS) to their
CFLAGS, but not libvirt_lxc, so it fails to build on Fedora and RHEL
that have only libnl3-devel installed. This was previously unnoticed
because everyone was building with libnl headers in
/usr/include/netlink (even on systems with the headers in
/usr/include/libnl3/netlink, many people (like me) usually also have
the libnl1.1 headers in /usr/include/netlink).

This patch adds the necessary CFLAGS for libvirt_lxc.

Note that we don't need to add $(LIBNL_LIBS) to the LDADD for this
binary, because it never directly calls libnl functions, but only
calls them indirectly through the util library, which it's already
linking against.

12 years agosnapshot: rename an enum
Eric Blake [Mon, 13 Aug 2012 22:59:57 +0000 (16:59 -0600)]
snapshot: rename an enum

The name 'virDomainDiskSnapshot' didn't fit in with our normal
conventions of using a prefix hinting that it is related to a
virDomainSnapshotPtr.  Also, a future patch will reuse the
enum for declaring where the VM memory is stored.

* src/conf/snapshot_conf.h (virDomainDiskSnapshot): Rename...
(virDomainSnapshotLocation): ...to this.
(_virDomainSnapshotDiskDef): Update clients.
* src/conf/domain_conf.h (_virDomainDiskDef): Likewise.
* src/libvirt_private.syms (domain_conf.h): Likewise.
* src/conf/domain_conf.c (virDomainDiskDefParseXML)
(virDomainDiskDefFormat): Likewise.
* src/conf/snapshot_conf.c: (virDomainSnapshotDiskDefParseXML)
(virDomainSnapshotAlignDisks, virDomainSnapshotDefFormat):
Likewise.
* src/qemu/qemu_driver.c (qemuDomainSnapshotDiskPrepare)
(qemuDomainSnapshotCreateSingleDiskActive)
(qemuDomainSnapshotCreateDiskActive, qemuDomainSnapshotCreateXML):
Likewise.

12 years agosnapshot: split snapshot conf code into own file
Eric Blake [Tue, 14 Aug 2012 00:09:12 +0000 (18:09 -0600)]
snapshot: split snapshot conf code into own file

This has several benefits:
1. Future snapshot-related code has a definite place to go (and I
_will_ be adding some)
2. Snapshot errors now use the VIR_FROM_DOMAIN_SNAPSHOT error
classification, which has been underutilized (previously only in
libvirt.c)

* src/conf/domain_conf.h, domain_conf.c: Split...
* src/conf/snapshot_conf.h, snapshot_conf.c: ...into new files.
* src/Makefile.am (DOMAIN_CONF_SOURCES): Build new files.
* po/POTFILES.in: Mark new file for translation.
* src/vbox/vbox_tmpl.c: Update caller.
* src/esx/esx_driver.c: Likewise.
* src/qemu/qemu_command.c: Likewise.
* src/qemu/qemu_domain.h: Likewise.

12 years agosnapshot: make virDomainSnapshotObjList opaque
Eric Blake [Tue, 14 Aug 2012 06:22:39 +0000 (00:22 -0600)]
snapshot: make virDomainSnapshotObjList opaque

We were failing to react to allocation failure when initializing
a snapshot object list.  Changing things to store a pointer
instead of a complete object adds one more possible point of
allocation failure, but at the same time, will make it easier to
react to failure now, as well as making it easier for a future
patch to split all virDomainSnapshotPtr handling into a separate
file, as I continue to add even more snapshot code.

Luckily, there was only one client outside of domain_conf.c that
was actually peeking inside the object, and a new wrapper function
was easy.

* src/conf/domain_conf.h (_virDomainObj): Use a pointer.
(virDomainSnapshotObjListInit): Rename.
(virDomainSnapshotObjListFree, virDomainSnapshotForEach): New
declarations.
(_virDomainSnapshotObjList): Move definitions...
* src/conf/domain_conf.c: ...here.
(virDomainSnapshotObjListInit, virDomainSnapshotObjListDeinit):
Rename...
(virDomainSnapshotObjListNew, virDomainSnapshotObjListFree): ...to
these.
(virDomainSnapshotForEach): New function.
(virDomainObjDispose, virDomainListPopulate): Adjust callers.
* src/qemu/qemu_domain.c (qemuDomainSnapshotDiscard)
(qemuDomainSnapshotDiscardAllMetadata): Likewise.
* src/qemu/qemu_migration.c (qemuMigrationIsAllowed): Likewise.
* src/qemu/qemu_driver.c (qemuDomainSnapshotLoad)
(qemuDomainUndefineFlags, qemuDomainSnapshotCreateXML)
(qemuDomainSnapshotListNames, qemuDomainSnapshotNum)
(qemuDomainListAllSnapshots)
(qemuDomainSnapshotListChildrenNames)
(qemuDomainSnapshotNumChildren)
(qemuDomainSnapshotListAllChildren)
(qemuDomainSnapshotLookupByName, qemuDomainSnapshotGetParent)
(qemuDomainSnapshotGetXMLDesc, qemuDomainSnapshotIsCurrent)
(qemuDomainSnapshotHasMetadata, qemuDomainRevertToSnapshot)
(qemuDomainSnapshotDelete): Likewise.
* src/libvirt_private.syms (domain_conf.h): Export new function.

12 years agoxen-xs: fix uuid of renamed domain
Philipp Hahn [Fri, 24 Aug 2012 12:58:52 +0000 (14:58 +0200)]
xen-xs: fix uuid of renamed domain

When the XenStore tdb lives persistently and is not cleared between host
reboots, Xend (version 3.4 and 4.1) re-creates the domain information
located in XenStore below /vm/$UUID. (According to the xen-3.2-commit
hg265950e3df69 to fix a problem when locally migrating a domain to the
host itself.)

When doing so a version number is added to the UUID separated by one
dash, which confuses xenStoreDomainIntroduced(): It iterates over all
domains and tries to lookup all inactive domains using
xenStoreDomainGetUUID(), which fails if the running domain is renamed:
virUUIDParse() fails to parse the versioned UUID and the domain is
flagged as missing. When this happens the function delays .2s and
re-tries 20 times again, multiplied by the number of renamed VMs.
  14:48:38.878: 4285: debug : xenStoreDomainIntroduced:1354 : Some domains were missing, trying again

This adds a significant delay:
  # time virsh list >/dev/null
  real    0m6.529s
  # xenstore-list /vm
  00000000-0000-0000-0000-000000000000
  00000000-0000-0000-0000-000000000000-1
  00000000-0000-0000-0000-000000000000-2
  00000000-0000-0000-0000-000000000000-3
  00000000-0000-0000-0000-000000000000-4
  00000000-0000-0000-0000-000000000000-5
  7c06121e-90c3-93d4-0126-50481d485cca
  00000000-0000-0000-0000-000000000000-6
  00000000-0000-0000-0000-000000000000-7
  144ad19d-dfb4-2f80-8045-09196bb8784f
  00000000-0000-0000-0000-000000000000-8
  144ad19d-dfb4-2f80-8045-09196bb8784f-1
  00000000-0000-0000-0000-000000000000-9
  00000000-0000-0000-0000-000000000000-10
  00000000-0000-0000-0000-000000000000-11
  00000000-0000-0000-0000-000000000000-12
  00000000-0000-0000-0000-000000000000-13
  00000000-0000-0000-0000-000000000000-14
  144ad19d-dfb4-2f80-8045-09196bb8784f-2
  00000000-0000-0000-0000-000000000000-15
  144ad19d-dfb4-2f80-8045-09196bb8784f-3
  00000000-0000-0000-0000-000000000000-16

The patch adds truncation of the UUID as read from the XenStore path
before passing it to virUUIDParse().

The same issue is reported at
<http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=666135>

Signed-off-by: Philipp Hahn <hahn@univention.de>
12 years agoconf: Don't always require security/@model
Michal Privoznik [Fri, 24 Aug 2012 12:59:59 +0000 (14:59 +0200)]
conf: Don't always require security/@model

Only parse model, if static labelling, or
a base label is set, or doing active XML.

12 years agosecurity: Add DAC to security_drivers
Michal Privoznik [Fri, 24 Aug 2012 10:36:03 +0000 (12:36 +0200)]
security: Add DAC to security_drivers

Currently, if users set 'security_driver="dac"' in qemu.conf libvirtd
fails to initialize as DAC driver is not found because it is missing
in our security drivers array.

12 years agolibssh2_transport: Add docs to remote.html
Peter Krempa [Fri, 24 Aug 2012 13:44:46 +0000 (15:44 +0200)]
libssh2_transport: Add docs to remote.html

Describe the existence of the transport driver and document the
configurable options.

12 years agonwfilter: don't log error if firewalld is disabled, improve diagnostics
Laine Stump [Fri, 24 Aug 2012 05:38:19 +0000 (01:38 -0400)]
nwfilter: don't log error if firewalld is disabled, improve diagnostics

The original patch to support firewalld in nwfilter wasn't personally
checking the exit status of firewall-cmd, but was instead sending NULL
in the *exitstatus arg, which meant that virCommandWait would log an
error just for the exit status being non-0 (and a "more scary than
useful" error at that).

We don't want to treat this as an error, though, just as a reason to
use standard (ip|eb)tables commands instead of firewall-cmd.

This patch modifies the virCommandRun in the nwfilter code to request
status back from the caller. This avoids virCommandWait logging an
error message, and allows the caller to do as it likes after examining
the status.

The VIR_DEBUG() logged when firewalld is enabled has also been
reworded and changed to a VIR_INFO, and a similar VIR_INFO has been
added in the case that firewalld is *not* found+enabled.

12 years agoopenvz: check the exitstatus of vzlist
Laine Stump [Fri, 24 Aug 2012 05:43:19 +0000 (01:43 -0400)]
openvz: check the exitstatus of vzlist

I noticed this while auditing all calls to virCommandRun that request
an exit status from virCommandRun. Two functions in the openvz driver

  openvzDomainGetBarrierLimit
  openvzDomainSetBarrierLimit

request an exit status from virCommandRun (thus assuring that
virCommandRun won't log any errors just due to a non-0 exit status),
but then fail to examine that exit status. This could result in the
functions believing that the call to "vzlist" was successful, even
though it may have encountered an error.

12 years agoqemu-agent: available in 0.10.0
Eric Blake [Thu, 23 Aug 2012 15:56:56 +0000 (09:56 -0600)]
qemu-agent: available in 0.10.0

The recent virDomainQemuAgentCommand addition is part of 0.10.0;
also, grouping all libvirt-qemu.so callbacks together makes them
easier to identify.

* src/libvirt_qemu.syms: Fix release symbol.
* src/qemu/qemu_driver.c (qemuDriver): Likewise.
* src/remote/remote_driver.c (remote_driver): Likewise.
* src/driver.h (_virDriver): Group qemu-specific callbacks.

12 years agonetwork: fix virtual network bridge delay setting
Laine Stump [Thu, 23 Aug 2012 15:21:47 +0000 (11:21 -0400)]
network: fix virtual network bridge delay setting

libvirt's network config documents that a bridge's STP "forward delay"
(called "delay" in the XML) should be specified in seconds, but
virNetDevBridgeSetSTPDelay() assumes that it is given a delay in
milliseconds (although the comment at the top of the function
incorrectly says "seconds".

This fixes the comment, and converts the delay to milliseconds before
calling virNetDevBridgeSetSTPDelay().

12 years agoqemu: forbid suspend if already pmsuspended
Michal Privoznik [Thu, 23 Aug 2012 13:26:20 +0000 (15:26 +0200)]
qemu: forbid suspend if already pmsuspended

If a domain is pmsuspended then virsh suspend will succeed. Beside
obvious flaw, virsh resume will report success and change domain
state to running which is another mistake. Therefore we must forbid
any attempts for suspend and resume when pmsuspended.

12 years agoagent: add qemu-agent-command to virsh
MATSUDA Daiki [Thu, 23 Aug 2012 03:29:27 +0000 (12:29 +0900)]
agent: add qemu-agent-command to virsh

Add qemu-agent-command to virsh to support virDomainQemuAgentCommand().

Signed-off-by: MATSUDA Daiki <matsudadik@intellilink.co.jp>
12 years agoagent: add python module support
MATSUDA Daiki [Thu, 23 Aug 2012 03:29:26 +0000 (12:29 +0900)]
agent: add python module support

Add virDomainQemuAgentCommand() support function to python module.

Signed-off-by: MATSUDA Daiki <matsudadik@intellilink.co.jp>
12 years agoagent: add remote driver support
MATSUDA Daiki [Thu, 23 Aug 2012 03:29:25 +0000 (12:29 +0900)]
agent: add remote driver support

Add qemuDomainAgentCommand() which is generated automatically,
for .qemuDomainArbitraryAgentCommand to remote driver.

Signed-off-by: MATSUDA Daiki <matsudadik@intellilink.co.jp>
12 years agoagent: add qemu driver support
MATSUDA Daiki [Thu, 23 Aug 2012 03:29:24 +0000 (12:29 +0900)]
agent: add qemu driver support

Add qemuDrvDomainAgentCommand() for .qemuDomainArbitraryAgentCommand
to qemu driver.

Signed-off-by: MATSUDA Daiki <matsudadik@intellilink.co.jp>
12 years agoagent: add virDrvDomainQemuAgentCommand prototype for drivers.
MATSUDA Daiki [Thu, 23 Aug 2012 03:29:23 +0000 (12:29 +0900)]
agent: add virDrvDomainQemuAgentCommand prototype for drivers.

Add virDrvDomainQemuAgentCommand prototype for drivers.
Add virDomainQemuAgentCommand() for virDrvDomainQemuAgentCommand.

Signed-off-by: MATSUDA Daiki <matsudadik@intellilink.co.jp>
12 years agoagent: add qemuAgentArbitraryCommand() for general qemu agent command
MATSUDA Daiki [Thu, 23 Aug 2012 03:29:22 +0000 (12:29 +0900)]
agent: add qemuAgentArbitraryCommand() for general qemu agent command

Add a function qemuAgentArbitraryCommand() for general qemu agent command.

Signed-off-by: MATSUDA Daiki <matsudadik@intellilink.co.jp>
12 years agoagent : add @seconds variable to qemuAgentSend().
MATSUDA Daiki [Thu, 23 Aug 2012 03:29:21 +0000 (12:29 +0900)]
agent : add @seconds variable to qemuAgentSend().

Add @seconds variable to qemuAgentSend().
When @timemout is true, @seconds controls how long to wait for a
response (if @seconds is VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT,
default to QEMU_AGENT_WAIT_TIME).
In addition, @seconds must be >= 0 or VIR_DOMAIN_QEMU_AGENT_COMMAND_DEFAULT.
If @timeout is false, @seconds is ignored.

Signed-off-by: MATSUDA Daiki <matsudadik@intellilink.co.jp>
12 years agoFix a missing build requirement on dbus-devel
Daniel Veillard [Thu, 23 Aug 2012 09:44:08 +0000 (17:44 +0800)]
Fix a missing build requirement on dbus-devel

Communication with the firewall daemon uses DBus
so if we compile with firewalld support, the dbus-devel
is required for building

12 years agofix check of vcpuid in virDomainVcpuPinDefParseXML
Hu Tao [Thu, 23 Aug 2012 02:31:12 +0000 (10:31 +0800)]
fix check of vcpuid in virDomainVcpuPinDefParseXML

For emulator, the vcpuid field is always set to -1, instead of parsing
XML for the value of it.

12 years agoutil: eliminate erroneous VIR_WARNs in (eb|ip)tables.c
Laine Stump [Wed, 22 Aug 2012 20:00:28 +0000 (16:00 -0400)]
util: eliminate erroneous VIR_WARNs in (eb|ip)tables.c

Several VIR_DEBUG()'s were changed to VIR_WARN() while I was testing
the firewalld support patch, and I neglected to change them back
before I pushed.

In the meantime I've decided that it would be useful to have them be
VIR_INFO(), just so there will be logged evidence of which method is
being used (firewall-cmd vs. (eb|ip)tables) without needing to crank
logging to 11. (at most this adds 2 lines to libvirtd's logs per
libvirtd start).

12 years agoFix some typos in messages, docs and comments.
Yuri Chornoivan [Wed, 22 Aug 2012 18:29:18 +0000 (21:29 +0300)]
Fix some typos in messages, docs and comments.

12 years agodnsmasq: avoid forwarding queries without a domain
Gene Czarcinski [Wed, 22 Aug 2012 16:59:24 +0000 (12:59 -0400)]
dnsmasq: avoid forwarding queries without a domain

dnsmasq is forwarding a number of queries upstream that should not
be done.  There still remains an MX query for a plain name with no
domain specified that will be forwarded is dnsmasq has --domain=xxx
--local=/xxx/ specified. This does not happen with no domain name
and --local=// ... not a libvirt problem.

BTW, thanks again to Claudio Bley!

12 years agodocs: fix blockpull/blockcopy bandwidth Mbps -> MiB/s
Stefan Hajnoczi [Wed, 22 Aug 2012 13:59:11 +0000 (14:59 +0100)]
docs: fix blockpull/blockcopy bandwidth Mbps -> MiB/s

The bandwidth units for blockpull and blockcopy are in Megabytes per
Second, not Megabits per Second.

Signed-off-by: Stefan Hajnoczi <stefanha@linux.vnet.ibm.com>
12 years agoFix parameter list in virNetlinkEvent{Add,Remove}Client Win32 stubs
Daniel P. Berrange [Wed, 22 Aug 2012 15:09:17 +0000 (16:09 +0100)]
Fix parameter list in virNetlinkEvent{Add,Remove}Client Win32 stubs

The virNetlinkEventAddClient / virNetlinkEventRemoveClient stub
impls had syntax errors in their parameter lists, using a ')'
after the second-to-last parameter instead of a ','

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agovirsh: don't print error info when snapshot xml is not changed
Guannan Ren [Tue, 21 Aug 2012 20:37:34 +0000 (04:37 +0800)]
virsh: don't print error info when snapshot xml is not changed

If xml is not changed, error message is printed.
So check ret value instead of edit variable for error message.

12 years agoFix typo in Makefile.am s/LDFOAGS/LDFLAGS/
Daniel P. Berrange [Wed, 22 Aug 2012 10:42:47 +0000 (11:42 +0100)]
Fix typo in Makefile.am  s/LDFOAGS/LDFLAGS/

12 years agoAdd uevent netlink service.
Tang Chen [Wed, 22 Aug 2012 04:10:25 +0000 (12:10 +0800)]
Add uevent netlink service.

This patch adds a new netlink service with NETLINK_KOBJECT_UEVENT
protocol hotplug event.

Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
12 years agoIntroduce virNetlinkEventServiceStopAll() to stop all netlink services.
Tang Chen [Wed, 22 Aug 2012 04:10:24 +0000 (12:10 +0800)]
Introduce virNetlinkEventServiceStopAll() to stop all netlink services.

This patch introduce virNetlinkEventServiceStopAll() to stop
all the monitors to receive netlink messages for libvirtd.

Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
12 years agoImprove netlink to support all protocol.
Tang Chen [Wed, 22 Aug 2012 04:10:23 +0000 (12:10 +0800)]
Improve netlink to support all protocol.

This patch improve all the API in virnetlink.c to support
all kinds of netlink protocols, and make all netlink sockets
be able to join in groups.

Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
12 years agoclient: Change default location of known_hosts file for libssh2 layer
Peter Krempa [Tue, 21 Aug 2012 15:54:26 +0000 (17:54 +0200)]
client: Change default location of known_hosts file for libssh2 layer

Unfortunately libssh2 doesn't support all types of host keys that can be
saved in the known_hosts file. Also it does not report that parsing of
the file failed. This results into truncated known_hosts files where the
standard client stores keys also in other formats (eg.
ecdsa-sha2-nistp256).

This patch changes the default location of the known_hosts file into the
libvirt private configuration directory, where it will be only written
by the libssh2 layer itself. This prevents trashing user's known_host
file.

12 years agolibssh2_session: Add support for creating known_hosts file
Peter Krempa [Tue, 21 Aug 2012 16:28:11 +0000 (18:28 +0200)]
libssh2_session: Add support for creating known_hosts file

The libssh2 code wasn't supposed to create the known_hosts file, but
recent findings show, that we can't use the default created by OpenSSH
as libssh2 might damage it. We need to create a private known_hosts file
in the config path.

This patch adds support for skipping error if the known_hosts file is
not present and let libssh2 create a new one.

12 years agoqemu: support of emulator_period and emulator_quota's modification
Wen Congyang [Tue, 21 Aug 2012 09:18:44 +0000 (17:18 +0800)]
qemu: support of emulator_period and emulator_quota's modification

allow the user change/get emulator's period and quota when the vm is running.

12 years agonew interface to control emulator_period/emulator_quota
Hu Tao [Tue, 21 Aug 2012 09:18:43 +0000 (17:18 +0800)]
new interface to control emulator_period/emulator_quota

This patch adds two macros: VIR_DOMAIN_SCHEDULER_EMULATOR_PERIOD,
VIR_DOMAIN_SCHEDULER_EMULATOR_QUOTA for controlling cpu bandwidth
for emulator activities not tied to vcpus

12 years agoqemu: introduce period/quota tuning for emulator
Hu Tao [Tue, 21 Aug 2012 09:18:42 +0000 (17:18 +0800)]
qemu: introduce period/quota tuning for emulator

This patch introduces support of setting emulator's period and
quota to limit cpu bandwidth when the vm starts.  Also updates
XML Schema for new entries and docs.

12 years agolimit cpu bandwidth only for vcpus
Hu Tao [Tue, 21 Aug 2012 09:18:41 +0000 (17:18 +0800)]
limit cpu bandwidth only for vcpus

This patch changes the behaviour of xml element cputune.period
and cputune.quota to limit cpu bandwidth only for vcpus, and no
longer limit cpu bandwidth for the whole guest.

The reasons to do this are:

  - This matches docs of cputune.period and cputune.quota.
  - The other parts excepting vcpus are treated as "emulator",
    and there are separate period/quota settings for emulator
    in the subsequent patches

12 years agonew command emulatorpin
Hu Tao [Tue, 21 Aug 2012 09:18:40 +0000 (17:18 +0800)]
new command emulatorpin

12 years agoAdd a new function vshPrintPinInfo.
Hu Tao [Tue, 21 Aug 2012 09:18:39 +0000 (17:18 +0800)]
Add a new function vshPrintPinInfo.

This is a helper function to print vcpu pin info.

12 years agoremote: introduce emulator pinning RPCs
Tang Chen [Tue, 21 Aug 2012 09:18:38 +0000 (17:18 +0800)]
remote: introduce emulator pinning RPCs

Introduce 2 APIs to support emulator threads in remote driver.
    1) remoteDomainPinEmulator: call driver api, such as qemudDomainPinEmulator.
    2) remoteDomainGetEmulatorPinInfo: call driver api, such as qemudDomainGetEmulatorPinInfo.
They are similar to remoteDomainPinVcpuFlags and remoteDomainGetVcpuPinInfo.

Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
12 years agoqemu: support emulator pinning
Hu Tao [Tue, 21 Aug 2012 09:18:37 +0000 (17:18 +0800)]
qemu: support emulator pinning

Introduce 2 APIs to support emulator threads pin in qemu driver.

    1) qemudDomainPinEmulator: setup emulator threads pin info.
    2) qemudDomainGetEmulatorPinInfo: get all emulator threads pin info.

They are similar to qemudDomainPinVcpuFlags and qemudDomainGetVcpuPinInfo.
And also, remoteDispatchDomainPinEmulatorFlags and remoteDispatchDomainGetEmulatorPinInfo
functions are introduced.

Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
12 years agoIntroduce virDomainEmulatorPinAdd and virDomainEmulatorPinDel functions
Tang Chen [Tue, 21 Aug 2012 09:18:36 +0000 (17:18 +0800)]
Introduce virDomainEmulatorPinAdd and virDomainEmulatorPinDel functions

Introduce 2 APIs to support emulator threads pin.
    1) virDomainEmulatorPinAdd: setup emulator threads pin with a given cpumap string.
    2) virDomainEmulatorPinDel: remove all emulator threads pin.

Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
12 years agoIntroduce virDomainPinEmulator and virDomainGetEmulatorPinInfo functions.
Tang Chen [Tue, 21 Aug 2012 09:18:35 +0000 (17:18 +0800)]
Introduce virDomainPinEmulator and virDomainGetEmulatorPinInfo functions.

Introduce 2 APIs to set/get physical cpu pinning info of emulator threads.

Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
12 years agoAdd qemuProcessSetEmulatorAffinites and set emulator threads affinities
Tang Chen [Tue, 21 Aug 2012 09:18:34 +0000 (17:18 +0800)]
Add qemuProcessSetEmulatorAffinites and set emulator threads affinities

Emulator threads should also be pinned by sched_setaffinity(), just
the same as vcpu threads.

Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
12 years agoqemu: synchronize emulatorpin info to cgroup
Tang Chen [Tue, 21 Aug 2012 09:18:33 +0000 (17:18 +0800)]
qemu: synchronize emulatorpin info to cgroup

Introduce qemuSetupCgroupEmulatorPin() function to add emulator
threads pin info to cpuset cgroup, the same as vcpupin.

Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
12 years agoSupport emulatorpin xml parse.
Tang Chen [Tue, 21 Aug 2012 09:18:32 +0000 (17:18 +0800)]
Support emulatorpin xml parse.

This patch adds a new xml element <emulatorpin>, which is a sibling
to the existing <vcpupin> element under the <cputune>, to pin emulator
threads to specified physical CPUs.

Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
12 years agoChange virDomainVcpuPinDefParseXML to support parsing emulatorpin
Hu Tao [Tue, 21 Aug 2012 09:18:31 +0000 (17:18 +0800)]
Change virDomainVcpuPinDefParseXML to support parsing emulatorpin

12 years agoEnable cpuset cgroup and synchronous vcpupin info to cgroup.
Hu Tao [Tue, 21 Aug 2012 09:18:30 +0000 (17:18 +0800)]
Enable cpuset cgroup and synchronous vcpupin info to cgroup.

vcpu threads pin are implemented using sched_setaffinity(), but
not controlled by cgroup. This patch does the following things:

    1) enable cpuset cgroup
    2) reflect all the vcpu threads pin info to cgroup

Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
12 years agoupdates of some vcpupin related functions
Hu Tao [Tue, 21 Aug 2012 09:18:29 +0000 (17:18 +0800)]
updates of some vcpupin related functions

1. add a new function virDomainVcpuPinDefCopy
2. make virDomainVcpuPinDefFree non-static

12 years agorefactor virDomainVcpuPinAdd()
Hu Tao [Tue, 21 Aug 2012 09:18:28 +0000 (17:18 +0800)]
refactor virDomainVcpuPinAdd()

12 years agoadd function bitmapFromBytemap() to convert bytemap to bitmap
Hu Tao [Tue, 21 Aug 2012 09:18:27 +0000 (17:18 +0800)]
add function bitmapFromBytemap() to convert bytemap to bitmap

12 years agocreate a new cgroup and move all emulator threads to the new cgroup
Wen Congyang [Tue, 21 Aug 2012 09:18:26 +0000 (17:18 +0800)]
create a new cgroup and move all emulator threads to the new cgroup

Create a new cgroup and move all emulator threads to the new cgroup.
And then we can do the other things:
1. limit only vcpu usage rather than the whole qemu
2. limit for emulator threads(include vhost-net threads)

Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
12 years agoIntroduce the function virCgroupMoveTask
Hu Tao [Tue, 21 Aug 2012 09:18:25 +0000 (17:18 +0800)]
Introduce the function virCgroupMoveTask

Introduce a new API to move tasks of one controller from a cgroup to another cgroup

Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
12 years agoIntroduce the function virCgroupForEmulator
Wen Congyang [Tue, 21 Aug 2012 09:18:24 +0000 (17:18 +0800)]
Introduce the function virCgroupForEmulator

Introduce the function virCgroupForEmulator() to create sub directory
for simulator thread(include I/O thread, vhost-net thread)

Signed-off-by: Wen Congyang <wency@cn.fujitsu.com>
Signed-off-by: Tang Chen <tangchen@cn.fujitsu.com>
Signed-off-by: Hu Tao <hutao@cn.fujitsu.com>
12 years agooutput status information during guest shutdown again
Gerd v. Egidy [Tue, 21 Aug 2012 15:03:40 +0000 (17:03 +0200)]
output status information during guest shutdown again

Since the move to systemd libvirt-guests doesn't output this progress
information anymore. This patch brings back this feature.

It is helpful to show the admin what the system is waiting for and what
is left of the timeout (e.g. for calibrating the shutdown timing of a ups).

Rewriting the current line with \r doesn't work anymore in the context
of systemd. So always write new lines, but move to 5 second intervals
to avoid flooding the console.

12 years agoqemu: Disk Geometry Override Support
J.B. Joret [Mon, 20 Aug 2012 13:58:51 +0000 (15:58 +0200)]
qemu: Disk Geometry Override Support

Qemu command line generation for geometry override and testcases.

Signed-off-by: J.B. Joret <jb@linux.vnet.ibm.com>
Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
12 years agoSupport for Disk Geometry Override
J.B. Joret [Mon, 20 Aug 2012 13:58:50 +0000 (15:58 +0200)]
Support for Disk Geometry Override

A hypervisor may allow to override the disk geometry of drives.
Qemu, as an example with cyls=,heads=,secs=[,trans=].
This patch extends the domain config to allow the specification of
disk geometry with libvirt.

Signed-off-by: J.B. Joret <jb@linux.vnet.ibm.com>
Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
12 years agobuild: avoid $(builddir) in Makefile
Eric Blake [Tue, 21 Aug 2012 20:33:03 +0000 (14:33 -0600)]
build: avoid $(builddir) in Makefile

Older automake 1.9.6 (hello there, RHEL 5) did not populate
$(builddir), which meant 'make check' failed with:

make[3]: *** No rule to make target `/.libs/libvirt.la', needed by `check-symfile'.  Stop.

For that matter, even newer automake doesn't directly emit rules
to build .libs/libvirt.la; we are better off basing our rules
on the public ./libvirt.la.

* src/Makefile.am (check-symfile): Delete useless variable.

12 years agobuild: network requires location of dbus headers
Eric Blake [Tue, 21 Aug 2012 20:23:35 +0000 (14:23 -0600)]
build: network requires location of dbus headers

Without this patch, RHEL 5 fails to compile, since the dbus
files lives under /usr/include/dbus-1.0/dbus/dbus.h, and
DBUS_CFLAGS contains -I/usr/include/dbus-1.0.

In file included from network/bridge_driver.c:67:
../src/util/virdbus.h:26:25: error: dbus/dbus.h: No such file or directory

* src/Makefile.am (libvirt_driver_network_impl_la_CFLAGS): Add
DBUS_CFLAGS.

12 years agoatomic: fix whitespace in previous patch
Eric Blake [Tue, 21 Aug 2012 20:27:32 +0000 (14:27 -0600)]
atomic: fix whitespace in previous patch

12 years agoatomic: mark header functions static
Eric Blake [Tue, 21 Aug 2012 19:51:00 +0000 (13:51 -0600)]
atomic: mark header functions static

When gcc atomic intrinsics are not available (such as on RHEL 5
with gcc 4.1.2), we were getting link errors due to multiple
definitions:

./.libs/libvirt_util.a(libvirt_util_la-virobject.o): In function `virAtomicIntXor':
/home/dummy/l,ibvirt/src/util/viratomoic.h:404: multiple definition of `virAtomicIntXor'
./.libs/libvirt_util.a(libvirt_util_la-viratomic.o):/home/dummy/libvirt/src/util/viratomic.h:404: first defined here

Solve this by conditionally marking the functions static (the
condition avoids falling foul of gcc warnings about unused
static function declarations).

* src/util/viratomic.h: When not using gcc intrinsics, use static
functions to avoid linker errors on duplicate functions.

12 years agobuild: work with glibc that lacks CPU_COUNT
Eric Blake [Tue, 21 Aug 2012 17:10:14 +0000 (11:10 -0600)]
build: work with glibc that lacks CPU_COUNT

Building on RHEL 5 warned:

nodeinfo.c: 305: warning: implicit declaration of function 'CPU_COUNT'

This extension macro in <sched.h> was not added until later glibc.

* src/nodeinfo.c (CPU_COUNT): Add fallback implementation.

12 years agobuild: work with older RHEL 5 kernel
Eric Blake [Tue, 21 Aug 2012 16:26:18 +0000 (10:26 -0600)]
build: work with older RHEL 5 kernel

We already skip out on building the LXC under RHEL 5, because the
kernel is too old (commits 4c18acf2dee896); but commit 9612e4b
moved some LXC-only code into common files, resulting in this
build failure:

util/virfile.c: In function 'virFileLoopDeviceAssociate':
util/virfile.c:580: error: 'LO_FLAGS_AUTOCLEAR' undeclared (first use in this function)

Unfortunately, the kernel folks only made it an enum, rather than
also a #define, so we have to modify configure.ac to record when
it is usable.

* configure.ac (with_lxc): Mark when LO_FLAGS_AUTOCLEAR was found.
* src/util/virfile.c (virFileLoopDeviceAssociate): Avoid
compilation when kernel is too old.

12 years agocommand: avoid double close in virExecWithHook
Ján Tomko [Tue, 21 Aug 2012 09:01:44 +0000 (11:01 +0200)]
command: avoid double close in virExecWithHook

Fix possible double close in the child process after the fork in case
infd and outfd are equal, just like they are after being called from
virNetSocketNewConnectCommand.

12 years agonwfilter: provide basic support for firewalld
Stefan Berger [Wed, 8 Aug 2012 16:00:23 +0000 (12:00 -0400)]
nwfilter: provide basic support for firewalld

This patch provides basic support for using firewalld's firewall-cmd
rather than then plain eb/ip(6)tables commands.

12 years agonetwork: use firewalld instead of iptables, when available
Thomas Woerner [Tue, 14 Aug 2012 18:59:52 +0000 (20:59 +0200)]
network: use firewalld instead of iptables, when available

* configure.ac, spec file: firewalld defaults to enabled if dbus is
  available, otherwise is disabled. If --with_firewalld is explicitly
  requested and dbus is not available, configure will fail.

* bridge_driver: add dbus filters to get the FirewallD1.Reloaded
  signal and DBus.NameOwnerChanged on org.fedoraproject.FirewallD1.
  When these are encountered, reload all the iptables reuls of all
  libvirt's virtual networks (similar to what happens when libvirtd is
  restarted).

* iptables, ebtables: use firewall-cmd's direct passthrough interface
  when available, otherwise use iptables and ebtables commands. This
  decision is made once the first time libvirt calls
  iptables/ebtables, and that decision is maintained for the life of
  libvirtd.

* Note that the nwfilter part of this patch was separated out into
  another patch by Stefan in V2, so that needs to be revised and
  re-reviewed as well.

================

All the configure.ac and specfile changes are unchanged from Thomas'
V3.

V3 re-ran "firewall-cmd --state" every time a new rule was added,
which was extremely inefficient.  V4 uses VIR_ONCE_GLOBAL_INIT to set
up a one-time initialization function.

The VIR_ONCE_GLOBAL_INIT(x) macro references a static function called
vir(Ip|Eb)OnceInit(), which will then be called the first time that
the static function vir(Ip|Eb)TablesInitialize() is called (that
function is defined for you by the macro). This is
thread-safe, so there is no chance of any race.

IMPORTANT NOTE: I've left the VIR_DEBUG messages in these two init
functions (one for iptables, on for ebtables) as VIR_WARN so that I
don't have to turn on all the other debug message just to see
these. Even if this patch doesn't need any other modification, those
messages need to be changed to VIR_DEBUG before pushing.

This one-time initialization works well. However, I've encountered
problems with testing:

1) Whenever I have enabled the firewalld service, *all* attempts to
call firewall-cmd from within libvirtd end with firewall-cmd hanging
internally somewhere. This is *not* the case if firewall-cmd returns
non-0 in response to "firewall-cmd --state" (i.e. *that* command runs
and returns to libvirt successfully.)

2) If I start libvirtd while firewalld is stopped, then start
firewalld later, this triggers libvirtd to reload its iptables rules,
however it also spits out a *ton* of complaints about deletion failing
(I suppose because firewalld has nuked all of libvirt's rules). I
guess we need to suppress those messages (which is a more annoying
problem to fix than you might think, but that's another story).

3) I noticed a few times during this long line of errors that
firewalld made a complaint about "Resource Temporarily
unavailable. Having libvirtd access iptables commands directly at the
same time as firewalld is doing so is apparently problematic.

4) In general, I'm concerned about the "set it once and never change
it" method - if firewalld is disabled at libvirtd startup, causing
libvirtd to always use iptables/ebtables directly, this won't cause
*terrible* problems, but if libvirtd decides to use firewall-cmd and
firewalld is later disabled, libvirtd will not be able to recover.

12 years agosanlock: Provide better error if lockspace directory is missing
Jiri Denemark [Tue, 21 Aug 2012 13:27:10 +0000 (15:27 +0200)]
sanlock: Provide better error if lockspace directory is missing

Generating "Unable to add lockspace /lock/space/dir/__LIBVIRT__DISKS__:
No such file or directory" is correct but not exactly clear. This patch
changes the error message to "Unable to create lockspace
/lock/space/dir/__LIBVIRT__DISKS__: parent directory does not exist or
is not a directory".

12 years agodaemon: Autodetect lock driver directory
Jiri Denemark [Tue, 21 Aug 2012 13:21:47 +0000 (15:21 +0200)]
daemon: Autodetect lock driver directory

When running libvirtd from a build directory, libvirtd would load lock
drivers from system directory unless explicitly overridden by setting
LIBVIRT_LOCK_MANAGER_PLUGIN_DIR environment variable. Since we already
autodetect driver directory if libvirt is build with driver modules, we
can use the same trick to automagically set lock driver directory.