]> xenbits.xensource.com Git - people/liuw/libxenctrl-split/libvirt.git/log
people/liuw/libxenctrl-split/libvirt.git
10 years agotests: qemu: Couple aarch64 CPU tests
Cole Robinson [Thu, 23 Apr 2015 17:47:06 +0000 (13:47 -0400)]
tests: qemu: Couple aarch64 CPU tests

- Make sure aarch64 host-passthrough works correctly
- Make sure libvirt doesn't choke on cpu model=host, which is what
  virt-install/virt-manager were incorrectly specifying up until recently.

10 years agomigration: Usable time statistics without requiring NTP
Jiri Denemark [Thu, 23 Apr 2015 07:19:12 +0000 (09:19 +0200)]
migration: Usable time statistics without requiring NTP

virDomainGetJobStats is able to report statistics of a completed
migration, however to get usable downtime and total time statistics both
hosts have to keep synchronized time. To provide at least some
estimation of the times even when NTP daemons are not running on both
hosts we can just ignore the time needed to transfer a migration cookie
to the destination host. The result will be also inaccurate but a bit
more predictable. The total/down time will just be at least what we
report.

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

10 years agoFix memory leak in virNetSocketNewConnectUNIX
Jiri Denemark [Fri, 24 Apr 2015 09:56:34 +0000 (11:56 +0200)]
Fix memory leak in virNetSocketNewConnectUNIX

==26726==    by 0x673CD67: __vasprintf_chk (vasprintf_chk.c:80)
==26726==    by 0x5673605: UnknownInlinedFun (stdio2.h:210)
==26726==    by 0x5673605: virVasprintfInternal (virstring.c:476)
==26726==    by 0x56736EE: virAsprintfInternal (virstring.c:497)
==26726==    by 0x5680C37: virGetUserRuntimeDirectory (virutil.c:866)
==26726==    by 0x5783A89: virNetSocketNewConnectUNIX (virnetsocket.c:572)
==26726==    by 0x57751AF: virNetClientNewUNIX (virnetclient.c:344)
==26726==    by 0x57689B3: doRemoteOpen (remote_driver.c:895)
==26726==    by 0x5769F8E: remoteConnectOpen (remote_driver.c:1195)
==26726==    by 0x57092DF: do_open (libvirt.c:1189)
==26726==    by 0x570A7BF: virConnectOpenAuth (libvirt.c:1341)

https://bugzilla.redhat.com/show_bug.cgi?id=1215042
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agobuild: add pragma directive to fix build on some gcc
Pavel Hrdina [Fri, 24 Apr 2015 10:57:10 +0000 (12:57 +0200)]
build: add pragma directive to fix build on some gcc

Commit 1268820a removed obsolete index() function and replaced it by
strchr.  Few versions of gcc has a bug and reports a warning about
strchr:

../../src/util/virstring.c:1006: error: logical '&&' with non-zero
constant will always evaluate as true [-Wlogical-op]

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agouml: s/virDomainObjListFindByID/virDomainObjListFindByUUID/
Michal Privoznik [Fri, 24 Apr 2015 07:34:10 +0000 (09:34 +0200)]
uml: s/virDomainObjListFindByID/virDomainObjListFindByUUID/

ListFindByID() still requires to step through items in the hash table
(in the worst case scenario through all of them), lock each one and
compare whether we've found what we're looking for. This is suboptimal
as locking a domain object means we need to wait for the current API
running over the object to finish.

Unfortunately, we can't drop the function completely because we have
this public API virDomainLookupByID which we can't drop.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirDomainObjList: Introduce yet another hash table
Michal Privoznik [Thu, 23 Apr 2015 13:31:53 +0000 (15:31 +0200)]
virDomainObjList: Introduce yet another hash table

This hash table will contain the same data as already existing one.
The only difference is that while the first table uses domain uuid as
key, the new table uses domain name. This will allow much faster (and
lockless) lookups by domain name.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirDomainObjListFindByName: Return referenced object
Michal Privoznik [Thu, 23 Apr 2015 16:00:01 +0000 (18:00 +0200)]
virDomainObjListFindByName: Return referenced object

Every domain that grabs a domain object to work over should
reference it to make sure it won't disappear meanwhile.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoIntroduce virDomainObjEndAPI
Michal Privoznik [Thu, 23 Apr 2015 15:27:58 +0000 (17:27 +0200)]
Introduce virDomainObjEndAPI

