[libvirt] [PATCH 07/10] qemu: hotplug: Simplify removal of managed PR infrastructure on unplug
John Ferlan
jferlan at redhat.com
Sat Jul 21 11:23:51 UTC 2018
On 07/17/2018 08:14 AM, Peter Krempa wrote:
> Extract the (possible) removal of the PR backend and daemon into a
> separate helper which enters monitor on it's own. This simplifies the
> code and allows reuse of this function in the future e.g. for blockjobs
> where removing a image with PR may result into PR not being necessary.
>
> Since the PR is not used often the overhead of entering monitor again
> should be negligible.
>
> Signed-off-by: Peter Krempa <pkrempa at redhat.com>
> ---
> src/qemu/qemu_hotplug.c | 49 ++++++++++++++++++++++++++++++++++++++-----------
> 1 file changed, 38 insertions(+), 11 deletions(-)
>
> diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c
> index 3ee74c8e40..57ab753974 100644
> --- a/src/qemu/qemu_hotplug.c
> +++ b/src/qemu/qemu_hotplug.c
> @@ -350,6 +350,41 @@ qemuDomainDiskAttachManagedPR(virDomainObjPtr vm,
> }
>
>
> +/**
> + * qemuHotplugRemoveManagedPR:
> + * @driver: QEMU driver object
> + * @vm: domain object
> + * @asyncJob: asynchronous job identifier
> + *
> + * Removes the managed PR object from @vm if the configuration does not require
> + * it any more.
> + */
> +static int
> +qemuHotplugRemoveManagedPR(virQEMUDriverPtr driver,
> + virDomainObjPtr vm,
> + qemuDomainAsyncJob asyncJob)
> +{
> + qemuDomainObjPrivatePtr priv = vm->privateData;
> + virErrorPtr orig_err;
> + virErrorPreserveLast(&orig_err);
Coverity points out that orig_err is leaked at each subsequent return
before the virErrorRestore below
John
> +
> + if (!priv->prDaemonRunning ||
> + virDomainDefHasManagedPR(vm->def))
> + return 0;
> +
> + if (qemuDomainObjEnterMonitorAsync(driver, vm, asyncJob) < 0)
> + return -1;
> + ignore_value(qemuMonitorDelObject(priv->mon, qemuDomainGetManagedPRAlias()));
> + if (qemuDomainObjExitMonitor(driver, vm) < 0)
> + return -1;
> +
> + qemuProcessKillManagedPRDaemon(vm);
> + virErrorRestore(&orig_err);
> +
> + return 0;
> +}
> +
> +
[...]
More information about the libvir-list
mailing list