qapi event: convert QUORUM events
Signed-off-by: Wenchao Xia <wenchaoqemu@gmail.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com> Reviewed-by: Eric Blake <eblake@redhat.com> Signed-off-by: Luiz Capitulino <lcapitulino@redhat.com>
This commit is contained in:
parent
3a44969037
commit
fe069d9d59
@ -17,6 +17,7 @@
|
|||||||
#include <gnutls/crypto.h>
|
#include <gnutls/crypto.h>
|
||||||
#include "block/block_int.h"
|
#include "block/block_int.h"
|
||||||
#include "qapi/qmp/qjson.h"
|
#include "qapi/qmp/qjson.h"
|
||||||
|
#include "qapi-event.h"
|
||||||
|
|
||||||
#define HASH_LENGTH 32
|
#define HASH_LENGTH 32
|
||||||
|
|
||||||
@ -198,32 +199,22 @@ static QuorumAIOCB *quorum_aio_get(BDRVQuorumState *s,
|
|||||||
|
|
||||||
static void quorum_report_bad(QuorumAIOCB *acb, char *node_name, int ret)
|
static void quorum_report_bad(QuorumAIOCB *acb, char *node_name, int ret)
|
||||||
{
|
{
|
||||||
QObject *data;
|
const char *msg = NULL;
|
||||||
assert(node_name);
|
|
||||||
data = qobject_from_jsonf("{ 'node-name': %s"
|
|
||||||
", 'sector-num': %" PRId64
|
|
||||||
", 'sectors-count': %d }",
|
|
||||||
node_name, acb->sector_num, acb->nb_sectors);
|
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
QDict *dict = qobject_to_qdict(data);
|
msg = strerror(-ret);
|
||||||
qdict_put(dict, "error", qstring_from_str(strerror(-ret)));
|
|
||||||
}
|
}
|
||||||
monitor_protocol_event(QEVENT_QUORUM_REPORT_BAD, data);
|
qapi_event_send_quorum_report_bad(!!msg, msg, node_name,
|
||||||
qobject_decref(data);
|
acb->sector_num, acb->nb_sectors, &error_abort);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void quorum_report_failure(QuorumAIOCB *acb)
|
static void quorum_report_failure(QuorumAIOCB *acb)
|
||||||
{
|
{
|
||||||
QObject *data;
|
|
||||||
const char *reference = acb->common.bs->device_name[0] ?
|
const char *reference = acb->common.bs->device_name[0] ?
|
||||||
acb->common.bs->device_name :
|
acb->common.bs->device_name :
|
||||||
acb->common.bs->node_name;
|
acb->common.bs->node_name;
|
||||||
data = qobject_from_jsonf("{ 'reference': %s"
|
|
||||||
", 'sector-num': %" PRId64
|
qapi_event_send_quorum_failure(reference, acb->sector_num,
|
||||||
", 'sectors-count': %d }",
|
acb->nb_sectors, &error_abort);
|
||||||
reference, acb->sector_num, acb->nb_sectors);
|
|
||||||
monitor_protocol_event(QEVENT_QUORUM_FAILURE, data);
|
|
||||||
qobject_decref(data);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int quorum_vote_error(QuorumAIOCB *acb);
|
static int quorum_vote_error(QuorumAIOCB *acb);
|
||||||
|
@ -1,41 +0,0 @@
|
|||||||
QEMU Machine Protocol Events
|
|
||||||
============================
|
|
||||||
|
|
||||||
QUORUM_FAILURE
|
|
||||||
--------------
|
|
||||||
|
|
||||||
Emitted by the Quorum block driver if it fails to establish a quorum.
|
|
||||||
|
|
||||||
Data:
|
|
||||||
|
|
||||||
- "reference": device name if defined else node name.
|
|
||||||
- "sector-num": Number of the first sector of the failed read operation.
|
|
||||||
- "sector-count": Failed read operation sector count.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
{ "event": "QUORUM_FAILURE",
|
|
||||||
"data": { "reference": "usr1", "sector-num": 345435, "sector-count": 5 },
|
|
||||||
"timestamp": { "seconds": 1344522075, "microseconds": 745528 } }
|
|
||||||
|
|
||||||
QUORUM_REPORT_BAD
|
|
||||||
-----------------
|
|
||||||
|
|
||||||
Emitted to report a corruption of a Quorum file.
|
|
||||||
|
|
||||||
Data:
|
|
||||||
|
|
||||||
- "error": Error message (json-string, optional)
|
|
||||||
Only present on failure. This field contains a human-readable
|
|
||||||
error message. There are no semantics other than that the
|
|
||||||
block layer reported an error and clients should not try to
|
|
||||||
interpret the error string.
|
|
||||||
- "node-name": The graph node name of the block driver state.
|
|
||||||
- "sector-num": Number of the first sector of the failed read operation.
|
|
||||||
- "sector-count": Failed read operation sector count.
|
|
||||||
|
|
||||||
Example:
|
|
||||||
|
|
||||||
{ "event": "QUORUM_REPORT_BAD",
|
|
||||||
"data": { "node-name": "1.raw", "sector-num": 345435, "sector-count": 5 },
|
|
||||||
"timestamp": { "seconds": 1344522075, "microseconds": 745528 } }
|
|
@ -617,6 +617,9 @@ static void monitor_qapi_event_init(void)
|
|||||||
monitor_qapi_event_throttle(QAPI_EVENT_RTC_CHANGE, 1000);
|
monitor_qapi_event_throttle(QAPI_EVENT_RTC_CHANGE, 1000);
|
||||||
monitor_qapi_event_throttle(QAPI_EVENT_WATCHDOG, 1000);
|
monitor_qapi_event_throttle(QAPI_EVENT_WATCHDOG, 1000);
|
||||||
monitor_qapi_event_throttle(QAPI_EVENT_BALLOON_CHANGE, 1000);
|
monitor_qapi_event_throttle(QAPI_EVENT_BALLOON_CHANGE, 1000);
|
||||||
|
/* limit the rate of quorum events to avoid hammering the management */
|
||||||
|
monitor_qapi_event_throttle(QAPI_EVENT_QUORUM_REPORT_BAD, 1000);
|
||||||
|
monitor_qapi_event_throttle(QAPI_EVENT_QUORUM_FAILURE, 1000);
|
||||||
|
|
||||||
qmp_event_set_func_emit(monitor_qapi_event_queue);
|
qmp_event_set_func_emit(monitor_qapi_event_queue);
|
||||||
}
|
}
|
||||||
@ -743,9 +746,6 @@ monitor_protocol_event_throttle(MonitorEvent event,
|
|||||||
* and initialize state */
|
* and initialize state */
|
||||||
static void monitor_protocol_event_init(void)
|
static void monitor_protocol_event_init(void)
|
||||||
{
|
{
|
||||||
/* limit the rate of quorum events to avoid hammering the management */
|
|
||||||
monitor_protocol_event_throttle(QEVENT_QUORUM_REPORT_BAD, 1000);
|
|
||||||
monitor_protocol_event_throttle(QEVENT_QUORUM_FAILURE, 1000);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -278,3 +278,41 @@
|
|||||||
##
|
##
|
||||||
{ 'event': 'GUEST_PANICKED',
|
{ 'event': 'GUEST_PANICKED',
|
||||||
'data': { 'action': 'GuestPanicAction' } }
|
'data': { 'action': 'GuestPanicAction' } }
|
||||||
|
|
||||||
|
##
|
||||||
|
# @QUORUM_FAILURE
|
||||||
|
#
|
||||||
|
# Emitted by the Quorum block driver if it fails to establish a quorum
|
||||||
|
#
|
||||||
|
# @reference: device name if defined else node name
|
||||||
|
#
|
||||||
|
# @sector-num: number of the first sector of the failed read operation
|
||||||
|
#
|
||||||
|
# @sector-count: failed read operation sector count
|
||||||
|
#
|
||||||
|
# Since: 2.0
|
||||||
|
##
|
||||||
|
{ 'event': 'QUORUM_FAILURE',
|
||||||
|
'data': { 'reference': 'str', 'sector-num': 'int', 'sector-count': 'int' } }
|
||||||
|
|
||||||
|
##
|
||||||
|
# @QUORUM_REPORT_BAD
|
||||||
|
#
|
||||||
|
# Emitted to report a corruption of a Quorum file
|
||||||
|
#
|
||||||
|
# @error: #optional, error message. Only present on failure. This field
|
||||||
|
# contains a human-readable error message. There are no semantics other
|
||||||
|
# than that the block layer reported an error and clients should not
|
||||||
|
# try to interpret the error string.
|
||||||
|
#
|
||||||
|
# @node-name: the graph node name of the block driver state
|
||||||
|
#
|
||||||
|
# @sector-num: number of the first sector of the failed read operation
|
||||||
|
#
|
||||||
|
# @sector-count: failed read operation sector count
|
||||||
|
#
|
||||||
|
# Since: 2.0
|
||||||
|
##
|
||||||
|
{ 'event': 'QUORUM_REPORT_BAD',
|
||||||
|
'data': { '*error': 'str', 'node-name': 'str',
|
||||||
|
'sector-num': 'int', 'sector-count': 'int' } }
|
||||||
|
Loading…
Reference in New Issue
Block a user