]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
9 years agolibxl: don't attempt to resume domain when suspend fails
Jim Fehlig [Wed, 15 Jul 2015 23:29:15 +0000 (17:29 -0600)]
libxl: don't attempt to resume domain when suspend fails

Failure of libxl_domain_suspend() does not leave the domain in
a suspended state, so no need to call libxl_domain_resume(),
which btw will fail with "domain not suspended".

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
9 years agolibxl: fix ref counting of libxlMigrationDstArgs
Jim Fehlig [Wed, 15 Jul 2015 22:35:50 +0000 (16:35 -0600)]
libxl: fix ref counting of libxlMigrationDstArgs

This patch fixes some flawed logic around ref counting the
libxlMigrationDstArgs object.

First, when adding sockets to the event loop with
virNetSocketAddIOCallback(), the generic virObjectFreeCallback()
was registered as a free function, with libxlMigrationDstArgs as
its parameter. A reference was also taken on
libxlMigrationDstArgs for each successful call to
virNetSocketAddIOCallback(). The rational behind this logic was
that the libxlMigrationDstArgs object had to out-live the socket
objects. But virNetSocketAddIOCallback() already takes a
reference on socket objects, ensuring their life until removed
from the event loop and unref'ed in virNetSocketEventFree(). We
only need to ensure libxlMigrationDstArgs lives until
libxlDoMigrateReceive() finishes, which can be done by simply
unref'ing libxlMigrationDstArgs at the end of
libxlDoMigrateReceive().

The second flaw was unref'ing the sockets in the failure path of
libxlMigrateReceive() and at the end of libxlDoMigrateReceive().
As mentioned above, the sockets are already unref'ed by
virNetSocketEventFree() when removed from the event loop.
Attempting to unref the socket a second time resulted in a
libvirtd crash since the socket was previously unref'ed and
disposed.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
9 years agoRevert "lxc: ensure setns() syscall is defined"
Michal Privoznik [Thu, 27 Aug 2015 01:01:17 +0000 (03:01 +0200)]
Revert "lxc: ensure setns() syscall is defined"

After my previous commit this commit is no longer needed.

This reverts commit eff95ac8fce8af47c0948a1c8a654b210633a350.

9 years agolxc_container: Turn lxcAttachNS into calling virProcessSetNamespaces
Michal Privoznik [Thu, 27 Aug 2015 00:59:29 +0000 (02:59 +0200)]
lxc_container: Turn lxcAttachNS into calling virProcessSetNamespaces

Now that virProcessSetNamespaces() does accept FD list in the
correct format, we can simply turn lxcAttachNS into calling
virProcessSetNamespaces().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agolibvirt_lxc: Claim success for --help
Michal Privoznik [Thu, 27 Aug 2015 00:21:54 +0000 (02:21 +0200)]
libvirt_lxc: Claim success for --help

So far, if libvirt_lxc binary (usually to be found under
/usr/libexec/) is run with --help, due to a missing line
and our usual functions pattern, an 'uknown' error is returned.
Yeah, the help is printed out, but we should not claim error.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoutil: Allow virProcessSetNamespaces() to have sparse FD list
Michal Privoznik [Thu, 27 Aug 2015 00:09:54 +0000 (02:09 +0200)]
util: Allow virProcessSetNamespaces() to have sparse FD list

So far, the virProcessSetNamespaces() takes an array of FDs that
it tries to set namespace on. However, in the very next commit
this array may be sparse, having some -1's in it. Teach the
function to cope with that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirt-aa-helper: Improve valid_path
Michal Privoznik [Thu, 27 Aug 2015 00:50:21 +0000 (02:50 +0200)]
virt-aa-helper: Improve valid_path

So, after some movement in virt-aa-helper, I've noticed the
virt-aa-helper-test failing. I've ran gdb (it took me a while to
realize how to do that) and this showed up immediately:

  Program received signal SIGSEGV, Segmentation fault.
  strlen () at ../sysdeps/x86_64/strlen.S:106
  106     ../sysdeps/x86_64/strlen.S: No such file or directory.
  (gdb) bt
  #0  strlen () at ../sysdeps/x86_64/strlen.S:106
  #1  0x0000555555561a13 in array_starts_with (str=0x5555557ce910 "/tmp/tmp.6nI2Fkv0KL/1.img", arr=0x7fffffffd160, size=-1540438016) at security/virt-aa-helper.c:525
  #2  0x0000555555561d49 in valid_path (path=0x5555557ce910 "/tmp/tmp.6nI2Fkv0KL/1.img", readonly=false) at security/virt-aa-helper.c:617
  #3  0x0000555555562506 in vah_add_path (buf=0x7fffffffd3e0, path=0x5555557cb910 "/tmp/tmp.6nI2Fkv0KL/1.img", perms=0x555555581585 "rw", recursive=false) at security/virt-aa-helper.c:823
  #4  0x0000555555562693 in vah_add_file (buf=0x7fffffffd3e0, path=0x5555557cb910 "/tmp/tmp.6nI2Fkv0KL/1.img", perms=0x555555581585 "rw") at security/virt-aa-helper.c:854
  #5  0x0000555555562918 in add_file_path (disk=0x5555557d4440, path=0x5555557cb910 "/tmp/tmp.6nI2Fkv0KL/1.img", depth=0, opaque=0x7fffffffd3e0) at security/virt-aa-helper.c:931
  #6  0x00007ffff78f18b1 in virDomainDiskDefForeachPath (disk=0x5555557d4440, ignoreOpenFailure=true, iter=0x5555555628a6 <add_file_path>, opaque=0x7fffffffd3e0) at conf/domain_conf.c:23286
  #7  0x0000555555562b5f in get_files (ctl=0x7fffffffd670) at security/virt-aa-helper.c:982
  #8  0x0000555555564100 in vahParseArgv (ctl=0x7fffffffd670, argc=5, argv=0x7fffffffd7e8) at security/virt-aa-helper.c:1277
  #9  0x00005555555643d6 in main (argc=5, argv=0x7fffffffd7e8) at security/virt-aa-helper.c:1332

So I've taken look at valid_path() because it is obviously
calling array_starts_with() with malformed @size. And here's the
result: there are two variables to hold the size of three arrays
and their value is recalculated before each call of
array_starts_with(). What if we just use three variables,
initialize them and do not touch them afterwards?

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agolxc: Resolve Coverity RESOURCE_LEAK
John Ferlan [Thu, 27 Aug 2015 10:59:38 +0000 (06:59 -0400)]
lxc: Resolve Coverity RESOURCE_LEAK

