]> git.ipfire.org Git - thirdparty/libvirt.git/log
thirdparty/libvirt.git
10 years agoRNG: Add 'ppc64le' arch and newer pseries-2.* machine types
Prerna Saxena [Thu, 26 Feb 2015 14:10:58 +0000 (08:10 -0600)] 
RNG: Add 'ppc64le' arch and newer pseries-2.* machine types

Acked-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Prerna Saxena <prerna@linux.vnet.ibm.com>
(cherry picked from commit 0afa6be8153518fad5862da022f63042cb72abbb)

10 years agoschema: Fix interface link state schema
Peter Krempa [Mon, 2 Mar 2015 16:21:23 +0000 (17:21 +0100)] 
schema: Fix interface link state schema

In commit edd1295e1da6bfe8e4e257e5fbfad71ac0bf7c87 I've introduced an
XML element that allows to configure state of the network interface
link. Somehow the RNG schema hunk ended up in a weird place in the
network schema definition. Move it to the right place and add a test
case.

Note that the link state is set up via the monitor at VM startup so I
originally didn't think of adding a test case.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1173468
(cherry picked from commit 8eb907b8d0fd73c8f88f9cd8df1fa0e7abf40c93)

10 years agoconf: De-duplicate scheduling policy enums
Martin Kletzander [Mon, 2 Mar 2015 16:14:39 +0000 (17:14 +0100)] 
conf: De-duplicate scheduling policy enums

Since adding the support for scheduler policy settings in commit
8680ea97, there are two enums with the same information.  That was
caused by rewriting the patch since first draft.

Find out thanks to clang, but there was no impact whatsoever.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
(cherry picked from commit 2fd5880b3b00cb6549242c613c5215617f29c428)

10 years agoqemu: Don't crash in qemuDomainOpenChannel()
Martin Kletzander [Mon, 2 Mar 2015 14:42:41 +0000 (15:42 +0100)] 
qemu: Don't crash in qemuDomainOpenChannel()

The problem here was that when opening a channel, we were checking
whether the channel given is alias (can't be NULL for running domain) or
it's name, which can be NULL (for example with spicevmc).  In case of
such domain qemuDomainOpenChannel() made the daemon crash.
STREQ_NULLABLE() is safe to use since the code in question is wrapped in
"if (name)" and is more readable, so use that instead of checking for
non-NULL "vm->def->channels[i]->target.name".

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
(cherry picked from commit b3ea0a8fb86a8024538c68ca1d43a2bbc0192a0f)

10 years agovirsh.pod: Update find-storage-pool-sources[-as] man page
John Ferlan [Wed, 25 Feb 2015 22:41:34 +0000 (17:41 -0500)] 
virsh.pod: Update find-storage-pool-sources[-as] man page

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

Add to the man page a more complete description of what exactly the
command expects on input and will return on output based on what is
currently supported.

Perhaps missing findPoolSources implementations are backends for
sheepdog and rbd.  Also missing any backend is zfs.

(cherry picked from commit 567bd0fa57025efe8eda8f39e48d957842e39d43)

10 years agoiscsi: Adjust error message for findStorageSources backend
John Ferlan [Wed, 25 Feb 2015 22:31:55 +0000 (17:31 -0500)] 
iscsi: Adjust error message for findStorageSources backend

The virStorageBackendISCSIFindPoolSources API only needs the 'host' name
in order to discover iSCSI pools, it returns the various device paths.
On input, it's also possible to further restrict a search by providing the
port attribute for the host element and the (undocumented) initiator element.

For example:

$  virsh find-storage-pool-sources-as iscsi
error: Failed to find any iscsi pool sources
error: invalid argument: hostname and device path must be specified for iscsi sources

$ virsh find-storage-pool-sources-as iscsi 192.168.122.1
<sources>
  <source>
    <host name='192.168.122.1' port='3260'/>
    <device path='iqn.2013-12.com.example:iscsi-chap-lclpool'/>
  </source>
</sources>

(cherry picked from commit 30f69ae86b888ca4b2957454d16d8e9b1501a510)

10 years agovirsh.pod: Add information regarding LXC for setmem, memtune, and dominfo
John Ferlan [Thu, 26 Feb 2015 23:31:06 +0000 (18:31 -0500)] 
virsh.pod: Add information regarding LXC for setmem, memtune, and dominfo

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

Modify the virsh man page to more accurately describe which values are
set by the virsh setmem and displayed by the virsh memtune or dominfo
based on the setmem command results.

(cherry picked from commit 69db32f93d7a22e7be04c2e9dc41a357f9811404)

10 years agodocs: add a note that attr 'managed' is only used by PCI devices
Erik Skultety [Fri, 27 Feb 2015 11:45:57 +0000 (12:45 +0100)] 
docs: add a note that attr 'managed' is only used by PCI devices

Our documentation isn't 100% clear about hostdev 'managed' attribute usage,
because it only makes sense to use it with PCI devices, yet we format
this attribute to all hostdev devices. By adding a note into the docs,
we can possibly avoid confusion from customer's side and also avoid a solution
using ternary logic.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1155887
(cherry picked from commit ccfe9e480986c075a6a04f7792a5b30350396d83)

10 years agoCheck if domain is running in qemuDomainAgentIsAvailable
Ján Tomko [Thu, 26 Feb 2015 13:00:47 +0000 (14:00 +0100)] 
Check if domain is running in qemuDomainAgentIsAvailable

If the domain is not running, the agent will not respond.
Do not even try.

https://bugzilla.redhat.com/show_bug.cgi?id=872424
(cherry picked from commit 723522328f2d92e4c2d5de35b3b3ec0302bb06ac)

10 years agoPass virDomainObjPtr to qemuDomainAgentAvailable
Ján Tomko [Fri, 27 Feb 2015 13:06:47 +0000 (14:06 +0100)] 
Pass virDomainObjPtr to qemuDomainAgentAvailable

Not just the DomainObj's private data.

(cherry picked from commit fbb94044eabf1853af605314da96b533f7c3d44e)

10 years agoCheck for qemu guest agent availability after getting the job
Ján Tomko [Thu, 26 Feb 2015 12:47:58 +0000 (13:47 +0100)] 
Check for qemu guest agent availability after getting the job

This way checks requiring the job can be done in qemuDomainAgentAvailable.

(cherry picked from commit c8b80b49f6db277eee1bf6caf9ff9cb8ffd91dfd)

10 years agostorage: fs: Ignore volumes that fail to open with EACCESS/EPERM
Cole Robinson [Mon, 27 Apr 2015 15:47:28 +0000 (11:47 -0400)] 
storage: fs: Ignore volumes that fail to open with EACCESS/EPERM

Trying to use qemu:///session to create a storage pool pointing at
/tmp will usually fail with something like:

$ virsh pool-start tmp
error: Failed to start pool tmp
error: cannot open volume '/tmp/systemd-private-c38cf0418d7a4734a66a8175996c384f-colord.service-kEyiTA': Permission denied

If any volume in an FS pool can't be opened by the daemon, the refresh
fails, and the pool can't be used.

This causes pain for virt-install/virt-manager though. Imaging a user
downloads a disk image to /tmp. virt-manager wants to import /tmp as
a storage pool, so we can detect what disk format it is, and set the
XML correctly. However this case will likely fail as explained above.

Change the logic here to skip volumes that fail to open. This could
conceivably cause user complaints along the lines of 'why doesn't
libvirt show $ROOT-OWNED-VOLUME-FOO', but figuring that currently
the pool won't even startup, I don't think there are any current
users that care about that case.

https://bugzilla.redhat.com/show_bug.cgi?id=1103308
(cherry picked from commit 56476f6a2d1564c040b749a385c3588a914921f0)

10 years agodomain: conf: Don't validate VM ostype/arch at daemon startup
Cole Robinson [Fri, 17 Apr 2015 20:37:57 +0000 (16:37 -0400)] 
domain: conf: Don't validate VM ostype/arch at daemon startup

When parsing XML, we validate the passed ostype + arch combo against
the detected hypervisor capabilities. This has led to the following
problem:

- Define x86 qemu guest
- qemu is inadvertently removed from the host
- libvirtd is restarted. fails to parse VM config since arch is removed
- 'virsh list --all' is now empty, user is wondering where their VMs went

Add a new internal flag VIR_DOMAIN_DEF_PARSE_SKIP_OSTYPE_CHECKS. Use
it when loading VM and snapshot configs from disk.

https://bugzilla.redhat.com/show_bug.cgi?id=1043572
(cherry picked from commit f1a89a8b6d1a1097e41a171a13b1984b06e8ab3e)

10 years agodomain: conf: Better errors on bad os <type> values
Cole Robinson [Thu, 16 Apr 2015 22:08:17 +0000 (18:08 -0400)] 
domain: conf: Better errors on bad os <type> values

If no <os><type> was specified:
  before: unknown OS type no OS type
  after : xml error: an os <type> must be specified

If an <os><type> is specified that's not in our capabiliities data:
  before: unknown OS type: $type
  after : unsupported configuration: no support found for os <type> '$type'

VIR_ERR_OS_TYPE is now unused (as it should be frankly) so drop its strings
as well to save our translators some effort.

(cherry picked from commit 3700c065cde30ff3f70cc3a029279c79c2337a54)

10 years agospec: Point fedora --with-loader-nvram at nightly firmware repo
Cole Robinson [Wed, 22 Apr 2015 20:01:32 +0000 (16:01 -0400)] 
spec: Point fedora --with-loader-nvram at nightly firmware repo

Fedora doesn't ship OVMF/AAVMF builds in its repos due to licensing
issues, so the recommended way to consume these bits is via Gerd's
nightly repo: https://www.kraxel.org/repos

Let's teach fedora builds about the loader/nvram pairs these packages
installed, so users don't need to edit qemu.conf to get virt-manager
UEFI support.

(cherry picked from commit f93e1211297aeae0ca7ee2f0d9dd0a213f468702)

10 years agoconfigure: Report --with-loader-nvram value in summary
Cole Robinson [Wed, 22 Apr 2015 18:28:56 +0000 (14:28 -0400)] 
configure: Report --with-loader-nvram value in summary

(cherry picked from commit ce452877cb27008f239cbc8a63a30150a6ebcc68)

10 years agoconfigure: Fix --loader-nvram typo
Cole Robinson [Wed, 22 Apr 2015 18:19:43 +0000 (14:19 -0400)] 
configure: Fix --loader-nvram typo

(cherry picked from commit 714668b506695b7902851912f58f1d8c20985e5a)

10 years agocpu: Add {Haswell,Broadwell}-noTSX CPU models
Jiri Denemark [Mon, 23 Mar 2015 16:19:28 +0000 (17:19 +0100)] 
cpu: Add {Haswell,Broadwell}-noTSX CPU models

QEMU 2.3 adds these new models to cover Haswell and Broadwell CPUs with
updated microcode. Luckily, they also reverted former the machine type
specific changes to existing models. And since these changes were never
released, we don't need to hack around them in libvirt.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
(cherry picked from commit c563b50605ae9895b981d198e11dbe9f6e18027b)

10 years agodomcaps: Check for architecture more wisely
Michal Privoznik [Wed, 8 Apr 2015 14:59:36 +0000 (16:59 +0200)] 
domcaps: Check for architecture more wisely

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

So we have this bug. The virConnectGetDomainCapabilities() API
performs a couple of checks before it produces any result. One of
the checks is if the architecture requested by user can be run by
the binary (again user provided). However, the check is pretty
dumb. It merely compares if the default binary architecture
matches the one provided by user. However, a qemu binary can run
multiple architectures. For instance: qemu-system-ppc64 can run:
ppc, ppcle, ppc64, ppc64le and ppcemb. The default is ppc64, so
if user requested something else, like ppc64le, the check would
have failed without obvious reason.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit 0af9325e6a06fd4478d4eebfcd92dfe7e2ec570c)

