]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
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.

12 years agobuild: split driver_storage into convenience library
Eric Blake [Tue, 21 Aug 2012 12:50:28 +0000 (06:50 -0600)]
build: split driver_storage into convenience library

Commit 1d22ba95 was complete at the time, but we have since
reintroduced a warning that is fixed in the same manner:

  CCLD   storagebackendsheepdogtest

*** Warning: Linking the executable storagebackendsheepdogtest against the loadable module
*** libvirt_driver_storage.so is not portable!

* src/Makefile.am (libvirt_driver_storage.la): Factor into new
convenience library libvirt_driver_storage_impl.la.
* tests/Makefile.am (storagebackendsheepdogtest_LDADD): Link to
convenience library, not shared library.

12 years agobuild: silence stupid gcc warning on STREQ_NULLABLE
Eric Blake [Mon, 20 Aug 2012 19:05:31 +0000 (13:05 -0600)]
build: silence stupid gcc warning on STREQ_NULLABLE

Our existing STRNEQ_NULLABLE() triggered a warning in gcc 4.7 when
used with a literal NULL argument:

qemumonitorjsontest.c: In function 'testQemuMonitorJSONGetMachines':
qemumonitorjsontest.c:289:5: error: null argument where non-null required (argument 1) [-Werror=nonnull]

even though the strcmp is provably dead when a null argument is
present.  Squelch the warning by refactoring things so that gcc
never sees strcmp() called with NULL arguments (we still compare
NULL as not equal to "", this rewrite merely aids gcc).

Next, gcc has a valid warning about a literal NULLSTR(NULL):

qemumonitorjsontest.c:289:5: error: invalid application of 'sizeof' to a void type [-Werror=pointer-arith]

Of course, you'd never write NULLSTR(NULL) directly, but it is
handy to use through macros.  But the entire part about verify_true()
is unnecessary - gcc already warns about type mismatch with ?:,
without needing to make it more complex.

* src/internal.h (STREQ_NULLABLE, STRNEQ_NULLABLE): Avoid gcc 4.7
stupidity.
(NULLSTR): Simplify, to allow passing compile-time constants.

12 years agoFix parsing of uid/gid on Mingw32
Daniel P. Berrange [Tue, 21 Aug 2012 11:07:04 +0000 (12:07 +0100)]
Fix parsing of uid/gid on Mingw32

The DAC security driver uses the virStrToLong_ui function to
parse the uid/gid out of the seclabel string. This works on
Linux where 'uid_t' is an unsigned int, but on Mingw32 it is
just an 'int'. This causes compiler warnings about signed/
unsigned int pointer mis-match.

To avoid this, use explicit 'unsigned int ouruid' local
vars to pass into virStrToLong_ui, and then simply assign
to the 'uid_t' type after parsing

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agolibssh2_transport: Use libssh2 driver code in remote driver
Peter Krempa [Tue, 17 Jul 2012 13:48:04 +0000 (15:48 +0200)]
libssh2_transport: Use libssh2 driver code in remote driver

This patch adds URI options to support libssh2 transport in the remote
driver.

A new transport sceme is introduced eg. "qemu+libssh2://..." that
utilizes the libssh2 code added in previous patches.

The libssh2 code requires the authentication callback to be able to
perform keyboard-interactive authentication or to ask t passprhases or
add host keys to known hosts database.

Added URI components:
- known_hosts -  path to a knownHosts file in OpenSSH format to check
                 for known ssh host keys
- known_hosts_verify - how to deal with server key verification:
                            * "normal" (default) - ask to add new keys
                            * "auto" - automaticaly add new keys
                            * "ignore" - don't validate host keys
- sshauth - authentication methods to use. Default is
            "agent,privkey,keyboard-interactive". It's a comma separated
            string of methods to try while authenticating. The order is
            preserved. Some of the methods may require additional
            parameters.

Locations of the known_hosts file and private keys are set to default
values if they're present. (~/.ssh/known_hosts, ~/.ssh/id_rsa,
                            ~/.ssh/id_dsa)

12 years agolibssh2_transport: Add libssh2 session support to net client code
Peter Krempa [Mon, 14 Nov 2011 15:12:53 +0000 (16:12 +0100)]
libssh2_transport: Add libssh2 session support to net client code

This patch adds a glue layer to enable using libssh2 code with the
network client code.

As in the original client implementation, shell code is sent to the
server to detect correct options for netcat and connect to libvirt's
unix socket.

12 years agolibssh2_transport: add ssh context support to virNetSocket
Peter Krempa [Mon, 14 Nov 2011 14:50:02 +0000 (15:50 +0100)]
libssh2_transport: add ssh context support to virNetSocket

This patch enables virNetSocket to be used as an ssh client when
properly configured.

This patch adds function virNetSocketNewConnectLibSSH2() that takes all
needed parameters and creates a libssh2 session and performs steps
needed to open the connection and then create a virNetSocket that
seamlesly encapsulates the communication.

12 years agolibssh2_transport: add main libssh2 transport implementation
Peter Krempa [Mon, 14 Nov 2011 14:30:23 +0000 (15:30 +0100)]
libssh2_transport: add main libssh2 transport implementation

