]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
8 years agoconf: allow setting peer address in <ip> element of <interface>
Vasiliy Tolstov [Mon, 4 Apr 2016 21:00:03 +0000 (21:00 +0000)]
conf: allow setting peer address in <ip> element of <interface>

The peer attribute is used to set the property of the same name in the
interface IP info:

  <interface type='ethernet'>
    ...
    <ip family='ipv4' address='192.168.122.5'
        prefix='32' peer='192.168.122.6'/>
    ...
  </interface>

Note that this element is used to set the IP information on the
*guest* side interface, not the host side interface - that will be
supported in an upcoming patch.

(This is an updated *re*-commit of commit 690969af, which was
subsequently reverted in commit 1d14b13f).

Signed-off-by: Vasiliy Tolstov <v.tolstov@selfip.ru>
Signed-off-by: Laine Stump <laine@laine.org>
8 years agoutil: new function virNetDevIPInfoAddToDev
Laine Stump [Thu, 16 Jun 2016 16:22:07 +0000 (12:22 -0400)]
util: new function virNetDevIPInfoAddToDev

This patch takes the code out of
lxcContainerRenameAndEnableInterfaces() that adds all IP addresses and
IP routes to the interface, and puts it into a utility function
virNetDevIPInfoAddToDev() in virnetdevip.c so that it can be used by
anyone.

One small change in functionality -
lxcContainerRenameAndEnableInterfaces() previously would add all IP
addresses to the interface while it was still offline, then set the
interface online, and then add the routes. Because I don't want the
utility function to set the interface online, I've moved this up so
the interface is first set online, then IP addresses and routes are
added. This is the same order that the network service from
initscripts (in ifup-ether) does it, so it shouldn't pose any problem
(and hasn't, in the tests that I've run).

8 years agolxc: move debug/error log when adding IP addresses to virNetDevIPAddrAdd
Laine Stump [Wed, 15 Jun 2016 19:27:47 +0000 (15:27 -0400)]
lxc: move debug/error log when adding IP addresses to virNetDevIPAddrAdd

It makes more sense to have the logging at the lower level so other
callers can share the goodness.

While removing so much stuff from / touching so many lines in
lxcContainerRenameAndEnableInterfaces() (which used to have this
debug/error logging), label names were changed and it was updated to
use the now-more-common method of initializing ret to -1 (failure),
then setting to 0 right before the cleanup label.

8 years agoconf: clean up after adding calls to virNetDevIPInfo helpers
Laine Stump [Thu, 9 Jun 2016 01:08:31 +0000 (21:08 -0400)]
conf: clean up after adding calls to virNetDevIPInfo helpers

virDomainNetIPInfoParseXML() and virDomainNetIPInfoFormat() are no
longer "unused", so we can now remove the "ATTRIBUTE_UNUSED" from
their definitions, since virDomainNetIPInfoFormat() is now the only
caller of virDomainNetIPsFormat() and virDomainNetRoutesFormat(),
those two functions can simply be subsumed into
virDomainNetIPInfoFormat().

8 years agoqemu: forbid setting guest-side IP address/route info of <interface>
Laine Stump [Tue, 21 Jun 2016 15:59:37 +0000 (11:59 -0400)]
qemu: forbid setting guest-side IP address/route info of <interface>

libvirt's qemu driver doesn't have direct access to the config on the
guest side of a network interface, and currently doesn't have any
method in place to even inform the guest of the desired config. In the
future, an unenforceable attempt to set the guest-side IP info could
be made by adding a static host entry to the appropriate dnsmasq
configuration (or changing the default dhcp client address on the qemu
commandline for type='user' interfaces), or enhancing the guest agent
to allow setting an IP address, but for now it can't have any effect,
and we don't want to give the illusion that it does.

To prevent the "disappearance" of any existing configs with ip
address/route info (due to parser failure), this check is added in the
newly implemented qemuDomainDeviceDefValidate(), which is only called
when a domain is defined or started, *not* when it is reread from disk
at libvirtd startup.

8 years agoconf: use virNetDevIPInfo for guest-side <interface> config
Laine Stump [Tue, 7 Jun 2016 15:39:34 +0000 (11:39 -0400)]
conf: use virNetDevIPInfo for guest-side <interface> config

All the same information was already there, just in slightly different
places in the virDomainNetDef.

8 years agoconf: use virNetDevIPInfo in virDomainHostdevCaps
Laine Stump [Mon, 6 Jun 2016 19:44:15 +0000 (15:44 -0400)]
conf: use virNetDevIPInfo in virDomainHostdevCaps

a.k.a. <hostdev mode='capabilities' type='net'>.

This replaces the existing nips, ips, nroutes, and routes with a
single virNetDevIPInfo, and simplifies the code by calling that
object's parse/format/clear functions instead of open coding.

8 years agoconf: single object containing list of IP addresses, list of routes
Laine Stump [Mon, 6 Jun 2016 19:19:23 +0000 (15:19 -0400)]
conf: single object containing list of IP addresses, list of routes

There are currently two places in the domain where this combination is
used, and there is about to be another. This patch puts them together
for brevity and uniformity.

