]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
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

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

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

9 years agoqemu: domain: split out post parse default device handling
Cole Robinson [Thu, 7 Jan 2016 01:35:36 +0000 (20:35 -0500)]
qemu: domain: split out post parse default device handling

Should be a no-op

9 years agodomain: separate out function for post parse timer validation
Cole Robinson [Fri, 8 Jan 2016 00:27:32 +0000 (19:27 -0500)]
domain: separate out function for post parse timer validation

This should be a no-op

9 years agodomain: separate out function for post parse console compat
Cole Robinson [Fri, 8 Jan 2016 00:07:45 +0000 (19:07 -0500)]
domain: separate out function for post parse console compat

This should be a no-op

9 years agoqemu: Refactor qemuMigrationFinish
Jiri Denemark [Tue, 15 Dec 2015 12:19:08 +0000 (13:19 +0100)]
qemu: Refactor qemuMigrationFinish

To get rid of a giant if-else block which is very easy to get lost in.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Report more migration statistics
Jiri Denemark [Fri, 27 Nov 2015 11:30:09 +0000 (12:30 +0100)]
qemu: Report more migration statistics

memory_dirty_rate corresponds to dirty-pages-rate in QEMU and
memory_iteration is what QEMU reports in dirty-sync-count.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Create a proper type for migration status enum
Jiri Denemark [Thu, 26 Nov 2015 12:24:31 +0000 (13:24 +0100)]
qemu: Create a proper type for migration status enum

The enum will be called qemuMonitorMigrationStatus.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Rename qemuMonitorMigrationStatus struct
Jiri Denemark [Thu, 26 Nov 2015 12:23:08 +0000 (13:23 +0100)]
qemu: Rename qemuMonitorMigrationStatus struct

The structure actually contains migration statistics rather than just
the status as the name suggests. Renaming it as
qemuMonitorMigrationStats removes the confusion.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agoqemu: Reorder migration status enum
Jiri Denemark [Thu, 26 Nov 2015 11:45:25 +0000 (12:45 +0100)]
qemu: Reorder migration status enum

A migration is in "setup" state after it was "inactive" and before it
becomes "active". Let's reflect this in our migration status enum.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agotests.nwfilterebiptablestest: swap actual and expected
Pavel Hrdina [Thu, 10 Dec 2015 13:10:35 +0000 (14:10 +0100)]
tests.nwfilterebiptablestest: swap actual and expected

Those parameters should be in opposite order.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agotests.testutils: use virTestDifferenceFull in virtTestCompareToFile
Pavel Hrdina [Thu, 10 Dec 2015 14:20:56 +0000 (15:20 +0100)]
tests.testutils: use virTestDifferenceFull in virtTestCompareToFile

Let's use the new virTestDifferenceFull function that will regenerate
the expected output and fail the test to let developer know that there
something was updated.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agotests.testutils: use VIR_TEST_REGENERATE_OUTPUT for virTestDifferenceFull
Pavel Hrdina [Thu, 10 Dec 2015 12:40:54 +0000 (13:40 +0100)]
tests.testutils: use VIR_TEST_REGENERATE_OUTPUT for virTestDifferenceFull

This patch enable regeneration of expected output file for
virTestDifferenceFull.  It also introduces new
virTestDifferenceFullNoRegenerate function for special cases, where we
don't want to regenerate output.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agotests: add helper for VIR_TEST_REGENERATE_OUTPUT flag
Pavel Hrdina [Thu, 10 Dec 2015 12:30:37 +0000 (13:30 +0100)]
tests: add helper for VIR_TEST_REGENERATE_OUTPUT flag

When this flag is specified, some of the expected output files will be
regenerated with the actual output data.  Use helper function like for
other flags.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agoxen: move virDomainDefPostParse to xenParseSxpr
Pavel Hrdina [Thu, 7 Jan 2016 07:59:26 +0000 (08:59 +0100)]
xen: move virDomainDefPostParse to xenParseSxpr

This patch partially reverts previous commit 91a00424 and moves the post
parse function to xenParseSxpr.  This update is required because xen
driver calls xenParseSxpr directly.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agoRemove non-breaking space in comment
Martin Kletzander [Fri, 8 Jan 2016 13:21:23 +0000 (14:21 +0100)]
Remove non-breaking space in comment