10 years agodaemon: Clear fake domain def object that is used to check ACL prior to use
Peter Krempa [Wed, 25 Mar 2015 07:52:26 +0000 (08:52 +0100)] 
daemon: Clear fake domain def object that is used to check ACL prior to use

The fake object is used to pass the domain name and UUID to the ACL code
for events where we don't have the full domain def when dispatching
events. The rest of the entries would be left uninitialized. While this
is not a problem code-wise as the used fields are initialized it looks
ugly in the debugger.

(cherry picked from commit 6ca857c7c8a1f7b571132d6c7fff5a06301a5e9a)

10 years agoutil: identity: Harden virIdentitySetCurrent()
Peter Krempa [Wed, 25 Mar 2015 07:25:45 +0000 (08:25 +0100)] 
util: identity: Harden virIdentitySetCurrent()

Don't unref the old identity unless we set the new one correctly and
unref the new one on failure to set it so that we don't leak any
references or use invalid pointers.

(cherry picked from commit ad886fa6c8ebc321a0386a75c187d315111cf1f3)

10 years agoqemu: Always refresh capabilities if no <guests> found
Cole Robinson [Thu, 16 Apr 2015 18:51:26 +0000 (14:51 -0400)] 
qemu: Always refresh capabilities if no <guests> found

- Remove all qemu emulators
- Restart libvirtd
- Install qemu emulators
- Call 'virsh version' -> errors

The only thing that will force the qemu driver to refresh it's cached
capablities info is an explict API call to GetCapabilities.

However in the case when the initial caps lookup at driver connect didn't
find a single qemu emulator to poll, the driver is effectively useless
and really can't do anything until it's populated some qemu capabilities
info.

With the above steps, the user would have to either know about the
magic refresh capabilities call, or restart libvirtd to pick up the
changes.

Instead, this patch changes things so that every time a part of th
driver requests access to capabilities info, check to see if
we've previously seen any emulators. If not, force a refresh.

In the case of 'still no emulators found', this is still very quick, so
I can't think of a downside.

https://bugzilla.redhat.com/show_bug.cgi?id=1000116
(cherry picked from commit 95546c43de51a3d54f9a7f65059a6492a64d4f69)
(cherry picked from commit 9ebc1631b42aa2c4aad120d24f940771ec781852)

10 years agoqemu: Build nvram directory at driver startup
Cole Robinson [Fri, 24 Apr 2015 00:01:05 +0000 (20:01 -0400)] 
qemu: Build nvram directory at driver startup

Similar to what was done for the channel socket in the previous commit.

(cherry picked from commit 19425d110b0ca2ea3588dbf880ce48d81edea89c)

10 years agoqemu: Build channel autosocket directory at driver startup
Cole Robinson [Thu, 23 Apr 2015 23:24:50 +0000 (19:24 -0400)] 
qemu: Build channel autosocket directory at driver startup

Rather than depend on the RPM to put it in place, since this doesn't
cover the qemu:///session case. Currently auto allocated socket path is
completely busted with qemu:///session

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

And because we chown the directory at driver startup now, this also fixes
autosocket startup failures when using user/group=root

https://bugzilla.redhat.com/show_bug.cgi?id=1044561
https://bugzilla.redhat.com/show_bug.cgi?id=1146886
(cherry picked from commit e31ab02fd049aa72bea9cfabde15b2dd17e37f98)

10 years agovirQEMUDriverGetConfig: Fix memleak
Michal Privoznik [Fri, 3 Apr 2015 18:58:20 +0000 (20:58 +0200)] 
virQEMUDriverGetConfig: Fix memleak

