]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
12 years agoOnly let VM drivers block libvirtd timed shutdown
Daniel P. Berrange [Tue, 4 Dec 2012 12:12:51 +0000 (12:12 +0000)]
Only let VM drivers block libvirtd timed shutdown

The only important state that should prevent libvirtd shutdown
is from running VMs. Networks, host devices, network filters
and storage pools are all long lived resources that have no
significant in-memory state. They should not block shutdown.

12 years agoMake QEMU perform managed save of all VMs on stop of libvirtd
Daniel P. Berrange [Wed, 31 Oct 2012 19:03:53 +0000 (19:03 +0000)]
Make QEMU perform managed save of all VMs on stop of libvirtd

When the virStateStop() method is invoked, perform a managed
save of all VMs currently running

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agobuild: fix incremental autogen.sh when no AUTHORS is present
Eric Blake [Mon, 3 Dec 2012 20:12:09 +0000 (13:12 -0700)]
build: fix incremental autogen.sh when no AUTHORS is present

Commit 71d1256 tried to fix a problem where rebasing an old
branch on top of newer libvirt.git resulted in automake failing
because of a missing AUTHORS file.  However, while the fix
worked for an incremental 'make', it did not work for someone
that directly reran './autogen.sh'.  Reported by Laine Stump.

* autogen.sh (autoreconf): Check for same conditions as cfg.mk.
* cfg.mk (_update_required): Add comments.

12 years agoAdd iSCSI backend storage driver for ESX
Ata E Husain Bohra [Sat, 10 Nov 2012 07:18:08 +0000 (23:18 -0800)]
Add iSCSI backend storage driver for ESX

The patch adds the backend driver to support iSCSI format storage pools
and volumes for ESX host. The mapping of ESX iSCSI specifics to Libvirt
is as follows:

1. ESX static iSCSI target <------> Libvirt Storage Pools
2. ESX iSCSI LUNs          <------> Libvirt Storage Volumes.

The above understanding is based on http://libvirt.org/storage.html.

The operation supported on iSCSI pools includes:

1. List storage pools & volumes.
2. Get XML descriptor operaion on pools & volumes.
3. Lookup operation on pools & volumes by name, UUID and path (if applicable).

iSCSI pools does not support operations such as: Create / remove pools
and volumes.

12 years agoqemu: support live update of an interface's filter
Laine Stump [Mon, 12 Nov 2012 16:21:10 +0000 (11:21 -0500)]
qemu: support live update of an interface's filter

Since we can't (currently) rely on the ability to provide blanket
support for all possible network changes by calling the toplevel
netdev hostside disconnect/connect functions (due to qemu only
supporting a lockstep between initialization of host side and guest
side of devices), in order to support live change of an interface's
nwfilter we need to make a special purpose function to only call the
nwfilter teardown and setup functions if the filter for an interface
(or its parameters) changes. The pattern is nearly identical to that
used to change the bridge that an interface is connected to.

This patch was inspired by a request from Guido Winkelmann
<guido@sagersystems.de>, who tested an earlier version.

12 years agonwfilter: utility function virNWFilterVarValueEqual
Stefan Berger [Thu, 29 Nov 2012 17:49:32 +0000 (12:49 -0500)]
nwfilter: utility function virNWFilterVarValueEqual

To detect if an interface's nwfilter has changed, we need to also
compare the filterparams, which is a hashtable of virNWFilterVarValue.
virHashEqual can do this nicely, but requires a pointer to a function
that will compare two of the items being stored in the hashes.

12 years agoconf: fix virDomainNetGetActualDirect*() and BridgeName()
Laine Stump [Mon, 3 Dec 2012 17:24:46 +0000 (12:24 -0500)]
conf: fix virDomainNetGetActualDirect*() and BridgeName()

This resolves:

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

These three functions:

  virDomainNetGetActualBridgeName
  virDomainNetGetActualDirectDev
  virDomainNetGetActualDirectMode

return attributes that are in a union whose contents are interpreted
differently depending on the actual->type and so they should only
return non-0 when actual->type is 'bridge' (in the first case) or
'direct' (in the other two cases, but I had neglected to do that, so
...DirectDev() was returning bridge.brname (which happens to share the
same spot in the union with direct.linkdev) if actual->type was
'bridge', and ...BridgeName was returning direct.linkdev when
actual->type was 'direct'.

How does this involve Bug 881480 (which was about the inability to
switch between two networks that both have "<forward mode='bridge'/>
<bridge name='xxx'/>"? Whenever the return value of
virDomainNetGetActualDirectDev() for the new and old network
definitions doesn't match, qemuDomainChangeNet() requires a "complete
reconnect" of the device, which qemu currently doesn't
support. ...DirectDev() *should* have been returning NULL for old and
new, but was instead returning the old and new bridge names, which
differ.

(The other two functions weren't causing any behavioral problems in
virDomainChangeNet(), but their problem and fix was identical, so I
included them in this same patch).

12 years agovirsh: Report errors if arguments of the schedinfo command are incorrect
Peter Krempa [Mon, 3 Dec 2012 13:17:52 +0000 (14:17 +0100)]
virsh: Report errors if arguments of the schedinfo command are incorrect

Libvirt's helper API's when called directly don't raise the error so
that virsh remembers it. Subsequent calls to libvirt API's might reset
the error.

In case of schedinfo virDomainFree() in the cleanup section resets the
error when virTypedParameterAssignFromStr() fails.

This patch adds function vshSaveLibvirtError() that can be called after
calling libvirt helper APIs to ensure the error is remembered.

12 years agomaint: Misc whitespace cleanups
Peter Krempa [Mon, 3 Dec 2012 13:17:29 +0000 (14:17 +0100)]
maint: Misc whitespace cleanups

12 years agoconf: prevent crash with no uuid in cephx auth secret
Ján Tomko [Mon, 3 Dec 2012 12:35:05 +0000 (13:35 +0100)]
conf: prevent crash with no uuid in cephx auth secret

Fix the null pointer access when UUID is not specified.
Introduce a bool 'uuidUsable' to virStoragePoolAuthCephx that indicates
if uuid was specified or not and use it instead of the pointless
comparison of the static UUID array to NULL.
Add an error message if both uuid and usage are specified.

Fixes:
Error: FORWARD_NULL (CWE-476):
libvirt-0.10.2/src/conf/storage_conf.c:461: var_deref_model: Passing
    null pointer "uuid" to function "virUUIDParse(char const *, unsigned
    char *)", which dereferences it. (The dereference is assumed on the
    basis of the 'nonnull' parameter attribute.)
