]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
9 years agoqemu: hotplug: Add support for signalling device unplug failure
Peter Krempa [Mon, 4 Apr 2016 15:17:43 +0000 (17:17 +0200)]
qemu: hotplug: Add support for signalling device unplug failure

Similarly to the DEVICE_DELETED event we will be able to tell when
unplug of certain device types will be rejected by the guest OS. Wire up
the device deletion signalling code to allow handling this.

9 years agoqemu: Use domain condition for device removal signaling
Peter Krempa [Mon, 4 Apr 2016 11:59:48 +0000 (13:59 +0200)]
qemu: Use domain condition for device removal signaling

No need to keep two separate conditions. A slight juggling of return
values is needed to accomodate virDomainObjWaitUntil.

9 years agoqemu: hotplug: Refactor semantics of qemuDomainWaitForDeviceRemoval
Peter Krempa [Mon, 4 Apr 2016 13:08:40 +0000 (15:08 +0200)]
qemu: hotplug: Refactor semantics of qemuDomainWaitForDeviceRemoval

Neither of the callers cares whether the DEVICE_DELETED event isn't
supported or the event was received. Simplify the code and callers by
unifying the two values and changing the return value constants so that
a temporary variable can be omitted.

9 years agoqemu: hotplug: Properly handle errors in qemuDomainWaitForDeviceRemoval
Peter Krempa [Mon, 4 Apr 2016 13:27:25 +0000 (15:27 +0200)]
qemu: hotplug: Properly handle errors in qemuDomainWaitForDeviceRemoval

Callers ignore if this function returns -1 and continue as though the
DEVICE_DELETED event was not received. Since we can't be sure that the
event was not received we should behave as if the event was not
supported and remove the device definition right away. The error
fortunately won't really happen here.

9 years agoqemu: assign addresses before aliases
Ján Tomko [Wed, 13 Apr 2016 07:38:29 +0000 (09:38 +0200)]
qemu: assign addresses before aliases

The address assigning code might add new pci bridges.
We need them to have an alias when building the command line.

In real word usage, this is not a problem because all the code
paths already call qemuDomainAssignAddresses. However moving
this call lets us remove one extra call from qemuxml2argvtest.

9 years agoqemuxml2argvtest: drop FLAG_EXPECT_ERROR
Ján Tomko [Wed, 13 Apr 2016 06:21:42 +0000 (08:21 +0200)]
qemuxml2argvtest: drop FLAG_EXPECT_ERROR

It is only used for failed address allocation
Since we already have FLAG_EXPECT_FAILURE, use that instead.

Also unify the output to print the whole log buffer instead
of just the last error message.

9 years agotests: clean up includes
Ján Tomko [Wed, 13 Apr 2016 06:12:47 +0000 (08:12 +0200)]
tests: clean up includes

After removing qemuBuildCommandLineCallbacks, testutilsqemu.h does not
need to include qemu_command.h.

Include just qemu_conf.h here and qemu_domain_address.h in files that
need it.

9 years agodrop qemuBuildCommandLineCallbacks
Ján Tomko [Wed, 13 Apr 2016 06:10:24 +0000 (08:10 +0200)]
drop qemuBuildCommandLineCallbacks

Essentially revert commit 3a6204c which added these to allow the test
suite to pass without depending on the host system state.

Since commit 4b527c1 we already mock virSCSIDeviceGetSgName, so these
callbacks are useless.

9 years agodomain_conf: call ...ListensParseXML only for appropriate graphics
Pavel Hrdina [Thu, 7 Apr 2016 11:08:58 +0000 (13:08 +0200)]
domain_conf: call ...ListensParseXML only for appropriate graphics

Instead of calling the virDomainGraphicsListensParseXML function for all
graphics types and ignore the wrong ones move the call only to graphics
types where we supports listen elements.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agodomain_conf: remove unused virDomainGraphicsListenGet*
Pavel Hrdina [Sun, 10 Apr 2016 17:00:01 +0000 (19:00 +0200)]
domain_conf: remove unused virDomainGraphicsListenGet*

Those are the last two places that uses the getter functions.  Use a
direct access instead and remove those getters.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agouse virDomainGraphicsGetListen instead of the other getters
Pavel Hrdina [Wed, 23 Mar 2016 08:27:56 +0000 (09:27 +0100)]
use virDomainGraphicsGetListen instead of the other getters

There is no point the use two different getters on the same listen
structure few lines apart.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agodomain_conf: cleanup virDomainGraphicsGetListen
Pavel Hrdina [Sun, 10 Apr 2016 16:57:12 +0000 (18:57 +0200)]
domain_conf: cleanup virDomainGraphicsGetListen

Removes the check for graphics type, it's not a public API and developer
know what he's doing and this check makes no sense.  It also removes
the ability to allocate a new array if there is none.  This was used by
the virDomainGraphicsListenAdd* functions and isn't used anymore.

This is now a simple getter with simple check for listens array presence
and whether the index in out of bounds.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agodomain_conf: remove unused virDomainGraphicsListenSetType
Pavel Hrdina [Wed, 23 Mar 2016 08:09:16 +0000 (09:09 +0100)]
domain_conf: remove unused virDomainGraphicsListenSetType

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agodomain_conf: remove virDomainGraphicsListenSetNetwork
Pavel Hrdina [Sun, 10 Apr 2016 16:54:40 +0000 (18:54 +0200)]
domain_conf: remove virDomainGraphicsListenSetNetwork

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agodomain_conf: introduce virDomainGraphicsListenAppendAddress
Pavel Hrdina [Wed, 23 Mar 2016 07:55:46 +0000 (08:55 +0100)]
domain_conf: introduce virDomainGraphicsListenAppendAddress

