]> xenbits.xensource.com Git - libvirt.git/log
libvirt.git
6 years agoconf: Use VIR_STEAL_PTR in domain_conf
John Ferlan [Fri, 15 Feb 2019 12:42:17 +0000 (07:42 -0500)]
conf: Use VIR_STEAL_PTR in domain_conf

In preparation for some autofree mods.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotestutils: Explicitly name virTestCompare*() arguments
Michal Privoznik [Tue, 19 Feb 2019 17:15:23 +0000 (18:15 +0100)]
testutils: Explicitly name virTestCompare*() arguments

Currently, some arguments are called strcontent and strsrc, or
content and src or some other combination. This makes it
impossible to see at the first glance what argument is supposed
to represent 'expected' value and which one represents 'actual'
value. Rename the arguments to make it obvious.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agovirTestCompareToULL: Rename local variables
Michal Privoznik [Wed, 20 Feb 2019 13:14:31 +0000 (14:14 +0100)]
virTestCompareToULL: Rename local variables

The current naming makes it hard for me to see which holds the
expected value and which holds the actual value. Rename them to
make it obvious.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agovirTestCompareToULL: Use VIR_AUTOFREE()
Michal Privoznik [Wed, 20 Feb 2019 13:12:09 +0000 (14:12 +0100)]
virTestCompareToULL: Use VIR_AUTOFREE()

In order to save a few lines of code, and also since it's hype
let's use VIR_AUTOFREE() for the two strings we allocate there.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoiohelper: Remove remaining newlines from error messages
Andrea Bolognani [Tue, 19 Feb 2019 15:03:54 +0000 (16:03 +0100)]
iohelper: Remove remaining newlines from error messages

The iohelper is an internal program that's only supposed to
be called by libvirt, and whatever output it might produce
will ultimately be passed to virReportError() or similar.

Since we do not want strings passed to those functions to
contain newlines, we can simply not output them in the first
place.

This is what happens in pretty much all cases already, but
in a couple instances newlines have managed to slip in.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Laine Stump <laine@laine.org>
6 years agosnapshot: Define explicit flags for snapshot xml
Eric Blake [Wed, 13 Feb 2019 21:09:05 +0000 (15:09 -0600)]
snapshot: Define explicit flags for snapshot xml

Commit f609cb85 (0.9.5) introduced virDomainSnapshotGetXMLDesc()'s use
of @flags as a subset of virDomainXMLFlags, documenting that 2 of the
3 flags defined at the time would never be valid.  Later, commit
28f8dfdc (1.0.0) introduced a new flag, VIR_DOMAIN_XML_MIGRATABLE, but
did not adjust the snapshot documentation to declare it as invalid.
However, since the flag is not accepted as valid by any of the
drivers (remote is just passthrough; esx and vbox don't support flags;
qemu, test, and vz only support VIR_DOMAIN_XML_SECURE), and it is
unlikely that the domain state saved off during a snapshot creation
needs to be migration-friendly (as the snapshot is not the source of
a migration), it is easier to just define an explicit set of supported
flags directly related to the snapshot API rather than trying to
borrow from domain API, and risking confusion if even more domain
flags are added later (in fact, I have an upcoming patch that plans to
add a new flag to virDomainGetXMLDesc that makes no sense for
snapshots).

There is no API or ABI impact (since we purposefully used unsigned int
rather than an enum type in public API, and since the new flag name
carries the same value as the reused name).

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agodomain: Define explicit flags for saved image xml
Eric Blake [Wed, 13 Feb 2019 21:09:05 +0000 (15:09 -0600)]
domain: Define explicit flags for saved image xml

Commit d2a929d4 (0.9.4) defined virDomainSaveImageGetXMLDesc()'s use
of @flags as a subset of virDomainXMLFlags, documenting that 2 of the
3 flags defined at the time would never be valid.  Later, commit
28f8dfdc (1.0.0) introduced a new flag, VIR_DOMAIN_XML_MIGRATABLE, but
did not adjust the save image documentation to declare it as invalid.
Later, commit a67e3872 (3.7.0) blindly copied and pasted the same text
into virDomainManagedSaveGetXMLDesc.

However, since the flag is not accepted as valid by any of the
drivers (remote is just passthrough; and qemu is the only supporting
driver for either API, with support for just VIR_DOMAIN_XML_SECURE),
it is easier to just define an explicit set of supported flags
directly related to the save image API rather than trying to borrow
from live domain API, and risking confusion if even more domain flags
are added later (in fact, I have an upcoming patch that plans to add
a new flag to virDomainGetXMLDesc that makes no sense for saved
images).  We may someday decide that saved images need to support the
_MIGRATABLE flag, as it is possible to load a saved image with a
different version of libvirt than the one that created it, but that
can be a separate patch if it is ever needed.  Meanwhile, it DOES make
sense to reuse the same flags for SaveImage and for ManagedSave (since
ManagedSave is really just sugar for creating a normal SaveImage in a
location controlled by libvirt instead of by the user).

There is no API or ABI impact (since we purposefully used unsigned int
rather than an enum type in public API, and since the new flag name
carries the same value as the old reused name).

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: Use correct domain xml flag
Eric Blake [Thu, 14 Feb 2019 18:53:36 +0000 (12:53 -0600)]
qemu: Use correct domain xml flag

