|
Paolo Bonzini |
0fb2b2 |
From 3caf122d29ecc3317671a9f651a236e8d02e2e90 Mon Sep 17 00:00:00 2001
|
|
Paolo Bonzini |
0fb2b2 |
From: Paolo Bonzini <pbonzini@redhat.com>
|
|
Paolo Bonzini |
0fb2b2 |
Date: Mon, 21 Aug 2017 18:58:56 +0200
|
|
Paolo Bonzini |
0fb2b2 |
Subject: [PATCH 15/15] scsi: add persistent reservation manager using
|
|
Paolo Bonzini |
0fb2b2 |
qemu-pr-helper
|
|
Paolo Bonzini |
0fb2b2 |
|
|
Paolo Bonzini |
0fb2b2 |
This adds a concrete subclass of pr-manager that talks to qemu-pr-helper.
|
|
Paolo Bonzini |
0fb2b2 |
|
|
Paolo Bonzini |
0fb2b2 |
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
|
|
Paolo Bonzini |
0fb2b2 |
---
|
|
Paolo Bonzini |
0fb2b2 |
scsi/Makefile.objs | 2 +-
|
|
Paolo Bonzini |
0fb2b2 |
scsi/pr-manager-helper.c | 302 +++++++++++++++++++++++++++++++++++++++++++++++
|
|
Paolo Bonzini |
0fb2b2 |
2 files changed, 303 insertions(+), 1 deletion(-)
|
|
Paolo Bonzini |
0fb2b2 |
create mode 100644 scsi/pr-manager-helper.c
|
|
Paolo Bonzini |
0fb2b2 |
|
|
Paolo Bonzini |
0fb2b2 |
diff --git a/scsi/Makefile.objs b/scsi/Makefile.objs
|
|
Paolo Bonzini |
0fb2b2 |
index 5496d2ae6a..4d25e476cf 100644
|
|
Paolo Bonzini |
0fb2b2 |
--- a/scsi/Makefile.objs
|
|
Paolo Bonzini |
0fb2b2 |
+++ b/scsi/Makefile.objs
|
|
Paolo Bonzini |
0fb2b2 |
@@ -1,3 +1,3 @@
|
|
Paolo Bonzini |
0fb2b2 |
block-obj-y += utils.o
|
|
Paolo Bonzini |
0fb2b2 |
|
|
Paolo Bonzini |
0fb2b2 |
-block-obj-$(CONFIG_LINUX) += pr-manager.o
|
|
Paolo Bonzini |
0fb2b2 |
+block-obj-$(CONFIG_LINUX) += pr-manager.o pr-manager-helper.o
|
|
Paolo Bonzini |
0fb2b2 |
diff --git a/scsi/pr-manager-helper.c b/scsi/pr-manager-helper.c
|
|
Paolo Bonzini |
0fb2b2 |
new file mode 100644
|
|
Paolo Bonzini |
0fb2b2 |
index 0000000000..82ff6b6123
|
|
Paolo Bonzini |
0fb2b2 |
--- /dev/null
|
|
Paolo Bonzini |
0fb2b2 |
+++ b/scsi/pr-manager-helper.c
|
|
Paolo Bonzini |
0fb2b2 |
@@ -0,0 +1,302 @@
|
|
Paolo Bonzini |
0fb2b2 |
+/*
|
|
Paolo Bonzini |
0fb2b2 |
+ * Persistent reservation manager that talks to qemu-pr-helper
|
|
Paolo Bonzini |
0fb2b2 |
+ *
|
|
Paolo Bonzini |
0fb2b2 |
+ * Copyright (c) 2017 Red Hat, Inc.
|
|
Paolo Bonzini |
0fb2b2 |
+ *
|
|
Paolo Bonzini |
0fb2b2 |
+ * Author: Paolo Bonzini <pbonzini@redhat.com>
|
|
Paolo Bonzini |
0fb2b2 |
+ *
|
|
Paolo Bonzini |
0fb2b2 |
+ * This code is licensed under the LGPL v2.1 or later.
|
|
Paolo Bonzini |
0fb2b2 |
+ *
|
|
Paolo Bonzini |
0fb2b2 |
+ */
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+#include "qemu/osdep.h"
|
|
Paolo Bonzini |
0fb2b2 |
+#include "qapi/error.h"
|
|
Paolo Bonzini |
0fb2b2 |
+#include "scsi/constants.h"
|
|
Paolo Bonzini |
0fb2b2 |
+#include "scsi/pr-manager.h"
|
|
Paolo Bonzini |
0fb2b2 |
+#include "scsi/utils.h"
|
|
Paolo Bonzini |
0fb2b2 |
+#include "io/channel.h"
|
|
Paolo Bonzini |
0fb2b2 |
+#include "io/channel-socket.h"
|
|
Paolo Bonzini |
0fb2b2 |
+#include "pr-helper.h"
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+#include <scsi/sg.h>
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+#define PR_MAX_RECONNECT_ATTEMPTS 5
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+#define TYPE_PR_MANAGER_HELPER "pr-manager-helper"
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+#define PR_MANAGER_HELPER(obj) \
|
|
Paolo Bonzini |
0fb2b2 |
+ OBJECT_CHECK(PRManagerHelper, (obj), \
|
|
Paolo Bonzini |
0fb2b2 |
+ TYPE_PR_MANAGER_HELPER)
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+typedef struct PRManagerHelper {
|
|
Paolo Bonzini |
0fb2b2 |
+ /* <private> */
|
|
Paolo Bonzini |
0fb2b2 |
+ PRManager parent;
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+ char *path;
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+ QemuMutex lock;
|
|
Paolo Bonzini |
0fb2b2 |
+ QIOChannel *ioc;
|
|
Paolo Bonzini |
0fb2b2 |
+} PRManagerHelper;
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+/* Called with lock held. */
|
|
Paolo Bonzini |
0fb2b2 |
+static int pr_manager_helper_read(PRManagerHelper *pr_mgr,
|
|
Paolo Bonzini |
0fb2b2 |
+ void *buf, int sz, Error **errp)
|
|
Paolo Bonzini |
0fb2b2 |
+{
|
|
Paolo Bonzini |
0fb2b2 |
+ ssize_t r = qio_channel_read_all(pr_mgr->ioc, buf, sz, errp);
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+ if (r < 0) {
|
|
Paolo Bonzini |
0fb2b2 |
+ object_unref(OBJECT(pr_mgr->ioc));
|
|
Paolo Bonzini |
0fb2b2 |
+ pr_mgr->ioc = NULL;
|
|
Paolo Bonzini |
0fb2b2 |
+ return -EINVAL;
|
|
Paolo Bonzini |
0fb2b2 |
+ }
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+ return 0;
|
|
Paolo Bonzini |
0fb2b2 |
+}
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+/* Called with lock held. */
|
|
Paolo Bonzini |
0fb2b2 |
+static int pr_manager_helper_write(PRManagerHelper *pr_mgr,
|
|
Paolo Bonzini |
0fb2b2 |
+ int fd,
|
|
Paolo Bonzini |
0fb2b2 |
+ const void *buf, int sz, Error **errp)
|
|
Paolo Bonzini |
0fb2b2 |
+{
|
|
Paolo Bonzini |
0fb2b2 |
+ size_t nfds = (fd != -1);
|
|
Paolo Bonzini |
0fb2b2 |
+ while (sz > 0) {
|
|
Paolo Bonzini |
0fb2b2 |
+ struct iovec iov;
|
|
Paolo Bonzini |
0fb2b2 |
+ ssize_t n_written;
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+ iov.iov_base = (void *)buf;
|
|
Paolo Bonzini |
0fb2b2 |
+ iov.iov_len = sz;
|
|
Paolo Bonzini |
0fb2b2 |
+ n_written = qio_channel_writev_full(QIO_CHANNEL(pr_mgr->ioc), &iov, 1,
|
|
Paolo Bonzini |
0fb2b2 |
+ nfds ? &fd : NULL, nfds, errp);
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+ if (n_written <= 0) {
|
|
Paolo Bonzini |
0fb2b2 |
+ assert(n_written != QIO_CHANNEL_ERR_BLOCK);
|
|
Paolo Bonzini |
0fb2b2 |
+ object_unref(OBJECT(pr_mgr->ioc));
|
|
Paolo Bonzini |
0fb2b2 |
+ return n_written < 0 ? -EINVAL : 0;
|
|
Paolo Bonzini |
0fb2b2 |
+ }
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+ nfds = 0;
|
|
Paolo Bonzini |
0fb2b2 |
+ buf += n_written;
|
|
Paolo Bonzini |
0fb2b2 |
+ sz -= n_written;
|
|
Paolo Bonzini |
0fb2b2 |
+ }
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+ return 0;
|
|
Paolo Bonzini |
0fb2b2 |
+}
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+/* Called with lock held. */
|
|
Paolo Bonzini |
0fb2b2 |
+static int pr_manager_helper_initialize(PRManagerHelper *pr_mgr,
|
|
Paolo Bonzini |
0fb2b2 |
+ Error **errp)
|
|
Paolo Bonzini |
0fb2b2 |
+{
|
|
Paolo Bonzini |
0fb2b2 |
+ char *path = g_strdup(pr_mgr->path);
|
|
Paolo Bonzini |
0fb2b2 |
+ SocketAddress saddr = {
|
|
Paolo Bonzini |
0fb2b2 |
+ .type = SOCKET_ADDRESS_TYPE_UNIX,
|
|
Paolo Bonzini |
0fb2b2 |
+ .u.q_unix.path = path
|
|
Paolo Bonzini |
0fb2b2 |
+ };
|
|
Paolo Bonzini |
0fb2b2 |
+ QIOChannelSocket *sioc = qio_channel_socket_new();
|
|
Paolo Bonzini |
0fb2b2 |
+ Error *local_err = NULL;
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+ uint32_t flags;
|
|
Paolo Bonzini |
0fb2b2 |
+ int r;
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+ assert(!pr_mgr->ioc);
|
|
Paolo Bonzini |
0fb2b2 |
+ qio_channel_set_name(QIO_CHANNEL(sioc), "pr-manager-helper");
|
|
Paolo Bonzini |
0fb2b2 |
+ qio_channel_socket_connect_sync(sioc,
|
|
Paolo Bonzini |
0fb2b2 |
+ &saddr,
|
|
Paolo Bonzini |
0fb2b2 |
+ &local_err);
|
|
Paolo Bonzini |
0fb2b2 |
+ g_free(path);
|
|
Paolo Bonzini |
0fb2b2 |
+ if (local_err) {
|
|
Paolo Bonzini |
0fb2b2 |
+ object_unref(OBJECT(sioc));
|
|
Paolo Bonzini |
0fb2b2 |
+ error_propagate(errp, local_err);
|
|
Paolo Bonzini |
0fb2b2 |
+ return -ENOTCONN;
|
|
Paolo Bonzini |
0fb2b2 |
+ }
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+ qio_channel_set_delay(QIO_CHANNEL(sioc), false);
|
|
Paolo Bonzini |
0fb2b2 |
+ pr_mgr->ioc = QIO_CHANNEL(sioc);
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+ /* A simple feature negotation protocol, even though there is
|
|
Paolo Bonzini |
0fb2b2 |
+ * no optional feature right now.
|
|
Paolo Bonzini |
0fb2b2 |
+ */
|
|
Paolo Bonzini |
0fb2b2 |
+ r = pr_manager_helper_read(pr_mgr, &flags, sizeof(flags), errp);
|
|
Paolo Bonzini |
0fb2b2 |
+ if (r < 0) {
|
|
Paolo Bonzini |
0fb2b2 |
+ goto out_close;
|
|
Paolo Bonzini |
0fb2b2 |
+ }
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+ flags = 0;
|
|
Paolo Bonzini |
0fb2b2 |
+ r = pr_manager_helper_write(pr_mgr, -1, &flags, sizeof(flags), errp);
|
|
Paolo Bonzini |
0fb2b2 |
+ if (r < 0) {
|
|
Paolo Bonzini |
0fb2b2 |
+ goto out_close;
|
|
Paolo Bonzini |
0fb2b2 |
+ }
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+ return 0;
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+out_close:
|
|
Paolo Bonzini |
0fb2b2 |
+ object_unref(OBJECT(pr_mgr->ioc));
|
|
Paolo Bonzini |
0fb2b2 |
+ pr_mgr->ioc = NULL;
|
|
Paolo Bonzini |
0fb2b2 |
+ return r;
|
|
Paolo Bonzini |
0fb2b2 |
+}
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+static int pr_manager_helper_run(PRManager *p,
|
|
Paolo Bonzini |
0fb2b2 |
+ int fd, struct sg_io_hdr *io_hdr)
|
|
Paolo Bonzini |
0fb2b2 |
+{
|
|
Paolo Bonzini |
0fb2b2 |
+ PRManagerHelper *pr_mgr = PR_MANAGER_HELPER(p);
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+ uint32_t len;
|
|
Paolo Bonzini |
0fb2b2 |
+ PRHelperResponse resp;
|
|
Paolo Bonzini |
0fb2b2 |
+ int ret;
|
|
Paolo Bonzini |
0fb2b2 |
+ int expected_dir;
|
|
Paolo Bonzini |
0fb2b2 |
+ int attempts;
|
|
Paolo Bonzini |
0fb2b2 |
+ uint8_t cdb[PR_HELPER_CDB_SIZE] = { 0 };
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+ if (!io_hdr->cmd_len || io_hdr->cmd_len > PR_HELPER_CDB_SIZE) {
|
|
Paolo Bonzini |
0fb2b2 |
+ return -EINVAL;
|
|
Paolo Bonzini |
0fb2b2 |
+ }
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+ memcpy(cdb, io_hdr->cmdp, io_hdr->cmd_len);
|
|
Paolo Bonzini |
0fb2b2 |
+ assert(cdb[0] == PERSISTENT_RESERVE_OUT || cdb[0] == PERSISTENT_RESERVE_IN);
|
|
Paolo Bonzini |
0fb2b2 |
+ expected_dir =
|
|
Paolo Bonzini |
0fb2b2 |
+ (cdb[0] == PERSISTENT_RESERVE_OUT ? SG_DXFER_TO_DEV : SG_DXFER_FROM_DEV);
|
|
Paolo Bonzini |
0fb2b2 |
+ if (io_hdr->dxfer_direction != expected_dir) {
|
|
Paolo Bonzini |
0fb2b2 |
+ return -EINVAL;
|
|
Paolo Bonzini |
0fb2b2 |
+ }
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+ len = scsi_cdb_xfer(cdb);
|
|
Paolo Bonzini |
0fb2b2 |
+ if (io_hdr->dxfer_len < len || len > PR_HELPER_DATA_SIZE) {
|
|
Paolo Bonzini |
0fb2b2 |
+ return -EINVAL;
|
|
Paolo Bonzini |
0fb2b2 |
+ }
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+ qemu_mutex_lock(&pr_mgr->lock);
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+ /* Try to reconnect while sending the CDB. */
|
|
Paolo Bonzini |
0fb2b2 |
+ for (attempts = 0; attempts < PR_MAX_RECONNECT_ATTEMPTS; attempts++) {
|
|
Paolo Bonzini |
0fb2b2 |
+ if (!pr_mgr->ioc) {
|
|
Paolo Bonzini |
0fb2b2 |
+ ret = pr_manager_helper_initialize(pr_mgr, NULL);
|
|
Paolo Bonzini |
0fb2b2 |
+ if (ret < 0) {
|
|
Paolo Bonzini |
0fb2b2 |
+ qemu_mutex_unlock(&pr_mgr->lock);
|
|
Paolo Bonzini |
0fb2b2 |
+ g_usleep(G_USEC_PER_SEC);
|
|
Paolo Bonzini |
0fb2b2 |
+ qemu_mutex_lock(&pr_mgr->lock);
|
|
Paolo Bonzini |
0fb2b2 |
+ continue;
|
|
Paolo Bonzini |
0fb2b2 |
+ }
|
|
Paolo Bonzini |
0fb2b2 |
+ }
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+ ret = pr_manager_helper_write(pr_mgr, fd, cdb, ARRAY_SIZE(cdb), NULL);
|
|
Paolo Bonzini |
0fb2b2 |
+ if (ret >= 0) {
|
|
Paolo Bonzini |
0fb2b2 |
+ break;
|
|
Paolo Bonzini |
0fb2b2 |
+ }
|
|
Paolo Bonzini |
0fb2b2 |
+ }
|
|
Paolo Bonzini |
0fb2b2 |
+ if (ret < 0) {
|
|
Paolo Bonzini |
0fb2b2 |
+ goto out;
|
|
Paolo Bonzini |
0fb2b2 |
+ }
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+ /* After sending the CDB, any communications failure causes the
|
|
Paolo Bonzini |
0fb2b2 |
+ * command to fail. The failure is transient, retrying the command
|
|
Paolo Bonzini |
0fb2b2 |
+ * will invoke pr_manager_helper_initialize again.
|
|
Paolo Bonzini |
0fb2b2 |
+ */
|
|
Paolo Bonzini |
0fb2b2 |
+ if (expected_dir == SG_DXFER_TO_DEV) {
|
|
Paolo Bonzini |
0fb2b2 |
+ io_hdr->resid = io_hdr->dxfer_len - len;
|
|
Paolo Bonzini |
0fb2b2 |
+ ret = pr_manager_helper_write(pr_mgr, -1, io_hdr->dxferp, len, NULL);
|
|
Paolo Bonzini |
0fb2b2 |
+ if (ret < 0) {
|
|
Paolo Bonzini |
0fb2b2 |
+ goto out;
|
|
Paolo Bonzini |
0fb2b2 |
+ }
|
|
Paolo Bonzini |
0fb2b2 |
+ }
|
|
Paolo Bonzini |
0fb2b2 |
+ ret = pr_manager_helper_read(pr_mgr, &resp, sizeof(resp), NULL);
|
|
Paolo Bonzini |
0fb2b2 |
+ if (ret < 0) {
|
|
Paolo Bonzini |
0fb2b2 |
+ goto out;
|
|
Paolo Bonzini |
0fb2b2 |
+ }
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+ resp.result = be32_to_cpu(resp.result);
|
|
Paolo Bonzini |
0fb2b2 |
+ resp.sz = be32_to_cpu(resp.sz);
|
|
Paolo Bonzini |
0fb2b2 |
+ if (io_hdr->dxfer_direction == SG_DXFER_FROM_DEV) {
|
|
Paolo Bonzini |
0fb2b2 |
+ assert(resp.sz <= io_hdr->dxfer_len);
|
|
Paolo Bonzini |
0fb2b2 |
+ ret = pr_manager_helper_read(pr_mgr, io_hdr->dxferp, resp.sz, NULL);
|
|
Paolo Bonzini |
0fb2b2 |
+ if (ret < 0) {
|
|
Paolo Bonzini |
0fb2b2 |
+ goto out;
|
|
Paolo Bonzini |
0fb2b2 |
+ }
|
|
Paolo Bonzini |
0fb2b2 |
+ io_hdr->resid = io_hdr->dxfer_len - resp.sz;
|
|
Paolo Bonzini |
0fb2b2 |
+ } else {
|
|
Paolo Bonzini |
0fb2b2 |
+ assert(resp.sz == 0);
|
|
Paolo Bonzini |
0fb2b2 |
+ }
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+ io_hdr->status = resp.result;
|
|
Paolo Bonzini |
0fb2b2 |
+ if (resp.result == CHECK_CONDITION) {
|
|
Paolo Bonzini |
0fb2b2 |
+ io_hdr->driver_status = SG_ERR_DRIVER_SENSE;
|
|
Paolo Bonzini |
0fb2b2 |
+ io_hdr->sb_len_wr = MIN(io_hdr->mx_sb_len, PR_HELPER_SENSE_SIZE);
|
|
Paolo Bonzini |
0fb2b2 |
+ memcpy(io_hdr->sbp, resp.sense, io_hdr->sb_len_wr);
|
|
Paolo Bonzini |
0fb2b2 |
+ }
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+out:
|
|
Paolo Bonzini |
0fb2b2 |
+ if (ret < 0) {
|
|
Paolo Bonzini |
0fb2b2 |
+ int sense_len = scsi_build_sense(io_hdr->sbp,
|
|
Paolo Bonzini |
0fb2b2 |
+ SENSE_CODE(LUN_COMM_FAILURE));
|
|
Paolo Bonzini |
0fb2b2 |
+ io_hdr->driver_status = SG_ERR_DRIVER_SENSE;
|
|
Paolo Bonzini |
0fb2b2 |
+ io_hdr->sb_len_wr = MIN(io_hdr->mx_sb_len, sense_len);
|
|
Paolo Bonzini |
0fb2b2 |
+ io_hdr->status = CHECK_CONDITION;
|
|
Paolo Bonzini |
0fb2b2 |
+ }
|
|
Paolo Bonzini |
0fb2b2 |
+ qemu_mutex_unlock(&pr_mgr->lock);
|
|
Paolo Bonzini |
0fb2b2 |
+ return ret;
|
|
Paolo Bonzini |
0fb2b2 |
+}
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+static void pr_manager_helper_complete(UserCreatable *uc, Error **errp)
|
|
Paolo Bonzini |
0fb2b2 |
+{
|
|
Paolo Bonzini |
0fb2b2 |
+ PRManagerHelper *pr_mgr = PR_MANAGER_HELPER(uc);
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+ qemu_mutex_lock(&pr_mgr->lock);
|
|
Paolo Bonzini |
0fb2b2 |
+ pr_manager_helper_initialize(pr_mgr, errp);
|
|
Paolo Bonzini |
0fb2b2 |
+ qemu_mutex_unlock(&pr_mgr->lock);
|
|
Paolo Bonzini |
0fb2b2 |
+}
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+static char *get_path(Object *obj, Error **errp)
|
|
Paolo Bonzini |
0fb2b2 |
+{
|
|
Paolo Bonzini |
0fb2b2 |
+ PRManagerHelper *pr_mgr = PR_MANAGER_HELPER(obj);
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+ return g_strdup(pr_mgr->path);
|
|
Paolo Bonzini |
0fb2b2 |
+}
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+static void set_path(Object *obj, const char *str, Error **errp)
|
|
Paolo Bonzini |
0fb2b2 |
+{
|
|
Paolo Bonzini |
0fb2b2 |
+ PRManagerHelper *pr_mgr = PR_MANAGER_HELPER(obj);
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+ g_free(pr_mgr->path);
|
|
Paolo Bonzini |
0fb2b2 |
+ pr_mgr->path = g_strdup(str);
|
|
Paolo Bonzini |
0fb2b2 |
+}
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+static void pr_manager_helper_instance_finalize(Object *obj)
|
|
Paolo Bonzini |
0fb2b2 |
+{
|
|
Paolo Bonzini |
0fb2b2 |
+ PRManagerHelper *pr_mgr = PR_MANAGER_HELPER(obj);
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+ object_unref(OBJECT(pr_mgr->ioc));
|
|
Paolo Bonzini |
0fb2b2 |
+ qemu_mutex_destroy(&pr_mgr->lock);
|
|
Paolo Bonzini |
0fb2b2 |
+}
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+static void pr_manager_helper_instance_init(Object *obj)
|
|
Paolo Bonzini |
0fb2b2 |
+{
|
|
Paolo Bonzini |
0fb2b2 |
+ PRManagerHelper *pr_mgr = PR_MANAGER_HELPER(obj);
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+ qemu_mutex_init(&pr_mgr->lock);
|
|
Paolo Bonzini |
0fb2b2 |
+}
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+static void pr_manager_helper_class_init(ObjectClass *klass,
|
|
Paolo Bonzini |
0fb2b2 |
+ void *class_data G_GNUC_UNUSED)
|
|
Paolo Bonzini |
0fb2b2 |
+{
|
|
Paolo Bonzini |
0fb2b2 |
+ PRManagerClass *prmgr_klass = PR_MANAGER_CLASS(klass);
|
|
Paolo Bonzini |
0fb2b2 |
+ UserCreatableClass *uc_klass = USER_CREATABLE_CLASS(klass);
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+ object_class_property_add_str(klass, "path", get_path, set_path,
|
|
Paolo Bonzini |
0fb2b2 |
+ &error_abort);
|
|
Paolo Bonzini |
0fb2b2 |
+ uc_klass->complete = pr_manager_helper_complete;
|
|
Paolo Bonzini |
0fb2b2 |
+ prmgr_klass->run = pr_manager_helper_run;
|
|
Paolo Bonzini |
0fb2b2 |
+}
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+static const TypeInfo pr_manager_helper_info = {
|
|
Paolo Bonzini |
0fb2b2 |
+ .parent = TYPE_PR_MANAGER,
|
|
Paolo Bonzini |
0fb2b2 |
+ .name = TYPE_PR_MANAGER_HELPER,
|
|
Paolo Bonzini |
0fb2b2 |
+ .instance_size = sizeof(PRManagerHelper),
|
|
Paolo Bonzini |
0fb2b2 |
+ .instance_init = pr_manager_helper_instance_init,
|
|
Paolo Bonzini |
0fb2b2 |
+ .instance_finalize = pr_manager_helper_instance_finalize,
|
|
Paolo Bonzini |
0fb2b2 |
+ .class_init = pr_manager_helper_class_init,
|
|
Paolo Bonzini |
0fb2b2 |
+};
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+static void pr_manager_helper_register_types(void)
|
|
Paolo Bonzini |
0fb2b2 |
+{
|
|
Paolo Bonzini |
0fb2b2 |
+ type_register_static(&pr_manager_helper_info);
|
|
Paolo Bonzini |
0fb2b2 |
+}
|
|
Paolo Bonzini |
0fb2b2 |
+
|
|
Paolo Bonzini |
0fb2b2 |
+type_init(pr_manager_helper_register_types);
|
|
Paolo Bonzini |
0fb2b2 |
--
|
|
Paolo Bonzini |
0fb2b2 |
2.13.5
|
|
Paolo Bonzini |
0fb2b2 |
|