Error: NO_EFFECT (CWE-398):
    libvirt-0.10.2/src/conf/storage_conf.c:979: array_null: Comparing an
    array to null is not useful: "src->auth.cephx.secret.uuid != NULL".

12 years agoFix the coding style
Osier Yang [Mon, 3 Dec 2012 08:41:45 +0000 (16:41 +0800)]
Fix the coding style

Fix the "if ... else" coding style, and indentions problem.

12 years agoFix indentions
Osier Yang [Mon, 3 Dec 2012 01:57:00 +0000 (09:57 +0800)]
Fix indentions

12 years agovirsh: don't crash if shutdown --mode not provided
Eric Blake [Fri, 30 Nov 2012 21:48:24 +0000 (14:48 -0700)]
virsh: don't crash if shutdown --mode not provided

virStringSplit requires a non-NULL input, but commit cef78ed forgot
to follow the rule.

* tools/virsh-domain.c (cmdReboot, cmdShutdown): Avoid NULL deref.

12 years agologging: more API needing to log flags
Eric Blake [Fri, 30 Nov 2012 20:19:20 +0000 (13:19 -0700)]
logging: more API needing to log flags

Commit a21f5112 fixed one API, but missed two others that also
failed to log their 'flags' argument.

* src/libvirt.c (virNodeSuspendForDuration, virDomainGetHostname):
Log flags parameter.

12 years agos/flags=%u/flags=%x/ in earlier commit
Daniel P. Berrange [Fri, 30 Nov 2012 20:01:57 +0000 (20:01 +0000)]
s/flags=%u/flags=%x/ in earlier commit

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoAllow duration=0 for virsh nodesuspend
Daniel P. Berrange [Fri, 30 Nov 2012 18:43:40 +0000 (18:43 +0000)]
Allow duration=0 for virsh nodesuspend

The virNodeSuspend API allows for a duration of 0, to mean no
timed wakup. virsh needlessly forbids this though

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoAllow comma separated list of shutdown/reboot modes with virsh
Daniel P. Berrange [Fri, 30 Nov 2012 15:30:05 +0000 (15:30 +0000)]
Allow comma separated list of shutdown/reboot modes with virsh

The shutdown and reboot commands in virsh allow a comma
separated list of mode values

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoIntroduce APIs for splitting/joining strings
Daniel P. Berrange [Fri, 30 Nov 2012 15:21:02 +0000 (15:21 +0000)]
Introduce APIs for splitting/joining strings

This introduces a few new APIs for dealing with strings.
One to split a char * into a char **, another to join a
char ** into a char *, and finally one to free a char **

There is a simple test suite to validate the edge cases
too. No more need to use the horrible strtok_r() API,
or hand-written code for splitting strings.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoAdd support for shutdown / reboot APIs in LXC driver
Daniel P. Berrange [Wed, 28 Nov 2012 13:26:52 +0000 (13:26 +0000)]
Add support for shutdown / reboot APIs in LXC driver

Add support for doing controlled shutdown / reboot in the LXC
driver. The default behaviour is to try talking to /dev/initctl
inside the container's virtual root (/proc/$INITPID/root). This
works with sysvinit or systemd. If that file does not exist
then send SIGTERM (for shutdown) or SIGHUP (for reboot). These
signals are not any kind of particular standard for shutdown
or reboot, just something apps can choose to handle. The new
virDomainSendProcessSignal allows for sending custom signals.

We might allow the choice of SIGTERM/HUP to be configured for
LXC containers via the XML in the future.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoIntroduce two new methods for triggering controlled shutdown/reboot
Daniel P. Berrange [Wed, 28 Nov 2012 13:24:23 +0000 (13:24 +0000)]
Introduce two new methods for triggering controlled shutdown/reboot

The virDomainShutdownFlags and virDomainReboot APIs allow the caller
to request the operation is implemented via either acpi button press
or a guest agent. For containers, a couple of other methods make
sense, a message to /dev/initctl, and direct kill(SIGTERM|HUP) of
the container init process.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoMove reboot/shutdown flags combination check into QEMU driver
Daniel P. Berrange [Fri, 30 Nov 2012 13:51:39 +0000 (13:51 +0000)]
Move reboot/shutdown flags combination check into QEMU driver

The fact that only the guest agent, or ACPI flag can be used
when requesting reboot/shutdown is merely a limitation of the
QEMU driver impl at this time. Thus it should not be in
libvirt.c code

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoAdd APIs for talking to init via /dev/initctl
Daniel P. Berrange [Wed, 28 Nov 2012 12:17:31 +0000 (12:17 +0000)]
Add APIs for talking to init via /dev/initctl

To be able todo controlled shutdown/reboot of containers an
API to talk to init via /dev/initctl is required. Fortunately
this is quite straightforward to implement, and is supported
by both sysvinit and systemd. Upstart support for /dev/initctl
is unclear.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoEnsure virDomainShutdownFlags logs flags parameter
Daniel P. Berrange [Fri, 30 Nov 2012 15:29:49 +0000 (15:29 +0000)]
Ensure virDomainShutdownFlags logs flags parameter

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoQuote client identity in SASL whitelist log message
Daniel P. Berrange [Fri, 30 Nov 2012 15:05:48 +0000 (15:05 +0000)]
Quote client identity in SASL whitelist log message

When seeing a message

 virNetSASLContextCheckIdentity:146 : SASL client admin not allowed in whitelist

it isn't immediately obvious that 'admin' is the identity
being checked. Quote the string to make it more obvious

12 years agoqemu: Fix up the default machine type for QMP probing
Viktor Mihajlovski [Fri, 30 Nov 2012 18:22:42 +0000 (11:22 -0700)]
qemu: Fix up the default machine type for QMP probing

The default machine type must be stored in the first element of
the caps->machineTypes array. This was done for help output
parsing but not for QMP probing.