This patch adds helper functions that enable us to use libssh2 in
conjunction with libvirt's virNetSockets for ssh transport instead of
spawning "ssh" client process.

This implemetation supports tunneled plaintext, keyboard-interactive,
private key, ssh agent based and null authentication. Libvirt's Auth
callback is used for interaction with the user. (Keyboard interactive
authentication, adding of host keys, private key passphrases). This
enables seamless integration into the application using libvirt. No
helpers as "ssh-askpass" are needed.

Reading and writing of OpenSSH style "known_hosts" files is supported.

Communication is done using SSH exec channel, where the user may specify
arbitrary command to be executed on the remote side and reads and writes
to/from stdin/out are sent through the ssh channel. Usage of stderr is
not (yet) supported.

12 years agoAdd test case for SELinux label generation
Daniel P. Berrange [Fri, 10 Aug 2012 13:31:14 +0000 (14:31 +0100)]
Add test case for SELinux label generation

This test case validates the correct generation of SELinux labels
for VMs, wrt the current process label. Since we can't actually
change the label of the test program process, we create a shared
library libsecurityselinuxhelper.so which overrides the getcon()
and setcon() libselinux.so functions. When started the test case
will check to see if LD_PRELOAD is set, and if not, it will
re-exec() itself setting LD_PRELOAD=libsecurityselinuxhelper.so

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoHonour current sensitivity and category ranges in SELinux label generation
Daniel P. Berrange [Fri, 10 Aug 2012 13:27:51 +0000 (14:27 +0100)]
Honour current sensitivity and category ranges in SELinux label generation

Currently the dynamic label generation code will create labels
with a sensitivity of s0, and a category pair in the range
0-1023. This is fine when running a standard MCS policy because
libvirtd will run with a label

  system_u:system_r:virtd_t:s0-s0:c0.c1023

With custom policies though, it is possible for libvirtd to have
a different sensitivity, or category range. For example

  system_u:system_r:virtd_t:s2-s3:c512.c1023

In this case we must assign the VM a sensitivity matching the
current lower sensitivity value, and categories in the range
512-1023

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoFix regression generating image context
Daniel P. Berrange [Tue, 21 Aug 2012 10:36:14 +0000 (11:36 +0100)]
Fix regression generating image context

The code to refactor sec label handling accidentally changed the
SELinux driver to use the 'domain_context' when generating the
image label instead of the 'file_context'

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoqemu: modify 3 error messages
Martin Kletzander [Mon, 18 Jun 2012 09:07:17 +0000 (11:07 +0200)]
qemu: modify 3 error messages

After the cleanup of remote display port allocation, I noticed some
messages that didn't make a lot of sense the way they were written. So
I rephrased them.

12 years agoqemu: configurable remote display port boundaries
Martin Kletzander [Mon, 18 Jun 2012 08:22:07 +0000 (10:22 +0200)]
qemu: configurable remote display port boundaries

The defines QEMU_REMOTE_PORT_MIN and QEMU_REMOTE_PORT_MAX were used to
find free port when starting domains. As this was hard-coded to the
same ports as default VNC servers, there were races with these other
programs. This patch includes the possibility to change the default
starting port as well as the maximum port (mostly for completeness) in
qemu config file.

Support for two new config options in qemu.conf is added:
 - remote_port_min (defaults to QEMU_REMOTE_PORT_MIN and
   must be >= than this value)
 - remote_port_max (defaults to QEMU_REMOTE_PORT_MAX and
   must be <= than this value)

12 years agoqemu: Unify port-wise SPICE and VNC behavior
Martin Kletzander [Mon, 18 Jun 2012 07:58:31 +0000 (09:58 +0200)]
qemu: Unify port-wise SPICE and VNC behavior

Port allocations for SPICE and VNC behave almost the same (with
default ports), but there is some mess in the code. This patch clears
these inconsistencies and makes sure the same behavior will be used
when ports for remote displays are changed.

Changes:
 - hard-coded number 5900 removed (handled elsewhere like with VNC)
 - reservedVNCPorts renamed to reservedRemotePorts (it's not just for
   VNC anymore)
 - QEMU_VNC_PORT_{MIN,MAX} renamed to QEMU_REMOTE_PORT_{MIN,MAX}
 - port allocation unified for VNC and SPICE

12 years agobuild: fix build with autoconf 2.59
Eric Blake [Tue, 21 Aug 2012 06:29:49 +0000 (00:29 -0600)]
build: fix build with autoconf 2.59

Commit 350583c8 broke development on a RHEL 5 box, where the
ancient Autoconf 2.59 lacks AS_VERSION_STRING.  Rather than
backport the complex awk script that newer autoconf uses for
true strverscmp comparisons from the shell, it was easier to
just open-code a shell case statement.

* configure.ac (qemu_version): Open-code a replacement for
AS_VERSION_CHECK.

12 years agovirsh: split out virsh-volume.c
Eric Blake [Mon, 20 Aug 2012 23:41:24 +0000 (17:41 -0600)]
virsh: split out virsh-volume.c

Last of the file splits.

* tools/virsh-volume.h: New file.
* tools/Makefile.am (virsh_SOURCES): Build it.
* tools/virsh.c: Use new header.
* tools/virsh-volume.c: Likewise.
(vshCommandOptVolBy): Fix flag usage.

