]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
9 years agoqemu: vcpupin: Always set affinity even when cgroups are supported
Peter Krempa [Fri, 12 Feb 2016 06:05:24 +0000 (07:05 +0100)]
qemu: vcpupin: Always set affinity even when cgroups are supported

VM startup and CPU hotplug always set the affinity regardless of cgroups
support. Use the same approach for the pinning API.

9 years agoqemu: vcpupin: Don't overwrite errors from functions setting pinning
Peter Krempa [Fri, 12 Feb 2016 05:54:41 +0000 (06:54 +0100)]
qemu: vcpupin: Don't overwrite errors from functions setting pinning

Both errors from the cgroups code and from the affinity code would be
overwritten by the API. Report the more specific error.

9 years agoutil: Use virBitmapIsBitSet in freebsd impl of virProcessSetAffinity
Peter Krempa [Fri, 12 Feb 2016 05:49:50 +0000 (06:49 +0100)]
util: Use virBitmapIsBitSet in freebsd impl of virProcessSetAffinity

Use the helper that does not return errors to fix spuriously looking
dead return of -1.

9 years agovirsh: cmdVcpuPin: Simplify handling of API flags
Peter Krempa [Fri, 12 Feb 2016 05:15:47 +0000 (06:15 +0100)]
virsh: cmdVcpuPin: Simplify handling of API flags

Rather than setting flags to -1 if none were specified, move the logic
to use the old API to the place where we need to decide. It simplifies
the logic a bit.

9 years agotest: qemuxml2argv: Drop QEMU_CAPS_DEVICE uses
Andrea Bolognani [Fri, 19 Feb 2016 12:25:38 +0000 (13:25 +0100)]
test: qemuxml2argv: Drop QEMU_CAPS_DEVICE uses

Since commit 51045df01b3c, the QEMU_CAPS_DEVICE capability is enabled
automatically and shouldn't be passed as an argument to DO_TEST();
however, commit 998a936c4c1a accidentally introduced few such uses.

9 years agoadmin: Fix memory leak in remoteAdminConnectClose
Erik Skultety [Thu, 18 Feb 2016 13:39:18 +0000 (14:39 +0100)]
admin: Fix memory leak in remoteAdminConnectClose

When virt-admin is run with valgrind, this kind of output can be obtained:

HEAP SUMMARY:
  in use at exit: 134,589 bytes in 1,031 blocks
  total heap usage: 2,667 allocs, 1,636 frees, 496,755 bytes allocated

88 bytes in 1 blocks are definitely lost in loss record 82 of 128
 at 0x4C2A9C7: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
 by 0x52F6D1F: virAllocVar (viralloc.c:560)
 by 0x5350268: virObjectNew (virobject.c:193)
 by 0x53503E0: virObjectLockableNew (virobject.c:219)
 by 0x4E3BBCB: virAdmConnectNew (datatypes.c:832)
 by 0x4E38495: virAdmConnectOpen (libvirt-admin.c:209)
 by 0x10C541: vshAdmConnect (virt-admin.c:107)
 by 0x10C7B2: vshAdmReconnect (virt-admin.c:163)
 by 0x10CC7C: cmdConnect (virt-admin.c:298)
 by 0x110838: vshCommandRun (vsh.c:1224)
 by 0x10DFD8: main (virt-admin.c:862)

 LEAK SUMMARY:
    definitely lost: 88 bytes in 1 blocks
    indirectly lost: 0 bytes in 0 blocks
    possibly lost: 0 bytes in 0 blocks
    still reachable: 134,501 bytes in 1,030 blocks
    suppressed: 0 bytes in 0 blocks

This is because virNetClientSetCloseCallback was being reinitialized
incorrectly. By resetting the callbacks in a proper way, the leak is fixed.

9 years agoesx: Avoid using vSphere SessionIsActive function
Matthias Bolte [Mon, 15 Feb 2016 20:17:49 +0000 (21:17 +0100)]
esx: Avoid using vSphere SessionIsActive function

A login session with the vSphere API might expire after some idle time.
The esxVI_EnsureSession function uses the SessionIsActive function to
check if the current session has expired and a relogin needs to be done.

But the SessionIsActive function needs the Sessions.ValidateSession
privilege that is considered as an admin level privilege.

Only vCenter actually provides the SessionIsActive function. This results
in requiring an admin level privilege even for read-only operations on
a vCenter server.

ESX and VMware Server don't provide the SessionIsActive function and
the code already works around that. Use the same workaround for vCenter
again.

This basically reverts commit 5699034b65afd49d91dff13c46481bea545cbaac.

9 years agoError out on missing machine type in machine configs
Ján Tomko [Thu, 11 Feb 2016 09:55:07 +0000 (10:55 +0100)]
Error out on missing machine type in machine configs

Commit f1a89a8 allowed parsing configs from /etc/libvirt
without validating the emulator capabilities.

Check for the presence of os->type.machine even if the
VIR_DOMAIN_DEF_PARSE_SKIP_OSTYPE_CHECKS flag is set,
otherwise the daemon can crash on carelessly crafted input
in the config directory.

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

9 years agovsh: use virBufferTrim in vshOutputLogFile
Ján Tomko [Fri, 12 Feb 2016 12:49:18 +0000 (13:49 +0100)]
vsh: use virBufferTrim in vshOutputLogFile

Use virBufferTrim to strip the extra newline at the end
of the message instead of open-coding it after the buffer's
string is formatted.

9 years agoqemu: Introduce qemuBuildMonitorCommandLine
John Ferlan [Wed, 17 Feb 2016 22:27:21 +0000 (17:27 -0500)]
qemu: Introduce qemuBuildMonitorCommandLine

Add new function to manage adding the '-mon' or '-monitor' options to
the command line removing that task from the mainline qemuBuildCommandLine.