Added a helper function qemuSetDefaultMachine to apply the same
fix up for both probing methods.

Further, it was necessary to set caps->nmachineTypes after QMP
probing.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
12 years agoFix uninitialized variables
Guido Günther [Fri, 30 Nov 2012 17:51:28 +0000 (18:51 +0100)]
Fix uninitialized variables

detecet by

http://honk.sigxcpu.org:8001/job/libvirt-build/348/console

12 years agoqemu: don't attempt undefined QMP commands
Eric Blake [Fri, 30 Nov 2012 00:35:23 +0000 (17:35 -0700)]
qemu: don't attempt undefined QMP commands

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

Libvirt should not attempt to call a QMP command that has not been
documented in qemu.git - if future qemu introduces a command by the
same name but with subtly different semantics, then libvirt will be
broken when trying to use that command.

We also had some code that could never be reached - some of our
commands have an alternate for new vs. old qemu HMP commands; but
if we are new enough to support QMP, we only need a fallback to
the new HMP counterpart, and don't need to try for a QMP counterpart
for the old HMP version.

See also this attempt to convert the three snapshot commands to QMP:
https://lists.gnu.org/archive/html/qemu-devel/2012-07/msg01597.html
although it looks like that will still not happen before qemu 1.3.
That thread eventually decided that qemu would use the name
'save-vm' rather than 'savevm', which mitigates the fact that
libvirt's attempt to use a QMP 'savevm' would be broken, but we
might not be as lucky on the other commands.

* src/qemu/qemu_monitor_json.c (qemuMonitorJSONSetCPU)
(qemuMonitorJSONAddDrive, qemuMonitorJSONDriveDel)
(qemuMonitorJSONCreateSnapshot, qemuMonitorJSONLoadSnapshot)
(qemuMonitorJSONDeleteSnapshot): Use only HMP fallback for now.
(qemuMonitorJSONAddHostNetwork, qemuMonitorJSONRemoveHostNetwork)
(qemuMonitorJSONAttachDrive, qemuMonitorJSONGetGuestDriveAddress):
Delete; QMP implies QEMU_CAPS_DEVICE, which prefers AddNetdev,
RemoveNetdev, and AddDrive anyways (qemu_hotplug.c has all callers).
* src/qemu/qemu_monitor.c (qemuMonitorAddHostNetwork)
(qemuMonitorRemoveHostNetwork, qemuMonitorAttachDrive): Reflect
deleted commands.
* src/qemu/qemu_monitor_json.h (qemuMonitorJSONAddHostNetwork)
(qemuMonitorJSONRemoveHostNetwork, qemuMonitorJSONAttachDrive):
Likewise.

12 years agostorage: fix scsi detach regression with cgroup ACLs
Eric Blake [Tue, 27 Nov 2012 13:55:00 +0000 (06:55 -0700)]
storage: fix scsi detach regression with cgroup ACLs

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

Commit 38c4a9cc introduced a regression in hot unplugging of disks
from qemu, where cgroup device ACLs were no longer being revoked
(thankfully not a security hole: cgroup ACLs only prevent open()
of the disk; so reverting the ACL prevents future abuse but doesn't
stop abuse from an fd that was already opened before the ACL change).

Commit 1b2ebf95 overlooked that there were two spots affected.

* src/qemu/qemu_hotplug.c (qemuDomainDetachDiskDevice):
Transfer backing chain before deletion.
* src/qemu/qemu_driver.c (qemuDomainDetachDeviceDiskLive): Fix
spacing (partly to ensure a different-looking patch).

12 years agonwfilter: report an error on OOM
Ján Tomko [Fri, 30 Nov 2012 14:07:50 +0000 (15:07 +0100)]
nwfilter: report an error on OOM

Also removed some unreachable code found by coverity:
libvirt-0.10.2/src/nwfilter/nwfilter_driver.c:259: unreachable: This
code cannot be reached: "nwfilterDriverUnlock(driver...".

12 years agovirsh: check the return value of virStoragePoolGetAutostart
Ján Tomko [Fri, 30 Nov 2012 12:09:21 +0000 (13:09 +0100)]
virsh: check the return value of virStoragePoolGetAutostart

On error, virStoragePoolGetAutostart would return -1 leaving autostart
untouched.

Removed the misleading debug message as well.

Error: CHECKED_RETURN (CWE-252):
libvirt-0.10.2/tools/virsh-pool.c:1386: unchecked_value: No check of the
    return value of "virStoragePoolGetAutostart(pool, &autostart)".

12 years agoqemu: Refactor error reporting in qemu driver configuration parser
Peter Krempa [Thu, 29 Nov 2012 11:25:07 +0000 (12:25 +0100)]
qemu: Refactor error reporting in qemu driver configuration parser

This patch adds two labels and gets rid of a ton of duplicated code.
This patch also fixes some error message and switches most of them to
proper error reporting functions.

12 years agoqemu: Refactor config parameter retrieval
Peter Krempa [Tue, 27 Nov 2012 16:59:34 +0000 (17:59 +0100)]
qemu: Refactor config parameter retrieval

This patch adds macros to help retrieve configuration values from qemu
driver's configuration. Some configuration options are grouped
together in the process.

12 years agonetwork: use dnsmasq --bind-dynamic when available
Laine Stump [Thu, 22 Nov 2012 02:21:02 +0000 (21:21 -0500)]
network: use dnsmasq --bind-dynamic when available

This bug resolves CVE-2012-3411, which is described in the following
bugzilla report:

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

The following report is specifically for libvirt on Fedora:

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

In short, a dnsmasq instance run with the intention of listening for
DHCP/DNS requests only on a libvirt virtual network (which is
constructed using a Linux host bridge) would also answer queries sent
from outside the virtualization host.

This patch takes advantage of a new dnsmasq option "--bind-dynamic",
which will cause the listening socket to be setup such that it will
only receive those requests that actually come in via the bridge
interface. In order for this behavior to actually occur, not only must
"--bind-interfaces" be replaced with "--bind-dynamic", but also all
"--listen-address" options must be replaced with a single
"--interface" option. Fully:

   --bind-interfaces --except-interface lo --listen-address x.x.x.x ...

(with --listen-address possibly repeated) is replaced with:

   --bind-dynamic --interface virbrX

