From: Michal Privoznik <mprivozn@redhat.com>
To: Paolo Bonzini <pbonzini@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH 5/5] pr-manager-helper: report event on connection/disconnection
Date: Wed, 27 Jun 2018 12:16:42 +0200 [thread overview]
Message-ID: <99e4c61b-38a2-37c8-091b-06a9f79955cc@redhat.com> (raw)
In-Reply-To: <20180626154028.11133-6-pbonzini@redhat.com>
On 06/26/2018 05:40 PM, Paolo Bonzini wrote:
> Let management know if there were any problems communicating with
> qemu-pr-helper. The event is edge-triggered, and is sent every time
> the connection status of the pr-manager-helper object changes.
>
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
> qapi/block.json | 24 ++++++++++++++++++++++++
> scsi/pr-manager-helper.c | 25 +++++++++++++++++++------
> 2 files changed, 43 insertions(+), 6 deletions(-)
>
> diff --git a/qapi/block.json b/qapi/block.json
> index dc3323c954..1882a8d107 100644
> --- a/qapi/block.json
> +++ b/qapi/block.json
> @@ -334,6 +334,30 @@
> { 'event': 'DEVICE_TRAY_MOVED',
> 'data': { 'device': 'str', 'id': 'str', 'tray-open': 'bool' } }
>
> +##
> +# @PR_MANAGER_STATUS_CHANGED:
> +#
> +# Emitted whenever the connected status of a persistent reservation
> +# manager changes.
> +#
> +# @id: The QOM path of the PR manager object
> +#
> +# @connected: true if the PR manager is connected to a backend
> +#
> +# Since: 2.12
> +#
> +# Example:
> +#
> +# <- { "event": "PR_MANAGER_STATUS_CHANGED",
> +# "data": { "id": "/object/pr-helper0",
> +# "connected": true
> +# },
> +# "timestamp": { "seconds": 1519840375, "microseconds": 450486 } }
> +#
> +##
> +{ 'event': 'PR_MANAGER_STATUS_CHANGED',
> + 'data': { 'id': 'str', 'connected': 'bool' } }
> +
> ##
> # @QuorumOpType:
> #
> diff --git a/scsi/pr-manager-helper.c b/scsi/pr-manager-helper.c
> index b11481be9e..6643caf4cf 100644
> --- a/scsi/pr-manager-helper.c
> +++ b/scsi/pr-manager-helper.c
> @@ -17,6 +17,7 @@
> #include "io/channel.h"
> #include "io/channel-socket.h"
> #include "pr-helper.h"
> +#include "qapi/qapi-events-block.h"
>
> #include <scsi/sg.h>
>
> @@ -33,6 +34,7 @@ typedef struct PRManagerHelper {
> PRManager parent;
>
> char *path;
> + char *qom_path;
>
> QemuMutex lock;
> QIOChannel *ioc;
> @@ -127,6 +129,8 @@ static int pr_manager_helper_initialize(PRManagerHelper *pr_mgr,
> goto out_close;
> }
>
> + qapi_event_send_pr_manager_status_changed(pr_mgr->qom_path, true,
> + &error_abort);
> return 0;
Also, can we emit this earlier? For instance at the two places where we
unset pr_mgr->ioc:
diff --git i/scsi/pr-manager-helper.c w/scsi/pr-manager-helper.c
index 6643caf4cf..4ca15dff3f 100644
--- i/scsi/pr-manager-helper.c
+++ w/scsi/pr-manager-helper.c
@@ -48,6 +48,8 @@ static int pr_manager_helper_read(PRManagerHelper *pr_mgr,
if (r < 0) {
object_unref(OBJECT(pr_mgr->ioc));
+ qapi_event_send_pr_manager_status_changed(pr_mgr->qom_path, false,
+ &error_abort);
pr_mgr->ioc = NULL;
return -EINVAL;
}
@@ -74,6 +76,8 @@ static int pr_manager_helper_write(PRManagerHelper *pr_mgr,
assert(n_written != QIO_CHANNEL_ERR_BLOCK);
object_unref(OBJECT(pr_mgr->ioc));
pr_mgr->ioc = NULL;
+ qapi_event_send_pr_manager_status_changed(pr_mgr->qom_path, false,
+ &error_abort);
return n_written < 0 ? -EINVAL : 0;
}
@@ -150,7 +154,6 @@ static int pr_manager_helper_run(PRManager *p,
int ret;
int expected_dir;
int attempts;
- bool was_connected = pr_mgr->ioc != NULL;
uint8_t cdb[PR_HELPER_CDB_SIZE] = { 0 };
if (!io_hdr->cmd_len || io_hdr->cmd_len > PR_HELPER_CDB_SIZE) {
@@ -232,11 +235,6 @@ static int pr_manager_helper_run(PRManager *p,
return ret;
out:
- if (was_connected) {
- qapi_event_send_pr_manager_status_changed(pr_mgr->qom_path, false,
- &error_abort);
- }
-
sense_len = scsi_build_sense(io_hdr->sbp, SENSE_CODE(LUN_COMM_FAILURE));
io_hdr->driver_status = SG_ERR_DRIVER_SENSE;
io_hdr->sb_len_wr = MIN(io_hdr->mx_sb_len, sense_len);
@@ -261,7 +259,7 @@ static void pr_manager_helper_complete(UserCreatable *uc, Error **errp)
{
PRManagerHelper *pr_mgr = PR_MANAGER_HELPER(uc);
- pr_mgr->qom_path = object_get_canonical_path(OBJECT(pr_mgr));
+ pr_mgr->qom_path = object_get_canonical_path_component(OBJECT(pr_mgr));
qemu_mutex_lock(&pr_mgr->lock);
pr_manager_helper_initialize(pr_mgr, errp);
With your approach the event is emitted only after the 5 reconnect
attempts (which makes little sense IMO). With my approach the event is
emitted a bit sooner so that reconnect has at least chance of
succeeding.
I've written some patches for libvirt and with these changes it works
well.
Michal
next prev parent reply other threads:[~2018-06-27 10:16 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-06-26 15:40 [Qemu-devel] [PATCH 0/5] pr-manager/qemu-pr-helper patches for QEMU 3.0 Paolo Bonzini
2018-06-26 15:40 ` [Qemu-devel] [PATCH 1/5] pr-helper: fix --socket-path default in help Paolo Bonzini
2018-06-26 16:13 ` Philippe Mathieu-Daudé
2018-06-26 16:24 ` Michal Privoznik
2018-06-26 15:40 ` [Qemu-devel] [PATCH 2/5] pr-helper: fix assertion failure on failed multipath PERSISTENT RESERVE IN Paolo Bonzini
2018-06-26 16:16 ` Philippe Mathieu-Daudé
2018-06-26 16:25 ` Michal Privoznik
2018-06-26 15:40 ` [Qemu-devel] [PATCH 3/5] pr-manager-helper: avoid SIGSEGV when writing to the socket fail Paolo Bonzini
2018-06-26 16:24 ` Michal Privoznik
2018-06-26 15:40 ` [Qemu-devel] [PATCH 4/5] pr-manager: add query-pr-managers QMP command Paolo Bonzini
2018-06-26 16:31 ` Michal Privoznik
2018-06-27 15:44 ` Paolo Bonzini
2018-06-28 7:05 ` Michal Prívozník
2018-06-28 7:08 ` Paolo Bonzini
2018-06-26 20:51 ` Eric Blake
2018-06-27 15:34 ` Paolo Bonzini
2018-06-26 15:40 ` [Qemu-devel] [PATCH 5/5] pr-manager-helper: report event on connection/disconnection Paolo Bonzini
2018-06-26 16:23 ` Philippe Mathieu-Daudé
2018-06-27 8:04 ` Michal Privoznik
2018-06-27 10:16 ` Michal Privoznik [this message]
2018-06-27 15:35 ` Paolo Bonzini
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=99e4c61b-38a2-37c8-091b-06a9f79955cc@redhat.com \
--to=mprivozn@redhat.com \
--cc=pbonzini@redhat.com \
--cc=qemu-devel@nongnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).