This is basically turning qemuDomObjEndAPI into a more general
function. Other drivers which gets a reference to domain objects may
benefit from this function too.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirDomainObjListNew: Use virObjectFreeHashData
Michal Privoznik [Thu, 23 Apr 2015 15:10:28 +0000 (17:10 +0200)]
virDomainObjListNew: Use virObjectFreeHashData

There's no point in duplicating virObjectFreeHashData() in a separate
function.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirDomainObjListAddLocked: s/false/NULL/ for @oldDef
Michal Privoznik [Thu, 23 Apr 2015 13:27:32 +0000 (15:27 +0200)]
virDomainObjListAddLocked: s/false/NULL/ for @oldDef

It's a pointer after all. We should initialize it to NULL instead of
false.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoparallels: implement .domainGetMaxMemory
Dmitry Guryanov [Thu, 23 Apr 2015 13:21:00 +0000 (16:21 +0300)]
parallels: implement .domainGetMaxMemory

Since we haven't implemented balloon parameters tuning
we can just return amount of memory in this function.

Signed-off-by: Dmitry Guryanov <dguryanov@parallels.com>
10 years agoApparmor: allow reading block-rbd.so
Cédric Bosdonnat [Thu, 23 Apr 2015 07:34:19 +0000 (09:34 +0200)]
Apparmor: allow reading block-rbd.so

10 years agoAllow access to vendor and device file for PCI device passthrough
Cédric Bosdonnat [Thu, 23 Apr 2015 07:32:16 +0000 (09:32 +0200)]
Allow access to vendor and device file for PCI device passthrough

For some devices, the $PCIDIR/vendor and $PCIDIR/device need to be
read. Iterate over them to get them as well in the the generated
apparmor profile.

10 years agoqemu: cgroup: Fix priorities when setting emulatorpin
Peter Krempa [Thu, 23 Apr 2015 14:16:03 +0000 (16:16 +0200)]
qemu: cgroup: Fix priorities when setting emulatorpin

Use the custom emulator pin setting with the highest priority same as
with vcpupin.

10 years agotests: Add VIR_TEST_REGENERATE_OUTPUT
Cole Robinson [Thu, 23 Apr 2015 18:02:57 +0000 (14:02 -0400)]
tests: Add VIR_TEST_REGENERATE_OUTPUT

If this enviroment variable is set, the virTestCompareToFile helper
will overwrite the file content we are comparing against, if the
file doesn't exist or it doesn't match the expected input.

This is useful when adding new test cases, or making changes that
generate a lot of output churn.

10 years agotests: Add virtTestCompareToFile
Cole Robinson [Thu, 23 Apr 2015 15:14:26 +0000 (11:14 -0400)]
tests: Add virtTestCompareToFile

Replaces a common pattern used in many test files

10 years agotests: Use *DefParseFile more
Cole Robinson [Thu, 23 Apr 2015 15:10:15 +0000 (11:10 -0400)]
tests: Use *DefParseFile more

10 years agotests: Add VIR_TEST_DEBUG and VIR_TEST_VERBOSE
Cole Robinson [Thu, 23 Apr 2015 17:38:00 +0000 (13:38 -0400)]
tests: Add VIR_TEST_DEBUG and VIR_TEST_VERBOSE

To remove a bunch of TestGetDebug()/TestGetVerbose() checks

10 years agobuild: avoid obsolete index()
Eric Blake [Thu, 23 Apr 2015 14:13:53 +0000 (08:13 -0600)]
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>
10 years agoparallels: fix IS_CT macro
Maxim Nestratov [Wed, 22 Apr 2015 19:49:00 +0000 (22:49 +0300)]
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>
10 years agoparallels_sdk: Utilize parallelsDomObjFromDomain()
Michal Privoznik [Wed, 22 Apr 2015 16:27:05 +0000 (18:27 +0200)]
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>
10 years agoparallels_driver: Utilize parallelsDomObjFromDomain()
Michal Privoznik [Wed, 22 Apr 2015 16:23:38 +0000 (18:23 +0200)]
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>
10 years agoparallels: Introduce parallelsDomObjFromDomain()
Michal Privoznik [Wed, 22 Apr 2015 16:10:50 +0000 (18:10 +0200)]
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>
10 years agostruct _parallelsConn: Mark @domains as immutable pointer
Michal Privoznik [Wed, 22 Apr 2015 16:07:06 +0000 (18:07 +0200)]
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>
10 years agorng: fix port number range validation
Daniel P. Berrange [Thu, 23 Apr 2015 10:49:23 +0000 (11:49 +0100)]
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>
10 years agoqemu: Don't fail to reboot domains with unresponsive agent
zhang bo [Thu, 23 Apr 2015 03:40:15 +0000 (11:40 +0800)]
qemu: Don't fail to reboot domains with unresponsive agent