Although VIR_DOMAIN_DEF_FORMAT_INACTIVE and VIR_DOMAIN_XML_INACTIVE
happen to have the same value (1<<1), they come from different enums;
and it is nicer to reason about a 'flags' variable if all uses of
that variable are compared against the same enum type.  Messed up in
commit 06f75ff2 (3.8.0).

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agodomain: Fix unknown flags diagnosis in virDomainGetXMLDesc
Eric Blake [Thu, 14 Feb 2019 20:25:01 +0000 (14:25 -0600)]
domain: Fix unknown flags diagnosis in virDomainGetXMLDesc

Many drivers had a comment that they did not validate the incoming
'flags' to virDomainGetXMLDesc() because they were relying on
virDomainDefFormat() to do it instead. This used to be the case
(at least since 461e0f1a and friends in 0.9.4 added unknown flag
checking in general), but regressed in commit 0ecd6851 (1.2.12),
when all of the drivers were changed to pass 'flags' through the
new helper virDomainDefFormatConvertXMLFlags(). Since this helper
silently ignores unknown flags, we need to implement flag checking
in each driver instead.

Annoyingly, this means that any new flag values added will silently
be ignored when targeting an older libvirt, rather than our usual
practice of loudly diagnosing an unsupported flag.  Add comments
in domain_conf.[ch] to remind us to be extra vigilant about the
impact when adding flags (a new flag to add data is safe if the
older server omitting the requested data doesn't break things in
the newer client; a new flag to suppress data rather than enhancing
the existing VIR_DOMAIN_XML_SECURE may form a data leak or even a
security hole).

In the qemu driver, there are multiple callers all funnelling to
qemuDomainDefFormatBufInternal(); many of them already validated
flags (and often only a subset of the full set of possible flags),
but for ease of maintenance, we can also check flags at the common
helper function.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu_process: Enter QMP command mode when starting QEMU Process
Chris Venteicher [Thu, 14 Feb 2019 10:25:50 +0000 (11:25 +0100)]
qemu_process: Enter QMP command mode when starting QEMU Process

qemuProcessQMPStart starts a QEMU process and monitor connection that
can be used by multiple functions possibly for multiple QMP commands.

The QMP exchange to exit capabilities negotiation mode and enter command
mode can only be performed once after the monitor connection is
established.

Move responsibility for entering QMP command mode into the
qemuProcessQMP code so multiple functions can issue QMP commands in
arbitrary orders.

This also simplifies the functions using the connection provided by
qemuProcessQMPStart to issue QMP commands.

Test code now needs to call qemuMonitorSetCapabilities to send the
message to switch to command mode because the test code does not use the
qemuProcessQMP command that internally calls qemuMonitorSetCapabilities.

Signed-off-by: Chris Venteicher <cventeic@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu_process: Use unique directories for QMP processes
Chris Venteicher [Wed, 13 Feb 2019 16:22:31 +0000 (17:22 +0100)]
qemu_process: Use unique directories for QMP processes

Multiple QEMU processes for QMP commands can operate concurrently.

Use a unique directory under libDir for each QEMU process to avoid
pidfile and unix socket collision between processes.

The pid file name is changed from "capabilities.pidfile" to "qmp.pid"
because we no longer need to avoid a possible clash with a qemu domain
called "capabilities" now that the processes artifacts are stored in
their own unique temporary directories.

"Capabilities" was changed to "qmp" in the pid file name because these
processes are no longer specific to the capabilities usecase and are
more generic in terms of being used for any general purpose QMP message
exchanges with a QEMU process that is not associated with a domain.

Signed-off-by: Chris Venteicher <cventeic@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu_process: Hide qemuProcessQMPStop
Jiri Denemark [Wed, 13 Feb 2019 16:18:51 +0000 (17:18 +0100)]
qemu_process: Hide qemuProcessQMPStop

Users qemuProcessQMP struct were always forced to call both
qemuProcessQMPStop and qemuProcessQMPFree when they are done with the
process. We can just call qemuProcessQMPStop from qemuProcessQMPFree and
let users call qemuProcessQMPFree only.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu_process: Document and cleanup qemuProcessQMPNew
Chris Venteicher [Sun, 13 Jan 2019 00:50:15 +0000 (18:50 -0600)]
qemu_process: Document and cleanup qemuProcessQMPNew

qemuProcessQMPNew is one of the public functions used to create and
manage a QEMU process for QMP command exchanges outside of domain
operations.

Add descriptive comment block, debug statement and make source
consistent with the cleanup / VIR_STEAL_PTR format used elsewhere.

Signed-off-by: Chris Venteicher <cventeic@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu_process: Stop retaining monitor config in qemuProcessQMP
Chris Venteicher [Sun, 13 Jan 2019 00:50:14 +0000 (18:50 -0600)]
qemu_process: Stop retaining monitor config in qemuProcessQMP

The monitor config data is removed from the qemuProcessQMP struct.

The monitor config data can be initialized immediately before call to
qemuMonitorOpen and does not need to be maintained after the call
because qemuMonitorOpen copies any strings it needs.

Signed-off-by: Chris Venteicher <cventeic@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu_process: Setup paths within qemuProcessQMPInit
Chris Venteicher [Sun, 13 Jan 2019 00:50:13 +0000 (18:50 -0600)]
qemu_process: Setup paths within qemuProcessQMPInit

Move code for setting paths and prepping file system from
qemuProcessQMPNew to qemuProcessQMPInit.

This keeps qemuProcessQMPNew limited to data structures and path
initialization is done in qemuProcessQMPInit.

The patch is a non-functional, cut / paste change, however goto is now
"cleanup" rather than "error".

Signed-off-by: Chris Venteicher <cventeic@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu_process: Store libDir in qemuProcessQMP struct
Chris Venteicher [Sun, 13 Jan 2019 00:50:12 +0000 (18:50 -0600)]
qemu_process: Store libDir in qemuProcessQMP struct

