Commit Graph

13247 Commits

Author SHA1 Message Date
Gao feng
2a3466fafb LXC: fix memory leak in virLXCControllerSetupDevPTS
We forgot to free the mount_options.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
2013-05-20 12:45:02 -06:00
Gao feng
eae1c286a1 LXC: remove unnecessary check on root filesystem
After commit c131525bec
"Auto-add a root <filesystem> element to LXC containers on startup"
for libvirt lxc, root must be existent.

Signed-off-by: Gao feng <gaofeng@cn.fujitsu.com>
2013-05-20 12:45:01 -06:00
Michal Privoznik
d8b3130664 openvzDomainSetNetwork: use virCommand
Currently, the openvzDomainSetNetwork function constructs an
array of strings representing a command line for VZCTL binary.
This is a overkill since our virCommand APIs can cover all the
functionality. Moreover, the function is not following our
structure where return value is set to -1 initially, and after
all operations succeeded then it is set to zero.
2013-05-20 18:55:29 +02:00
Osier Yang
3a6204cbbd qemu: Add callback struct for qemuBuildCommandLine
Since 0d70656afd, it starts to access the sysfs files to build
the qemu command line (by virSCSIDeviceGetSgName, which is to find
out the scsi generic device name by adpater🚌target:unit), there
is no way to work around, qemu wants to see the scsi generic device
like "/dev/sg6" anyway.

And there might be other places which need to access sysfs files
when building qemu command line in future.

Instead of increasing the arguments of qemuBuildCommandLine, this
introduces a new callback for qemuBuildCommandLine, and thus tests
can register their own callbacks for sysfs test input files accessing.

* src/qemu/qemu_command.h: (New callback struct
                            qemuBuildCommandLineCallbacks;
                            extern buildCommandLineCallbacks)
* src/qemu/qemu_command.c: (wire up the callback struct)
* src/qemu/qemu_driver.c: (Use the new syntax of qemuBuildCommandLine)
* src/qemu/qemu_hotplug.c: Likewise
* src/qemu/qemu_process.c: Likewise
* tests/testutilsqemu.[ch]: (Helper testSCSIDeviceGetSgName;
                             callback struct testCallbacks;)
* tests/qemuxml2argvtest.c: (Use testCallbacks)
* src/tests/qemuxmlnstest.c: (Like above)
2013-05-20 20:14:19 +08:00
Osier Yang
8b7b43a1d4 storage_conf: Improve the coding style in storage_conf.h
Changes:
  * Remove useless comments
  * Remove useless blank lines
  * If the struct member is a enum type, comment it like
    /* enum fooBar */
  * Break the long lines
  * Prefer the common function style for the inline function