Also adjusted qemuBuildChrChardevStr and qemuBuildChrArgStr to use
const virDomainChrSourceDef *def rather than virDomainChrSourceDefPtr def.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Introduce qemuBuildSgaCommandLine
John Ferlan [Wed, 17 Feb 2016 22:19:00 +0000 (17:19 -0500)]
qemu: Introduce qemuBuildSgaCommandLine

Add new function to manage adding the '-device sga' to the command
line removing that task from the mainline qemuBuildCommandLine

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Introduce qemuBuildSmbiosCommandLine
John Ferlan [Wed, 17 Feb 2016 22:10:37 +0000 (17:10 -0500)]
qemu: Introduce qemuBuildSmbiosCommandLine

Add new function to manage adding the '-smbios' options to the command
line removing that task from the mainline qemuBuildCommandLine

Also while I was looking at it, move the uuid processing closer to usage.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Introduce qemuBuildNumaCommandLine
John Ferlan [Wed, 17 Feb 2016 21:56:37 +0000 (16:56 -0500)]
qemu: Introduce qemuBuildNumaCommandLine

Add new function to manage adding the '-numa' options to the command
line removing that task from the mainline qemuBuildCommandLine

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Introduce qemuBuildIOThreadCommandLine
John Ferlan [Wed, 17 Feb 2016 21:27:30 +0000 (16:27 -0500)]
qemu: Introduce qemuBuildIOThreadCommandLine

Add new function to manage adding the IOThread '-object' to the command
line removing that task from the mainline qemuBuildCommandLine

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Rename qemuBuildSmpArgStr to qemuBuildSmpCommandLine
John Ferlan [Wed, 17 Feb 2016 21:23:46 +0000 (16:23 -0500)]
qemu: Rename qemuBuildSmpArgStr to qemuBuildSmpCommandLine

Rename function and move code in from qemuBuildCommandLine to
keep smp related code together. Also make a few style changes
for long lines, return value change, and 2 spaces between functions.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Introduce qemuBuildMemCommandLine
John Ferlan [Wed, 17 Feb 2016 21:19:26 +0000 (16:19 -0500)]
qemu: Introduce qemuBuildMemCommandLine

Add new function to manage adding the '-m' memory options to the command
line removing that task from the mainline qemuBuildCommandLine

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Rename qemuBuildCpuArgStr to qemuBuildCpuCommandLine
John Ferlan [Wed, 17 Feb 2016 21:12:49 +0000 (16:12 -0500)]
qemu: Rename qemuBuildCpuArgStr to qemuBuildCpuCommandLine

Rename function and move code from mainline qemuBuildCommandLine to
keep alike code together.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Rename qemuBuildMachineArgStr
John Ferlan [Wed, 17 Feb 2016 21:04:17 +0000 (16:04 -0500)]
qemu: Rename qemuBuildMachineArgStr

Rename to qemuBuildMachineCommandLine to fit current (and future)
helper naming conventions.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Make basic upfront checks before create command
John Ferlan [Mon, 15 Feb 2016 21:55:08 +0000 (16:55 -0500)]
qemu: Make basic upfront checks before create command

Create qemuBuildCommandLineValidate to make some checks before trying
to build the command. This will move some logic from much later to much
earlier - we shouldn't be adjusting any data so that shouldn't matter.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: cgroup: fix cgroup permission logic
Bjoern Walk [Thu, 18 Feb 2016 09:19:51 +0000 (10:19 +0100)]
qemu: cgroup: fix cgroup permission logic

Fix logic error introduced in commit d6c91b3c which essentially broke
starting any domain.

Signed-off-by: Bjoern Walk <bwalk@linux.vnet.ibm.com>
9 years agovirsh: Remove <backingStore> when changing cdrom media source
Peter Krempa [Tue, 28 Jul 2015 13:34:58 +0000 (15:34 +0200)]
virsh: Remove <backingStore> when changing cdrom media source

Since the code is changing the source image path by modifying the
existing XML snippet the <backingStore> stays in place.

As <backingStore> is relevant to the <source> part of the image, the
update of that part makes the element invalid.

CD/floppy images usually don't have a backing chain and the element is
currently ignored though but it might start being used in the future so
let's start behaving correctly.

Drop the <backingStore> subtree once we want to update the XML.

Before this patch, you'd get:
$ virsh change-media --eject --print-xml 10 hdc
<disk type="file" device="cdrom">
      <driver name="qemu" type="qcow2"/>

      <backingStore type="file" index="1">
        <format type="qcow2"/>
        <source file="/var/lib/libvirt/images/vm.1436949097"/>
        <backingStore/>
      </backingStore>
      <target dev="hdc" bus="ide"/>
      ...
    </disk>

After:

 $ virsh change-media --eject --print-xml 10 hdc
<disk type="file" device="cdrom">
      <driver name="qemu" type="qcow2"/>

      <target dev="hdc" bus="ide"/>
      ...
    </disk>

9 years agoqemu: Remove local emulator
John Ferlan [Mon, 15 Feb 2016 21:23:28 +0000 (16:23 -0500)]
qemu: Remove local emulator

Remove the local variable 'emulator' and just use def->emulator

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Kill VIR_WRAPPER_SHELL_PREFIX
Peter Krempa [Wed, 17 Feb 2016 15:44:18 +0000 (16:44 +0100)]
qemu: Kill VIR_WRAPPER_SHELL_PREFIX

The migration code now doesn't need it, so remove the macros and the
configure code that is detecting it.

9 years agoqemu: Move PORT definitions to qemu_conf.c
Cole Robinson [Wed, 10 Feb 2016 14:43:57 +0000 (09:43 -0500)]
qemu: Move PORT definitions to qemu_conf.c

Which is the only user. That was the only reason for including
qemu_command.h, though we need to explicitly include qemu_domain.h
afterwards.

9 years agotests: Remove unused virtTestClearLineRegex
Cole Robinson [Wed, 17 Feb 2016 14:10:28 +0000 (09:10 -0500)]
tests: Remove unused virtTestClearLineRegex