Of course libvirt can't use this new option if the host's dnsmasq
doesn't have it, but we still want libvirt to function (because the
great majority of libvirt installations, which only have mode='nat'
networks using RFC1918 private address ranges (e.g. 192.168.122.0/24),
are immune to this vulnerability from anywhere beyond the local subnet
of the host), so we use the new dnsmasqCaps API to check if dnsmasq
supports the new option and, if not, we use the "old" option style
instead. In order to assure that this permissiveness doesn't lead to a
vulnerable system, we do check for non-private addresses in this case,
and refuse to start the network if both a) we are using the old-style
options, and b) the network has a publicly routable IP
address. Hopefully this will provide the proper balance of not being
disruptive to those not practically affected, and making sure that
those who *are* affected get their dnsmasq upgraded.

(--bind-dynamic was added to dnsmasq in upstream commit
54dd393f3938fc0c19088fbd319b95e37d81a2b0, which was included in
dnsmasq-2.63)

12 years agoutil: new virSocketAddrIsPrivate function
Laine Stump [Thu, 22 Nov 2012 02:17:30 +0000 (21:17 -0500)]
util: new virSocketAddrIsPrivate function

This new function returns true if the given address is in the range of
any "private" or "local" networks as defined in RFC1918 (IPv4) or
RFC3484/RFC4193 (IPv6), otherwise they return false.

These ranges are:

   192.168.0.0/16
   172.16.0.0/16
   10.0.0.0/24
   FC00::/7
   FEC0::/10

12 years agoutil: capabilities detection for dnsmasq
Laine Stump [Tue, 20 Nov 2012 17:22:15 +0000 (12:22 -0500)]
util: capabilities detection for dnsmasq

In order to optionally take advantage of new features in dnsmasq when
the host's version of dnsmasq supports them, but still be able to run
on hosts that don't support the new features, we need to be able to
detect the version of dnsmasq running on the host, and possibly
determine from the help output what options are in this dnsmasq.

This patch implements a greatly simplified version of the capabilities
code we already have for qemu. A dnsmasqCaps device can be created and
populated either from running a program on disk, reading a file with
the concatenated output of "dnsmasq --version; dnsmasq --help", or
examining a buffer in memory that contains the concatenated output of
those two commands. Simple functions to retrieve capabilities flags,
the version number, and the path of the binary are also included.

bridge_driver.c creates a single dnsmasqCaps object at driver startup,
and disposes of it at driver shutdown. Any time it must be used, the
dnsmasqCapsRefresh method is called - it checks the mtime of the
binary, and re-runs the checks if the binary has changed.

networkxml2argvtest.c creates 2 "artificial" dnsmasqCaps objects at
startup - one "restricted" (doesn't support --bind-dynamic) and one
"full" (does support --bind-dynamic). Some of the test cases use one
and some the other, to make sure both code pathes are tested.

12 years agoconf: fix uninitialized variable in virDomainListSnapshots
Ján Tomko [Thu, 29 Nov 2012 10:55:54 +0000 (11:55 +0100)]
conf: fix uninitialized variable in virDomainListSnapshots

If allocation of names fails, list is uninitialized.

12 years agorpc: don't destroy xdr before creating it in virNetMessageEncodeHeader
Ján Tomko [Thu, 29 Nov 2012 10:50:09 +0000 (11:50 +0100)]
rpc: don't destroy xdr before creating it in virNetMessageEncodeHeader

On OOM, xdr_destroy got called even though it wasn't created yet.

Found by coverity:
Error: UNINIT (CWE-457):
    libvirt-0.10.2/src/rpc/virnetmessage.c:214: var_decl: Declaring
    variable "xdr" without initializer.
    libvirt-0.10.2/src/rpc/virnetmessage.c:219: cond_true: Condition
    "virReallocN(&msg->buffer, 1UL /* sizeof (*msg->buffer) */,
    msg->bufferLength) < 0", taking true branch
    libvirt-0.10.2/src/rpc/virnetmessage.c:221: goto: Jumping to label
    "cleanup"
    libvirt-0.10.2/src/rpc/virnetmessage.c:257: label: Reached label
    "cleanup"
    libvirt-0.10.2/src/rpc/virnetmessage.c:258: uninit_use: Using
    uninitialized value "xdr.x_ops".

12 years agovirsh: do timing even for unusable connections
Ján Tomko [Thu, 29 Nov 2012 10:46:00 +0000 (11:46 +0100)]
virsh: do timing even for unusable connections

Time values were uninitialized if the connection wasn't usable.

12 years agovirsh: use correct sizeof when allocating cpumap
Ján Tomko [Thu, 29 Nov 2012 10:23:06 +0000 (11:23 +0100)]
virsh: use correct sizeof when allocating cpumap

Found by coverity:
Error: SIZEOF_MISMATCH (CWE-569):
    libvirt-0.10.2/tools/virsh-domain.c:4754: suspicious_sizeof: Passing
    argument "8UL /* sizeof (cpumap) */" to function
    "_vshCalloc(vshControl *, size_t, size_t, char const *, int)" and
    then casting the return value to "unsigned char *" is suspicious.

Error: SIZEOF_MISMATCH (CWE-569):
    libvirt-0.10.2/tools/virsh-domain.c:4942: suspicious_sizeof: Passing
    argument "8UL /* sizeof (cpumap) */" to function
    "_vshCalloc(vshControl *, size_t, size_t, char const *, int)" and
    then casting the return value to "unsigned char *" is suspicious.

12 years agoutil: fix virBitmap allocation in virProcessInfoGetAffinity
Ján Tomko [Thu, 29 Nov 2012 09:56:56 +0000 (10:56 +0100)]
util: fix virBitmap allocation in virProcessInfoGetAffinity

Found by coverity:
Error: REVERSE_INULL (CWE-476):
    libvirt-0.10.2/src/util/processinfo.c:141: deref_ptr: Directly
    dereferencing pointer "map".
    libvirt-0.10.2/src/util/processinfo.c:142: check_after_deref:
    Null-checking "map" suggests that it may be null, but it has already
    been dereferenced on all paths leading to the check.