This effectively removes virDomainGraphicsListenSetAddress which was
used only to change the address of listen structure and possible change
the listen type.  The new function will auto-expand the listens array
and append a new listen.

The old function was used on pre-allocated array of listens and in most
cases it only "add" a new listen.  The two remaining uses can access the
listen structure directly.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agoconfigure: Make virt-host-validate optional
Andrea Bolognani [Fri, 8 Apr 2016 15:14:13 +0000 (17:14 +0200)]
configure: Make virt-host-validate optional

virt-host-validate, just like virt-login-shell, doesn't make sense
on Windows, so we should avoid building it.

Make the tool optional and build it by default on all platforms
except Windows, erroring out if the user attempts to build it
anyway.

9 years agotools: Reorganize conditional bits
Andrea Bolognani [Fri, 8 Apr 2016 15:23:10 +0000 (17:23 +0200)]
tools: Reorganize conditional bits

Instead of having separate handling for programs and man pages,
deal with both in the same place.

9 years agoconf: extract disk geometry parsing code
Peter Krempa [Tue, 12 Apr 2016 13:48:40 +0000 (15:48 +0200)]
conf: extract disk geometry parsing code

9 years agoconf: Refactor virDomainDiskDefMirrorParse
Peter Krempa [Tue, 12 Apr 2016 13:39:38 +0000 (15:39 +0200)]
conf: Refactor virDomainDiskDefMirrorParse

Now that the mirror parsing code is not crammed in the main disk parser
we can employ better coding style.

9 years agoconf: disk: Split out parsing of disk mirror data
Peter Krempa [Tue, 12 Apr 2016 13:27:50 +0000 (15:27 +0200)]
conf: disk: Split out parsing of disk mirror data

Changes are indentation and 'cleanup' label instead of 'error'.

9 years agoconf: virDomainDiskDefIotuneParse: Report malformed number errors
Peter Krempa [Tue, 12 Apr 2016 13:03:19 +0000 (15:03 +0200)]
conf: virDomainDiskDefIotuneParse: Report malformed number errors

Rest of the fields of the iotune data structure did not check for
malformed integers. Use the previously defined macro to extract them
which will simplify the code and add error reporting.

9 years agoconf: virDomainDiskDefIotuneParse: simplify parsing
Peter Krempa [Tue, 12 Apr 2016 12:49:47 +0000 (14:49 +0200)]
conf: virDomainDiskDefIotuneParse: simplify parsing

Since the structure was pre-initialized to 0 we don't need to set every
single member to 0 if it's not present in the XML. Additionally if we
put the name of the field into the error message the code can be
simplified using a macro to parse the members.

9 years agoconf: disk: Remove error label from virDomainDiskDefIotuneParse
Peter Krempa [Tue, 12 Apr 2016 12:25:44 +0000 (14:25 +0200)]
conf: disk: Remove error label from virDomainDiskDefIotuneParse

Since this function isn't doing any cleanup, the label is not necessary.

9 years agoconf: disk: Extract iotune parsing into a separate func
Peter Krempa [Tue, 12 Apr 2016 12:22:34 +0000 (14:22 +0200)]
conf: disk: Extract iotune parsing into a separate func

9 years agoconf: disk: Remove one unnecessary level of indentation
Peter Krempa [Mon, 11 Apr 2016 14:13:33 +0000 (16:13 +0200)]
conf: disk: Remove one unnecessary level of indentation

Also simplify the code by switching to a for loop.

9 years agoconf: disk: Don't initialize fields allocated by calloc
Peter Krempa [Mon, 11 Apr 2016 14:06:07 +0000 (16:06 +0200)]
conf: disk: Don't initialize fields allocated by calloc

All the fields were initialized to 0.

9 years agoutil: Rename and move virStrIsPrint to virStringIsPrintable
Peter Krempa [Mon, 11 Apr 2016 11:35:25 +0000 (13:35 +0200)]
util: Rename and move virStrIsPrint to virStringIsPrintable

9 years agovz: add Hypervisor prefix to vz and parallels Driver structures
Maxim Nestratov [Wed, 6 Apr 2016 08:06:18 +0000 (11:06 +0300)]
vz: add Hypervisor prefix to vz and parallels Driver structures

9 years agovz: remove drivername field from vzConn structure
Maxim Nestratov [Tue, 29 Mar 2016 08:21:17 +0000 (11:21 +0300)]
vz: remove drivername field from vzConn structure

No need to remember connection name and have corresponding
domain type to keep backward compatibility with former
'parallels' driver. It is enough to be able to accept 'parallels'
uri and domain types.

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
9 years agovz: change the order of capabilities reported
Maxim Nestratov [Mon, 28 Mar 2016 18:08:49 +0000 (21:08 +0300)]
vz: change the order of capabilities reported

'vz' goes first now to make clients like virt-manager choose 'vz'
instead of 'parallels'

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
9 years agovirsh: report when vz driver is compiled
Maxim Nestratov [Mon, 28 Mar 2016 13:20:40 +0000 (16:20 +0300)]
virsh: report when vz driver is compiled

Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
9 years agotests: fix xen-related tests
Ján Tomko [Tue, 12 Apr 2016 12:58:43 +0000 (14:58 +0200)]
tests: fix xen-related tests