==19015== 968 (416 direct, 552 indirect) bytes in 1 blocks are definitely lost in loss record 999 of 1,049
==19015==    at 0x4C2C070: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==19015==    by 0x52ADF14: virAllocVar (viralloc.c:560)
==19015==    by 0x5302FD1: virObjectNew (virobject.c:193)
==19015==    by 0x1DD9401E: virQEMUDriverConfigNew (qemu_conf.c:164)
==19015==    by 0x1DDDF65D: qemuStateInitialize (qemu_driver.c:666)
==19015==    by 0x53E0823: virStateInitialize (libvirt.c:777)
==19015==    by 0x11E067: daemonRunStateInit (libvirtd.c:905)
==19015==    by 0x53201AD: virThreadHelper (virthread.c:206)
==19015==    by 0xA1EE1F2: start_thread (in /lib64/libpthread-2.19.so)
==19015==    by 0xA4EFC8C: clone (in /lib64/libc-2.19.so)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit 225aa80246d5e4a9e3a16ebd4c482525045da3db)

10 years agoqemu: chown autoDumpPath on driver startup
Cole Robinson [Fri, 24 Apr 2015 00:21:21 +0000 (20:21 -0400)] 
qemu: chown autoDumpPath on driver startup

Not sure if this is required, but it makes things consistent with the
rest of the directories.

(cherry picked from commit db3ccd582c94f8c5a046f2f9be92a1ad95bc4753)

10 years agoqemu: conf: Clarify paths that are relative to libDir
Cole Robinson [Fri, 24 Apr 2015 00:16:30 +0000 (20:16 -0400)] 
qemu: conf: Clarify paths that are relative to libDir

Rather than duplicate libDir for each new path

(cherry picked from commit c19f43ae7e69103b9db59be1dcab6f8236fa1b24)

10 years agoStrip control codes in virBufferEscapeString
Ján Tomko [Mon, 30 Mar 2015 10:41:40 +0000 (12:41 +0200)] 
Strip control codes in virBufferEscapeString

These cannot be represented in XML.

We have been stripping them, but only if the string had
characters that needed escaping: <>"'&

Extend the strcspn check to include control codes, and strip
them even if we don't do any escaping.

https://bugzilla.redhat.com/show_bug.cgi?id=1184131
https://bugzilla.redhat.com/show_bug.cgi?id=1066564
(cherry picked from commit aeb5262e4397528d582682471cb8075141189465)

10 years agoutil: buffer: Add support for adding text blocks with indentation
Peter Krempa [Tue, 24 Mar 2015 09:53:29 +0000 (10:53 +0100)] 
util: buffer: Add support for adding text blocks with indentation

The current auto-indentation buffer code applies indentation only on
complete strings. To allow adding a string containing newlines and
having it properly indented this patch adds virBufferAddStr.

(cherry picked from commit 6ff59cbc8367856f12f4eef5755eeccade36d8cf)

10 years agoIgnore storage volumes with control codes in their names
Ján Tomko [Tue, 14 Apr 2015 10:30:55 +0000 (12:30 +0200)] 
Ignore storage volumes with control codes in their names

To prevent generating invalid XML.

https://bugzilla.redhat.com/show_bug.cgi?id=1066564
(cherry picked from commit 60db2bc80fb5048b227c77c5138fe0e2c97e9c14)

10 years agoStrip control characters from sysfs attributes
Ján Tomko [Tue, 14 Apr 2015 10:30:34 +0000 (12:30 +0200)] 
Strip control characters from sysfs attributes

Including them in the XML makes them unparsable.

https://bugzilla.redhat.com/show_bug.cgi?id=1184131
(cherry picked from commit 557107500b22d4a5ba7d1b09f5f516512dfca67b)

10 years agoAdd functions dealing with control characters in strings
Ján Tomko [Tue, 14 Apr 2015 10:30:16 +0000 (12:30 +0200)] 
Add functions dealing with control characters in strings

Add virStringHasControlChars that checks if the string has
any control characters other than \t\r\n,
and virStringStripControlChars that removes them in-place.

(cherry picked from commit 2a530a3e50d9314950cff0a5790c81910b0750a9)

10 years agotests: rename testStripIPv6BracketsData to testStripData
Ján Tomko [Tue, 14 Apr 2015 10:06:44 +0000 (12:06 +0200)] 
tests: rename testStripIPv6BracketsData to testStripData

For reuse with other Strip* functions.

(cherry picked from commit e892842dfd3c7bad8fbfbfcf0501d01804e9e7c3)

10 years agolxc: fix starting a domain with non-strict numa memory mode
Luyao Huang [Mon, 20 Apr 2015 13:33:31 +0000 (15:33 +0200)] 
lxc: fix starting a domain with non-strict numa memory mode

 # virsh -c lxc:/// start helloworld
 error: Failed to start domain helloworld
 error: internal error: guest failed to start: Unknown
 failure in libvirt_lxc startup

Return success when there are no cpuset.mems to be set,
instead of failing without setting an error.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 930e8697a5b66989fbf56a5e38cfaf1378a1c59e)

10 years agolxc: fix starting a domain with a cpuset but no numatune
Luyao Huang [Fri, 3 Apr 2015 10:11:15 +0000 (18:11 +0800)] 
lxc: fix starting a domain with a cpuset but no numatune

 # virsh -c lxc:/// start helloworld
 error: Failed to start domain helloworld
 error: internal error: guest failed to start: Invalid value '1-3'
 for 'cpuset.mems': Invalid argument

Free the cpu mask to avoid reusing it as a mem mask
in virCgroupSetCpusetMems
if virDomainNumatuneMaybeFormatNodeset does not set a mask.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
(cherry picked from commit 461eafecfade36555e44378c34568caf55c5cc8a)

10 years agovirsh: fix regression in 'virsh event' by domain
Eric Blake [Tue, 14 Apr 2015 22:15:06 +0000 (16:15 -0600)] 
virsh: fix regression in 'virsh event' by domain

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

Commit a0670ae caused a regression in 'virsh event' and
'virsh qemu-monitor-event' - if a user tries to filter the
command to a specific domain, an error message is printed:

$ virsh event dom --loop
error: internal error: virsh qemu-monitor-event: no domain VSH_OT_DATA option

and then the command continues as though no domain had been
supplied (giving events for ALL domains, instead of the
requested one).  This is because the code was incorrectly
assuming that all "domain" options would be supplied via a
mandatory VSH_OT_DATA, even though "domain" is optional for
these two commands, so we had changed them to VSH_OT_STRING
to quit failing for other reasons (ever since it was decided
that VSH_OT_DATA and VSH_OT_STRING should no longer be
synonyms).

In looking at the situation, though, the code for looking up
a domain was making a pointless check for whether the option
exists prior to finding the option's string value, as
vshCommandOptStringReq does just fine at reporting any errors
when looking up a string whether or not the option was present.

So this is a case of regression fixing by pure code deletion :)

* tools/virsh-domain.c (vshCommandOptDomainBy): Drop useless filter.
* tools/virsh-interface.c (vshCommandOptInterfaceBy): Likewise.
* tools/virsh-network.c (vshCommandOptNetworkBy): Likewise.
* tools/virsh-nwfilter.c (vshCommandOptNWFilterBy): Likewise.
* tools/virsh-secret.c (vshCommandOptSecret): Likewise.
* tools/virsh.h (vshCmdHasOption): Drop unused function.
* tools/virsh.c (vshCmdHasOption): Likewise.

Signed-off-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit 31ef0836a73ed8583ff93613d2759e28965103ef)

10 years agovirsh: Improve change-media success message
Cole Robinson [Mon, 6 Apr 2015 17:59:46 +0000 (13:59 -0400)] 
virsh: Improve change-media success message