12 years agoconf: fix NULL check in virNetDevBandwidthParse
Ján Tomko [Thu, 29 Nov 2012 09:37:53 +0000 (10:37 +0100)]
conf: fix NULL check in virNetDevBandwidthParse

Found by coverity:
Error: REVERSE_INULL (CWE-476):
    libvirt-0.10.2/src/conf/netdev_bandwidth_conf.c:99: deref_ptr:
    Directly dereferencing pointer "node".
    libvirt-0.10.2/src/conf/netdev_bandwidth_conf.c:107:
    check_after_deref: Null-checking "node" suggests that it may be
    null, but it has already been dereferenced on all paths leading to
    the check.

12 years agoTurn some dual-state int parameters into booleans
Daniel P. Berrange [Wed, 31 Oct 2012 19:03:54 +0000 (19:03 +0000)]
Turn some dual-state int parameters into booleans

The virStateInitialize method and several cgroups methods were
using an 'int privileged' parameter or similar for dual-state
values. These are better represented with the bool type.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoIntroduce a 'stop' method to virDriverState
Daniel P. Berrange [Wed, 31 Oct 2012 19:03:52 +0000 (19:03 +0000)]
Introduce a 'stop' method to virDriverState

To allow actions to be performed in libvirtd when the host
shuts down, or user session exits, introduce a 'stop'
method to virDriverState. This will do things like saving
the VM state to a file.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoImplement virDomainSendProcessSignal for LXC driver
Daniel P. Berrange [Tue, 15 Nov 2011 15:26:32 +0000 (15:26 +0000)]
Implement virDomainSendProcessSignal for LXC driver

Implement the new API for sending signals to processes in a guest
for the LXC driver. Only support sending signals to the init
process for now, because

 - The kernel does not appear to expose the mapping between
   container PID numbers and host PID numbers anywhere in the
   host OS namespace
 - There is no race-free way to validate whether a host PID
   corresponds to a process in a container.

* src/lxc/lxc_driver.c: Allow sending processes signals

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoAdd a 'send-process-signal' command to virsh
Daniel P. Berrange [Tue, 15 Nov 2011 16:01:11 +0000 (16:01 +0000)]
Add a 'send-process-signal' command to virsh

* tools/virsh.c: Add send-process-signal
* tools/virsh.pod: Document new command

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoSpecify remote protocol for virDomainSendProcessSignal
Daniel P. Berrange [Tue, 15 Nov 2011 16:38:19 +0000 (16:38 +0000)]
Specify remote protocol for virDomainSendProcessSignal

* src/remote/remote_protocol.x: message definition
* src/remote/remote_driver.c: Register driver function
* src/remote_protocol-structs: Test case

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoAdd virDomainSendProcessSignal API
Daniel P. Berrange [Tue, 15 Nov 2011 15:13:05 +0000 (15:13 +0000)]
Add virDomainSendProcessSignal API

Add an API for sending signals to arbitrary processes in the
guest OS. This is primarily useful for container based virt,
but can be used for machine virt too, if there is a suitable
guest agent,

* include/libvirt/libvirt.h.in: Add virDomainSendProcessSignal
  and virDomainProcessSignal enum
* src/driver.h: Driver entry point
* src/libvirt.c, src/libvirt_public.syms: Impl for new API

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoqemu: Remove full stop from error messages
Jiri Denemark [Thu, 29 Nov 2012 13:15:35 +0000 (14:15 +0100)]
qemu: Remove full stop from error messages

12 years agoDon't fail hard when we can't connect to the monitor
Guido Günther [Thu, 29 Nov 2012 12:08:40 +0000 (13:08 +0100)]
Don't fail hard when we can't connect to the monitor

As of 1a50ba2cb07d8bb2aa724062889deb9efd7ad9e9 we fail to connect to the
monitor instead of getting an exit status != 0 from qemu itself.  This
breaks capabilities probing for the non QMP case.

12 years agolibvirt.c: Fix wording and grammar in virDomainFSTrim
Michal Privoznik [Thu, 29 Nov 2012 08:30:58 +0000 (09:30 +0100)]
libvirt.c: Fix wording and grammar in virDomainFSTrim

The documentation to this API has some defects from
grammar and wording POV. These were raised after I've
pushed the patches, so they are in a separate commit.

12 years agonode_memory: Fix bug of node_memory_tune
Osier Yang [Wed, 28 Nov 2012 14:11:07 +0000 (22:11 +0800)]
node_memory: Fix bug of node_memory_tune

The 3 options accept 0, and merely checking for non-zero values
would cause wrong results.

12 years agonode_memory: Do not fail if there is parameter unsupported
Osier Yang [Wed, 28 Nov 2012 14:11:06 +0000 (22:11 +0800)]
node_memory: Do not fail if there is parameter unsupported

It makes no sense to fail the whole getting command if there is
a parameter unsupported by the kernel. This patch fixes it by
omitting the unsupported parameter for getMemoryParameters.

And for setMemoryParameters, this checks if there is an unsupported
parameter up front of the setting, and just returns failure if not
all parameters are supported.

12 years agoRename misc QEMU structs/enums to use normal naming style
Daniel P. Berrange [Wed, 28 Nov 2012 17:29:44 +0000 (17:29 +0000)]
Rename misc QEMU structs/enums to use normal naming style

Replace the following names

 * struct qemu_snap_remove  with virQEMUSnapRemovePtr
 * struct qemu_snap_reparent with virQEMUSnapReparentPtr
 * struct qemu_save_header with virQEMUSaveHeaderPtr
 * enum qemu_save_formats with virQEMUSaveFormat

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoReplace 'struct qemud_driver *' with virQEMUDriverPtr
Daniel P. Berrange [Wed, 28 Nov 2012 16:43:10 +0000 (16:43 +0000)]
Replace 'struct qemud_driver *' with virQEMUDriverPtr

Remove the obsolete 'qemud' naming prefix and underscore
based type name. Introduce virQEMUDriverPtr as the replacement,
in common with LXC driver naming style

12 years agonetwork: fix crash when portgroup has no name
Laine Stump [Wed, 28 Nov 2012 04:59:17 +0000 (23:59 -0500)]
network: fix crash when portgroup has no name

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