Commit id 'c27553b6e' added a return -1 in a failure path without
the necessary VIR_FREE(stack)

9 years agoqemu: Emit correct audit message for memory hot unplug
Luyao Huang [Thu, 13 Aug 2015 14:15:28 +0000 (22:15 +0800)]
qemu: Emit correct audit message for memory hot unplug

https://bugzilla.redhat.com/show_bug.cgi?id=1226234#c3

If the qemu monitor fails to remove the memory from the guest for
any reason, the auditlog message will incorrectly use the current
actual memory (via virDomainDefGetMemoryActual) instead of the
value we were attempting to reduce to. The result is the 'new-mem'
and 'old-mem' values for the auditlog message would be identical.

This patch creates a local 'newmem' which accounts for the current
memory size minus the memory which is being removed. NB, for the
success case this results in the same value that would be returned
by virDomainDefGetMemoryActual without the need to do the math. This
follows the existing code which would subtract the size for cur_balloon.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
9 years agoqemu: Emit correct audit message for memory hot plug
Luyao Huang [Thu, 13 Aug 2015 14:15:27 +0000 (22:15 +0800)]
qemu: Emit correct audit message for memory hot plug

https://bugzilla.redhat.com/show_bug.cgi?id=1226234#c3

Prior to this patch, after successfully hot plugging memory
the audit log indicated that the update failed, e.g.:

type=VIRT_RESOURCE ... old-mem=1024000 new-mem=1548288 \
exe="/usr/sbin/libvirtd" hostname=? addr=? terminal=pts/2 res=failed

This patch will adjust where virDomainAuditMemory is called to
ensure the proper 'ret' value is used based on success or failure.

Additionally, the audit message should include the size of the
memory we were attempting to change to rather than the current
actual size. On failure to add, the message showed the same value
for old-mem and new-mem.

In order to do this, introduce a 'newmem' local which will compute
the new size based on the oldmem size plus the size of memory we
are about to add. NB: This would be the same as calling the
virDomainDefGetMemoryActual again on success, but avoids the
overhead of recalculating. Plus cur_balloon is already adjusted
by the same value, so this follows that.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
9 years agoutils: Remove the logging of errors from virNetDevSendEthtoolIoctl
Moshe Levi [Tue, 18 Aug 2015 20:58:03 +0000 (23:58 +0300)]
utils: Remove the logging of errors from virNetDevSendEthtoolIoctl

This patch remove the logging of errors of ioctl api and instead
let the caller to choose what errors to log

9 years agohostdev: skip ACS check when using VFIO for device assignment
Laine Stump [Wed, 26 Aug 2015 06:04:23 +0000 (02:04 -0400)]
hostdev: skip ACS check when using VFIO for device assignment

The ACS checks are meaningless when using the more modern VFIO driver
for device assignment since VFIO has its own more complete and exact
checks, but I didn't realize that when I added support for VFIO. This
patch eliminates the ACS check when preparing PCI devices for
assignment if VFIO is being used.

This resolves:

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

9 years agolxc: ensure setns() syscall is defined
Daniel P. Berrange [Wed, 26 Aug 2015 14:52:15 +0000 (15:52 +0100)]
lxc: ensure setns() syscall is defined

Older versions of glibc don't provide the setns() syscall
function wrapper, so we must define it ourselves to prevent
build failure on old distros.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoStart daemon only after filesystems are mounted
Martin Kletzander [Tue, 25 Aug 2015 15:07:46 +0000 (17:07 +0200)]
Start daemon only after filesystems are mounted

When images are on mounted filesystems, there is no guarantee libvirtd
will start before they are mounted.  Since we want to start after both
local and remote filesystems are mounted, we need to add both local-fs
and remote-fs as targets that should precede starting libvirtd service.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agovirt-aa-helper: add NVRAM store file for read/write
Peter Kieser [Thu, 20 Aug 2015 17:58:59 +0000 (10:58 -0700)]
virt-aa-helper: add NVRAM store file for read/write

This is a cryptographically signed message in MIME format.

Some UEFI firmwares may want to use a non-volatile memory to store some
variables.
If AppArmor is enabled, and NVRAM store file is set currently
virt-aa-helper does
not add the NVRAM store file to the template. Add this file for
read/write when
this functionality is defined in domain XML.

Signed-off-by: Peter Kieser <peter@kieser.ca>
9 years agoFix link to page for Virtuozzo driver
Sergey Bronnikov [Wed, 26 Aug 2015 11:34:58 +0000 (14:34 +0300)]
Fix link to page for Virtuozzo driver

9 years agolxc: Inherit namespace feature
ik.nitk [Thu, 20 Aug 2015 13:46:17 +0000 (19:16 +0530)]
lxc: Inherit namespace feature

This patch adds feature for lxc containers to inherit namespaces.
This is very similar to what lxc-tools or docker provides.  Look
for "man lxc-start" and you will find that you can pass command
args as [ --share-[net|ipc|uts] name|pid ]. Or check out docker
networking option in which you can give --net=container:NAME_or_ID
as an option for sharing +namespace.

>From this patch you can add extra libvirt option to share
namespace in following way.

 <lxc:namespace>
   <lxc:sharenet type='netns' value='red'/>
   <lxc:shareipc type='pid' value='12345'/>
   <lxc:shareuts type='name' value='container1'/>
 </lxc:namespace>

The netns option is specific to sharenet. It can be used to
inherit from existing network namespace.

Co-authored: Daniel P. Berrange <berrange@redhat.com>

9 years agoqemu: Label correct per-VM path when starting
Martin Kletzander [Tue, 25 Aug 2015 08:57:56 +0000 (10:57 +0200)]
qemu: Label correct per-VM path when starting

Commit f1f68ca33433825ce0deed2d96f1990200bc6618 overused mdir_name()
event though it was not needed in the latest version, hence labelling
directory one level up in the tree and not the one it should.

If anyone with SElinux managed to try run a domain with guest agent set
up, it's highly possible that they will need to run 'restorecon -F
/var/lib/libvirt/qemu/channel/target' to fix what was done.

Reported-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoqemu: Update blkio.weight value after successful set
Luyao Huang [Wed, 19 Aug 2015 03:56:33 +0000 (11:56 +0800)]
qemu: Update blkio.weight value after successful set

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

