Commit Graph

20546 Commits

Author SHA1 Message Date
Laine Stump
070732735f interface: re-use name and mac address rather than re-retrieving
Getting the MAC address of an interface is actually fairly expensive,
and we've already gotten it and stored it into def, so just keep def
around a bit longer and retrieve it from there.

This reduces the time for "virsh iface-list --all" from 28 to 23
seconds when there are 400 interfaces.
2015-10-02 11:16:11 -04:00
Laine Stump
6fda6699e5 interface: report correct interface count when not returning list
The spec for virConnectListAllInterfaces says that if the pointer that
is supposed to hold the list of interfaces is NULL, the function
should just return the count of interfaces that matched the filter,
but the code never increments the count if the list pointer is NULL.
2015-10-02 11:16:11 -04:00
Laine Stump
ead2df32ba interface: fail on OOM from virGetInterface() 2015-10-02 11:16:11 -04:00
Daniel P. Berrange
e3155cac18 libvirt.spec: fix accidental conditional inclusion of polkit docs
In previous change:

  commit 29b5167417
  Author: Jiri Denemark <jdenemar@redhat.com>
  Date:   Tue Aug 4 14:05:52 2015 +0200

    examples: Add example polkit ACL rules

The polkit examples were accidentally added to the spec inside
a %if %{with_network} conditional.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2015-10-02 16:08:02 +01:00
Martin Kletzander
41c2aa729f qemu: Use memory-backing-file only when needed
We are using memory-backing-file even when it's not needed, for example
if user requests hugepages for memory backing, but does not specify any
pagesize or memory node pinning.  This causes migrations to fail when
migrating from older libvirt that did not do this.  So similarly to
commit 7832fac847 which does it for
memory-backend-ram, this commit makes is more generic and
backend-agnostic, so the backend is not used if there is no specific
pagesize of hugepages requested, no nodeset the memory node should be
bound to, no memory access change required, and so on.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-10-02 16:14:26 +02:00
Martin Kletzander
a2dba3ceb2 qemu: Add -mem-path even with numa
So since the introduction of the memory-backend-file object until now we
only added '-mem-path' for non-NUMA guests and we used the parameters of
the memory-backend-file object to specify the path to the hugetlbfs
mount.  But hugepages can be also used without memory-backend-file
object, as it used to be before its introduction.  Let's just get this
part of the code back and properly append the '-mem-path' for NUMA
guests as well, but only when the memory backend is not needed.

This parameter is already being applied when no numa is requested and
because we still use memory-object-file unconditionally for
hugepage-backed NUMA guests, this should not fire until later.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-10-02 16:14:26 +02:00
Martin Kletzander
ad8ab88c91 qemu: Extract -mem-path building into its own function
That function is called qemuBuildMemPathStr() and will be used in
other places in the future.  The change in the test suite is proper due
to the fact that -mem-prealloc makes only sense with -mem-path (from
qemu documentation -- html/qemu-doc.html).

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-10-02 16:14:26 +02:00
Martin Kletzander
5f12b8444c qemu: Move memory size detection to the top of the function
To get rid of very long line and make it more readable.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-10-02 16:14:26 +02:00
Martin Kletzander
04b57b4ae1 qemu: Move simplification variable to begining of the function
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-10-02 16:14:26 +02:00
Martin Kletzander
37e85cff06 docs: Add Cuckoo Sandbox into apps.html
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-10-02 16:14:26 +02:00
Pavel Fedin
12a73cf14a qemu: Add test cases for gic-version option
These tests make sure that we can use this option only when the capability is
set.

Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
2015-10-02 16:14:26 +02:00
Pavel Fedin
b7621b7e96 qemu: Add support for gic-version machine option
Support for GICv3 has been recently introduced in qemu using gic-version
option for the 'virt' machine. The option can actually take values of
'2', '3' and 'host', however, since in libvirt this is a numeric
parameter, we limit it only to 2 and 3. Value of 2 is not added to the
command line in order to keep backward compatibility with older qemu
versions.

Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
2015-10-02 16:14:26 +02:00
Pavel Fedin
399d7044cd qemu: Introduce QEMU_CAPS_MACH_VIRT_GIC_VERSION capability
Unfortunately qemu currently doesn't offer introspection for machine types,
so we have to rely on version number, similar to QEMU_CAPS_MACHINE_USB_OPT.