The name attribute is required for portgroup elements (yes, the RNG
specifies that), and there is code in libvirt that assumes it is
non-null.  Unfortunately, the portgroup parsing function wasn't
checking for lack of portgroup. One adverse result of this was that
attempts to update a network by adding a portgroup with no name would
cause libvirtd to segfault. For example:

   virsh net-update default add portgroup "<portgroup default='yes'/>"

This patch causes virNetworkPortGroupParseXML to fail if no name is
specified, thus avoiding any later problems.

12 years agomaint: Fix use of invalid reboot flags
Michal Privoznik [Wed, 28 Nov 2012 16:31:14 +0000 (17:31 +0100)]
maint: Fix use of invalid reboot flags

Throughout the code, we've always used VIR_DOMAIN_SHUTDOWN* flags
even for virDomainReboot() API and its implementation. Fortunately,
the appropriate macros has the same value. But if we want to keep
things consistent, we should be using the correct macros. This
patch doesn't break anything, luckily.

12 years agobuild: more fix to avoid C99 for loop
Hu Tao [Wed, 28 Nov 2012 16:34:51 +0000 (09:34 -0700)]
build: more fix to avoid C99 for loop

see commit 7e5aa78d0f7f4cbf1c8

* src/interface/interface_backend_udev.c: Declare variable sooner.

12 years agonwfilter: drop dead code
Eric Blake [Wed, 28 Nov 2012 16:20:49 +0000 (09:20 -0700)]
nwfilter: drop dead code

Commit cb022152 went overboard and introduced a dead conditional
while trying to get rid of a potential NULL dereference.

* src/nwfilter/nwfilter_dhcpsnoop.c (virNWFilterSnoopReqNew):
Remove redundant conditional.

12 years agoutil: check for NULL parameter in virFileWrapperFdCatchError
Ján Tomko [Wed, 28 Nov 2012 14:59:07 +0000 (15:59 +0100)]
util: check for NULL parameter in virFileWrapperFdCatchError

This reverts 8927c0e qemu: fix a crash when save file can't be opened
and allows virFileWrapperFdCatchError to be called with NULL instead.

12 years agoconf: snapshot: check return value of virDomainSnapshotObjListNum
Ján Tomko [Wed, 28 Nov 2012 13:34:51 +0000 (14:34 +0100)]
conf: snapshot: check return value of virDomainSnapshotObjListNum

If it's negative, this might result in a request to allocate lots of
memory.

12 years agoconf: check the return value of virXPathNodeSet
Ján Tomko [Wed, 28 Nov 2012 13:34:50 +0000 (14:34 +0100)]
conf: check the return value of virXPathNodeSet

In a few places, the return value could get passed to VIR_ALLOC_N without
being checked, resulting in a request to allocate a lot of memory if the
return value was negative.

12 years agovirsh: fix error messages in iface-bridge
Ján Tomko [Wed, 28 Nov 2012 13:34:49 +0000 (14:34 +0100)]
virsh: fix error messages in iface-bridge

The error messages did not correspond to the attributes they printed.

12 years agolibssh2_session: support DSS keys as well
Ján Tomko [Wed, 28 Nov 2012 13:34:48 +0000 (14:34 +0100)]
libssh2_session: support DSS keys as well

Missing break in the switch.

12 years agocgroup: fix impossible overrun in virCgroupAddTaskController
Ján Tomko [Wed, 28 Nov 2012 13:34:47 +0000 (14:34 +0100)]
cgroup: fix impossible overrun in virCgroupAddTaskController

The size of the controllers array is VIR_CGROUP_CONTROLLER_LAST, however
we only call it with values less than VIR_CGROUP_CONTROLLER_LAST.

12 years agonwfilter: fix NULL pointer check in virNWFilterSnoopReqNew
Ján Tomko [Wed, 28 Nov 2012 13:34:45 +0000 (14:34 +0100)]
nwfilter: fix NULL pointer check in virNWFilterSnoopReqNew

This can't lead to a crash since virNWFilterSnoopReqNew is only called
with a static array as the argument, but if we check for NULL we should
do it right.

12 years agoqemu: Fix error messages when dispatching guest agent commands
Peter Krempa [Wed, 28 Nov 2012 12:30:40 +0000 (13:30 +0100)]
qemu: Fix error messages when dispatching guest agent commands

Error messages produced while dispatching guest agent commands didn't
have an apparent reference to the fact that they are dealing with guest
agent commands. This patch fixes up some of the messages to contain that
reference.

12 years agoqemu: Drop word "either" from comments for agent monitor functions
Peter Krempa [Wed, 28 Nov 2012 12:32:40 +0000 (13:32 +0100)]
qemu: Drop word "either" from comments for agent monitor functions

12 years agovirsh: Rewrite cmdDomDisplay
Martin Kletzander [Wed, 21 Nov 2012 15:31:51 +0000 (16:31 +0100)]
virsh: Rewrite cmdDomDisplay

Just a little rewrite of the cmdDomDisplay function to make it
consistent and hopefully more readable.  This also fixes a problem
with password not being displayed for vnc even with the
"--include-password" option.

12 years agovirsh: Expose new virDomainFSTrim API
Michal Privoznik [Tue, 20 Nov 2012 17:23:20 +0000 (18:23 +0100)]
virsh: Expose new virDomainFSTrim API

It's exposed under domfstrim command. Although the API
doesn't support specifying mount point yet, expose it
anyway.

12 years agoqemu: Implement virDomainFSTrim
Michal Privoznik [Tue, 20 Nov 2012 16:10:29 +0000 (17:10 +0100)]
qemu: Implement virDomainFSTrim

using qemu guest agent. As said in previous patch,
@mountPoint must be NULL and @flags zero because
qemu guest agent doesn't support these arguments
yet. If qemu learns them, we can start supporting
them as well.

12 years agoremote: Implement virDomainFSTrim
Michal Privoznik [Tue, 20 Nov 2012 18:01:21 +0000 (19:01 +0100)]
remote: Implement virDomainFSTrim

A new rule to fixup_name() in gendispatch.pl needs to be added,
otherwise we are left with remoteDomainFstrim which is not wanted.

12 years agoIntroduce virDomainFSTrim() public API
Michal Privoznik [Tue, 20 Nov 2012 15:43:56 +0000 (16:43 +0100)]
Introduce virDomainFSTrim() public API