$ sudo virsh change-media f19 hdc /mnt/data/devel/media/Fedora-16-x86_64-Live-KDE.iso
succeeded to complete action update on media

Change the message to:

  Successfully {inserted,ejected,changed} media.

https://bugzilla.redhat.com/show_bug.cgi?id=967946
(cherry picked from commit e3aa4c91c8b54cdfb1c312a142fd9fb79daec65a)

10 years agovirNetSocketNewConnectUNIX: Use flocks when spawning a daemon
Michal Privoznik [Thu, 2 Apr 2015 12:41:17 +0000 (14:41 +0200)] 
virNetSocketNewConnectUNIX: Use flocks when spawning a daemon

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

Even though we have a mutex mechanism so that two clients don't spawn
two daemons, it's not strong enough. It can happen that while one
client is spawning the daemon, the other one fails to connect.
Basically two possible errors can happen:

  error: Failed to connect socket to '/home/mprivozn/.cache/libvirt/libvirt-sock': Connection refused

or:

  error: Failed to connect socket to '/home/mprivozn/.cache/libvirt/libvirt-sock': No such file or directory

The problem in both cases is, the daemon is only starting up, while we
are trying to connect (and fail). We should postpone the connecting
phase until the daemon is started (by the other thread that is
spawning it). In order to do that, create a file lock 'libvirt-lock'
in the directory where session daemon would create its socket. So even
when called from multiple processes, spawning a daemon will serialize
on the file lock. So only the first to come will spawn the daemon.

Tested-by: Richard W. M. Jones <rjones@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
(cherry picked from commit be78814ae07f092d9c4e71fd82dd1947aba2f029)

10 years agorpc: Don't unref identity object while callbacks still can be executed
Peter Krempa [Wed, 25 Mar 2015 07:56:07 +0000 (08:56 +0100)] 
rpc: Don't unref identity object while callbacks still can be executed

While this thread is cleaning up the client and connection objects:
 #2  virFileReadAll (path=0x7f28780012b0 "/proc/1319/stat", maxlen=maxlen@entry=1024, buf=buf@entry=0x7f289c60fc40) at util/virfile.c:1287
 #3  0x00007f28adbb1539 in virProcessGetStartTime (pid=<optimized out>, timestamp=timestamp@entry=0x7f289c60fc98) at util/virprocess.c:838
 #4  0x00007f28adb91981 in virIdentityGetSystem () at util/viridentity.c:151
 #5  0x00007f28ae73f17c in remoteClientFreeFunc (data=<optimized out>) at remote.c:1131
 #6  0x00007f28adcb7f33 in virNetServerClientDispose (obj=0x7f28aecad180) at rpc/virnetserverclient.c:858
 #7  0x00007f28adba8eeb in virObjectUnref (anyobj=<optimized out>) at util/virobject.c:265
 #8  0x00007f28ae74ad05 in virNetServerHandleJob (jobOpaque=<optimized out>, opaque=0x7f28aec93ff0) at rpc/virnetserver.c:205
 #9  0x00007f28adbbef4e in virThreadPoolWorker (opaque=opaque@entry=0x7f28aec88030) at util/virthreadpool.c:145

In stack frame #6 the client->identity object got unref'd, but the code
that removes the event callbacks in frame #5 did not run yet as we are
trying to obtain the system identity (frames #4, #3, #2).

In other thead:
 #0  virObjectUnref (anyobj=anyobj@entry=0x7f288c162c60) at util/virobject.c:264
        klass = 0xdeadbeef
        obj = 0x7f288c162c60
 #1  0x00007f28ae71c709 in remoteRelayDomainEventCheckACL (client=<optimized out>, conn=<optimized out>, dom=dom@entry=0x7f28aecaafc0) at remote.c:164
 #2  0x00007f28ae71fc83 in remoteRelayDomainEventTrayChange (conn=<optimized out>, dom=0x7f28aecaafc0, ... ) at remote.c:717
 #3  0x00007f28adc04e53 in virDomainEventDispatchDefaultFunc (conn=0x7f287c0009a0, event=0x7f28aecab1a0, ...) at conf/domain_event.c:1455
 #4  0x00007f28adc03831 in virObjectEventStateDispatchCallbacks (callbacks=<optimized out>, ....) at conf/object_event.c:724
 #5  virObjectEventStateQueueDispatch (callbacks=0x7f288c083730, queue=0x7fff51f90030, state=0x7f288c18da20) at conf/object_event.c:738
 #6  virObjectEventStateFlush (state=0x7f288c18da20) at conf/object_event.c:816
 #7  virObjectEventTimer (timer=<optimized out>, opaque=0x7f288c18da20) at conf/object_event.c:562
 #8  0x00007f28adb859cd in virEventPollDispatchTimeouts () at util/vireventpoll.c:459

Frame #0 is unrefing an invalid identity object while frame #2 hints
that the client is still dispatching the event.

For untrimmed backtrace see the bugzilla attachment.

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1203030
(cherry picked from commit a98129c0ee52b6a8fdd39988a6d090057f149ae9)

10 years agolxc: create the required directories upon driver start
Lubomir Rintel [Wed, 8 Apr 2015 17:16:52 +0000 (19:16 +0200)] 
lxc: create the required directories upon driver start

/var/run may reside on a tmpfs and we fail to create the PID file if
/var/run/lxc does not exist.

Since commit 0a8addc1, the lxc driver's state directory isn't
automatically created before starting a domain. Now, the lxc driver
makes sure the state directory exists when it initializes.

Signed-off-by: Lubomir Rintel <lkundrak@v3.sk>
(cherry picked from commit da33a1ac1f6c0ae2ebe72bc385bbc7c407026956)

10 years agoqemu: read backing chain names from qemu
Eric Blake [Wed, 11 Mar 2015 20:37:04 +0000 (14:37 -0600)] 
qemu: read backing chain names from qemu

https://bugzilla.redhat.com/show_bug.cgi?id=1199182 documents that
after a series of disk snapshots into existing destination images,
followed by active commits of the top image, it is possible for
qemu 2.2 and earlier to end up tracking a different name for the
image than what it would have had when opening the chain afresh.
That is, when starting with the chain 'a <- b <- c', the name
associated with 'b' is how it was spelled in the metadata of 'c',
but when starting with 'a', taking two snapshots into 'a <- b <- c',
then committing 'c' back into 'b', the name associated with 'b' is
now the name used when taking the first snapshot.

Sadly, older qemu doesn't know how to treat different spellings of
the same filename as identical files (it uses strcmp() instead of
checking for the same inode), which means libvirt's attempt to
commit an image using solely the names learned from qcow2 metadata
fails with a cryptic:

error: internal error: unable to execute QEMU command 'block-commit': Top image file /tmp/images/c/../b/b not found

even though the file exists.  Trying to teach libvirt the rules on
which name qemu will expect is not worth the effort (besides, we'd
have to remember it across libvirtd restarts, and track whether a
file was opened via metadata or via snapshot creation for a given
qemu process); it is easier to just always directly ask qemu what
string it expects to see in the first place.

As a safety valve, we validate that any name returned by qemu
still maps to the same local file as we have tracked it, so that
a compromised qemu cannot accidentally cause us to act on an
incorrect file.

* src/qemu/qemu_monitor.h (qemuMonitorDiskNameLookup): New
prototype.
* src/qemu/qemu_monitor_json.h (qemuMonitorJSONDiskNameLookup):
Likewise.
* src/qemu/qemu_monitor.c (qemuMonitorDiskNameLookup): New function.
* src/qemu/qemu_monitor_json.c (qemuMonitorJSONDiskNameLookup)
(qemuMonitorJSONDiskNameLookupOne): Likewise.
* src/qemu/qemu_driver.c (qemuDomainBlockCommit)
(qemuDomainBlockJobImpl): Use it.

Signed-off-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit f9ea3d60119e82c02c00fbf3678c3ed20634dea1)