This was only used for test 'xml blanking', which has now all
been removed, and isn't an ideal paradigm anyways since it
inhibits easy XML regeneration.

9 years agotests: lxcconf2xml: Drop XML blanking
Cole Robinson [Tue, 16 Feb 2016 17:07:32 +0000 (12:07 -0500)]
tests: lxcconf2xml: Drop XML blanking

Hardcode a UUID like we did for qemuargv2xml, so we can use standard
comparison helpers, which gives us VIR_TEST_REGENERATE_OUTPUT support

9 years agotests: qemuargv2xml: Drop memory XML blanking
Cole Robinson [Tue, 16 Feb 2016 16:59:08 +0000 (11:59 -0500)]
tests: qemuargv2xml: Drop memory XML blanking

The memory XML blanking is only there to avoid the unit= churn that
was added by default a long time ago.

Drop the blanking, switch over to using the standard comparison
helpers, and regenerate the output with VIR_TEST_REGENERATE_OUTPUT.

9 years agotests: qemuargv2xml: hardcode disk auth usage
Cole Robinson [Tue, 16 Feb 2016 16:49:07 +0000 (11:49 -0500)]
tests: qemuargv2xml: hardcode disk auth usage

If a qemuargv has iscsi or ceph secrets on the command line, we will
convert that to XML like:

  <auth username='myname'>
    <secret type='iscsi'/>
  </auth>

This is not valid XML, as either a UUID or usage must be specified in
the secret block. It's not clear though how the argv2xml code can do
anything correct here, since XML like this requires a libvirt secret
object to have already been defined.

The current test suite handles this by blanking out any <secret> block
in the XML. This avoids domainschematest failures.

Instead of blanking, let's hardcode a usage= name. This lets us test
the other bits of generated <secret> XML, and is a step towards wiring
up VIR_TEST_REGENERATE_OUTPUT

9 years agotests: qemuargv2xml: Remove UUID randomness
Cole Robinson [Tue, 16 Feb 2016 16:13:21 +0000 (11:13 -0500)]
tests: qemuargv2xml: Remove UUID randomness

Overwrite any randomly generated UUID to use a hardcoded value, so
we don't need to blank it when comparing XML.

9 years agotests: qemuargv2xml: Remove unneeded XML blanking
Cole Robinson [Tue, 16 Feb 2016 15:55:24 +0000 (10:55 -0500)]
tests: qemuargv2xml: Remove unneeded XML blanking

None of the test cases depend on dropping these XML bits

9 years agoqemu: Remove unnecessary calculations in qemuDomainSaveMemory
Peter Krempa [Wed, 17 Feb 2016 12:10:11 +0000 (13:10 +0100)]
qemu: Remove unnecessary calculations in qemuDomainSaveMemory

Now that the file migration doesn't require us to use 'dd' and other
legacy stuff for too old qemus we don't even have to calcuate the
offsets and other stuff.

9 years agoqemu: monitor: Remove unused qemuMonitorMigrateToFile
Peter Krempa [Wed, 17 Feb 2016 11:56:07 +0000 (12:56 +0100)]
qemu: monitor: Remove unused qemuMonitorMigrateToFile

With the currently supported qemus we always migrate to file
descriptors so the old function is not required any more.

Additionally QEMU_MONITOR_MIGRATE_TO_FILE_TRANSFER_SIZE macro is now
unused.

9 years agovircgroup: Update virCgroupDenyDevicePath stub
Michal Privoznik [Wed, 17 Feb 2016 13:25:35 +0000 (14:25 +0100)]
vircgroup: Update virCgroupDenyDevicePath stub

In cf113e8d we changed the declaration of
virCgroupAllowDevicePath() and virCgroupDenyDevicePath().
However, while updating the stub for non-cgroup platforms for the
former we forgot to update the latter too causing a build
failure.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoRevert "storageVolCreateXMLFrom: Check if backend knows how to createVol"
Ján Tomko [Mon, 15 Feb 2016 08:04:58 +0000 (09:04 +0100)]
Revert "storageVolCreateXMLFrom: Check if backend knows how to createVol"

This reverts commit 611a278fa46d3136b7fe5c6ab05e660ca3c8fdf4.

According to the original commit message, this is dead code:

  It is highly unlikely that a backend will know how to create a
  volume from a different volume (buildVolFrom) and not know how to
  create an empty volume (createVol).

9 years agosyms: add forgotten virAdmConnectClass symbol
Erik Skultety [Wed, 17 Feb 2016 11:59:31 +0000 (12:59 +0100)]
syms: add forgotten virAdmConnectClass symbol

Although it currently doesn't cause any linking issues, the symbol should be
exported correctly according to our conventions.

9 years agovirt-admin: Introduce cmdSrvList
Erik Skultety [Thu, 19 Nov 2015 15:12:50 +0000 (16:12 +0100)]
virt-admin: Introduce cmdSrvList

Since we introduced listing API earlier in these series, it's time
to wire up the API to the virt-admin client.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
9 years agoadmin: Introduce adminDaemonConnectListServers API
Erik Skultety [Fri, 14 Aug 2015 07:17:01 +0000 (09:17 +0200)]
admin: Introduce adminDaemonConnectListServers API

This API is merely a convenience API, i.e. when managing clients connected to
daemon's servers, we should know (convenience) which server the specific client
is connected to. This implies a client-side representation of a server along
with a basic API to let the administrating client know what servers are actually
available on the daemon.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoadmin: Introduce virAdmServer structure
Erik Skultety [Thu, 13 Aug 2015 14:20:27 +0000 (16:20 +0200)]
admin: Introduce virAdmServer structure

This is the key structure of all management operations performed on the
daemon/clients. An admin client needs to be able to identify
another client (either admin or non-privileged client) to perform an
action on it. This identification includes a server the client is
connected to, thus a client-side representation of a server is needed.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
9 years agoadmin: Move admin_server.{h,c} to admin.{h,c}
Erik Skultety [Mon, 10 Aug 2015 10:39:33 +0000 (12:39 +0200)]
admin: Move admin_server.{h,c} to admin.{h,c}

