|
|
ae23c9 |
From e34b60deac41fc0c642598ea9e84e6c919fe2d02 Mon Sep 17 00:00:00 2001
|
|
|
ae23c9 |
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
ae23c9 |
Date: Fri, 6 Jul 2018 17:56:55 +0200
|
|
|
ae23c9 |
Subject: [PATCH 195/268] pr-manager: add query-pr-managers QMP command
|
|
|
ae23c9 |
|
|
|
ae23c9 |
RH-Author: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
ae23c9 |
Message-id: <20180706175659.30615-6-pbonzini@redhat.com>
|
|
|
ae23c9 |
Patchwork-id: 81251
|
|
|
ae23c9 |
O-Subject: [RHEL7.6 qemu-kvm-rhev PATCH 5/9] pr-manager: add query-pr-managers QMP command
|
|
|
ae23c9 |
Bugzilla: 1533158
|
|
|
ae23c9 |
RH-Acked-by: Laurent Vivier <lvivier@redhat.com>
|
|
|
ae23c9 |
RH-Acked-by: Stefan Hajnoczi <stefanha@redhat.com>
|
|
|
ae23c9 |
RH-Acked-by: Michal Privoznik <mprivozn@redhat.com>
|
|
|
ae23c9 |
|
|
|
ae23c9 |
This command lets you query the connection status of each pr-manager-helper
|
|
|
ae23c9 |
object.
|
|
|
ae23c9 |
|
|
|
ae23c9 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
|
ae23c9 |
(cherry picked from commit 5f64089416f0d77c87683401838f064c51a292ed)
|
|
|
ae23c9 |
|
|
|
ae23c9 |
[RHEL: no allow-preconfig yet, so don't specify it]
|
|
|
ae23c9 |
|
|
|
ae23c9 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
ae23c9 |
---
|
|
|
ae23c9 |
include/scsi/pr-manager.h | 2 ++
|
|
|
ae23c9 |
qapi/block.json | 27 +++++++++++++++++++++++++++
|
|
|
ae23c9 |
scsi/pr-manager-helper.c | 13 +++++++++++++
|
|
|
ae23c9 |
scsi/pr-manager-stub.c | 6 ++++++
|
|
|
ae23c9 |
scsi/pr-manager.c | 45 +++++++++++++++++++++++++++++++++++++++++++++
|
|
|
ae23c9 |
5 files changed, 93 insertions(+)
|
|
|
ae23c9 |
|
|
|
ae23c9 |
diff --git a/include/scsi/pr-manager.h b/include/scsi/pr-manager.h
|
|
|
ae23c9 |
index 71971ae..50a77b0 100644
|
|
|
ae23c9 |
--- a/include/scsi/pr-manager.h
|
|
|
ae23c9 |
+++ b/include/scsi/pr-manager.h
|
|
|
ae23c9 |
@@ -33,8 +33,10 @@ typedef struct PRManagerClass {
|
|
|
ae23c9 |
|
|
|
ae23c9 |
/* <public> */
|
|
|
ae23c9 |
int (*run)(PRManager *pr_mgr, int fd, struct sg_io_hdr *hdr);
|
|
|
ae23c9 |
+ bool (*is_connected)(PRManager *pr_mgr);
|
|
|
ae23c9 |
} PRManagerClass;
|
|
|
ae23c9 |
|
|
|
ae23c9 |
+bool pr_manager_is_connected(PRManager *pr_mgr);
|
|
|
ae23c9 |
BlockAIOCB *pr_manager_execute(PRManager *pr_mgr,
|
|
|
ae23c9 |
AioContext *ctx, int fd,
|
|
|
ae23c9 |
struct sg_io_hdr *hdr,
|
|
|
ae23c9 |
diff --git a/qapi/block.json b/qapi/block.json
|
|
|
ae23c9 |
index c694524..cf63ea2 100644
|
|
|
ae23c9 |
--- a/qapi/block.json
|
|
|
ae23c9 |
+++ b/qapi/block.json
|
|
|
ae23c9 |
@@ -78,6 +78,33 @@
|
|
|
ae23c9 |
'data': { 'device': 'str', 'name': 'str' } }
|
|
|
ae23c9 |
|
|
|
ae23c9 |
##
|
|
|
ae23c9 |
+# @PRManagerInfo:
|
|
|
ae23c9 |
+#
|
|
|
ae23c9 |
+# Information about a persistent reservation manager
|
|
|
ae23c9 |
+#
|
|
|
ae23c9 |
+# @id: the identifier of the persistent reservation manager
|
|
|
ae23c9 |
+#
|
|
|
ae23c9 |
+# @connected: true if the persistent reservation manager is connected to
|
|
|
ae23c9 |
+# the underlying storage or helper
|
|
|
ae23c9 |
+#
|
|
|
ae23c9 |
+# Since: 3.0
|
|
|
ae23c9 |
+##
|
|
|
ae23c9 |
+{ 'struct': 'PRManagerInfo',
|
|
|
ae23c9 |
+ 'data': {'id': 'str', 'connected': 'bool'} }
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+##
|
|
|
ae23c9 |
+# @query-pr-managers:
|
|
|
ae23c9 |
+#
|
|
|
ae23c9 |
+# Returns a list of information about each persistent reservation manager.
|
|
|
ae23c9 |
+#
|
|
|
ae23c9 |
+# Returns: a list of @PRManagerInfo for each persistent reservation manager
|
|
|
ae23c9 |
+#
|
|
|
ae23c9 |
+# Since: 3.0
|
|
|
ae23c9 |
+##
|
|
|
ae23c9 |
+{ 'command': 'query-pr-managers', 'returns': ['PRManagerInfo'] }
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+##
|
|
|
ae23c9 |
# @blockdev-snapshot-internal-sync:
|
|
|
ae23c9 |
#
|
|
|
ae23c9 |
# Synchronously take an internal snapshot of a block device, when the
|
|
|
ae23c9 |
diff --git a/scsi/pr-manager-helper.c b/scsi/pr-manager-helper.c
|
|
|
ae23c9 |
index 0c0fe38..b11481b 100644
|
|
|
ae23c9 |
--- a/scsi/pr-manager-helper.c
|
|
|
ae23c9 |
+++ b/scsi/pr-manager-helper.c
|
|
|
ae23c9 |
@@ -235,6 +235,18 @@ out:
|
|
|
ae23c9 |
return ret;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
+static bool pr_manager_helper_is_connected(PRManager *p)
|
|
|
ae23c9 |
+{
|
|
|
ae23c9 |
+ PRManagerHelper *pr_mgr = PR_MANAGER_HELPER(p);
|
|
|
ae23c9 |
+ bool result;
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ qemu_mutex_lock(&pr_mgr->lock);
|
|
|
ae23c9 |
+ result = (pr_mgr->ioc != NULL);
|
|
|
ae23c9 |
+ qemu_mutex_unlock(&pr_mgr->lock);
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ return result;
|
|
|
ae23c9 |
+}
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
static void pr_manager_helper_complete(UserCreatable *uc, Error **errp)
|
|
|
ae23c9 |
{
|
|
|
ae23c9 |
PRManagerHelper *pr_mgr = PR_MANAGER_HELPER(uc);
|
|
|
ae23c9 |
@@ -284,6 +296,7 @@ static void pr_manager_helper_class_init(ObjectClass *klass,
|
|
|
ae23c9 |
&error_abort);
|
|
|
ae23c9 |
uc_klass->complete = pr_manager_helper_complete;
|
|
|
ae23c9 |
prmgr_klass->run = pr_manager_helper_run;
|
|
|
ae23c9 |
+ prmgr_klass->is_connected = pr_manager_helper_is_connected;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
static const TypeInfo pr_manager_helper_info = {
|
|
|
ae23c9 |
diff --git a/scsi/pr-manager-stub.c b/scsi/pr-manager-stub.c
|
|
|
ae23c9 |
index 632f17c..738b6d7 100644
|
|
|
ae23c9 |
--- a/scsi/pr-manager-stub.c
|
|
|
ae23c9 |
+++ b/scsi/pr-manager-stub.c
|
|
|
ae23c9 |
@@ -22,3 +22,9 @@ PRManager *pr_manager_lookup(const char *id, Error **errp)
|
|
|
ae23c9 |
error_setg(errp, "No persistent reservation manager with id '%s'", id);
|
|
|
ae23c9 |
return NULL;
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+PRManagerInfoList *qmp_query_pr_managers(Error **errp)
|
|
|
ae23c9 |
+{
|
|
|
ae23c9 |
+ return NULL;
|
|
|
ae23c9 |
+}
|
|
|
ae23c9 |
diff --git a/scsi/pr-manager.c b/scsi/pr-manager.c
|
|
|
ae23c9 |
index 87c45db..2a8f300 100644
|
|
|
ae23c9 |
--- a/scsi/pr-manager.c
|
|
|
ae23c9 |
+++ b/scsi/pr-manager.c
|
|
|
ae23c9 |
@@ -17,6 +17,10 @@
|
|
|
ae23c9 |
#include "block/thread-pool.h"
|
|
|
ae23c9 |
#include "scsi/pr-manager.h"
|
|
|
ae23c9 |
#include "trace.h"
|
|
|
ae23c9 |
+#include "qapi/qapi-types-block.h"
|
|
|
ae23c9 |
+#include "qapi/qapi-commands-block.h"
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+#define PR_MANAGER_PATH "/objects"
|
|
|
ae23c9 |
|
|
|
ae23c9 |
typedef struct PRManagerData {
|
|
|
ae23c9 |
PRManager *pr_mgr;
|
|
|
ae23c9 |
@@ -64,6 +68,14 @@ BlockAIOCB *pr_manager_execute(PRManager *pr_mgr,
|
|
|
ae23c9 |
data, complete, opaque);
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
+bool pr_manager_is_connected(PRManager *pr_mgr)
|
|
|
ae23c9 |
+{
|
|
|
ae23c9 |
+ PRManagerClass *pr_mgr_class =
|
|
|
ae23c9 |
+ PR_MANAGER_GET_CLASS(pr_mgr);
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ return !pr_mgr_class->is_connected || pr_mgr_class->is_connected(pr_mgr);
|
|
|
ae23c9 |
+}
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
static const TypeInfo pr_manager_info = {
|
|
|
ae23c9 |
.parent = TYPE_OBJECT,
|
|
|
ae23c9 |
.name = TYPE_PR_MANAGER,
|
|
|
ae23c9 |
@@ -105,5 +117,38 @@ pr_manager_register_types(void)
|
|
|
ae23c9 |
type_register_static(&pr_manager_info);
|
|
|
ae23c9 |
}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
+static int query_one_pr_manager(Object *object, void *opaque)
|
|
|
ae23c9 |
+{
|
|
|
ae23c9 |
+ PRManagerInfoList ***prev = opaque;
|
|
|
ae23c9 |
+ PRManagerInfoList *elem;
|
|
|
ae23c9 |
+ PRManagerInfo *info;
|
|
|
ae23c9 |
+ PRManager *pr_mgr;
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ pr_mgr = (PRManager *)object_dynamic_cast(object, TYPE_PR_MANAGER);
|
|
|
ae23c9 |
+ if (!pr_mgr) {
|
|
|
ae23c9 |
+ return 0;
|
|
|
ae23c9 |
+ }
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ elem = g_new0(PRManagerInfoList, 1);
|
|
|
ae23c9 |
+ info = g_new0(PRManagerInfo, 1);
|
|
|
ae23c9 |
+ info->id = object_get_canonical_path_component(object);
|
|
|
ae23c9 |
+ info->connected = pr_manager_is_connected(pr_mgr);
|
|
|
ae23c9 |
+ elem->value = info;
|
|
|
ae23c9 |
+ elem->next = NULL;
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ **prev = elem;
|
|
|
ae23c9 |
+ *prev = &elem->next;
|
|
|
ae23c9 |
+ return 0;
|
|
|
ae23c9 |
+}
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+PRManagerInfoList *qmp_query_pr_managers(Error **errp)
|
|
|
ae23c9 |
+{
|
|
|
ae23c9 |
+ PRManagerInfoList *head = NULL;
|
|
|
ae23c9 |
+ PRManagerInfoList **prev = &head;
|
|
|
ae23c9 |
+ Object *container = container_get(object_get_root(), PR_MANAGER_PATH);
|
|
|
ae23c9 |
+
|
|
|
ae23c9 |
+ object_child_foreach(container, query_one_pr_manager, &prev;;
|
|
|
ae23c9 |
+ return head;
|
|
|
ae23c9 |
+}
|
|
|
ae23c9 |
|
|
|
ae23c9 |
type_init(pr_manager_register_types);
|
|
|
ae23c9 |
--
|
|
|
ae23c9 |
1.8.3.1
|
|
|
ae23c9 |
|