Commit Graph

19338 Commits

Author SHA1 Message Date
Cole Robinson
01f2f6c6c9 tests: Add VIR_TEST_DEBUG and VIR_TEST_VERBOSE
To remove a bunch of TestGetDebug()/TestGetVerbose() checks
2015-04-23 17:08:48 -04:00
Eric Blake
1268820a63 build: avoid obsolete index()
Commit 2a530a3e5 is not portable to mingw, which intentionally
avoids declaring the obsolete index().  See also:
https://bugzilla.redhat.com/show_bug.cgi?id=1214605

* src/util/virstring.c (virStringStripControlChars): Use strchr.

Signed-off-by: Eric Blake <eblake@redhat.com>
2015-04-23 08:15:55 -06:00
Maxim Nestratov
236d5bc34d parallels: fix IS_CT macro
CT stands for containers, i.e. def->os.type should be compared with VIR_DOMAIN_OSTYPE_EXE
rather than VIR_DOMAIN_OSTYPE_HVM

Signed-off-by: Maxim Nestratov <mnestratov@parallels.com>
2015-04-23 15:48:26 +03:00
Michal Privoznik
85cbe869f9 parallels_sdk: Utilize parallelsDomObjFromDomain()
Instead of each API copying the same lines of code, lets use the
generic function designed just for that purpose.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-04-23 14:21:42 +02:00
Michal Privoznik
d2256fb552 parallels_driver: Utilize parallelsDomObjFromDomain()
Instead of each API copying the same lines of code, lets use the
generic function designed just for that purpose. At the same time,
drop useless connection object locking in some functions.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-04-23 14:21:42 +02:00
Michal Privoznik
3236da8bb7 parallels: Introduce parallelsDomObjFromDomain()
This function is practically copied over from qemu driver. Its
only purpose in life is to lookup a domain object and print an
error if no object is found.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-04-23 14:21:42 +02:00
Michal Privoznik
859e6801db struct _parallelsConn: Mark @domains as immutable pointer
The pointer does not change throughout the while life of a
parallels connection. Mark it as such.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-04-23 14:21:42 +02:00
Daniel P. Berrange
615bdfda07 rng: fix port number range validation
The PortNumber data type is declared to derive from 'short'.
Unfortunately this is an signed type, so validates the range
[-32,768, 32,767] which excludes valid port numbers between
32767 and 65535.

We can't use 'unsignedShort', since we need -1 to be a valid
port number too.

This change is to use 'int' and set an explicit max boundary
instead of relying on the data types' built-in max.

One of the existing tests is changed to use a high port number
to validate the schema.

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

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2015-04-23 12:59:52 +01:00
zhang bo
eadf41fe31 qemu: Don't fail to reboot domains with unresponsive agent
just as what b8e25c35d7 did, we
fall back to the ACPI method when the guest agent is unresponsive
in qemuDomainReboot().

Signed-off-by: YueWenyuan <yuewenyuan@huawei.com>
Signed-off-by: Zhang Bo <oscar.zhangbo@huawei.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-04-23 10:34:32 +02:00
Roman Bogorodskiy
c42dbd8a18 bhyve: fix build in tests
Commit 835cf84 dropped expectedVirtTypes argument for
virDomainDefParse*() functions, however bhyve tests still try to pass
that to virDomainDefParseFile(), therefore build fails.

Fix build by fixing virDomainDefParseFile() usage.
2015-04-23 10:54:32 +04:00
Cole Robinson
f93e121129 spec: Point fedora --with-loader-nvram at nightly firmware repo
Fedora doesn't ship OVMF/AAVMF builds in its repos due to licensing
issues, so the recommended way to consume these bits is via Gerd's
nightly repo: https://www.kraxel.org/repos

Let's teach fedora builds about the loader/nvram pairs these packages
installed, so users don't need to edit qemu.conf to get virt-manager
UEFI support.
2015-04-22 18:29:39 -04:00
Cole Robinson
ce452877cb configure: Report --with-loader-nvram value in summary 2015-04-22 17:47:19 -04:00
Jim Fehlig
ee3eddb332 locking: relax PID requirement
Some hypervisors like Xen do not have PIDs associated with domains.
Relax the requirement for PID != 0 in the locking code so it can
be used by hypervisors that do not represent domains as a process
running on the host.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-04-22 14:16:44 -06:00
Cole Robinson
fa19aca168 spec: Fix libxl build with driver modules 2015-04-22 15:44:19 -04:00
Cole Robinson
714668b506 configure: Fix --loader-nvram typo 2015-04-22 14:19:43 -04:00
Maxim Nestratov
0898d818ee parallels: don't forget to unlock domain after successful virDomainObjListFindByUUID call
Also a typo is fixed (s/detached/attached/)