12 years agovirsh: split out virsh-snapshot.c
Eric Blake [Mon, 20 Aug 2012 23:29:03 +0000 (17:29 -0600)]
virsh: split out virsh-snapshot.c

Almost done with the splits.

* tools/virsh-snapshot.h: New file.
* tools/Makefile.am (virsh_SOURCES): Build it.
* tools/virsh.c: Use new header.
* tools/virsh-snapshot.c: Likewise.

12 years agovirsh: split out virsh-secret.c
Eric Blake [Mon, 20 Aug 2012 23:14:37 +0000 (17:14 -0600)]
virsh: split out virsh-secret.c

One of the simpler splits.

* tools/virsh-secret.h: New file.
* tools/Makefile.am (virsh_SOURCES): Build it.
* tools/virsh.c: Use new header.
* tools/virsh-secret.c: Likewise.

12 years agovirsh: split out virsh-pool.c
Eric Blake [Mon, 20 Aug 2012 22:56:53 +0000 (16:56 -0600)]
virsh: split out virsh-pool.c

More in a series of file splits.

* tools/virsh-pool.h: New file.
* tools/Makefile.am (virsh_SOURCES): Build it.
* tools/virsh.c: Use new header.
* tools/virsh-pool.c: Likewise.
(virCommandOptPoolBy): Fix flag usage.

12 years agovirsh: split out virsh-nwfilter.c
Eric Blake [Mon, 20 Aug 2012 22:56:03 +0000 (16:56 -0600)]
virsh: split out virsh-nwfilter.c

Yet another split file.

* tools/virsh-nwfilter.h: New file.
* tools/Makefile.am (virsh_SOURCES): Build it.
* tools/virsh.c: Use new header.
* tools/virsh-nwfilter.c: Likewise.

12 years agovirsh: split out virsh-nodedev.c
Eric Blake [Mon, 20 Aug 2012 22:23:10 +0000 (16:23 -0600)]
virsh: split out virsh-nodedev.c

Another worthwhile split, needed one more public function.

* tools/virsh-nodedev.h: New file.
* tools/Makefile.am (virsh_SOURCES): Build it.
* tools/virsh-nodedev.c: Use new header.
* tools/virsh.c: Likewise.
(vshTreePrint): Export.
* tools/virsh.h (vshTreePrint): Declare.

12 years agovirsh: split out virsh-network.c
Eric Blake [Mon, 20 Aug 2012 21:43:25 +0000 (15:43 -0600)]
virsh: split out virsh-network.c

Another relatively easy file split.

* tools/virsh-network.h: New file.
* tools/Makefile.am (virsh_SOURCES): Build it.
* tools/virsh.c: Use new header.
* tools/virsh-network.c: Likewise.
(vshCommandOptNetworkBy): Update signature.

12 years agovirsh: split out virsh-interface.c
Eric Blake [Mon, 20 Aug 2012 20:30:53 +0000 (14:30 -0600)]
virsh: split out virsh-interface.c

Another relatively easy split, since helper functions were fixed
in the previous patch.

* tools/virsh-interface.h: New file.
* tools/Makefile.am (virsh_SOURCES): Build it.
* tools/virsh.c: Use new header.
* tools/virsh-interface.c: Likewise.
(vshCommandOptInterfaceBy): Check flags.

12 years agovirsh: declare more common functions
Eric Blake [Mon, 20 Aug 2012 20:29:27 +0000 (14:29 -0600)]
virsh: declare more common functions

In preparation for splitting virsh-interface.c, I found these
functions need to be declared in virsh.h, as well as one that
belongs more properly in virsh-domain.h.  Also, since we
use the VSH_BY* flags in more than one function, I improved
how they are used.

* tools/virsh.h (vshNameSorter, vshCmdHasOption): Declare.
(VSH_BYID): Turn into enum.
(vshCommandOptDomainBy): Move...
* tools/virsh-domain.h): ...here.
* tools/virsh.c: (vshNameSorter): Export.
(cmd_has_option): Rename...
(vshCmdHasOption): ...and export.
(vshCommandOptDomainBy): Move...
* tools/virsh-domain.c (vshCommandOptDomainBy): ...here, adjust
signature, and check flags.
* tools/virsh-network.c (vshCommandOptNetworkBy): Update callers.
* tools/virsh-nwfilter.c (vshCommandOptNWFilterBy): Likewise.
* tools/virsh-secret.c (vshCommandOptSecret): Likewise.
* tools/virsh-domain-monitor.c (includes): Likewise.
* tools/virsh-host.c (includes): Likewise.

12 years agovirsh: split out virsh-host.c
Eric Blake [Mon, 20 Aug 2012 20:01:45 +0000 (14:01 -0600)]
virsh: split out virsh-host.c

The splits are getting easier, with fewer cleanups needed in virsh.h.

* tools/virsh-host.h: New file.
* tools/Makefile.am (virsh_SOURCES): Build it.
* tools/virsh-host.c: Use new header.
* tools/virsh.c: Likewise.

12 years agovirsh: split out virsh-domain-monitor.c
Eric Blake [Mon, 20 Aug 2012 13:46:38 +0000 (07:46 -0600)]
virsh: split out virsh-domain-monitor.c