10 years agodaemon: avoid memleak when ListAll returns nothing
Eric Blake [Fri, 13 Mar 2015 23:01:43 +0000 (17:01 -0600)] 
daemon: avoid memleak when ListAll returns nothing

Commit 4f25146 (v1.2.8) managed to silence Coverity, but at the
cost of a memory leak detected by valgrind:
==24129== 40 bytes in 5 blocks are definitely lost in loss record 355 of 637
==24129==    at 0x4A08B1C: realloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==24129==    by 0x5084B8E: virReallocN (viralloc.c:245)
==24129==    by 0x514D5AA: virDomainObjListExport (domain_conf.c:22200)
==24129==    by 0x201227DB: qemuConnectListAllDomains (qemu_driver.c:18042)
==24129==    by 0x51CC1B6: virConnectListAllDomains (libvirt-domain.c:6797)
==24129==    by 0x14173D: remoteDispatchConnectListAllDomains (remote.c:1580)
==24129==    by 0x121BE1: remoteDispatchConnectListAllDomainsHelper (remote_dispatch.h:1072)

In short, every time a client calls a ListAll variant and asks
for the resulting list, but there are 0 elements to return, we
end up leaking the 1-entry array that holds the NULL terminator.

What's worse, a read-only client can access these functions in a
tight loop to cause libvirtd to eventually run out of memory; and
this can be considered a denial of service attack against more
privileged clients.  Thankfully, the leak is so small (8 bytes per
call) that you would already have some other denial of service with
any guest calling the API that frequently, so an out-of-memory
crash is unlikely enough that this did not warrant a CVE.

* daemon/remote.c (remoteDispatchConnectListAllDomains)
(remoteDispatchDomainListAllSnapshots)
(remoteDispatchDomainSnapshotListAllChildren)
(remoteDispatchConnectListAllStoragePools)
(remoteDispatchStoragePoolListAllVolumes)
(remoteDispatchConnectListAllNetworks)
(remoteDispatchConnectListAllInterfaces)
(remoteDispatchConnectListAllNodeDevices)
(remoteDispatchConnectListAllNWFilters)
(remoteDispatchConnectListAllSecrets)
(remoteDispatchNetworkGetDHCPLeases): Plug leak.

Signed-off-by: Eric Blake <eblake@redhat.com>
(cherry picked from commit 3c2ff5029b83c9b33be0f1607a3c61f4f5850612)

10 years agoqemu: don't fill in nicindexes for session mode libvirtd
Laine Stump [Tue, 10 Mar 2015 06:09:24 +0000 (02:09 -0400)] 
qemu: don't fill in nicindexes for session mode libvirtd

Commit 4bbe1029f fixed a problem in commit f7afeddc by moving the call
to virNetDevGetIndex() to a location common to all interface types (so
that the nicindex array would be filled in for macvtap as well as tap
interfaces), but the location was *too* common, as the original call
to virNetDevGetIndex() had been in a section qualified by "if
(cfg->privileged)". The result was that the "fixed" libvirtd would try
to call virNetDevGetIndex() even for session mode libvirtd, and end up
failing with the log message:

  Unable to open control socket: Operation not permitted

To remedy that, this patch qualifies the call to virNetDevGetIndex()
in its new location with cfg->privileged.

This resolves https://bugzilla.redhat.com/show_bug.cgi?id=1198244

(cherry picked from commit 705242f8809dc2222c35c64d5408dd6b0cc94cf8)

10 years agoRelease of libvirt-1.2.13 v1.2.13
Daniel Veillard [Mon, 2 Mar 2015 03:40:05 +0000 (11:40 +0800)] 
Release of libvirt-1.2.13

10 years agodocs: Add mist.io as libvirt-based application
Michal Privoznik [Fri, 27 Feb 2015 15:11:25 +0000 (16:11 +0100)] 
docs: Add mist.io as libvirt-based application

As reported on the libvirt-users list [1], there's new web
application called mist.io which uses libvirt as one of its
backends. Lets add it into our list of libivrt based
applications.

1: https://www.redhat.com/archives/libvirt-users/2015-February/msg00096.html

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoReally fix XML formatting flags in SaveImageUpdateDef
Ján Tomko [Fri, 27 Feb 2015 10:55:40 +0000 (11:55 +0100)] 
Really fix XML formatting flags in SaveImageUpdateDef

Commit cf2d4c6 used a logical or instead of bitwise or,
effectively passing 1, that is VIR_DOMAIN_XML_INACTIVE.

This was caught by a warning when building with clang.

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

10 years agoIgnore listen attribute of <graphics> for type network listens
Ján Tomko [Thu, 26 Feb 2015 13:33:26 +0000 (14:33 +0100)] 
Ignore listen attribute of <graphics> for type network listens

Commit 6992994 started filling the listen attribute
of the parent <graphics> elements from type='network' listens.

When this XML is passed to UpdateDevice, parsing fails:
XML error: graphics listen attribute 10.20.30.40 must match
address attribute of first listen element (found none)

Ignore the address in the parent <graphics> attribute
when no type='address' listens are found,
the same we ignore the address for the <listen> subelements
when parsing inactive XML.

10 years agoutil: storage: Fix error type in virStorageSourceParseBackingURI
Peter Krempa [Thu, 26 Feb 2015 09:35:47 +0000 (10:35 +0100)] 
util: storage: Fix error type in virStorageSourceParseBackingURI

The gluster volume name extraction code was copied from the XML parser
without changing the VIR_ERR_XML_ERROR error code. Use
VIR_ERR_CONFIG_UNSUPPORTED instead.

10 years agoutil: storagefile: Don't crash on gluster URIs without path
Peter Krempa [Thu, 26 Feb 2015 09:28:21 +0000 (10:28 +0100)] 
util: storagefile: Don't crash on gluster URIs without path

Similar to commit fdb80ed4f6563928b9942a0d1450e0c725aa6c06 libvirtd
would crash if a gluster URI without path would be used in the backing
chain of a volume. The crash happens in the gluster specific part of the
parser that extracts the gluster volume name from the path.

Fix the crash by checking that the PATH is NULL.

This patch does not contain a test case as it's not possible to test it
with the current infrastructure as the test suite would attempt to
contact the gluster server in the URI. I'm working on the test suite
addition but that will be post-release material.

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

10 years agoconf: error out on missing dhcp host attributes
Ján Tomko [Thu, 26 Feb 2015 08:03:09 +0000 (09:03 +0100)] 
conf: error out on missing dhcp host attributes

In virNetworkDHCPHostDefParseXML an error is reported
when partialOkay == true, and none of ip, mac, name
were supplied.

Add the missing goto and error out in this case.

10 years agoconf: error out on invalid host id
Luyao Huang [Thu, 26 Feb 2015 06:14:20 +0000 (14:14 +0800)] 
conf: error out on invalid host id

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

We already check whether the host id is valid or not, add a jump
to forbid invalid host id.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
10 years agoqemu: fix ifindex array reported to systemd v1.2.13-rc2
Laine Stump [Fri, 20 Feb 2015 19:52:37 +0000 (14:52 -0500)] 
qemu: fix ifindex array reported to systemd

Commit f7afeddc added code to report to systemd an array of interface
indexes for all tap devices used by a guest. Unfortunately it not only
didn't add code to report the ifindexes for macvtap interfaces
(interface type='direct') or the tap devices used by type='ethernet',
it ended up sending "-1" as the ifindex for each macvtap or hostdev
interface. This resulted in a failure to start any domain that had a
macvtap or hostdev interface (or actually any type other than
"network" or "bridge").