Store libDir path in the qemuProcessQMP struct in anticipation of moving
path construction code into qemuProcessQMPInit function.

Signed-off-by: Chris Venteicher <cventeic@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu_process: Move monitor code to qemuProcessQMPConnectMonitor
Chris Venteicher [Sun, 13 Jan 2019 00:50:11 +0000 (18:50 -0600)]
qemu_process: Move monitor code to qemuProcessQMPConnectMonitor

All code related to QEMU monitor is moved from qemuProcessQMPNew and
qemuProcessQMPInit into qemuProcessQMPConnectMonitor.

Signed-off-by: Chris Venteicher <cventeic@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu_process: Introduce qemuProcessQMPStart
Chris Venteicher [Sun, 13 Jan 2019 00:50:10 +0000 (18:50 -0600)]
qemu_process: Introduce qemuProcessQMPStart

This is a replacement for qemuProcessQMPRun to make the name consistent
with qemuProcessStart. The original qemuProcessQMPRun function is
renamed as qemuProcessQMPLaunch and becomes one of the simpler functions
called from the main qemuProcessQMPStart entry point. The following
patches will move parts of the code in qemuProcessQMPLaunch to the other
functions (qemuProcessQMPInit and qemuProcessQMPConnectMonitor).

Signed-off-by: Chris Venteicher <cventeic@redhat.com>
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu_process: Hide qmperr inside qemuProcessQMP
Jiri Denemark [Tue, 12 Feb 2019 14:00:42 +0000 (15:00 +0100)]
qemu_process: Hide qmperr inside qemuProcessQMP

Keep the pointer to QEMU stderr output in qemuProcessQMP struct instead
of requiring the caller to provide it (and free it).

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu_capabilities: Log probe failure in virQEMUCapsInitQMPSingle
Jiri Denemark [Tue, 12 Feb 2019 13:50:39 +0000 (14:50 +0100)]
qemu_capabilities: Log probe failure in virQEMUCapsInitQMPSingle

Let's push the call to virQEMUCapsLogProbeFailure down the stack to
where the probing failure is detected.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu_process: Don't ignore errors in virQEMUCapsInit
Jiri Denemark [Tue, 12 Feb 2019 13:38:40 +0000 (14:38 +0100)]
qemu_process: Don't ignore errors in virQEMUCapsInit

While qemuProcessQMPRun and virQEMUCapsInitQMPMonitor* functions called
from virQEMUCapsInit ignore some errors, the caller of virQEMUCapsInit
would report an error unless usedQMP is true anyway. And since usedQMP
can only be true if the probing code really succeeded (i.e., no errors
were ignored), we can just simplify the logic by not ignoring the errors
in the first place.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu_capabilities: Refactor virQEMUCapsInitQMP
Jiri Denemark [Mon, 11 Feb 2019 16:06:31 +0000 (17:06 +0100)]
qemu_capabilities: Refactor virQEMUCapsInitQMP

The function contains two almost identical parts. Let's consolidate them
into a single helper function and call it twice.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu_process: Use qemuProcessQMP struct for a single process
Chris Venteicher [Sun, 13 Jan 2019 00:50:06 +0000 (18:50 -0600)]
qemu_process: Use qemuProcessQMP struct for a single process

In new process code, move from model where qemuProcessQMP struct can be
used to activate a series of Qemu processes to model where one
qemuProcessQMP struct is used for one and only one Qemu process.

By allowing only one process activation per qemuProcessQMP struct, the
struct can safely store process outputs like status and stderr, without
being overwritten, until qemuProcessQMPFree is called.

By doing this, process outputs like status and stderr can remain stored
in the qemuProcessQMP struct without being overwritten by subsequent
process activations.

The forceTCG parameter (use / don't use KVM) will be passed when the
qemuProcessQMP struct is initialized since the qemuProcessQMP struct
won't be reused.

Signed-off-by: Chris Venteicher <cventeic@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu_capabilities: Stop QEMU process before freeing
Chris Venteicher [Sun, 13 Jan 2019 00:50:05 +0000 (18:50 -0600)]
qemu_capabilities: Stop QEMU process before freeing

virQEMUCapsInitQMP now stops QEMU process in all execution paths,
before freeing the process structure.

The qemuProcessQMPStop function can be called multiple times without
problems... Won't attempt to stop processes and free resources multiple
times.

Follow the convention established in qemu_process of
1) alloc process structure
2) start process
3) use process
4) stop process
5) free process data structure

The process data structure persists after the process activation fails
or the process dies or is killed so stderr strings can be retrieved
until the process data structure is freed.

Signed-off-by: Chris Venteicher <cventeic@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu_process: Use consistent name for stop process function
Chris Venteicher [Sun, 13 Jan 2019 00:50:04 +0000 (18:50 -0600)]
qemu_process: Use consistent name for stop process function

s/qemuProcessQMPAbort/qemuProcessQMPStop/ applied to change function
name used to stop QEMU processes in process code moved from
qemu_capabilities.

No functionality change.

The new name, qemuProcessQMPStop, is consistent with the existing
function qemuProcessStop used to stop Domain processes.

Signed-off-by: Chris Venteicher <cventeic@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu_process: Refer to proc not cmd in process code
Chris Venteicher [Sun, 13 Jan 2019 00:50:03 +0000 (18:50 -0600)]
qemu_process: Refer to proc not cmd in process code

s/cmd/proc/ in process code imported from qemu_capabilities.