Signed-off-by: Pavel Fedin <p.fedin@samsung.com>
2015-10-02 16:14:26 +02:00
Martin Kletzander
4373043f55 Post-release version bump to 1.2.21
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-10-02 16:14:26 +02:00
Daniel Veillard
439760214c Release of libvirt-1.2.20
* docs/news.html.in libvirt.spec.in: update for new release
* po/*.po*: regenerate localization
2015-10-02 13:17:16 +02:00
Cole Robinson
68572de822 qemu: Fix dynamic_ownership qemu.conf setting
Commit 307fb904 (Sep 10) added a 'privileged' variable when creating
the DAC driver:

@@ -153,6 +157,7 @@ virSecurityManagerNewDAC(const char *virtDriver,
                          bool defaultConfined,
                          bool requireConfined,
                          bool dynamicOwnership,
+                         bool privileged,
                          virSecurityManagerDACChownCallback chownCallback)

But argument order is mixed up at the caller, swapping dynamicOwnership
and privileged values. This corrects the argument order

https://bugzilla.redhat.com/show_bug.cgi?id=1266628
2015-09-29 08:26:52 -04:00
Michal Privoznik
d72a8f7465 virsh: Preserve startupPolicy in change-media command
https://bugzilla.redhat.com/show_bug.cgi?id=1250331

Even after my rework of startupPolicy handling, one command
slipped my attention. The change-media command has a very unique
approach to constructing disk XML. However, it will not preserve
startupPolicy attribute.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-09-29 13:29:29 +02:00
Ján Tomko
1b5685dada Create a shallow copy for volume building only if supported
Since the previous commit, the shallow copy is only used inside
the if (backend->buildVol) if.
2015-09-29 10:45:01 +02:00
Ján Tomko
56a4e9cb61 Update pool allocation with new values on volume creation
Since commit e0139e3, we update the pool allocation with
the user-provided allocation values.

For qcow2, the allocation is ignored for volume building,
but we still subtracted it from pool's allocation.
This can result in interesting values if the user-provided
allocation is large enough:

Capacity:       104.71 GiB
Allocation:     109.13 GiB
Available:      16.00 EiB

We already do a VolRefresh on volume creation. Also refresh
the volume after creating and use the new value to update the pool.

https://bugzilla.redhat.com/show_bug.cgi?id=1163091
2015-09-29 10:45:01 +02:00
John Ferlan
5e06a4f063 conf: Fix virtType check
Commit id '7383b8cc' changed virDomainDef 'virtType' to an enum, that
caused a build failure on some archs due to comparing an unsigned value
to < 0.  Adjust the fetch of 'type' to be into temporary 'int virtType'
and then assign that virtType to the def->virtType
2015-09-25 17:33:05 -04:00
Shivangi Dhir
7383b8cc06 qemu: Make virtType of type virDomainVirtType
Earlier virtType was of type int. After, introducing the enum VIR_DOMAIN_VIRT_NONE,
the type of virtType is modified to virDomainVirtType.
2015-09-25 15:34:09 -04:00
Shivangi Dhir
62569e45ea conf: Add new VIR_DOMAIN_VIRT_NONE enum
Introduce VIR_DOMAIN_VIRT_NONE to give domaintype the default value of zero.
This is specially helpful in constructing better error messages
when we don't want to look up the default emulator by virtType.

The test data in vircapstest.c is also modified to reflect this change.
2015-09-25 15:33:53 -04:00
Guido Günther
fd00f0e6c7 Use daemon log facility for journald
otherwise messages end up in /var/log/kern.log if journald forwards to
syslog.

Reference: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=799633
2015-09-25 16:22:39 +02:00
Michal Privoznik
1fb8ac4c79 tools: Link libvirt.la and readline to libvirt_shell.a
So, our mingw build is broken. It's because while libvirt_shell
library is using some of our internal APIs, e.g. virStrndup, and
readline API but it's not being linked with nor libvirt.la nor
libreadline.  Only subsequent users of the library, like virsh,
do link to the needed libraries. In fact, I'm surprised Linux
linker doesn't care, because how can it make a static library
with missing symbols is mystery to me.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-09-25 14:33:06 +02:00
Andrea Bolognani
08e5d1efcf maint: Remove control characters from LGPL license file 2015-09-25 09:16:24 +02:00
Jiri Denemark
c0806dc30b domain: Fix migratable XML with graphics/@listen
As of commit 6992994, we set graphics/@listen attribute according to the
first listen child element even if that element is of type='network'.
This was done for backward compatibility with applications which only
support the original listen attribute. However, by doing so we broke
migration to older libvirt which tried to check that the listen
attribute matches one of the listen child elements but which did not
take type='network' elements into account.

We are not concerned about compatibility with old applications when
formatting domain XML for migration for two reasons. The XML is consumed
only by libvirtd and the IP address associated with type='network'
listen address on the source host is just useless on the destination
host. Thus, we can safely avoid propagating the type='network' IP
address to graphics/@listen attribute when creating migratable XML.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-09-24 17:07:33 +02:00
Erik Skultety
2d9fcb3102 vsh: create a noinstall libvirt_shell library
Instead of referencing vsh sources in all relevant client targets,
create a library that the client can link against.
2015-09-24 16:58:28 +02:00
John Ferlan
a73c67b6cc qemu: Resolve Coverity RESOURCE_LEAK
This seemed to be more of a false positive as for some reason Coverity
was missing the "ret < 0" goto error condition and somehow believing that
event could be overwritten.  At first I thought it was just the ret != 0
condition difference, but it wasn't.

In any case, make use of the recent change to qemuDomainEventQueue to
check event == NULL and just pass it as a parameter directly in the
error path. That avoids the error.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2015-09-24 09:53:39 -04:00
John Ferlan
83cbbbef45 qemu: Clean up ret in qemuDomainSaveMemory and qemuDomainSaveInternal
As it turns out, ret can only be 0 or -1, so rather than have some comparisons
be "ret < 0" and others be "ret != 0", make them all "ret < 0".
2015-09-24 09:53:39 -04:00
John Ferlan
ace8e2276e qemu: Resolve Coverity CHECKED_RETURN
Coverity complains that return from virHookCall is not checked in
one place in qemuProcessStop.  Since the comment notes that we cannot
stop the operation even it if fails, just added the ignore_value.
2015-09-24 09:53:39 -04:00
John Ferlan
35369a7d48 virsh: Resolve Coverity DEADCODE
Use 'dead_error_condition' instead of 'dead_error_begin'
2015-09-24 09:53:38 -04:00
John Ferlan
a36b0ad2d5 tests: Resolve Coverity RESOURCE_LEAK
The cleanup path did not clear the reference for sk1 and sk2

Signed-off-by: John Ferlan <jferlan@redhat.com>
2015-09-24 09:53:38 -04:00
John Ferlan
6743809dbf tests: Resolve Coverity RESOURCE_LEAK
In the error path need to unref the 'caps' as well

Signed-off-by: John Ferlan <jferlan@redhat.com>
2015-09-24 09:53:38 -04:00
Michal Privoznik
a2ac63af0e virDomainRestore: Don't keep transient domains around
So while working on my previous patches, I've noticed that
virDomainRestore implementation in qemu and test drivers has the
same problem as I am fixing.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-09-24 10:52:38 +02:00
Michal Privoznik
f41be29635 qemu: Move vm->persistent check into qemuDomainRemoveInactive
So far we have the following pattern occurring over and over
again:

  if (!vm->persistent)
      qemuDomainRemoveInactive(driver, vm);

It's safe to put the check into the function and save some LoC.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-09-24 10:52:38 +02:00
Michal Privoznik
c99b8cec82 virDomainCreateXML: Make domain definition transient
https://bugzilla.redhat.com/show_bug.cgi?id=871452

So, you want to create a domain from XML. The domain already
exists in libvirt's database of domains. It's okay, because name
and UUID matches. However, on domain startup, internal
representation of the domain is overwritten with your XML even
though we claim that the XML you've provided is a transient one.
The bug is to be found across nearly all the drivers.
Le sigh.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-09-24 10:52:38 +02:00
Michal Privoznik
37405b9109 virDomainCreateXML: Don't remove persistent domains on error
https://bugzilla.redhat.com/show_bug.cgi?id=871452

Okay, so we allow users to 'virsh create' an already existing
domain, providing completely different XML than the one stored in
Libvirt. Well, as long as name and UUID matches. However, in some
drivers the code that handles errors unconditionally removes the
domain that failed to start even though the domain might have
been persistent. Fortunately, the domain is removed just from the
internal list of domains and the config file is kept around.

Steps to reproduce:

1) virsh dumpxml $dom > /tmp/dom.xml
2) change XML so that it is still parse-able but won't boot, e.g.
change guest agent path to /foo/bar
3) virsh create /tmp/dom.xml
4) virsh dumpxml $dom
5) Observe "No such domain" error

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-09-24 10:52:37 +02:00
Michal Privoznik
3824c19df8 docs: Add yet another libvirt based app
As announced on the list [1], Cherrypop is a management
application based on libvirt. It's a decentralized cloud software
with nice scaling ability.

1: https://www.redhat.com/archives/libvir-list/2015-September/msg00670.html

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-09-24 10:45:28 +02:00
Martin Kletzander
54cf313cdd Remove redundand assignment
I initially added this in order to keep the code more error-prone to
following additions, but it seems it's still frowned upon.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-09-24 10:20:33 +02:00
Michal Privoznik
cde3b97a26 qemuDomainDeviceDefPostParse: Drop useless checks
Now that virQEMUDriverCreateXMLConf is never called with NULL
(after 086f37e97a) we can safely drop useless check in
qemuDomainDeviceDefPostParse as we are guaranteed to be always
called with the driver initialized. Therefore checking if driver
is NULL makes no sense. Moreover, if we mix it with direct driver
dereference. And after that, we are sure that nor @cfg will be
NULL, therefore we can drop checks for that too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-09-24 07:31:47 +02:00
Peter Krempa
7acfb940f7 virsh: Fix job status indicator for 0 length block jobs
Although 0 length block jobs aren't entirely useful, the output of virsh
blockjob is empty due to the condition that suppresses the output for
migration jobs that did not start. Since the only place that actually
uses the condition that suppresses the output is in migration, let's
move the check there and thus add support for 0 of 0 equaling to 100%.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1196711
2015-09-23 15:06:56 +02:00
Peter Krempa
d7a0386e22 qemu: Refresh memory size only on fresh starts
Qemu unfortunately doesn't update internal state right after migration
and so the actual balloon size as returned by 'query-balloon' are
invalid for a while after the CPUs are started after migration. If we'd
refresh our internal state at this point we would report invalid current
memory size until the next balloon event would arrive.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1242940
2015-09-23 14:22:29 +02:00
Peter Krempa
624ec1c2f9 qemu: Align memory module sizes to 2MiB
My original implementation was based on a qemu version that still did
not have all the checks in place. Using sizes that would align to odd
megabyte increments will produce the following error:

qemu-kvm: -device pc-dimm,node=0,memdev=memdimm0,id=dimm0: backend memory size must be multiple of 0x200000
qemu-kvm: -device pc-dimm,node=0,memdev=memdimm0,id=dimm0: Device 'pc-dimm' could not be initialized

Introduce an alignment retrieval function for memory devices and use it
to align the devices separately and modify a test case to verify it.
2015-09-23 13:54:54 +02:00
Jiri Denemark
035947eb87 virsh: Notify users about disconnects
After my "client rpc: Report proper error for keepalive disconnections"
patch, virsh would no long print a warning when it closes a connection
to a daemon after a keepalive timeout. Although the warning

    virsh # 2015-09-15 10:59:26.729+0000: 642080: info :
    libvirt version: 1.2.19
    2015-09-15 10:59:26.729+0000: 642080: warning :
    virKeepAliveTimerInternal:143 : No response from client
    0x7efdc0a46730 after 1 keepalive messages in 2 seconds

was pretty ugly, it was still useful. This patch brings the useful part
back while making it much nicer:

virsh # error: Disconnected from qemu:///system due to keepalive timeout

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-09-23 13:09:50 +02:00
Jiri Denemark
adf3be57df client rpc: Process pending data on error
Even though we hit an error in client's IO loop, we still want to
process any pending data. So instead of reporting the error right away,
we can finish the current iteration and report the error once we're done
with it. Note that the error is stored in client->error by
virNetClientMarkClose so we don't need to worry about it being reset or
rewritten by any API we call in the meantime.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-09-23 13:09:50 +02:00
Jiri Denemark
c91776d5ff client rpc: Report proper error for keepalive disconnections
Whenever a connection was closed due to keepalive timeout, we would log
a warning but the interrupted API would return rather useless generic
error:

    internal error: received hangup / error event on socket

Let's report a proper keepalive timeout error and make sure it is
propagated to all pending APIs. The error should be better now:

    internal error: connection closed due to keepalive timeout

Based on an old patch from Martin Kletzander.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2015-09-23 13:09:49 +02:00
Luyao Huang
363995b029 conf: escape string for disk driver name attribute
Just like e92e5ba1, this attribute was missed.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
2015-09-23 11:46:16 +02:00
Martin Kletzander
d772a70faa Use VIR_DIV_UP macro where possible
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2015-09-23 11:45:59 +02:00
Luyao Huang
789bdd7dea Makefile: fix build fail when make rpm
Build fail and error like this:

  CC       qemu/libvirt_driver_qemu_impl_la-qemu_command.lo
qemu/qemu_capabilities.c:46:27: fatal error: qemu_capspriv.h: No such file or directory
 #include "qemu_capspriv.h"

Add qemu_capspriv.h to source.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
2015-09-23 08:06:56 +02:00
Cole Robinson
dae1250b24 spec: Fix some warnings with latest rpmbuild
$ rpmbuild -ba libvirt.spec
warning: Macro expanded in comment on line 5: # If neither fedora nor rhel was defined, try to guess them from %{dist}

warning: Macro %enable_autotools defined but not used within scope
warning: Macro %client_only defined but not used within scope
...
2015-09-22 15:57:23 -04:00