Another file worth compiling on its own instead of by .c inclusion.

* tools/virsh-domain-monitor.h: New file.
* tools/Makefile.am (virsh_SOURCES): Build it.
* tools/virsh.h (vshGetDomainDescription): Move to correct
header.
* tools/virsh-domain-monitor.c: Use new header.
* tools/virsh.c: Likewise.
* tools/virsh-domain.c: Likewise.

12 years agoUpdate the remote API
Marcelo Cerri [Wed, 15 Aug 2012 22:10:39 +0000 (19:10 -0300)]
Update the remote API

This patch updates libvirt's API to allow applications to inspect the
full list of security labels of a domain.

Signed-off-by: Marcelo Cerri <mhcerri@linux.vnet.ibm.com>
12 years agoSupport for multiple default security drivers in QEMU config
Marcelo Cerri [Wed, 15 Aug 2012 22:10:38 +0000 (19:10 -0300)]
Support for multiple default security drivers in QEMU config

This patch updates the key "security_driver" in QEMU config to suport
both a sigle default driver or a list of default drivers. This ensures
that it will remain compatible with older versions of the config file.

Signed-off-by: Marcelo Cerri <mhcerri@linux.vnet.ibm.com>
12 years agoUpdate security layer to handle many security labels
Marcelo Cerri [Wed, 15 Aug 2012 22:10:37 +0000 (19:10 -0300)]
Update security layer to handle many security labels

These changes make the security drivers able to find and handle the
correct security label information when more than one label is
available. They also update the DAC driver to be used as an usual
security driver.

Signed-off-by: Marcelo Cerri <mhcerri@linux.vnet.ibm.com>
12 years agoMultiple security drivers in XML data
Marcelo Cerri [Wed, 15 Aug 2012 22:10:36 +0000 (19:10 -0300)]
Multiple security drivers in XML data

This patch updates the domain and capability XML parser and formatter to
support more than one "seclabel" element for each domain and device. The
RNG schema and the tests related to this are also updated by this patch.

Signed-off-by: Marcelo Cerri <mhcerri@linux.vnet.ibm.com>
12 years agoInternal refactory of data structures
Marcelo Cerri [Wed, 15 Aug 2012 22:10:35 +0000 (19:10 -0300)]
Internal refactory of data structures

This patch updates the structures that store information about each
domain and each hypervisor to support multiple security labels and
drivers. It also updates all the remaining code to use the new fields.

Signed-off-by: Marcelo Cerri <mhcerri@linux.vnet.ibm.com>
12 years agoselinux: Fix incorrect object label generation.
Viktor Mihajlovski [Mon, 20 Aug 2012 14:12:14 +0000 (16:12 +0200)]
selinux: Fix incorrect object label generation.

This is a fix for the object label generation. It uses a new flag for
virSecuritySELinuxGenNewContext that specifies whether the context is
for an object. If so the context role remains unchanged.
Without this fix it is not possible to start domains with image file or
block device backed storage when selinux is enabled.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
12 years agovirsh: drop unused headers
Eric Blake [Mon, 20 Aug 2012 15:56:25 +0000 (09:56 -0600)]
virsh: drop unused headers

The previous commit now trips up 'make syntax-check' due to a useless
use of <signal.h>.

* tools/virsh.c (includes): Drop useless includes.

12 years agomaint: prohibit translations in testsuite
Eric Blake [Mon, 20 Aug 2012 14:26:58 +0000 (08:26 -0600)]
maint: prohibit translations in testsuite

Nothing in the testsuite or examples directory should be translated,
as it is not part of the normally installed binary.  We already
meet this rule, but enforcing it will make it easier to remember.

Suggested by Daniel P. Berrange.

* cfg.mk (sc_prohibit_useless_translation): Enhance rule.

12 years agoFix build of virsh on Win32 by moving SA_SIGINFO stub
Daniel P. Berrange [Mon, 20 Aug 2012 14:59:31 +0000 (15:59 +0100)]
Fix build of virsh on Win32 by moving SA_SIGINFO stub

On Win32 SA_SIGINFO is not defined, so virsh.c stub'd it out
to 0, but recent changes moved the usage out of virsh.c and
into virsh-domain.c

12 years agovirsh: use common namespacing
Eric Blake [Sun, 19 Aug 2012 04:10:17 +0000 (22:10 -0600)]
virsh: use common namespacing

Convert the exported items in virsh.h to use a common 'vsh' prefix.