This change is merely because admin_server would contain all the code
from dispatchers and helpers to the actual APIs. Admin should have
similar structure to the daemon-side remote driver - dispatchers and
helpers in a separate module, APIs in a separate module.

Best viewed with -M.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agovirnetdaemon: Store servers in a hash table
Erik Skultety [Mon, 10 Aug 2015 11:01:44 +0000 (13:01 +0200)]
virnetdaemon: Store servers in a hash table

Since the daemon can manage and add (at fresh start) multiple servers,
we also should be able to add them from a JSON state file in case of a
daemon restart, so post exec restart support for multiple servers is also
provided. Patch also updates virnetdaemontest accordingly.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoutil: Refactor virHashForEach so it returns as soon as an iterator fails
Erik Skultety [Fri, 12 Feb 2016 09:15:57 +0000 (10:15 +0100)]
util: Refactor virHashForEach so it returns as soon as an iterator fails

The method will now return 0 on success and -1 on error, rather than number of
items which it iterated over before it returned back to the caller. Since the
only place where we actually check the number of elements iterated is in
virhashtest, return value of 0 and -1 can be a pretty accurate hint that it
iterated over all the items. However, if we really want to know the number of
items iterated over (like virhashtest does), a counter has to be provided
through opaque data to each iterator call. This patch adjusts return value of
virHashForEach, refactors the body, so it returns as soon as one of the
iterators fail and adjusts virhashtest to reflect these changes.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
9 years agoutil: Add a return value to void hash iterators
Erik Skultety [Fri, 12 Feb 2016 09:03:50 +0000 (10:03 +0100)]
util: Add a return value to void hash iterators

Our existing virHashForEach method iterates through all items disregarding the
fact, that some of the iterators might have actually failed. Errors are usually
dispatched through an error element in opaque data which then causes the
original caller of virHashForEach to return -1. In that case, virHashForEach
could return as soon as one of the iterators fail. This patch changes the
iterator return type and adjusts all of its instances accordingly, so the
actual refactor of virHashForEach method can be dealt with later.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
9 years agoqemu: cgroup: Setup cgroups for bios/firmware images
Peter Krempa [Tue, 16 Feb 2016 15:26:01 +0000 (16:26 +0100)]
qemu: cgroup: Setup cgroups for bios/firmware images

oVirt wants to use OVMF images on top of lvm for their 'logical'
storage thus we should set up device ACLs for them so it will actually
work.

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

9 years agoqemu: cgroup: Extract guts of qemuSetupImageCgroupInternal
Peter Krempa [Tue, 16 Feb 2016 14:46:40 +0000 (15:46 +0100)]
qemu: cgroup: Extract guts of qemuSetupImageCgroupInternal

They will later be reused for setting cgroup for other image backed
devices.

9 years agoqemu: cgroup: Split up qemuSetImageCgroupInternal
Peter Krempa [Tue, 16 Feb 2016 14:37:01 +0000 (15:37 +0100)]
qemu: cgroup: Split up qemuSetImageCgroupInternal

Separate the Teardown and Setup code paths into separate helpers.

9 years agoqemu: cgroup: Switch to qemu(Setup|Teardown)ImageCgroup
Peter Krempa [Mon, 15 Feb 2016 15:15:58 +0000 (16:15 +0100)]
qemu: cgroup: Switch to qemu(Setup|Teardown)ImageCgroup

For other objects we use the two functions rather than one with a bool.
Convert qemuSetImageCgroup to the same approach.

9 years agoqemu: cgroup: Avoid reporting errors from inaccessible NFS volumes
Peter Krempa [Tue, 16 Feb 2016 14:11:32 +0000 (15:11 +0100)]
qemu: cgroup: Avoid reporting errors from inaccessible NFS volumes

Rather than reporting it and then reseting the error, don't report it in
the first place.

9 years agoutil: cgroup: Allow ignoring EACCES in virCgroup(Allow|Deny)DevicePath
Peter Krempa [Tue, 16 Feb 2016 13:43:41 +0000 (14:43 +0100)]
util: cgroup: Allow ignoring EACCES in virCgroup(Allow|Deny)DevicePath

When adding disk images to ACL we may call those functions on NFS
shares. In that case we might get an EACCES, which isn't really relevant
since NFS would not hold a block device. This patch adds a flag that
allows to stop reporting an error on EACCES to avoid spaming logs.

Currently there's no functional change.

9 years agoutil: cgroup: Drop virCgroup(Allow|Deny)DeviceMajor
Peter Krempa [Tue, 16 Feb 2016 12:57:10 +0000 (13:57 +0100)]
util: cgroup: Drop virCgroup(Allow|Deny)DeviceMajor

Since commit 47e5b5ae virCgroupAllowDevice allows to pass -1 as either
the minor or major device number and it automatically uses '*' in place
of that. Reuse the new approach through the code and drop the duplicated
functions.

9 years agoutil: cgroup: Instrument virCgroupDenyDevice to handle -1 device number as *
Peter Krempa [Tue, 16 Feb 2016 13:01:25 +0000 (14:01 +0100)]
util: cgroup: Instrument virCgroupDenyDevice to handle -1 device number as *

Similarly to commit 47e5b5ae virCgroupDenyDevice will handle -1 as *.

9 years agoqemu: migration: Refactor code now that we assume support for fd migration
Peter Krempa [Mon, 15 Feb 2016 16:17:02 +0000 (17:17 +0100)]
qemu: migration: Refactor code now that we assume support for fd migration

After removing capability check for fd migration the code that was left
behind didn't make quite sense. The old exec migration would be used in
case when pipe() failed. Remove the old code and make failure of pipe()
a hard error.

