]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/log
people/liuw/libxenctrl-split/libvirt.git
9 years agoqemuDomainUpdateDeviceConfig: Allow startupPolicy update, yet again
Michal Privoznik [Mon, 14 Sep 2015 10:59:53 +0000 (12:59 +0200)]
qemuDomainUpdateDeviceConfig: Allow startupPolicy update, yet again

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

So, in 11e058ca589808bd I've tried to make UpdateDevice update
startupPolicy too. And it worked well until somebody came around
and pushed d0dc6c036914da which accidentally removed my
contribution. Redo my commit.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemu: Fix some corner cases in persistent migration
Jiri Denemark [Thu, 10 Sep 2015 22:14:59 +0000 (00:14 +0200)]
qemu: Fix some corner cases in persistent migration

When persistently migrating a domain to a destination host where the
same domain already exists (i.e., it is persistent and shutdown at the
destination), we would happily throw away the original persistent
definition without properly freeing it. And when updating the definition
fails for some reason we don't properly revert to the original state
leaving the domain broken.

In addition to fixing these issues, the patch also makes sure the domain
definition parsed from a migration cookie is either used or freed.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Queue events in migration Finish phase ASAP
Jiri Denemark [Tue, 7 Jul 2015 13:54:39 +0000 (15:54 +0200)]
qemu: Queue events in migration Finish phase ASAP

For quite a long time we don't need to postpone queueing events until
the end of the function since we no longer have the big driver lock.
Let's make the code of qemuMigrationFinish simpler by queuing events at
the time we generate them.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemuDomainEventQueue: Check if event is non-NULL
Jiri Denemark [Tue, 7 Jul 2015 13:33:53 +0000 (15:33 +0200)]
qemuDomainEventQueue: Check if event is non-NULL

Every single call to qemuDomainEventQueue() uses the following pattern:

    if (event)
        qemuDomainEventQueue(driver, event);

Let's move the check for valid event to qemuDomainEventQueue and
simplify all callers.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Don't report false errors in migration protocol v2
Jiri Denemark [Tue, 7 Jul 2015 13:29:10 +0000 (15:29 +0200)]
qemu: Don't report false errors in migration protocol v2

Finish is the final state in v2 of our migration protocol. If something
fails, we have no option to abort the migration and resume the original
domain. Non fatal errors (such as failure to start guest CPUs or make
the domain persistent) has to be treated as success. Keeping the domain
running while reporting the failure was just asking for trouble.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Kill domain when migration finish fails
Jiri Denemark [Tue, 7 Jul 2015 12:42:42 +0000 (14:42 +0200)]
qemu: Kill domain when migration finish fails

Whenever something fails during incoming migration in Finish phase
before we started guest CPUs, we need to kill the domain in addition to
reporting the failure.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Don't fail migration on save status failure
Jiri Denemark [Tue, 7 Jul 2015 12:15:31 +0000 (14:15 +0200)]
qemu: Don't fail migration on save status failure

When we save status XML at the point during migration where we have
already started the domain on destination, we can't really go back and
abort migration. Thus the only thing we can do is to log a warning and
report success.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Simplify qemuMigrationFinish
Jiri Denemark [Tue, 7 Jul 2015 12:11:58 +0000 (14:11 +0200)]
qemu: Simplify qemuMigrationFinish

Offline migration is quite special because we don't really need to do
anything but make the domain persistent. Let's do it separately from
normal migration to avoid cluttering the code with
!(flags & VIR_MIGRATE_OFFLINE).

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Split qemuMigrationFinish
Jiri Denemark [Tue, 7 Jul 2015 10:11:37 +0000 (12:11 +0200)]
qemu: Split qemuMigrationFinish

Separate code which makes incoming domain persistent into
qemuMigrationPersist.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agolibxl: fix AttachDeviceConfig on hostdev type
Chunyan Liu [Thu, 17 Sep 2015 05:15:22 +0000 (01:15 -0400)]
libxl: fix AttachDeviceConfig on hostdev type

After attach-device a <hostdev> with --config, new device doesn't
show up in dumpxml and in guest.

To fix that, set dev->data.hostdev = NULL after work so that the
pointer is not freed, since vmdef has the pointer and still need it.

Signed-off-by: Chunyan Liu <cyliu@suse.com>
9 years agovmx: Expose datacenter path in domain XML
Matthias Bolte [Fri, 11 Sep 2015 10:00:47 +0000 (12:00 +0200)]
vmx: Expose datacenter path in domain XML

Tool such as libguestfs need the datacenter path to get access to disk
images. The ESX driver knows the correct datacenter path, but this
information cannot be accessed using libvirt API yet. Also, it cannot
be deduced from the connection URI in a robust way.

Expose the datacenter path in the domain XML as <vmware:datacenterpath>
node similar to the way the <qemu:commandline> node works. The new node
is ignored while parsing the domain XML. In contrast to <qemu:commandline>
it is output only.

9 years agovirfile: Check for existence of dir in virFileDeleteTree
John Ferlan [Tue, 15 Sep 2015 20:33:36 +0000 (16:33 -0400)]
virfile: Check for existence of dir in virFileDeleteTree

Commit id 'f1f68ca33' added code to remove the directory paths for
auto-generated sockets, but that code could be called before the
paths were created resulting in generating error messages from
virFileDeleteTree indicating that the file doesn't exist.

Rather than "enforce" all callers to make the non-NULL and existence
checks, modify the virFileDeleteTree API to silently ignore NULL on
input and non-existent directory trees.