Make a call virCgroupGetBlkioWeight to re-read blkio.weight right
after it is set in order to keep internal data up-to-date.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
9 years agoRename page about vz driver
Sergey Bronnikov [Fri, 21 Aug 2015 21:44:11 +0000 (00:44 +0300)]
Rename page about vz driver

9 years agodocs: Rename 'parallels' to 'vz'
Sergey Bronnikov [Fri, 21 Aug 2015 21:43:48 +0000 (00:43 +0300)]
docs: Rename 'parallels' to 'vz'

Parallels driver was renamed to Virtuozzo. Replace old name by new
one for libvirt docs and schemas.

9 years agoEliminate incorrect and unnecessary check for changed IP address
Vasiliy Tolstov [Sat, 22 Aug 2015 15:33:15 +0000 (15:33 +0000)]
Eliminate incorrect and unnecessary check for changed IP address

Commit aa2cc7 modified a previously unnecessary but innocuous check
for interface IP address during interface update incorrectly, causing
all attempted updates (e.g. changing link state) to interfaces of
type='ethernet' for QEMU to fail.

This patch fixes the issue by completely removing the check for IP
address, which is pointless since QEMU doesn't support setting
interface IP addresses from the domain interface XML anyway.

Signed-off-by: Vasiliy Tolstov <v.tolstov@selfip.ru>
Signed-off-by: Laine Stump <laine@laine.org>
9 years agovirDomainRename: Extend API documentation
Tomas Meszaros [Tue, 18 Aug 2015 20:22:07 +0000 (22:22 +0200)]
virDomainRename: Extend API documentation

Signed-off-by: Tomas Meszaros <exo@tty.sk>
9 years agoqemu: add a check for nodeset in qemuDomainSetNumaParamsLive
Luyao Huang [Fri, 14 Aug 2015 09:37:28 +0000 (17:37 +0800)]
qemu: add a check for nodeset in qemuDomainSetNumaParamsLive

We will try to set the node to cpuset.mems without check if
it is available, since we already have helper to check this.
Call virNumaNodesetIsAvailable to check if node is available,
then try to change it in the cgroup.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
9 years agoselinux: fix compile errors
Guido Günther [Mon, 24 Aug 2015 12:04:37 +0000 (14:04 +0200)]
selinux: fix compile errors

Remove unused variable, tag unused parameter and adjust return type.

introduced by 3f48345f7ec0c44b8ce2371cab454d2118f830b4

CC     security/libvirt_security_manager_la-security_selinux.lo
security/security_selinux.c: In function 'virSecuritySELinuxDomainSetDirLabel':
security/security_selinux.c:2520:5: error: return makes pointer from integer without a cast [-Werror]
security/security_selinux.c:2514:9: error: unused variable 'ret' [-Werror=unused-variable]
security/security_selinux.c:2509:59: error: unused parameter 'mgr' [-Werror=unused-parameter]

9 years agostorage: only run safezero if allocation is > 0
Guido Günther [Sun, 23 Aug 2015 20:03:54 +0000 (22:03 +0200)]
storage: only run safezero if allocation is > 0

While a zero allocation in safezero should be fine it isn't when we use
posix_fallocate which returns EINVAL on a zero allocation.

While we could skip the zero allocation in safezero_posix_fallocate it's
an optimization to do it for all allocations.

This fixes vm installation via virtinst for me which otherwise aborts
like:

   Starting install...
   Retrieving file linux...               | 5.9 MB     00:01 ...
   Retrieving file initrd.gz...           |  29 MB     00:07 ...
   ERROR    Couldn't create storage volume 'virtinst-linux.sBgds4': 'cannot fill file '/var/lib/libvirt/boot/virtinst-linux.sBgds4': Invalid argument'

The error was introduced by e30297b0 as spotted by Chunyan Liu

9 years agovirt-aa-helper: allow access to /usr/share/ovmf/
intrigeri [Fri, 21 Aug 2015 08:52:52 +0000 (10:52 +0200)]
virt-aa-helper: allow access to /usr/share/ovmf/

We forbid access to /usr/share/, but (at least on Debian-based systems)
the Open Virtual Machine Firmware files needed for booting UEFI virtual
machines in QEMU live in /usr/share/ovmf/. Therefore, we need to add
that directory to the list of read only paths.

A similar patch was suggested by Jamie Strandboge <jamie@canonical.com>
on https://bugs.launchpad.net/ubuntu/+source/libvirt/+bug/1483071.

9 years agovirt-aa-helper: Simplify restriction logic
Guido Günther [Fri, 21 Aug 2015 08:49:15 +0000 (10:49 +0200)]
virt-aa-helper: Simplify restriction logic

First check overrides, then read only files then restricted access
itself.

This allows us to mark files for read only access whose parents were
already restricted for read write.

Based on a proposal by Martin Kletzander

9 years agovirt-aa-helper: document --probing and --dry-run
Guido Günther [Fri, 21 Aug 2015 10:29:25 +0000 (12:29 +0200)]
virt-aa-helper: document --probing and --dry-run

9 years agotests: Use qemuProcessPrepareMonitorChr in qemuxmlnstest
Martin Kletzander [Thu, 13 Aug 2015 09:00:48 +0000 (11:00 +0200)]
tests: Use qemuProcessPrepareMonitorChr in qemuxmlnstest

The output of that function was not tested until now.  In order to keep
the paths in /tmp, the test driver config is "fixed" as well.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoqemu: Fix access to auto-generated socket paths
Martin Kletzander [Fri, 7 Aug 2015 12:42:31 +0000 (14:42 +0200)]
qemu: Fix access to auto-generated socket paths

We are automatically generating some socket paths for domains, but all
those paths end up in a directory that's the same for multiple domains.
The problem is that multiple domains can each run with different
seclabels (users, selinux contexts, etc.).  The idea here is to create a
per-domain directory labelled in a way that each domain can access its
own unix sockets.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agosecurity_dac: Add SetDirLabel support
Martin Kletzander [Mon, 17 Aug 2015 18:15:58 +0000 (11:15 -0700)]
security_dac: Add SetDirLabel support

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agosecurity_selinux: Add SetDirLabel support
Martin Kletzander [Mon, 17 Aug 2015 18:07:07 +0000 (11:07 -0700)]
security_selinux: Add SetDirLabel support

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agosecurity_stack: Add SetDirLabel support
Martin Kletzander [Mon, 17 Aug 2015 18:01:12 +0000 (11:01 -0700)]
security_stack: Add SetDirLabel support

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agosecurity: Add virSecurityDomainSetDirLabel
Martin Kletzander [Mon, 17 Aug 2015 17:43:43 +0000 (10:43 -0700)]
security: Add virSecurityDomainSetDirLabel