2013-05-20 20:01:23 +08:00
Osier Yang
76359ee505 storage_conf: Fix indentions in storage_conf.c
Uses the 4 spaces for indention.
2013-05-20 20:00:19 +08:00
Osier Yang
c8a3cf89f3 storage_conf: Fix the coding stype in storage_conf.c
Changes:
  * Remove the useless space in "for" statement (e.g.
    for (i = 0 ; i < something ; i++)

  * Change the function's style to:
    void
    foo(bar)
    {
        printf("foo is not bar\n");
    }

  * Don't lose "{}" for "if...else" branches if one of the branch
    has more than one line block. Example of the old ones:
    if (a) {
        printf("a is not funny");
    } else
        printf("a is funny");

  * Remove the 1 space before "goto" label.

  * Remove the useless blank line(s)

  * Add blank line if it can make the code more clear to eyes.
2013-05-20 19:59:18 +08:00
Osier Yang
479d5991cd qemu: Abstract code for cpuset controller setting into a helper 2013-05-20 19:57:00 +08:00
Osier Yang
9f2455d359 qemu: Abstract code for devices controller setting into a helper 2013-05-20 19:52:35 +08:00
Osier Yang
f60a50c795 qemu: Abstract code for memory controller setting into a helper 2013-05-20 19:39:54 +08:00
Osier Yang
2fd16df7b5 qemu: Abstract the code for blkio controller setting into a helper 2013-05-20 19:24:45 +08:00
Matthias Bolte
9bf5246f97 esx: Fix error reporting in esxVI_LookupManagedObjectHelper
As the name parameter can be NULL the error message can only contain it
conditionally.
2013-05-17 20:14:27 +02:00
Daniel P. Berrange
ec04914c47 Add missing c-ctype.h to virfile.c
The virfile.c file uses c_isalpha on Win32 platforms, so must
include c-ctype.h

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-17 17:09:29 +01:00
Daniel P. Berrange
6ab6bc19f0 Add libvirt-daemon-vbox & libvirt-daemon-driver-vbox RPMs
Now the VirtualBox driver is a loadable module, it needs
to live in its own sub-RPM

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-17 17:09:29 +01:00
Daniel P. Berrange
34d63dd750 Include GNULIB mkdtemp module
The mkdtemp function is missing on mingw platforms. It is
used in various Linux specific places in libvirt, but
recently became used in fdstreamtest.c which is cross
platform. Thus the GNULIB mkdtemp module should be used
to provide mkdtemp.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-17 17:09:29 +01:00
Daniel P. Berrange
3e5752747c Set PKG_CONFIG_LIBDIR in autobuild.sh
If PKG_CONFIG_LIBDIR is not set when doing mingw32/64 builds,
then pkg-config may silently fallback to native versions of
libraries, with predictably bad results. Setting PKG_CONFIG_LIBDIR
forces it to only consider the mingw32/64 libraries.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-17 17:09:29 +01:00
Eric Blake
0d09854c10 docs: add another user
Described here:
https://www.redhat.com/archives/libvir-list/2013-May/msg01329.html

* docs/apps.html.in: Mention Cracow Cloud One.

Signed-off-by: Eric Blake <eblake@redhat.com>
2013-05-17 09:18:14 -06:00
Guannan Ren
6459af6a43 qemu: report useful error failling to destroy domain gracefully
Resolves:https://bugzilla.redhat.com/show_bug.cgi?id=927620

 #kill -STOP `pidof qemu-kvm`
 #virsh destroy $guest --graceful
 error: Failed to destroy domain testVM
 error: An error occurred, but the cause is unknown

With --graceful, SIGTERM always is emitted to kill driver
process, but it won't success till burning out waiting time
in case of process being stopped.
But domain destroy without --graceful can work, SIGKILL will
be emitted to the stopped process after 10 secs which always
kills a process even one that is currently stopped.
So report an error after burning out waiting time in this case.
2013-05-17 22:22:46 +08:00
Osier Yang
6aa4fc656d qemu: Check conflicts for shared scsi host device
Just like previous patches, this changes qemuCheckSharedDisk
into qemuCheckSharedDevice, which takes a virDomainDeviceDefPtr
argument instead.
2013-05-17 19:26:33 +08:00
Viktor Mihajlovski
4fb50623a7 test: fix VPATH fchosttest failure
Running make check in a VPATH configured build directory fails
in fchosttest as the test data files are searched for relative to
the current working directory.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
2013-05-17 12:09:52 +02:00
Daniel P. Berrange
63ea1e5432 Re-add selinux/selinux.h to lxc_container.c
Re-add the selinux header to lxc_container.c since other
functions now use it, beyond the patch that was just
reverted.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-17 10:59:25 +01:00
Daniel P. Berrange
c2cf5f1c2a Fix failure to detect missing cgroup partitions
Change bbe97ae968 caused the
QEMU driver to ignore ENOENT errors from cgroups, in order
to cope with missing /proc/cgroups. This is not good though
because many other things can cause ENOENT and should not
be ignored. The callers expect to see ENXIO when cgroups
are not present, so adjust the code to report that errno
when /proc/cgroups is missing

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-17 10:25:15 +01:00
Daniel P. Berrange
7bebd88871 Revert "Change label of fusefs mounted at /proc/meminfo in lxc containers"
This reverts commit 940c6f1085.
2013-05-17 10:22:54 +01:00
Jim Fehlig
a2619bb1ff libxl: fix leaking libxl events
libxl expects the event handler to free the event passed to it.  From
libxl_event.h:

   event becomes owned by the application and must be freed, either
   by event_occurs or later
2013-05-17 02:35:56 -06:00
Jim Fehlig
43b0ff5b1e libxl: fix build with Xen4.3
Xen 4.3 fixes a mistake in the libxl event handler signature where the
event owned by the application was defined as const.  Detect this and
define the libvirt libxl event handler signature appropriately.
2013-05-17 02:31:14 -06:00
Ján Tomko
25b98d31ec schema: make source optional in volume XML
We don't parse it anyway.

https://bugzilla.redhat.com/show_bug.cgi?id=893273
2013-05-17 08:35:08 +02:00
Ján Tomko
a07b88ee03 schema: require target path in storage pool xml
Make target path mandatory for pool types that require target,
since we refuse to parse a target without a path.

https://bugzilla.redhat.com/show_bug.cgi?id=893273
2013-05-17 08:33:22 +02:00
Osier Yang
9049d6a8c7 qemu: Change values of disk discard
QEMU might support more values for "-drive discard", so using Bi-state
values (on/off) for it doesn't make sense.

"on" maps to "unmap", "off" maps to "ignore":

<...>
@var{discard} is one of "ignore" (or "off") or "unmap" (or "on") and
controls whether @dfn{discard} (also known as @dfn{trim} or @dfn{unmap})
requests are ignored or passed to the filesystem.  Some machine types
may not support discard requests.
</...>
2013-05-17 13:03:25 +08:00
Jiri Denemark
fd74f74fe6 qemu: Implement support for locking domain's memory pages 2013-05-16 23:21:58 +02:00
Jiri Denemark
555866389c Add support for locking domain's memory pages
The following XML configuration can be used to request all domain's
memory pages to be kept locked in host's memory (i.e., domain's memory
pages will not be swapped out):

      <memoryBacking>
        <locked/>
      </memoryBacking>
