Commit Graph

23453 Commits

Author SHA1 Message Date
Laine Stump
9104509289 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.
2016-06-26 19:33:08 -04:00
Laine Stump
7cfbaad189 conf: new function virDomainNetDefClear
We need to clear these out without freeing the object completely.
2016-06-26 19:33:08 -04:00
Laine Stump
70a2c7e062 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().
2016-06-26 19:33:08 -04:00
Laine Stump
f03a4a2a96 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.
2016-06-26 19:33:08 -04:00
Laine Stump
9359167ec0 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.
2016-06-26 19:33:08 -04:00
Laine Stump
e1219b6f3c 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.
2016-06-26 19:33:08 -04:00
Laine Stump
bfd2de6eed 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.
2016-06-26 19:33:07 -04:00
Laine Stump
22a6873a98 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)
2016-06-26 19:33:07 -04:00
Laine Stump
638c6e5ba5 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")
2016-06-26 19:33:07 -04:00
Laine Stump
943a400c0d 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.
2016-06-26 19:33:07 -04:00
Erik Skultety
d0a9dbc323 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>
2016-06-26 00:21:07 +02:00
Erik Skultety
fbb8205de3 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>
2016-06-26 00:21:06 +02:00
Erik Skultety
52dbacc07a 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>
2016-06-26 00:21:06 +02:00
Nikolay Shirokovskiy
851a751575 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>
2016-06-25 22:56:04 +03:00
Nikolay Shirokovskiy
96ca48451a vz: support vnc password
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2016-06-25 22:56:04 +03:00
Nikolay Shirokovskiy
4698b4e65c 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>
2016-06-25 22:56:04 +03:00
Nikolay Shirokovskiy
e325c997a8 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>
2016-06-25 22:56:04 +03:00
Nikolay Shirokovskiy
e7878d4623 vz: move getting container video devices out from vnc code
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2016-06-25 22:56:03 +03:00
Nikolay Shirokovskiy
3a622f6b32 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>
2016-06-25 22:56:03 +03:00
Nikolay Shirokovskiy
3a82c04c09 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>
2016-06-25 22:56:03 +03:00
Nikolay Shirokovskiy
62b0066de4 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>
2016-06-25 22:56:03 +03:00
Nikolay Shirokovskiy
c34a9d6e56 vz: dump route info in domain xml
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2016-06-25 22:56:03 +03:00
Nikolay Shirokovskiy
b86396dc54 vz: dump ip addresses to domain xml
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2016-06-25 22:56:03 +03:00
Nikolay Shirokovskiy
2e4bed1b81 vz: give nice report if network device not found
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2016-06-25 22:56:02 +03:00
Nikolay Shirokovskiy
3cea593f35 vz: fix memory leaks in attach/detach functions
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
2016-06-25 22:56:02 +03:00
Nikolay Shirokovskiy
91ee31d19e 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>
2016-06-25 22:56:02 +03:00
Nikolay Shirokovskiy
511f6ab5ba 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>
2016-06-25 22:56:02 +03:00
Nikolay Shirokovskiy
307eb644ed vz: add device updates
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
2016-06-25 22:56:02 +03:00
Nikolay Shirokovskiy
0f38187b68 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>
2016-06-25 22:56:01 +03:00
Nikolay Shirokovskiy
f6e13453e7 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>
2016-06-25 22:56:01 +03:00
Nikolay Shirokovskiy
2e6ff2da75 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>
2016-06-25 22:56:01 +03:00
Qiaowei Ren
f294b83ee6 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>
2016-06-25 00:23:58 +02:00
Jiri Denemark
e2ddc811ab 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>
2016-06-25 00:02:30 +02:00
Roman Bogorodskiy
b5447e78b2 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.
2016-06-24 21:41:43 +03:00
John Ferlan
01f4a4a070 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>
2016-06-24 13:42:38 -04:00
Daniel P. Berrange
0330848207 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>
2016-06-24 18:26:11 +01:00
John Ferlan
318ebb36f1 util: Add 'luks' to the FileTypeInfo
Add the ability to detect a luks encrypted device.

Signed-off-by: John Ferlan <jferlan@redhat.com>
2016-06-24 13:23:02 -04:00
John Ferlan
ea0ef33d05 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>
2016-06-24 13:23:02 -04:00
John Ferlan
cc1c7af2b3 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>
2016-06-24 13:23:02 -04:00
John Ferlan
8be83eef60 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>
2016-06-24 13:23:02 -04:00
John Ferlan
23c5f1b0a1 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>
2016-06-24 13:23:02 -04:00
Shivaprasad G Bhat
e6806d7938 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>
2016-06-24 19:20:14 +02:00
Shivaprasad G Bhat
8dbb347816 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>
2016-06-24 19:14:43 +02:00
John Ferlan
c6910bd4c7 qemu: Make qemuBuildSecretInfoProps global
Need to create the object for a hotplug disk
2016-06-24 13:04:38 -04:00
John Ferlan
c8c3484b46 qemu: Remove type from qemuBuildSecretInfoProps
It's just a constant "secret" string anyway
2016-06-24 13:04:38 -04:00
Shivaprasad G Bhat
b95965c4f8 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>
2016-06-24 18:52:21 +02:00
yuelongguang
969b27d84c add help document relevant to default mapping of credentials to machines
* src/util/virauthconfig.c
2016-06-24 16:36:54 +01:00
Peter Krempa
5da28cc306 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
2016-06-24 17:29:00 +02:00
Ján Tomko
b7200d7236 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.
2016-06-24 16:41:57 +02:00
Ján Tomko
9beb299554 openvz: do not open-code STRSKIP
Remove one more use of STREQLEN with strlen as its argument.
2016-06-24 16:30:55 +02:00