* tools/virsh.h (VIRSH_MAX_XML_FILE): Rename...
(VSH_MAX_XML_FILE): ...and parenthesize.
(DIFF_MSEC, CTRL_CLOSE_BRACKET): Delete.
(vshUsage, vshInit, vshDeinit, vshParseArgv): Remove prototype.
(editWriteToTempFile, editFile, editReadBackFile, prettyCapacity)
(virshReportError): Rename...
(vshEditWriteToTempFile, vshEditFile, vshEditReadBackFile)
(vshPrettyCapacity, vshReportError): ...into vsh namespace.
(jobWatchTimeoutFunc): Move to virsh-domain.c.
* tools/virsh.c (vshCommandRun): Inline former DIFF_MSEC.
(main): Inline former CTRL_CLOSE_BRACKET.
(vshUsage, vshInit, vshDeinit, vshParseArgv): Make static.
(prettyCapacity, virshReportError, editWriteToTempFile, editFile):
Fix naming, and adjust usage.
(vshAskReedit, vshCommandRun, vshEventLoop, vshInit): Adjust
usage.
* tools/virsh-domain.c (cmdAttachDevice, cmdCPUCompare)
(cmdCPUBaseline, cmdCreate, cmdDefine, cmdDetachDevice)
(cmdUpdateDevice, cmdDesc, cmdUndefine, cmdStart, cmdVcpucount)
(cmdAttachDevice, cmdDomjobinfo): Likewise.
* tools/virsh-edit.c (do): Likewise.
* tools/virsh-interface.c (cmdInterfaceDefine): Likewise.
* tools/virsh-network.c (cmdNetworkCreate, cmdNetworkDefine):
Likewise.
* tools/virsh-nodedev.c (cmdNodeDeviceCreate): Likewise.
* tools/virsh-nwfilter.c (cmdNWFilterDefine): Likewise.
* tools/virsh-pool.c (cmdPoolCreate, cmdPoolDefine)
(cmdPoolDiscoverSources, cmdPoolList): Likewise.
* tools/virsh-secret.c (cmdSecretDefine): Likewise.
* tools/virsh-snapshot.c (cmdSnapshotCreate, vshSnapshotCreate)
(vshLookupSnapshot, cmdSnapshotEdit, cmdSnapshotCurrent)
(vshGetSnapshotParent): Likewise.
* tools/virsh-volume.c (cmdVolCreate, cmdVolCreateFrom)
(cmdVolInfo, cmdVolList): Likewise.

12 years agoAdd support for creating sockets & RPC servers from a pre-opened fd
Daniel P. Berrange [Thu, 9 Aug 2012 14:09:19 +0000 (15:09 +0100)]
Add support for creating sockets & RPC servers from a pre-opened fd

In order to support systemd socket based activation, it needs to
be possible to create virNetSocketPtr and virNetServerServicePtr
instance from a pre-opened file descriptor

12 years agoRefactor impl of the virNetServerClientNew method
Daniel P. Berrange [Thu, 9 Aug 2012 11:52:48 +0000 (12:52 +0100)]
Refactor impl of the virNetServerClientNew method

In preparation for adding further constructors, refactor
the virNetServerClientNew method to move most of the code
into a common virNetServerClientNewInternal helper API.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoRefactor the way new clients are registered with the server
Daniel P. Berrange [Thu, 9 Aug 2012 11:35:43 +0000 (12:35 +0100)]
Refactor the way new clients are registered with the server

Currently the virNetServerDispatchNewClient both creates the
virNetServerClientPtr instance and registers it with the
virNetServerPtr internal state. Split the client registration
code out into a separate virNetServerAddClient method to
allow future reuse from other contexts

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoMake Win32 stub of vshAskReedit non-static
Daniel P. Berrange [Mon, 20 Aug 2012 12:29:14 +0000 (13:29 +0100)]
Make Win32 stub of vshAskReedit non-static

The main impl of vshAskReedit is non-static, so the Win32
stub must be the same

12 years agoFix syntax-check failures wrt virsh
Daniel P. Berrange [Mon, 20 Aug 2012 10:17:26 +0000 (11:17 +0100)]
Fix syntax-check failures wrt virsh

* cfg.mk: Whitelist virsh.h instead of virsh.c for strcasecmp check
* tools/virsh-domain.h, tools/virsh.h: Fix #define indentation

12 years agovirsh: kill some double underscores
Eric Blake [Sat, 18 Aug 2012 04:35:13 +0000 (22:35 -0600)]
virsh: kill some double underscores

C99 says that __foo naming is reserved for the compiler.  Besides,
we had several different styles in use; this consolidates things
to set up the typedefs up front then declare the types with
consistent naming.

* tools/virsh.h: Use consistent struct naming.
* tools/virsh.c (_vshCommandParser): Likewise.

12 years agovirsh: split out virsh-domain.c
Eric Blake [Sat, 18 Aug 2012 04:00:42 +0000 (22:00 -0600)]
virsh: split out virsh-domain.c

The virsh-domain.c file was pretty self-contained; the only
entry point was the table of command definitions.  The bulk
of this patch is making more functions in virsh.c reusable.
A later patch will clean up poor naming choices.

* tools/Makefile.am (virsh_SOURCES): Build virsh-domain.c.
* tools/virsh-domain.h: New file.
* tools/virsh.h (virshReportError, vshResetLibvirtError)
(vshAskReedit, vshStreamSink): Declare.
* tools/virsh.c: Switch from using .c to .h.
(virshReportError, vshResetLibvirtError, vshAskReedit)
(vshStreamSink, prettyCapacity): Export.
(vshCatchInt): Move...
* tools/virsh-domain.c: ...into sole user.  Use header.

12 years agovirsh: split out virsh.h
Eric Blake [Sat, 18 Aug 2012 03:16:04 +0000 (21:16 -0600)]
virsh: split out virsh.h