That function can be used for setting security labels on arbitrary
directories.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agosecurity_dac: Label non-listening sockets
Martin Kletzander [Thu, 13 Aug 2015 05:36:30 +0000 (07:36 +0200)]
security_dac: Label non-listening sockets

SELinux security driver already does that, but DAC driver somehow missed
the memo.  Let's fix it so it works the same way.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agosecurity_selinux: Use proper structure to access socket data
Martin Kletzander [Thu, 13 Aug 2015 05:35:10 +0000 (07:35 +0200)]
security_selinux: Use proper structure to access socket data

In virSecuritySELinuxSetSecurityChardevLabel() we are labelling unix
socket path, but accessing another structure of the union.  This does
not pose a problem currently as both paths are at the same offset, but
this should be fixed for the future.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agolocking: Remove redundant 'srv' element from virLockDaemon
Erik Skultety [Thu, 20 Aug 2015 14:56:32 +0000 (16:56 +0200)]
locking: Remove redundant 'srv' element from virLockDaemon

Now that we have virNetDaemon object holding all the data and being
capable of referencing multiple servers, having a duplicate reference to
a single server stored in virLockDaemon isn't necessary anymore. This
patch removes the above described element.

9 years agotest: Replace tabs with spaces in virnetdaemondata json files
Erik Skultety [Thu, 6 Aug 2015 13:33:58 +0000 (15:33 +0200)]
test: Replace tabs with spaces in virnetdaemondata json files

JSON data that are used to initialize tests in virnetdaemontest should
be in a consistent format, i.e. not using tabs for indentation, those
should be replaced by spaces.

9 years agotests: Add some compatibility-related cases to the CPU tests
Andrea Bolognani [Fri, 14 Aug 2015 14:45:18 +0000 (16:45 +0200)]
tests: Add some compatibility-related cases to the CPU tests

9 years agocpu: Move check for NULL CPU model inside the driver
Andrea Bolognani [Fri, 14 Aug 2015 14:04:18 +0000 (16:04 +0200)]
cpu: Move check for NULL CPU model inside the driver

While the check is appropriate for eg. the x86 and generic drivers,
there are some valid ppc64 guest configurations where the CPU
model is supposed to be NULL.

Moving this check from the generic code to the drivers makes it
possible to accomodate both use cases.

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

9 years agocpu: Better support for ppc64 compatibility modes
Andrea Bolognani [Thu, 13 Aug 2015 15:50:37 +0000 (17:50 +0200)]
cpu: Better support for ppc64 compatibility modes

Not all combinations of host CPU models and compatibility modes
are valid, so we need to make sure we don't try to do something
that QEMU will reject.

Moreover, we need to apply a different logic to guests using
host-model and host-passthrough modes when testing them for host
compatibility.

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

9 years agocpu: Don't update host-model guest CPUs on ppc64
Andrea Bolognani [Thu, 13 Aug 2015 11:40:12 +0000 (13:40 +0200)]
cpu: Don't update host-model guest CPUs on ppc64

If a guest CPU is defined using

  <cpu mode='host-model'/>

the <model> sub-element will contain the compatibility mode to use.
That means we can't just copy the host CPU model on cpuUpdate(),
otherwise we'll overwrite that information and migration of such
guests will fail.

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

9 years agoAdd generated libvirt_admin.syms into .gitignore
Martin Kletzander [Thu, 20 Aug 2015 18:03:12 +0000 (11:03 -0700)]
Add generated libvirt_admin.syms into .gitignore

Commit a2c5d16a70a6161449c687be74db2813b362cf5e switched to generating
libvirt_admin.syms, but forgot to add the generated file into
.gitignore, hence causing tree pollution post-build.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoconf: Check for attach disk usage of iothread=0
John Ferlan [Wed, 12 Aug 2015 19:02:47 +0000 (15:02 -0400)]
conf: Check for attach disk usage of iothread=0

Since iothreadid = 0 is invalid, we need to check for it when attempting
to add a disk; otherwise, someone would think/believe their attempt to
add an IOThread to the disk would succeed. Luckily other code ignored
things when ->iothread == 0...

9 years agodocs: Drop unused rule for internals/%.html.tmp target
Guido Günther [Wed, 19 Aug 2015 10:35:31 +0000 (12:35 +0200)]
docs: Drop unused rule for internals/%.html.tmp target

We're using the %.html.tmp for all html files now so drop the unused one
and rather make sure the needed directory exists.

This fixes build failures as described in

    https://www.redhat.com/archives/libvir-list/2015-August/msg00603.html

9 years agolibvirt-admin: Generate symbols file
Guido Günther [Wed, 19 Aug 2015 08:38:31 +0000 (10:38 +0200)]
libvirt-admin: Generate symbols file

Since we're linking this into libvirtd we need some symbols to be public
but not part of the public API so mark them as
LIBVIRT_ADMIN_PRIVATE_<VERSION> as we do with libvirt.

Making all other symbols local makes sure we don't accidentally leak
unwanted ones.

9 years agodaemon: Use $(NULL) for libvird_admin's flags
Guido Günther [Wed, 19 Aug 2015 08:27:25 +0000 (10:27 +0200)]
daemon: Use $(NULL) for libvird_admin's flags

This makes it consistent with the other FLAGS in this file and reduced
clutter in the diff when adding new entries.

9 years agoutil: fix build without cgroup
Roman Bogorodskiy [Thu, 20 Aug 2015 06:42:56 +0000 (09:42 +0300)]
util: fix build without cgroup

Commit 89c509a0 added getters for cgroup block device I/O throttling,
however stub versions of these functions have not matching function
prototypes that result in compilation fail on platforms not supporting
cgroup.

Fix build by correcting prototypes of the stubbed functions.

Pushing under build-breaker rule.

9 years agovirconf: correct code formatting
Cao jin [Mon, 17 Aug 2015 12:42:03 +0000 (20:42 +0800)]
virconf: correct code formatting

Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
9 years agovirConfWalk: fix the inconsistent name
Cao jin [Wed, 19 Aug 2015 02:36:28 +0000 (10:36 +0800)]
virConfWalk: fix the inconsistent name