This additionally removes usage of virCgroupAllowDevicePath outside of
qemu_cgroup.c.

9 years agoqemu: cgroup: Remove abandoned function qemuAddToCgroup
Peter Krempa [Tue, 16 Feb 2016 12:40:49 +0000 (13:40 +0100)]
qemu: cgroup: Remove abandoned function qemuAddToCgroup

This function doesn't do anything useful since 2049ef99425db33f1e66fa8.

9 years agoconf: Use a temporary int variable to store GIC version osstest/frozen/xen-4.5-testing
Andrea Bolognani [Tue, 16 Feb 2016 16:41:47 +0000 (17:41 +0100)]
conf: Use a temporary int variable to store GIC version

Since no value in the virGICVersion enumeration is negative, a clever
enough compiler can report an error such as

  src/conf/domain_conf.c:15337:75: error: comparison of unsigned enum
  expression < 0 is always false [-Werror,-Wtautological-compare]
    if ((def->gic_version = virGICVersionTypeFromString(tmp)) < 0 ||
        ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ ^ ~

virGICVersionTypeFromString() can, however, return a negative value if
the input string is not part of the enumeration, so we definitely need
that check.

Work around the problem by storing the return value in a temporary int
variable.

9 years agoqemu: Move qemuDomainNetVLAN
John Ferlan [Tue, 16 Feb 2016 15:11:34 +0000 (10:11 -0500)]
qemu: Move qemuDomainNetVLAN

Move function into qemu_domain.c.

9 years agoqemu: Move qemuAssign*Alias* API's into their own module
John Ferlan [Tue, 16 Feb 2016 15:24:35 +0000 (10:24 -0500)]
qemu: Move qemuAssign*Alias* API's into their own module

Create a new module qemu_alias.c to handle the qemuAssign*Alias* APIs
and the qemuDomainDeviceAliasIndex

9 years agoqemu: Move qemuNetworkPrepareDevices
John Ferlan [Mon, 15 Feb 2016 17:01:21 +0000 (12:01 -0500)]
qemu: Move qemuNetworkPrepareDevices

Move function to qemu_process.c, rename to qemuProcessNetworkPrepareDevices
and make it static.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Move and rename qemuOpenVhostNet
John Ferlan [Mon, 15 Feb 2016 16:51:48 +0000 (11:51 -0500)]
qemu: Move and rename qemuOpenVhostNet

Move function to qemu_interface.c and rename to qemuInterfaceOpenVhostNet

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Move qemuDomain*Address* functions
John Ferlan [Mon, 15 Feb 2016 18:08:02 +0000 (13:08 -0500)]
qemu: Move qemuDomain*Address* functions

Create new modules qemu_domain_address.c and qemu_domain_address.h to
contain all the new functions and header data. Additionally move any
supporting static functions.

Make qemuDomainSupportsPCI non static.

Also, move and rename the following:

qemuSetSCSIControllerModel to qemuDomainSetSCSIControllerModel
qemuCollectPCIAddress to qemuDomainCollectPCIAddress
qemuValidateDevicePCISlotsPIIX3 to qemuDomainValidateDevicePCISlotsPIIX3
qemuAssignDevicePCISlots to qemuDomainAssignDevicePCISlots

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Move qemuDomainSupports* functions
John Ferlan [Mon, 15 Feb 2016 16:44:21 +0000 (11:44 -0500)]
qemu: Move qemuDomainSupports* functions

Move qemuDomainSupportsNicdev and qemuDomainSupportsNetdev into qemu_domain.c
and expose from there.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Move qemuNetworkIfaceConnect to qemu_interface.c and rename
John Ferlan [Mon, 15 Feb 2016 15:52:50 +0000 (10:52 -0500)]
qemu: Move qemuNetworkIfaceConnect to qemu_interface.c and rename

Move the misplaced function from qemu_command.c to qemu_interface.c
since it's closer in functionality there and had less to do with building
the command line.

Rename function to qemuInterfaceBridgeConnect and modify callers.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Move qemuPhysIfaceConnect to qemu_interface.c and rename
John Ferlan [Mon, 15 Feb 2016 15:26:40 +0000 (10:26 -0500)]
qemu: Move qemuPhysIfaceConnect to qemu_interface.c and rename

Move the misplaced function from qemu_command.c to qemu_interface.c
since it's closer in functionality there and had less to do with building
the command line.

Rename function to qemuInterfaceDirectConnect and modify callers.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Move qemuVirCommandGetDevSet
John Ferlan [Mon, 15 Feb 2016 14:38:49 +0000 (09:38 -0500)]
qemu: Move qemuVirCommandGetDevSet

Move function closer to where it's used in qemuBuildTPMBackendStr

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Move qemuBuildTPMDevStr
John Ferlan [Mon, 15 Feb 2016 14:32:23 +0000 (09:32 -0500)]
qemu: Move qemuBuildTPMDevStr

Move function closer to where it's used in qemuBuildTPMCommandLine

Also fix function header to match current coding practices

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Move qemuVirCommandGetFDSet
John Ferlan [Mon, 15 Feb 2016 14:28:25 +0000 (09:28 -0500)]
qemu: Move qemuVirCommandGetFDSet

Move function closer to where it's used in qemuBuildTPMCommandLine

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoqemu: Move qemuBuildTPMBackendStr
John Ferlan [Mon, 15 Feb 2016 14:26:41 +0000 (09:26 -0500)]
qemu: Move qemuBuildTPMBackendStr

Move function closer to where it's called in qemuBuildTPMCommandLine

Also adjust function header to fit current coding guidelines

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agotests: Add more GIC test cases
Andrea Bolognani [Wed, 3 Feb 2016 13:35:41 +0000 (14:35 +0100)]
tests: Add more GIC test cases

Test all kinds of scenarios, including guests asking for GIC but
failing to specify a version, guests specifying an invalid version
and guests trying to use GIC with non-virt or even non-ARM machines.

9 years agotests: Reorganize and simplify GIC test cases
Andrea Bolognani [Wed, 3 Feb 2016 15:58:20 +0000 (16:58 +0100)]
tests: Reorganize and simplify GIC test cases

Unify the naming to prepare for new test cases that will be added
later on.

Convert a couple of output XML files for the qemuxml2xml test to
symlinks while at it, since they were identical to the corresponding
input XML files anyways.

Moreover, since we're only interested in testing GIC support here,
simplify XML files by getting rid of the unrelevant bits.

9 years agoqemu: Always enable GIC on ARM virt machines
Andrea Bolognani [Wed, 3 Feb 2016 18:49:27 +0000 (19:49 +0100)]
qemu: Always enable GIC on ARM virt machines

GIC is always available to ARM virt machines, and the domain XML should
reflect this fact.

9 years agoqemu: Default to GIC v2
Andrea Bolognani [Wed, 3 Feb 2016 18:49:07 +0000 (19:49 +0100)]
qemu: Default to GIC v2

When a domain is configured to use GIC but no version has been
specified by the user, default to GIC v2.

9 years agoconf: Use virGICVersion enumeration in virDomainDef
Andrea Bolognani [Wed, 3 Feb 2016 13:33:28 +0000 (14:33 +0100)]
conf: Use virGICVersion enumeration in virDomainDef

Instead of allowing any random positive number, restrict the possible
values to the ones that are part of the virGICVersion enumeration.

9 years agoschema: List allowed GIC versions
Andrea Bolognani [Wed, 3 Feb 2016 13:34:32 +0000 (14:34 +0100)]
schema: List allowed GIC versions

This change allows to use "host" as a GIC version in the domain XML.

Since we'll need to update the virGICVersion enumeration to support
new GIC versions anyway, it makes sense to be a bit more strict in
the schema as well and reject values that are not in the enumeration.

9 years agogic: Introduce virGICVersion enumeration
Andrea Bolognani [Wed, 3 Feb 2016 11:49:51 +0000 (12:49 +0100)]
gic: Introduce virGICVersion enumeration

We currently blindly accept any numeric value as a GIC version, even
though only GIC v2 and GIC v3 actually exist; on the other hand, we
reject "host", which is a perfectly legitimate value for QEMU guests.

This new enumeration contains all GIC versions libvirt is aware of.

9 years agoqemu: fix hot unplug of PCI devices with VFIO
Ludovic Beliveau [Fri, 5 Feb 2016 19:07:50 +0000 (14:07 -0500)]
qemu: fix hot unplug of PCI devices with VFIO

Currently, on hot unplug of PCI devices with VFIO driver for QEMU, libvirt is
trying to restore the host devices to it's previous value (basically a chown
on the previous user/group).