It was added by mistake before the 'If' by commit 714080791778.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoqemu: Fix NBD migration with default listenAddress
Jiri Denemark [Thu, 7 Jan 2016 23:07:37 +0000 (00:07 +0100)]
qemu: Fix NBD migration with default listenAddress

My commit 674afcb09e3d33500cfbbcf870ebf92cb99ecfa3 moved computing the
default listen address from qemuMigrationPrepareAny to
qemuMigrationPrepareIncoming. However, I didn't notice listenAddress was
later passed to qemuMigrationStartNBDServer. Thus, it would be called
with the original value of listenAddress (NULL).

Let's add the updated listen address to qemuProcessIncomingDef and use
it when starting NBD servers.

Reported-by: Michael Chapman <mike@very.puzzling.org>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agovirsh: Add timestamps to events
Jiri Denemark [Wed, 16 Dec 2015 16:32:18 +0000 (17:32 +0100)]
virsh: Add timestamps to events

A new --timestamp option for event virsh command can be used to print
timestamp of each event.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agovirsh: Refactor event printing
Jiri Denemark [Wed, 16 Dec 2015 16:31:39 +0000 (17:31 +0100)]
virsh: Refactor event printing

To reduce code duplication.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
9 years agopci: Log debug messages when manipulating the inactive list
Andrea Bolognani [Thu, 7 Jan 2016 16:50:15 +0000 (17:50 +0100)]
pci: Log debug messages when manipulating the inactive list

Most of the changes to the list of active and inactive PCI devices
happen in virHostdev, where they are properly logged.

virPCIDeviceDetach() and virPCIDeviceReattach(), however, change the
inactive list as well, so they should be logging similar messages.

9 years agovirLogVMessage: Don't leak rawinitmsg
Michal Privoznik [Wed, 6 Jan 2016 16:14:44 +0000 (17:14 +0100)]
virLogVMessage: Don't leak rawinitmsg

Instead of misusing a const string to hold up runtime allocated
data, introduce new variable @hoststr and obey const correctness.

==6879== 15 bytes in 1 blocks are definitely lost in loss record 68 of 1,064
==6879==    at 0x4C29F80: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==6879==    by 0xA7DDF97: vasprintf (in /lib64/libc-2.21.so)
==6879==    by 0x552BBC6: virVasprintfInternal (virstring.c:493)
==6879==    by 0x552BCDB: virAsprintfInternal (virstring.c:514)
==6879==    by 0x54FA44C: virLogHostnameString (virlog.c:468)
==6879==    by 0x54FAB0F: virLogVMessage (virlog.c:645)
==6879==    by 0x54FA680: virLogMessage (virlog.c:531)
==6879==    by 0x54FBBF4: virLogParseOutputs (virlog.c:1130)
==6879==    by 0x11CB4F: daemonSetupLogging (libvirtd.c:685)
==6879==    by 0x11E137: main (libvirtd.c:1297)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirLogHostnameString: Don't leak hostname
Michal Privoznik [Wed, 6 Jan 2016 16:07:06 +0000 (17:07 +0100)]
virLogHostnameString: Don't leak hostname

Once @hostname is printed into @hoststr we don't need it anymore.

==6879== 5 bytes in 1 blocks are definitely lost in loss record 10 of 1,064
==6879==    at 0x4C29F80: malloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==6879==    by 0xA7ED599: strdup (in /lib64/libc-2.21.so)
==6879==    by 0x552C126: virStrdup (virstring.c:726)
==6879==    by 0x553B13E: virGetHostnameImpl (virutil.c:720)
==6879==    by 0x553B1BF: virGetHostnameQuiet (virutil.c:741)
==6879==    by 0x54FA3FD: virLogHostnameString (virlog.c:462)
==6879==    by 0x54FAB0F: virLogVMessage (virlog.c:645)
==6879==    by 0x54FA680: virLogMessage (virlog.c:531)
==6879==    by 0x54FBBF4: virLogParseOutputs (virlog.c:1130)
==6879==    by 0x11CB4F: daemonSetupLogging (libvirtd.c:685)
==6879==    by 0x11E137: main (libvirtd.c:1297)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
9 years agovirsh: Interrupt *event --loop on disconnect
Jiri Denemark [Thu, 17 Dec 2015 22:23:16 +0000 (23:23 +0100)]
virsh: Interrupt *event --loop on disconnect

The *event --loop commands would keep running even though a connection
to libvirtd is lost. This doesn't make a lot of sense since clearly we
won't get any new events from the closed connection.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>