Having one .c file include another does not give any compilation
benefits; move towards modular .o files by first splitting out
reused declarations into a new virsh.h.  This patch doesn't try
very hard to see which functions are used or not, to make it
easier to review the file split.  Future patches can further trim
the header to be smaller.

* tools/Makefile.am (virsh_SOURCES): List new file, and prepare
for others.
* tools/virsh.c: Split declarations...
* tools/virsh.h: ...into new file, and make several functions
non-static.
* tools/virsh-domain-monitor.c (vshGetDomainDescription): Make
non-static.

12 years agovirsh: move vshWatchJob earlier
Eric Blake [Sat, 18 Aug 2012 03:23:07 +0000 (21:23 -0600)]
virsh: move vshWatchJob earlier

It's easier to order things in topological order than it is to
forward declare in one file for use only by one other file.

* tools/virsh.c (vshWatchJob, parseRateStr)
(vshDomainStateToString, vshDomainStateReasonToString)
(vshDomainControlStateToString, vshDomainVcpuStateToString): Drop
useless prototypes.
* tools/virsh-domain.c (vshWatchJob): Move earlier.

12 years agoqemu: support netdevs from <forward mode='hostdev'> networks
Shradha Shah [Thu, 16 Aug 2012 15:42:48 +0000 (16:42 +0100)]
qemu: support netdevs from <forward mode='hostdev'> networks

For network devices allocated from a network with <forward
mode='hostdev'>, there is a need to add the newly minted hostdev to
the hostdevs array.

In this case we also need to call qemuPrepareHostDevices just for this
one device, as the standard call to initialize all the hostdevs that
were defined directly in the domain's configuration has already been
made by the time we allocate a device from a libvirt network, and thus
have something that needs initializing.

Signed-off-by: Shradha Shah <sshah@solarflare.com>
12 years agonetwork: support <forward mode='hostdev'> in network driver
Shradha Shah [Thu, 16 Aug 2012 15:42:31 +0000 (16:42 +0100)]
network: support <forward mode='hostdev'> in network driver

This patch updates the network driver to properly utilize the new
attributes/elements that are now in virNetworkDef

Signed-off-by: Shradha Shah <sshah@solarflare.com>
Signed-off-by: Laine Stump <laine@laine.org>
12 years agoconf: add function virDevicePCIAddressEqual
Shradha Shah [Thu, 16 Aug 2012 15:42:14 +0000 (16:42 +0100)]
conf: add function virDevicePCIAddressEqual

This function is needed by the network driver in a later commit.
It is useful in functions like networkNotifyActualDevice and
networkReleaseActualDevice

12 years agonetwork: return netdev name or pci addr of the VF in actualDevice
Shradha Shah [Thu, 16 Aug 2012 15:41:58 +0000 (16:41 +0100)]
network: return netdev name or pci addr of the VF in actualDevice

The network pool should be able to keep track of both network device
names and PCI addresses, and return the appropriate one in the
actualDevice when networkAllocateActualDevice is called.

Signed-off-by: Shradha Shah <sshah@solarflare.com>
12 years agoconf: parser/formatter/rng for <forward mode='hostdev'>
Shradha Shah [Thu, 16 Aug 2012 15:41:41 +0000 (16:41 +0100)]
conf: parser/formatter/rng for <forward mode='hostdev'>

This patch introduces the new forward mode='hostdev' along with
attribute managed. Includes updates to the network RNG and new xml
parser/formatter code.

Signed-off-by: Shradha Shah <sshah@solarflare.com>
12 years agonetwork: helper function to create interface pool from PF
Shradha Shah [Thu, 16 Aug 2012 15:41:24 +0000 (16:41 +0100)]
network: helper function to create interface pool from PF

Existing code that creates a list of forwardIfs from a single PF
was moved to the new utility function networkCreateInterfacePool.
No functional change.

Signed-off-by: Shradha Shah <sshah@solarflare.com>
12 years agoconf: move DevicePCIAddress functions to separate file
Shradha Shah [Thu, 16 Aug 2012 15:41:06 +0000 (16:41 +0100)]
conf: move DevicePCIAddress functions to separate file

Move the functions the parse/format, and validate PCI addresses to
their own file so they can be conveniently used in other places
besides device_conf.c

Refactoring existing code without causing any functional changes to
prepare for new code.

This patch makes the code reusable.

Signed-off-by: Shradha Shah <sshah@solarflare.com>
12 years agodocs: Enhance documentation of log_filters
Jiri Denemark [Fri, 17 Aug 2012 12:12:51 +0000 (14:12 +0200)]
docs: Enhance documentation of log_filters

Also make sure documentation in libvirtd.conf matches the one from
logging.html.

12 years agoconf: Fix ABI stability check for spicevmc channel
Jiri Denemark [Fri, 17 Aug 2012 12:06:13 +0000 (14:06 +0200)]
conf: Fix ABI stability check for spicevmc channel

Change device type of a virtio channel from/to spicevmc is not a user
visible change. However, spicevmc channels use different default target
name than other virtio channels. To maintain ABI stability during this
change target name must be explicitly specified (and equal) in both
configurations.

12 years agonetwork: add support for setting VLANs on Open vSwitch ports
Kyle Mestery [Fri, 17 Aug 2012 04:04:54 +0000 (00:04 -0400)]
network: add support for setting VLANs on Open vSwitch ports