My commit 6879be4 moved the addition of the implicit video device
from the XML parser to the PostParse function, but did not regenerate
all the tests.

9 years agovz: fix memory leak
Nikolay Shirokovskiy [Wed, 6 Apr 2016 11:42:14 +0000 (14:42 +0300)]
vz: fix memory leak

we don't need to allocate macstr at all as it is an array
and already has the the space it needs.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
9 years agoconf: use VIR_APPEND_ELEMENT in virDomainDefAddImplicitVideo
Ján Tomko [Mon, 11 Apr 2016 13:28:29 +0000 (15:28 +0200)]
conf: use VIR_APPEND_ELEMENT in virDomainDefAddImplicitVideo

9 years agoconf: reduce indentation in virDomainDefAddImplicitVideo
Ján Tomko [Mon, 11 Apr 2016 13:26:06 +0000 (15:26 +0200)]
conf: reduce indentation in virDomainDefAddImplicitVideo

Return early if there is nothing to do.

9 years agoconf: delete useless primaryVideo variable
Ján Tomko [Mon, 11 Apr 2016 13:20:41 +0000 (15:20 +0200)]
conf: delete useless primaryVideo variable

If we encounter a video device with primary=yes, we insert it
at def->videos[0].

There is no need to record this in a separate variable,
just check if there already is a primary video at def->videos[0].

9 years agoconf: use insertAt instead of j
Ján Tomko [Mon, 11 Apr 2016 12:45:46 +0000 (14:45 +0200)]
conf: use insertAt instead of j

We call VIR_INSERT_ELEMENT_INPLACE either with 0 (for primary video)
or def->nvideos (for the rest).

Use a variable with more semantic name, since j is usually used
for iterating.

9 years agoconf: use the iterator directly when parsing video devices
Ján Tomko [Mon, 11 Apr 2016 12:43:43 +0000 (14:43 +0200)]
conf: use the iterator directly when parsing video devices

We start with both i and def->nvideos at 0 and increment both
after every successful iteration.

Use i directly, instead of passing the def->nvideos value through j.

9 years agoconf: also mark the implicit video as primary
Ján Tomko [Mon, 11 Apr 2016 12:26:06 +0000 (14:26 +0200)]
conf: also mark the implicit video as primary

Commit 119cd06 started setting the primary bool for the first
user-specified video even if user omitted the 'primary' attribute.

However this was done before the addition of the implicit device.
This broke startup of transient qemu domains with no <video>:
https://bugzilla.redhat.com/show_bug.cgi?id=1325757

Move this default to virDomainDefPostParseInternal,
after the addition of the implicit video device, to catch the implicit
video as well.

9 years agoconf: move default video addition after XML parsing
Ján Tomko [Mon, 11 Apr 2016 12:06:03 +0000 (14:06 +0200)]
conf: move default video addition after XML parsing

Separate parsing of the XML from auto-generating the device.

9 years agocfg.mk: Use single quotes wherever possible
Andrea Bolognani [Mon, 11 Apr 2016 14:45:53 +0000 (16:45 +0200)]
cfg.mk: Use single quotes wherever possible

Being consistent is nice, especially when it comes to defining our
regular expression, where using single quotes instead of double
quotes allows us to leave out a few backslashes.

Changing this required altering a few error messages.

The only remaining use of double quotes is one where they are
actually required for the check to work.

9 years agocfg.mk: Remove spurious whitespace
Andrea Bolognani [Mon, 11 Apr 2016 14:38:18 +0000 (16:38 +0200)]
cfg.mk: Remove spurious whitespace

9 years agoutil: Fix 'exempt from syntax-check' comment
Andrea Bolognani [Mon, 11 Apr 2016 14:21:59 +0000 (16:21 +0200)]
util: Fix 'exempt from syntax-check' comment

9 years agovz: implement memory setting functions
Nikolay Shirokovskiy [Fri, 8 Apr 2016 09:36:45 +0000 (12:36 +0300)]
vz: implement memory setting functions

Quite straigthforward as vz sdk memory setting function makes
just what we want to that is set "amount of physical memory
allocated to a domain".

'useflags' is introduced for non flag function implementation.
We can't just use combination of flags like "live | config" or
we fail for inactive domains. Other combinations have drawbacks
too.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
9 years agovz: factor out config update flags checks
Nikolay Shirokovskiy [Fri, 8 Apr 2016 09:36:44 +0000 (12:36 +0300)]
vz: factor out config update flags checks

Actually this is not pure refactoring. Part of common code is
replaced with virDomainObjUpdateModificationImpact and this
a good replacement. It includes removed check of inactive
domain and active flags set. Additionally we resolve
current flag in accordance with current state of domain.
Thus it becames possible to attach/detach devices for
inactive domains if this flag is set.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
9 years agodomain_conf: fix graphics parsing
Pavel Hrdina [Mon, 11 Apr 2016 11:05:42 +0000 (13:05 +0200)]
domain_conf: fix graphics parsing

Commit dc98a5bc refactored the code a lot and forget about checking if
listen attribute is specified.  This ensures that listen attribute and
first listen element are compared only if both exist.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agovirtlogd: Fix a couple minor memory leaks
Cole Robinson [Sun, 10 Apr 2016 23:19:25 +0000 (19:19 -0400)]
virtlogd: Fix a couple minor memory leaks

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