This patch does the following with the nicindexes array:

1) Modify qemuBuildInterfaceCommandLine() to only fill in the
nicindexes array if given a non-NULL pointer to an array (and modifies
the test jig calls to the function to send NULL). This is because
there are tests in the test suite that have type='ethernet' and still
have an ifname specified, but that device of course doesn't actually
exist on the test system, so attempts to call virNetDevGetIndex() will
fail.

2) Even then, only add an entry to the nicindexes array for
appropriate types, and to do so for all appropriate types ("network",
"bridge", and "direct"), but only if the ifname is known (since that
is required to call virNetDevGetIndex().

10 years agoutil: check for null ifname inside virNetDevBandwidthSet()
Laine Stump [Tue, 24 Feb 2015 18:17:24 +0000 (13:17 -0500)] 
util: check for null ifname inside virNetDevBandwidthSet()

Previously this function relied on having ATTRIBUTE_NONNULL(1) in its
prototype rather than explicitly checking for a null
ifname. Unfortunately, ATTRIBUTE_NONNULL is just a hint to the
optimizer and code analyzers like Coverity, it doesn't actually check
anything at execution time, so the result was possible warnings from
Coverity, along with the possibility of null dereferences when ifname
wasn't available.

This patch removes the ATTRIBUTE_NONNULL from the prototype, and
checks ifname inside the function, logging an error if it's NULL (once
we've determined that the user really is trying to set a bandwidth).

10 years agonetwork: only clear bandwidth if it has been set
Laine Stump [Tue, 24 Feb 2015 17:12:56 +0000 (12:12 -0500)] 
network: only clear bandwidth if it has been set

libvirt was unconditionally calling virNetDevBandwidthClear() for
every interface (and network bridge) of a type that supported
bandwidth, whether it actually had anything set or not. This doesn't
hurt anything (unless ifname == NULL!), but is wasteful.

This patch makes sure that all calls to virNetDevBandwidthClear() are
qualified by checking that the interface really had some bandwidth
setup done, and checks for a null ifname inside
virNetDevBandwidthClear(), silently returning success if it is null
(as well as removing the ATTRIBUTE_NONNULL from that function's
prototype, since we can't guarantee that it is never null,
e.g. sometimes a type='ethernet' interface has no ifname as it is
provided on the fly by qemu).

10 years agoschema: Allow interleaving the /domain/os/type element
Peter Krempa [Wed, 25 Feb 2015 10:19:15 +0000 (11:19 +0100)] 
schema: Allow interleaving the /domain/os/type element

The element wasn't declared under the interleave thus it was required
always to be first. This made it inconvenient when pasting new stuff to
the XML manually in the "wrong" place.

10 years agoFix typos in messages
Yuri Chornoivan [Wed, 25 Feb 2015 13:12:33 +0000 (14:12 +0100)] 
Fix typos in messages

Signed-off-by: Ján Tomko <jtomko@redhat.com>
10 years agoFix error messages in virStorageFileGetMetadataFromFD
Ján Tomko [Thu, 19 Feb 2015 12:32:41 +0000 (13:32 +0100)] 
Fix error messages in virStorageFileGetMetadataFromFD

Do not use relPath, it has not been filled by virStorageFileMetadataNew.

10 years agoschema: Add virtio-mmio address type into RNG
Martin Kletzander [Wed, 25 Feb 2015 10:23:45 +0000 (11:23 +0100)] 
schema: Add virtio-mmio address type into RNG

The "virtio-mmio" is perfectly valid address type which we parse and
format correctly, but it's missing in our RNG schemas, hence editing a
domain with device having such address fails the validation.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoClarify behavior or virDomainDetachDevice
Ján Tomko [Fri, 20 Feb 2015 11:25:42 +0000 (12:25 +0100)] 
Clarify behavior or virDomainDetachDevice

Document that a complete device definition should be used
and a partial match can lead to the device being detached.

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

10 years agoAssign default SCSI controller model before checking attribute validity
Ján Tomko [Wed, 18 Feb 2015 14:11:31 +0000 (15:11 +0100)] 
Assign default SCSI controller model before checking attribute validity

If the qemu binary on x86 does not support lsi SCSI controller,
but it supports virtio-scsi, we reject the virtio-specific attributes
for no reason.

Move the default controller assignment before the check.

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

10 years agovirsh: Add missing parenthesis into man page
Martin Kletzander [Wed, 25 Feb 2015 08:34:27 +0000 (09:34 +0100)] 
virsh: Add missing parenthesis into man page

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoqemu: Use correct flags for ABI stability check in SaveImageUpdateDef
Michal Privoznik [Thu, 19 Feb 2015 12:54:53 +0000 (13:54 +0100)] 
qemu: Use correct flags for ABI stability check in SaveImageUpdateDef

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

Soo. you've successfully started yourself a domain. And since you want
to use it on your host exclusively you are confident enough to
passthrough the host CPU model, like this:

  <cpu mode='host-passthrough'/>

Then, after a while, you want to save the domain into a file (e.g.
virsh save dom dom.save). And here comes the trouble. The file consist
of two parts: Libvirt header (containing domain XML among other
things), and qemu migration data. Now, the domain XML in the header is
formatted using special flags (VIR_DOMAIN_XML_SECURE |
VIR_DOMAIN_XML_UPDATE_CPU | VIR_DOMAIN_XML_INACTIVE |
VIR_DOMAIN_XML_MIGRATABLE).

Then, on your way back from the bar, you think of changing something
in the XML in the saved file (we have a command for it after all), say
listen address for graphics console. So you successfully type in the
command:

  virsh save-image-edit dom.save

Change all the bits, and exit the editor. But instead of success
you're left with sad error message:

  error: unsupported configuration: Target CPU model <null> does not
  match source Pentium Pro

Sigh. Digging into the code you see lines, where we check for ABI
stability. The new XML you've produced is compared with the old one
from the saved file to see if qemu ABI will break or not. Wait, what?
We are using different flags to parse the XML you've provided so we
were just lucky it worked in some cases? Yep, that's right.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agocpu: Format <cpu/> properly
Michal Privoznik [Wed, 18 Feb 2015 17:04:16 +0000 (18:04 +0100)] 
cpu: Format <cpu/> properly

Well, not that we are not formatting invalid XML, rather than not as
beautiful as we can:

  <cpu mode='host-passthrough'>
  </cpu>

If there are no children, let's use the singleton element.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirCPUDefFormatBufFull: Use our general error handling pattern
Michal Privoznik [Wed, 18 Feb 2015 17:06:44 +0000 (18:06 +0100)] 
virCPUDefFormatBufFull: Use our general error handling pattern

Well, so far there are no variables to free, no cleanup work needed on
an error, so bare 'return -1;' after each error is just okay. But this
will change in a while.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoutil: Introduce virBufferAddBuffer
Michal Privoznik [Thu, 19 Feb 2015 09:56:58 +0000 (10:56 +0100)] 
util: Introduce virBufferAddBuffer

This API joins the following two lines:

char *s = virBufferContentAndReset(buf1);
virBufferAdd(buf2, s, -1);

into one:

virBufferAddBuffer(buf2, buf1);

With one exception: there's no re-indentation applied to @buf1.
The idea is, that in general both can have different indentation
(like the test I'm adding proves)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoqemu: fix memory leak while starting a guest
Pavel Hrdina [Tue, 24 Feb 2015 13:31:37 +0000 (14:31 +0100)] 
qemu: fix memory leak while starting a guest

In commit cc41c648 I've re-factored qemuMonitorFindBalloonObjectPath, but
missed that there is a memory leak. The "nextpath" variable is
overwritten while looping in for cycle and we have to free it before next
cycle.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agonetwork_conf: Forbid commas in DNS TXT
Michal Privoznik [Mon, 23 Feb 2015 12:19:16 +0000 (13:19 +0100)] 
network_conf: Forbid commas in DNS TXT

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

While the restriction doesn't have origin in any RFC, it matters
to us while constructing the dnsmasq config file (or command line
previously). For better picture, this is how the corresponding
part of network XML look like:

  <dns>
    <forwarder addr='8.8.4.4'/>
    <txt name='example' value='example value'/>
  </dns>

And this is how the config file looks like then:

  server=8.8.4.4
  txt-record=example,example value

Now we can see why there can't be any commas in the TXT name.
They are used by dnsmasq to separate @name and @value.

Funny, we have it in the documentation, but the code (which was
pushed back in 2011) didn't reflect that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoRework s390 architecture checking v1.2.13-rc1
Stefan Zimmermann [Wed, 18 Feb 2015 15:44:19 +0000 (16:44 +0100)] 
Rework s390 architecture checking

Making use of the ARCH_IS_S390 macro introduced with
e808357528d8be1ebc3970424b4a7b7c04eda2b6

Signed-off-by: Stefan Zimmermann <stzi@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
10 years agoPrevent default creation of usb controller on s390 and s390x
Stefan Zimmermann [Wed, 18 Feb 2015 15:44:17 +0000 (16:44 +0100)] 
Prevent default creation of usb controller on s390 and s390x

Since s390 does not support usb the default creation of a usb controller
for a domain should not occur.

Also adjust s390 test cases by removing usb device instances since
usb devices are no longer created by default for s390 the s390
test cases need to be adjusted.

Signed-off-by: Stefan Zimmermann <stzi@linux.vnet.ibm.com>
Reviewed-by: Boris Fiuczynski <fiuczy@linux.vnet.ibm.com>
10 years agoman: moved virsh command cpu-models
Daniel Hansel [Wed, 18 Feb 2015 13:53:32 +0000 (14:53 +0100)] 
man: moved virsh command cpu-models

The description of the virsh command 'cpu-models' was written in the
wrong context (i.e. beside the domain states).
This patch moves the command description just to the cpu related
commands like 'cpu-baseline' and 'cpu-compare'.

Signed-off-by: Daniel Hansel <daniel.hansel@linux.vnet.ibm.com>
10 years agopo: Add config file for zanata
Daniel P. Berrange [Mon, 23 Feb 2015 09:45:02 +0000 (09:45 +0000)] 
po: Add config file for zanata

Add configuration file for use with https://fedora.zanata.org
translation system

10 years agolibvirt-guests: Allow time sync on guests resume
Michal Privoznik [Wed, 18 Feb 2015 10:59:22 +0000 (11:59 +0100)] 
libvirt-guests: Allow time sync on guests resume

Well, imagine domains were running, and as the host went down, they
were managesaved. Later, after some time, the host went up again and
domains got restored. But without correct time. And depending on how
long was the host shut off, it may take some time for ntp to sync the
time too. But hey, wait a minute. We have an API just for that! So:

1) Introduce SYNC_TIME variable in libvirt-guests.sysconf to allow
users control over the new functionality
2) Call 'virsh domtime --sync $dom' in the libvirt-guests script.