Add the ability to support VLAN tags for Open vSwitch virtual port
types. To accomplish this, modify virNetDevOpenvswitchAddPort and
virNetDevTapCreateInBridgePort to take a virNetDevVlanPtr
argument. When adding the port to the OVS bridge, setup either a
single VLAN or a trunk port based on the configuration from the
virNetDevVlanPtr.

Signed-off-by: Kyle Mestery <kmestery@cisco.com>
12 years agoFix the indentions of libvirt.h.in
Osier Yang [Wed, 11 Jul 2012 14:27:38 +0000 (22:27 +0800)]
Fix the indentions of libvirt.h.in

Substitute 2 spaces with 4 spaces instead.

12 years agoqemu: Set swap_hard_limit before hard_limit
Osier Yang [Fri, 17 Aug 2012 07:34:52 +0000 (15:34 +0800)]
qemu: Set swap_hard_limit before hard_limit

Setting hard_limit larger than previous swap_hard_limit must fail,
it's not that good if one wants to change the swap_hard_limit
and hard_limit together. E.g.

% virsh memtune rhel6
hard_limit     : 1000000
soft_limit     : 1000000
swap_hard_limit: 1000000

% virsh memtune rhel6 --hard-limit 1000020 --soft-limit 1000020 \
--swap-hard-limit 1000020 --live

This patch reorder the limits setting to set the swap_hard_limit
first, hard_limit then, and soft_limit last if it's greater than
current swap_hard_limit. And soft_limit first, hard_limit then,
swap_hard_limit last, if not.

12 years agobuild: fix syntax check during 'make distcheck'
Eric Blake [Thu, 16 Aug 2012 22:18:44 +0000 (16:18 -0600)]
build: fix syntax check during 'make distcheck'

'make distcheck' was failing because a syntax check file,
.sc-start-sc_vulnerable_makefile_CVE-2012-3386, got left
behind.  I traced it to the 'distdir' rule depending on a
shortcut syntax-check name rather than the full rule name
normally used during 'local-check' from maint.mk.

* cfg.mk (distdir): Depend on full rule, not shorthand name.

12 years agobuild: ship stamp files
Eric Blake [Thu, 16 Aug 2012 19:57:34 +0000 (13:57 -0600)]
build: ship stamp files

'make distcheck' fails because the generated ESX and HyperV files
are (intentionally) marked read-only, but since the stamp file was
missing, make assumes they need to be rebuilt.  Shipping the stamp
file solves the problem.

* src/Makefile.am (EXTRA_DIST): Ship stamp files.

12 years agoqemu: support setting vlan tag for <interface type='hostdev'>
Laine Stump [Wed, 15 Aug 2012 07:13:36 +0000 (03:13 -0400)]
qemu: support setting vlan tag for <interface type='hostdev'>

The underlying function to set the vlan tag of an SR-IOV network
device was already in place (although an extra patch to save/restore
the original vlan tag was needed), and recent patches added the
ability to configure a vlan tag. This patch just ties those two
together.

An SR-IOV device doesn't support vlan trunking, so if anyone tries to
configure more than a single tag, or set the trunk flag, and error is
logged.

12 years agoutil: properly save/restore original vlan tag for VFs
Laine Stump [Thu, 16 Aug 2012 04:06:39 +0000 (00:06 -0400)]
util: properly save/restore original vlan tag for VFs

When a network device that is a VF of an SR-IOV card was assigned to a
guest using <interface type='hostdev'>, only the MAC address was being
saved/restored, but the VLAN tag was left untouched. Up to now we
haven't actually used vlan tags on SR-IOV devices, so the guest would
have used whatever was set, and left it the same at the end.

The patch following this one will hook up the <vlan> element from the
interface config, so save/restore of the device state needs to also
include the vlan tag.

MAC address is being saved as a simple ASCII string in a file named
for the device under /var/run.  The VLAN tag is now just added at the
end of that file, after a newline. It might be nicer if the file was
XML (in case it ever gets more complicated) but at the moment there's
nothing else on the horizon, and this makes backward compatibility
easier.

12 years agoqemu: Ensure the cpuset is formatted as expected before passing to cgroup
Osier Yang [Thu, 16 Aug 2012 03:35:04 +0000 (11:35 +0800)]
qemu: Ensure the cpuset is formatted as expected before passing to cgroup

The parameter value for cpuset could be in special format like
"0-10,^7", which is not recognized by cgroup. This patch is to
ensure the cpuset is formatted as expected before passing it to
cgroup. As a side effect, after the patch, it parses the cpuset
early before cgroup setting, to avoid the rollback if cpuset
parsing fails afterwards.

12 years agoFix WIN32 conditional for disabling console command
Daniel P. Berrange [Wed, 15 Aug 2012 20:43:01 +0000 (21:43 +0100)]
Fix WIN32 conditional for disabling console command

The '#endif' for a WIN32 conditional was placed one function
too high, leaving the impl of the console command enabled
and referencing functions that were disabled

12 years agoMove some SASL symbols into libvirt_sasl.syms
Daniel P. Berrange [Wed, 15 Aug 2012 20:41:42 +0000 (21:41 +0100)]
Move some SASL symbols into libvirt_sasl.syms