As with the newly-renamed virNetDevIPAddr and virNetDevIPRoute
objects, the new virNetDevIPInfo object will need to be accessed by a
utility function that calls low level Netlink functions (so we don't
want it to be in the conf directory) and will be called from multiple
hypervisor drivers (so it can't be in any hypervisor directory); the
most appropriate place is thus once again the util directory.

The parse and format functions are in conf/domain_conf.c because only
the domain XML (i.e. *not* the network XML) has this exact combination
of IP addresses plus routes. Note that virDomainNetIPInfoFormat() will
end up being the only caller to virDomainNetRoutesFormat() and
virDomainNetIPsFormat(), so it will just subsume those functions in a
later patch, but we can't do that until they are no longer called.

(It would have been nice to include the interface name within the
virNetDevIPInfo object (with a slight name change), but that can't
be done cleanly, because in each case the interface name is provided
in a different place in the XML relative to the routes and IP
addresses, so putting it in this object would actually make the code
more confused rather than simpler).

8 years agoutil: move IP route & address object-related functions to virnetdevip.c
Laine Stump [Tue, 14 Jun 2016 17:40:04 +0000 (13:40 -0400)]
util: move IP route & address object-related functions to virnetdevip.c

These functions all need to be called from a utility function that
must be located in the util directory, so we move them all into
util/virnetdevip.[ch] now that it exists.

Function and struct names were appropriately changed for the new
location, but all code is unchanged aside from motion and renaming.

8 years agoutil: new files virnetdevip.[ch] for IP-related netdev functions
Laine Stump [Mon, 13 Jun 2016 21:01:27 +0000 (17:01 -0400)]
util: new files virnetdevip.[ch] for IP-related netdev functions

This patch splits virnetdev.[ch] into multiple files, with the new
virnetdevip.[ch] containing all the functions related to setting and
retrieving IP-related info for a device (both addresses and routes).

8 years agoconf/openvz: eliminate incorrect/undocumented use of <source dev='blah'/>
Laine Stump [Tue, 21 Jun 2016 19:20:57 +0000 (15:20 -0400)]
conf/openvz: eliminate incorrect/undocumented use of <source dev='blah'/>

When support for <interface type='ethernet'> was added in commit
9a4b705f back in 2010, it erroneously looked at <source dev='blah'/>
for a user-specified guest-side interface name. This was never
documented though. (that attribute already existed at the time in the
data.ethernet union member of virDomainNetDef, but apparently had no
practical use - it was only used as a storage place for a NetDef's
bridge name during qemuDomainXMLToNative(), but even then that was
never used for anything).

When support for similar guest-side device naming was added to the lxc
driver several years later, it was put in a new subelement <guest
dev='blah'/>.

In the intervening years, since there was no validation that
ethernet.dev was NULL in the other drivers that didn't actually use
it, innocent souls who were adding other features assuming they needed
to account for non-NULL ethernet.dev when really they didn't, so
little bits of the usual pointless cargo-cult code showed up.

This patch not only switches the openvz driver to use the documented
<guest dev='blah'/> notation for naming the guest-side device (just in
case anyone is still using the openvz driver), and logs an error if
anyone tries to set <source dev='blah'/> for a type='ethernet'
interface, it also removes the cargo-cult uses of ethernet.dev and
<source dev='blah'/>, and eliminates if from the RNG and from
virDomainNetDef.

NB: I decided on this course of action after mentioning the
inconsistency here:

  https://www.redhat.com/archives/libvir-list/2016-May/msg02038.html

and getting encouragement do eliminate it in a later IRC discussion
with danpb.

8 years agoqemu: eliminate memory leaks when converting NetDefs to type='ethernet'
Laine Stump [Tue, 21 Jun 2016 18:29:17 +0000 (14:29 -0400)]
qemu: eliminate memory leaks when converting NetDefs to type='ethernet'

in qemuConnectDomainXMLToNative. This function was only accounting for
about 1/10 of all the allocated items in the NetDef prior to memseting
it to all 0's. On top of that, it was going to great pains to learn
the name of the bridge device, but then never doing anything useful
with it (just putting it into data.ethernet.dev, which is *never* used
when building a qemu commandline). (I think this again all started off
as code with good intentions, but it was never completed, and instead
was just Frankensteinically cargo-culted into the odd mish mash we
have today).

The resulting code is much simpler, produces exactly the same output,
and doesn't leak memory.

8 years agoqemu: don't set/clear NetDef IP addresses in qemuConnectDomainXMLToNative()
Laine Stump [Tue, 7 Jun 2016 23:59:10 +0000 (19:59 -0400)]
qemu: don't set/clear NetDef IP addresses in qemuConnectDomainXMLToNative()

This patch removes the expanded and duplicated code that all sprung
out of two well-intentioned-but-useless settings of
net->data.(bridge|ethernet).ipaddr.

qemu has never supported even a single IP address in the interface
config, much less a list of them. All of the instances of "clearing
out the IP addresses" that are now in this function originated with
commit d8dbd6 "Basic domain XML conversions for Xen/QEMU drivers" in
May 2009, but even then the single "ipaddr" in the struct for
type='ethernet' and type='bridge' wasn't used in the qemu driver (only
in xen and openvz). Since then anyone who added a new interface type
also tacked on another unnecessary clearing of ipaddr, and when it was
made into a list of IPs (so far supported only by the LXC driver) this
simple setting was turned into a loop (well, multiple loops) to clear
them all.