9 years agobuild: add GCC 6.0 -Wlogical-op workaround
Pavel Hrdina [Sun, 10 Apr 2016 16:22:20 +0000 (18:22 +0200)]
build: add GCC 6.0 -Wlogical-op workaround

fdstream.c: In function 'virFDStreamWrite':
fdstream.c:390:29: error: logical 'or' of equal expressions [-Werror=logical-op]
        if (errno == EAGAIN || errno == EWOULDBLOCK) {
                            ^~

Fedora rawhide now uses gcc 6.0 and there is a bug with -Wlogical-op
producing false warnings.

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=69602

Use GCC pragma push/pop and ignore -Wlogical-op for GCC that supports
push/pop pragma and also has this bug.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agobuild: cleanup GCC < 4.6 -Wlogical-op workaround
Pavel Hrdina [Sun, 10 Apr 2016 16:21:13 +0000 (18:21 +0200)]
build: cleanup GCC < 4.6 -Wlogical-op workaround

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agoqemu: Free priv->machineName
Martin Kletzander [Fri, 8 Apr 2016 13:29:40 +0000 (15:29 +0200)]
qemu: Free priv->machineName

Commit c3bd0019c0e3 forgot to cleanup after itself.

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

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
9 years agoqemu: agent: Fix incorrect and weird debug/warning log entries
Peter Krempa [Fri, 8 Apr 2016 08:08:37 +0000 (10:08 +0200)]
qemu: agent: Fix incorrect and weird debug/warning log entries

Replace the nonsensical debug statement by adding the expected event
code into the existing debug statement.

Since the monitor code always notifies the agent on guest
reboot/shutdown even if that was not initiated by the agent the warning
emitted later is bogus and pollutes the logs in such cases. Delete it
and keep just the original debug message where this info can be
inferred.

9 years agohost-validate: Be more careful when checking for cgroup support
Andrea Bolognani [Fri, 8 Apr 2016 12:13:10 +0000 (14:13 +0200)]
host-validate: Be more careful when checking for cgroup support

Simply checking whether the cgroup name appears somewhere inside
/proc/self/cgroup is enough most of the time, but there are some
corner cases that require a more mindful parsing.

9 years agoconfigure: Fix check for --with-login-shell on Windows
Andrea Bolognani [Fri, 8 Apr 2016 14:17:16 +0000 (16:17 +0200)]
configure: Fix check for --with-login-shell on Windows

The check is supposed to stop users from trying to compile
virt-login-shell on Windows by erroring out during the
configure phase; however, there are two flaws in it:

  * the value of "x$with_win" is compared to "yes" instead
    of "xyes" (note the "x" in the first string)

  * "test" is not being used, so the script will actually
    try to run a command called "x$with_win" instead of
    performing string comparison

This patch fixes both issues.

9 years agopo: Really fix po/POTFILES.in ordering
Erik Skultety [Sun, 10 Apr 2016 16:58:53 +0000 (18:58 +0200)]
po: Really fix po/POTFILES.in ordering

Commit e72667bd tried to fix the incorrect file ordering in po/POTFILES.in
except it didn't, since the sort was run using locale en_US instead of
using locale C which is the default in libvirt. So this patch hopefully fixes
it for good.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
9 years agopo: fix POTFILES.in file ordering
Erik Skultety [Sat, 9 Apr 2016 18:02:49 +0000 (20:02 +0200)]
po: fix POTFILES.in file ordering

When it comes to a situation that a new translatable file needs to be added
into the list of files, an automatically generated patch is proposed during
syntax-check. However, the diff was made against a sorted list of files and
the same sorted list of files + the new file that actually needs to be added
into the list. Since we do not keep POTFILES sorted, the proposed patch thus
can't be applied...most of the time - depending on the context.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
9 years agoqemu: fix build without gnutls installed
Roman Bogorodskiy [Sat, 9 Apr 2016 19:04:40 +0000 (22:04 +0300)]
qemu: fix build without gnutls installed

Move including of gnutls/gnutls.h in qemu/qemu_domain.c under the
"ifdef WITH_GNUTLS" check because otherwise it fails like this:

  CC       qemu/libvirt_driver_qemu_impl_la-qemu_domain.lo
qemu/qemu_domain.c:50:10: fatal error: 'gnutls/gnutls.h' file not found

in case if gnutls is not installed on the system.

9 years agonss: properly include syms files to dist
Roman Bogorodskiy [Sat, 9 Apr 2016 05:17:14 +0000 (08:17 +0300)]
nss: properly include syms files to dist

Explicitly add Linux and BSD syms files for nss to EXTRA_DIST
instead of using the LIBVIRT_NSS_SYMBOL_FILE variable, because its value
will point to either Linux or BSD syms file, but we need to ship both.

9 years agonss: fix typo in configure help string
Roman Bogorodskiy [Sat, 9 Apr 2016 04:50:52 +0000 (07:50 +0300)]
nss: fix typo in configure help string

Servie -> Service

9 years agodomain_conf: cleanup error paths for graphics parser
Pavel Hrdina [Wed, 2 Mar 2016 16:03:59 +0000 (17:03 +0100)]
domain_conf: cleanup error paths for graphics parser

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agodomain_conf: split graphics xml parser into multiple functions
Pavel Hrdina [Wed, 2 Mar 2016 16:03:39 +0000 (17:03 +0100)]
domain_conf: split graphics xml parser into multiple functions

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agodomain_conf: cleanup virDomainGraphicsListensParseXML
Pavel Hrdina [Tue, 15 Mar 2016 16:15:17 +0000 (17:15 +0100)]
domain_conf: cleanup virDomainGraphicsListensParseXML

Refactor the listen parser to use only one loop.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agodomain_conf: introduce virDomainGraphicsListensParseXML
Pavel Hrdina [Wed, 2 Mar 2016 15:27:02 +0000 (16:27 +0100)]
domain_conf: introduce virDomainGraphicsListensParseXML

Move code, that parses graphics listens, to its own function.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agodocs: rewrite graphics XML documentation
Pavel Hrdina [Wed, 30 Mar 2016 14:00:14 +0000 (16:00 +0200)]
docs: rewrite graphics XML documentation

This cleanups the documentation, reformat some of the paragraphs to use
<p> instead of </br> and rewrites the listen part to be more extendable.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agotests: remove unwanted VIR_FREE of spice and vnc default listen
Pavel Hrdina [Wed, 23 Mar 2016 15:32:11 +0000 (16:32 +0100)]
tests: remove unwanted VIR_FREE of spice and vnc default listen

After the test and qemu_process refactor now we can benefit from default
listen address for spice and vnc in tests.

Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
9 years agodocs: Remove unused div.body CSS rule
Andrea Bolognani [Fri, 1 Apr 2016 09:29:21 +0000 (11:29 +0200)]
docs: Remove unused div.body CSS rule

The 'body' CSS class is not used anywhere in the HTML files,
so we can get rid of the definition as well.

9 years agoutil: netdev: Don't crash in virNetDevSetIPAddress if @peer is NULL
Peter Krempa [Fri, 8 Apr 2016 11:51:57 +0000 (13:51 +0200)]
util: netdev: Don't crash in virNetDevSetIPAddress if @peer is NULL

VIR_SOCKET_ADDR_VALID dereferences the pointer, thus if we pass NULL
into virNetDevSetIPAddress it crashes. Regression introduced by
b3d069872ce53eb.

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

9 years agoqemu: support virt-2.6 machine type on arm
Ján Tomko [Fri, 8 Apr 2016 08:46:41 +0000 (10:46 +0200)]
qemu: support virt-2.6 machine type on arm

Some places already check for "virt-" prefix as well as plain "virt".
virQEMUCapsHasPCIMultiBus did not, resulting in multiple PCI devices
having assigned the same unnumbered "pci" alias.

Add a test for the "virt-2.6" machine type which also omits the
<model type='virtio'/> in <interface>, to check if
qemuDomainDefaultNetModel works too.

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

9 years agohost-validate: Be more careful when checking for cgroup mounts
Andrea Bolognani [Mon, 4 Apr 2016 14:25:15 +0000 (16:25 +0200)]
host-validate: Be more careful when checking for cgroup mounts

The existing code is built on the assumption that no cgroup
name can appear as part of another cgroup name; moreover, cgroups
are expected to always be listed in a specific order.

If that's not the case, eg. 'cpuacct' is listed before 'cpu', the
algorithm fails to detect the cgroup mount point.

Rewrite it to get rid of such assumptions.

9 years agonetdev: Use the correct pointer type for virSocketAddrFormat()
Andrea Bolognani [Fri, 8 Apr 2016 09:07:16 +0000 (11:07 +0200)]
netdev: Use the correct pointer type for virSocketAddrFormat()

virSocketAddrFormat() wants a single pointer, not a double pointer.

Fixes the following compilation error on FreeBSD:

  util/virnetdev.c:1448:72: error: incompatible pointer types passing
   'virSocketAddr **' to parameter of type 'const virSocketAddr *';
   remove & [-Werror,-Wincompatible-pointer-types]
      if (VIR_SOCKET_ADDR_VALID(peer) && !(peerstr = virSocketAddrFormat(&peer)))
                                                                         ^~~~~
  ./util/virsocketaddr.h:92:48: note: passing argument to parameter 'addr' here
  char *virSocketAddrFormat(const virSocketAddr *addr);
                                                 ^

9 years agoconfigure: Move check for <gnutls/crypto.h>
Andrea Bolognani [Fri, 8 Apr 2016 09:01:09 +0000 (11:01 +0200)]
configure: Move check for <gnutls/crypto.h>

Checking for the availability of this header, just like checking
for the availability of gnutls_rnd(), requires CFLAGS and LIBS to
be set appropriately.

Fixes the following compilation errors on FreeBSD:

  qemu/qemu_domain.c:640:16: error: implicit declaration of function
   'gnutls_rnd' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
      if ((ret = gnutls_rnd(GNUTLS_RND_RANDOM, key, nbytes)) < 0) {
                 ^
  qemu/qemu_domain.c:640:27: error: use of undeclared identifier
   'GNUTLS_RND_RANDOM'; did you mean 'GNUTLS_CRD_ANON'?
      if ((ret = gnutls_rnd(GNUTLS_RND_RANDOM, key, nbytes)) < 0) {
                            ^~~~~~~~~~~~~~~~~
                            GNUTLS_CRD_ANON

9 years agoutil: move ENODATA redefine to internal.h
Roman Bogorodskiy [Thu, 7 Apr 2016 06:51:11 +0000 (09:51 +0300)]
util: move ENODATA redefine to internal.h

FreeBSD lacks ENODATA, and viruuid.c redefines it to EIO, but it's not
actually using it. On the other hand, we have virrandom.c that's using
ENODATA. So make this re-definition common by moving it to internal.h,
so all the current and possible future users don't need to care about
that.

9 years agoqemu domain allow to set ip address, peer address and route
Vasiliy Tolstov [Mon, 4 Apr 2016 21:00:06 +0000 (21:00 +0000)]
qemu domain allow to set ip address, peer address and route

Signed-off-by: Vasiliy Tolstov <v.tolstov@selfip.ru>
9 years agolxc domain allow to set peer address
Vasiliy Tolstov [Mon, 4 Apr 2016 21:00:04 +0000 (21:00 +0000)]
lxc domain allow to set peer address

Signed-off-by: Vasiliy Tolstov <v.tolstov@selfip.ru>
9 years agolibvirt domain xml allow to set peer address
Vasiliy Tolstov [Mon, 4 Apr 2016 21:00:03 +0000 (21:00 +0000)]
libvirt domain xml allow to set peer address

Signed-off-by: Vasiliy Tolstov <v.tolstov@selfip.ru>
9 years agovirnetdev allow to set peer address
Vasiliy Tolstov [Mon, 4 Apr 2016 21:00:02 +0000 (21:00 +0000)]
virnetdev allow to set peer address

Signed-off-by: Vasiliy Tolstov <v.tolstov@selfip.ru>
9 years agolibxl: libxl_domain_create_restore has an extra argument
Wei Liu [Tue, 5 Apr 2016 14:20:12 +0000 (15:20 +0100)]
libxl: libxl_domain_create_restore has an extra argument

In the latest libxenlight code, libxl_domain_create_restore accepts a
new argument. Update libvirt's libxl driver for that. Use the macro
provided by libxenlight to detect which version should be used.

The new parameter (send_back_fd) is set to -1 because libvirt provides
no such fd.

Signed-off-by: Wei Liu <wei.liu2@citrix.com>
Message-id: 1459866012-27081-1-git-send-email-wei.liu2@citrix.com

9 years agoqemu: Explicitly check for gnutls_rnd()
Andrea Bolognani [Thu, 7 Apr 2016 11:48:48 +0000 (13:48 +0200)]
qemu: Explicitly check for gnutls_rnd()

Our use of gnutls_rnd(), introduced with commit ad7520e8, is
conditional to the availability of the <gnutls/crypto.h> header
file.

Such check, however, turns out not to be strict enough, as there
are some versions of GnuTLS (eg. 2.8.5 from CentOS 6) that provide
the header file, but not the function itself, which was introduced
only in GnuTLS 2.12.0.

Introduce an explicit check for the function.

9 years agoconfigure: Always use old_CFLAGS and old_LIBS
Andrea Bolognani [Thu, 7 Apr 2016 13:04:42 +0000 (15:04 +0200)]
configure: Always use old_CFLAGS and old_LIBS

The variables used for storing CFLAGS and LIBS before temporarily
modifying them was consistent when it comes to the name, but not
when it comes to the case.

Make sure names are completely consistent.

9 years agoconfigure: Restore CFLAGS properly after GnuTLS checks
Andrea Bolognani [Thu, 7 Apr 2016 13:00:42 +0000 (15:00 +0200)]
configure: Restore CFLAGS properly after GnuTLS checks

The previous value of CFLAGS was saved as old_cflags but later
restored from old_CFLAGS, which is clearly not correct.

Restore CFLAGS from the right variable.

9 years agohost-validate: Improve CPU flags processing
Andrea Bolognani [Tue, 29 Mar 2016 14:38:28 +0000 (16:38 +0200)]
host-validate: Improve CPU flags processing

Instead of relying on substring search, tokenize the input
and process each CPU flag separately. This ensures CPU flag
detection will continue to work correctly even if we start
looking for CPU flags whose name might appear as part of
other CPU flags' names.

The result of processing is stored in a virBitmap, which
means we don't have to parse /proc/cpuinfo in its entirety
for each single CPU flag we want to check.

Moreover, use of the newly-introduced virHostValidateCPUFlag
enumeration ensures we don't go looking for random CPU flags
which might actually be simple typos.

9 years agovz: support boot order in domain xml dump
Nikolay Shirokovskiy [Tue, 22 Mar 2016 13:56:38 +0000 (16:56 +0300)]
vz: support boot order in domain xml dump

As usual we try to deal correctly with vz domains that were
created by other means and thus can have all range of SDK domain
parameters. If vz domain boot order can't be represented
in libvirt os boot section let's give warning and make os boot section
represent SDK to some extent.

1. Os boot section supports up to 4 boot devices. Here we just
cut SDK boot order up to this limit. Not too bad.

2. If there is a floppy in boot order let's just skip it.
Anyway we don't show it in the xml. Not too bad too.

3. SDK boot order with unsupported disks order. Say we have "hdb, hda" in
SDK. We can not present this thru os boot order. Well let's just
give warning but leave double <boot dev='hd'/> in xml. It's
kind of misleading but we warn you!

SDK boot order have an extra parameters 'inUse' and 'sequenceIndex'
which makes our task more complicated. In realitly however 'inUse'
is always on and 'sequenceIndex' is not less than 'boot position index'
which simplifies out task back again! To be on a safe side let's explicitly
check for this conditions!

We have another exercise here. We want to check for unrepresentable
condition 3 (see above). The tricky part is that in contrast to
domains defined thru this driver 3-rd party defined domains can
have device ordering different from default. Thus we need
some id to check that N-th boot disk of os boot section is same as
N-th boot disk of SDK boot. This is what prlsdkBootOrderCheck
for. It uses disks sources paths as id for disks and iface names
for network devices.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
9 years agovz: fix disk order on load domain
Nikolay Shirokovskiy [Tue, 22 Mar 2016 13:56:37 +0000 (16:56 +0300)]
vz: fix disk order on load domain

We want to report boot order in dumpxml for vz domains.
Thus we want disks devices to be sorted in output compatible with boot
ordering specification. So let's just use virDomainDiskInsert
which makes appropriate sorting.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
9 years agovz: support boot order specification on define domain
Nikolay Shirokovskiy [Tue, 22 Mar 2016 13:56:36 +0000 (16:56 +0300)]
vz: support boot order specification on define domain

The patch makes some refactoring of the existing code. Current boot order spec code
makes very simple thing in somewhat obscure way. In case of VMs
it sets the first hdd as the only bootable device. In case of CTs it
doesn't touch the boot order at all if one of the filesystems is mounted to root.
Otherwise like in case of VMs it sets the first hdd as the only bootable
device and additionally sets this device mount point to root. Refactored
code makes all this explicit.

The actual boot order support is simple. Common libvirt domain xml parsing
code makes the exact ordering of disks devices as described in docs
for boot ordering (disks are sorted by bus order first, device target
second. Bus order is the order of disk buses appearence in original
xml. Device targets order is alphabetical). We add devices in the
same order and SDK designates device indexes sequentially for each
device type. Thus device index is equal to its boot index. For
example N-th cdrom in boot specification refers to sdk cdrom with
it's device index N.

If there is no boot spec in xml the parsing code will add <boot dev='hdd'>
for HVMs automatically and we backward compatibly set fist hdd as
bootable.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Signed-off-by: Maxim Nestratov <mnestratov@virtuozzo.com>
9 years agoqemu: perf: Fix crash/memory corruption on failed VM start
Peter Krempa [Thu, 7 Apr 2016 10:50:15 +0000 (12:50 +0200)]
qemu: perf: Fix crash/memory corruption on failed VM start

The new perf code didn't bother to clear a pointer in 'priv' causing a
double free or other memory corruption goodness if a VM failed to start.

Clear the pointer after freeing the memory.

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

9 years agoqemu: alias: Fix calculation of memory device aliases
Peter Krempa [Wed, 6 Apr 2016 15:32:12 +0000 (17:32 +0200)]
qemu: alias: Fix calculation of memory device aliases

For device hotplug, the new alias ID needs to be checked in the list
rather than using the count of devices. Unplugging a device that is not
last in the array will make further hotplug impossible due to alias
collision.

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

9 years agoqemu: alias: Fix calculation of RNG device aliases
Peter Krempa [Wed, 6 Apr 2016 15:32:12 +0000 (17:32 +0200)]
qemu: alias: Fix calculation of RNG device aliases

For device hotplug, the new alias ID needs to be checked in the list
rather than using the count of devices. Unplugging a device that is not
last in the array will make further hotplug impossible due to alias
collision.

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

9 years agosecret: Introduce virSecretGetSecretString
John Ferlan [Mon, 4 Apr 2016 17:31:29 +0000 (13:31 -0400)]
secret: Introduce virSecretGetSecretString

Commit id 'fb2bd208' essentially copied the qemuGetSecretString
creating an libxlGetSecretString.  Rather than have multiple copies
of the same code, create src/secret/secret_util.{c,h} files and
place the common function in there.

Modify the the build in order to build the module as a library
which is then pulled in by both the qemu and libxl drivers for
usage from both qemu_command.c and libxl_conf.c

9 years agoqemu: Introduce qemuBuildMasterKeyCommandLine
John Ferlan [Tue, 29 Mar 2016 22:23:02 +0000 (18:23 -0400)]
qemu: Introduce qemuBuildMasterKeyCommandLine

If the -object secret capability exists, then get the path to the
masterKey file and provide that to qemu. Checking for the existence
of the file before passing to qemu could be done, but causes issues
in mock test environment.

Since the qemuDomainObjPrivate is not available when building the
command line, the qemuBuildHasMasterKey API will have to suffice
as the primary arbiter for whether the capability exists in order
to find/return the path to the master key for usage.

Created the qemuDomainGetMasterKeyAlias API which will be used by
later patches to define the 'keyid' (eg, masterKey) to be used by
other secrets to provide the id to qemu for the master key.

9 years agoqemu: Create domain master key
John Ferlan [Tue, 29 Mar 2016 22:22:46 +0000 (18:22 -0400)]
qemu: Create domain master key

Add a masterKey and masterKeyLen to _qemuDomainObjPrivate to store a
random domain master key and its length in order to support the ability
to encrypt/decrypt sensitive data shared between libvirt and qemu. The
key will be base64 encoded and written to a file to be used by the
command line building code to share with qemu.

New API's from this patch:

  qemuDomainGetMasterKeyFilePath:
    Return a path to where the key is located

  qemuDomainWriteMasterKeyFile: (private)
    Open (create/trunc) the masterKey path and write the masterKey

  qemuDomainMasterKeyReadFile:
    Using the master key path, open/read the file, and store the
    masterKey and masterKeyLen. Expected use only from qemuProcessReconnect

  qemuDomainGenerateRandomKey: (private)
    Generate a random key using available algorithms

    The key is generated either from the gnutls_rnd function if it
    exists or a less cryptographically strong mechanism using
    virGenerateRandomBytes

   qemuDomainMasterKeyRemove:
    Remove traces of the master key, remove the *KeyFilePath

  qemuDomainMasterKeyCreate:
    Generate the domain master key and save the key in the location
    returned by qemuDomainGetMasterKeyFilePath.

    This API will first ensure the QEMU_CAPS_OBJECT_SECRET is set
    in the capabilities. If not, then there's no need to generate
    the secret or file.

The creation of the key will be attempted from qemuProcessPrepareHost
once the libDir directory structure exists.

The removal of the key will handled from qemuProcessStop just prior
to deleting the libDir tree.

Since the key will not be written out to the domain object XML file,
the qemuProcessReconnect will read the saved file and restore the
masterKey and masterKeyLen.

9 years agoutil: Introduce virRandomBytes
John Ferlan [Tue, 29 Mar 2016 22:15:33 +0000 (18:15 -0400)]
util: Introduce virRandomBytes

Using the existing virUUIDGenerateRandomBytes, move API to virrandom.c
rename it to virRandomBytes and add it to libvirt_private.syms.

This will be used as a fallback for generating a domain master key.

9 years agoqemu: Add capability bit for qemu secret object
John Ferlan [Mon, 21 Mar 2016 15:49:12 +0000 (11:49 -0400)]
qemu: Add capability bit for qemu secret object

Add a capability bit for the qemu secret object.

Adjust the 2.6.0-1 caps/replies to add the secret object. For the
.replies it's take from the '{"execute":"qom-list-types"}' output.

9 years agoqemu: Tear down the cgroup before reattach device to host
John Ferlan [Mon, 28 Mar 2016 11:40:57 +0000 (07:40 -0400)]
qemu: Tear down the cgroup before reattach device to host

When a hostdev is attached to the guest (and removed from the host),
the order of operations is call qemuHostdevPreparePCIDevices to remove
the device from the host, call qemuSetupHostdevCgroup to setup the cgroups,
and virSecurityManagerSetHostdevLabel to set the labels.

When the device is removed from the guest, the code didn't use the
reverse order leading to possible issues (especially if the path to
the device no longer exists). This patch will move the call to
qemuTeardownHostdevCgroup to prior to reattaching the device to
the host.

9 years agoqemu: Restore label before reattach device to host
John Ferlan [Mon, 28 Mar 2016 11:34:03 +0000 (07:34 -0400)]
qemu: Restore label before reattach device to host

When a hostdev is attached to the guest (and removed from the host),
the order of operations is call qemuHostdevPreparePCIDevices to remove
the device from the host, call qemuSetupHostdevCgroup to setup the cgroups,
and virSecurityManagerSetHostdevLabel to set the labels.

When the device is removed from the guest, the code didn't use the
reverse order leading to possible issues (especially if the path to
the device no longer exists). This patch will move the call to
virSecurityManagerRestoreHostdevLabel to prior to reattaching the
device to the host.

9 years agoLink libvirt_xenconfig instead of libvirt against libxl
Guido Günther [Thu, 31 Mar 2016 12:57:24 +0000 (14:57 +0200)]
Link libvirt_xenconfig instead of libvirt against libxl

to avoid the test failure

 7) Test driver "xen"  ... 2016-03-31 12:53:26.950+0000: 22430: debug : virDriverLoadModule:54 : Module load xen
 2016-03-31 12:53:26.950+0000: 22430: error : virDriverLoadModule:73 : failed to load module /build/libvirt-1.3.3~rc1/debian/build/src/.libs/libvirt_driver_xen.so /build/libvirt-1.3.3~rc1/debian/build/src/.libs/libvirt_driver_xen.so: undefined symbol: xlu_cfg_destroy
FAILED

9 years agovirt-admin: get rid of LIBVIRT_DEFAULT_ADMIN_URI env var
Ján Tomko [Wed, 6 Apr 2016 12:57:21 +0000 (14:57 +0200)]
virt-admin: get rid of LIBVIRT_DEFAULT_ADMIN_URI env var

There is a LIBVIRT_ADMIN_DEFAULT_URI environment variable
which is honored by virAdmConnectOpen and documented
in the virt-admin man page.

LIBVIRT_DEFAULT_ADMIN_URI is undocumented and this is its
only occurrence.

9 years agolibvirt-admin: do not crash on URI without a scheme
Ján Tomko [Wed, 6 Apr 2016 08:43:39 +0000 (10:43 +0200)]
libvirt-admin: do not crash on URI without a scheme

9 years agotools: remove unnecessary defaultConn variable
Ján Tomko [Wed, 6 Apr 2016 08:42:02 +0000 (10:42 +0200)]
tools: remove unnecessary defaultConn variable

vshStrdup returns NULL without exiting on NULL input.

9 years agovirsh: read default connection uri from env later
Ján Tomko [Wed, 6 Apr 2016 08:08:55 +0000 (10:08 +0200)]
virsh: read default connection uri from env later

Postpone filling out the default connection in ctl->connname
after calling virshInit.

This allows printing help without a connection to the daemon.

9 years agospec: Include KVM support on RHEL 7 ppc64 and newer
Andrea Bolognani [Thu, 17 Mar 2016 10:00:54 +0000 (11:00 +0100)]
spec: Include KVM support on RHEL 7 ppc64 and newer

9 years agoconf: store bootindex as unsigned int
Peter Krempa [Tue, 29 Mar 2016 12:31:37 +0000 (14:31 +0200)]
conf: store bootindex as unsigned int

The value is never negative thus there's no need to store it in a signed
type.