Signed-off-by: Maxim Nestratov mnestratov@parallels.com
2015-04-22 17:53:04 +02:00
Roman Bogorodskiy
e34cccf783 vircommand: fix polling in virCommandProcessIO
When running on FreeBSD, there's a bug in virCommandProcessIO
polling that is triggered by the commandtest.

A test that triggers EPIPE in commandtest (named "test20") hungs
forever on FreeBSD.

Apparently, this happens because FreeBSD sets POLLHUP flag on revents
when stdin in closed. And as the current implementation only checks for
POLLOUT and POLLERR, it ends up looping forever inside
virCommandProcessIO and not trying to do one more write() that would
trigger EPIPE.

To fix that check for the POLLHUP flag along with POLLOUT and POLLERR.
2015-04-22 17:56:53 +03:00
Peter Krempa
dff92b3f2f util: storage: Improve error message when requesting image above 'start'
When a user would specify a backing chain index that is above the start
point libvirt would report a rather unhelpful error:

invalid argument: could not find backing store 1 in chain for 'sub/link2'

This patch adds an explicit check that the index is below start point in
the backing store and reports the following error if not:

invalid argument: requested backing store index 1 is above 'sub/../qcow2' in chain for 'sub/link2'

Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1177062
2015-04-22 14:24:32 +02:00
Peter Krempa
9447f3c5fb util: storage: Add hint to error message that indexed access was used 2015-04-22 14:18:53 +02:00
Peter Krempa
62a61d583c util: storage: Fix possible crash when source path is NULL
Some storage protocols allow to have the @path field in struct
virStorageSource set to NULL. Add NULLSTR() wrappers to handle this
possibility until I finish the storage source error formatter.
2015-04-22 14:18:52 +02:00
Peter Krempa
64a9d2fa2f util: command: Deduplicate code in virCommandNewArgList
virCommandNewArgList can use virCommandNewVAList.
2015-04-22 14:05:50 +02:00
Peter Krempa
bd57977391 qemu: migration: Refactor hostdev validation in migration check
The hostdev check can error out right away.
2015-04-22 14:05:50 +02:00
Roman Bogorodskiy
584db1054c util: fix build on non-Linux
Build fails on non-Linux systems with this error:

  CC       util/libvirt_util_la-virnetdev.lo
