Commit Graph

11584 Commits

Author SHA1 Message Date
Laine Stump
012d69dff1 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.
2012-11-28 11:59:30 -05:00
Michal Privoznik
4ded3fb1c2 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.
2012-11-28 17:45:30 +01:00
Hu Tao
39ad0001ca build: more fix to avoid C99 for loop
see commit 7e5aa78d0f

* src/interface/interface_backend_udev.c: Declare variable sooner.
2012-11-28 09:34:51 -07:00
Eric Blake
89cf363061 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.
2012-11-28 09:21:33 -07:00
Ján Tomko
7794e02c56 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.
2012-11-29 00:00:39 +08:00
Ján Tomko
0361917619 conf: snapshot: check return value of virDomainSnapshotObjListNum
If it's negative, this might result in a request to allocate lots of
memory.
2012-11-29 00:00:39 +08:00
Ján Tomko
34e5791332 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.
2012-11-29 00:00:39 +08:00
Ján Tomko
924a6c7f6a virsh: fix error messages in iface-bridge
The error messages did not correspond to the attributes they printed.
2012-11-29 00:00:39 +08:00
Ján Tomko
7475ee0f75 libssh2_session: support DSS keys as well
Missing break in the switch.
2012-11-29 00:00:39 +08:00
Ján Tomko
28a6fd9396 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.
2012-11-29 00:00:39 +08:00
Ján Tomko
cb02215252 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.
2012-11-29 00:00:39 +08:00
Peter Krempa
d3337028f5 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.
2012-11-28 16:36:34 +01:00
Peter Krempa
86727836c2 qemu: Drop word "either" from comments for agent monitor functions 2012-11-28 16:36:34 +01:00
Martin Kletzander
1d4f41fdbe 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.
2012-11-28 16:22:10 +01:00
Michal Privoznik
47c724e54f virsh: Expose new virDomainFSTrim API
It's exposed under domfstrim command. Although the API
doesn't support specifying mount point yet, expose it
anyway.
2012-11-28 16:15:01 +01:00
Michal Privoznik
6092fea93a 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.
2012-11-28 16:15:01 +01:00
Michal Privoznik
bcbe646d92 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.
2012-11-28 16:15:01 +01:00
Michal Privoznik
0fbf3704fd 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.
2012-11-28 16:15:01 +01:00
Viktor Mihajlovski
856a482207 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>
2012-11-28 14:54:44 +00:00
Viktor Mihajlovski
1a50ba2cb0 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>
2012-11-28 14:54:29 +00:00
Viktor Mihajlovski
7a95eccc81 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>
2012-11-28 14:54:21 +00:00
Gao feng
df33ecdd9e 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>
2012-11-28 10:28:49 +00:00
Gao feng
d671c0ed1b 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>
2012-11-28 10:28:49 +00:00
Gao feng
729acc23df 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>
2012-11-28 10:28:49 +00:00
Gao feng
4d4f371e09 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>
2012-11-28 10:28:49 +00:00
Gao feng
2a596dac5e 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>
2012-11-28 10:28:49 +00:00
Gao feng
b6c37e5fb5 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>
2012-11-28 10:28:49 +00:00
Guannan Ren
237629d204 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
2012-11-28 18:30:28 +08:00
Ján Tomko
8927c0eab6 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
2012-11-28 10:24:31 +01:00
Daniel P. Berrange
ebb1ccb517 Alphabetically sort libvirt_daemon.syms
Sort the symbols listed in libvirt_daemon.syms

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-11-27 19:37:13 +00:00
Daniel P. Berrange
54f89ef1fc Change bridge driver to use named initializers with virDriverState
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-11-27 19:37:07 +00:00
Alexander Larsson
d74b03e51c virdbus: Add virDBusGetSessionBus helper
This splits out some common code from virDBusGetSystemBus and
uses it to implement a new virDBusGetSessionBus helper.
2012-11-27 19:37:00 +00:00
Daniel P. Berrange
7492276317 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>
2012-11-27 19:36:36 +00:00
Daniel P. Berrange
509ce9437f 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>
2012-11-27 17:59:28 +00:00
Daniel P. Berrange
0584d6626b 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>
2012-11-27 17:59:28 +00:00
Daniel P. Berrange
9d2bfc1ca7 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>
2012-11-27 17:59:23 +00:00
Daniel P. Berrange
43db9cf4ed 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>
2012-11-27 17:02:22 +00:00
Daniel P. Berrange
68dceb635d 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>
2012-11-27 17:02:22 +00:00
Daniel P. Berrange
e11daa2b60 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>
2012-11-27 17:02:22 +00:00
Daniel P. Berrange
7c5ba648f7 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>
2012-11-27 17:02:22 +00:00
Daniel P. Berrange
8e1f0c38fa 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>
2012-11-27 17:02:22 +00:00
Daniel P. Berrange
ea2fec86dd 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.
2012-11-27 17:02:22 +00:00
Daniel P. Berrange
a33d8fceee Remove bogus newline at end of debug log message
Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2012-11-27 17:02:22 +00:00
Daniel P. Berrange
f999e2fdce 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>
2012-11-27 16:45:09 +00:00
Daniel P. Berrange
3f6470f753 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>
2012-11-27 16:45:04 +00:00
Eric Blake
1b2ebf9502 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.
2012-11-27 08:02:26 -07:00
Harsh Prateek Bora
f97a569944 tests: Add tests for gluster protocol based network disks support
Signed-off-by: Harsh Prateek Bora <harsh@linux.vnet.ibm.com>
2012-11-27 10:19:22 +01:00
Harsh Prateek Bora
c33c36d28f qemu: Add support for gluster protocol based network storage backend.
Qemu accepts gluster protocol as supported storage backend beside others.