9 years agovirsh: Teach attach-interface to --print-xml
Michal Privoznik [Mon, 7 Sep 2015 10:13:47 +0000 (12:13 +0200)]
virsh: Teach attach-interface to --print-xml

We have the same argument to many other commands that produce an
XML based on what user typed. But unfortunately attach-interface
was missing it. Maybe nobody had needed it yet. Well, I did
just now.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemu: Fix using guest architecture as lookup key
Andrea Bolognani [Tue, 15 Sep 2015 13:58:09 +0000 (15:58 +0200)]
qemu: Fix using guest architecture as lookup key

When looking for a QEMU binary suitable for running ppc64le guests
we have to take into account the fact that we use the QEMU target
as key for the hash, so direct comparison is not good enough.

Factor out the logic from virQEMUCapsFindBinaryForArch() to a new
virQEMUCapsFindTarget() function and use that both when looking
for QEMU binaries available on the system and when looking up
QEMU capabilities later.

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

9 years agolibxl: fix compiler error introduced by commit ba25c214
Jim Fehlig [Wed, 16 Sep 2015 03:10:59 +0000 (21:10 -0600)]
libxl: fix compiler error introduced by commit ba25c214

libxl/libxl_conf.c: In function 'libxlDriverConfigNew':
libxl/libxl_conf.c:1560:30: error: 'log_level' may be used uninitialized
in this function [-Werror=maybe-uninitialized]

9 years agolibxl: open libxl log stream with libvirtd log_level
Jim Fehlig [Tue, 15 Sep 2015 14:17:44 +0000 (08:17 -0600)]
libxl: open libxl log stream with libvirtd log_level

Instead of a hardcoded DEBUG log level, use the overall
daemon log level specified in libvirtd.conf when opening
a log stream with libxl. libxl is very verbose when DEBUG
log level is set, resulting in huge log files that can
potentially fill a disk. Control of libxl verbosity should
be placed in the administrator's hands.

9 years agoIgnore virtio-mmio disks in qemuAssignDevicePCISlots()
Pavel Fedin [Wed, 9 Sep 2015 12:02:53 +0000 (15:02 +0300)]
Ignore virtio-mmio disks in qemuAssignDevicePCISlots()

Fixes the following error when attempting to add a disk with bus='virtio'
to a machine which actually supports virtio-mmio (caught with ARM virt):

virtio disk cannot have an address of type 'virtio-mmio'

The problem has been likely introduced by
e8d55172544c1fafe31a9e09346bdebca4f0d6f9. Before that
qemuAssignDevicePCISlots() was never called for ARM "virt" machine.

Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
9 years agosecurity_selinux: Take @privileged into account
Michal Privoznik [Thu, 10 Sep 2015 11:27:28 +0000 (13:27 +0200)]
security_selinux: Take @privileged into account

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

If running in session mode it may happen that we fail to set
correct SELinux label, but the image may still be readable to
the qemu process. Take this into account.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirSecurityManager: Track if running as privileged
Michal Privoznik [Thu, 10 Sep 2015 09:43:31 +0000 (11:43 +0200)]
virSecurityManager: Track if running as privileged

We may want to do some decisions in drivers based on fact if we
are running as privileged user or not. Propagate this info there.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agosecurity_selinux: Replace SELinuxSCSICallbackData with proper struct
Michal Privoznik [Thu, 10 Sep 2015 11:49:18 +0000 (13:49 +0200)]
security_selinux: Replace SELinuxSCSICallbackData with proper struct

We have plenty of callbacks in the driver. Some of these
callbacks require more than one argument to be passed. For that
we currently have a data type (struct) per each callback. Well,
so far for only one - SELinuxSCSICallbackData. But lets turn it
into more general name so it can be reused in other callbacks too
instead of each one introducing a new, duplicate data type.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirSecuritySELinuxSetSecurityAllLabel: drop useless virFileIsSharedFSType
Michal Privoznik [Thu, 10 Sep 2015 11:29:36 +0000 (13:29 +0200)]
virSecuritySELinuxSetSecurityAllLabel: drop useless virFileIsSharedFSType

The check is done in virSecuritySELinuxSetFilecon itself. There's
no need to check it again.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoMinor typo fixes in documentation
Christian Loehle [Tue, 15 Sep 2015 09:15:06 +0000 (11:15 +0200)]
Minor typo fixes in documentation

Signed-off-by: Christian Loehle <cloehle@linutronix.de>
9 years agoutil: Add space before comment end marker
Andrea Bolognani [Mon, 14 Sep 2015 09:29:03 +0000 (11:29 +0200)]
util: Add space before comment end marker

This allows the Wikipedia link to be recognized correctly by eg.
gnome-terminal's Open Link and Copy Link Address features.

9 years agoqemu: Allow others to browse /var/lib/libvirt/qemu
Martin Kletzander [Tue, 8 Sep 2015 16:34:36 +0000 (18:34 +0200)]
qemu: Allow others to browse /var/lib/libvirt/qemu

Commit f1f68ca33433 tried fixing running multiple domains under various
users, but if the user can't browse the directory, it's hard for the
qemu running under that user to create the monitor socket.

The permissions need to be fixed in two places in the spec file due to
support for both installations with and without driver modules.

Creating a directory with '$(MKDIR_P) -m' shouldn't fail even on systems
where autoconf needs to fallback to 'install-sh -d'.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoqemu: Do not allow others into per-VM subdirectories
Martin Kletzander [Sat, 12 Sep 2015 13:00:58 +0000 (15:00 +0200)]
qemu: Do not allow others into per-VM subdirectories

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoqemu: hotplug: Properly clean up drive backend if frontend hotplug fails
Peter Krempa [Fri, 11 Sep 2015 15:34:18 +0000 (17:34 +0200)]
qemu: hotplug: Properly clean up drive backend if frontend hotplug fails