Fix inconsistency between function description and actual
parameter name.

Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
9 years agoqemu: Report better error message when renaming to existing domain name
Martin Kletzander [Tue, 18 Aug 2015 18:22:02 +0000 (11:22 -0700)]
qemu: Report better error message when renaming to existing domain name

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoqemu: Sync BlkioDevice values when setting them in cgroups
Martin Kletzander [Mon, 3 Aug 2015 13:56:20 +0000 (15:56 +0200)]
qemu: Sync BlkioDevice values when setting them in cgroups

The problem here is that there are some values that kernel accepts, but
does not set them, for example 18446744073709551615 which acts the same
way as zero.  Let's do the same thing we do with other tuning options
and re-read them right after they are set in order to keep our internal
structures up-to-date.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agolxc: Sync BlkioDevice values when setting them in cgroups
Martin Kletzander [Mon, 3 Aug 2015 13:56:08 +0000 (15:56 +0200)]
lxc: Sync BlkioDevice values when setting them in cgroups

The problem here is that there are some values that kernel accepts, but
does not set them, for example 18446744073709551615 which acts the same
way as zero.  Let's do the same thing we do with other tuning options
and re-read them right after they are set in order to keep our internal
structures up-to-date.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoutil: Add getters for cgroup block device I/O throttling
Martin Kletzander [Mon, 3 Aug 2015 13:10:20 +0000 (15:10 +0200)]
util: Add getters for cgroup block device I/O throttling

Since now they were not needed, but I sense they will be in a short
while.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoutil: Add virCgroupGetBlockDevString
Martin Kletzander [Mon, 3 Aug 2015 12:44:14 +0000 (14:44 +0200)]
util: Add virCgroupGetBlockDevString

This function translates device paths to "major:minor " string, and all
virCgroupSetBlkioDevice* functions are modified to use it.  It's a
cleanup with no functional change.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoutil: Add virStringGetFirstWithPrefix
Martin Kletzander [Mon, 3 Aug 2015 12:03:23 +0000 (14:03 +0200)]
util: Add virStringGetFirstWithPrefix

That function takes string list and returns first string in that list
that starts with the @prefix parameter with that prefix being skipped as
the caller knows what it starts with (also for easier manipulation in
future).

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoqemuDomainRename: Don't leave a domain locked uppon fail
Michal Privoznik [Tue, 18 Aug 2015 18:40:56 +0000 (20:40 +0200)]
qemuDomainRename: Don't leave a domain locked uppon fail

Well, yet again one case of 'goto cleanup' while 'goto endjob'
was needed. Sorry.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemu: Add check for invalid iothread_id in qemuDomainChgIOThread
John Ferlan [Thu, 13 Aug 2015 13:19:01 +0000 (09:19 -0400)]
qemu: Add check for invalid iothread_id in qemuDomainChgIOThread

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

Since iothread_id == 0 is an invalid value for QEMU let's point
that out specifically.  For the IOThreadDel code, the failure would
have ended up being a failure to find the IOThread ID; however, for
the IOThreadAdd code - an IOThread 0 was added and that isn't good.

It seems during many reviews/edits to the code the check for
iothread_id = 0 being invalid was lost - it could have originally
been in the API code, but requested to be moved - I cannot remember.

9 years agoapi: Adjust comment for virDomainAddIOThread
John Ferlan [Thu, 13 Aug 2015 13:18:48 +0000 (09:18 -0400)]
api: Adjust comment for virDomainAddIOThread

The comment for the function indicated that iothread_id had to be
a positive non-zero value; however, that wasn't checked - that is
a value of 0 is/was allowed by the API and was left up to the
hypervisor to reject the value.

More than likely this nuance was missed during the many "adjustments"
to the API in the review phase.

9 years agoapi: Remove check on iothread_id arg in virDomainPinIOThread
John Ferlan [Thu, 13 Aug 2015 12:44:32 +0000 (08:44 -0400)]
api: Remove check on iothread_id arg in virDomainPinIOThread

Allow 0 as an iothread_id and force the hypervisor to handle.
The qemuDomainPinIOThread API will look up the iothread_id of
0 and not find it and message that anyway.

9 years agoqemuDomainAddCgroupForThread: Don't overwrite the error
Luyao Huang [Fri, 14 Aug 2015 06:59:54 +0000 (14:59 +0800)]
qemuDomainAddCgroupForThread: Don't overwrite the error

Just like in commit 704cf06, if virCgroup*() fails, the error is
already reported. There's no need to overwrite the error with a
generic one and possibly hiding the true root cause of the error.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
9 years agovirconf: fix the inconsistent name
Cao jin [Tue, 18 Aug 2015 12:38:07 +0000 (20:38 +0800)]
virconf: fix the inconsistent name

Fix inconsistency between function description and actual
parameter name in virConfGetValue/virConfSetValue.

Signed-off-by: Cao jin <caoj.fnst@cn.fujitsu.com>
9 years agovirsh: Reset global error after successfull domain lookup
Luyao Huang [Mon, 17 Aug 2015 09:56:48 +0000 (17:56 +0800)]
virsh: Reset global error after successfull domain lookup

When looking up a domain, we try to look up by ID, UUID and NAME
consequently while not really caring which of those lookups succeeds.
The problem is that if any of them fails, we dispatch the error from the
driver and that means setting both threadlocal and global error. Let's
say the last lookup (by NAME) succeeds and resets the threadlocal error as any
other API does, however leaving the global error unchanged. If the underlying
virsh command does not succeed afterwards, our cleanup routine in
vshCommandRun ensures that no libvirt error will be forgotten and that's
exactly where this global error comes in incorrectly.

 # virsh domif-setlink 123 vnet1 up
 error: interface (target: vnet1) not found
 error: Domain not found: no domain with matching id 123

This patch also resets the global error which would otherwise cause some
minor confusion in reported error messages.

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

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Erik Skultety <eskultet@redhat.com>
9 years agobuild: fix mingw build
Eric Blake [Mon, 17 Aug 2015 23:03:40 +0000 (16:03 -0700)]
build: fix mingw build

Ever since commit e44b0269, 64-bit mingw compilation fails with:

../../src/util/virprocess.c: In function 'virProcessGetPids':
../../src/util/virprocess.c:628:50: error: passing argument 4 of 'virStrToLong_i' from incompatible pointer type [-Werror=incompatible-pointer-types]
         if (virStrToLong_i(ent->d_name, NULL, 10, &tmp_pid) < 0)
                                                  ^