Signed-off-by: Harsh Prateek Bora <harsh@linux.vnet.ibm.com>
2012-11-27 10:19:22 +01:00
Harsh Prateek Bora
a2d2b80fbd Add Gluster protocol as supported network disk backend
This patch introduces the RNG schema and updates necessary data strucutures
to allow various hypervisors to make use of Gluster protocol as one of the
supported network disk backend. Next patch will add support to make use of
this feature in Qemu since it now supports Gluster protocol as one of the
network based storage backend.

Two new optional attributes for <host> element are introduced - 'transport'
and 'socket'. Valid transport values are tcp, unix or rdma. If none specified,
tcp is assumed. If transport is unix, socket specifies path to unix socket.

This patch allows users to specify disks on gluster backends like this:

    <disk type='network' device='disk'>
      <driver name='qemu' type='raw'/>
      <source protocol='gluster' name='Volume1/image'>
        <host name='example.org' port='6000' transport='tcp'/>
      </source>
      <target dev='vda' bus='virtio'/>
    </disk>

    <disk type='network' device='disk'>
      <driver name='qemu' type='raw'/>
      <source protocol='gluster' name='Volume2/image'>
        <host transport='unix' socket='/path/to/sock'/>
      </source>
      <target dev='vdb' bus='virtio'/>
    </disk>

Signed-off-by: Harsh Prateek Bora <harsh@linux.vnet.ibm.com>
2012-11-27 10:19:22 +01:00
Eric Blake
7e5aa78d0f build: avoid C99 for loop
Although we require various C99 features, we don't yet require a
complete C99 compiler.  On RHEL 5, compilation complained:

qemu/qemu_command.c: In function 'qemuBuildGraphicsCommandLine':
qemu/qemu_command.c:4688: error: 'for' loop initial declaration used outside C99 mode

* src/qemu/qemu_command.c (qemuBuildGraphicsCommandLine): Declare
variable sooner.
* src/qemu/qemu_process.c (qemuProcessInitPasswords): Likewise.
2012-11-26 15:28:25 -07:00