just as what b8e25c35d7f80a2fadc0e51e95318e39db3d1687 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>
10 years agobhyve: fix build in tests
Roman Bogorodskiy [Thu, 23 Apr 2015 06:25:11 +0000 (10:25 +0400)]
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.

10 years agospec: Point fedora --with-loader-nvram at nightly firmware repo
Cole Robinson [Wed, 22 Apr 2015 20:01:32 +0000 (16:01 -0400)]
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.

10 years agoconfigure: Report --with-loader-nvram value in summary
Cole Robinson [Wed, 22 Apr 2015 18:28:56 +0000 (14:28 -0400)]
configure: Report --with-loader-nvram value in summary

10 years agolocking: relax PID requirement
Jim Fehlig [Thu, 16 Apr 2015 17:32:42 +0000 (11:32 -0600)]
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>
10 years agospec: Fix libxl build with driver modules
Cole Robinson [Wed, 22 Apr 2015 19:43:38 +0000 (15:43 -0400)]
spec: Fix libxl build with driver modules

10 years agoconfigure: Fix --loader-nvram typo
Cole Robinson [Wed, 22 Apr 2015 18:19:43 +0000 (14:19 -0400)]
configure: Fix --loader-nvram typo

10 years agoparallels: don't forget to unlock domain after successful virDomainObjListFindByUUID...
Maxim Nestratov [Wed, 22 Apr 2015 15:25:50 +0000 (18:25 +0300)]
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
10 years agovircommand: fix polling in virCommandProcessIO
Roman Bogorodskiy [Tue, 21 Apr 2015 17:11:32 +0000 (20:11 +0300)]
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.

10 years agoutil: storage: Improve error message when requesting image above 'start'
Peter Krempa [Tue, 21 Apr 2015 15:38:08 +0000 (17:38 +0200)]
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

10 years agoutil: storage: Add hint to error message that indexed access was used
Peter Krempa [Tue, 21 Apr 2015 15:48:17 +0000 (17:48 +0200)]
util: storage: Add hint to error message that indexed access was used

10 years agoutil: storage: Fix possible crash when source path is NULL
Peter Krempa [Tue, 21 Apr 2015 15:35:23 +0000 (17:35 +0200)]
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.

10 years agoutil: command: Deduplicate code in virCommandNewArgList
Peter Krempa [Wed, 22 Apr 2015 08:07:00 +0000 (10:07 +0200)]
util: command: Deduplicate code in virCommandNewArgList

virCommandNewArgList can use virCommandNewVAList.

10 years agoqemu: migration: Refactor hostdev validation in migration check
Peter Krempa [Wed, 22 Apr 2015 09:41:22 +0000 (11:41 +0200)]
qemu: migration: Refactor hostdev validation in migration check

The hostdev check can error out right away.

10 years agoutil: fix build on non-Linux
Roman Bogorodskiy [Wed, 22 Apr 2015 08:14:57 +0000 (12:14 +0400)]
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.

10 years agoprocessNicRxFilterChangedEvent: Take appropriate actions for NET_TYPE_NETWORK too
Michal Privoznik [Tue, 14 Apr 2015 09:47:53 +0000 (11:47 +0200)]
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>
10 years agovirDomainActualNetDefContentsFormat: Format class_id only for status XML
Michal Privoznik [Mon, 20 Apr 2015 08:48:19 +0000 (10:48 +0200)]
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>
10 years agoqemu: Fix issues with maxMemory in qemuDomainSetMemoryFlags()
Luyao Huang [Tue, 24 Mar 2015 14:12:37 +0000 (22:12 +0800)]
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>
10 years agolibxl: Introduce configuration file for libxl driver
Jim Fehlig [Mon, 9 Sep 2013 15:15:15 +0000 (09:15 -0600)]
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>
10 years agoqemu: set macvtap physdevs online when macvtap is set online
Laine Stump [Mon, 13 Apr 2015 17:26:54 +0000 (13:26 -0400)]
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.

10 years agoutil: set MAC address for VF via netlink message to PF+VF# when possible
Laine Stump [Fri, 10 Apr 2015 16:19:49 +0000 (12:19 -0400)]
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.