2013-05-16 23:03:08 +02:00
Jiri Denemark
4734f1f53b Fix build with VirtualBox
Commit ba5f3c7c moved vbox driver into libvirtd but forgot to adapt
daemon's Makefile.am.
2013-05-16 23:01:43 +02:00
Martin Kletzander
0471637d56 qemu: Fix cgroup handling when setting VCPU BW
Commit 632f78c introduced a regression which causes schedinfo being
unable to set some parameters.  When migrating to priv->cgroup there
was missing variable left out and due to passed NULL to underlying
function, the setting failed.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=963592
2013-05-16 22:13:29 +02:00
Osier Yang
a842df78ea qemu: Set unpriv_sgio for scsi host device 2013-05-17 01:00:01 +08:00
Osier Yang
0453bcdfc3 qemu: Refactor qemuSetUnprivSGIO to support scsi host device
Just like what previous patches do, it refactors qemuSetUnprivSGIO
to take the virDomainDeviceDefPtr as argument instead.
2013-05-17 00:57:01 +08:00
Osier Yang
99fdd434bc qemu: Move qemuSetUnprivSGIO into qemu_conf.c
unpriv_sgio setting is tight with the shared device helpers, let's
put them together in qemu_conf.c
2013-05-17 00:51:58 +08:00
Osier Yang
6765316093 conf: Introduce sgio for hostdev
"sgio" is only valid for scsi host device.
2013-05-17 00:46:44 +08:00
Osier Yang
ead4391562 Rename virDomainDiskSGIO to virDomainDeviceSGIO
SCSI host device will also support "sgio", and perhaps we could
use "sgio" in other places too in future, renaming the enum to
reuse.
2013-05-17 00:43:38 +08:00
Osier Yang
1d94b3e760 qemu: Manage shared device entry for scsi host device
This adds the shared device entry when starting domain (more
exactly, when preparing host devices), and remove the entry
when destroying domain (when reattaching host devices).
2013-05-17 00:34:29 +08:00
Osier Yang
aeda1ff12d qemu: Refactor the helpers to track shared scsi host device
This changes the helpers qemu{Add,Remove}SharedDisk into
qemu{Add,Remove}SharedDevice, as most of the code in the helpers
can be reused for scsi host device.

To track the shared scsi host device, first it finds out the
device path (e.g. /dev/s[dr]*) which is mapped to the sg device,
and use device ID of the found device path (/dev/s[dr]*) as the
hash key. This is because of the device ID is not unique between
between /dev/s[dr]* and /dev/sg*, e.g.

% sg_map
/dev/sg0  /dev/sda
/dev/sg1  /dev/sr0