Signed-off-by: Chris Venteicher <cventeic@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu_process: Limit qemuProcessQMPNew to const input strings
Chris Venteicher [Sun, 13 Jan 2019 00:50:02 +0000 (18:50 -0600)]
qemu_process: Limit qemuProcessQMPNew to const input strings

Add the const qualifier on non modified strings
(string only copied inside qemuProcessQMPNew)
so that const strings can be used directly in calls to
qemuProcessQMPNew in future patches.

Signed-off-by: Chris Venteicher <cventeic@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu_process: Rename identifiers moved from qemu_capabilities
Chris Venteicher [Sun, 13 Jan 2019 00:50:01 +0000 (18:50 -0600)]
qemu_process: Rename identifiers moved from qemu_capabilities

s/virQEMUCapsInitQMPCommand/qemuProcessQMP/

Signed-off-by: Chris Venteicher <cventeic@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoqemu_process: Move process code from qemu_capabilities
Chris Venteicher [Sun, 13 Jan 2019 00:50:00 +0000 (18:50 -0600)]
qemu_process: Move process code from qemu_capabilities

QEMU process code in qemu_capabilities.c is moved to qemu_process.c in
order to make the code usable outside the original capabilities use
cases.

The moved code activates and manages QEMU processes without establishing
a guest domain.

This patch is a straight cut/paste move between files.

Signed-off-by: Chris Venteicher <cventeic@redhat.com>
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agovirsh: fix return value in storage vol name completor
Daniel P. Berrangé [Mon, 11 Feb 2019 14:21:35 +0000 (14:21 +0000)]
virsh: fix return value in storage vol name completor

The function must return a pointer, not a boolean. Fortunately 'false'
is equivalent to 'NULL' so this bug no had ill effect previously.

Reviewed-by: Ján Tomko <jtomko@redhat.com>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoconf: make virPCIDeviceAddressFormat void
Daniel P. Berrangé [Wed, 19 Dec 2018 11:58:42 +0000 (11:58 +0000)]
conf: make virPCIDeviceAddressFormat void

Only one of the three callers of virPCIDeviceAddressFormat correctly
handles an error return status. Fortunately it can't fail so can be
made void.

Reviewed-by: Laine Stump <laine@laine.org>
Signed-off-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agoiohelper: Don't include newlines in error messages
Andrea Bolognani [Tue, 5 Feb 2019 14:54:55 +0000 (15:54 +0100)]
iohelper: Don't include newlines in error messages

The newline was pretty arbitrary, and we're better off
without it.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agovircommand: Ensure buffers are NULL-terminated
Andrea Bolognani [Tue, 5 Feb 2019 13:30:42 +0000 (14:30 +0100)]
vircommand: Ensure buffers are NULL-terminated

The memory allocated by VIR_REALLOC_N() is uninitialized,
which means it's not possible to figure out whether any
output was produced at all after the fact.

Since we don't care about the previous contents of buffers,
if any, use VIR_FREE() followed by VIR_ALLOC_N() instead.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agovz: build fix for virStorageBackendVzPoolStart
Nikolay Shirokovskiy [Thu, 14 Feb 2019 13:06:54 +0000 (16:06 +0300)]
vz: build fix for virStorageBackendVzPoolStart

Remove unused variable. Fix for [1]

[1] 821dd6d8: storage: Use VIR_AUTOFREE for storage backends

Signed-off-by: Nikolay Shirokovskiy <nshirokovskiy@virtuozzo.com>
6 years agoRemove remaining references to kqemu
Ján Tomko [Mon, 18 Feb 2019 15:13:30 +0000 (16:13 +0100)]
Remove remaining references to kqemu

We dropped support in commit 8e91a40 (November 2015), but some
occurrences still remained, even in live code.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reported-by: Thomas Huth <thuth@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoutil: Use virStorageSourceNew in virStorageFileMetadataNew
Peter Krempa [Mon, 18 Feb 2019 12:24:37 +0000 (13:24 +0100)]
util: Use virStorageSourceNew in virStorageFileMetadataNew

Commit dcda2bf4c110 forgot to fix this one instance.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoutil: Replace virStorageSourceFree with virObjectUnref
Peter Krempa [Fri, 15 Feb 2019 12:03:58 +0000 (13:03 +0100)]
util: Replace virStorageSourceFree with virObjectUnref

Now that virStorageSource is a subclass of virObject we can use
virObjectUnref and remove virStorageSourceFree which was a thin wrapper.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoutil: Remove the AUTOPTR func for virStorageSource
Peter Krempa [Fri, 15 Feb 2019 11:52:45 +0000 (12:52 +0100)]
util: Remove the AUTOPTR func for virStorageSource

Since virStorageSource is now a subclass of virObject, we can use
VIR_AUTOUNREF instead.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoutil: alloc: Introduce VIR_AUTOUNREF macro
Peter Krempa [Fri, 15 Feb 2019 11:35:12 +0000 (12:35 +0100)]
util: alloc: Introduce VIR_AUTOUNREF macro

Add helper for utilizing __attribute__(cleanup())) for unref-ing
instances of sublasses of virObject.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoutil: storage: Turn virStorageSource into a virObject
Peter Krempa [Fri, 15 Feb 2019 08:46:03 +0000 (09:46 +0100)]
util: storage: Turn virStorageSource into a virObject

To allow tracking a single virStorageSource in multiple structures
without extra hassle allow refcounting by turining it into an object.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoutil: Introduce function for allocating virStorageSource
Peter Krempa [Thu, 14 Feb 2019 15:20:25 +0000 (16:20 +0100)]
util: Introduce function for allocating virStorageSource