Previous commit:

  commit 9093ab77345767f741304aa0adb02adbbe766f14
  Author: Daniel P. Berrange <berrange@redhat.com>
  Date:   Wed Jul 18 17:03:17 2012 +0100

    Add lots of internal symbols to libvirt_private.syms

mistakenly put some conditional SASL symbols in libvirt_private.syms
instead of libvirt_sasl.syms

12 years agobuild: avoid warnings on older gcc
Eric Blake [Tue, 14 Aug 2012 20:11:35 +0000 (14:11 -0600)]
build: avoid warnings on older gcc

A previous patch (c606671a) pulled in a newer version of
stat-time.h from gnulib, which causes some warnings in older gcc:

  CC     libvirt_driver_storage_la-storage_backend.lo
cc1: warnings being treated as errors
In file included from ../../src/storage/storage_backend.c:59:
../../gnulib/lib/stat-time.h:55: error: no previous prototype for 'get_stat_atime_ns' [-Wmissing-prototypes]

Upstream gnulib argues that these warnings are stupid (and I agree;
see <http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54113>), and has
used a modern gcc feature (#pragma GCC diagnostic push) to avoid the
warning.  But we still aim to compile on RHEL 6.3, with gcc 4.4.6
(not to mention even older platforms like RHEL 5), and therefore
the warning trips up our default of development with -Werror.

It took me a while to figure out how to make our set of warnings
smaller on older gcc without losing the benefit of the warnings
when using newer gcc (such as the one on Fedora 17), but this
should do the trick.

* m4/virt-compile-warnings.m4 (LIBVIRT_COMPILE_WARNINGS): Avoid
warnings that gnulib can't silence on older gcc.

12 years agonetwork: make network driver vlan-aware
Laine Stump [Mon, 13 Aug 2012 02:46:27 +0000 (22:46 -0400)]
network: make network driver vlan-aware

The network driver now looks for the vlan element in network and
portgroup objects, and logs an error at network define time if a vlan
is requested for a network type that doesn't support it. (Currently
vlan configuration is only supported for openvswitch networks, and
networks used to do hostdev assignment of SR-IOV VFs.)

At runtime, the three potential sources of vlan information are
examined in this order: interface, chosen portgroup, network, and the
first that is non-empty is used.  Another check for valid network type
is made at this time, since the interface may have requested a vlan (a
legal thing to have in the interface config, since it's not known
until runtime if the chosen network will actually support it).

Since we must also check for domains requesting vlans for unsupported
connection types even if they are type='network', and since
networkAllocateActualDevice() is being called in exactly the correct
places, and has all of the necessary information to check, I slightly
modified the logic of that function so that interfaces that aren't
type='network' don't just return immediately. Instead, they also
perform all the same validation for supported features. Because of
this, it's not necessary to make this identical check in the other
three places that would normally require it: 1) qemu domain startup,
2) qemu device hotplug, 3) lxc domain startup.

This can be seen as a first step in consolidating network-related
functionality into the network driver, rather than having copies of
the same code spread around in multiple places; this will make it
easier to split the network parts off into a separate daemon, as we've
discussed recently.

12 years agoconf: add <vlan> element to network and domain interface elements
Laine Stump [Sun, 12 Aug 2012 07:51:30 +0000 (03:51 -0400)]
conf: add <vlan> element to network and domain interface elements

The following config elements now support a <vlan> subelements:

within a domain: <interface>, and the <actual> subelement of <interface>
within a network: the toplevel, as well as any <portgroup>

Each vlan element must have one or more <tag id='n'/> subelements.  If
there is more than one tag, it is assumed that vlan trunking is being
requested. If trunking is required with only a single tag, the
attribute "trunk='yes'" should be added to the toplevel <vlan>
element.

Some examples:

  <interface type='hostdev'/>
    <vlan>
      <tag id='42'/>
    </vlan>
    <mac address='52:54:00:12:34:56'/>
    ...
  </interface>

  <network>
    <name>vlan-net</name>
    <vlan trunk='yes'>
      <tag id='30'/>
    </vlan>
    <virtualport type='openvswitch'/>
  </network>

  <interface type='network'/>
    <source network='vlan-net'/>
    ...
  </interface>

  <network>
    <name>trunk-vlan</name>
    <vlan>
      <tag id='42'/>
      <tag id='43'/>
    </vlan>
    ...
  </network>

  <network>
    <name>multi</name>
    ...
    <portgroup name='production'/>
      <vlan>
        <tag id='42'/>
      </vlan>
    </portgroup>
    <portgroup name='test'/>
      <vlan>
        <tag id='666'/>
      </vlan>
    </portgroup>
  </network>

  <interface type='network'/>
    <source network='multi' portgroup='test'/>
    ...
  </interface>

IMPORTANT NOTE: As of this patch there is no backend support for the
vlan element for *any* network device type. When support is added in
later patches, it will only be for those select network types that
support setting up a vlan on the host side, without the guest's
involvement. (For example, it will be possible to configure a vlan for
a guest connected to an openvswitch bridge, but it won't be possible
to do that for one that is connected to a standard Linux host bridge.)