8 years agoconf: new function virDomainNetDefClear
Laine Stump [Tue, 21 Jun 2016 18:22:15 +0000 (14:22 -0400)]
conf: new function virDomainNetDefClear

We need to clear these out without freeing the object completely.

8 years agolxc: use correct prefix when setting veth IP address
Laine Stump [Tue, 26 Apr 2016 18:27:08 +0000 (14:27 -0400)]
lxc: use correct prefix when setting veth IP address

Commit c9a641 (first appearred in 1.2.12) added support for setting
the guest-side IP address of veth devices in lxc domains.
Unfortunately, it hardcoded the assumption that the proper prefix for
any IP address with no explicit prefix in the config should be "24";
that is only correct for class C IPv4 addresses, but not for any other
IPv4 address, nor for any IPv6 address.

The good news is that there is already a function in libvirt that will
determine the proper default prefix for any IP address. This patch
replaces the use of the ill-fated VIR_SOCKET_ADDR_DEFAULT_PREFIX with
calls to virSocketAddrGetIPPrefix().

8 years agolxc: eliminate extraneous free of netDef->ifname_guest
Laine Stump [Wed, 15 Jun 2016 19:17:53 +0000 (15:17 -0400)]
lxc: eliminate extraneous free of netDef->ifname_guest

lxcContainerRenameAndEnableInterfaces() isn't making a copy of the
interface's ifname_guest (into newname), it's just copying the pointer
to it. This means that when it later calls VIR_FREE(newname), it's
actually freeing up (and fortunately NULLing out, so at least we don't
try to access free'd memory) netDef->ifname_guest.

8 years agoutil: allow calling virSocketAddrGetIPPrefix with NULL netmask or address
Laine Stump [Tue, 26 Apr 2016 18:55:12 +0000 (14:55 -0400)]
util: allow calling virSocketAddrGetIPPrefix with NULL netmask or address

There are times when we don't have a netmask pointer to give to
virSocketAddrGetIPPrefix() (e.g. the IP addresses in domain interfaces
only have a prefix, no netmask), but it would have caused a segv if we
called it with NULL instead of a pointer to a netmask. This patch
qualifies the code that would use the netmask or address pointers to
check for NULL first.

8 years agotests: mock virNetDevSetIPAddress
Laine Stump [Tue, 26 Apr 2016 16:49:48 +0000 (12:49 -0400)]
tests: mock virNetDevSetIPAddress

Now that we can include <interface type='ethernet'> in tests, we could
almost test XML that has an <ip> element in an interface. Except that
the test fails when it tries to actually set the IP address for the
interface's tap device. This patch mocks virNetDevSetIPAddress() to
just return success.

8 years agoconf: clean up virDomainNetIPParseXML()
Laine Stump [Tue, 26 Apr 2016 16:18:53 +0000 (12:18 -0400)]
conf: clean up virDomainNetIPParseXML()

Rearrange this function to be better organized and more correct:

* the error codes were changed from the incorrect INVALID_ARG to
  XML_ERROR

* prefix still isn't required, but if present it must be valid or an
  error will be logged.

* don't emit a debug log just because prefix is missing - this
  is valid.

* group everything related to setting prefix in one place rather than
  scattered through the function.

8 years agoglobal: consistently use IP rather than Ip in identifiers
Laine Stump [Wed, 8 Jun 2016 16:48:50 +0000 (12:48 -0400)]
global: consistently use IP rather than Ip in identifiers

I'm tired of mistyping this all the time, so let's do it the same all
the time (similar to how we changed all "Pci" to "PCI" awhile back).

(NB: I've left alone some things in the esx and vbox drivers because
I'm unable to compile them and they weren't obviously *not* a part of
some API. I also didn't change a couple of variables named,
e.g. "somethingIptables", because they were derived from the name of
the "iptables" command)

8 years agoutil: move virInterface(State|Link)/virNetDevFeature from conf to util
Laine Stump [Mon, 13 Jun 2016 17:06:15 +0000 (13:06 -0400)]
util: move virInterface(State|Link)/virNetDevFeature from conf to util

These had been declared in conf/device_conf.h, but then used in
util/virnetdev.c, meaning that we had to #include conf/device_conf.h
in virnetdev.c (which we have for a long time said shouldn't be done.

This caused a bigger problem when I tried to #include util/virnetdev.h
in a file in src/conf (which is allowed) - for some reason the
"device_conf.h: File not found" error.

The solution is to move the data types and functions used in util
sources from conf to util. Some names were adjusted during the move
("virInterface" --> "virNetDevIf", and "VIR_INTERFACE" -->
"VIR_NETDEV_IF")

8 years agoutil: move virNetDevLinkDump to virnetlink.c
Laine Stump [Mon, 13 Jun 2016 11:59:12 +0000 (07:59 -0400)]
util: move virNetDevLinkDump to virnetlink.c

virNetDevLinkDump should have been in virnetlink.c, but that file
didn't exist yet when the function was created. It didn't really
matter until now - I found that having virnetlink.h included by
virnetdev.h caused build problems when trying to #include virnetdev.h
in a .c file in src/conf (due to missing directory in -I). Rather than
fix that to further institutionalize the incorrect placement of this
one function, this patch moves the function.

8 years agospec: distribute admin API within libvirt-client package
Erik Skultety [Fri, 24 Jun 2016 17:50:10 +0000 (19:50 +0200)]
spec: distribute admin API within libvirt-client package

With respect to to the following thread
https://www.redhat.com/archives/libvir-list/2016-June/msg01822.html, until we
introduce a new rpm package '-libs' that would allow us to drop daemon's
dependency on the client package, distribute admin API related stuff within
the client package (since it's the best analogy to the virsh client).

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agoexamples: admin: Add some examples for the new admin APIs
Erik Skultety [Sun, 15 May 2016 14:04:51 +0000 (16:04 +0200)]
examples: admin: Add some examples for the new admin APIs

Some of the examples make use of asprintf and strtol functions (to keep
things simple) which are prohibited to use within our code (enforced by
syntax-check). Therefore besides adding some examples, this patch also updates
cfg.mk to exclude examples directory from asprintf and strtol rules, as well as
updates .gitignore to exclude all the new admin binaries created in the
'examples' dir.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agoadmin: enable both admin API functionality and tarball distribution
Erik Skultety [Fri, 24 Jun 2016 17:27:09 +0000 (19:27 +0200)]
admin: enable both admin API functionality and tarball distribution

This patch enables admin socket creation in daemon's code, bumps the library
version in libvirt_admin_public.syms, and performs all necessary modifications
to our makefiles so that admin API can finally be included in the tarball,
and eventually become part of an rpm package (a patch later in this series).

Signed-off-by: Erik Skultety <eskultet@redhat.com>
8 years agovz: always pass graphics address to sdk
Nikolay Shirokovskiy [Wed, 20 Apr 2016 14:05:45 +0000 (17:05 +0300)]
vz: always pass graphics address to sdk

We need this because apply graphics functions is used on
update too. Also in case of NULL address resolve it to default
instead of error.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: support vnc password
Nikolay Shirokovskiy [Wed, 20 Apr 2016 14:05:44 +0000 (17:05 +0300)]
vz: support vnc password

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: remove exlicitly setting zeros in dumping graphics
Nikolay Shirokovskiy [Wed, 20 Apr 2016 14:05:43 +0000 (17:05 +0300)]
vz: remove exlicitly setting zeros in dumping graphics

Allocation will do this job. Also we don't use the explicit setting
in other places.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: support attach/detach/update/ of graphics device
Nikolay Shirokovskiy [Wed, 20 Apr 2016 14:05:42 +0000 (17:05 +0300)]
vz: support attach/detach/update/ of graphics device

Move graphic device config to post parse. This way we
detect error on early stage and leverage checking on detach too.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: move getting container video devices out from vnc code
Nikolay Shirokovskiy [Wed, 20 Apr 2016 14:05:41 +0000 (17:05 +0300)]
vz: move getting container video devices out from vnc code

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: trustGuestRxFilters fixes
Nikolay Shirokovskiy [Wed, 20 Apr 2016 14:05:40 +0000 (17:05 +0300)]
vz: trustGuestRxFilters fixes

First we need to always set value to vz sdk parameter so
we can leverage setting code for device updates. This patch
resolves tristate default to off implicitly. This is easier
then extract default value from vz sdk itself. First current
default is off too, second this approach is already taken
for 'net->linkstate'.

Second dump this option in domain xml.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: fix minor type safey issues with net union usage
Nikolay Shirokovskiy [Wed, 20 Apr 2016 14:05:39 +0000 (17:05 +0300)]
vz: fix minor type safey issues with net union usage

Fix net->data usage accordingly to type field.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: fix updating to no gateways
Nikolay Shirokovskiy [Wed, 20 Apr 2016 14:05:38 +0000 (17:05 +0300)]
vz: fix updating to no gateways

Current code that pass gateways to vz sdk is not suitable for
updates. If update has no gateways while we had them before
we need to pass "" for vz sdk gateways to reset old value.

The code definitely deserves its own function.

Drop checks that skip setting gateways if network address
is not set. Such a configuration is possible in vz sdk.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: dump route info in domain xml
Nikolay Shirokovskiy [Wed, 20 Apr 2016 14:05:37 +0000 (17:05 +0300)]
vz: dump route info in domain xml

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: dump ip addresses to domain xml
Nikolay Shirokovskiy [Wed, 20 Apr 2016 14:05:36 +0000 (17:05 +0300)]
vz: dump ip addresses to domain xml

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: give nice report if network device not found
Nikolay Shirokovskiy [Wed, 20 Apr 2016 14:05:35 +0000 (17:05 +0300)]
vz: give nice report if network device not found

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: fix memory leaks in attach/detach functions
Nikolay Shirokovskiy [Wed, 20 Apr 2016 14:05:34 +0000 (17:05 +0300)]
vz: fix memory leaks in attach/detach functions

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: move disks checks to device post parse
Nikolay Shirokovskiy [Wed, 20 Apr 2016 14:05:33 +0000 (17:05 +0300)]
vz: move disks checks to device post parse

And reformat so that we don't have lengthy lines. Also simplify
some checks.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: leverage disks parameters check on disks updates too
Nikolay Shirokovskiy [Wed, 20 Apr 2016 14:05:32 +0000 (17:05 +0300)]
vz: leverage disks parameters check on disks updates too

This is as easy as moving disks checks from domain post
parse callback to device post parse callback.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agovz: add device updates
Nikolay Shirokovskiy [Wed, 20 Apr 2016 14:05:31 +0000 (17:05 +0300)]
vz: add device updates

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
8 years agovz: reuse edit config frame in for attach/detach functions
Nikolay Shirokovskiy [Wed, 20 Apr 2016 14:05:30 +0000 (17:05 +0300)]
vz: reuse edit config frame in for attach/detach functions

Attach/detach functions for disk/net are quite trivial and
typically call a few functions in begin/end edit frame. Having
in mind update function too adding configuring for another
device (like graphics) will introduce 3 trivial functions more.
Let's replace current approach by attach/detach functions for
device.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
8 years agovz: make prlsdkGetDisk more generic
Nikolay Shirokovskiy [Wed, 20 Apr 2016 14:05:29 +0000 (17:05 +0300)]
vz: make prlsdkGetDisk more generic

Current implementation works with hard disks only. This patch
adds support for any disk device (cdroms and hdds right now).

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
8 years agovz: remove disk cache mode hunk
Nikolay Shirokovskiy [Wed, 20 Apr 2016 14:05:28 +0000 (17:05 +0300)]
vz: remove disk cache mode hunk

This code was added as a part of huge patch that moves driver
from working with prlctl to vz sdk so there is no good explanation
why this is done this way. The problem that it is not correct.
vz sdk cache mode parameter affects all domain disks while this hunk
resets its on every disk to a new value.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
8 years agocpu_map.xml: add cmt/mbm feature to x86
Qiaowei Ren [Fri, 24 Jun 2016 00:44:50 +0000 (08:44 +0800)]
cpu_map.xml: add cmt/mbm feature to x86

Some Intel processor families (e.g. the Intel Xeon processor E5 v3
family) introduced some PQos (Platform Qos) features, including CMT
(Cache Monitoring technology) and MBM (Memory Bandwidth Monitoring),
to monitor or control shared resource. This patch add them into x86
part of cpu_map.xml to be used for applications based on libvirt to
get cpu capabilities. For example, Nova in OpenStack schedules guests
based on the CPU features that the host has.

Signed-off-by: Qiaowei Ren <qiaowei.ren@intel.com>
8 years agocpu: Consolidate ARM drivers
Jiri Denemark [Fri, 24 Jun 2016 16:21:50 +0000 (18:21 +0200)]
cpu: Consolidate ARM drivers

Both ARM and AArch64 drivers are exactly the same (modulo function
names). Let's use just one driver for all ARM architectures.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
8 years agoutil: fix build in virNetDevTapGetRealDeviceName
Roman Bogorodskiy [Fri, 24 Jun 2016 18:41:43 +0000 (21:41 +0300)]
util: fix build in virNetDevTapGetRealDeviceName

Commit e81de04c switched virNetDevTapGetRealDeviceName() to use
virDirOpen() instead of opendir(), however it mistakenly dropped
DIR *dirp declaration, so restore that to fix build.

8 years agostorage: Introduce virStoragePoolObjBuildTempFilePath
John Ferlan [Tue, 21 Jun 2016 22:17:51 +0000 (18:17 -0400)]
storage: Introduce virStoragePoolObjBuildTempFilePath

Create a function to return a temporary file path to be used in a mkostemp
type call using the path to the stateDir + pool->def->name + vol->name

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoPromote storage pool refresh lifecycle event to top level event
Daniel P. Berrange [Fri, 24 Jun 2016 16:35:51 +0000 (17:35 +0100)]
Promote storage pool refresh lifecycle event to top level event

The VIR_STORAGE_POOL_EVENT_REFRESHED constant does not
reflect any change in the lifecycle of the storage pool.

It should thus not be part of the storage pool lifecycle
event set, but rather be a top level event in its own
right. Thus we introduce VIR_STORAGE_POOL_EVENT_ID_REFRESH
to replace it.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
8 years agoutil: Add 'luks' to the FileTypeInfo
John Ferlan [Tue, 21 Jun 2016 16:59:54 +0000 (12:59 -0400)]
util: Add 'luks' to the FileTypeInfo

Add the ability to detect a luks encrypted device.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoutil: Modify the FileTypeInfo to add a version size
John Ferlan [Tue, 21 Jun 2016 17:47:21 +0000 (13:47 -0400)]
util: Modify the FileTypeInfo to add a version size

The version field historically has been a 4 byte data; however, an upcoming
new type will use a 2 byte version.  So let's adjust for that now.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoutil: Introduce virReadBufInt16LE and virReadBufInt16BE
John Ferlan [Tue, 21 Jun 2016 16:57:30 +0000 (12:57 -0400)]
util: Introduce virReadBufInt16LE and virReadBufInt16BE

In order to read 16 bits of data in the native format and convert add
the 16 bit macros to match existing 32 and 64 bit code.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoqemu: Remove authdef from secret setup
John Ferlan [Thu, 2 Jun 2016 18:27:08 +0000 (14:27 -0400)]
qemu: Remove authdef from secret setup

Rather than pass authdef, pass the 'authdef->username' and the
'&authdef->secdef'

Note that a username may be NULL.

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoqemu: Change protocol parameter for secret setup
John Ferlan [Thu, 2 Jun 2016 18:15:54 +0000 (14:15 -0400)]
qemu: Change protocol parameter for secret setup

Rather than assume/pass the protocol to the qemuDomainSecretPlainSetup
and qemuDomainSecretAESSetup, set and pass the secretUsageType based
on the src->protocol type. This will eventually be used by the
virSecretGetSecretString call

Signed-off-by: John Ferlan <jferlan@redhat.com>
8 years agoDocument to not rely on virConnectGetMaxVcpus API
Shivaprasad G Bhat [Fri, 24 Jun 2016 15:04:34 +0000 (20:34 +0530)]
Document to not rely on virConnectGetMaxVcpus API

The API virConnectGetMaxVcpus doesn't really reflect the actual usable number
of cpus as the maximum limits can be different for kvm and/or qemu. So update
the documentation to use virConnectGetDomainCapabilities() instead.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
8 years agoqemu: check the kvm host cpu max limits in virConnectGetDomainCapabilities
Shivaprasad G Bhat [Fri, 24 Jun 2016 15:04:13 +0000 (20:34 +0530)]
qemu: check the kvm host cpu max limits in virConnectGetDomainCapabilities

The qemu limit and host limit both should be considered for
the domain vcpu max limits.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
8 years agoqemu: Make qemuBuildSecretInfoProps global
John Ferlan [Wed, 22 Jun 2016 10:11:59 +0000 (06:11 -0400)]
qemu: Make qemuBuildSecretInfoProps global

Need to create the object for a hotplug disk

8 years agoqemu: Remove type from qemuBuildSecretInfoProps
John Ferlan [Wed, 22 Jun 2016 10:10:59 +0000 (06:10 -0400)]
qemu: Remove type from qemuBuildSecretInfoProps

It's just a constant "secret" string anyway

8 years agoRename kvmGetMaxVCPUs() to virHostCPUGetKVMMaxVCPUs()
Shivaprasad G Bhat [Fri, 24 Jun 2016 15:03:13 +0000 (20:33 +0530)]
Rename kvmGetMaxVCPUs() to virHostCPUGetKVMMaxVCPUs()

This kvmGetMaxVCPUs() needs to be used at two different places
so move it to utils with appropriate name and mark it as private
global now.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
8 years agoadd help document relevant to default mapping of credentials to machines
yuelongguang [Thu, 16 Jun 2016 11:20:24 +0000 (19:20 +0800)]
add help document relevant to default mapping of credentials to machines

* src/util/virauthconfig.c

8 years agoconf: Allow disks with identical WWN or serial
Peter Krempa [Fri, 24 Jun 2016 15:01:27 +0000 (17:01 +0200)]
conf: Allow disks with identical WWN or serial

Disallowing them broke a use case of testing multipath configurations
for storage. Originally this was added as it was impossible to
use certain /dev/disk-by... links but the disks worked properly.

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

8 years agobuild: increase xz compression level
Ján Tomko [Mon, 20 Jun 2016 15:46:05 +0000 (17:46 +0200)]
build: increase xz compression level

Increase the default compression level to 9 from 6.

This also increases decompression memory requirements
from 9 MB to 65 MB.

Also turn on verbosity.

8 years agoopenvz: do not open-code STRSKIP
Ján Tomko [Fri, 24 Jun 2016 12:35:08 +0000 (14:35 +0200)]
openvz: do not open-code STRSKIP

Remove one more use of STREQLEN with strlen as its argument.

8 years agoFix error detection in virStorageBackendISCSIGetHostNumber
Ján Tomko [Tue, 21 Jun 2016 13:13:41 +0000 (15:13 +0200)]
Fix error detection in virStorageBackendISCSIGetHostNumber

In the unlikely case the iSCSI session path exists, but does not
contain an entry starting with "target", we would silently use
an initialized value.

Rewrite the function to correctly report errors.

8 years agoReplace some uses STREQLEN with STRPREFIX
Ján Tomko [Fri, 24 Jun 2016 08:37:04 +0000 (10:37 +0200)]
Replace some uses STREQLEN with STRPREFIX

Do not call it with a magic constant matching the length
of the pattern.

8 years agodocs: Fix whitespace in output
John Ferlan [Fri, 24 Jun 2016 14:16:18 +0000 (10:16 -0400)]
docs: Fix whitespace in output

Many moons ago, commit id '8d7800a55' adjusted the format of the output
to add a space on the HEADER and the DATA... the docs weren't updated to
reflect that... This makes that adjustment.

8 years agoqemu: Check for VFIO too where legacy passthrough is checked
Shivaprasad G Bhat [Wed, 15 Jun 2016 09:57:14 +0000 (09:57 +0000)]
qemu: Check for VFIO too where legacy passthrough is checked

On PPC the legacy passthrough is not supported and only
VFIO is supported. So, the checks at places to confirm if the
host is passthrough capable checks only legacy, fix it. This
is seen at only one place now.

Signed-off-by: Shivaprasad G Bhat <sbhat@linux.vnet.ibm.com>
8 years agovirStorageBackendISCSIGetHostNumber: correctly use virDirOpen
Ján Tomko [Fri, 24 Jun 2016 12:51:35 +0000 (14:51 +0200)]
virStorageBackendISCSIGetHostNumber: correctly use virDirOpen

Incorrect conflict resolution in my commit e81de04c1 broke this.

8 years agoProhibit opendir in syntax-check
Ján Tomko [Tue, 21 Jun 2016 14:53:42 +0000 (16:53 +0200)]
Prohibit opendir in syntax-check

Prefer virDirOpen.

8 years agoUse virDirOpenQuiet
Ján Tomko [Tue, 21 Jun 2016 14:52:37 +0000 (16:52 +0200)]
Use virDirOpenQuiet

Remove all the remaining usage of opendir.

8 years agoIntroduce virDirOpenQuiet
Ján Tomko [Tue, 21 Jun 2016 14:52:11 +0000 (16:52 +0200)]
Introduce virDirOpenQuiet

A helper function that does not report any errors.

8 years agoUse virDirOpenIfExists
Ján Tomko [Tue, 21 Jun 2016 14:47:24 +0000 (16:47 +0200)]
Use virDirOpenIfExists

Use it instead of opendir everywhere we need to check for ENOENT.

8 years agoAdd virDirOpenIfExists
Ján Tomko [Tue, 21 Jun 2016 14:43:16 +0000 (16:43 +0200)]
Add virDirOpenIfExists

Just like virDirOpen, but it returns 0 without reporting an error
on ENOENT.

8 years agoUse virDirOpen
Ján Tomko [Tue, 21 Jun 2016 14:34:08 +0000 (16:34 +0200)]
Use virDirOpen

Switch from opendir to virDirOpen everywhere we need to report an error.

8 years agoIntroduce virDirOpen
Ján Tomko [Tue, 21 Jun 2016 14:33:36 +0000 (16:33 +0200)]
Introduce virDirOpen

A helper that calls opendir and reports an error if it fails.

8 years agostorage: Fix coverity warning
Cole Robinson [Thu, 23 Jun 2016 22:40:00 +0000 (18:40 -0400)]
storage: Fix coverity warning

After commit e808d3f227 cbdata is always available here, so the
check is pointless

8 years agoDon't allow raneming domains to empty strings
Martin Kletzander [Wed, 22 Jun 2016 15:27:46 +0000 (17:27 +0200)]
Don't allow raneming domains to empty strings

It may cause unwanted behaviour (of course, is there any wanted one for
that case?) so we should rather disable the possibility of doing so.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
8 years agoopenvz: split single-line if
Ján Tomko [Fri, 24 Jun 2016 08:36:12 +0000 (10:36 +0200)]
openvz: split single-line if

Put the 'continue' statement on a separate line.

8 years agoqemu: Use stricter checks in virQEMUCapsFillDomainDeviceDiskCaps()
Andrea Bolognani [Thu, 23 Jun 2016 08:24:43 +0000 (10:24 +0200)]
qemu: Use stricter checks in virQEMUCapsFillDomainDeviceDiskCaps()

Unfortunately, we can't just call qemuDomainMachineIsPSeries()
here, because we don't have a virDomainDef instance; that said,
the open-coded check should match said function as closely as
possible.

8 years agoqemu: Introduce qemuDomainMachineIsPSeries()
Andrea Bolognani [Thu, 23 Jun 2016 08:19:05 +0000 (10:19 +0200)]
qemu: Introduce qemuDomainMachineIsPSeries()

This new function checks for both the architecture and the
machine type, so we can use it instead of writing the same
checks over and over again.

8 years agoqemu: Add architecture checks to qemuDomainMachineIsVirt()
Andrea Bolognani [Wed, 22 Jun 2016 16:55:37 +0000 (18:55 +0200)]
qemu: Add architecture checks to qemuDomainMachineIsVirt()

Remove all external architecture checks that have been
made redundant by this change.

8 years agoqemu: Remove redundant arguments to qemuBuildSerialChrDeviceStr()
Andrea Bolognani [Thu, 23 Jun 2016 08:07:44 +0000 (10:07 +0200)]
qemu: Remove redundant arguments to qemuBuildSerialChrDeviceStr()

Since we're already passing the full virDomainDef, it doesn't
make sense to also pass def->os.arch and def->os.machine as
separate arguments.

8 years agoAdd support for VirtualBox 5
Martin Pietsch [Sun, 19 Jun 2016 11:54:23 +0000 (13:54 +0200)]
Add support for VirtualBox 5

8 years agoRename virNetClient*AddrString
Ján Tomko [Thu, 23 Jun 2016 20:31:20 +0000 (22:31 +0200)]
Rename virNetClient*AddrString

Add SASL at the end to make the format obvious.

8 years agoRename virNetServerClient*AddrString
Ján Tomko [Mon, 20 Jun 2016 14:04:49 +0000 (16:04 +0200)]
Rename virNetServerClient*AddrString

Add SASL at the end to make the format obvious.

8 years agoAdd SASL to virNetSocket{Local,Remote}AddrString
Ján Tomko [Mon, 20 Jun 2016 14:01:50 +0000 (16:01 +0200)]
Add SASL to virNetSocket{Local,Remote}AddrString

Rename them to virNetSocket{Local,Remote}AddrStringSASL
to make their format more obvious.

8 years agovirNetSocket: rename AddrStr to AddrStrSASL
Ján Tomko [Mon, 20 Jun 2016 13:55:55 +0000 (15:55 +0200)]
virNetSocket: rename AddrStr to AddrStrSASL

Make it more obvious that these are in the SASL format.

8 years agovirnetsockettest: fix error messages
Ján Tomko [Mon, 20 Jun 2016 13:52:55 +0000 (15:52 +0200)]
virnetsockettest: fix error messages

8 years agoIntroduce virNetServerClientRemoteAddrStringURI
Ján Tomko [Mon, 20 Jun 2016 13:51:18 +0000 (15:51 +0200)]
Introduce virNetServerClientRemoteAddrStringURI

Use it in virNetServerClientGetInfo to switch back to using
the URI-format (separated by ':') instead of the SASL format
(separated by ';').

Also use it in the error message reported by virNetServerAddClient.

8 years agoIntroduce virNetSocketRemoteAddrStringURI
Ján Tomko [Mon, 20 Jun 2016 13:48:47 +0000 (15:48 +0200)]
Introduce virNetSocketRemoteAddrStringURI

It will return the socket address and port in a URI-like
format: [::1]:1234
Add a test case to virnetsockettest.

8 years agoRevert "virnetsocket: Provide socket address format in a more standard form"
Ján Tomko [Mon, 20 Jun 2016 13:22:44 +0000 (15:22 +0200)]
Revert "virnetsocket: Provide socket address format in a more standard form"

This partially reverts commit 9b45c9f049a7e9b6c1abfa6988b63b760714e169.

It changed the default format of socket address from the one SASL
requires, but did not adjust all the callers.

It also removed the test coverage for it.

Revert most of the changes except the virSocketAddrFormatFull support
for URI-formatted strings.

This fixes https://bugzilla.redhat.com/show_bug.cgi?id=1345743 while
reverting the format used by virt-admin's client-info command from
the URI one to the SASL one.

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

8 years agoDo not skip files starting with a dot in leases directory
Ján Tomko [Tue, 21 Jun 2016 15:43:11 +0000 (17:43 +0200)]
Do not skip files starting with a dot in leases directory

'.' and '..' are skipped by virDirRead already.

8 years agoAllow configs to start with a dot
Ján Tomko [Tue, 21 Jun 2016 15:40:37 +0000 (17:40 +0200)]
Allow configs to start with a dot

This fixes the disappearance of domains and networks starting with a
dot.

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

8 years agoDo not skip hidden entries when looking for a stable path
Ján Tomko [Tue, 21 Jun 2016 15:36:33 +0000 (17:36 +0200)]
Do not skip hidden entries when looking for a stable path

The device names are unlikely to start with a dot.
'.' and '..' are already skipped by virDirRead.

8 years agoDo not ignore hidden files in /sys and /proc
Ján Tomko [Tue, 21 Jun 2016 15:29:47 +0000 (17:29 +0200)]
Do not ignore hidden files in /sys and /proc

The directories we iterate over are unlikely to contain any entries
starting with a dot, other than '.' and '..' which is already skipped
by virDirRead.

8 years agoFix comment in virStorageBackendFileSystemRefresh
Ján Tomko [Tue, 21 Jun 2016 15:27:27 +0000 (17:27 +0200)]
Fix comment in virStorageBackendFileSystemRefresh

'.' and '..' are now skipped by virDirRead, there's no need to mention
them in the comment.

8 years agoDo not check for '.' and '..' after virDirRead
Ján Tomko [Tue, 21 Jun 2016 15:25:58 +0000 (17:25 +0200)]
Do not check for '.' and '..' after virDirRead

It skips those directory entries.

8 years agoSkip '.' and '..' in virDirRead
Ján Tomko [Tue, 21 Jun 2016 15:23:41 +0000 (17:23 +0200)]
Skip '.' and '..' in virDirRead

All of the callers either skip these explicitly, skip all entries
starting with a dot or match the entry name against stricter patterns.

8 years agoIntroduce VIR_DIR_CLOSE
Ján Tomko [Tue, 21 Jun 2016 10:40:29 +0000 (12:40 +0200)]
Introduce VIR_DIR_CLOSE

Introduce a helper that only calls closedir if DIR* is non-NULL
and sets it to NULL afterwards.

8 years agoDo not check the return value of closedir
Ján Tomko [Tue, 21 Jun 2016 11:20:48 +0000 (13:20 +0200)]
Do not check the return value of closedir

The only possible error is EBADFD.
Since we only use the directory stream returned by opendir,
this should never happen.

8 years agoDo not save errno in virUSBDeviceSearch
Ján Tomko [Tue, 21 Jun 2016 11:19:19 +0000 (13:19 +0200)]
Do not save errno in virUSBDeviceSearch

The virUSBDeviceFind* callers do not check errno after calling
this function.