Add virStorageSourceNew and refactor places allocating that structure to
use the helper.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agobhyve: use virDomainDiskDefNew to instead of VIR_ALLOC
Peter Krempa [Mon, 18 Feb 2019 09:12:24 +0000 (10:12 +0100)]
bhyve: use virDomainDiskDefNew to instead of VIR_ALLOC

Use the proper function to allocate a disk definition.

Signed-off-by: Peter Krempa <pkrempa@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agoconf: Rework virDomainDeviceDefPostParseCommon()
Andrea Bolognani [Fri, 15 Feb 2019 11:39:36 +0000 (12:39 +0100)]
conf: Rework virDomainDeviceDefPostParseCommon()

Now that we've moved all the actual code into helper
functions, we can turn it into a switch statement.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Introduce virDomainNetDefPostParse()
Andrea Bolognani [Fri, 15 Feb 2019 11:26:13 +0000 (12:26 +0100)]
conf: Introduce virDomainNetDefPostParse()

Minor tweaks to ensure compliance with our coding style.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Introduce virDomainControllerDefPostParse()
Andrea Bolognani [Fri, 15 Feb 2019 11:22:24 +0000 (12:22 +0100)]
conf: Introduce virDomainControllerDefPostParse()

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Introduce virDomainVideoDefPostParse()
Andrea Bolognani [Fri, 15 Feb 2019 11:17:06 +0000 (12:17 +0100)]
conf: Introduce virDomainVideoDefPostParse()

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Introduce virDomainDiskDefPostParse()
Andrea Bolognani [Fri, 15 Feb 2019 11:05:51 +0000 (12:05 +0100)]
conf: Introduce virDomainDiskDefPostParse()

Minor tweaks to ensure compliance with our coding style.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Introduce virDomainRNGDefPostParse()
Andrea Bolognani [Fri, 15 Feb 2019 09:39:20 +0000 (10:39 +0100)]
conf: Introduce virDomainRNGDefPostParse()

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Introduce virDomainChrDefPostParse()
Andrea Bolognani [Fri, 15 Feb 2019 09:35:02 +0000 (10:35 +0100)]
conf: Introduce virDomainChrDefPostParse()

Minor tweaks to ensure compliance with our coding style.

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agonetwork: explicitly allow icmp/icmpv6 in libvirt zonefile
Laine Stump [Thu, 14 Feb 2019 19:33:34 +0000 (14:33 -0500)]
network: explicitly allow icmp/icmpv6 in libvirt zonefile

The libvirt zonefile for firewalld (added in commit 3b71f2e4) does the
following:

1) lists specific services it wants to allow, then

2) uses a lower priority <reject/> rule to block all other services to
   the host, and then finally,

3) relies on the zone's default "accept" policy to, accept all
   forwarded traffic (since forwarded traffic is ignored by the
   slightly higher priority <reject/> rule in (2)).

I had assumed that icmp traffic was either being allowed at the top of
the rules, or that it would be ignored by the <reject/> rule and
passed by the default accept policy (similar to forwarded traffic),
but this assumption was incorrect; the <reject/> rule does block icmp
traffic. This became apparent when DHCPv6 which requires ICMPv6 in
addition to udp/dhcpv6) failed to work.

This all means that in order to achieve our original goal of "similar
behavior to a default reject policy, but also allowing forwarded
traffic", we need to add rules to allow all icmp and icmpv6 traffic to
the libvirt zone, and that's what this patch does.

This is a further refinement of the resolution to
https://bugzilla.redhat.com/1650320

Signed-off-by: Laine Stump <laine@laine.org>
Acked-by: Eric Garver <eric@garver.life>
6 years agovirkmodtest: Don't fail if modprobe doesn't exist
Michal Privoznik [Thu, 14 Feb 2019 15:25:44 +0000 (16:25 +0100)]
virkmodtest: Don't fail if modprobe doesn't exist

On some very basic installations (e.g. some container images) the
modprobe binary might be missing. If that is the case, don't fail
virkmodtest.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Daniel P. Berrangé <berrange@redhat.com>
6 years agovirsh: fix snapshot list --parent
Ján Tomko [Thu, 14 Feb 2019 13:45:12 +0000 (14:45 +0100)]
virsh: fix snapshot list --parent

The root snapshot does not have a parent.
Use NULLSTR_EMPTY to pass an empty string instead of putting
too few columns in the table.

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

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Eric Blake <eblake@redhat.com>
6 years agoqemu_hotplug: Initialize @charAlias in qemuDomainRemoveChrDevice
Michal Privoznik [Thu, 14 Feb 2019 13:13:08 +0000 (14:13 +0100)]
qemu_hotplug: Initialize @charAlias in qemuDomainRemoveChrDevice

My change in 112f3a8d0f32 was too drastic. The @charAlias
variable is initialized only if @monitor == true. However, it is
used even outside of that condition, at which point it's just
uninitialized pointer.

Reported-by: John Ferlan <jferlan@redhat.com>
Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoudev: only report a warning if udev_enumerate_scan_devices fails
Marc Hartmayer [Thu, 14 Feb 2019 09:01:01 +0000 (10:01 +0100)]
udev: only report a warning if udev_enumerate_scan_devices fails

Even if an error is reported by `udev_enumerate_scan_devices`,
e.g. because a driver of a device has an bug, we can still enumerate
all other devices. Additionally the documentation of
udev_enumerate_scan_devices says that on success an integer >= 0 is
returned (see man udev_enumerate_scan_devices(3)).