Unfortunately, this is all-or-nothing approach (just like anything
else with the script). Domains are required to have configured and
running qemu-ga inside.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoqemu: Fix AAVMF/OVMF #define names
Cole Robinson [Wed, 18 Feb 2015 19:26:02 +0000 (14:26 -0500)] 
qemu: Fix AAVMF/OVMF #define names

The AAVMF and OVMF names were swapped. Reorder the one usage where it
matters so behavior doesn't change.

10 years agolibxl: support backend domain setting for disk and net devices
Marek Marczykowski [Fri, 20 Feb 2015 03:22:06 +0000 (04:22 +0100)] 
libxl: support backend domain setting for disk and net devices

This implement handling of <backenddomain name=''/>  parameter introduced
in previous patch.

Works on Xen >= 4.3, because only there libxl supports setting backend
domain by name.  Specifying backend domain by ID or UUID is currently not
supported.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
10 years agoconf: support backend domain name in disk and network devices
Marek Marczykowski [Fri, 20 Feb 2015 03:22:05 +0000 (04:22 +0100)] 
conf: support backend domain name in disk and network devices

At least Xen supports backend drivers in another domain (aka "driver
domain"). This patch introduces an XML config option for specifying the
backend domain name for <disk> and <interface> devices.  E.g.

  <disk>
    <backenddomain name='diskvm'/>
    ...
  </disk>
  <interface type='bridge'>
    <backenddomain name='netvm'/>
    ...
  </interface>

In the future, same option will be needed for USB devices (hostdev
objects), but for now libxl doesn't have support for PVUSB.

Signed-off-by: Marek Marczykowski-Górecki <marmarek@invisiblethingslab.com>
10 years agonetwork: allow <pf> together with <interface>/<address> in network status
Laine Stump [Sun, 15 Feb 2015 03:43:16 +0000 (22:43 -0500)] 
network: allow <pf> together with <interface>/<address> in network status

The function that parses the <forward> subelement of a network used to
fail/log an error if the network definition contained both a <pf>
element as well as at least one <interface> or <address> element. That
check was present because the configuration of a network should have
either one <pf>, one or more <interface>, or one or more <address>,
but never combinations of multiple kinds.

This caused a problem when libvirtd was restarted with a network
already active - when a network with a <pf> element is started, the
referenced PF (Physical Function of an SRIOV-capable network card) is
checked for VFs (Virtual Functions), and the <forward> is filled in
with a list of all VFs for that PF either in the form of their PCI
addresses (a list of <address>) or their netdev names (a list of
<interface>); the <pf> element is not removed though. When libvirtd is
restarted, it parses the network status and finds both the original
<pf> from the config, as well as the list of either <address> or
<interface>, fails the parse, and the network is not added to the
active list. This failure is often obscured because the network is
marked as autostart so libvirt immediately restarts it.

It seems odd to me that <interface> and <address> are stored in the
same array rather than keeping two separate arrays, and having
separate arrays would have made the check much simpler. However,
changing to use two separate arrays would have required changes in
more places, potentially creating more conflicts and (more
importantly) more possible regressions in the event of a backport, so
I chose to keep the existing data structure in order to localize the
change.

It appears that this problem has been in the code ever since support
for <pf> was added (0.9.10), but until commit
34cc3b2f106e296df5e64309620c79d16fd76c85 (first in libvirt 1.2.4)
networks with interface pools were not properly marked as active on
restart anyway, so there is no point in backporting this patch any
further than that.

10 years agoqemu: caps: Add capability bit for the "pc-dimm" device
Peter Krempa [Mon, 6 Oct 2014 12:16:47 +0000 (14:16 +0200)] 
qemu: caps: Add capability bit for the "pc-dimm" device

The pc-dimm device represents a RAM memory module.

10 years agoconf: Hoist validation of memory size into the post parse callback
Peter Krempa [Tue, 10 Feb 2015 16:11:40 +0000 (17:11 +0100)] 
conf: Hoist validation of memory size into the post parse callback

Later patches will need to access the full definition to do check the
memory size and thus the checking needs to be done after the whole
definition including devices is known.

10 years agoconf: numa: Check ABI stability of NUMA configuration
Peter Krempa [Mon, 16 Feb 2015 19:34:37 +0000 (20:34 +0100)] 
conf: numa: Check ABI stability of NUMA configuration

Add helper to compare initial sizes of indivitual NUMA nodes and the map
of belonging vCPUs. Other configuration is not ABI.

10 years agoconf: ABI: Hugepage backing definition is not guest ABI
Peter Krempa [Wed, 11 Feb 2015 14:15:13 +0000 (15:15 +0100)] 
conf: ABI: Hugepage backing definition is not guest ABI

The backing of the vm's memory isn't influencing the guest ABI thus
shouldn't be checked.

10 years agoconf: Move all NUMA configuration to virDomainNuma
Peter Krempa [Mon, 16 Feb 2015 16:28:48 +0000 (17:28 +0100)] 
conf: Move all NUMA configuration to virDomainNuma

For historical reasons data regarding NUMA configuration were split
between the CPU definition and numatune. We cannot do anything about the
XML still being split, but we certainly can at least store the relevant
data in one place.

This patch moves the NUMA stuff to the right place.

10 years agoconf: numa: Add setter/getter for NUMA node memory size
Peter Krempa [Mon, 16 Feb 2015 18:14:23 +0000 (19:14 +0100)] 
conf: numa: Add setter/getter for NUMA node memory size

Add the helpers and refactor places where the value is accessed without
them.

10 years agoconf: numa: Add accessor to NUMA node's memory access mode
Peter Krempa [Mon, 16 Feb 2015 17:51:36 +0000 (18:51 +0100)] 
conf: numa: Add accessor to NUMA node's memory access mode

10 years agoconf: numa: Add accessor for the NUMA node cpu mask
Peter Krempa [Mon, 16 Feb 2015 17:38:43 +0000 (18:38 +0100)] 
conf: numa: Add accessor for the NUMA node cpu mask

Add virDomainNumaGetNodeCpumask() and refactor a few places that would
get the cpu mask without the helper.

10 years agoconf: numa: Add helper to get guest NUMA node count and refactor users
Peter Krempa [Mon, 16 Feb 2015 17:11:46 +0000 (18:11 +0100)] 
conf: numa: Add helper to get guest NUMA node count and refactor users

Add an accessor so that a later refactor is simpler.

10 years agoqemu: command: Unify retrieval of NUMA cell count in qemuBuildNumaArgStr
Peter Krempa [Mon, 16 Feb 2015 16:55:50 +0000 (17:55 +0100)] 
qemu: command: Unify retrieval of NUMA cell count in qemuBuildNumaArgStr

The function uses the cell count in 6 places. Add a temp variable to
hold the count as it will greatly simplify the refactor.

10 years agoconf: numa: Don't pass double pointer to virDomainNumatuneParseXML
Peter Krempa [Mon, 16 Feb 2015 16:19:15 +0000 (17:19 +0100)] 
conf: numa: Don't pass double pointer to virDomainNumatuneParseXML

virDomainNumatuneParseXML now doesn't allocate the def->numa object any
longer so we don't need to pass a double pointer.

10 years agonuma: conf: Tweak parameters of virDomainNumatuneSet
Peter Krempa [Mon, 16 Feb 2015 16:05:46 +0000 (17:05 +0100)] 
numa: conf: Tweak parameters of virDomainNumatuneSet

As virDomainNumatuneSet now doesn't allocate the virDomainNuma object
any longer it's not necessary to pass the pointer to a pointer to store
the object as it will not change any longer.

While touching the parameter definitions I've also changed the name of
the parameter to "numa".

10 years agoconf: numa: Always allocate the NUMA config
Peter Krempa [Mon, 16 Feb 2015 15:42:13 +0000 (16:42 +0100)] 
conf: numa: Always allocate the NUMA config

Since our formatter now handles well if the config is allocated and not
filled we can safely always-allocate the NUMA config and remove the
ad-hoc allocation code.

This will help in later patches as the parser will be refactored to just
fill the data.

10 years agoconf: Allocate domain definition with the new helper
Peter Krempa [Mon, 16 Feb 2015 15:30:11 +0000 (16:30 +0100)] 
conf: Allocate domain definition with the new helper

Use the virDomainDefNew() helper to allocate the definition instead of
doing it via VIR_ALLOC.

10 years agoconf: Separate helper for creating domain objects
Peter Krempa [Mon, 16 Feb 2015 14:58:13 +0000 (15:58 +0100)] 
conf: Separate helper for creating domain objects

Move the existing virDomainDefNew to virDomainDefNewFull as it's setting
a few things in the conf and re-introduce virDomainDefNew as a function
without parameters for common use.

10 years agoconf: numa: Format <numatune> XML only if necessary
Peter Krempa [Mon, 16 Feb 2015 13:17:41 +0000 (14:17 +0100)] 
conf: numa: Format <numatune> XML only if necessary

Do a content-aware check if formatting of the <numatune> element is
necessary. Later on the def->numa structure will be always present so we
cannot decide only on the basis whether it's allocated.

10 years agoconf: numa: Refactor logic in virDomainNumatuneParseXML
Peter Krempa [Thu, 12 Feb 2015 15:04:45 +0000 (16:04 +0100)] 
conf: numa: Refactor logic in virDomainNumatuneParseXML

Shuffling around the logic will allow to simplify the code quite a bit.
As an additional bonus the change in the logic now reports an error if
automatic placement is selected and individual placement is configured.

10 years agoconf: numa: Reformat virDomainNumatuneParseXML
Peter Krempa [Thu, 12 Feb 2015 14:34:05 +0000 (15:34 +0100)] 
conf: numa: Reformat virDomainNumatuneParseXML

Collapse few of the conditions so that the program flow is more clear.

10 years agoconf: numa: Improve error message in case a numa node doesn't have cpus
Peter Krempa [Wed, 11 Feb 2015 16:38:29 +0000 (17:38 +0100)] 
conf: numa: Improve error message in case a numa node doesn't have cpus

Currently the code would exit without reporting an error as
virBitmapParse reports one only if it fails to parse the bitmap, whereas
the code was jumping to the error label even in case 0 cpus were
correctly parsed in the map.

10 years agoconf: numa: Recalculate rather than remember total NUMA cpu count
Peter Krempa [Thu, 12 Feb 2015 08:37:13 +0000 (09:37 +0100)] 
conf: numa: Recalculate rather than remember total NUMA cpu count

It's easier to recalculate the number in the one place it's used as
having a separate variable to track it. It will also help with moving
the NUMA code to the separate module.

10 years agoconf: Move enum virMemAccess to the NUMA code and rename it
Peter Krempa [Wed, 11 Feb 2015 14:40:27 +0000 (15:40 +0100)] 
conf: Move enum virMemAccess to the NUMA code and rename it

Name it virNumaMemAccess and add it to conf/numa_conf.[ch]

Note that to avoid a circular dependency the type of the NUMA cell
memAccess variable was changed to int. It will be turned back later
after the circular dependency will not exist.

10 years agoconf: numa: Rename virDomainNumatune to virDomainNuma
Peter Krempa [Wed, 11 Feb 2015 13:54:59 +0000 (14:54 +0100)] 
conf: numa: Rename virDomainNumatune to virDomainNuma

The structure will gradually become the only place for NUMA related
config, thus rename it appropriately.

10 years agoconf: Move NUMA cell formatter to numa_conf
Peter Krempa [Wed, 11 Feb 2015 13:26:19 +0000 (14:26 +0100)] 
conf: Move NUMA cell formatter to numa_conf

Move the code that formats the /domain/cpu/numa element to numa_conf as
it belongs there.

10 years agoconf: numa: Don't duplicate NUMA cell cpumask
Peter Krempa [Wed, 11 Feb 2015 13:06:20 +0000 (14:06 +0100)] 
conf: numa: Don't duplicate NUMA cell cpumask

The mask was stored both as a bitmap and as a string. The string is used
for XML output only. Remove the string, as it can be reconstructed from
the bitmap.

The test change is necessary as the bitmap formatter doesn't "optimize"
using the '^' operator.