|
|
7a3408 |
From 0ef69d9942be58851bdbfca900274aa24c871812 Mon Sep 17 00:00:00 2001
|
|
|
7a3408 |
Message-Id: <0ef69d9942be58851bdbfca900274aa24c871812@dist-git>
|
|
|
7a3408 |
From: Pavel Hrdina <phrdina@redhat.com>
|
|
|
7a3408 |
Date: Fri, 10 Jul 2015 12:39:31 +0200
|
|
|
7a3408 |
Subject: [PATCH] monitor: detect that eject fails because the tray is locked
|
|
|
7a3408 |
|
|
|
7a3408 |
Modify the eject monitor functions to parse the return code and detect,
|
|
|
7a3408 |
whether the error contains "is locked" to report this type of failure to
|
|
|
7a3408 |
upper layers.
|
|
|
7a3408 |
|
|
|
7a3408 |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
7a3408 |
(cherry picked from commit 256496e1499fcc7b20a51919eb4471987a36dbab)
|
|
|
7a3408 |
|
|
|
7a3408 |
Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=1147471
|
|
|
7a3408 |
|
|
|
7a3408 |
Signed-off-by: Pavel Hrdina <phrdina@redhat.com>
|
|
|
7a3408 |
Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
|
|
|
7a3408 |
---
|
|
|
7a3408 |
src/qemu/qemu_monitor_json.c | 14 ++++++++++++++
|
|
|
7a3408 |
src/qemu/qemu_monitor_text.c | 10 ++++++++++
|
|
|
7a3408 |
2 files changed, 24 insertions(+)
|
|
|
7a3408 |
|
|
|
7a3408 |
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
|
|
|
7a3408 |
index 4323c2a..4040ff0 100644
|
|
|
7a3408 |
--- a/src/qemu/qemu_monitor_json.c
|
|
|
7a3408 |
+++ b/src/qemu/qemu_monitor_json.c
|
|
|
7a3408 |
@@ -44,6 +44,7 @@
|
|
|
7a3408 |
#include "virprobe.h"
|
|
|
7a3408 |
#include "virstring.h"
|
|
|
7a3408 |
#include "cpu/cpu_x86.h"
|
|
|
7a3408 |
+#include "c-strcasestr.h"
|
|
|
7a3408 |
|
|
|
7a3408 |
#ifdef WITH_DTRACE_PROBES
|
|
|
7a3408 |
# include "libvirt_qemu_probes.h"
|
|
|
7a3408 |
@@ -2209,6 +2210,14 @@ int qemuMonitorJSONSetCPU(qemuMonitorPtr mon,
|
|
|
7a3408 |
}
|
|
|
7a3408 |
|
|
|
7a3408 |
|
|
|
7a3408 |
+/**
|
|
|
7a3408 |
+ * Run QMP command to eject a media from ejectable device.
|
|
|
7a3408 |
+ *
|
|
|
7a3408 |
+ * Returns:
|
|
|
7a3408 |
+ * -2 on error, when the tray is locked
|
|
|
7a3408 |
+ * -1 on all other errors
|
|
|
7a3408 |
+ * 0 on success
|
|
|
7a3408 |
+ */
|
|
|
7a3408 |
int qemuMonitorJSONEjectMedia(qemuMonitorPtr mon,
|
|
|
7a3408 |
const char *dev_name,
|
|
|
7a3408 |
bool force)
|
|
|
7a3408 |
@@ -2227,6 +2236,11 @@ int qemuMonitorJSONEjectMedia(qemuMonitorPtr mon,
|
|
|
7a3408 |
if (ret == 0)
|
|
|
7a3408 |
ret = qemuMonitorJSONCheckError(cmd, reply);
|
|
|
7a3408 |
|
|
|
7a3408 |
+ VIR_DEBUG("%s", virJSONValueToString(reply, false));
|
|
|
7a3408 |
+
|
|
|
7a3408 |
+ if (ret < 0 && c_strcasestr(virJSONValueToString(reply, false), "is locked"))
|
|
|
7a3408 |
+ ret = -2;
|
|
|
7a3408 |
+
|
|
|
7a3408 |
virJSONValueFree(cmd);
|
|
|
7a3408 |
virJSONValueFree(reply);
|
|
|
7a3408 |
return ret;
|
|
|
7a3408 |
diff --git a/src/qemu/qemu_monitor_text.c b/src/qemu/qemu_monitor_text.c
|
|
|
7a3408 |
index 2e77534..2aa0460 100644
|
|
|
7a3408 |
--- a/src/qemu/qemu_monitor_text.c
|
|
|
7a3408 |
+++ b/src/qemu/qemu_monitor_text.c
|
|
|
7a3408 |
@@ -1169,6 +1169,14 @@ int qemuMonitorTextSetCPU(qemuMonitorPtr mon, int cpu, bool online)
|
|
|
7a3408 |
}
|
|
|
7a3408 |
|
|
|
7a3408 |
|
|
|
7a3408 |
+/**
|
|
|
7a3408 |
+ * Run HMP command to eject a media from ejectable device.
|
|
|
7a3408 |
+ *
|
|
|
7a3408 |
+ * Returns:
|
|
|
7a3408 |
+ * -2 on error, when the tray is locked
|
|
|
7a3408 |
+ * -1 on all other errors
|
|
|
7a3408 |
+ * 0 on success
|
|
|
7a3408 |
+ */
|
|
|
7a3408 |
int qemuMonitorTextEjectMedia(qemuMonitorPtr mon,
|
|
|
7a3408 |
const char *dev_name,
|
|
|
7a3408 |
bool force)
|
|
|
7a3408 |
@@ -1187,6 +1195,8 @@ int qemuMonitorTextEjectMedia(qemuMonitorPtr mon,
|
|
|
7a3408 |
* device not found, device is locked ...
|
|
|
7a3408 |
* No message is printed on success it seems */
|
|
|
7a3408 |
if (c_strcasestr(reply, "device ")) {
|
|
|
7a3408 |
+ if (c_strcasestr(reply, "is locked"))
|
|
|
7a3408 |
+ ret = -2;
|
|
|
7a3408 |
virReportError(VIR_ERR_OPERATION_FAILED,
|
|
|
7a3408 |
_("could not eject media on %s: %s"), dev_name, reply);
|
|
|
7a3408 |
goto cleanup;
|
|
|
7a3408 |
--
|
|
|
7a3408 |
2.4.5
|
|
|
7a3408 |
|