This will call FITRIM within guest. The API has 4 arguments,
however, only 2 will be used for now (@dom and @minumum).
The rest two are there if in future qemu guest agent learns them.

12 years agoqemu: Add QEMU version computation to QMP probing
Viktor Mihajlovski [Mon, 26 Nov 2012 14:17:14 +0000 (15:17 +0100)]
qemu: Add QEMU version computation to QMP probing

With QMP capability probing, the version was not set.
virsh version returns:
...
Cannot extract running QEMU hypervisor version

This is fixed by computing caps->version from QMP major,
minor, micro values.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
12 years agoqemu: Fix QMP Capabability Probing Failure
Viktor Mihajlovski [Mon, 26 Nov 2012 14:17:13 +0000 (15:17 +0100)]
qemu: Fix QMP Capabability Probing Failure

QMP Capability probing will fail if QEMU cannot bind to the
QMP monitor socket in the qemu_driver->libDir directory.
That's because the child process is stripped of all
capabilities and this directory is chown'ed to the configured
QEMU user/group (normally qemu:qemu) by the QEMU driver.

To prevent this from happening, the driver startup will now pass
the QEMU uid and gid down to the capability probing code.
All capability probing invocations of QEMU will be run with
the configured QEMU uid instead of libvirtd's.

Furter, the pid file handling is moved to libvirt, as QEMU
cannot write to the qemu_driver->runDir (root:root). This also
means that the libvirt daemonizing must be used.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
12 years agoqemu: Wait for monitor socket even without pid
Viktor Mihajlovski [Mon, 26 Nov 2012 14:17:12 +0000 (15:17 +0100)]
qemu: Wait for monitor socket even without pid

If qemuMonitorOpenUnix is called without a related pid, i.e. for
QMP probing, a connect failure can happen as the result of a race.
Without a pid there is no retry and thus we give up too early.
This changes the code to retry if no pid is supplied.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
12 years agomount fuse's meminfo file to container's /proc/meminfo
Gao feng [Mon, 12 Nov 2012 07:02:28 +0000 (15:02 +0800)]
mount fuse's meminfo file to container's /proc/meminfo

we already have virtualize meminfo for container through fuse filesystem,
add function lxcContainerMountProcFuse to mount this meminfo file to
the container's /proc/meminfo.

So we can isolate container's /proc/meminfo from host now.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
12 years agomake /proc/meminfo isolate with host through fuse
Gao feng [Mon, 12 Nov 2012 11:52:01 +0000 (19:52 +0800)]
make /proc/meminfo isolate with host through fuse

with this patch,container's meminfo will be shown based on
containers' mem cgroup.

Right now,it's impossible to virtualize all values in meminfo,
I collect some values such as MemTotal,MemFree,Cached,Active,
Inactive,Active(anon),Inactive(anon),Active(file),Inactive(anon),
Active(file),Inactive(file),Unevictable,SwapTotal,SwapFree.

if I miss something, please let me know.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
12 years agoadd interface virCgroupGetAppRoot
Gao feng [Mon, 12 Nov 2012 07:02:26 +0000 (15:02 +0800)]
add interface virCgroupGetAppRoot

because libvirt_lxc's cgroup mountpoint is what it shown
in /proc/self/cgroup.

we can get container's cgroup through virCgroupNew("/", &group),
add interface virCgroupGetAppRoot to help container to
get it's cgroup.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
12 years agoadd interface virCgroupGetMemSwapUsage
Gao feng [Mon, 12 Nov 2012 07:02:25 +0000 (15:02 +0800)]
add interface virCgroupGetMemSwapUsage

virCgroupGetMemSwapUsage is used to get container's swap usage,
with this interface,we can get swap usage in fuse filesystem.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
12 years agoadd fuse support for libvirt lxc
Gao feng [Wed, 14 Nov 2012 09:39:04 +0000 (17:39 +0800)]
add fuse support for libvirt lxc

this patch addes fuse support for libvirt lxc.
we can use fuse filesystem to generate sysinfo dynamically,
So we can isolate /proc/meminfo,cpuinfo and so on through
fuse filesystem.

we mount fuse filesystem for every container.
the mount name is libvirt,mount point is
localstatedir/run/libvirt/lxc/containername.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
12 years agoAdd a configure option for fuse support in LXC driver
Gao feng [Mon, 12 Nov 2012 07:02:23 +0000 (15:02 +0800)]
Add a configure option for fuse support in LXC driver

Add a configure option --with-fuse to prepare introduction
of fuse support for libvirt lxc.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
12 years agobitmap: fix typo to use UL type of integer constant in virBitmapIsAllSet
Guannan Ren [Wed, 28 Nov 2012 06:15:38 +0000 (14:15 +0800)]
bitmap: fix typo to use UL type of integer constant in virBitmapIsAllSet

This bug leads to getting incorrect vcpupin information via
qemudDomainGetVcpuPinInfo() API when the number of maximum
cpu on a host falls into a range such as 31 < ncpus < 64.

gcc warning:
left shift count >= width of type

The following bug is such the case
https://bugzilla.redhat.com/show_bug.cgi?id=876415

12 years agoqemu: fix a crash when save file can't be opened
Ján Tomko [Wed, 28 Nov 2012 08:08:52 +0000 (09:08 +0100)]
qemu: fix a crash when save file can't be opened

In qemuDomainSaveMemory, wrapperFd might be NULL and should be checked before
calling virFileWrapperFdCatchError. Same in doCoreDump.

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

12 years agoAlphabetically sort libvirt_daemon.syms
Daniel P. Berrange [Wed, 31 Oct 2012 19:03:51 +0000 (19:03 +0000)]
Alphabetically sort libvirt_daemon.syms

Sort the symbols listed in libvirt_daemon.syms

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoChange bridge driver to use named initializers with virDriverState
Daniel P. Berrange [Wed, 31 Oct 2012 19:03:50 +0000 (19:03 +0000)]
Change bridge driver to use named initializers with virDriverState

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agovirdbus: Add virDBusGetSessionBus helper
Alexander Larsson [Wed, 31 Oct 2012 19:03:49 +0000 (19:03 +0000)]
virdbus: Add virDBusGetSessionBus helper

