]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
9 years agoqemuProcessReadLog: Fix memmove arguments
Michal Privoznik [Mon, 18 Jan 2016 09:50:14 +0000 (10:50 +0100)]
qemuProcessReadLog: Fix memmove arguments

So I can observe this crasher that with freshly started daemon
(and virtlogd enabled) I am trying to startup a domain that
immediately dies (because it's said to use huge pages but I
haven't allocated a single one in the pool). Hardly reproducible
with -O0 or under valgrind. But I just got lucky:

==20469== Invalid write of size 8
==20469==    at 0x4C2E99B: memcpy@GLIBC_2.2.5 (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==20469==    by 0x217EDD07: qemuProcessReadLog (qemu_process.c:1670)
==20469==    by 0x217EDE1D: qemuProcessReportLogError (qemu_process.c:1696)
==20469==    by 0x217EE8C1: qemuProcessWaitForMonitor (qemu_process.c:1957)
==20469==    by 0x217F6636: qemuProcessLaunch (qemu_process.c:4955)
==20469==    by 0x217F71A4: qemuProcessStart (qemu_process.c:5152)
==20469==    by 0x21846582: qemuDomainObjStart (qemu_driver.c:7396)
==20469==    by 0x218467DE: qemuDomainCreateWithFlags (qemu_driver.c:7450)
==20469==    by 0x21846845: qemuDomainCreate (qemu_driver.c:7468)
==20469==    by 0x5611CD0: virDomainCreate (libvirt-domain.c:6753)
==20469==    by 0x125D9A: remoteDispatchDomainCreate (remote_dispatch.h:3613)
==20469==    by 0x125CB7: remoteDispatchDomainCreateHelper (remote_dispatch.h:3589)
==20469==  Address 0x27a52ad0 is 0 bytes after a block of size 5,584 alloc'd
==20469==    at 0x4C29F80: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==20469==    by 0x9B8D1DB: xdr_string (in /lib64/libc-2.21.so)
==20469==    by 0x563B39C: xdr_virLogManagerProtocolNonNullString (log_protocol.c:24)
==20469==    by 0x563B6B7: xdr_virLogManagerProtocolDomainReadLogFileRet (log_protocol.c:123)
==20469==    by 0x164B34: virNetMessageDecodePayload (virnetmessage.c:407)
==20469==    by 0x5682360: virNetClientProgramCall (virnetclientprogram.c:379)
==20469==    by 0x563B30E: virLogManagerDomainReadLogFile (log_manager.c:272)
==20469==    by 0x217CD613: qemuDomainLogContextRead (qemu_domain.c:2485)
==20469==    by 0x217EDC76: qemuProcessReadLog (qemu_process.c:1660)
==20469==    by 0x217EDE1D: qemuProcessReportLogError (qemu_process.c:1696)
==20469==    by 0x217EE8C1: qemuProcessWaitForMonitor (qemu_process.c:1957)
==20469==    by 0x217F6636: qemuProcessLaunch (qemu_process.c:4955)

This points to memmove() in qemuProcessReadLog(). Imagine we just
read the following string from qemu:

"abc\n2016-01-18T09:40:44.022744Z qemu-system-x86_64: Error\n"

After the first pass of the while() loop in the
qemuProcessReadLog() (in which we have taken the false branch in
the if) @buf still points to the beginning of the string,
@filter_next points to the beginning of the second line.  So we
start second iteration because there is yet another newline
character at the end. In this iteration @eol points to it
actually. Now, the control gets inside true branch of if(). Just
to remind you:

got = 58
filter_next = buf + 5,
eol = buf + 58.

Therefore skip = 54 which is correct. The message we want to skip
is 54 bytes long. However:

memmove(filter_next, eol + 1, (got - skip) +1);

which is

memmove(filter_next, eol + 1, 5)

is obviously wrong as there is only one byte we can access, not 5!

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoFix make check with gcc version 5
Martin Kletzander [Tue, 12 Jan 2016 15:47:13 +0000 (16:47 +0100)]
Fix make check with gcc version 5

When building with gcc-5 (particularly gcc-5.3.0 now) and having pdwtags
installed (package dwarves) make check fails with the following error:

  $ make lock_protocol-struct
  GEN      lock_protocol-struct
  --- lock_protocol-structs 2016-01-13 15:04:59.318809607 +0100
  +++ lock_protocol-struct-t3 2016-01-13 15:05:17.703501234 +0100
  @@ -26,10 +26,6 @@
           virLockSpaceProtocolNonNullString name;
           u_int                      flags;
   };
  -enum virLockSpaceProtocolAcquireResourceFlags {
  -        VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_SHARED = 1,
  -        VIR_LOCK_SPACE_PROTOCOL_ACQUIRE_RESOURCE_AUTOCREATE = 2,
  -};
   struct virLockSpaceProtocolAcquireResourceArgs {
           virLockSpaceProtocolNonNullString path;
           virLockSpaceProtocolNonNullString name;
  Makefile:10415: recipe for target 'lock_protocol-struct' failed
  make: *** [lock_protocol-struct] Error 1

That happens because without any specific options gcc doesn't keep enum
information in the resulting binary object.  I managed to isolate the
parameters of gcc that caused this issue to disappear, however I
remember that they influenced the resulting binaries quite a bit and
were definitely not something we would want to add as mandatory to the
build process.

So to deal with this cleanly, let's take that enum and separate it out
to its own header file.  Since it is only used in the lockd driver and
the protocol, lock_driver_lockd.h feels like a suitable name.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agorbd: Set r variable so it can be returned should an error occur
Wido den Hollander [Fri, 15 Jan 2016 12:52:16 +0000 (13:52 +0100)]
rbd: Set r variable so it can be returned should an error occur

This was reported in bug #1298024 where r would be filled with the
return code of rbd_open().

Should rbd_snap_unprotect() fail for any reason the virReportSystemError
call would return 'Success' since rbd_open() succeeded.

https://bugzilla.redhat.com/show_bug.cgi?id=1298024
Signed-off-by: Wido den Hollander <wido@widodh.nl>
9 years agoqemuTestDriverInit: fill driver with zeroes
Michal Privoznik [Mon, 18 Jan 2016 08:11:19 +0000 (09:11 +0100)]
qemuTestDriverInit: fill driver with zeroes

In the commit aea47e48c473a we have fixed a single pointer within
driver structure. Since all callers pass statically allocated
driver on stack other pointers within driver may contain random
values too. Before touching it lets overwrite it with zeroes and
thus fix all dangling pointers.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoPost-release version bump to 1.3.2
Michal Privoznik [Mon, 18 Jan 2016 12:07:35 +0000 (13:07 +0100)]
Post-release version bump to 1.3.2

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoNEWS: Don't prefix version numbers with 'v'
Andrea Bolognani [Mon, 18 Jan 2016 09:50:37 +0000 (10:50 +0100)]
NEWS: Don't prefix version numbers with 'v'

It was only used in two instances, so get rid of it for
consistency's sake.

9 years agoNEWS: Fix whitespace issues
Andrea Bolognani [Mon, 18 Jan 2016 09:49:05 +0000 (10:49 +0100)]
NEWS: Fix whitespace issues

9 years agoNEWS: Move 2015 entries to a separate file
Andrea Bolognani [Mon, 18 Jan 2016 09:47:12 +0000 (10:47 +0100)]
NEWS: Move 2015 entries to a separate file

Now that the first release made in 2016 is out, we can move all
entries for 2015 to their own file, just like we did for all previous
years.

9 years agoRelease of libvirt-1.3.1
Daniel Veillard [Sun, 17 Jan 2016 02:29:57 +0000 (10:29 +0800)]
Release of libvirt-1.3.1

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

9 years agosecurity: Do not restore labels on device tree binary
Jiri Denemark [Fri, 15 Jan 2016 15:34:37 +0000 (16:34 +0100)]
security: Do not restore labels on device tree binary

A device tree binary file specified by /domain/os/dtb element is a
read-only resource similar to kernel and initrd files. We shouldn't
restore its label when destroying a domain to avoid breaking other
domains configure with the same device tree.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agosecurity: Do not restore kernel and initrd labels
Jiri Denemark [Fri, 15 Jan 2016 09:55:58 +0000 (10:55 +0100)]
security: Do not restore kernel and initrd labels

Kernel/initrd files are essentially read-only shareable images and thus
should be handled in the same way. We already use the appropriate label
for kernel/initrd files when starting a domain, but when a domain gets
destroyed we would remove the labels which would make other running
domains using the same files very unhappy.

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

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Print better warning in qemuAgentNotifyEvent
Yaniv Kaul [Fri, 15 Jan 2016 07:33:49 +0000 (08:33 +0100)]
qemu: Print better warning in qemuAgentNotifyEvent

We have this function qemuAgentNotifyEvent() which is supposed to
be called from thread pool responsible for processing qemu
monitor events. The function then should wake up other thread
that is waiting for a guest to shutdown or reboot. However, if we
have received a different error a warning is printed out. This
warning lacks info on which event is expected.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agocgroup: Fix possible bug as a result of code motion for vcpu cgroup setup
John Ferlan [Tue, 22 Dec 2015 14:46:01 +0000 (09:46 -0500)]
cgroup: Fix possible bug as a result of code motion for vcpu cgroup setup

Commit id '90b721e43' moved where the virCgroupAddTask was made until
after the check for the vcpupin checks. However, in doing so it missed
an option where if the cpumap didn't exist, then the code would continue
back to the top of the current vcpu loop. The results was that the
virCgroupAddTask wouldn't be called.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoRevert "lxc_cgroup: Add check for NULL cgroup before AddTask call"
John Ferlan [Thu, 14 Jan 2016 16:01:50 +0000 (11:01 -0500)]
Revert "lxc_cgroup: Add check for NULL cgroup before AddTask call"

This reverts commit ae09988eb787df63d3bb298f713a3bbd77275901.

Since commit id '71ce4759' has been reverted, this one is no
longer necessary.

9 years agoRevert "util: cgroups do not implicitly add task to new machine cgroup"
John Ferlan [Thu, 14 Jan 2016 16:00:25 +0000 (11:00 -0500)]
Revert "util: cgroups do not implicitly add task to new machine cgroup"

This reverts commit 71ce475967b3523882b0e1a0f649fdbea5abf9d5.

Since commit id 'a41c00b47' has been reverted, this no longer is
necessary

9 years agoRevert "qemu: do not put a task into machine cgroup"
John Ferlan [Thu, 14 Jan 2016 15:56:53 +0000 (10:56 -0500)]
Revert "qemu: do not put a task into machine cgroup"

This reverts commit a41c00b472efaa192d2deae51ab732e65903238f.

After much testing and upstream discussion this has been deemed to be
the incorrect operation since it means we no longer have any guarantee
about which resource controllers the QEMU processes in general are in.

9 years agovirt-aa-helper: don't deny writes to readonly mounts
Cédric Bosdonnat [Tue, 17 Nov 2015 09:11:30 +0000 (10:11 +0100)]
virt-aa-helper: don't deny writes to readonly mounts

There is no need to deny writes on a readonly mount: write still
won't be accepted, even if the user remounts the folder as RW in
the guest as qemu sets the 9p mount as ro.

This deny rule was leading to problems for example with readonly /:
The qemu process had to write to a bunch of files in / like logs,
sockets, etc. This deny rule was also preventing auditing of these
denials, making it harder to debug.

9 years agoconf: Initialize 'deflate' for balloon parse XML
John Ferlan [Wed, 13 Jan 2016 22:01:04 +0000 (17:01 -0500)]
conf: Initialize 'deflate' for balloon parse XML

Commit id '7bf3198df' neglected to initialize deflate leading to a
possibility if model allocation/checks fail, then the VIR_FREE(deflate)
would be erroneous. Noted by Jan Tomko.

9 years agowireshark: Drop DESTDIR from install path
Michal Privoznik [Wed, 13 Jan 2016 15:10:15 +0000 (16:10 +0100)]
wireshark: Drop DESTDIR from install path

In 50078cfbcbf3c8 I've tried to fix distcheck but accidentally
broke rpm build. The problem is that rpm build not only sets
DESTDIR but also passes plugindir path. This results in double
DESTDIR being in the plugin path, Drop one.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirsh: Update description of lxc-enter-namespace
Guido Günther [Wed, 13 Jan 2016 07:47:26 +0000 (08:47 +0100)]
virsh: Update description of lxc-enter-namespace

Mention that we run a command in that namespace

9 years agobuild: fix distdir with wireshark disabled
Cole Robinson [Tue, 12 Jan 2016 20:56:42 +0000 (15:56 -0500)]
build: fix distdir with wireshark disabled

Even though the Makefile has WITH_WIRESHARK guards, the _SOURCES
variables are still processed when adding bits to the dist archive.

plugin.c is a generated file that is only built when wireshark is
enabled and it shouldn't be distributed, so use 'nodist'

9 years agoqemuProcessCleanupChardevDevice: Don't unlink NULL paths
Michal Privoznik [Wed, 13 Jan 2016 10:17:24 +0000 (11:17 +0100)]
qemuProcessCleanupChardevDevice: Don't unlink NULL paths

So, you try to start a domain, but before we even get to the part
where chardev part of qemu command line is generated (and
possibly missing path to unix sockets is made up) an error occurs
which results in calling qemuProcessStop. This will then try to
clean up the mess and possibly ends up calling unlink(NULL).

==8085== Thread 3:
==8085== Syscall param unlink(pathname) points to unaddressable byte(s)
==8085==    at 0xA85EA57: unlink (in /lib64/libc-2.21.so)
==8085==    by 0x213D3C24: qemuProcessCleanupChardevDevice (qemu_process.c:2866)
==8085==    by 0x558D6B1: virDomainChrDefForeach (domain_conf.c:22924)
==8085==    by 0x213DA9AE: qemuProcessStop (qemu_process.c:5326)
==8085==    by 0x213DA2F2: qemuProcessStart (qemu_process.c:5190)
==8085==    by 0x2142957F: qemuDomainObjStart (qemu_driver.c:7396)
==8085==    by 0x214297DB: qemuDomainCreateWithFlags (qemu_driver.c:7450)
==8085==    by 0x21429842: qemuDomainCreate (qemu_driver.c:7468)
==8085==    by 0x5611B95: virDomainCreate (libvirt-domain.c:6753)
==8085==    by 0x125D9A: remoteDispatchDomainCreate (remote_dispatch.h:3613)
==8085==    by 0x125CB7: remoteDispatchDomainCreateHelper (remote_dispatch.h:3589)
==8085==    by 0x568BF41: virNetServerProgramDispatchCall (virnetserverprogram.c:437)
==8085==  Address 0x0 is not stack'd, malloc'd or (recently) free'd
==8085==

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoxenconfig: check return value of regcomp
Jim Fehlig [Tue, 12 Jan 2016 18:34:06 +0000 (11:34 -0700)]
xenconfig: check return value of regcomp

Commit ec63000a missed checking the return value of regcomp(),
which coverity promptly identified.

9 years agowireshark: Install into DESTDIR
Michal Privoznik [Tue, 12 Jan 2016 16:20:08 +0000 (17:20 +0100)]
wireshark: Install into DESTDIR

Like everything we install, it should be prefixed with DESTDIR.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoXen: use correct domctl version in domaininfolist union
Jim Fehlig [Mon, 11 Jan 2016 22:17:53 +0000 (15:17 -0700)]
Xen: use correct domctl version in domaininfolist union

Commmit fd2e3c4c used the domctl version 8 structure for version 9
in the xen_getdomaininfolist union, resulting in insufficient buffer
size (and subsequent memory corruption) for the GETDOMAININFOLIST
ioctl.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
9 years agotestutils: Fix coverity warning with REGENERATE_OUTPUT
Cole Robinson [Tue, 12 Jan 2016 15:55:08 +0000 (10:55 -0500)]
testutils: Fix coverity warning with REGENERATE_OUTPUT

- Don't double check for expectName
- actual is always non-NULL by this point, so don't check it either

9 years agobuild: Kill tools/wireshark Makefiles
Cole Robinson [Sun, 10 Jan 2016 20:35:36 +0000 (15:35 -0500)]
build: Kill tools/wireshark Makefiles

Just handle it all in tools/Makefile.am. I verified the generated output
looks similar to the pre patch output, but I didn't test it.

9 years agoExpand $(wildcard) correctly
Michal Privoznik [Tue, 12 Jan 2016 15:22:24 +0000 (16:22 +0100)]
Expand $(wildcard) correctly

So after da176bf6b756 and friend we have switched to $(wildcard
some/path/*.xml) instead of enumerating the files explicitly.
This is nice, however it makes distcheck build from VPATH fail.
The reason is that it's is not obvious to what does the wildcard
refer to: srcdir or builddir?

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemu: add support of optional 'autodeflate' attribute
Dmitry Andreev [Fri, 8 Jan 2016 10:45:07 +0000 (13:45 +0300)]
qemu: add support of optional 'autodeflate' attribute

Autodeflate can be enabled/disabled for memballon device
of model 'virtio'.

xml:
<devices>
  <memballoon model='virtio' autodeflate='on'/>
</devices>

qemu:
qemu -device virtio-balloon-pci,...,deflate-on-oom=on

Autodeflate cannot be enabled/disabled for running domain.

9 years agoqemu: add capability check for memballoon 'deflate-on-oom' feature
Dmitry Andreev [Fri, 8 Jan 2016 10:45:06 +0000 (13:45 +0300)]
qemu: add capability check for memballoon 'deflate-on-oom' feature

Add appropriate capability check and new virQEMUCaps flag for the new
virtio balloon feature. QEMU commit with the complete feature description:
http://git.qemu.org/?p=qemu.git;a=commit;h=e3816255bf4b6377bb405331e2ee0dc14d841b80

9 years agoconf: introduce 'autodeflate' attribute for memballoon device
Dmitry Andreev [Fri, 8 Jan 2016 10:45:05 +0000 (13:45 +0300)]
conf: introduce 'autodeflate' attribute for memballoon device

Excessive memory balloon inflation can cause invocation of OOM-killer,
when Linux is under severe memory pressure. QEMU memballoon device
has a feature to release some memory at the last moment before some
process will be get killed by OOM-killer.

Introduce a new optional balloon device attribute 'autodeflate' to
enable or disable this feature.

9 years agorpc: socket: Don't repeatedly attempt to launch daemon
Cole Robinson [Tue, 12 Jan 2016 01:13:38 +0000 (20:13 -0500)]
rpc: socket: Don't repeatedly attempt to launch daemon

On every socket connect(2) attempt we were re-launching session
libvirtd, up to 100 times in 5 seconds.

This understandably caused some weird load races and intermittent
qemu:///session startup failures

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

9 years agorpc: socket: Explicitly error if we exceed retry count
Cole Robinson [Tue, 12 Jan 2016 01:08:45 +0000 (20:08 -0500)]
rpc: socket: Explicitly error if we exceed retry count

When we autolaunch libvirtd for session URIs, we spin in a retry
loop waiting for the daemon to start and the connect(2) to succeed.

However if we exceed the retry count, we don't explicitly raise an
error, which can yield a slew of different error messages elsewhere
in the code.

Explicitly raise the last connect(2) failure if we run out of retries.

9 years agorpc: socket: Minor cleanups
Cole Robinson [Tue, 12 Jan 2016 01:01:24 +0000 (20:01 -0500)]
rpc: socket: Minor cleanups

- Add some debugging
- Make the loop dependent only on retries
- Make it explicit that connect(2) success exits the loop
- Invert the error checking logic

9 years agoAdd missing virxdrdefs.h include to log_protocol
Roman Bogorodskiy [Tue, 12 Jan 2016 15:11:11 +0000 (18:11 +0300)]
Add missing virxdrdefs.h include to log_protocol

Commit 2b6f6ad introduced the virxdrdefs.h header with
common definitions to be included in the protocol files,
but logging/log_protocol.x was missed, so add it there as well.

Hopefully this fixes build on OS X.

9 years agovirsh: Fix alignment in VIRSH_COMMON_OPT_CONFIG definition
Andrea Bolognani [Tue, 12 Jan 2016 08:09:36 +0000 (09:09 +0100)]
virsh: Fix alignment in VIRSH_COMMON_OPT_CONFIG definition

9 years agorpc: Don't rewrite msg->fds on every read dispatch
Ben Gray [Thu, 26 Nov 2015 16:10:40 +0000 (16:10 +0000)]
rpc: Don't rewrite msg->fds on every read dispatch

When we are receiving data in smaller chunks it might happen that
virNetServerClientDispatchRead() will be called multiple times.  And as
that happens, if it is a message that also transfer headers, we decode
the number of them every single time and, unfortunately, also allocate
the memory for them.  That causes a leak, in the best scenario.

Best viewed with '-w'.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agovirsh: Create macro for common "interface" option
John Ferlan [Sat, 9 Jan 2016 13:36:35 +0000 (08:36 -0500)]
virsh: Create macro for common "interface" option

Rather than continually cut-n-paste the strings into each command,
create a common macro to be used generically.  Note that not all
'{.name = "interface",' entries are replaced, just those that have the
common .help string of "interface name or MAC address".

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agovirsh: Create macro for common "network" option
John Ferlan [Sat, 9 Jan 2016 13:36:34 +0000 (08:36 -0500)]
virsh: Create macro for common "network" option

Rather than continually cut-n-paste the strings into each command,
create a common macro to be used generically.  Note that not all
'{.name = "network",' entries are replaced, just those that have the
common .help string of "network name or uuid".

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agovirsh: Create macros for common "vol" options
John Ferlan [Sat, 9 Jan 2016 13:36:31 +0000 (08:36 -0500)]
virsh: Create macros for common "vol" options

Rather than continually cut-n-paste the strings into each command,
create common macros to be used generically.  Replace the more commonly
used "vol" option with a macro. This also adjusts 2 commands that
didn't have the correct helpstr - 'vol-create-from' and 'vol-clone'.
Both are described in the man page as taking vol, path, or key and
the code uses the virshCommandOptVol instead of virshCommandOptVolBy.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agovirsh: Create macro for common "file" option
John Ferlan [Sat, 9 Jan 2016 13:36:29 +0000 (08:36 -0500)]
virsh: Create macro for common "file" option

Rather than continually cut-n-paste the strings into each command,
create a common macro to be used generically. The macro will take a
single argument _helpstr for the less common help string for each
command option.  Note that only file options using "OT_DATA" and
"OFLAG_REQ" will be replace - others are left as is.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agovirsh: Create macro for common "current" option
John Ferlan [Sat, 9 Jan 2016 13:36:28 +0000 (08:36 -0500)]
virsh: Create macro for common "current" option

Rather than continually cut-n-paste the strings into each command,
create a common macro to be used generically. The macro will take a
single argument _helpstr which for many options in virsh-domain.c
is simply "affect current domain". So, create a second macro within that
file in order to define the more common use as a revector to the
common macro with the common _helpstr.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agovirsh: Create macro for common "live" option
John Ferlan [Sat, 9 Jan 2016 13:36:27 +0000 (08:36 -0500)]
virsh: Create macro for common "live" option

Rather than continually cut-n-paste the strings into each command,
create a common macro to be used generically. The macro will take a
single argument _helpstr which for many options in virsh-domain.c
is simply "affect running domain". So, create a second macro within that
file in order to define the more common use as a revector to the
common macro with the common _helpstr.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agovirsh: Create macro for common "config" option
John Ferlan [Sat, 9 Jan 2016 13:36:26 +0000 (08:36 -0500)]
virsh: Create macro for common "config" option

Rather than continually cut-n-paste the strings into each command,
create a common macro to be used generically. The macro will take a
single argument _helpstr which for many options in virsh-domain.c
is simply "affect next boot". So, create a second macro within that
file in order to define the more common use as a revector to the
common macro with the common _helpstr.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agovirsh: Create macro for common "persistent" option
John Ferlan [Sat, 9 Jan 2016 13:36:25 +0000 (08:36 -0500)]
virsh: Create macro for common "persistent" option

Rather than continually cut-n-paste the strings into each command,
create a common macro to be used generically.  Note that not all
'{.name = "persistent",' entries are replaced, just those that have the
common .help string of "make live change persistent".

Non replaced instances are unique to the command.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agovirsh: Create macro for common "domain" option
John Ferlan [Sat, 9 Jan 2016 13:36:24 +0000 (08:36 -0500)]
virsh: Create macro for common "domain" option

Rather than continually cut-n-paste the strings into each command,
create a common macro to be used generically. The macro will take a
single argument _helpstr which will be used to pass the translatable
helpstr since not all domain options can take the same string.

The majority of the options take 'N_("domain name, id or uuid")', so
create a separate macro with a _FULL suffix while those that do not
take the same string will use the VIRSH_COMMON_OPT_DOMAIN macro.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agovirsh: Adjustments for the VIRSH_COMMON_OPT_POOL
John Ferlan [Sat, 9 Jan 2016 13:36:23 +0000 (08:36 -0500)]
virsh: Adjustments for the VIRSH_COMMON_OPT_POOL

The macro is slightly adjusted to add an argument "_helpstr". This
will be passed as a translation macro string since other uses of the
option may not have the same exact help string (such as is the case
when the uuid is not suppliable for create commands).

In virsh-pool.c - we'll create a singular VIRSH_COMMON_OPT_POOL_FULL
in order to pass along the 'N_("pool name or uuid")'

In virsh-volume.c there will be a VIRSH_COMMON_OPT_POOL_FULL and a
VIRSH_COMMON_OPT_POOL_NAME, which passes 'N_("pool name")' for
the commands that can only pass a name. There will also be a
VIRSH_COMMON_OPT_POOL_OPTIONAL which is used for the command
options which use OT_STRING and don't require the --pool argument.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agovirsh: Convert VSH_POOL_ macro to VIRSH_COMMON_OPT_
John Ferlan [Sat, 9 Jan 2016 13:36:22 +0000 (08:36 -0500)]
virsh: Convert VSH_POOL_ macro to VIRSH_COMMON_OPT_

Commit id's 'cf793b00', 'e178688f', 'f9a6110f', '5372d49', and 'e193735'
added new VSH_POOL_ macros; however, it was pointed out after push that
commit id '834c5720' preferred use of VIRSH_ for the prefix over VSH_.

So this patch just changes the VSH_ to VIRSH_ and it changes the naming
format from VIRSH_<opt>_OPT_COMMON to VIRSH_COMMON_OPT_<opt>.

Signed-off-by: John Ferlan <jferlan@redhat.com>
9 years agoutil: eliminate bogus error log in virNetDevVPortProfileGetStatus
Laine Stump [Mon, 11 Jan 2016 22:08:43 +0000 (17:08 -0500)]
util: eliminate bogus error log in virNetDevVPortProfileGetStatus

 if instanceId is NULL

When virNetDevVPortProfileGetStatus() was called with instanceId =
NULL (which is the case for all DISASSOCIATE requests in 802.1Qbh) it
would log the following error:

   Could not find netlink response with expected parameters

even though the disassociate had been successfully completely. Then,
due to the fortunate coincidence of status having been initialized to
0 and then not changed when the "failure" was encountered, it would
still return a status of 0 (PORT_VDP_RESPONSE_SUCCESS), so the caller
would assume a successful operation.

This would result in a spurious log message though, and would fill in
LastErrorMessage, so that the API would return that error if it
happened during cleanup from some other error. That, in turn, would
lead to an incorrect supposition that the response to the port profile
disassociate was the cause of the failure.

During debugging, I noticed that the VF in question usually had *no
uuid* associated with it (big surprise)by the time the disassociate
completed, so the solution is *not* to send the previous instanceId
down.

This patch fixes virNetDevVPortProfileGetStatus() to only check the
VF's uuid in the status if it was given an instanceId to check against
when originally called. Otherwise it only checks that the particular
VF is present (it will be).

This does cause a slight difference in behavior - rather than
returning with status unchanged (and thus always 0) it will actually
get the IFLA_PORT_RESPONSE. This could lead to revelation of error
conditions we were previously ignoring. Or not. So far "not".

9 years agoqemu: use enum when setting PCI "multi" value, not 0 or 1
Laine Stump [Mon, 11 Jan 2016 20:12:08 +0000 (15:12 -0500)]
qemu: use enum when setting PCI "multi" value, not 0 or 1

Use the VIR_TRISTATE_SWITCH_* enums appropriately.

No functional change.

9 years agoqemu: auto-add a USB2 controller set for Q35 machines
Laine Stump [Tue, 20 Oct 2015 16:08:56 +0000 (12:08 -0400)]
qemu: auto-add a USB2 controller set for Q35 machines

Use virDomainDefAddUSBController() to add an EHCI1+UHCI1+UHCI2+UHCI3
controller set to newly defined Q35 domains that don't have any USB
controllers defined.

9 years agoqemu: define virDomainDevAddUSBController()
Laine Stump [Thu, 5 Nov 2015 20:16:50 +0000 (15:16 -0500)]
qemu: define virDomainDevAddUSBController()

This new function will add a single controller of the given model,
except the case of ich9-usb-ehci1 (the master controller for a USB2
controller set) in which case a set of related controllers will be
added (EHCI1, UHCI1, UHCI2, UHCI3). These controllers will not be
given PCI addresses, but should be otherwise ready to use.

"-1" is allowed for controller model, and means "default for this
machinetype". This matches the existing practice in
qemuDomainDefPostParse(), which always adds the default controller
with model = -1, and relies on the commandline builder to set a model
(that is wrong, but will be fixed later).

9 years agoconf: add virDomainDefAddController()
Laine Stump [Fri, 6 Nov 2015 18:01:29 +0000 (13:01 -0500)]
conf: add virDomainDefAddController()

We need a virDomainDefAddController() that doesn't check for an
existing controller at the same index (since USB2 controllers must be
added in sets of 4 that are all at the same index), so rather than
duplicating the code in virDomainDefMaybeAddController(), split it
into two functions, in the process eliminating existing duplicated
code that loops through the controller list by calling
virDomainControllerFind(), which does the same thing).

9 years agoqemu: prefer 00:1D.x and 00:1A.x for USB2 controllers on Q35
Laine Stump [Wed, 21 Oct 2015 19:08:49 +0000 (15:08 -0400)]
qemu: prefer 00:1D.x and 00:1A.x for USB2 controllers on Q35

The real Q35 machine puts the first USB controller set (EHCI+(UHCIx4))
on bus 0 slot 0x1D, and the 2nd USB controller set on bus 0 slot 0x1A,
so let's attempt to make the virtual machine match that for
controllers with auto-assigned addresses when possible.

Three test cases were added to assure that the proper addresses are
assigned - one with a single set of unaddressed USB controllers, one
with 3 (to grab both preferred slots plus one more), and one with the
order of the controller definitions reordered, to assure that the
auto-assignment isn't mixed up by order.

9 years agoqemu: don't assume slot 0 is unused/reserved.
Laine Stump [Wed, 21 Oct 2015 18:49:06 +0000 (14:49 -0400)]
qemu: don't assume slot 0 is unused/reserved.

When qemuAssignDevicePCISlots() is looking for companion controllers
for a USB controller that has no PCI address specified, it initializes
a virDevicePCIAddress to 0000:00:00.0, fills it in with the
companion's address if one is found, then checks whether or not there
was a find based on slot == 0. On a system with a single PCI bus, that
is a valid way to check, because slot 0 is reserved, but on most other
PCI buses, slot 0 is not reserved, and is open for use by any
device. This patch adds a separate bool that is set when a companion
is found rather than relying on the faulty information provided with
"slot == 0".

9 years agoUnify int types handling in protocol files
Jasper Lievisse Adriaanse [Sat, 9 Jan 2016 22:37:33 +0000 (01:37 +0300)]
Unify int types handling in protocol files

Some of the protocol files already include handing of the missing int
types such as xdr_uint64_t, some don't. To fix it everywhere, move out
of the appropriate defines to the utils/virxdrdefs.h file and include
it where needed.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
9 years agoUse struct sockpeercred when available
Jasper Lievisse Adriaanse [Thu, 7 Jan 2016 21:31:17 +0000 (00:31 +0300)]
Use struct sockpeercred when available

OpenBSD uses 'struct sockpeercred' instead of 'struct ucred'. Add a
configure check that detects its presence and use if in the code that
could be compiled on OpenBSD.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
9 years agocgroup: don't include sys/mount.h if not needed
Jasper Lievisse Adriaanse [Thu, 7 Jan 2016 18:41:52 +0000 (21:41 +0300)]
cgroup: don't include sys/mount.h if not needed

As cgroup implementation only works on Linux, it does not
make much sense to include sys/mount.h if other requirements are
not met, such as HAVE_MNTENT_H and HAVE_GETMNTENT_R.

Also, it fixes build on OpenBSD that requires to include sys/param.h
along with sys/mount.h.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
9 years agobuild: Kill docs/schemas/Makefile.am
Cole Robinson [Sun, 10 Jan 2016 20:14:33 +0000 (15:14 -0500)]
build: Kill docs/schemas/Makefile.am

Move the logic to docs/Makefile.am, and simplify it with a wildcard
expression.

9 years agobuild: Kill include/libvirt/Makefile.am
Cole Robinson [Sun, 10 Jan 2016 19:36:13 +0000 (14:36 -0500)]
build: Kill include/libvirt/Makefile.am

Move all the logic to include/Makefile.am, simplify it with a wildcard,
then kill include/libvirt/Makefile.am

9 years agowireshark: Fix header of get_message_len()
Michal Privoznik [Sun, 27 Dec 2015 10:00:22 +0000 (11:00 +0100)]
wireshark: Fix header of get_message_len()

In wireshark commit ceb8d954 (v1.99.2) they have changed the
signature of a function that determines how long a libvirt packet
is. Now it accepts a void pointer for passing data into the
function. Well, this is nice, but we don't need it right now.
Anyway, we have to change our code.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agowireshark: Replace WIRESHARK_COMPAT with actual version comparison
Michal Privoznik [Mon, 4 Jan 2016 10:26:03 +0000 (11:26 +0100)]
wireshark: Replace WIRESHARK_COMPAT with actual version comparison

In the upcoming patch we will need yet another #ifdef code block
depending on wireshark version. Instead of defining
WIRESHARK_COMPAT2 or something lets just compare the version
right at the place so that we can clearly see what version broke
API.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agowireshark: s/tvb_length/tvb_captured_length/
Michal Privoznik [Sun, 27 Dec 2015 09:55:29 +0000 (10:55 +0100)]
wireshark: s/tvb_length/tvb_captured_length/

In wireshak commit 22149c55 (v.1.11.3) the API was renamed.
Follow the change in our code too. Since the wireshark change was
made in the very same version that we require at least we are
good to go.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agowireshark: s/ep_alloc/wmem_alloc/
Michal Privoznik [Sun, 27 Dec 2015 09:49:10 +0000 (10:49 +0100)]
wireshark: s/ep_alloc/wmem_alloc/

In wireshark, they have introduced their own memory allocator
wmem. This means that we need to adapt our code to that change
too. Notably 0ad15f88ccf434e8210ca is the wireshark commit you
want to look at. It's the one where they dropped the old API. The
new allocator has been introduced in 84cc3daa (v1.10.0), however,
was not exposed until 5c05c9e0 (v1.10.0). Since we already are
requiring 1.11.3 or higher no other change is needed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agowireshark: s/proto_tree_add_text/proto_tree_add_item/
Michal Privoznik [Sun, 27 Dec 2015 09:43:37 +0000 (10:43 +0100)]
wireshark: s/proto_tree_add_text/proto_tree_add_item/

In the wireshark commit e2735ecfdd7a96c they dropped
proto_tree_add_text in favor of proto_tree_add_item. Adapt to
this change.

Moreover, the proto_tree_add_item API is around for ages and we
are already using it anyway. Therefore we don't need to change
required version of wireshark.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemu: Introduce QEMU_CAPS_VSERPORT_CHANGE
Michal Privoznik [Tue, 5 Jan 2016 13:05:15 +0000 (14:05 +0100)]
qemu: Introduce QEMU_CAPS_VSERPORT_CHANGE

This capability tells if qemu is capable of vserport_change
events.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemu: change qemuFindAgentConfig return type
Michal Privoznik [Fri, 8 Jan 2016 15:21:30 +0000 (16:21 +0100)]
qemu: change qemuFindAgentConfig return type

While this is no functional change, whole channel definition is
going to be needed very soon. Moreover, while touching this obey
const correctness rule in qemuAgentOpen() - so far it was passed
regular pointer to channel config even though the function is
expected to not change pointee at all. Pass const pointer
instead.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoqemu: Set virtio channel state sooner
Michal Privoznik [Tue, 5 Jan 2016 10:39:20 +0000 (11:39 +0100)]
qemu: Set virtio channel state sooner

In qemu driver we listen to virtio channel events like an agent
connected to or disconnected from the guest part of socket.
However, with a little exception - when we find out that the
socket in question is the guest agent one, we connect or
disconnect guest agent which is done prior setting new state in
internal structure. Due to a bug in our code it may happen that
we got the event but failed to set it in internal structure
representing the channel.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoFix LSB requirements in service script and sync them
Martin Kletzander [Thu, 7 Jan 2016 08:50:26 +0000 (09:50 +0100)]
Fix LSB requirements in service script and sync them

Commit b22344f3285187ee1768d6e031bc0ff20e32552d mistakenly reordered
Default-* lines.  Thanks to that I noticed that we are very inconsistent
with our init scripts, so I took the liberty of synchronizing them,
updating them and making them all look shiny and new.  So apart from
fixing the LSB requirements, I also fixed the ordering, specified
runlevels and fix the link to the reference specification.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agovirDomainGetTime: Deny on RO connections
Michal Privoznik [Mon, 11 Jan 2016 12:34:17 +0000 (13:34 +0100)]
virDomainGetTime: Deny on RO connections

We have a policy that if API may end up talking to a guest agent
it should require RW connection. We don't obey the rule in
virDomainGetTime().

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirDomainInterfaceAddresses: Allow API on RO connection too
Michal Privoznik [Mon, 11 Jan 2016 11:48:30 +0000 (12:48 +0100)]
virDomainInterfaceAddresses: Allow API on RO connection too

This API does not change domain state. However, we have a policy
that an API talking to a guest agent requires RW access. But that
happens only if source == VIR_DOMAIN_INTERFACE_ADDRESSES_SRC_AGENT.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirsh: Document the --timestamp option
Andrea Bolognani [Fri, 8 Jan 2016 11:04:08 +0000 (12:04 +0100)]
virsh: Document the --timestamp option

The event, net-event and qemu-monitor-event virsh commands all
support the --timestamp option now, but such option was not
referenced in the man page.

9 years agovirsh: Add timestamps to network events
Andrea Bolognani [Fri, 8 Jan 2016 10:50:55 +0000 (11:50 +0100)]
virsh: Add timestamps to network events

Implement a --timestamp option for 'virsh net-event', similar to the
one for 'virsh event'.

When the option is used, the human-readable timestamp will be printed
before the message.

9 years agovirsh: Add timestamps to QEMU monitor events
Andrea Bolognani [Mon, 21 Dec 2015 15:22:58 +0000 (16:22 +0100)]
virsh: Add timestamps to QEMU monitor events

Implement a --timestamp option for 'virsh qemu-monitor-event', similar
to the one for 'virsh event'.

When the option is used, the human-readable timestamp will be printed
before the message, and the timing information provided by QEMU will
not be displayed.

9 years agoDon't clear libvirt-internal paths when parsing status XML
Martin Kletzander [Fri, 8 Jan 2016 12:59:20 +0000 (13:59 +0100)]
Don't clear libvirt-internal paths when parsing status XML

Earlier commit 714080791778e3dfbd484ccb3953bffd820b8ba9 forgot to deal
properly with status XMLs where we want the libvirt-internal paths to be
kept in place and not cleared, otherwise we could end up copying a NULL
string and segfaulting th daemon.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoProvide parse flags to PostParse functions
Martin Kletzander [Fri, 8 Jan 2016 13:00:56 +0000 (14:00 +0100)]
Provide parse flags to PostParse functions

This way both Domain and Device PostParse functions can act based on the
flags.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoqemu: command: wire up usage of q35/ich9 disable s3/s4
Cole Robinson [Sat, 9 Jan 2016 21:00:01 +0000 (16:00 -0500)]
qemu: command: wire up usage of q35/ich9 disable s3/s4

If the q35 specific disable s3/s4 setting isn't supported, fallback to
specifying the PIIX setting, which is the previous behavior. It doesn't
have any effect, but qemu will just warn about it rather than error:

  qemu-system-x86_64: Warning: global PIIX4_PM.disable_s3=1 not used
  qemu-system-x86_64: Warning: global PIIX4_PM.disable_s4=1 not used

Since it doesn't error, I don't think we should either, since there
may be configs in the wild that already have q35 + disable_s3/4 (via
virt-manager)

9 years agoqemu: caps: check for q35/ICH9 disable S3/S4
Cole Robinson [Sat, 9 Jan 2016 20:58:50 +0000 (15:58 -0500)]
qemu: caps: check for q35/ICH9 disable S3/S4

Update test data to match

9 years agoqemu: caps: Rename CAPS_DISABLE_S[34] to CAPS_PIIX_DISABLE_S[34]
Cole Robinson [Mon, 4 Jan 2016 22:57:06 +0000 (17:57 -0500)]
qemu: caps: Rename CAPS_DISABLE_S[34] to CAPS_PIIX_DISABLE_S[34]

These settings are specific to PIIX, so clarify it

9 years agoqemu: capabilities: s/Pixx/Piix/g
Cole Robinson [Mon, 4 Jan 2016 22:54:25 +0000 (17:54 -0500)]
qemu: capabilities: s/Pixx/Piix/g

The chipset is called PIIX; the functions are misnamed

9 years agoexamples: Use one top level makefile
Cole Robinson [Sat, 9 Jan 2016 23:03:56 +0000 (18:03 -0500)]
examples: Use one top level makefile

Using one Makefile per example subdirectory essentially serializes 'make'
calls. Convert to one example/Makefile that builds and distributes
all the subdir files. This reduces example/ rebuild time from about 5.8
seconds to 1.5 seconds on my machine.

One slight difference is that we no longer ship Makefile.am with the
examples in the rpm. This was virtually useless anyways since the Makefile
was very specific to libvirt infrastructure, so wasn't generically
reusable anyways.

Tested with 'make distcheck' and 'make rpm'

9 years agocfg.mk: Drop period after filename for indent failures
Cole Robinson [Sat, 9 Jan 2016 21:33:10 +0000 (16:33 -0500)]
cfg.mk: Drop period after filename for indent failures

The period makes it more difficult to copy/paste the errant filename
for manual fixup

9 years agovirt-host-validate-common: Print warning on missing IOMMU
Michal Privoznik [Thu, 7 Jan 2016 10:42:59 +0000 (11:42 +0100)]
virt-host-validate-common: Print warning on missing IOMMU

No only coverity warns about this, but it kind of makes sense
too. We have a test whether host supports IOMMU. Some platforms
don't have it, I know. But in that case we should print a message
that it's unknown whether platform has it or not.

Before:
  (no output)

After:
  QEMU: Checking for device assignment IOMMU support                         : WARN (Unknown if this platform has IOMMU support)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirDomainMigrateUnmanagedParams: Don't blindly dereference @dconnuri
Michal Privoznik [Thu, 7 Jan 2016 10:39:45 +0000 (11:39 +0100)]
virDomainMigrateUnmanagedParams: Don't blindly dereference @dconnuri

This function may be called with @dconnuri == NULL, e.g. from
virDomainMigrateToURI3() if the flags are missing
VIR_MIGRATE_PEER2PEER flag. Moreover, all later functions called
from here do wrap it into NULLSTR() so why not do the same here?

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agoFix USB model defaults for ppc64
Martin Kletzander [Thu, 7 Jan 2016 15:14:58 +0000 (16:14 +0100)]
Fix USB model defaults for ppc64

The condition was checking for UHCI (and OHCI for ppc64) availability so
that it can specify the proper device instead of legacy usb.  However,
for ppc64, we don't need to check both OHCI and UHCI, but only OHCI as
that is the legacy default.  The condition is so big that it was just a
matter of time when someone will make a mistake there, so let's use more
lines so that it is visible what the condition checks for.

This fixes usage of -device instead of -usb for ppc64 that supports
pci-usb-ohci and does not support piix3-usb-uhci.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoAvoid wild securityManager pointer in tests
Martin Kletzander [Sat, 9 Jan 2016 17:28:53 +0000 (18:28 +0100)]
Avoid wild securityManager pointer in tests

For some reason we are not setting the driver with memset() to zeros.
But since commit 74abc3deac6e14ffa9151e425c6e6cd2b075aac5
driver->securityManager is being accessed and qemuagenttest started
crashing due to that.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agotests: qemuxml2xml: Wire up QEMUCaps usage
Cole Robinson [Fri, 8 Jan 2016 03:50:05 +0000 (22:50 -0500)]
tests: qemuxml2xml: Wire up QEMUCaps usage

Future changes will make some of these tests dependent on specific
QEMUCaps flags, so wire up the basic handling. Flags will be added
in future patches.

9 years agotests: add genericxml2xmltest
Cole Robinson [Fri, 8 Jan 2016 23:15:33 +0000 (18:15 -0500)]
tests: add genericxml2xmltest

For testing hypervisor independent XML handling. Right now it's just
populated with an example test case.

9 years agotests: qemuxml2xml: drop early file loading
Cole Robinson [Fri, 8 Jan 2016 21:41:37 +0000 (16:41 -0500)]
tests: qemuxml2xml: drop early file loading

For the standard active/inactive XML testing, if we leave the file loading
up to the generic XML2XML infrastructure, we get the benefit of
VIR_TEST_REGENERATE_OUTPUT, at the price of a few more disk reads. Seems
worth it.

9 years agotests: Share domain XML2XML compare helper
Cole Robinson [Fri, 8 Jan 2016 20:55:44 +0000 (15:55 -0500)]
tests: Share domain XML2XML compare helper

This creates a shared function in testutils.c that consolidates all
the slightly different implementations.

9 years agotests: Fix running schematests directly from topdir
Cole Robinson [Fri, 8 Jan 2016 23:31:16 +0000 (18:31 -0500)]
tests: Fix running schematests directly from topdir

Previously it failed like:

$ ./tests/domainschematest
./tests/domainschematest: line 4: ./test-lib.sh: No such file or directory

9 years agotests: Add newlines with VIR_TEST_REGENERATE_OUTPUT
Cole Robinson [Mon, 4 Jan 2016 19:31:58 +0000 (14:31 -0500)]
tests: Add newlines with VIR_TEST_REGENERATE_OUTPUT

Since test files are formatted predictably nowadays, we can make
VIR_TEST_REGENERATE_OUTPUT handle most cases for us with a simple
replacement. test-wrap-argv.pl is still canon, but this bit makes
it easier to confirm test output changes during active development.

9 years agolibxl: support vif outgoing bandwidth QoS
Jim Fehlig [Tue, 29 Dec 2015 00:26:58 +0000 (17:26 -0700)]
libxl: support vif outgoing bandwidth QoS

The libxl_device_nic structure supports specifying an outgoing rate
limit based on a time interval and bytes allowed per interval. In xl
config a rate limit is specified as "<RATE>/s@<INTERVAL>". INTERVAL
is optional and defaults to 50ms.

libvirt expresses outgoing limits by average (required), peak, burst,
and floor attributes in units of KB/s. This patch supports the outgoing
bandwidth limit by converting the average KB/s to bytes per interval
based on the same default interval (50ms) used by xl.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
9 years agoxenconfig: support vif bandwidth in xm and xl parser and formatter
Jim Fehlig [Mon, 28 Dec 2015 22:26:17 +0000 (15:26 -0700)]
xenconfig: support vif bandwidth in xm and xl parser and formatter

Both xm and xl config have long supported specifying vif rate
limiting, e.g.

vif = [ 'mac=00:16:3E:74:3d:76,bridge=br0,rate=10MB/s' ]

Add support for mapping rate to and from <bandwidth> in the xenconfig
parser and formatter. rate is mapped to the required 'average' attribute
of the <outbound> element, e.g.

  <interface type='bridge'>
    ...
    <bandwidth>
      <outbound average='10240'/>
    </bandwidth>
  </interface>

Also add a unit test to check the conversion logic.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
9 years agoxenconfig: support vif bandwidth in sexpr parser and formatter
Jim Fehlig [Tue, 5 Jan 2016 00:46:31 +0000 (17:46 -0700)]
xenconfig: support vif bandwidth in sexpr parser and formatter

The xen sexpr config format has long supported specifying vif rate
limiting, e.g.

  (device
    (vif
      (mac '00:16:3e:1b:b1:47')
      (rate '10240KB/s')
      ...
    )
  )

Add support for mapping rate to and from <bandwidth> in the xenconfig
sexpr parser and formatter. rate is mapped to the required 'average'
attribute of the <outbound> element, e.g.

  <interface type='bridge'>
    ...
    <bandwidth>
      <outbound average='10240'/>
    </bandwidth>
  </interface>

Also add unit tests to check the conversion logic.

This patch benefits both the old xen driver and the libxl driver.
Both drivers gain support for vif bandwidth when converting to/from
domXML and xen-sxpr. In addition, the old xen driver will now be
able to handle vif 'rate' setting when communicating with xend.

9 years agoqemu: Fix crash when defining XML with bogus emulator
Cole Robinson [Fri, 8 Jan 2016 19:46:48 +0000 (14:46 -0500)]
qemu: Fix crash when defining XML with bogus emulator

We weren't checking for failure of qemuCaps lookup

9 years agoutil: add missing newline
Laine Stump [Fri, 8 Jan 2016 19:09:31 +0000 (14:09 -0500)]
util: add missing newline

Somehow I managed to backspace over the newline between the closing
brace and goto cleanup; in commit 36e244f3.

9 years agotests: qemuxml2argv: Add tests for USB controller on q35
Andrea Bolognani [Fri, 8 Jan 2016 15:20:47 +0000 (16:20 +0100)]
tests: qemuxml2argv: Add tests for USB controller on q35

9 years agotests: qemuxml2xml: Convert fprintf to VIR_TEST_DEBUG
Cole Robinson [Thu, 7 Jan 2016 22:36:07 +0000 (17:36 -0500)]
tests: qemuxml2xml: Convert fprintf to VIR_TEST_DEBUG

9 years agoqemu: Handle SecurityManagerVerify in post parse
Cole Robinson [Thu, 7 Jan 2016 01:43:15 +0000 (20:43 -0500)]
qemu: Handle SecurityManagerVerify in post parse

Rather than open coding calls. I can't see any reason not to