util/virnetdev.c:364:1: error: unused function 'virNetDevReplaceMacAddress' [-Werror,-Wunused-function]
virNetDevReplaceMacAddress(const char *linkdev,
^
util/virnetdev.c:406:1: error: unused function 'virNetDevRestoreMacAddress' [-Werror,-Wunused-function]
virNetDevRestoreMacAddress(const char *linkdev,
^
2 errors generated.

The virNetDev{Restore,Replace}MacAddress() functions are only used
by VF-related routines that are available on Linux only. So move these
functions under the same #ifdef.
2015-04-22 13:05:06 +04:00
Michal Privoznik
74acc4cabf processNicRxFilterChangedEvent: Take appropriate actions for NET_TYPE_NETWORK too
Because packets going through the egress from a bridge (where our
bandwidth limiting takes place) have no information about which
interface they came from, the QoS rules that we create instead
use the source MAC address of the packets to make their decisions
about which QDisc the packet should be in.

One flaw in this is that when a guest changed the MAC address it
used, packets from the guest would no longer be put into the
correct QDisc, but would instead be put in an "unprivileged"
class, resulting in the bandwidth "floor" (minimum guaranteed)
being no longer honored.

Now that libvirt has infrastructure to capture and respond to
RX_FILTER_CHANGE events from qemu (sent whenever a guest
interface modifies its MAC address, among other things), we can
notice when a guest MAC address changes, and update the QoS rules
accordingly, so that bandwidth floor is honored even after a
guest MAC address change.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-04-22 09:50:24 +02:00
Michal Privoznik
e128b4a44d virDomainActualNetDefContentsFormat: Format class_id only for status XML
In one of my previous patches (b68a56bcfe) I made class_id to
format more frequently. Well, now it's formatting way too
frequent - even for regular active XML. Users don't need to see
it, so lets format it only for the status XML where it's really
needed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-04-22 09:50:24 +02:00
Luyao Huang
d174394105 qemu: Fix issues with maxMemory in qemuDomainSetMemoryFlags()
qemuDomainSetMemoryFlags() would allow to set the initial memory greater
than the <maxMemory> field. While the configuration would not work as
memory hotplug requires NUMA to be enabled and the
qemuDomainSetMemoryFlags() API does not work on NUMA guests this just
fixes a corner case.

The fix is still worth though as it allows to induce an invalid
configuration and make the VM vanish on libvirt restart.

Additionally this tweaks error message to be more accurate.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Peter Krempa <pkrempa@redhat.com>
2015-04-22 09:26:25 +02:00
Jim Fehlig
d0baac09e6 libxl: Introduce configuration file for libxl driver
Introduce libxl.conf configuration file, adding the 'autoballoon'
setting as the first knob for controlling the libxl driver.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
2015-04-21 14:23:40 -06:00
Laine Stump
38172ed894 qemu: set macvtap physdevs online when macvtap is set online
A further fix for:

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

Since there is no possibility that any type of macvtap will work if
the parent physdev it's attached to is offline, we should bring the
physdev online at the same time as the macvtap. When taking the
macvtap offline, it's also necessary to take the physdev offline for
macvtap passthrough mode (because the physdev has the same MAC address
as the macvtap device, so could potentially cause problems with
misdirected packets during migration, as outlined in commits 829770
and 879c13). We can't set the physdev offline for other macvtap modes
1) because there may be other macvtap devices attached to the same
physdev (and/or the host itself may be using the device) in the other
modes whereas passthrough mode is exclusive to one macvtap at a time,
and 2) there's no practical reason to do so anyway.
2015-04-21 12:34:29 -04:00
Laine Stump
cb3fe38c74 util: set MAC address for VF via netlink message to PF+VF# when possible
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1113474

When we set the MAC address of a network device as a part of setting
up macvtap "passthrough" mode (where the domain has an emulated netdev
connected to a host macvtap device that has exclusive use of the
physical device, and sets the device MAC address to match its own,
i.e. "<interface type='direct'> <source mode='passthrough' .../>"), we
use ioctl(SIOCSIFHWADDR) giving it the name of that device. This is
true even if it is an SRIOV Virtual Function (VF).

But, when we are setting the MAC address / vlan ID of a VF in
preparation for "hostdev network" passthrough (this is where we set
the MAC address and vlan id of the VF after detaching the host net
driver and before assigning the device to the domain with PCI
passthrough, i.e. "<interface type='hostdev'>", we do the setting via
a netlink RTM_SETLINK message for that VF's Physical Function (PF),
telling it the VF# we want to change. This sets an "administratively
changed MAC" flag for that VF in the PF's driver, and from that point
on (until the PF driver is reloaded, *not* merely the VF driver) that
VF's MAC address can't be changed using ioctl(SIOCSIFHWADDR) - the
only way to change it is via the PF with RTM_SETLINK.

This means that if a VF is used for hostdev passthrough, it will have
the admin flag set, and future attempts to use that VF for macvtap
passthrough will fail.

The solution to this problem is to check if the device being used for
macvtap passthrough is actually a VF; if so, we use the netlink
RTM_SETLINK message to the PF to set the VF's mac address instead of
ioctl(SIOCSIFHWADDR) directly to the VF; if not, behavior does not
change from previously.

There are three pieces to making this work:

1) virNetDevMacVLan(Create|Delete)WithVPortProfile() now call
   virNetDev(Replace|Restore)NetConfig() rather than
   virNetDev(Replace|Restore)MacAddress() (simply passing -1 for VF#
   and vlanid).

2) virNetDev(Replace|Restore)NetConfig() check to see if the device is
   a VF. If so, they find the PF's name and VF#, allowing them to call
   virNetDev(Replace|Restore)VfConfig().

3) To prevent mixups when detaching a macvtap passthrough device that
   had been attached while running an older version of libvirt,
   virNetDevRestoreVfConfig() is potentially given the preserved name
   of the VF, and if the proper statefile for a VF can't be found in
   the stateDir (${stateDir}/${pfname}_vf${vfid}),
   virNetDevRestoreMacAddress() is called instead (which will look in
   the file named ${stateDir}/${vfname}).

