]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
6 years agonwfilter: fix adding std MAC and IP values to filter binding
Nikolay Shirokovskiy [Wed, 20 Mar 2019 13:05:59 +0000 (16:05 +0300)]
nwfilter: fix adding std MAC and IP values to filter binding

Commit d1a7c08eb changed filter instantiation code to ignore MAC and IP
variables explicitly specified for filter binding. It just replaces
explicit values with values associated with the binding. Before the
commit virNWFilterCreateVarsFrom was used so that explicit value
take precedence. Let's bring old behavior back.

This is useful. For example if domain has two interfaces it makes
sense to list both mac adresses in MAC var of every interface
filterref. So that if guest make a bond of these interfaces
and start sending frames with one of the mac adresses from
both interfaces we can pass outgress traffic from both
interfaces too.

Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
6 years agosnapshot: Make virDomainSnapshotObjList use MomentObjList
Eric Blake [Fri, 22 Mar 2019 05:46:57 +0000 (00:46 -0500)]
snapshot: Make virDomainSnapshotObjList use MomentObjList

Now that the generic moment code does pretty much everything that both
snapshots and checkpoints will need, it's time to replace the
now-duplicate code in virdomainsnapshotobjlist.c with simpler calls
into the generic code. I considered using sub-classing (a
'virDomainMomentObjList parent;' member, but that requires making the
opaque type visible in headers; so for now, I stuck with a container
instead (a 'virDomainMomentObjListPtr base;' member).

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agosnapshot: Create new virDomainMomentObjList type
Eric Blake [Fri, 22 Mar 2019 05:39:02 +0000 (00:39 -0500)]
snapshot: Create new virDomainMomentObjList type

The new code here very heavily resembles the code in
virDomainSnapshotObjList. There are still a couple of spots that are
tied a little too heavily to snapshots (the free function lacks a
polymorphic cleanup until we refactor code to use virObject; and an
upcoming patch will add internal VIR_DOMAIN_MOMENT_LIST flags to
replace the snapshot flag bits), but in general this is fairly close
to the state needed to add checkpoint lists.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agosnapshot: Rename file for virDomainMomentObj
Eric Blake [Fri, 22 Mar 2019 04:46:26 +0000 (23:46 -0500)]
snapshot: Rename file for virDomainMomentObj

Now that we have made virDomainMomentObj sufficiently generic to
support both snapshots and checkpoints, it is time to rename the file
that it lives in. The split between a generic object and a list of the
generic objects doesn't buy us as much, so it will be easier to stick
all the moment list code in one file, with more code moving in the
next patch.  The changes during the move are fairly minor, although it
is worth pointing out that the log/error messages for the new file
report that they are from "domain", since the file will eventually be
shared by both "domain snapshot" and "domain checkpoint".

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agosnapshot: Rename virDomainSnapshotObjPtr
Eric Blake [Fri, 22 Mar 2019 04:45:25 +0000 (23:45 -0500)]
snapshot: Rename virDomainSnapshotObjPtr

Now that the core of SnapshotObj is agnostic to snapshots and can be
shared with upcoming checkpoint code, it is time to rename the struct
and the functions specific to list operations. A later patch will
shuffle which file holds the common code. This is a fairly mechanical
patch.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agosnapshot: Switch type of virDomainSnapshotObj.def
Eric Blake [Fri, 22 Mar 2019 04:44:33 +0000 (23:44 -0500)]
snapshot: Switch type of virDomainSnapshotObj.def

Another step towards making the object list reusable for both
snapshots and checkpoints: the list code only ever needs items that
are in the common virDomainMomentDef base type. This undoes a lot of
the churn in accessing common members added in the previous patch, and
the bulk of the patch is mechanical. But there was one spot where I
had to unroll a VIR_STEAL_PTR to work around changed types.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agosnapshot: Factor out virDomainMomentDef class
Eric Blake [Fri, 22 Mar 2019 02:02:19 +0000 (21:02 -0500)]
snapshot: Factor out virDomainMomentDef class

Pull out the common parts of virDomainSnapshotDef that will be reused
for virDomainCheckpointDef into a new base class.  Adjust all callers
that use the direct fields (some of it is churn that disappears when
the next patch refactors virDomainSnapshotObj; oh well...).

Someday, I hope to switch this type to be a subclass of virObject, but
that requires a more thorough audit of cleanup paths, and besides
minimal incremental changes are easier to review.

As for the choice of naming:
I promised my teenage daughter Evelyn that I'd give her credit for her
contribution to this commit. I asked her "What would be a good name
for a base class for DomainSnapshot and DomainCheckpoint". After
explaining what a base class was (using the classic OOB Square and
Circle inherit from Shape), she came up with "DomainMoment", which is
way better than my initial thought of "DomainPointInTime" or
"DomainPIT".

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agosnapshot: Refactor list filtering
Eric Blake [Wed, 20 Mar 2019 02:33:23 +0000 (21:33 -0500)]
snapshot: Refactor list filtering

Separate the algorithm for which list members to vist (which is
generic and can be shared with checkpoints, provided that common
filtering bits are either declared with the same value or have a
mapping from public API to common value) from the decision on which
members to return (which is specific to snapshots).  The typedef for
the callback function feels a bit heavy here, but will make it easier
to move the common portions in a later patch.

As part of the refactoring, note that the macros for selecting filter
bits are specific to listing functionality, so they belong better in
virdomainsnapshotobjlist.h (missed in commit 9b75154c).

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agosnapshot: Access snapshot def directly when needed
Eric Blake [Mon, 18 Mar 2019 21:13:50 +0000 (16:13 -0500)]
snapshot: Access snapshot def directly when needed

An upcoming patch will rework virDomainSnapshotObjList to be generic
for both snapshots and checkpoints; reduce the churn by adding a new
accessor virDomainSnapshotObjGetDef() which returns the
snapshot-specific definition even when the list is rewritten to
operate only on a base class, then using it at sites that that are
specific to snapshots.  Use VIR_STEAL_PTR when appropriate in the
affected lines.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agosnapshot: Add accessors for updating snapshot list relations
Eric Blake [Sun, 17 Mar 2019 03:38:33 +0000 (22:38 -0500)]
snapshot: Add accessors for updating snapshot list relations

Rather than allowing a leaky abstraction where multiple drivers have
to open-code operations that update the relations in a
virDomainSnapshotObjList, it is better to add accessor functions so
that updates to relations are maintained closer to the internals.
This patch finishes the job started in the previous patch, by getting
rid of all direct access to nchildren, first_child, or sibling outside
of the lowest level functions, making it easier to refactor later on.

The lone new caller to virDomainSnapshotObjListSize() checks for a
return != 0, because it wants to handles errors (-1, only possible if
the hash table wasn't allocated) and existing snapshots (> 0) in the
same manner; we can drop the check for a current snapshot on the
grounds that there shouldn't be one if there are no snapshots.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agosnapshot: Add accessor for reparenting snapshot children
Eric Blake [Thu, 21 Mar 2019 20:33:21 +0000 (15:33 -0500)]
snapshot: Add accessor for reparenting snapshot children

Rather than allowing a leaky abstraction where multiple drivers have
to open-code operations that update the relations in a
virDomainSnapshotObjList, it is better to add accessor functions so
that updates to relations are maintained closer to the internals.
This patch starts the task with a single new function:
virDomainSnapshotMoveChildren(). The logic might not be immediately
obvious [okay, that's an understatement - the existing code uses black
magic ;-)], so here's an overview: The old code has an implicit for
loop around each call to qemuDomainSnapshotReparentChildren() by using
virDomainSnapshotForEachChild() (you'll need a wider context than
git's default of 3 lines to see that); the new code has a more visible
for loop. Then it helps if you realize that the code is making two
separate changes to each child object: STRDUP of the new parent name
prior to writing XML files (unchanged), and touching up the pointer to
the parent object (refactored); the end result is the same whether a
single pass made both changes (both in driver code), or whether it is
split into two passes making one change each (one in driver code, the
other in the new accessor).

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agosnapshot: Track current snapshot in virDomainSnapshotObjList
Eric Blake [Thu, 21 Mar 2019 20:00:08 +0000 (15:00 -0500)]
snapshot: Track current snapshot in virDomainSnapshotObjList

It is easier to track the current snapshot as part of the list of
snapshots. In particular, doing so lets us guarantee that the current
snapshot is cleared if that snapshot is removed from the list (rather
than depending on the caller to do so, and risking a use-after-free
problem, such as the one recently patched in 1db9d0efbf).  This
requires the addition of several new accessor functions, as well as a
useful return type for virDomainSnapshotObjListRemove().  A few error
handling sites that were previously setting vm->current_snapshot =
NULL can now be dropped, because the previous function call has now
done it already.  Also, qemuDomainRevertToSnapshot() was setting the
current vm twice, so keep only the one used on the success path.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agosnapshot: Rework parse logic during libvirt startup
Eric Blake [Thu, 21 Mar 2019 17:16:03 +0000 (12:16 -0500)]
snapshot: Rework parse logic during libvirt startup

Rework the logic in qemuDomainSnapshotLoad() to set
vm->current_snapshot only once at the end of the loop, rather than
repeatedly querying it during the loop, to make it easier for the next
patch to use accessor functions rather than direct manipulation of
vm->current_snapshot.  When encountering multiple snapshots claiming
to be current (based on the presence of an <active>1</active> element
in the XML, which libvirt only outputs for internal use and not for
any public API), this changes behavior from warning only once and
running with no current snapshot, to instead warning on each duplicate
and selecting the last one encountered (which is arbitrary based on
readdir() ordering, but actually stands a fair chance of being the
most-recently created snapshot whether by timestamp or by the
propensity of humans to name things in ascending order).

Note that the code in question is only run by libvirtd when it first
starts, reading state from disk from the previous run into memory for
this run. Since the data resides somewhere that only libvirt should be
touching (typically /var/lib/libvirt/qemu/snapshot/*), it should be
clean.  So in the common case, the code touched here is unreachable.
But if someone is actually messing with files behind libvirt's back,
they deserve the change in behavior.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agosnapshot: Drop virDomainSnapshotDef.current
Eric Blake [Tue, 19 Mar 2019 03:56:19 +0000 (22:56 -0500)]
snapshot: Drop virDomainSnapshotDef.current

The only use for the 'current' member of virDomainSnapshotDef was with
the PARSE/FORMAT_INTERNAL flag for controlling an internal-use
<active> element marking whether a particular snapshot definition was
current, and even then, only by the qemu driver on output, and by qemu
and test driver on input. But this duplicates vm->snapshot_current,
and gets in the way of potential simplifications to have qemu store a
single file for all snapshots rather than one file per snapshot.  Get
rid of the member by adding a bool* parameter during parse (ignored if
the PARSE_INTERNAL flag is not set), and by adding a new flag during
format (if FORMAT_INTERNAL is set, the value printed in <active>
depends on the new FORMAT_CURRENT).

Then update the qemu driver accordingly, which involves hoisting
assignments to vm->current_snapshot to occur prior to any point where
a snapshot XML file is written (although qemu kept
vm->current_snapshot and snapshot->def_current in sync by the end of
the function, they were not always identical in the middle of
functions, so the shuffling gets a bit interesting). Later patches
will clean up some of that confusing churn to vm->current_snapshot.

Note: even if later patches refactor qemu to no longer use
FORMAT_INTERNAL for output (by storing bulk snapshot XML instead), we
will always need PARSE_INTERNAL for input (because on upgrade, a new
libvirt still has to parse XML left from a previous libvirt).

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agosnapshot: Minor cleanup to virDomainSnapshotAssignDef
Eric Blake [Fri, 22 Mar 2019 06:05:06 +0000 (01:05 -0500)]
snapshot: Minor cleanup to virDomainSnapshotAssignDef

When a future patch converts virDomainSnapshotDef to be a virObject,
we need to be careful that converting VIR_FREE() to virObjectUnref()
does not result in double frees. Reorder the assignment of def into
the object to the point after object is in the hash table (as
otherwise the virHashAddEntry() error path would have a shot at
freeing def prematurely).

Suggested-by: John Ferlan <ferlan@redhat.com>
Signed-off-by: Eric Blake <eblake@redhat.com>
6 years agosnapshot: Tweaks to bulk dumpxml/import internals
Eric Blake [Mon, 11 Mar 2019 11:50:23 +0000 (06:50 -0500)]
snapshot: Tweaks to bulk dumpxml/import internals

Change the return value of virDomainSnapshotObjListParse() to return
the number of snapshots imported, and allow a return of 0 (the
original proposal of adding a flag to virDomainSnapshotCreateXML
required returning an arbitrary non-NULL snapshot, but that idea was
abandoned; and by returning a count, we are no longer constrained to a
non-empty list).

Document which flags are supported (namely, just SECURE) in
virDomainSnapshotObjListFormat().

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agovbox: Clean up some snapshot usage
Eric Blake [Thu, 21 Mar 2019 16:41:26 +0000 (11:41 -0500)]
vbox: Clean up some snapshot usage

An upcoming patch will be reworking virDomainSnapshotDef to have a
base class; minimize the churn by using a local variable to reduce the
number of dereferences required when acessing the domain definition
associated with the snapshot.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agotests: qemuxml2argv: move DO_TEST qemuCaps init
Cole Robinson [Thu, 14 Mar 2019 10:19:28 +0000 (06:19 -0400)]
tests: qemuxml2argv: move DO_TEST qemuCaps init

Move DO_TEST* qemuCaps init into testInfoSetArgs. This is a step
towards unifying the different test macro implementations

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agotests: qemuxml2argv: add testInfoClear
Cole Robinson [Thu, 14 Mar 2019 09:54:00 +0000 (05:54 -0400)]
tests: qemuxml2argv: add testInfoClear

This is closer to the pattern of qemuxml2xml tests, and will make
things easier if we extend testInfo to contain more freeable data

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agotests: qemuxml2argv: build capsfile in DO_TEST_CAPS_INTERNAL
Cole Robinson [Wed, 13 Mar 2019 23:48:06 +0000 (19:48 -0400)]
tests: qemuxml2argv: build capsfile in DO_TEST_CAPS_INTERNAL

Rather than make callers do it. The operative info is just arch
and ver which we are passing in already.

Fold in stripmachinealiases too since it is just dependent on
ver value

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agotests: qemuxml2argv: centralize CAPS suffix building
Cole Robinson [Wed, 13 Mar 2019 23:32:31 +0000 (19:32 -0400)]
tests: qemuxml2argv: centralize CAPS suffix building

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agotests: qemuxml2argv: remove full testInfo initialization
Cole Robinson [Wed, 13 Mar 2019 23:26:08 +0000 (19:26 -0400)]
tests: qemuxml2argv: remove full testInfo initialization

Only initialize the fields that are passed in

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agotests: qemuxml2argv: use varargs for CAPS flags
Cole Robinson [Wed, 13 Mar 2019 23:15:05 +0000 (19:15 -0400)]
tests: qemuxml2argv: use varargs for CAPS flags

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agotests: qemuxml2argv: remove unused CAPS migrateFrom
Cole Robinson [Wed, 13 Mar 2019 22:16:55 +0000 (18:16 -0400)]
tests: qemuxml2argv: remove unused CAPS migrateFrom

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agotests: qemuxml2argv: add a comment separating DO_TEST* macros
Cole Robinson [Thu, 14 Mar 2019 13:43:23 +0000 (09:43 -0400)]
tests: qemuxml2argv: add a comment separating DO_TEST* macros

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agotests: qemuxml2argv: remove unused DO_TEST_CAPS* macros
Cole Robinson [Thu, 14 Mar 2019 13:41:58 +0000 (09:41 -0400)]
tests: qemuxml2argv: remove unused DO_TEST_CAPS* macros

They are potentially useful at the moment, but we will be making
things much more flexible

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agotests: qemuxml2argv: remove DO_TEST_PARSE_FLAGS_ERROR
Cole Robinson [Wed, 13 Mar 2019 21:25:23 +0000 (17:25 -0400)]
tests: qemuxml2argv: remove DO_TEST_PARSE_FLAGS_ERROR

It only has one caller. Just use DO_TEST_FULL

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agotests: qemuxml2argv: handle parseFlags with varargs
Cole Robinson [Wed, 13 Mar 2019 20:17:10 +0000 (16:17 -0400)]
tests: qemuxml2argv: handle parseFlags with varargs

This allows us to drop parseFlags from DO_TEST_FULL

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agotests: qemuxml2argv: handle flags with varargs
Cole Robinson [Wed, 13 Mar 2019 20:04:44 +0000 (16:04 -0400)]
tests: qemuxml2argv: handle flags with varargs

This allows us to drop flags from DO_TEST_FULL

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agotests: qemuxml2argv: handle migrate* with varargs
Cole Robinson [Wed, 13 Mar 2019 19:59:42 +0000 (15:59 -0400)]
tests: qemuxml2argv: handle migrate* with varargs

This allows us to drop migrateFrom and migrateFd from DO_TEST_FULL

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agotests: qemuxml2argv: handle GIC with varargs
Cole Robinson [Wed, 13 Mar 2019 19:49:18 +0000 (15:49 -0400)]
tests: qemuxml2argv: handle GIC with varargs

This allows us to drop stub GIC values from DO_TEST_FULL calls

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agotests: qemuxml2argv: break apart testInitQEMUCaps
Cole Robinson [Wed, 13 Mar 2019 19:31:16 +0000 (15:31 -0400)]
tests: qemuxml2argv: break apart testInitQEMUCaps

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agotests: qemuxml2argv: push ARG_QEMU_CAPS to callers
Cole Robinson [Wed, 13 Mar 2019 19:18:11 +0000 (15:18 -0400)]
tests: qemuxml2argv: push ARG_QEMU_CAPS to callers

This is necessary before we can start adding more optional parameter
implementations to DO_TEST_FULL

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agotests: qemuxml2argv: add va_arg enum handling
Cole Robinson [Wed, 13 Mar 2019 22:25:21 +0000 (18:25 -0400)]
tests: qemuxml2argv: add va_arg enum handling

This establishes a pattern that will allow us to make test macros
more general purpose, by taking optional arguments. The general
format will be:

DO_TEST_FULL(...
             ARG_FOO, <value1>,
             ARG_BAR, <value2>)

ARG_X are just enum values that we look for in the va_args and know
how to interpret.

Implement this for the existing implicit qemuCaps va_args

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agotests: qemuxml2argv: add testInfoSetArgs
Cole Robinson [Wed, 13 Mar 2019 22:20:57 +0000 (18:20 -0400)]
tests: qemuxml2argv: add testInfoSetArgs

For now it just fills in the qemuCaps list. We will expand it
in future patches

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoqemu: add virQEMUCapsSetVAList
Cole Robinson [Wed, 13 Mar 2019 19:03:45 +0000 (15:03 -0400)]
qemu: add virQEMUCapsSetVAList

And adjust virQEMUCapsSetList to use it. It will also be used in future
patches.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agotest: Avoid use-after-free on virDomainSnapshotDelete
Eric Blake [Sun, 17 Mar 2019 03:57:45 +0000 (22:57 -0500)]
test: Avoid use-after-free on virDomainSnapshotDelete

The following virsh command was triggering a use-after-free:

$ virsh -c test:///default '
  snapshot-create-as test s1
  snapshot-create-as test s2
  snapshot-delete --children-only test s1
  snapshot-current --name test'
Domain snapshot s1 created
Domain snapshot s2 created
Domain snapshot s1 children deleted

error: name in virGetDomainSnapshot must not be NULL

I got lucky on that run - although the error message is quite
unexpected.  On other runs, I was able to get a core dump, and
valgrind confirms there is a definitive problem.

The culprit? We were inconsistent about whether we set
vm->current_snapshot, snap->def->current, or both when updating how
the current snapshot was being tracked.  As a result, deletion did not
see that snapshot s2 was previously current, and failed to update
vm->current_snapshot, so that the next API using the current snapshot
failed because it referenced stale memory for the now-gone s2 (instead
of the intended s1).

The test driver code was copied from the qemu code (which DOES track
both pieces of state everywhere), but was purposefully simplified
because the test driver does not have to write persistent snapshot
state to the file system.  But when you realize that the only reason
snap->def->current needs to exist is when writing out one file per
snapshot for qemu, it's just as easy to state that the test driver
never has to mess with the field (rather than chasing down which
places forgot to set the field), and have vm->current_snapshot be the
sole source of truth in the test driver.

Ideally, I'd get rid of the 'current' member in virDomainSnapshotDef,
as well as the 'current_snapshot' member in virDomainDef, and instead
track the current member in virDomainSnapshotObjList, coupled with
writing ALL snapshot state for qemu in a single file (where I can use
<snapshots current='...'> as a wrapper, rather than
VIR_DOMAIN_SNAPSHOT_FORMAT_INTERNAL to output <current>1</current> XML
on a per-snapshot file basis).  But that's a bigger change, so for now
I'm just patching things to avoid the test driver segfault.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agorpm: fix upgrades when RBD is disabled in a new version
Daniel P. Berrangé [Tue, 19 Mar 2019 15:59:36 +0000 (15:59 +0000)]
rpm: fix upgrades when RBD is disabled in a new version

We previously had to disable RBD on 32-bit platforms since Ceph has
dropped all support for 32-bit. Unfortunately anyone with the RPM
libvirt-daemon-driver-storage-rbd installed on 32-bit now has a
broken upgrade path.

To fix this we must make libvirt-daemon-driver-storage-core
have an Obsoletes: libvirt-daemon-driver-storage-rbd < $VER-$REL

Reviewed-by: Erik Skultety <eskultet@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agovirnwfilterbindingobj: Introduce and use virNWFilterBindingObjStealDef
Michal Privoznik [Wed, 20 Mar 2019 08:59:48 +0000 (09:59 +0100)]
virnwfilterbindingobj: Introduce and use virNWFilterBindingObjStealDef

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

When trying to create a nwfilter binding via
nwfilterBindingCreateXML() we may encounter a crash. The sequence
of functions called is as follows:

1) nwfilterBindingCreateXML() parses the XML and calls
virNWFilterBindingObjListAdd() which calls
virNWFilterBindingObjListAddLocked()

2) Here, @binding is not found because binding->remove is set.

3) Therefore, controls continue with creating new @binding,
setting its def to the one from 1) and adding it to the hash
table.

4) This fails, because the binding is still in the hash table
(duplicate key is detected).

5) The control jumps to 'error' label where
virNWFilterBindingObjEndAPI() is called which frees the binding
definition passed.

6) Error is propagated to the caller, which calls
virNWFilterBindingDefFree() over the definition again.

The solution is to unset binding->def in case of failure so it's
not freed in step 5).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Fold private data parsing into virDomainStorageSourceParse
Peter Krempa [Fri, 15 Mar 2019 15:33:38 +0000 (16:33 +0100)]
conf: Fold private data parsing into virDomainStorageSourceParse

Storage source private data can be parsed along with other components of
private data rather than a separate function which is called from
multiple places.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Simplify error paths in storage source component parsers
Peter Krempa [Fri, 8 Mar 2019 13:28:07 +0000 (14:28 +0100)]
conf: Simplify error paths in storage source component parsers

virDomainDiskSourcePrivateDataParse and virDomainDiskSourcePRParse don't
need the 'cleanup' label any more thanks to VIR_XPATH_NODE_AUTORESTORE.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Refactor control flow in virDomainDiskBackingStoreParse
Peter Krempa [Mon, 11 Mar 2019 15:10:35 +0000 (16:10 +0100)]
conf: Refactor control flow in virDomainDiskBackingStoreParse

The function does not have any code in the 'cleanup' label so we can
simplify the control flow.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: Refactor control flow in testBackingXMLjsonXML
Peter Krempa [Fri, 8 Mar 2019 15:11:20 +0000 (16:11 +0100)]
tests: Refactor control flow in testBackingXMLjsonXML

Get rid of the 'cleanup' label.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: Use full force of our VIR_AUTO* machinery in testBackingXMLjsonXML
Peter Krempa [Fri, 8 Mar 2019 15:10:07 +0000 (16:10 +0100)]
tests: Use full force of our VIR_AUTO* machinery in testBackingXMLjsonXML

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutil: xml: Introduce VIR_AUTOPTR functions for xmlDoc and xmlXPathContext
Peter Krempa [Fri, 8 Mar 2019 15:02:27 +0000 (16:02 +0100)]
util: xml: Introduce VIR_AUTOPTR functions for xmlDoc and xmlXPathContext

We can use our VIR_AUTOPTR machinery also for libxml2's xmlDoc and
xmlXPathContext.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: cleanup error path in virDomainStorageSourceParse
Peter Krempa [Fri, 8 Mar 2019 14:03:16 +0000 (15:03 +0100)]
conf: cleanup error path in virDomainStorageSourceParse

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Invert 'skipSeclabels' argument of virDomainDiskSourceFormatInternal
Peter Krempa [Wed, 6 Mar 2019 16:22:04 +0000 (17:22 +0100)]
conf: Invert 'skipSeclabels' argument of virDomainDiskSourceFormatInternal

Rename it to 'seclabels' and invert the value.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agovirStoragePoolDefParseSource: Don't leak @port
Michal Privoznik [Tue, 19 Mar 2019 16:35:21 +0000 (17:35 +0100)]
virStoragePoolDefParseSource: Don't leak @port

In a1c453dc088, during VIR_AUTOFREE() rewrite this wasn't done
properly. @port might be leaked because it's allocated in a for()
loop.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agovirStoragePoolDefFree: Free @def->refresh
Michal Privoznik [Tue, 19 Mar 2019 16:34:07 +0000 (17:34 +0100)]
virStoragePoolDefFree: Free @def->refresh

In 669018bc9cb I've introduced def->refresh which might be
allocated by virStoragePoolDefRefreshParse() but is never freed.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoconf: Drop unused variable
Andrea Bolognani [Tue, 19 Mar 2019 16:29:18 +0000 (17:29 +0100)]
conf: Drop unused variable

The refresh_volume_allocation variable in
virStoragePoolDefParseXML() has been unused since its
introduction in commit 669018bc9cb1, and Clang rightfully
complains about this fact.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
6 years agorbd: optionally compute volume allocation from capacity
Jason Dillaman [Tue, 19 Mar 2019 13:42:18 +0000 (09:42 -0400)]
rbd: optionally compute volume allocation from capacity

Use the new refresh volume allocation pool override to skip
computing the actual volume usage if disabled.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agostorage: optional 'refresh' elemement on pool
Jason Dillaman [Tue, 19 Mar 2019 13:42:17 +0000 (09:42 -0400)]
storage: optional 'refresh' elemement on pool

The new 'refresh' element can override the default refresh operations
for a storage pool. The only currently supported override is to set
the volume allocation size to the volume capacity. This can be specified
by adding the following snippet:

<pool>
...
  <refresh>
    <volume allocation='capacity'/>
  </refresh>
...
</pool>

This is useful for certain backends where computing the actual allocation
of a volume might be an expensive operation.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agorbd: do not attempt to use fast-diff if it's marked invalid
Jason Dillaman [Tue, 19 Mar 2019 13:42:16 +0000 (09:42 -0400)]
rbd: do not attempt to use fast-diff if it's marked invalid

The librbd API will transparently revert to a slow disk usage
calculation method if the fast-diff map is marked as invalid.

Signed-off-by: Jason Dillaman <dillaman@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agonetwork: avoid trying to create global firewall rules if unprivileged
Daniel P. Berrangé [Wed, 13 Mar 2019 16:21:15 +0000 (16:21 +0000)]
network: avoid trying to create global firewall rules if unprivileged

The unprivileged libvirtd does not have permission to create firewall
rules, or bridge devices, or do anything to the host network in
general. Historically we still activate the network driver though and
let the network start API call fail.

The startup code path which reloads firewall rules on active networks
would thus effectively be a no-op when unprivileged as it is impossible
for there to be any active networks

With the change to use a global set of firewall chains, however, we now
have code that is run unconditionally.

Ideally we would not register the network driver at all when
unprivileged, but the entanglement with the virt drivers currently makes
that impractical. As a temporary hack, we just make the firewall reload
into a no-op.

Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agonetwork: split setup of ipv4 and ipv6 top level chains
Daniel P. Berrangé [Mon, 18 Mar 2019 16:49:32 +0000 (16:49 +0000)]
network: split setup of ipv4 and ipv6 top level chains

During startup libvirtd creates top level chains for both ipv4
and ipv6 protocols. If this fails for any reason then startup
of virtual networks is blocked.

The default virtual network, however, only requires use of ipv4
and some servers have ipv6 disabled so it is expected that ipv6
chain creation will fail. There could equally be servers with
no ipv4, only ipv6.

This patch thus makes error reporting a little more fine grained
so that it works more sensibly when either ipv4 or ipv6 is
disabled on the server. Only the protocols that are actually
used by the virtual network have errors reported.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agonetwork: improve error report when firewall chain creation fails
Daniel P. Berrangé [Mon, 18 Mar 2019 17:31:21 +0000 (17:31 +0000)]
network: improve error report when firewall chain creation fails

During startup we create some top level chains in which all
virtual network firewall rules will be placed. The upfront
creation is done to avoid slowing down creation of individual
virtual networks by checking for chain existance every time.

There are some factors which can cause this upfront creation
to fail and while a message will get into the libvirtd log
this won't be seen by users who later try to start a virtual
network. Instead they'll just get a message saying that the
libvirt top level chain does not exist. This message is
accurate, but unhelpful for solving the root cause.

This patch thus saves any error during daemon startup and
reports it when trying to create a virtual network later.

Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agotests: domaincapstest: Fix build on mingw
Cole Robinson [Mon, 18 Mar 2019 16:40:03 +0000 (12:40 -0400)]
tests: domaincapstest: Fix build on mingw

fillStringValues is only used if WITH_QEMU || WITH_BHYVE

Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agostorage: add support for new rbd_list2 method
Daniel P. Berrangé [Mon, 18 Mar 2019 11:11:38 +0000 (11:11 +0000)]
storage: add support for new rbd_list2 method

The rbd_list method has been deprecated in Ceph >= 14.0.0
in favour of the new rbd_list2 method which populates an
array of structs.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agostorage: split off code for calling rbd_list
Daniel P. Berrangé [Mon, 18 Mar 2019 10:58:48 +0000 (10:58 +0000)]
storage: split off code for calling rbd_list

The rbd_list method has a quite unpleasant signature returning an
array of strings in a single buffer instead of an array. It is
being deprecated in favour of rbd_list2. To maintain clarity of
code when supporting both APIs in parallel, split the rbd_list
code out into a separate method.

In splitting this we now honour the rbd_list failures.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agodocs: formatdomaincaps: Describe optional XML changes
Cole Robinson [Wed, 6 Mar 2019 23:25:16 +0000 (18:25 -0500)]
docs: formatdomaincaps: Describe optional XML changes

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoconf: domcaps: Don't format XML on report=false
Cole Robinson [Wed, 6 Mar 2019 23:22:01 +0000 (18:22 -0500)]
conf: domcaps: Don't format XML on report=false

After this, newly added enums will not automatically show up in
driver output unless the driver code specifically sets report=true

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agobhyve: fill in virCapsEnum 'report'
Cole Robinson [Wed, 6 Mar 2019 23:20:09 +0000 (18:20 -0500)]
bhyve: fill in virCapsEnum 'report'

Set report=true for all enums currently formatted in the XML

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agolibxl: fill in virCapsEnum 'report'
Cole Robinson [Wed, 6 Mar 2019 23:20:58 +0000 (18:20 -0500)]
libxl: fill in virCapsEnum 'report'

Set report=true for all enums currently formatted in the XML

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoqemu: fill in virCapsEnum 'report'
Cole Robinson [Wed, 6 Mar 2019 23:21:45 +0000 (18:21 -0500)]
qemu: fill in virCapsEnum 'report'

Set report=true for all enums currently formatted in the XML

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoconf: domcaps: Add virCapsEnum 'report'
Cole Robinson [Wed, 6 Mar 2019 23:11:01 +0000 (18:11 -0500)]
conf: domcaps: Add virCapsEnum 'report'

virCapsEnum report is an internal bool indicating whether we
should format the enum in the XML at all. This is unused for
now but will be handled in future patches.

We use a plain bool instead of tristate because the case here
is a bit different than the explicit @supported output. We
already report the equivalent of supported=YES|NO based on
what enum values are filled in. This adds report=false to
handle the ABSENT case.

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoconf: domcaps: Don't output XML on tristate ABSENT
Cole Robinson [Tue, 19 Feb 2019 19:12:47 +0000 (14:12 -0500)]
conf: domcaps: Don't output XML on tristate ABSENT

Change domcaps to skip formatting XML if the default
TRISTATE_BOOL_ABSENT is found. Now when domcaps is extended, driver
XML output won't change until an explicit TRISTATE_BOOL value is set
in driver code.

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoschemas: domcaps: Make more elements optional
Cole Robinson [Sat, 9 Feb 2019 00:10:17 +0000 (19:10 -0500)]
schemas: domcaps: Make more elements optional

Upcoming changes will make outputting these subelements optional.

While we are here drop the useless interleave: since this is an output
only format the elements are always in the same order

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agobhyve: domcaps: fill in explicit supported BOOL_NO
Cole Robinson [Tue, 19 Feb 2019 19:28:52 +0000 (14:28 -0500)]
bhyve: domcaps: fill in explicit supported BOOL_NO

<hostdev> and <features> are not supported. <loader>, <graphics>,
and <video> are supported conditionally

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agolibxl: domcaps: fill in explicit supported BOOL_NO
Cole Robinson [Tue, 19 Feb 2019 19:22:23 +0000 (14:22 -0500)]
libxl: domcaps: fill in explicit supported BOOL_NO

None of the <feature> bits are supported, and the <loader> piece
is only conditionally supported

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoqemu: domcaps: fill in explicit supported BOOL_NO
Cole Robinson [Tue, 19 Feb 2019 19:15:06 +0000 (14:15 -0500)]
qemu: domcaps: fill in explicit supported BOOL_NO

Only gic->supported needs an explicit BOOL_NO setting, all other
'supported' values are handling things correctly

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoconf: domcaps: use virTristateBool for 'supported'
Cole Robinson [Fri, 8 Feb 2019 23:03:20 +0000 (18:03 -0500)]
conf: domcaps: use virTristateBool for 'supported'

Switch most 'supported' handling to use virTristateBool, so eventually
we can handle the ABSENT state.

For now the XML formatter treats ABSENT the same as FALSE, so there's
no functional output change. This will be addressed in later patches

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agoconf: domcaps: Add single line formatting macro
Cole Robinson [Fri, 8 Feb 2019 23:32:48 +0000 (18:32 -0500)]
conf: domcaps: Add single line formatting macro

Similar to the macros we have for formatting enums, add a macro to
simplify formatting the pattern:

  <FOO supported='yes|no'/>

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agotests: domcaps: Remove 'full' test
Cole Robinson [Tue, 19 Feb 2019 17:52:30 +0000 (12:52 -0500)]
tests: domcaps: Remove 'full' test

The 'full' test verifies the output of a virDomainCapsPtr built
by hand. It has the following problems:

The domcaps test suite nowadays has 3 hypervisor driver implementations
which should give us plenty of opportunity to get full domcaps coverage.
I don't think this test has much value. And it has the following issues:

- Requires manual intervention to test new domcaps XML, which is easy
  to miss, for example gic bits aren't covered there.
- The SET_ALL_BITS trick it uses to fill in enums will output
  values that are never reported by any driver implementation
  (strings like 'default')

Let's remove it

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agotests: domcaps: Remove unused typedef
Cole Robinson [Tue, 19 Feb 2019 17:51:37 +0000 (12:51 -0500)]
tests: domcaps: Remove unused typedef

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agotests: domcaps: Add a default 'empty' test
Cole Robinson [Tue, 19 Feb 2019 17:44:34 +0000 (12:44 -0500)]
tests: domcaps: Add a default 'empty' test

The 'empty' demonstrates XML generated when only bare minimum caps
data has been filled in. This will demonstrate changes that alter
the default XML output.

Acked-by: Michal Privoznik <mprivozn@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agotests: Document how to add new replies files
Andrea Bolognani [Wed, 13 Mar 2019 13:28:07 +0000 (14:28 +0100)]
tests: Document how to add new replies files

We already document how to generate them, so might as well
go the extra mile and document the remaining steps.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Acked-by: Michal Privoznik <mprivozn@redhat.com>
6 years agonode_device_hal.c: Follow _class -> klass rename
Michal Privoznik [Mon, 18 Mar 2019 13:32:55 +0000 (14:32 +0100)]
node_device_hal.c: Follow _class -> klass rename

In 0eca80e60 _class was renamed to klass for variety of struct
members. However, gather_usb_cap() was missed out in this rename
leaving FreeBSD build broken.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
6 years agoDrop needless virtType validation
Cole Robinson [Sun, 17 Mar 2019 19:53:40 +0000 (15:53 -0400)]
Drop needless virtType validation

This code originates from:

commit d0aa10fdd6c108ad442886e4451b2629a3dc8b86
Author: Daniel P. Berrange <berrange@redhat.com>
Date:   Tue Mar 3 12:03:44 2009 +0000

    QEMU security driver usage for sVirt support (James Morris, Dan Walsh, Daniel Berrange)

Originally in the qemudDomainGetSecurityLabel function. It doesn't
appear to have done anything useful back then either. The other two
instances look like copy+paste

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Cole Robinson <crobinso@redhat.com>
6 years agostorageVolWipePattern: Don't take shortcut to refreshPool()
Michal Privoznik [Thu, 28 Feb 2019 16:35:14 +0000 (17:35 +0100)]
storageVolWipePattern: Don't take shortcut to refreshPool()

In d16f803d780 we've tried to solve an issue that after wiping an
image its format might have changed (e.g. from qcow2 to raw) but
libvirt wasn't probing the image format. We fixed this by calling
virStorageBackendRefreshVolTargetUpdate() which is what
refreshPool() would end up calling. But this shortcut is not good
enough because the function is called only for local types of
volumes (like dir, fs, netfs). But now that more backends support
volume wiping we have to call the function with more caution.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
6 years agostorage_backend_iscsi_direct: Simplify vol zeroing
Michal Privoznik [Fri, 1 Mar 2019 10:42:20 +0000 (11:42 +0100)]
storage_backend_iscsi_direct: Simplify vol zeroing

So far we have two branches: either we zero BLOCK_PER_PACKET
(currently 128) block at once, or if we're close to the last block
then we zero out one block at the time. This is very suboptimal.
We know how many block are there left. Might as well just write
them all at once.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovirsh: man: Document asynchronous behaviour of detach-device-alias
Peter Krempa [Mon, 18 Mar 2019 07:08:57 +0000 (08:08 +0100)]
virsh: man: Document asynchronous behaviour of detach-device-alias

This command is fully async. Note that users can use virsh event to be
notified of the guest actually removing the device.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agovirsh: man: Document quirks of device-detach and friends
Peter Krempa [Mon, 18 Mar 2019 07:08:04 +0000 (08:08 +0100)]
virsh: man: Document quirks of device-detach and friends

Mention that successful return does not equal to device being detached
similarly as we do at the API level.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agonews: update for new class element of PCI nodedev capability
Nikolay Shirokovskiy [Tue, 12 Mar 2019 10:59:35 +0000 (13:59 +0300)]
news: update for new class element of PCI nodedev capability

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoxml: nodedev: add class info for pci capability
Nikolay Shirokovskiy [Tue, 19 Feb 2019 12:41:37 +0000 (15:41 +0300)]
xml: nodedev: add class info for pci capability

This info can be useful to filter devices visible
to mgmt clients so that they won't see devices that
unsafe/not meaningful to pass thru.

Provide class info the way it is provided by udev or
kernel that is as single 6-digit hexadecimal.

Class element is not optional. I guess this should not
break users that use virNodeDeviceCreateXML because
they probably specify only scsi_host capability on
input and then node device driver gets other capabilities
from udev after device appeared.

HAL driver does not get support for the new element in
this patch.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoconf: don't use "class" as name
Nikolay Shirokovskiy [Tue, 12 Mar 2019 08:08:00 +0000 (11:08 +0300)]
conf: don't use "class" as name

Vim treats *.h files as cpp ones with respect to syntax highlighting.
Thus "class" in _virNodeDevCapPCIDev highlighted mistakenly.
This can be fixed by filetype detection code tunables but it
is more convinient to skip this tuning by every project member.

Let's just use "klass" as field name instead of _class or class
and add syntax rule.

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agovz: build fix for virdomainsnapshotobjlist.h
Nikolay Shirokovskiy [Mon, 18 Mar 2019 08:03:04 +0000 (11:03 +0300)]
vz: build fix for virdomainsnapshotobjlist.h

Commit [1] moved snapshot list functions declaration into
its own file but missed a fix for vz driver.

[1] 9b75154c : snapshot: Break out virDomainSnapshotObjList into its own file

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
6 years agovirsh-pool: Offer only active pool for pool-refresh completer
Michal Privoznik [Fri, 1 Mar 2019 09:56:42 +0000 (10:56 +0100)]
virsh-pool: Offer only active pool for pool-refresh completer

Only active pools can be refreshed. But our completer offers just
all pool, even inactive ones.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
6 years agostoragePoolRefreshFailCleanup: Clear volumes on failed refresh
Michal Privoznik [Thu, 28 Feb 2019 17:07:02 +0000 (18:07 +0100)]
storagePoolRefreshFailCleanup: Clear volumes on failed refresh

If pool refresh failed, then the internal table of volumes is
probably left in inconsistent or incomplete state anyways. Clear
it out then. This has an advantage that we can move the
virStoragePoolObjClearVols() from those very few backends that
do call it.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
6 years agostorage_driver: Introduce storagePoolRefreshImpl()
Michal Privoznik [Fri, 1 Mar 2019 09:55:23 +0000 (10:55 +0100)]
storage_driver: Introduce storagePoolRefreshImpl()

This is a wrapper over refreshPool() call as at all places we are
doing basically the same. Might as well have a single function to
call.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
6 years agovirISCSIDirectReportLuns: Drop ClearVols
Michal Privoznik [Thu, 28 Feb 2019 16:43:57 +0000 (17:43 +0100)]
virISCSIDirectReportLuns: Drop ClearVols

In bf5cf610f206d5d54 I've fixed a problem where iscsi-direct
backend was reporting only the last LUN. The fix consisted of
moving virStoragePoolObjClearVols() one level up. However, as it
turns out, storage driver already calls it before calling
refreshPool callback (which is
virStorageBackendISCSIDirectRefreshPool() in this case).

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
6 years agoiscsi_direct: Don't overwrite error in virStorageBackenISCSIDirectWipeVol()
Michal Privoznik [Wed, 6 Mar 2019 14:43:04 +0000 (15:43 +0100)]
iscsi_direct: Don't overwrite error in virStorageBackenISCSIDirectWipeVol()

If virStorageBackendISCSIDirectVolWipeZero() fails, it has
already reported an error which is probably specific enough. Do
not overwrite it with some generic one.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
6 years agoiscsi_direct: Make virStorageBackendISCSIDirectGetLun report error properly
Michal Privoznik [Wed, 6 Mar 2019 14:27:55 +0000 (15:27 +0100)]
iscsi_direct: Make virStorageBackendISCSIDirectGetLun report error properly

This function reports error for one of the two error paths. This
is unfortunate as a caller see this function failing but doesn't
know right away if an error was reported.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Pavel Hrdina <phrdina@redhat.com>
6 years agonews: Add entry describing support for Xen's max grant frames
Jim Fehlig [Wed, 13 Mar 2019 22:06:11 +0000 (16:06 -0600)]
news: Add entry describing support for Xen's max grant frames

Signed-off-by: Jim Fehlig <jfehlig@suse.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agonews: Document dropping support for certain init scripts
Andrea Bolognani [Thu, 14 Mar 2019 10:59:42 +0000 (11:59 +0100)]
news: Document dropping support for certain init scripts

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agom4: Simplify LIBVIRT_CHECK_INIT_SCRIPT
Andrea Bolognani [Fri, 15 Mar 2019 15:57:40 +0000 (16:57 +0100)]
m4: Simplify LIBVIRT_CHECK_INIT_SCRIPT

Now that we no longer support the weird "redhat+systemd"
configuration, we can make our code slightly simpler.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoDrop support for "Red Hat" init scripts
Andrea Bolognani [Fri, 15 Mar 2019 15:47:27 +0000 (16:47 +0100)]
Drop support for "Red Hat" init scripts

Despite the misleading name, these were supposed to be used
with a System V style init; however, none of the platforms we
target is using that kind of init anymore: almost all Linux
distributions have switched to systemd, those that haven't
(such as Gentoo and Alpine) are mostly using OpenRC with
custom init scripts, and the BSDs have been doing their own
thing all along.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoDrop support for Upstart init scripts
Andrea Bolognani [Thu, 14 Mar 2019 10:56:13 +0000 (11:56 +0100)]
Drop support for Upstart init scripts

Not a single one of the platforms we target still uses Upstart, and
the Upstart project itself has been abandoned for several years now.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agotravis: Drop $DISTCHECK_CONFIGURE_FLAGS
Andrea Bolognani [Fri, 15 Mar 2019 15:37:09 +0000 (16:37 +0100)]
travis: Drop $DISTCHECK_CONFIGURE_FLAGS

It's no longer used.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agotravis: Stop using --with-init-script
Andrea Bolognani [Thu, 14 Mar 2019 10:57:03 +0000 (11:57 +0100)]
travis: Stop using --with-init-script

We're gonna drop support for non-systemd init scripts soon,
and we don't want Travis CI builds to break when we do.

Since we have init system auto-detection, we can just rely on
that and stop passing --with-init-script to configure entirely.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agosnapshot: Break out virDomainSnapshotObjList into its own file
Eric Blake [Fri, 15 Mar 2019 02:19:18 +0000 (21:19 -0500)]
snapshot: Break out virDomainSnapshotObjList into its own file

snapshot_conf.h was mixing three separate types: the snapshot
definition, the snapshot object, and the snapshot object list.
Separate out the snapshot object list code into its own file, and
update includes for affected clients.

This is just code motion, but done in preparation of sharing a lot of
the object list code with checkpoints.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>