% ls -l /dev/sda
brw-rw----. 1 root disk 8, 0 May  2 19:26 /dev/sda

%ls -l /dev/sg0
crw-rw----. 1 root disk 21, 0 May  2 19:26 /dev/sg0
2013-05-17 00:32:09 +08:00
Osier Yang
28d3ad952f utils: Add a helper to get the device name that sg device mapped to
E.g.

% sg_map
/dev/sg0  /dev/sda
/dev/sg1  /dev/sr0

What the helper gets for /dev/sg0 is /dev/sda, it will be used by
later patch.
2013-05-16 23:50:00 +08:00
Osier Yang
539d0e19fd qemu: Rename qemu_driver->sharedDisks to qemu_driver->sharedDevices
"Shared disk" is not only the thing we should care about after "scsi
hostdev" is introduced. A same scsi device can be used as "disk" for
one domain, and as "scsi hostdev" for another domain at the same time.
That's why this patch renames qemu_driver->sharedDisks. Related functions
and structs are also renamed.
2013-05-16 23:48:27 +08:00
Osier Yang
f2c1d9a804 conf: Introduce <shareable> for hostdev
Unlike disk device, the scsi-generic always writethrough the data,
so no need to introduce a "cache" tag, and set "cache=off".
2013-05-16 23:41:25 +08:00
Daniel P. Berrange
95c6cc344b Don't mount selinux fs in LXC if selinux is disabled
Before trying to mount the selinux filesystem in a container
use is_selinux_enabled() to check if the machine actually
has selinux support (eg not booted with selinux=0)

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-16 16:28:53 +01:00
Daniel P. Berrange
ba5f3c7c8e Move VirtualBox driver into libvirtd
Change the build process & driver initialization so that the
VirtualBox driver is built into libvirtd, instead of libvirt.so
This change avoids the VirtualBox GPLv2-only license causing
compatibility problems with libvirt.so which is under the
GPLv2-or-later license.

NB this change prevents use of the VirtualBox driver on the
Windows platform, until such time as libvirtd can be made
to work there.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-16 16:28:53 +01:00
Daniel P. Berrange
d7d7581b03 Fix LXC startup when /var/run is an absolute symlink
During startup, the LXC driver uses paths such as

  /.oldroot/var/run/libvirt/lxc/...

to access directories from the previous root filesystem
after doing a pivot_root(). Unfortunately if /var/run
is an absolute symlink to /run, instead of a relative
symlink to ../run, these paths break.

At least one Linux distro is known to use an absolute
symlink for /var/run, so workaround this, by resolving
all symlinks before doing the pivot_root().

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2013-05-16 16:28:53 +01:00
Osier Yang
e3b40bec42 conf: Fix the bug of disk->copy_on_read formating
The reason for it's not exposed for such long time is that the
enums for VirtioEventIdx and CopyOnReadType have same enum values
and Correspondingstrings. This fixes the bug and adds test.
2013-05-16 23:07:51 +08:00
Ján Tomko
d3842cb4e4 datatypes: fix virGetStoragePool's comment 2013-05-16 16:26:21 +02:00
Ján Tomko
ca697e90d5 daemon: fix leak after listing all volumes
CVE-2013-1962

remoteDispatchStoragePoolListAllVolumes wasn't freeing the pool.
The pool also held a reference to the connection, preventing it from
getting freed and closing the netcf interface driver, which held two
sockets open.
2013-05-16 15:59:37 +02:00
Viktor Mihajlovski
9684bb11fd qemu: Fix crash in migration of graphics-less guests.
Commit 7f15ebc7a2 introduced a bug
happening when guests without a <graphics> element are migrated.
The initialization of listenAddress happens unconditionally
from the cookie even if the cookie->graphics pointer was NULL.
Moved the initialization to where it is safe.

Signed-off-by: Viktor Mihajlovski <mihajlov@linux.vnet.ibm.com>
2013-05-16 15:48:34 +02:00
Jiri Denemark
e13e548fc2 build: Fix check-driverimpls in VPATH
DRIVER_SOURCE_FILES mixes files with absolute path (inherited from
REMOTE_DRIVER_GENERATED) with file paths that are relative to srcdir but
check-driverimpls.pl needs full paths.
2013-05-16 15:45:43 +02:00