Commit 8125113c added code that should remove the disk backend if the
fronted hotplug failed for any reason. The code had a bug though as it
used the disk string for unplug rather than the backend alias. Fix the
code by pre-creating an alias string and using it instead of the disk
string. In cases where qemu does not support QEMU_CAPS_DEVICE, we ignore
the unplug of the backend since we can't really create an alias in that
case.

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

9 years agoqemu: command: Report stderr from qemu-bridge-helper
Cole Robinson [Thu, 10 Sep 2015 16:35:00 +0000 (12:35 -0400)]
qemu: command: Report stderr from qemu-bridge-helper

There's a couple reports of things failing in this area (bug 1259070),
but it's tough to tell what's going wrong without stderr from
qemu-bridge-helper. So let's report stderr in the error message

Couple new examples:

virbr0 is inactive:
internal error: /usr/libexec/qemu-bridge-helper --use-vnet --br=virbr0 --fd=21: failed to communicate with bridge helper: Transport endpoint is not connected
stderr=failed to get mtu of bridge `virbr0': No such device

bridge isn't on the ACL:
internal error: /usr/libexec/qemu-bridge-helper --use-vnet --br=br0 --fd=21: failed to communicate with bridge helper: Transport endpoint is not connected
stderr=access denied by acl file

9 years agoxen: fix race in refresh of config cache
Daniel P. Berrange [Fri, 11 Sep 2015 13:15:50 +0000 (14:15 +0100)]
xen: fix race in refresh of config cache

The xenXMConfigCacheRefresh method scans /etc/xen and loads
all config files it finds. It then scans its internal hash
table and purges any (previously) loaded config files whose
refresh timestamp does not match the timestamp recorded at
the start of xenXMConfigCacheRefresh(). There is unfortunately
a subtle flaw in this, because if loading the config files
takes longer than 1 second, some of the config files will
have a refresh timestamp that is 1 or more seconds different
(newer) than is checked for. So we immediately purge a bunch
of valid config files we just loaded.

To avoid this flaw, we must pass the timestamp we record at
the start of xenXMConfigCacheRefresh() into the
xenXMConfigCacheAddFile() method, instead of letting the
latter call time(NULL) again.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agotests: Don't use testutils in mock libraries
Martin Kletzander [Fri, 11 Sep 2015 09:11:45 +0000 (11:11 +0200)]
tests: Don't use testutils in mock libraries

Mock libraries are not built with testutils.c, but there's one which
uses VIR_TEST_DEBUG.  But because that debug should be an error, if we
change it, then it will not only be more semantically correct, but mingw
compiler will be happier as well.

It also follows suit with all other mock libraries.

For few other things, used in this file, need libvirt.la to be added
into LIBADD for mingw as well.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agolibxl: don't end job for ephemeal domain on start failure
Ian Campbell [Thu, 10 Sep 2015 15:45:07 +0000 (16:45 +0100)]
libxl: don't end job for ephemeal domain on start failure

commit 4b53d0d4ac9c "libxl: don't remove persistent domain on start
failure" cleans up the vm object and sets it to NULL if the vm is not
persistent, however at end job vm (now NULL) is dereferenced via the call to
libxlDomainObjEndJob. Avoid this by skipping "endjob" and going
straight to "cleanup" in this case.

Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
9 years agodocs: Update devguide.html to point to the new Python dev guide
Daniel P. Berrange [Thu, 10 Sep 2015 11:15:45 +0000 (12:15 +0100)]
docs: Update devguide.html to point to the new Python dev guide

We have a new libvirt-appdev-guide-python which we need to
promote to users. Rewrite the existing page to mention it
too. Also use the new URL location which is automatically
refreshed once a day.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
9 years agoqemu: Try several network devices when looking for a default
Andrea Bolognani [Mon, 7 Sep 2015 06:51:00 +0000 (08:51 +0200)]
qemu: Try several network devices when looking for a default

Up until now, the default has been rtl8139, but no check was in
place to make sure that device was actually available.

Now we try rtl8139, e1000 and virtio-net in turn, checking for
availability before using any of them: this means we have a much
better chance for the guest to be able to boot.

9 years agoqemu: Introduce QEMU_CAPS_DEVICE_VIRTIO_NET
Andrea Bolognani [Tue, 1 Sep 2015 12:38:19 +0000 (14:38 +0200)]
qemu: Introduce QEMU_CAPS_DEVICE_VIRTIO_NET

This capability can be used to detect whether or not the QEMU
binary supports the virtio-net-* network device.

9 years agoqemu: Introduce QEMU_CAPS_DEVICE_E1000
Andrea Bolognani [Fri, 4 Sep 2015 14:40:37 +0000 (16:40 +0200)]
qemu: Introduce QEMU_CAPS_DEVICE_E1000

This capability can be used to detect whether or not the QEMU
binary supports the e1000 network device.

9 years agoqemu: Introduce QEMU_CAPS_DEVICE_RTL8139
Andrea Bolognani [Fri, 4 Sep 2015 14:23:46 +0000 (16:23 +0200)]
qemu: Introduce QEMU_CAPS_DEVICE_RTL8139

This capability can be used to detect whether or not the QEMU
binary supports the rtl8139 network device.

9 years agoqemu: Report error if per-VM directory cannot be created
Martin Kletzander [Tue, 8 Sep 2015 17:12:58 +0000 (19:12 +0200)]
qemu: Report error if per-VM directory cannot be created

Commit f1f68ca33433 did not report an error if virFileMakePath()
returned -1.  Well, who would've guessed function with name starting
with 'vir' sets an errno instead of reporting an error the libvirt way.
Anyway, let's fix it, so the output changes from:

  $ virsh start arm
  error: Failed to start domain arm
  error: An error occurred, but the cause is unknown

to:

  $ virsh start arm
  error: Failed to start domain arm
  error: Cannot create directory '/var/lib/libvirt/qemu/domain-arm': Not
  a directory

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoRevert "docs: Drop unused rule for internals/%.html.tmp target"
Martin Kletzander [Wed, 9 Sep 2015 09:45:57 +0000 (11:45 +0200)]
Revert "docs: Drop unused rule for internals/%.html.tmp target"

This reverts commit e5470dd0e0a5be02cbf18a882cfc676b39d1c1a5.

This has been ACK'd by the original author in the original mail thread:
https://www.redhat.com/archives/libvir-list/2015-September/msg00310.html

The reason to revert this is due to the patch breaking the generation of
internal subsites.  The original issue still needs to be dealt with,
though.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoqemu: migration: Relax enforcement of memory hotplug support
Peter Krempa [Tue, 8 Sep 2015 13:06:26 +0000 (15:06 +0200)]
qemu: migration: Relax enforcement of memory hotplug support

If the current live definition does not have memory hotplug enabled, but
the persistent one does libvirt would reject migration if the
destination does not support memory hotplug even if the user didn't want
to persist the VM at the destination and thus the XML containing the
memory hotplug definition would not be used. To fix this corner case the
code will check for memory hotplug in the newDef only if
VIR_MIGRATE_PERSIST_DEST was used.

9 years agodocs: Remove last use of double semicolon in Makefile
Martin Kletzander [Mon, 7 Sep 2015 08:27:53 +0000 (10:27 +0200)]
docs: Remove last use of double semicolon in Makefile

Double semicolons have special meaning in makefiles, but they would have
to be combined with other rules witch such separators in order to be
used as intended.  Since there are no other rules like that, let's
clean it up.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoutil: Add win32 version of virFileUnlink
Martin Kletzander [Mon, 7 Sep 2015 08:24:47 +0000 (10:24 +0200)]
util: Add win32 version of virFileUnlink

Commit 35847860f65f Added the virFileUnlink function, but failed to add
a version for mingw build, causing the following error:

  Cannot export virFileUnlink: symbol not defined

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoconf: fix crash when parsing a unordered NUMA <cell/>
Luyao Huang [Tue, 8 Sep 2015 04:59:10 +0000 (12:59 +0800)]
conf: fix crash when parsing a unordered NUMA <cell/>

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

Introduced by 8fedbbdb, if we parse an unordered NUMA cell, will
get a segfault. This is because of a check for overlapping @cpus
sets we have there. However, since the array to hold guest NUMA
cells is allocated upfront and therefore it contains all zeros,
an out of order cell will break our assumption that cell IDs have
increasing character. At this point we try to access yet NULL
bitmap and therefore segfault.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
9 years agoadmin: Resolve leaked reference to private data
Erik Skultety [Mon, 7 Sep 2015 15:28:22 +0000 (17:28 +0200)]
admin: Resolve leaked reference to private data

Running valgrind on a very simplistic program consisting only of
opening and closing admin connection (virAdmConnect{Open,Close}) shows a
leak in remoteAdminPrivNew, because the last reference to privateData is
not decremented, thus the object won't be disposed. This patch unrefs
the privateData object once we closed the active connection to daemon,
making further use of this connection  useless.

==24577==    at 0x4A089C7: calloc (in /usr/lib64/valgrind/vgpreload_***linux.so)
==24577==    by 0x4E8835F: virAllocVar (viralloc.c:560)
==24577==    by 0x4EDFA5C: virObjectNew (virobject.c:193)
==24577==    by 0x4EDFBD4: virObjectLockableNew (virobject.c:219)
==24577==    by 0x4C14DAF: remoteAdminPrivNew (libvirt-admin.c:152)
==24577==    by 0x4C1537E: virAdmConnectOpen (libvirt-admin.c:308)
==24577==    by 0x400BAD: main (listservers.c:39)

==24577== LEAK SUMMARY:
==24577==    definitely lost: 80 bytes in 1 blocks
==24577==    indirectly lost: 840 bytes in 6 blocks
==24577==      possibly lost: 0 bytes in 0 blocks
==24577==    still reachable: 12,179 bytes in 199 blocks
==24577==         suppressed: 0 bytes in 0 blocks

9 years agovmx: Add handling for CDROM devices with SCSI passthru
Matthias Bolte [Tue, 1 Sep 2015 14:52:04 +0000 (16:52 +0200)]
vmx: Add handling for CDROM devices with SCSI passthru

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

9 years agovmx: The virVMXParseDisk deviceType can be NULL, add some missing checks
Matthias Bolte [Tue, 1 Sep 2015 14:52:03 +0000 (16:52 +0200)]
vmx: The virVMXParseDisk deviceType can be NULL, add some missing checks

9 years agocpu: Introduce IvyBridge CPU model
Jiri Denemark [Fri, 4 Sep 2015 13:06:40 +0000 (15:06 +0200)]
cpu: Introduce IvyBridge CPU model

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agovirsh: Slightly rework cmdDomblklist
Michal Privoznik [Wed, 2 Sep 2015 13:44:41 +0000 (15:44 +0200)]
virsh: Slightly rework cmdDomblklist

Let's move some variables from an inside loop to global function
declaration header block. It's going to be easier for next
patches. At the same time, order the cleanup calls at the
function's end so it's easier to track which variables are freed
and which not.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years ago.gitignore: Ignore the correct rename example binary
Michal Privoznik [Mon, 7 Sep 2015 08:40:55 +0000 (10:40 +0200)]
.gitignore: Ignore the correct rename example binary

In e755186c5c305a9 we tried to introduce an example demonstrating
new virDomainRename API. Unfortunately, in the .gitignore we had
a different binary listed. It's 'rename' binary which we want git
to ignore, not 'test'.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoexamples: Add missing build data for 'rename'
Martin Kletzander [Mon, 7 Sep 2015 07:00:19 +0000 (09:00 +0200)]
examples: Add missing build data for 'rename'

Commit e755186c5c30 added the rename example, but forgot to build some
essential files in there as well as add it to the spec file.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agovmx: Some whitespace cleanup
Matthias Bolte [Tue, 1 Sep 2015 14:52:02 +0000 (16:52 +0200)]
vmx: Some whitespace cleanup

9 years agoconf: Remove need for a couple of sa_asserts
John Ferlan [Tue, 1 Sep 2015 11:20:15 +0000 (07:20 -0400)]
conf: Remove need for a couple of sa_asserts

Remove the need for a couple of sa_asserts.

9 years agoutil: Avoid Coverity FORWARD_NULL
John Ferlan [Tue, 1 Sep 2015 11:02:30 +0000 (07:02 -0400)]
util: Avoid Coverity FORWARD_NULL

Coverity claims it could be possible to call virDBusTypeStackFree with
*stack == NULL and although the two API's that call it don't appear to
allow that - I suppose it's better to be safe than sorry

9 years agovirfile: Avoid Coverity IDENTICAL_BRANCHES error
John Ferlan [Tue, 1 Sep 2015 10:56:38 +0000 (06:56 -0400)]
virfile: Avoid Coverity IDENTICAL_BRANCHES error

In virFileNBDDeviceFindUnused if virFileNBDDeviceIsBusy returns 0,
then both branches jumped to cleanup, so just use ignore_value
since the function returns NULL or some memory and the caller
handles the error.

9 years agolxc: Avoid Coverity SIZEOF_MISMATCH
John Ferlan [Tue, 1 Sep 2015 11:08:47 +0000 (07:08 -0400)]
lxc: Avoid Coverity SIZEOF_MISMATCH

Commit id '692e9fac7' used virProcessSetNamespaces instead of inlining
the similar functionality; however, Coverity notes that the function
prototype expects a size_t value and not an enum and complains. So,
just typecast the enum as a size_t to avoid the noise.

9 years agoqemu: Check virGetLastError return value for migration finish failure
John Ferlan [Tue, 1 Sep 2015 10:47:55 +0000 (06:47 -0400)]
qemu: Check virGetLastError return value for migration finish failure

Commit id '2e7cea243' added a check for an error from Finish instead
of 'unexpected error'; however, if for some reason there wasn't an
error, then virGetLastError could return NULL resulting in the
NULL pointer deref to err->domain.

9 years agoChange name of the domain upon successful rename
Martin Kletzander [Thu, 27 Aug 2015 10:43:15 +0000 (12:43 +0200)]
Change name of the domain upon successful rename

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoAdd example that renames domain there and back
Martin Kletzander [Thu, 27 Aug 2015 10:55:52 +0000 (12:55 +0200)]
Add example that renames domain there and back

And in the middle it prints out its name to demonstrate changes in later
patch(es).

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoexamples: Add example polkit ACL rules
Jiri Denemark [Tue, 4 Aug 2015 12:05:52 +0000 (14:05 +0200)]
examples: Add example polkit ACL rules

Creating ACL rules is not exactly easy and existing examples are pretty
simple. This patch adds a somewhat complex example which defines several
roles. Admins can do everything, operators can do basic operations
on any domain and several groups of users who act as operators but only
on a limited set of domains.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Need to check for machine.os when using ADDRESS_TYPE_CCW
John Ferlan [Mon, 31 Aug 2015 15:06:42 +0000 (11:06 -0400)]
qemu: Need to check for machine.os when using ADDRESS_TYPE_CCW

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

When attaching a disk, controller, or rng using an address type ccw
or s390, we need to ensure the support is provided by both the machine.os
and the emulator capabilities (corollary to unconditional setting when
address was not provided for the correct machine.os and emulator.

For an inactive guest, an addition followed by a start would cause the
startup to fail after qemu_command builds the command line and attempts
to start the guest. For an active guest, libvirtd would crash.

9 years agoqemu: Introduce qemuDomainMachineIsS390CCW
John Ferlan [Wed, 2 Sep 2015 20:02:14 +0000 (16:02 -0400)]
qemu: Introduce qemuDomainMachineIsS390CCW

Rather than have different usages of STR function in order to determine
whether the domain is s390-ccw or s390-ccw-virtio, make a single API
which will check the machine.os prefix. Then use the function.

9 years agovsh: Make vshInitDebug static
Erik Skultety [Fri, 4 Sep 2015 08:42:29 +0000 (10:42 +0200)]
vsh: Make vshInitDebug static

There's no reason why debug initialization could not be made completely
hidden, just like readline initialization is. The point of the global
initializer vshInit is to make initialization of smaller features transparent
to the user/caller.

9 years agovirsh: Do not make interactive mode default
Erik Skultety [Fri, 4 Sep 2015 09:19:55 +0000 (11:19 +0200)]
virsh: Do not make interactive mode default

Currently, we set interactive mode as default possibly reverting the
setting after we parse the command line arguments. There's nothing
particulary wrong with that, but a call to vshReadlineInit is performed
always in the global initializer just because the default mode is interactive.
Rather than moving vshReadlineInit call somewhere else (because another client
might want to implement interactive mode only), we could make the decision
if we're about to run in interactive mode once the command line is parsed.

9 years agovsh: Introduce vshInitReload
Erik Skultety [Thu, 3 Sep 2015 14:59:01 +0000 (16:59 +0200)]
vsh: Introduce vshInitReload

Commit a0b6a36f separated vshInitDebug from the original vshInit
(before virsh got split and vshInit became virshInit - commit 834c5720)
in order to be able to debug command line parsing.
After the parsing is finished, debugging is reinitialized to work properly.
There might as well be other features that require re-initialization as
the command line could specify parameters that override our defaults which
had been set prior to calling vshArgvParse.

9 years agovsh: adjust vshInit signature and remove redundant error label
Erik Skultety [Thu, 3 Sep 2015 14:52:44 +0000 (16:52 +0200)]
vsh: adjust vshInit signature and remove redundant error label

As part of the effort to stay consistent, change the vshInit signature
from returning int to returning bool. Moreover, remove the
unnecessary error label as there is no cleanup that would make use of
it.

9 years agolibxl: don't overwrite error from virNetSocketNewConnectTCP()
Jim Fehlig [Thu, 3 Sep 2015 16:14:20 +0000 (10:14 -0600)]
libxl: don't overwrite error from virNetSocketNewConnectTCP()

Remove redundant error reporting in libxlDomainMigrationPerform().
virNetSocketNewConnectTCP() is perfectly capable of reporting
sensible errors.

9 years agodomain-conf: escape string for socket attribute
Pavel Hrdina [Mon, 31 Aug 2015 13:33:49 +0000 (15:33 +0200)]
domain-conf: escape string for socket attribute

Commit d091518b tried to escape all strings in produced XML, but missed
this one.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agoutil: don't use netlink to save/set mac for macvtap+passthrough+802.1Qbh
Laine Stump [Wed, 26 Aug 2015 04:18:26 +0000 (00:18 -0400)]
util: don't use netlink to save/set mac for macvtap+passthrough+802.1Qbh

Before libvirt sets the MAC address of the physdev (the physical
ethernet device) linked to a macvtap passthrough device, it always
saves the previous MAC address to restore when the guest is finished
(following a "leave nothing behind" policy). For a long time it
accomplished the save/restore with a combination of
ioctl(SIOCGIFHWADDR) and ioctl(SIOCSIFHWADDR), but in commit cbfe38c
(first in libvirt 1.2.15) this was changed to use netlink RTM_GETLINK
and RTM_SETLINK commands sent to the Physical Function (PF) of any
device that was detected to be a Virtual Function (VF).

We later found out that this caused problems with any devices using
the Cisco enic driver (e.g. vmfex cards) because the enic driver
hasn't implemented the function that is called to gather the
information in the IFLA_VFINFO_LIST attribute of RTM_GETLINK
(ndo_get_vf_config() for those keeping score), so we would never get
back a useful response.

In an ideal world, all drivers would implement all functions, but it
turns out that in this case we can work around this omission without
any bad side effects - since all macvtap passthrough <interface>
definitions pointing to a physdev that uses the enic driver *must*
have a <virtualport type='802.1Qbh'>, and since no other type of
ethernet devices use 802.1Qbh, libvirt can change its behavior in this
case to use the old-style.  ioctl(SIOC[GS]IFHWADDR).  That's what this
patch does.

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

9 years agoutil: make virNetDev(Replace|Restore)MacAddress public functions
Laine Stump [Mon, 31 Aug 2015 21:09:01 +0000 (17:09 -0400)]
util: make virNetDev(Replace|Restore)MacAddress public functions

These functions were made static as a part of commit cbfe38c since
they were no longer called from outside virnetdev.c. We once again
need to call them from another file, so this patch makes them once
again public.

9 years agoremoteClientCloseFunc: Don't mangle connection object refcount
Michal Privoznik [Thu, 3 Sep 2015 10:11:53 +0000 (12:11 +0200)]
remoteClientCloseFunc: Don't mangle connection object refcount

Well, in 8ad126e6 we tried to fix a memory corruption problem.
However, the fix was not as good as it could be. I mean, the
commit has one line more than it should. I've noticed this output
just recently:

  # ./run valgrind --leak-check=full --show-reachable=yes ./tools/virsh domblklist gentoo
  ==17019== Memcheck, a memory error detector
  ==17019== Copyright (C) 2002-2013, and GNU GPL'd, by Julian Seward et al.
  ==17019== Using Valgrind-3.10.1 and LibVEX; rerun with -h for copyright info
  ==17019== Command: /home/zippy/work/libvirt/libvirt.git/tools/.libs/virsh domblklist gentoo
  ==17019==
  Target     Source
  ------------------------------------------------
  fda        /var/lib/libvirt/images/fd.img
  vda        /var/lib/libvirt/images/gentoo.qcow2
  hdc        /home/zippy/tmp/install-amd64-minimal-20150402.iso

  ==17019== Thread 2:
  ==17019== Invalid read of size 4
  ==17019==    at 0x4EFF5B4: virObjectUnref (virobject.c:258)
  ==17019==    by 0x5038CFF: remoteClientCloseFunc (remote_driver.c:552)
  ==17019==    by 0x5069D57: virNetClientCloseLocked (virnetclient.c:685)
  ==17019==    by 0x506C848: virNetClientIncomingEvent (virnetclient.c:1852)
  ==17019==    by 0x5082136: virNetSocketEventHandle (virnetsocket.c:1913)
  ==17019==    by 0x4ECD64E: virEventPollDispatchHandles (vireventpoll.c:509)
  ==17019==    by 0x4ECDE02: virEventPollRunOnce (vireventpoll.c:658)
  ==17019==    by 0x4ECBF00: virEventRunDefaultImpl (virevent.c:308)
  ==17019==    by 0x130386: vshEventLoop (vsh.c:1864)
  ==17019==    by 0x4F1EB07: virThreadHelper (virthread.c:206)
  ==17019==    by 0xA8462D3: start_thread (in /lib64/libpthread-2.20.so)
  ==17019==    by 0xAB441FC: clone (in /lib64/libc-2.20.so)
  ==17019==  Address 0x139023f4 is 4 bytes inside a block of size 240 free'd
  ==17019==    at 0x4C2B1F0: free (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
  ==17019==    by 0x4EA8949: virFree (viralloc.c:582)
  ==17019==    by 0x4EFF6D0: virObjectUnref (virobject.c:273)
  ==17019==    by 0x4FE74D6: virConnectClose (libvirt.c:1390)
  ==17019==    by 0x13342A: virshDeinit (virsh.c:406)
  ==17019==    by 0x134A37: main (virsh.c:950)

The problem is, when registering remoteClientCloseFunc(), it's
conn->closeCallback which is ref'd. But in the function itself
it's conn->closeCallback->conn what is unref'd. This is causing
imbalance in reference counting. Moreover, there's no need for
the remote driver to increase/decrease conn refcount since it's
not used anywhere. It's just merely passed to client registered
callback. And for that purpose it's correctly ref'd in
virConnectRegisterCloseCallback() and then unref'd in
virConnectUnregisterCloseCallback().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovshInit: Don't leak @histsize_env
Michal Privoznik [Thu, 3 Sep 2015 12:37:14 +0000 (14:37 +0200)]
vshInit: Don't leak @histsize_env

Caller is responsible for freeing the result of virStringJoin()
when no longer needed:

==10701== 1 bytes in 1 blocks are definitely lost in loss record 1 of 806
==10701==    at 0x4C29F80: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==10701==    by 0xAADB679: strdup (in /lib64/libc-2.20.so)
==10701==    by 0x4F18655: virStrdup (virstring.c:726)
==10701==    by 0x4F175AF: virStringJoin (virstring.c:165)
==10701==    by 0x131D4D: vshReadlineInit (vsh.c:2572)
==10701==    by 0x1322DF: vshInit (vsh.c:2736)
==10701==    by 0x1347C1: main (virsh.c:907)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agostorage: Handle failure from refreshVol
John Ferlan [Mon, 24 Aug 2015 16:38:13 +0000 (12:38 -0400)]
storage: Handle failure from refreshVol

Commit id '155ca616' added the 'refreshVol' API. In an NFS root-squash
environment it was possible that if the just created volume from XML wasn't
properly created with the right uid/gid and/or mode, then the followup
refreshVol will fail to open the volume in order to get the allocation/
capacity values. This would leave the volume still on the server and
cause a libvirtd crash because 'voldef' would be in the pool list, but
the cleanup code would free it.

9 years agostorage: Correct the 'mode' check
John Ferlan [Mon, 24 Aug 2015 16:48:40 +0000 (12:48 -0400)]
storage: Correct the 'mode' check

Commit id '7c2d65dde2' changed the default value of mode to be -1 if not
supplied in the XML, which should cause creation of the volume using the
default mode of VIR_STORAGE_DEFAULT_VOL_PERM_MODE; however, the check
made was whether mode was '0' or not to use default or provided value.

This patch fixes the issue to check if the 'mode' was provided in the XML
and use that value.

9 years agovirfile: Introduce virFileUnlink
John Ferlan [Mon, 24 Aug 2015 21:00:02 +0000 (17:00 -0400)]
virfile: Introduce virFileUnlink

In an NFS root-squashed environment the 'vol-delete' command will fail to
'unlink' the target volume since it was created under a different uid:gid.

This code continues the concepts introduced in virFileOpenForked and
virDirCreate[NoFork] with respect to running the unlink command under
the uid/gid of the child. Unlike the other two, don't retry on EACCES
(that's why we're here doing this now).

9 years agovirfile: Add error for root squash change mode failure
John Ferlan [Mon, 24 Aug 2015 16:37:41 +0000 (12:37 -0400)]
virfile: Add error for root squash change mode failure

This will only be seen when debugging, but in order to help determine
whether a virFileOpenForceOwnerMode failed during an NFS root-squash
volume/file creation, add an error message from the child.

9 years agoqemu: add udp interface support
Jonathan Toppins [Sat, 29 Aug 2015 20:19:10 +0000 (16:19 -0400)]
qemu: add udp interface support

Adds a new interface type using UDP sockets, this seems only applicable
to QEMU but have edited tree-wide to support the new interface type.

The interface type required the addition of a "localaddr" (local
address), this then maps into the following xml and qemu call.

<interface type='udp'>
  <mac address='52:54:00:5c:67:56'/>
  <source address='127.0.0.1' port='11112'>
    <local address='127.0.0.1' port='22222'/>
  </source>
  <model type='virtio'/>
  <address type='pci' domain='0x0000' bus='0x00' slot='0x07' function='0x0'/>
</interface>

QEMU call:
-net socket,udp=127.0.0.1:11112,localaddr=127.0.0.1:22222

Notice the xml "local" entry becomes the "localaddr" for the qemu call.

reference:
http://lists.gnu.org/archive/html/qemu-devel/2011-11/msg00629.html

Signed-off-by: Jonathan Toppins <jtoppins@cumulusnetworks.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
9 years agoPost release version bump to 1.2.20
Ján Tomko [Wed, 2 Sep 2015 08:17:37 +0000 (10:17 +0200)]
Post release version bump to 1.2.20

9 years agoRelease of libvirt-1.2.19
Daniel Veillard [Wed, 2 Sep 2015 02:19:20 +0000 (10:19 +0800)]
Release of libvirt-1.2.19

* docs/news.html.in libvirt.spec.in: updated for the release
* po/*.po*: regenerated

9 years agosrc: Check for symbols ordering in ADMIN_SYM_FILES
Michal Privoznik [Mon, 31 Aug 2015 10:45:16 +0000 (12:45 +0200)]
src: Check for symbols ordering in ADMIN_SYM_FILES

Like we are checking for the correct order in SYM_FILES, we
should do the same for ADMIN_SYM_FILES.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agosrc: Cleanup libvirt_admin.syms
Michal Privoznik [Mon, 31 Aug 2015 09:37:45 +0000 (11:37 +0200)]
src: Cleanup libvirt_admin.syms

It's a generated file, so after 'distclean' it should be gone.
But it isn't yet.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agosrc: Check libvirt_admin.syms for exported symbols
Michal Privoznik [Mon, 31 Aug 2015 09:35:46 +0000 (11:35 +0200)]
src: Check libvirt_admin.syms for exported symbols

We have this check rule in src/Makefile: check-symfile that
should check if all symbols we wanted to export are exported.
Moreover, if we are not exporting something more. Do the same
with libvirt_admin.syms.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoapparmor: Adjust path to domain monitor socket
Guido Günther [Sat, 29 Aug 2015 16:05:50 +0000 (18:05 +0200)]
apparmor: Adjust path to domain monitor socket

f1f68ca33 moved the monitor socket to a per domain directory. Adjust the
path accordingly.

9 years agoutil: fallback to ioctl(SIOCBRDELBR) if netlink RTM_DELLINK fails
Laine Stump [Wed, 26 Aug 2015 03:19:03 +0000 (23:19 -0400)]
util: fallback to ioctl(SIOCBRDELBR) if netlink RTM_DELLINK fails

commit 09778e09 switched from using ioctl(SIOCBRDELBR) for bridge
device deletion to using a netlink RTM_DELLINK message, which is the
more modern way to delete a bridge (and also doesn't require the
bridge to be ~IFF_UP to succeed). However, although older kernels
(e.g. 2.6.32, in RHEL6/CentOS6) support deleting *some* link types
with RTM_NEWLINK, they don't support deleting bridges, and there is no
compile-time way to figure this out.

This patch moves the body of the SIOCBRDELBR version of
virNetDevBridgeDelete() into a static function, calls the new function
from the original, and also calls the new function from the
RTM_DELLINK version if the RTM_DELLINK message generates an EOPNOTSUPP
error. Since RTM_DELLINK is done from the subordinate function
virNetlinkDelLink, which is also called for other purposes (deleting a
macvtap interface), a function pointer called "fallback" has been
added to the arglist of virNetlinkDelLink() - if that arg != NULL, the
provided function will be called when (and only when) RTM_DELLINK
fails with EOPNOTSUPP.

Resolves:  https://bugzilla.redhat.com/show_bug.cgi?id=1252780 (part 2)

9 years agoutil: fallback to ioctl(SIOCBRADDBR) if netlink RTM_NEWLINK fails
Laine Stump [Wed, 26 Aug 2015 00:48:19 +0000 (20:48 -0400)]
util: fallback to ioctl(SIOCBRADDBR) if netlink RTM_NEWLINK fails

commit fc7b23db switched from using ioctl(SIOCBRADDBR) for bridge
creation to using a netlink RTM_NEWLINK message with IFLA_INFO_KIND =
"bridge", which is the more modern way to create a bridge. However,
although older kernels (e.g. 2.6.32, in RHEL6/CentOS6) support
creating *some* link types with RTM_NEWLINK, they don't support
creating bridges, and there is no compile-time way to figure this out
(since the "type" isn't an enum, but rather a character string).

This patch moves the body of the SIOCBRADDBR version of
virNetDevBridgeCreate() into a static function, calls the new function
from the original, and also calls the new function from the
RTM_NEWLINK version if the RTM_NEWLINK message generates an EOPNOTSUPP
error.

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

9 years agoRevert "LXC: show used memory as 0 when domain is not active"
Jim Fehlig [Mon, 10 Aug 2015 18:49:55 +0000 (12:49 -0600)]
Revert "LXC: show used memory as 0 when domain is not active"

This reverts commit 1ce7c1d20cfd5afb26d2dbc88201085d52415d0e,
which introduced a significant semantic change to the
virDomainGetInfo() API. Additionally, the change was only
made to 2 of the 15 virt drivers.

Conflicts:
src/qemu/qemu_driver.c

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
9 years agolibxl: acquire a job when receiving a migrating domain
Jim Fehlig [Thu, 16 Jul 2015 18:24:32 +0000 (12:24 -0600)]
libxl: acquire a job when receiving a migrating domain

Commit f86ae403 moved acquiring a job from libxlDomainStart()
to its callers. One spot missed was in libxlDoMigrateReceive().
Acquire a job in libxlDoMigrateReceive() before calling
libxlDomainStart().

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
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