This splits out some common code from virDBusGetSystemBus and
uses it to implement a new virDBusGetSessionBus helper.

12 years agos/qemud/qemu/ in QEMU driver sources
Daniel P. Berrange [Wed, 31 Oct 2012 19:03:48 +0000 (19:03 +0000)]
s/qemud/qemu/ in QEMU driver sources

Change some legacy function names to use 'qemu' as their
prefix instead of 'qemud' which was a hang over from when
the QEMU driver ran inside a separate daemon

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoFix leak of virNetworkPtr in LXC startup failure path
Daniel P. Berrange [Tue, 27 Nov 2012 12:57:57 +0000 (12:57 +0000)]
Fix leak of virNetworkPtr in LXC startup failure path

When starting an LXC guest with a virNetwork based NIC device,
if the network was not active, the virNetworkPtr device would
be leaked

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoFix error reporting in virNetDevVethDelete
Daniel P. Berrange [Tue, 27 Nov 2012 12:35:49 +0000 (12:35 +0000)]
Fix error reporting in virNetDevVethDelete

In virNetDevVethDelete the virRun method will properly report
errors, but when checking the exit status for non-zero exit
code no error is reported

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoEnsure transient def is removed if LXC start fails
Daniel P. Berrange [Fri, 23 Nov 2012 16:40:16 +0000 (16:40 +0000)]
Ensure transient def is removed if LXC start fails

When starting a container, newDef is initialized to a
copy of 'def', but when startup fails newDef is never
removed. This cause later attempts to use 'virDomainDefine'
to lose the new data being defined.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoEnsure failure to create macvtap device aborts LXC start
Daniel P. Berrange [Fri, 23 Nov 2012 16:38:01 +0000 (16:38 +0000)]
Ensure failure to create macvtap device aborts LXC start

A mistaken initialization of 'ret' caused failure to create
macvtap devices to be ignored. The libvirt_lxc process
would later fail to start due to missing devices

Also make sure code checks '< 0' and not '!= 0' since only
-1 is considered an error condition

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoAvoid crash when LXC start fails with no interface target
Daniel P. Berrange [Fri, 23 Nov 2012 16:36:52 +0000 (16:36 +0000)]
Avoid crash when LXC start fails with no interface target

If the <interface> device did not contain any <target>
element, LXC would crash on a NULL pointer if starting
the container failed

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoSpecify name of target interface with macvlan error
Daniel P. Berrange [Fri, 23 Nov 2012 16:34:10 +0000 (16:34 +0000)]
Specify name of target interface with macvlan error

When failing to create a macvlan interface, make sure the
error message contains the name of the host interface

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoTreat missing driver cgroup as fatal in LXC driver
Daniel P. Berrange [Fri, 23 Nov 2012 10:44:39 +0000 (10:44 +0000)]
Treat missing driver cgroup as fatal in LXC driver

The LXC driver relies on use of cgroups to kill off LXC processes
in shutdown. If cgroups aren't available, we're unable to kill
off processes, so we must treat lack of cgroups as a fatal startup
error.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoEnsure LXC container exits if cgroups setup fails
Daniel P. Berrange [Fri, 23 Nov 2012 10:42:18 +0000 (10:42 +0000)]
Ensure LXC container exits if cgroups setup fails

The code setting up LXC cgroups used an 'rc' variable both
for capturing the return value of methods it calls, and
its own return status. The result was that several failures
in setting up cgroups would actually result in success being
returned.

Use a separate 'ret' for tracking return value as per normal
code design in other parts of libvirt

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoStore initpid in the domain status XML for LXC
Daniel P. Berrange [Thu, 22 Nov 2012 17:15:54 +0000 (17:15 +0000)]
Store initpid in the domain status XML for LXC

The initpid will be required long term to enable LXC to
implement various hotplug operations. Thus it needs to be
persisted in the domain status XML. LXC has not used the
domain status XML before, so this introduces use of the
helpers.

12 years agoRemove bogus newline at end of debug log message
Daniel P. Berrange [Fri, 23 Nov 2012 11:23:32 +0000 (11:23 +0000)]
Remove bogus newline at end of debug log message

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoPass virSecurityManagerPtr object further down into LXC setup code
Daniel P. Berrange [Thu, 22 Nov 2012 14:23:49 +0000 (14:23 +0000)]
Pass virSecurityManagerPtr object further down into LXC setup code

Currently the lxcContainerSetupMounts method uses the
virSecurityManagerPtr instance to obtain the mount options
string and then only passes the string down into methods
it calls. As functionality in LXC grows though, those
methods need to have direct access to the virSecurityManagerPtr
instance. So push the code down a level.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agoFix error handling in virSecurityManagerGetMountOptions
Daniel P. Berrange [Thu, 22 Nov 2012 14:11:35 +0000 (14:11 +0000)]
Fix error handling in virSecurityManagerGetMountOptions

The impls of virSecurityManagerGetMountOptions had no way to
return errors, since the code was treating 'NULL' as a success
value. This is somewhat pointless, since the calling code did
not want NULL in the first place and has to translate it into
the empty string "". So change the code so that the impls can
return "" directly, allowing use of NULL for error reporting
once again

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
12 years agostorage: fix device detach regression with cgroup ACLs
Eric Blake [Tue, 27 Nov 2012 13:55:00 +0000 (06:55 -0700)]
storage: fix device detach regression with cgroup ACLs

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

Commit 38c4a9cc introduced a regression in hot unplugging of disks
from qemu, where cgroup device ACLs were no longer being revoked
(thankfully not a security hole: cgroup ACLs only prevent open()
of the disk; so reverting the ACL prevents future abuse but doesn't
stop abuse from an fd that was already opened before the ACL change).

The actual regression is due to a latent bug.  The hot unplug code
was computing the set of files needing cgroup ACL revocation based
on the XML passed in by the user, rather than based on the domain's
details on which disk was being deleted.  As long as the revoke
path was always recomputing the backing chain, this didn't really
matter; but now that we want to compute the chain exactly once and
remember that computation, we need to hang on to the backing chain
until after the revoke has happened.

* src/qemu/qemu_hotplug.c (qemuDomainDetachPciDiskDevice):
Transfer backing chain before deletion.