In file included from ../../src/util/virprocess.c:59:0:
../../src/util/virstring.h:53:5: note: expected 'int *' but argument is of type 'pid_t * {aka long long int *}'
 int virStrToLong_i(char const *s,
     ^
cc1: all warnings being treated as errors

Although mingw won't be using this function, it does compile the
file, and the fix is relatively simple.

* src/util/virprocess.c (virProcessGetPids): Don't assume pid_t
fits in int.

Signed-off-by: Eric Blake <eblake@redhat.com>
9 years agoqemuDomainRename: Explicitly check if domain is renaming to itself
Michal Privoznik [Fri, 14 Aug 2015 13:36:05 +0000 (15:36 +0200)]
qemuDomainRename: Explicitly check if domain is renaming to itself

It may happen that user (mistakenly) wants to rename a domain to
itself. Which is no renaming at all. We should reject that with
some meaningful error message.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirHashAddEntry: Report error on duplicate key
Michal Privoznik [Mon, 17 Aug 2015 19:01:07 +0000 (21:01 +0200)]
virHashAddEntry: Report error on duplicate key

If this function fails, the error message is reported only in
some cases (e.g. OOM), but in some it's not (e.g. duplicate key).
This fact is painful and we should either not report error at all
or report the error in all possible cases. I vote for the latter.
Unfortunately, since the key may be an arbitrary value (not
necessarily a string) we can't report it in the error message.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirHashAddOrUpdateEntry: Turn @new_name into void *
Michal Privoznik [Mon, 17 Aug 2015 19:07:40 +0000 (21:07 +0200)]
virHashAddOrUpdateEntry: Turn @new_name into void *

In 9190f0b0 we've tried to fix an OOM. And boy, was that fix
successful. But back then, the hash table implementation worked
strictly over string keys, which is not the case anymore. Hash
table have this function keyCopy() which returns void *.
Therefore a local variable that is temporarily holding the
intermediate return value from that function should be void *
too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agolibvirt-domain: forbid use virDomainRename in readonly connection
Luyao Huang [Mon, 17 Aug 2015 05:22:00 +0000 (13:22 +0800)]
libvirt-domain: forbid use virDomainRename in readonly connection

This function will change the guest name, we shouldn't
allow the readonly user do this.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
9 years agovirsh: fix always return false in domrename
Luyao Huang [Mon, 17 Aug 2015 05:21:59 +0000 (13:21 +0800)]
virsh: fix always return false in domrename

Signed-off-by: Luyao Huang <lhuang@redhat.com>
9 years agoqemu: Resolve Coverity UNINIT
John Ferlan [Sat, 15 Aug 2015 13:15:42 +0000 (09:15 -0400)]
qemu: Resolve Coverity UNINIT

Coverity complained that 'vm' wasn't initialized before jumping to
cleanup: and calling virDomainObjEndAPI if the VIR_STRDUP fails.
So I initialized vm = NULL and also moved the VIR_STRDUP closer to
usage and used endjob for goto. Lots of other reasons for failures.

9 years agoprotocol: Don't use rename as a variable name
Martin Kletzander [Sat, 15 Aug 2015 14:44:38 +0000 (16:44 +0200)]
protocol: Don't use rename as a variable name

That causes shadowing errors on older compilers.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoRemove static keyword from vshReadline when readline does not exist
Moshe Levi [Sat, 15 Aug 2015 07:59:41 +0000 (10:59 +0300)]
Remove static keyword from vshReadline when readline does not exist

This patch removes the static keyword from the vshReadline which was
introduced in commit 834c5720e4434f0bcc807bb1cf20855af63e24a3. With
readline the vshReadline function is not static but when compiling
without readline it was defined as static which caused compilation
error.

9 years agotools: Introduce new client generic module vsh
Erik Skultety [Mon, 15 Jun 2015 16:53:58 +0000 (18:53 +0200)]
tools: Introduce new client generic module vsh

In order to share as much virsh' logic as possible with upcomming
virt-admin client we need to split virsh logic into virsh specific and
client generic features.

Since majority of virsh methods should be generic enough to be used by
other clients, it's much easier to rename virsh specific data to virshX
than doing this vice versa. It moved generic virsh commands (including info
and opts structures) to generic module vsh.c.

Besides renaming methods and structures, this patch also involves introduction
of a client specific control structure being referenced as private data in the
original control structure, introduction of a new global vsh Initializer,
which currently doesn't do much, but there is a potential for added
functionality in the future.
Lastly it introduced client hooks which are especially necessary during
client connecting phase.

9 years agoqemu: Implement virDomainRename
Tomas Meszaros [Mon, 10 Aug 2015 19:59:18 +0000 (21:59 +0200)]
qemu: Implement virDomainRename

Currently supports only renaming inactive domains without snapshots.

Signed-off-by: Tomas Meszaros <exo@tty.sk>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoIntroduce new VIR_DOMAIN_EVENT_DEFINED_RENAMED event
Tomas Meszaros [Mon, 10 Aug 2015 19:59:17 +0000 (21:59 +0200)]
Introduce new VIR_DOMAIN_EVENT_DEFINED_RENAMED event

This should be emitted whenever a domain is renamed.

Signed-off-by: Tomas Meszaros <exo@tty.sk>
9 years agodomain_conf: Introducde virDomainObjListRenameAddNew() & virDomainObjListRenameRemove()
Tomas Meszaros [Mon, 10 Aug 2015 19:59:16 +0000 (21:59 +0200)]
domain_conf: Introducde virDomainObjListRenameAddNew() & virDomainObjListRenameRemove()

We just need to update the entry in the second hash table. Since commit 8728a56
we have two hash tables for the domain list so that we can do O(1) lookup
regardless of looking up by UUID or name. Since with renaming a domain UUID does
not change, we only need to update the second hash table, where domains are
referenced by their name.

We will call both functions from the qemuDomainRename().

Signed-off-by: Tomas Meszaros <exo@tty.sk>
9 years agovirsh: Implement "domrename" command
Tomas Meszaros [Mon, 10 Aug 2015 19:59:15 +0000 (21:59 +0200)]
virsh: Implement "domrename" command

This patch implements new virsh command, domrename.

Using domrename, it will be possible to rename domain from the virsh shell by
calling virRenameDomain API.

It takes two arguments, current domain name and new domain name.

Example:

virsh # list --all
 Id    Name                           State
 ----------------------------------------------------
  -     bar                            shut off

virsh # domrename bar foo
Domain successfully renamed

virsh # list --all
 Id    Name                           State
 ----------------------------------------------------
  -     foo                            shut off

virsh #

Signed-off-by: Tomas Meszaros <exo@tty.sk>
9 years agoIntroduce virDomainRename API
Tomas Meszaros [Mon, 10 Aug 2015 19:59:14 +0000 (21:59 +0200)]
Introduce virDomainRename API

Also, among with this new API new ACL that restricts rename
capability is invented too.

Signed-off-by: Tomas Meszaros <exo@tty.sk>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoDetect location of qemu-bridge-helper
Guido Günther [Thu, 13 Aug 2015 10:20:29 +0000 (12:20 +0200)]
Detect location of qemu-bridge-helper

RedHat and Debian based distros use different locations

Reference: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=790935

9 years agoCheck if qemu-bridge-helper exists and is executable
Guido Günther [Thu, 13 Aug 2015 12:19:50 +0000 (14:19 +0200)]
Check if qemu-bridge-helper exists and is executable

Otherwise the error is just

    error: Failed to create domain from test1.xml
    error: failed to retrieve file descriptor for interface: Transport endpoint is not connected

since we don't get a sensible error after the fork.

9 years agoconf: Remove 'vmdef' from virDomainHostdevDefParseXML
John Ferlan [Fri, 19 Jun 2015 19:03:50 +0000 (15:03 -0400)]
conf: Remove 'vmdef' from virDomainHostdevDefParseXML

Since it's not used, let's remove it to avoid any future usage.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Use numad information when getting pin information
Martin Kletzander [Sun, 26 Jul 2015 16:49:02 +0000 (18:49 +0200)]
qemu: Use numad information when getting pin information

Pinning information returned for emulatorpin and vcpupin calls is being
returned from our data without querying cgroups for some time.  However,
not all the data were utilized.  When automatic placement is used the
information is not returned for the calls mentioned above.  Since the
numad hint in private data is properly saved/restored, we can safely use
it to return true information.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoqemu: Keep numad hint after daemon restart
Martin Kletzander [Fri, 24 Jul 2015 14:06:33 +0000 (16:06 +0200)]
qemu: Keep numad hint after daemon restart

The numad hint stored in priv->autoNodeset is information that gets lost
during daemon restart.  And because we would like to use that
information in the future, we also need to save it in the status XML.
For the sake of tests, we need to initialize nnumaCell_max to some
value, so that the restoration doesn't fail in our test suite.  There is
no need to fill in the actual numa cell data since the recalculating
function virCapabilitiesGetCpusForNodemask() will not fail, it will just
skip filling the data in the bitmap which we don't use in tests anyway.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoconf: Pass private data to Parse function of XML options
Martin Kletzander [Fri, 24 Jul 2015 17:35:00 +0000 (19:35 +0200)]
conf: Pass private data to Parse function of XML options

This needs a reorder of XML option definitions.  It might come in handy
one day.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoqemu: Fix segfault when parsing private domain data
Martin Kletzander [Thu, 13 Aug 2015 08:03:12 +0000 (10:03 +0200)]
qemu: Fix segfault when parsing private domain data

When parsing private domain data, there are two paths that are flawed.
They are both error paths, just from different parts of the function.
One of them can call free() on an uninitialized pointer.  Initialization
to NULL is enough here.  The other one is a bit trickier to explain, but
as easy as the first one to fix.  We create capabilities, parse them and
then assign them into the private data pointer inside the domain object.
If, however, we get to fail from now on, the error path calls unrefs the
capabilities and then, when the domain object is being cleaned,
qemuDomainObjPrivateFree() tries to unref them as well.  That causes a
segfault.  Settin the pointer to NULL upon successful addition to the
private data is enough.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoconf: Check for hostdev conflicts when assign default disk address
John Ferlan [Mon, 22 Jun 2015 19:13:39 +0000 (15:13 -0400)]
conf: Check for hostdev conflicts when assign default disk address

https://bugzilla.redhat.com/show_bug.cgi?id=1210587  (completed)

When generating the default drive address for a SCSI <disk> device,
check the generated address to ensure it doesn't conflict with a SCSI
<hostdev> address. The <disk> address generation algorithm uses the
<target> "dev" name in order to determine which controller and unit
in order to place the device. Since a SCSI <hostdev> device doesn't
require a target device name, its placement on the guest SCSI address
"could" conflict.  For instance, if a SCSI <hostdev> exists at
controller=0 unit=0 and an attempt to hotplug 'sda' into the guest
made, there would be a conflict if the <hostdev> is already using
/dev/sda.

9 years agoconf: Create locals for virDomainDiskDefAssignAddress
John Ferlan [Thu, 16 Jul 2015 15:29:03 +0000 (11:29 -0400)]
conf: Create locals for virDomainDiskDefAssignAddress

Create local controller/bus variables to be used by a future patch

9 years agoconf: Add SCSI hostdev check for disk drive address already in use
John Ferlan [Wed, 12 Aug 2015 19:30:45 +0000 (15:30 -0400)]
conf: Add SCSI hostdev check for disk drive address already in use

https://bugzilla.redhat.com/show_bug.cgi?id=1210587  (partial)

If a SCSI subsystem <hostdev> element address is provided, we need to
make sure the address provided doesn't conflict with an existing or
libvirt generated address for a SCSI <disk> element. We can handle
this condition in device post processing since we're not generating an
address based on some target name - rather it's either generated based
on space or provided from the user. If the user provides one that conflicts,
then we need to disallow the change.

This will fix the issue where the domain XML provided an <address> for
the <hostdev>, but not the <disk> element where the address provided
ends up being the same address used for the <disk>. A <disk> address
is generated using it's assigned <target> 'dev' name prior to the
check/validation of the <hostdev> address value.

9 years agoDrive hot-unplug: reliable parsing of HMP results
Frank Schreuder [Mon, 10 Aug 2015 15:37:30 +0000 (17:37 +0200)]
Drive hot-unplug: reliable parsing of HMP results

Hot-unplugging a disk from a guest that supports hot-unplugging generates an error
in the libvirt log when running QEMU with the "-msg timestamp=on" flag.

2015-08-06 10:48:59.945+0000: 11662: error : qemuMonitorTextDriveDel:2594 :
operation failed: deleting drive-virtio-disk4 drive failed:
2015-08-06T10:48:59.945058Z Device 'drive-virtio-disk4' not found

This error is caused because the HMP results are getting prefixed with a timestamp.
Parsing the output is not reliable with STRPREFIX as the results can be prefixed with a timestamp.

Using strstr ensures that parsing the output works whether the results are prefixed or not.

Cc: Stefan Hajnoczi <stefanha@redhat.com>
Cc: Daniel P. Berrange <berrange@redhat.com>
Signed-off-by: Frank Schreuder <fschreuder@transip.nl>
9 years agoRevert "qemu: Allow to plug virtio-net-pci into PCIe slot"
Laine Stump [Tue, 11 Aug 2015 23:07:53 +0000 (19:07 -0400)]
Revert "qemu: Allow to plug virtio-net-pci into PCIe slot"

This reverts commit ede34470fde19c0f326cdb0dfca39fa86fd9ec16, which
was apparently written based on testing performed before commits
1e15be1 and 9a12b6 were pushed upstream. Once those two patches are in
place, commit ede34470 is redundant, and can even cause
incorrect/unexpected behavior when auto-assigning addresses for
virtio-net devices.

9 years agocmdAttachInterface: Fully implement @floor support
Michal Privoznik [Wed, 12 Aug 2015 08:38:12 +0000 (10:38 +0200)]
cmdAttachInterface: Fully implement @floor support

In my previous commit d7f5c88961b52 I tried to introduce support
for inbound.floor. But the code change was incomplete. This is
the change needed to fully enable the feature.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agonetworkBandwidthGenericChecks: Drop useless check
Michal Privoznik [Wed, 12 Aug 2015 08:34:39 +0000 (10:34 +0200)]
networkBandwidthGenericChecks: Drop useless check

There's a check right at the beginning of the function that
shortcuts if the function was called over all NULL arguments.
However, this was meant just as a fool-proof check so that we
don't crash if function is used in a bad manner. Anyway, it makes
Coverity unhappy as it then thinks any of the arguments could be
NULL. Well, with the current state of the code it can't.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agonetworkBandwidthUpdate: Don't blindly dereference pointers
Michal Privoznik [Wed, 12 Aug 2015 08:25:48 +0000 (10:25 +0200)]
networkBandwidthUpdate: Don't blindly dereference pointers

It may happen that an interface don't have any bandwidth set and
a new one is to be set. In that case, @ifaceBand will be NULL.
This will cause troubles later in the code when deciding what to
do.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirsh: Refactor parseRateStr to avoid false-positive uninitialized variable
Peter Krempa [Wed, 12 Aug 2015 05:31:33 +0000 (07:31 +0200)]
virsh: Refactor parseRateStr to avoid false-positive uninitialized variable

Commit 6983d6d2 tried to improve parseRateStr but broke the build
instead for compilers that were not able to properly introspect the for
loop indexed by the enum resulting into the following error:

virsh-domain.c: In function 'parseRateStr':
virsh-domain.c:916:13: error: 'field_name' may be used uninitialized in this function [-Werror=maybe-uninitialized]
             vshError(ctl, _("malformed %s field"), field_name);
             ^
virsh-domain.c:915:13: error: 'tmp' may be used uninitialized in this function [-Werror=maybe-uninitialized]
         if (virStrToLong_ullp(token, NULL, 10, tmp) < 0) {
             ^
Rather than trying to fix the code, refactor the function again by
reusing virStringSplit.

9 years agodomain: Fix crash if trying to live update disk <serial>
Cole Robinson [Mon, 10 Aug 2015 23:01:43 +0000 (19:01 -0400)]
domain: Fix crash if trying to live update disk <serial>

If you pass <disk><serial> XML to UpdateDevice, and the original device
didn't have a <serial> block, libvirtd crashes trying to read the original
NULL serial string.

Use _NULLABLE string comparisons to avoid the crash. A couple other
properties needed the change too.

9 years agoqemu: fix qemuDomainSupportsPCI() for ARM machines of "virt" machinetype
Laine Stump [Tue, 11 Aug 2015 18:56:21 +0000 (14:56 -0400)]
qemu: fix qemuDomainSupportsPCI() for ARM machines of "virt" machinetype

Commit e8d5517 updated the domain post-parse to automatically add
pcie-root et al for certain ARM "virt" machinetypes, but didn't update
the function qemuDomainSupportsPCI() which is called later on when we
are auto-assigning PCI addresses and default settings for the PCI
controller <model> and <target> attributes. The result was that PCI
addresses weren't assigned, and the controllers didn't have their
attribute default values set, leading to an error when the domain was
started, e.g.:

  internal error: autogenerated dmi-to-pci-bridge options not set

This patch adds the same check made in the earlier patch to
qemuDomainSupportsPCI(), so that PCI address auto-assignment and
target/model default values will be set.

9 years agovirNetSocketCheckProtocols: handle EAI_NONAME as IPv6 unavailable
Guido Günther [Tue, 11 Aug 2015 09:49:18 +0000 (11:49 +0200)]
virNetSocketCheckProtocols: handle EAI_NONAME as IPv6 unavailable

When running the test suite using "unshare -n" we might have IPv6 but no
configured addresses. Due to AI_ADDRCONFIG getaddrinfo then fails with
EAI_NONAME which we should then treat as IPv6 unavailable.

9 years agoutil: don't overwrite stack when getting ethtool gfeatures
Laine Stump [Tue, 11 Aug 2015 17:45:46 +0000 (13:45 -0400)]
util: don't overwrite stack when getting ethtool gfeatures

This fixes the crash described here:

 https://www.redhat.com/archives/libvir-list/2015-August/msg00162.html

In short, we were calling ioctl(SIOCETHTOOL) pointing to a too-short
object that was a local on the stack, resulting in the memory past the
end of the object being overwritten. This was because the struct used
by the ETHTOOL_GFEATURES command of SIOCETHTOOL ends with a 0-length
array, but we were telling ethtool that it could use 2 elements on the
array.

The fix is to allocate the necessary memory with VIR_ALLOC_VAR(),
including the extra length needed for a 2 element array at the end.

9 years agocpu: Fix segfault in the ppc64 driver
Andrea Bolognani [Tue, 11 Aug 2015 15:51:28 +0000 (17:51 +0200)]
cpu: Fix segfault in the ppc64 driver

Commit adb865d introduced some changes in ppc64DriverNodeData()
that cause libvirtd to crash on startup unless this patch is
applied as well.