However for devices with VFIO driver, when the device is unbinded it is
removed from the /dev/vfio file system causing the restore label to fail.

The fix is to not restore the label for those PCI devices since they are going
to be teared down anyway.

Signed-off-by: Ludovic Beliveau <ludovic.beliveau@windriver.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoSpell VMware with a lowercase w
Ján Tomko [Mon, 15 Feb 2016 14:34:24 +0000 (15:34 +0100)]
Spell VMware with a lowercase w

Replace all occurrences of VMWare outside the news.

9 years agovsh: Replace vshPrint macro with function
Peter Krempa [Fri, 12 Feb 2016 13:09:02 +0000 (14:09 +0100)]
vsh: Replace vshPrint macro with function

The macro would eat the first parameter. In some cases the format string
for vshPrint was eaten. In other cases the calls referenced variables
which did not exist in the given context. Avoid errors by doing compile
time checking.

9 years agovsh: Simplify bailing out on OOM conditions
Peter Krempa [Fri, 12 Feb 2016 13:00:28 +0000 (14:00 +0100)]
vsh: Simplify bailing out on OOM conditions

When we hit OOM it doesn't really make sense to format the error message
by attempting to allocate it. Introduce a simple helper that prints a
static message and terminates the execution.

9 years agoutil: clean up and expand 802.1QbX negotiation logging
Laine Stump [Thu, 11 Feb 2016 20:24:17 +0000 (15:24 -0500)]
util: clean up and expand 802.1QbX negotiation logging