10 years agoqemu: Always refresh capabilities if no <guests> found
Cole Robinson [Thu, 16 Apr 2015 18:51:26 +0000 (14:51 -0400)]
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

10 years agovircapstest: fix build without LXC, QEMU or XEN
Roman Bogorodskiy [Tue, 21 Apr 2015 08:14:45 +0000 (12:14 +0400)]
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>
10 years agoscsi: Adjust return values from processLU
John Ferlan [Mon, 30 Mar 2015 22:55:16 +0000 (18:55 -0400)]
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.

10 years agoscsi: Change return values for virStorageBackendSCSIFindLUs
John Ferlan [Fri, 17 Apr 2015 01:22:35 +0000 (21:22 -0400)]
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.

10 years agoscsi: Adjust return value for virStorageBackendSCSINewLun
John Ferlan [Wed, 1 Apr 2015 13:13:05 +0000 (09:13 -0400)]
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

10 years agostorage: Fix check for stable path check
John Ferlan [Tue, 21 Apr 2015 10:07:50 +0000 (06:07 -0400)]
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.

10 years agostorage: Split out the stable path check
John Ferlan [Tue, 7 Apr 2015 14:53:37 +0000 (10:53 -0400)]
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

10 years agoxend: Remove a couple of unused function prototypes.
Richard W.M. Jones [Mon, 20 Apr 2015 16:15:12 +0000 (17:15 +0100)]
xend: Remove a couple of unused function prototypes.