Reviewed-by: Bjoern Walk <bwalk@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay@linux.ibm.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoUse NULLSTR_EMPTY
Ján Tomko [Tue, 12 Feb 2019 16:25:06 +0000 (17:25 +0100)]
Use NULLSTR_EMPTY

Instead of repetitive:
  s ? s : ""
use NULLSTR_EMPTY.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agoRemove EMPTY_STR macro
Ján Tomko [Tue, 12 Feb 2019 16:15:17 +0000 (17:15 +0100)]
Remove EMPTY_STR macro

Another misleadingly named macro.
Deprecate in favor of NULLSTR_STAR.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agoRemove EMPTYSTR macro
Ján Tomko [Tue, 12 Feb 2019 16:11:11 +0000 (17:11 +0100)]
Remove EMPTYSTR macro

This macro neither takes nor produces an empty string.
Remove it in favor of NULLSTR_MINUS.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agotools: use NULLSTR_MINUS
Ján Tomko [Tue, 12 Feb 2019 16:09:49 +0000 (17:09 +0100)]
tools: use NULLSTR_MINUS

Use the newly introduced macro in the few places that open-code it.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agointernal: introduce a family of NULLSTR macros
Ján Tomko [Tue, 12 Feb 2019 16:01:09 +0000 (17:01 +0100)]
internal: introduce a family of NULLSTR macros

NULLSTR_EMPTY, the quiet child,
NULLSTR_STAR, the famous one and
NULLSTR_MINUS, the grumpy one.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agoqemu_hotplug: Assume chardev alias always exists in qemuDomainDetachChrDevice
Michal Privoznik [Thu, 14 Feb 2019 09:44:15 +0000 (10:44 +0100)]
qemu_hotplug: Assume chardev alias always exists in qemuDomainDetachChrDevice

The @tmpChr is looked up in domain definition based on user
provided chardev XML. Therefore, the alias must have been
allocated already when domain was started up.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu_hotplug: Don't build device string in qemuDomainDetachChrDevice
Michal Privoznik [Thu, 14 Feb 2019 09:38:09 +0000 (10:38 +0100)]
qemu_hotplug: Don't build device string in qemuDomainDetachChrDevice

This is basically an old artefact from 24b0821926e when the idea
was:

1) Build device string only to see if chardev has any -device
associated with it and thus if device_del is needed
2) Detach chardev using chardev_del

Now, that DEVICE and DEVICE_DELETED capabilities are assumed for
every domain 1) does not make sense anymore.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemuhotplugtest: Test guestfwd attach and detach
Michal Privoznik [Mon, 11 Feb 2019 15:17:53 +0000 (16:17 +0100)]
qemuhotplugtest: Test guestfwd attach and detach

Previous two commits demonstrate a hole in our test scenario.
Fix that.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu_hotplug: Detach guestfwd using netdev_del
Michal Privoznik [Mon, 11 Feb 2019 13:16:58 +0000 (14:16 +0100)]
qemu_hotplug: Detach guestfwd using netdev_del

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