The existing log messages for this have several problems; there are
two lines of log when one will suffice, they duplicate the function
name in log message (when it's already included by VIR_DEBUG), they're
missing some useful bits, they get logged even when the call is a NOP.

This patch cleans up the problems with those existing logs, and also
adds a new VIR_INFO-level log down at the function that is actually
creating and sending the netlink message that logs *everything* going
into the netlink message (which turns out to be much more useful in
practice for me; I didn't want to eliminate the logs at the existing
location though, in case they are useful in some scenario I'm
unfamiliar with; anyway those logs are remaining at debug level, so it
shouldn't be a bother to anyone).

9 years agonetwork: consolidated info log for all network allocate/free operations
Laine Stump [Tue, 9 Feb 2016 17:28:48 +0000 (12:28 -0500)]
network: consolidated info log for all network allocate/free operations

There are three functions that deal with allocating and freeing
devices from a networks netdev/pci device pool:
network(Allocate|Notify|Release)ActualDevice(). These functions also
maintain a counter of the number of domains currently using a network
(regardless of whether or not that network uses a device pool). Each
of these functions had multiple log messages (output using VIR_DEBUG)
that were in slightly different formats and gave varying amounts of
information.

This patch creates a single function to log the pertinent information
in a consistent manner for all three of these functions. Along with
assuring that all the functions produce a consistent form of output
(and making it simpler to change), it adds the MAC address of the
domain interface involved in the operation, making it possible to
verify which interface of which domain the operation is being done for
(assuming that all MAC addresses are unique, of course).

All of these messages are raised from DEBUG to INFO, since they don't
happen that often (once per interface per domain/libvirtd start or
domain stop), and can be very informative and helpful - eliminating
the need to log debug level messages makes it much easier to sort
these out.

9 years agonetwork: consolidate connection count updates for device pool
Laine Stump [Thu, 11 Feb 2016 18:52:04 +0000 (13:52 -0500)]
network: consolidate connection count updates for device pool

networkReleaseActualDevice() and networkNotifyActualDevice() both were
updating the individual devices' connections count in two separate
places (unlike networkAllocateActualDevice() which does it in a single
unified place after success:). The code is correct, but prone to
confusion / later breakage. All of these updates are anyway located at
the end of if/else clauses that are (with the exception of a single
VIR_DEBUG() in each case) immediately followed by the success: label
anyway, so this patch replaces the duplicated ++/-- instructions with
a single ++/-- inside a qualifying "if (dev)" down below success:.
(NB: if dev != NULL, by definition we are using a device (either pci
or netdev, doesn't matter for these purposes) from the network's pool)

The VIR_DEBUG args (which will be replaced in a followup patch anyway)
were all adjusted to account for the connection count being out of
date at the time.

9 years agorbd: Use RBD fast-diff for querying actual volume allocation
Wido den Hollander [Thu, 11 Feb 2016 16:04:17 +0000 (17:04 +0100)]
rbd: Use RBD fast-diff for querying actual volume allocation

Since Ceph version Infernalis (9.2.0) the new fast-diff mechanism
of RBD allows for querying actual volume usage.

Prior to this version there was no easy and fast way to query how
much allocation a RBD volume had inside a Ceph cluster.

To use the fast-diff feature it needs to be enabled per RBD image
and is only supported by Ceph cluster running version Infernalis
(9.2.0) or newer.

Without the fast-diff feature enabled libvirt will report an allocation
identical to the image capacity. This is how libvirt behaves currently.

'virsh vol-info rbd/image2' might output for example:

  Name:           image2
  Type:           network
  Capacity:       1,00 GiB
  Allocation:     124,00 MiB

Newly created volumes will have the fast-diff feature enabled if the
backing Ceph cluster supports it.

Signed-off-by: Wido den Hollander <wido@widodh.nl>
9 years agorbd: rbd_diff_iterate2() is available in librbd since 266
Wido den Hollander [Thu, 11 Feb 2016 16:04:16 +0000 (17:04 +0100)]
rbd: rbd_diff_iterate2() is available in librbd since 266

In commit 0b15f920 there is a #ifdef which requires LIBRBD_VERSION_CODE
266 or newer for rbd_diff_iterate2()

rbd_diff_iterate2() is available since 266, so this if-statement should
require anything newer than 265.

Signed-off-by: Wido den Hollander <wido@widodh.nl>
9 years agorbd: Add volStorageBackendRBDGetFeatures() for internal calls
Wido den Hollander [Thu, 11 Feb 2016 16:04:15 +0000 (17:04 +0100)]
rbd: Add volStorageBackendRBDGetFeatures() for internal calls

As more and more features are added to RBD volumes we will need to
call this method more often.

By moving it into a internal function we can re-use code inside the
storage backend.

Signed-off-by: Wido den Hollander <wido@widodh.nl>
9 years agodomsuspend: Fix warning on mingw build
Andrea Bolognani [Wed, 10 Feb 2016 18:44:01 +0000 (19:44 +0100)]
domsuspend: Fix warning on mingw build

Commit d82170d introduced a workaround for domtop: in that example
program, we define a symbol called ERROR for our own use, but since
a symbol with the same name is already defined in one of mingw's
header files, we get a warning when using that compiler.

domsuspend defines the same problematic symbol, so the workaround
has been copied over.

9 years agostorageVolCreateXMLFrom: Check if backend knows how to createVol
Michal Privoznik [Wed, 10 Feb 2016 16:17:00 +0000 (17:17 +0100)]
storageVolCreateXMLFrom: Check if backend knows how to createVol

It is highly unlikely that a backend will know how to create a
volume from a different volume (buildVolFrom) and not know how to
create an empty volume (createVol). But:
1) we call the function without any prior check so if that's the
case we would SIGSEGV immediatelly
2) it's better to be safe than sorry.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agostorageVolCreateXML: Swap order of two operations
Michal Privoznik [Wed, 10 Feb 2016 16:05:03 +0000 (17:05 +0100)]
storageVolCreateXML: Swap order of two operations

Firstly, we realloc internal list to hold new item (=volume that
will be potentially created) and then we check whether we
actually know how to create it. If we don't we consume more
memory than we really need for no good reason.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirsh: Teach vol-create-as to --print-xml
Michal Privoznik [Wed, 10 Feb 2016 15:48:15 +0000 (16:48 +0100)]
virsh: Teach vol-create-as to --print-xml

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

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agocmdVolCreateAs: Rework to follow usual func pattern
Michal Privoznik [Wed, 10 Feb 2016 15:35:48 +0000 (16:35 +0100)]
cmdVolCreateAs: Rework to follow usual func pattern

The way we usually write functions is that we start the work and
if something goes bad we goto cleanup and roll back there. Or
just free resources that are no longer needed. Do the same here.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirportallocatortest: Run on linux only
Michal Privoznik [Fri, 12 Feb 2016 12:48:02 +0000 (13:48 +0100)]
virportallocatortest: Run on linux only

After the rework of mocking of our tests there's the
virportallocator test failing to link on mingw. Well, it's the
mocking library actually:

../gnulib/lib/.libs/libgnu.a(bind.o): In function `rpl_bind':
/home/jenkins/libvirt-mingw/build32/gnulib/lib/../../../gnulib/lib/bind.c:33: multiple definition of `rpl_bind'
.libs/virportallocatormock_la-virportallocatormock.o:/home/jenkins/libvirt-mingw/build32/tests/../../tests/virportallocatormock.c:79: first defined here

I've no idea why this matters to mingw and does not to others.
Nevertheless, if we make the test linux only the problem goes
away.

Apparently, our test for RTLD_NEXT is not sufficient because
mingw32 defines it. Lets put aside for a while fact that it has
the same value as RTLD_DEFAULT which by description has different
meaning, shall we?

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovz: fix race condition when adding domain to domains list
Mikhail Feoktistov [Wed, 10 Feb 2016 09:39:14 +0000 (12:39 +0300)]
vz: fix race condition when adding domain to domains list

Race condition:
User calls defineXML to create new instance.
The main thread from vzDomainDefineXMLFlags() creates new instance by prlsdkCreateVm.
Then this thread calls prlsdkAddDomain to add new domain to domains list.
The second thread receives notification from hypervisor that new VM was created.
It calls prlsdkHandleVmAddedEvent() and also tries to add new domain to domains list.
These two threads call virDomainObjListFindByUUID() from prlsdkAddDomain() and don't find new domain.
So they add two domains with the same uuid to domains list.

This fix splits logic of prlsdkAddDomain() into two functions.
1. vzNewDomain() creates new empty domain in domains list with the specific uuid.
2. prlsdkLoadDomain() add data from VM to domain object.

New algorithm for creating an instance:
In vzDomainDefineXMLFlags() we add new domain to domain list by calling vzNewDomain()
and only after that we call CreateVm() to create VM.
It means that we "reserve" domain object with the specific uuid.
After creation of new VM we add info from this VM
to reserved domain object by calling prlsdkLoadDomain().

Before this patch prlsdkLoadDomain() worked in 2 different cases:
1. It creates and initializes new domain. Then updates it from sdk handle.
2. It updates existed domain from sdk handle.
In this patch we remove code which creates new domain from LoadDomain()
and move it to vzNewDomain().
Now prlsdkLoadDomain() only updates domain from skd handle.

In notification handler prlsdkHandleVmAddedEvent() we check
the existence of a domain and if it doesn't exist we add new domain by calling
vzNewDomain() and load info from sdk handle via prlsdkLoadDomain().

9 years agovz: fix notification subscription
Mikhail Feoktistov [Wed, 10 Feb 2016 09:39:13 +0000 (12:39 +0300)]
vz: fix notification subscription

Bug cause:
Update the domain that is subscribed to hypervisor notification.
LoadDomain() rewrites notifications fields in vzDomObj structure and makes domain as "unsubscribed".
Fix:
Initialize notification fields in vzDomObj only if we create a new domain.
And do not reinitialize these fields if we update domain (by calling LoadDomain with olddom argument)

9 years agovz: remove unused struct field
Mikhail Feoktistov [Wed, 10 Feb 2016 09:39:12 +0000 (12:39 +0300)]
vz: remove unused struct field

In commit 7039bb3c we have removed code that saves uuid to vzDomObj.uuid
So this field is no longer needed.

9 years agovz: make output arguments in prlsdkGetDomainIds as optional
Mikhail Feoktistov [Wed, 10 Feb 2016 09:39:11 +0000 (12:39 +0300)]
vz: make output arguments in prlsdkGetDomainIds as optional

prlsdkGetDomainIds() returns name and uuid for specified instance.
Now output arguments can be NULL.
It allows to get only necessary info(name or uuid).

9 years agoChange maintainers list
Maxim Nestratov [Fri, 12 Feb 2016 10:06:05 +0000 (13:06 +0300)]
Change maintainers list

Add Maxim Nestratov to the commiters list.
Move Dmitry Guryanov to the previous maintainers list.

9 years agotests: Rename virmockdbus -> virdbusmock for consistency
Andrea Bolognani [Thu, 11 Feb 2016 13:08:11 +0000 (14:08 +0100)]
tests: Rename virmockdbus -> virdbusmock for consistency

All mock libraries were called vir*mock except for this one; now
the naming is consistent across the board.

9 years agotests: Don't use "lib" prefix for mock libraries
Andrea Bolognani [Thu, 11 Feb 2016 12:59:41 +0000 (13:59 +0100)]
tests: Don't use "lib" prefix for mock libraries

virportallocatormock was the only one using it, and has been
changed accordingly.

9 years agotests: Allow use of close() in mock libraries
Andrea Bolognani [Thu, 11 Feb 2016 12:51:26 +0000 (13:51 +0100)]
tests: Allow use of close() in mock libraries

As mock libraries are not to be linked against libvirt, the
sc_prohibit_close syntax-check rule does not apply.

This fixes a syntax-check failure introduced by commit a03cbfe0fb.

9 years agotests: Split off the mock part of the port allocator test
Andrea Bolognani [Thu, 11 Feb 2016 12:46:16 +0000 (13:46 +0100)]
tests: Split off the mock part of the port allocator test

Instead of compiling either the mock or the non-mock part of the
file based on a compiler flag, split the mock part off to its
own file.

9 years agoconf: snapshot: Avoid autogenerating duplicate snapshot names
Peter Krempa [Thu, 11 Feb 2016 08:57:45 +0000 (09:57 +0100)]
conf: snapshot: Avoid autogenerating duplicate snapshot names

The snapshot name generator truncates the original file name after a '.'
and replaces the suffix with the snapshot name. If two disks source
images differ only in the suffix portion, the generated name will be
duplicate.

Since this is a corner case just error out stating that a duplicate name
was generated. The user can work around this situation by providing
the file names explicitly.

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

9 years agoconf: snapshot: Refactor virDomainSnapshotDefAssignExternalNames
Peter Krempa [Thu, 11 Feb 2016 08:42:36 +0000 (09:42 +0100)]
conf: snapshot: Refactor virDomainSnapshotDefAssignExternalNames

Get rid of one indentation level by negating condition and remove ugly
pointer arithmetic at the cost of one extra allocation.

9 years agoconf: snapshot: Extract code to generate default external file names
Peter Krempa [Thu, 11 Feb 2016 08:07:05 +0000 (09:07 +0100)]
conf: snapshot: Extract code to generate default external file names