Commit 70f446631f142ae92b4d4eb349fcf11408171556 (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>
10 years agodomtop: Properly free cpu status
Michal Privoznik [Sun, 19 Apr 2015 13:58:29 +0000 (15:58 +0200)]
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>
10 years agodomain: conf: Drop expectedVirtTypes
Cole Robinson [Sat, 18 Apr 2015 01:22:48 +0000 (21:22 -0400)]
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.

10 years agocaps: Use DomainDataLookup to replace GuestDefault*
Cole Robinson [Sat, 18 Apr 2015 00:15:25 +0000 (20:15 -0400)]
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.

10 years agodomain: conf: Use CapabilitiesDomainDataLookup for caps validation
Cole Robinson [Fri, 17 Apr 2015 23:38:04 +0000 (19:38 -0400)]
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.

10 years agodomain: conf: Do ostype/arch/machine parsing earlier
Cole Robinson [Fri, 17 Apr 2015 23:18:59 +0000 (19:18 -0400)]
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.

10 years agocaps: Add virCapabilitiesDomainDataLookup
Cole Robinson [Fri, 17 Apr 2015 16:38:55 +0000 (12:38 -0400)]
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.

10 years agocaps: Convert to use VIR_DOMAIN_VIRT internally
Cole Robinson [Fri, 17 Apr 2015 22:38:10 +0000 (18:38 -0400)]
caps: Convert to use VIR_DOMAIN_VIRT internally

10 years agodomain: Convert os.type to VIR_DOMAIN_OSTYPE enum
Cole Robinson [Fri, 17 Apr 2015 00:11:06 +0000 (20:11 -0400)]
domain: Convert os.type to VIR_DOMAIN_OSTYPE enum

10 years agocaps: Switch AddGuest to take VIR_DOMAIN_OSTYPE value
Cole Robinson [Fri, 17 Apr 2015 22:09:16 +0000 (18:09 -0400)]
caps: Switch AddGuest to take VIR_DOMAIN_OSTYPE value

Rather than an opencoded string. This should be a no-op

10 years agocaps: Use an enum internally for ostype value
Cole Robinson [Thu, 16 Apr 2015 23:18:32 +0000 (19:18 -0400)]
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.

10 years agodomain: conf: Don't validate VM ostype/arch at daemon startup
Cole Robinson [Fri, 17 Apr 2015 20:37:57 +0000 (16:37 -0400)]
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

10 years agodomain: conf: Better errors on bad os <type> values
Cole Robinson [Thu, 16 Apr 2015 22:08:17 +0000 (18:08 -0400)]
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.

10 years agoparallels: make device addressing consistent
Nikolay Shirokovskiy [Mon, 20 Apr 2015 06:25:00 +0000 (09:25 +0300)]
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>
10 years agoparallels: fix return status for parallelsConnectOpen
Nikolay Shirokovskiy [Mon, 20 Apr 2015 06:24:00 +0000 (09:24 +0300)]
parallels: fix return status for parallelsConnectOpen

We should return VIR_DRV_OPEN_ERROR in case
if we handle scheme in query but some
error occur. Previously we sometimes
return VIR_DRV_OPEN_DECLINE.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@parallels.com>
10 years agolxc: fix starting a domain with non-strict numa memory mode
Luyao Huang [Mon, 20 Apr 2015 13:33:31 +0000 (15:33 +0200)]
lxc: fix starting a domain with non-strict numa memory mode

 # virsh -c lxc:/// start helloworld
 error: Failed to start domain helloworld
 error: internal error: guest failed to start: Unknown
 failure in libvirt_lxc startup

Return success when there are no cpuset.mems to be set,
instead of failing without setting an error.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
10 years agolxc: fix starting a domain with a cpuset but no numatune
Luyao Huang [Fri, 3 Apr 2015 10:11:15 +0000 (18:11 +0800)]
lxc: fix starting a domain with a cpuset but no numatune

 # virsh -c lxc:/// start helloworld
 error: Failed to start domain helloworld
 error: internal error: guest failed to start: Invalid value '1-3'
 for 'cpuset.mems': Invalid argument

Free the cpu mask to avoid reusing it as a mem mask
in virCgroupSetCpusetMems
if virDomainNumatuneMaybeFormatNodeset does not set a mask.

Signed-off-by: Luyao Huang <lhuang@redhat.com>
Signed-off-by: Ján Tomko <jtomko@redhat.com>
10 years agorng: Move sgio attr definition to a separate block
Erik Skultety [Mon, 20 Apr 2015 07:49:36 +0000 (09:49 +0200)]
rng: Move sgio attr definition to a separate block

it might be worth having sgio attribute defined in a separate block the same way
as rawio attribute.

10 years agorng: Forbid to validate mismatched <disk> 'device' and 'type' attributes
Erik Skultety [Fri, 17 Apr 2015 11:14:12 +0000 (13:14 +0200)]
rng: Forbid to validate mismatched <disk> 'device' and 'type' attributes

According to docs, using 'lun' as a value for device attribute is only valid
with disk types 'block' and 'network'. However current RNG schema also allows
a combination type='file' device='lun' which results in a successfull
xml validation, but fails at qemuBuildCommandLine.
Besides fixing the RNG schema, this patch also adds a qemuxml2argvtest
for this case.

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

10 years agoApparmor: removed duplicate nscd rules
Cédric Bosdonnat [Mon, 20 Apr 2015 07:32:04 +0000 (09:32 +0200)]
Apparmor: removed duplicate nscd rules

10 years agodomcaps: Check for architecture more wisely
Michal Privoznik [Wed, 8 Apr 2015 14:59:36 +0000 (16:59 +0200)]
domcaps: Check for architecture more wisely

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

So we have this bug. The virConnectGetDomainCapabilities() API
performs a couple of checks before it produces any result. One of
the checks is if the architecture requested by user can be run by
the binary (again user provided). However, the check is pretty
dumb. It merely compares if the default binary architecture
matches the one provided by user. However, a qemu binary can run
multiple architectures. For instance: qemu-system-ppc64 can run:
ppc, ppcle, ppc64, ppc64le and ppcemb. The default is ppc64, so
if user requested something else, like ppc64le, the check would
have failed without obvious reason.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoschema: Allow multiple machines for VMs and unite architectures
Martin Kletzander [Thu, 9 Apr 2015 08:49:02 +0000 (10:49 +0200)]
schema: Allow multiple machines for VMs and unite architectures

Use the same pattern for all machine types on all archs and same archs
for hvm and exe types.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
10 years agoqemuDomainShutdownFlags: Set fakeReboot more frequently
zhang bo [Fri, 17 Apr 2015 00:43:58 +0000 (08:43 +0800)]
qemuDomainShutdownFlags: Set fakeReboot more frequently

When a qemu domain is to be rebooted, from outside, at libvirt
level it looks like regular shutdown. To really restart the
domain, libvirt needs to issue reset command on the monitor once
SHUTDOWN event appeared. So, in order to differentiate bare
shutdown and reboot libvirt uses a variable within domain private
data. It's called fakeReboot. When the reboot API is called, the
variable is set, but when the shutdown API is called it must be
cleared out. But it was not for every possible case. So if user
called virDomainReboot(), and there was no ACPI daemon running
inside the guest (so guest didn't initiated shutdown sequence)
and then virDomainShutdown(mode=agent) was called bad thing
happened. We remembered the fakeReboot and instead of shutting
the domain down, we just rebooted it.

Signed-off-by: Zhang Bo <oscar.zhangbo@huawei.com>
Signed-off-by: Wang Yufei <james.wangyufei@huawei.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agoIntroduce virNetDevBandwidthUpdateFilter
Michal Privoznik [Tue, 14 Apr 2015 16:04:30 +0000 (18:04 +0200)]
Introduce virNetDevBandwidthUpdateFilter

This is a simple wrapper around virNetDevBandwidthManipulateFilter() that
will update the desired filter on an interface (usually a network bridge)
with a new MAC address. Although, the MAC address in question usually
refers to some other interface - the one that the filter is constructed
for. Yeah, hard to parse. Thing is, our NATed network has a bridge where
some part of QoS takes place. And vNICs from guests are plugged into
the bridge. However, if a guest decides to change the MAC of its vNIC,
the corresponding qemu process emits an event which we can use to
update the QoS configuration based on the new MAC address.. However,
our QoS hierarchy is currently not notified, therefore it falls apart.
This function (when called in response to the aforementioned event)
will update our QoS hierarchy and duct tape it together again.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirnetdevbandwidth.c: Separate tc filter creation to a function
Michal Privoznik [Tue, 14 Apr 2015 11:47:22 +0000 (13:47 +0200)]
virnetdevbandwidth.c: Separate tc filter creation to a function

Not only this simplifies the code a bit, it prepares the
environment for upcoming patches. The new
virNetDevBandwidthManipulateFilter() function is capable of both
removing a filter and adding a new one. At the same time! Yeah,
this is not currently used anywhere but look at the next commit
where you'll see it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirNetDevBandwidthSet: Add priority to filter
Michal Privoznik [Tue, 14 Apr 2015 13:40:17 +0000 (15:40 +0200)]
virNetDevBandwidthSet: Add priority to filter

Currently, when constructing traffic shaping rules, the ingress
filter is created without any priority specified on the command
line. This makes kernel to make up one. While this works, it
simplifies things a bit if we provide the filter priority. In
this case, since it's the root filter lets give it the highest
priority of number 1.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirDomainActualNetDefContentsFormat: Format class_id more frequently
Michal Privoznik [Tue, 14 Apr 2015 15:59:18 +0000 (17:59 +0200)]
virDomainActualNetDefContentsFormat: Format class_id more frequently

After a360912179 the formatting of virDomainActualNetDefPtr was
changed a bit. However, during the function rewrite, iface's class_id
is not formatted as frequently as it could be. In fact, after rewrite
it's formatted only for iface of type VIR_DOMAIN_NET_TYPE_DIRECT where
it makes no sense and is unused. While where needed (_TYPE_NETWORK) is
not formatted at all. This makes the daemon forget it upon daemon
restart resulting in bad behaviour.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agonwfilter: Partly initialize driver even for non-privileged users
Michal Privoznik [Thu, 16 Apr 2015 07:59:22 +0000 (09:59 +0200)]
nwfilter: Partly initialize driver even for non-privileged users

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

This reverts commit b7829f959b33c6e32422222a9ed745c0da7dc696.

The previous fix was not correct. Like everywhere else, a driver is a
global variable allocated in stateInitialize function (or something
similar for stateless drivers). Later, when a driver API is called,
it's possible that the global variable is accessed and dereferenced.
Now, some drivers require root privileges because they undertake some
actions reserved only for the system admin (e.g. manipulating host
firewall). And here's the trouble, the NWFilter state initializer
exited too early when finding out it's running unprivileged, leaving
the global NWFilter driver variable uninitialized. Any subsequent
API call that tried to lock the driver resulted in dereferencing the
driver and thus crash.

On the other hand, in order to not resurrect the bug the original
commit was fixing, Let's forbid the nwfilter define in session mode.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Conflicts:
src/nwfilter/nwfilter_driver.c: Context. Code changed a bit
        since 2013.

10 years agovirNetSocketNewConnectUNIX: Don't unlink(NULL)
Michal Privoznik [Thu, 16 Apr 2015 14:07:15 +0000 (16:07 +0200)]
virNetSocketNewConnectUNIX: Don't unlink(NULL)

There is a possibility that we jump onto error label with @lockpath
still initialized to NULL. Here, the @lockpath should be unlink()-ed,
but passing there a NULL is not a good idea. Don't do that. In fact,
we should call unlink() only if we created the lock file successfully.

Reported-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agolxc: move wireless PHYs to a network namespace
Lubomir Rintel [Tue, 14 Apr 2015 16:21:44 +0000 (18:21 +0200)]
lxc: move wireless PHYs to a network namespace

The 802.11 interfaces can not be moved by themselves, their Phy has to move too.

If there are other interfaces, they have to move too -- hopefully it's not too
confusing. This is a less-invasive alternative to defining a new hostdev type
for PHYs.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agolibxl: drop virDomainObj lock when destroying a domain
Jim Fehlig [Wed, 4 Mar 2015 00:54:50 +0000 (17:54 -0700)]
libxl: drop virDomainObj lock when destroying a domain

A destroy operation can take considerable time on large memory
domains due to scrubbing the domain's memory.  Unlock the
virDomainObj while libxl_domain_destroy is executing.

Implement libxlDomainDestroyInternal wrapper to handle unlocking,
calling destroy, and locking.  Change all callers of
libxl_domain_destroy to use the wrapper.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
10 years agolibxl: acquire a job when destroying a domain
Jim Fehlig [Sun, 1 Mar 2015 23:22:07 +0000 (16:22 -0700)]
libxl: acquire a job when destroying a domain

A job should be acquired at the beginning of a domain destroy operation,
not at the end when cleaning up the domain.  Fix two occurrences of this
late job acquisition in the libxl driver.  Doing so renders
libxlDomainCleanupJob unused, so it is removed.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
10 years agolibxl: Move job acquisition in libxlDomainStart to callers
Jim Fehlig [Mon, 2 Mar 2015 01:24:26 +0000 (18:24 -0700)]
libxl: Move job acquisition in libxlDomainStart to callers

Let callers of libxlDomainStart decide when it is appropriate to
acquire a job on the associated virDomainObj.

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
10 years agolibxl: support HVM direct kernel boot
Jim Fehlig [Fri, 20 Mar 2015 04:16:11 +0000 (22:16 -0600)]
libxl: support HVM direct kernel boot

Add support for HVM direct kernel boot in libxl.  Also add a
test to verify domXML <-> native conversions.

Signed-off-by: Chunyan Liu <cyliu@suse.com>
Signed-off-by: Jim Fehlig <jfehlig@suse.com>
10 years agoxenconfig: don't use "kernel" for hvmloader
Jim Fehlig [Fri, 20 Mar 2015 01:03:08 +0000 (19:03 -0600)]
xenconfig: don't use "kernel" for hvmloader

In xl config, hvmloader is implied for hvm guests.  It is not
specified with the "kernel" option like xm config.  The "kernel"
option, along with "ramdisk" and "extra", is used for HVM direct
kernel boot.  Instead of using "kernel" option to populate
virDomainDef object's os.loader->path, use hvmloader discovered
when gathering capabilities.

This change required fixing initialization of capabilities in
the test utils and removing 'kernel = "/usr/lib/xen/boot/hvmloader"'
from the test config files.

10 years agoxenconfig: move <os> parsing/formating to config-specific files
Jim Fehlig [Fri, 20 Mar 2015 00:28:49 +0000 (18:28 -0600)]
xenconfig: move <os> parsing/formating to config-specific files

xl and xm differ a bit in how <os> configuration is represented.
E.g. xl config supports <os><nvram .../></os> via its "bios"
setting.

Move the xenParseOS and xenFormatOS functions from xen_common.c
and copy to xen_xl.c and xen_xm.c so they can be customized for
xm vs xl config.  An unfortunate fallout is reordering of entries
in the test config files.

10 years agoxenconfig: remove redunant parsing of device_model
Jim Fehlig [Fri, 20 Mar 2015 00:02:28 +0000 (18:02 -0600)]
xenconfig: remove redunant parsing of device_model

device_model is parsed in xenParseOS(), then later in
xenParseConfigCommon().  <emulator> is not part of <os>,
so makes sense to remove the parsing in xenParseOS().

10 years agoxenconfig: export xenConfigCopyString
Jim Fehlig [Thu, 19 Mar 2015 23:29:38 +0000 (17:29 -0600)]
xenconfig: export xenConfigCopyString

Export xenConfigCopyString for use outside of xen_common.c

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
10 years agovirbuffer: fix build on rhel-6
Pavel Hrdina [Thu, 16 Apr 2015 16:32:26 +0000 (18:32 +0200)]
virbuffer: fix build on rhel-6

On rhel-6 is broken gcc that reports this warning:

util/virbuffer.c:500: error: logical '&&' with non-zero constant will
    always evaluate as true [-Wlogical-op]

Move the pragma directive before function virBufferEscapeString because
since commit aeb5262e this function uses 'strchr' too.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
10 years agostorage: Refactor virStorageBackendSCSINewLun
John Ferlan [Tue, 7 Apr 2015 17:39:01 +0000 (13:39 -0400)]
storage: Refactor virStorageBackendSCSINewLun

Invert the logical of retval and clean up code paths, especially goto's

Signed-off-by: John Ferlan <jferlan@redhat.com>
10 years agovirCondWaitUntil: calculate timespec correctly
Michael Chapman [Thu, 16 Apr 2015 09:27:36 +0000 (19:27 +1000)]
virCondWaitUntil: calculate timespec correctly

ts.tv_nsec was off by a factor of 1000, making timeouts less than a
second in the future often expiring immediately.

Signed-off-by: Michael Chapman <mike@very.puzzling.org>
10 years agoqemu: monitor: Refactor and fix monitor checking
Peter Krempa [Tue, 14 Apr 2015 15:52:48 +0000 (17:52 +0200)]
qemu: monitor: Refactor and fix monitor checking

Among all the monitor APIs some where checking if mon is NULL and some
were not. Since it's possible to have mon equal to NULL in case a second
call is attempted once entered the monitor. This requires that every
single API checks for the monitor.

This patch adds a macro that helps checking the state of the monitor and
either refactors existing checking code to use the macro or adds it in
case it was missing.

10 years agodaemon: Prefix sysctl configuration filename with a number
Jiri Denemark [Wed, 15 Apr 2015 09:49:22 +0000 (11:49 +0200)]
daemon: Prefix sysctl configuration filename with a number

Apparently, files in /usr/lib/sysctl.d are usually prefixed with numbers
for easier ordering. Let's be consistent with this. I chose 60 for
libvirtd so that it goes after 50-default.conf.

https://bugzilla.redhat.com/show_bug.cgi?id=1084876
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
10 years agoqemu: bulk stats: Ignore errors from missing/inaccessible disks
Peter Krempa [Wed, 15 Apr 2015 16:14:30 +0000 (18:14 +0200)]
qemu: bulk stats: Ignore errors from missing/inaccessible disks

Rather than erroring out make the best attempt to retrieve other data if
disks are inaccessible or missing. The failure will still be logged
though.

Since the bulk stats API is called on multiple domains an error like
this makes the API unusable. This regression was introduced by commit
596a13713420e01b20ce3dc3fdbe06d073682675

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

10 years agoRNG schema: allow plain @floor to <bandwidth/>
Michal Privoznik [Tue, 14 Apr 2015 13:54:42 +0000 (15:54 +0200)]
RNG schema: allow plain @floor to <bandwidth/>

The <inbound/> element to <bandwidth/> has several attributes from
which two are mandatory. Well, from two at least one has to be
present: @average or @floor or both. Instead of inventing crazy RNG
schema, let's make all the attributes optional there and rely on our
parsing code to correctly handle the situation.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agovirNetDevBandwidthPlug: Update function description
Michal Privoznik [Tue, 14 Apr 2015 11:45:30 +0000 (13:45 +0200)]
virNetDevBandwidthPlug: Update function description

The comment is describing arguments passed to the function.
However, there's no @ifmac argument. In 955af4d4 it was replaced
with @ifmac_ptr.  Unfortunately, the comment wasn't updated.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
10 years agotests: fix build on old 32-bit platforms
Eric Blake [Wed, 15 Apr 2015 18:50:23 +0000 (12:50 -0600)]
tests: fix build on old 32-bit platforms

gcc 4.1.2 (hello RHEL 5) on 32-bit platforms complains:

vircgrouptest.c: In function 'testCgroupGetPercpuStats':
vircgrouptest.c:627: warning: integer constant is too large for 'long' type
vircgrouptest.c:628: warning: this decimal constant is unsigned only in ISO C90
vircgrouptest.c:634: warning: integer constant is too large for 'long' type
vircgrouptest.c:635: warning: this decimal constant is unsigned only in ISO C90
vircgrouptest.c:636: warning: this decimal constant is unsigned only in ISO C90
vircgrouptest.c:644: warning: integer constant is too large for 'long' type

* tests/vircgrouptest.c (testCgroupGetPercpuStats): Use ULL suffix.

Signed-off-by: Eric Blake <eblake@redhat.com>