The guestfwd channels are -netdevs really. Hotunplug them as
such. Also, DEVICE_DELETED event is not triggered (surprisingly,
since we're not issuing device_del rather than netdev_del) and
associated chardev is removed automagically too. This means that
we need to do qemuDomainRemoveChrDevice() minus monitor call to
remove the chardev.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu_hotplug: Attach guestfwd using netdev_add
Michal Privoznik [Mon, 11 Feb 2019 15:05:37 +0000 (16:05 +0100)]
qemu_hotplug: Attach guestfwd using netdev_add

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

The guestfwd channels are -netdevs really. Hotplug them as such.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemuL: Drop "user-" prefix for guestfwd netdev
Michal Privoznik [Mon, 11 Feb 2019 13:16:00 +0000 (14:16 +0100)]
qemuL: Drop "user-" prefix for guestfwd netdev

Introduced by d86c876a66e3.

There is no real need to have "user-" prefix for chardev.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: Use @tmpChr in qemuDomainDetachChrDevice to build device string
Michal Privoznik [Mon, 11 Feb 2019 13:13:39 +0000 (14:13 +0100)]
qemu: Use @tmpChr in qemuDomainDetachChrDevice to build device string

So far we are passing @chr to qemuBuildChrDeviceStr. This is
suboptimal (in fact wrong) because @chr is just parsed XML
definition provided by user which by definition may lack some
information. On the other hand, @tmpChr is the one that was found
using @chr in domain definition so it contains the same amount of
information or more.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoqemu: Escape external snapshot names containing comma
Eric Blake [Wed, 13 Feb 2019 04:18:15 +0000 (22:18 -0600)]
qemu: Escape external snapshot names containing comma

The code for creating external snapshots for an offline domain
called out to qemu-img without escaping commas in the manner
that qemu-img expects. This also fixes a typo in the comment.

Signed-off-by: Eric Blake <eblake@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoutil: fix memory leak in virFirewallDInterfaceSetZone()
Laine Stump [Wed, 13 Feb 2019 15:57:57 +0000 (10:57 -0500)]
util: fix memory leak in virFirewallDInterfaceSetZone()

commit 3bba4825 added the new function virFirewallDInterfaceSetZone()
which calledsends virDBUSCallMethod a DBusMessage** for the reply
message, but doesn't use the reply, and also doesn't free it. Since
this arg is allowed to be NULL, this patch simply sets it to NULL so
we don't have to deal with it.

Signed-off-by: Laine Stump <laine@laine.org>
Reviewed-by: Andrea Bolognani <abologna@redhat.com>
6 years agovirsh: initialize info in cmdIOThreadInfo
Ján Tomko [Tue, 12 Feb 2019 11:04:24 +0000 (12:04 +0100)]
virsh: initialize info in cmdIOThreadInfo

Although it is not needed at the moment, do not rely on a value being
set before the first jump to cleanup.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agovirsh: remove redundant virshNodeGetCPUCount
Ján Tomko [Tue, 12 Feb 2019 10:52:59 +0000 (11:52 +0100)]
virsh: remove redundant virshNodeGetCPUCount

Since commit 4c4b821e it is not used for anything.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agovirsh: do not assign negative values to niothreads
Ján Tomko [Tue, 12 Feb 2019 10:42:36 +0000 (11:42 +0100)]
virsh: do not assign negative values to niothreads

Use a temporary 'rc' variable to avoid comparing signed
and unsigned integers in the cleanup section.

Bug introduced by commit 3072ded which added the comparison against
the unsigned 'i'.

Also make niothreads size_t to mark that it should be unsigned.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agovirsh: reduce the optimism in cmdIOThreadInfo
Ján Tomko [Tue, 12 Feb 2019 09:35:17 +0000 (10:35 +0100)]
virsh: reduce the optimism in cmdIOThreadInfo

Instead of using niothreads which defaults to zero, use the common
pattern with a ret varaible set to true just before the cleanup label.

Signed-off-by: Ján Tomko <jtomko@redhat.com>
Reviewed-by: John Ferlan <jferlan@redhat.com>
6 years agoutil: Introduce VIR_DEFINE_AUTOPTR_FUNC for virStorageSource
John Ferlan [Tue, 12 Feb 2019 18:17:56 +0000 (13:17 -0500)]
util: Introduce VIR_DEFINE_AUTOPTR_FUNC for virStorageSource

Let's make use of the auto __cleanup capabilities cleaning up any
now unnecessary goto paths.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutil: Check for duplicated id in virStorageSourceParseRBDColonString
John Ferlan [Tue, 12 Feb 2019 13:36:40 +0000 (08:36 -0500)]
util: Check for duplicated id in virStorageSourceParseRBDColonString

If we find multiple "id=" strings during processing, then we need
to force an error since we cannot have multiple <auth>'s defined
for a single source volume.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Check for duplicate authdef during hostdev iSCSI processing
John Ferlan [Tue, 12 Feb 2019 13:35:38 +0000 (08:35 -0500)]
conf: Check for duplicate authdef during hostdev iSCSI processing

If virDomainHostdevSubsysSCSIiSCSIDefParseXML processing finds a
duplicated <auth> structure, we should error out rather than continue.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: Fix memory leak in testCompareXMLToArgvFiles
John Ferlan [Fri, 8 Feb 2019 15:43:23 +0000 (10:43 -0500)]
tests: Fix memory leak in testCompareXMLToArgvFiles

Only one path will consume the @def; otherwise, we need to free it.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agostorage: Use VIR_AUTOCLOSE
John Ferlan [Thu, 31 Jan 2019 23:56:27 +0000 (18:56 -0500)]
storage: Use VIR_AUTOCLOSE

Modify code to use the VIR_AUTOCLOSE logic cleaning up any
now unnecessary goto paths.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agostorage: Rework ret logic in storageBackendUpdateVolTargetInfo
John Ferlan [Tue, 12 Feb 2019 12:46:38 +0000 (07:46 -0500)]
storage: Rework ret logic in storageBackendUpdateVolTargetInfo

Rather than overload @ret with trying serve multiple purposes,
let's initialize @ret to -1 and introduce an @rc function return
value that can be used for functions that may return -1 or -2
and only override @ret when rc < 0.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agostorage: Use VIR_AUTOFREE for storage backends
John Ferlan [Thu, 31 Jan 2019 17:09:38 +0000 (12:09 -0500)]
storage: Use VIR_AUTOFREE for storage backends

Let's make use of the auto __cleanup capabilities. This also allows
for the cleanup of some goto paths.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agostorage: Cleanup virStorageFileBackendGlusterReadlinkCallback
John Ferlan [Tue, 12 Feb 2019 11:23:01 +0000 (06:23 -0500)]
storage: Cleanup virStorageFileBackendGlusterReadlinkCallback

Rather than having two exit paths, let's use a @retval value
and VIR_STEAL_PTR in order to unite the exit path through the
error label.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: Rename variable in testStorageFileGetMetadata
John Ferlan [Fri, 8 Feb 2019 13:35:56 +0000 (08:35 -0500)]
tests: Rename variable in testStorageFileGetMetadata

To prepare for subsequent change to use VIR_AUTOPTR logic rename
the @ret to @def.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutil: Rename variable in virStorageSourceNewFromBacking
John Ferlan [Fri, 8 Feb 2019 13:33:33 +0000 (08:33 -0500)]
util: Rename variable in virStorageSourceNewFromBacking

To prepare for subsequent change to use VIR_AUTOPTR logic rename
the @ret to @def.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutil: Rename variable in virStorageSourceNewFromBackingAbsolute
John Ferlan [Fri, 8 Feb 2019 13:31:51 +0000 (08:31 -0500)]
util: Rename variable in virStorageSourceNewFromBackingAbsolute

To prepare for subsequent change to use VIR_AUTOPTR logic rename
the @ret to @def.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutil: Rename variable in virStorageSourceNewFromBackingRelative
John Ferlan [Fri, 8 Feb 2019 13:29:41 +0000 (08:29 -0500)]
util: Rename variable in virStorageSourceNewFromBackingRelative

To prepare for subsequent change to use VIR_AUTOPTR logic rename
the @ret to @def.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutil: Rename variable in virStorageSourceCopy
John Ferlan [Fri, 8 Feb 2019 13:28:27 +0000 (08:28 -0500)]
util: Rename variable in virStorageSourceCopy

To prepare for subsequent change to use VIR_AUTOPTR logic rename
the @ret to @def.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutil: Rename variable in virStorageFileMetadataNew
John Ferlan [Fri, 8 Feb 2019 13:25:50 +0000 (08:25 -0500)]
util: Rename variable in virStorageFileMetadataNew

To prepare for subsequent change to use VIR_AUTOPTR logic rename
the @ret to @def.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agostorage: Use VIR_STEAL_PTR in storageBackendProbeTarget
John Ferlan [Thu, 7 Feb 2019 13:15:12 +0000 (08:15 -0500)]
storage: Use VIR_STEAL_PTR in storageBackendProbeTarget

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotests: Use VIR_AUTOFREE for various storage tests
John Ferlan [Fri, 1 Feb 2019 17:03:16 +0000 (12:03 -0500)]
tests: Use VIR_AUTOFREE for various storage tests

Let's make use of the auto __cleanup capabilities cleaning up any
now unnecessary goto paths.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotest: Use VIR_AUTOFREE for test driver
John Ferlan [Fri, 1 Feb 2019 13:54:56 +0000 (08:54 -0500)]
test: Use VIR_AUTOFREE for test driver

Let's make use of the auto __cleanup capabilities cleaning up any
now unnecessary goto paths.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotest: Remove unused @xml from testDomainSnapshotCreateXML
John Ferlan [Fri, 8 Feb 2019 15:36:54 +0000 (10:36 -0500)]
test: Remove unused @xml from testDomainSnapshotCreateXML

Commit 390c06b67 added @xml, but it was never used.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agotest: Cleanup testDomainRenameCallback
John Ferlan [Thu, 7 Feb 2019 13:11:03 +0000 (08:11 -0500)]
test: Cleanup testDomainRenameCallback

Rather than have a need for old_dom_name, let's just VIR_FREE
the old name first, then use VIR_STEAL_PTR to handle the swap
from the old name to the new name.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutil: Use VIR_AUTOFREE for virstoragefile
John Ferlan [Fri, 1 Feb 2019 12:40:40 +0000 (07:40 -0500)]
util: Use VIR_AUTOFREE for virstoragefile

Let's make use of the auto __cleanup capabilities cleaning up any
now unnecessary goto paths.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutil: Use VIR_STEAL_PTR in virstoragefile
John Ferlan [Thu, 7 Feb 2019 13:07:50 +0000 (08:07 -0500)]
util: Use VIR_STEAL_PTR in virstoragefile

Rather than open coding virStorageFileGetRelativeBackingPath
and virStorageFileGetMetadataRecurse, let's make use of the
VIR_STEAL_PTR macro.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Use VIR_AUTOFREE for storage_conf
John Ferlan [Thu, 31 Jan 2019 13:20:02 +0000 (08:20 -0500)]
conf: Use VIR_AUTOFREE for storage_conf

Let's make use of the auto __cleanup capabilities cleaning up any
now unnecessary goto paths.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoconf: Remove @name in virStoragePoolDefParseSource
John Ferlan [Tue, 12 Feb 2019 12:04:42 +0000 (07:04 -0500)]
conf: Remove @name in virStoragePoolDefParseSource

Remove the need for the @name variable by directly assigning
into source->hosts[i].name.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
6 years agostorage: Use VIR_AUTOFREE for storage util
John Ferlan [Thu, 31 Jan 2019 19:18:51 +0000 (14:18 -0500)]
storage: Use VIR_AUTOFREE for storage util

Let's make use of the auto __cleanup capabilities cleaning up any
now unnecessary goto paths.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agostorage: Fix error retval for getDeviceType
John Ferlan [Tue, 12 Feb 2019 12:00:38 +0000 (07:00 -0500)]
storage: Fix error retval for getDeviceType

On error from virAsprintf we would erroneously return 0 with
the @*type not being set. Change to a return -1 on error like
we should have been doing.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agoutil: Fix virStorageBackendSCSINewLun error handling
John Ferlan [Fri, 8 Feb 2019 15:25:27 +0000 (10:25 -0500)]
util: Fix virStorageBackendSCSINewLun error handling

Commit a523770c3 added @retval return processing for
virStorageBackendUpdateVolInfo in order to allow a -2
to be return; however, upon successful completion
@retval = 0 and if either the virStorageBackendSCSISerial
or the virStoragePoolObjAddVol failed, the method would
return 0, but not add the @vol to the pool. So let's
just reset retval = -1 and continue processing.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agostorage: Use VIR_AUTOFREE for storage driver
John Ferlan [Thu, 31 Jan 2019 18:41:29 +0000 (13:41 -0500)]
storage: Use VIR_AUTOFREE for storage driver

Let's make use of the auto __cleanup capabilities cleaning up any
now unnecessary goto paths.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>
6 years agostorage: Invert retval logic in virStorageBackendSCSITriggerRescan
John Ferlan [Tue, 12 Feb 2019 02:48:53 +0000 (21:48 -0500)]
storage: Invert retval logic in virStorageBackendSCSITriggerRescan

Rather than initialize to 0 and change to -1 on error, let's do the
normal operation of initializing to -1 and set to 0 on success.

Signed-off-by: John Ferlan <jferlan@redhat.com>
Reviewed-by: Ján Tomko <jtomko@redhat.com>