This problem has existed in every version of libvirt that has both
macvtap passthrough and interface type='hostdev'. Fortunately people
seem to use one or the other though, so it hasn't caused any real
world problem reports.
2015-04-21 12:33:20 -04:00
Cole Robinson
95546c43de qemu: Always refresh capabilities if no <guests> found
- Remove all qemu emulators
- Restart libvirtd
- Install qemu emulators
- Call 'virsh version' -> errors

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

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

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

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

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

https://bugzilla.redhat.com/show_bug.cgi?id=1000116
2015-04-21 11:14:20 -04:00
Roman Bogorodskiy
a7c1eb140f vircapstest: fix build without LXC, QEMU or XEN
When building without lxc support enabled, build fails with:

CLD     vircapstest
vircapstest.o: In function `test_virCapsDomainDataLookupLXC':
vircapstest.c:(.text+0x9ef): undefined reference to `testLXCCapsInit'

Fix that by hiding LXC tests under appropriate #ifdef. Same applies
for QEMU and XEN.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-04-21 16:53:02 +02:00
John Ferlan
9832205263 scsi: Adjust return values from processLU
https://bugzilla.redhat.com/show_bug.cgi?id=1171933

Adjust the processLU error returns to be a bit more logical. Currently,
the calling code cannot determine the difference between a non disk/lun
volume and a processed/found disk/lun. It can also not differentiate
between perhaps real/fatal error and one that won't necessarily stop
the code from finding other volumes.

After this patch virStorageBackendSCSIFindLUsInternal will stop processing
as soon as a "fatal" message occurs rather than continuting processing
for no apparent reason. It will also only set the *found value when
at least one of the processLU's was successful.

With the failed return, if the reason for the stop was that the pool
target path did not exist, was /dev, was /dev/, or did not start with
/dev, then iSCSI pool startup and refresh will fail.
2015-04-21 10:20:17 -04:00
John Ferlan
1e13eff435 scsi: Change return values for virStorageBackendSCSIFindLUs
Rather than passing/returning a pointer to a boolean to indicate that
perhaps we should try again - adjust the return of the call to return
the count of LU's found during processing, then let the caller decide
what to do with that value.
2015-04-21 10:20:17 -04:00
John Ferlan
adb182fa2f scsi: Adjust return value for virStorageBackendSCSINewLun
Use virStorageBackendPoolUseDevPath API to determine whether creation of
stable target path is possible for the volume.

This will differentiate a failed virStorageBackendStablePath which won't
need to be fatal. Thus, we'll add a -2 return value to differentiate that
the failure was a result of either the inability to find the symlink for
the device or failure to open the target path directory
2015-04-21 10:20:13 -04:00
John Ferlan
9e5e1ca144 storage: Fix check for stable path check
Fix the if (!STRPREFIX(path, "/dev")) to be if (!STRPREFIX(path, "/dev/"))
to ensure a path such as "/device" isn't declared stable.
2015-04-21 06:08:56 -04:00
John Ferlan
9126161d0b storage: Split out the stable path check
For virStorageBackendStablePath, in order to make decisions in other code
split out the checks regarding whether the pool's target is empty, using /dev,
using /dev/, or doesn't start with /dev
2015-04-21 06:08:05 -04:00
Richard W.M. Jones
093eea9589 xend: Remove a couple of unused function prototypes.
Commit 70f446631f (from 2008) introduced
some functions for testing whether xend was returning correct sound
models.  Those functions have long gone, but the function prototypes
remain.  This commit removes the unused prototypes.

Signed-off-by: Richard W.M. Jones <rjones@redhat.com>
2015-04-21 10:22:43 +01:00
Michal Privoznik
498d7b2bf5 domtop: Properly free cpu status
So, in the example the cpu stats are collected within a function
called do_top. At the beginning of the function we ask the daemon for
how much vCPUs can we get stats, and how many stats for a vCPU can we
get. This is because it's how our API works - users are required to
preallocate a chunk of memory for the results. Now, at the end, we try
to free the allocated array, but we are not doing it correctly.
There's this virTypedParamsFree() function which gets a pointer to the
array and the length of the array. However, if there was an error in
getting vCPU stats we pass a negative number instead of the originally
computed value. This flaw results in SIGSEGV:

libvirt: QEMU Driver error : Requested operation is not valid: domain is not running
ERROR do_top:333 : Unable to get cpu stats
==29201== Invalid read of size 4
==29201==    at 0x4F1DF8B: virTypedParamsClear (virtypedparam.c:1145)
==29201==    by 0x4F1DFEB: virTypedParamsFree (virtypedparam.c:1165)
==29201==    by 0x4023C3: do_top (domtop.c:349)
==29201==    by 0x40260B: main (domtop.c:386)
==29201==  Address 0x131cd7c0 is 16 bytes after a block of size 768 alloc'd
==29201==    at 0x4C2C070: calloc (in /usr/lib64/valgrind/vgpreload_memcheck-amd64-linux.so)
==29201==    by 0x401FF1: do_top (domtop.c:295)
==29201==    by 0x40260B: main (domtop.c:386)

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
2015-04-21 10:56:50 +02:00
Cole Robinson
835cf84b7e domain: conf: Drop expectedVirtTypes
This needs to specified in way too many places for a simple validation
check. The ostype/arch/virttype validation checks later in
DomainDefParseXML should catch most of the cases that this was covering.
2015-04-20 16:43:43 -04:00
Cole Robinson
747761a79a caps: Use DomainDataLookup to replace GuestDefault*
This revealed that GuestDefaultEmulator was a bit buggy, capable
of returning an emulator that didn't match the passed domain type. Fix
up the test suite input to continue to pass.
2015-04-20 16:43:13 -04:00
Cole Robinson
3f9868a57e domain: conf: Use CapabilitiesDomainDataLookup for caps validation
The strange logic here is just to duplicate the previous behavior,
which parts of the test suite are currently relying on.
2015-04-20 16:43:13 -04:00
Cole Robinson
4c96e682ec domain: conf: Do ostype/arch/machine parsing earlier
Just move this code to where we parse virtType. Lots of things depend
on os.type values so it should be handled early like virtType.
2015-04-20 16:43:13 -04:00
Cole Robinson
a693652341 caps: Add virCapabilitiesDomainDataLookup
This is a helper function to look up all capabilities data for all
the OS bits that are relevant to <domain>. This is

- os type
- arch
- domain type
- emulator
- machine type

This will be used to replace several functions in later commits.
2015-04-20 16:43:08 -04:00
Cole Robinson
4fa6f9b413 caps: Convert to use VIR_DOMAIN_VIRT internally 2015-04-20 16:40:26 -04:00
Cole Robinson
5f7c599456 domain: Convert os.type to VIR_DOMAIN_OSTYPE enum 2015-04-20 16:40:09 -04:00
Cole Robinson
d0440e3269 caps: Switch AddGuest to take VIR_DOMAIN_OSTYPE value
Rather than an opencoded string. This should be a no-op
2015-04-20 16:38:09 -04:00
Cole Robinson
4231485c1c caps: Use an enum internally for ostype value
But the internal API stays the same, and we just convert the value as
needed. Not useful yet, but this is the beginning step of using an enum
for ostype throughout the code.
2015-04-20 16:37:25 -04:00
Cole Robinson
f1a89a8b6d domain: conf: Don't validate VM ostype/arch at daemon startup
When parsing XML, we validate the passed ostype + arch combo against
the detected hypervisor capabilities. This has led to the following
problem:

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

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

https://bugzilla.redhat.com/show_bug.cgi?id=1043572
2015-04-20 16:36:35 -04:00
Cole Robinson
3700c065cd domain: conf: Better errors on bad os <type> values
If no <os><type> was specified:
  before: unknown OS type no OS type
  after : xml error: an os <type> must be specified

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

VIR_ERR_OS_TYPE is now unused (as it should be frankly) so drop its strings
as well to save our translators some effort.
2015-04-20 16:35:29 -04:00
Nikolay Shirokovskiy
6b7b677a0e parallels: make device addressing consistent
In Parallels we do not support device name hints
aka <target dev=../> option and full-fledged device
disk device addressing through
<address type=.. controller=.. bus=.. target=.. unit=../>
and have only one index instead.
In this situation to be consistent we can only take
one-to-one mapping from some reasonable subset
of full address. Values outside this subset are
invalid to create Parallels VMs.

Reasonable mapping is default one defined in virDomainDiskDefAssignAddress.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@parallels.com>
2015-04-20 20:02:54 +03:00