The event will be fired when the domain memory only dump completes.
Fill in a return buffer to store/pass along the dump statistics that
will be eventually shared by a query-dump command. Also pass along
the status of the filling and any possible error received.
Signed-off-by: John Ferlan <jferlan@redhat.com>
---
src/qemu/qemu_monitor.c | 21 ++++++++++++++++
src/qemu/qemu_monitor.h | 14 ++++++++++-
src/qemu/qemu_monitor_json.c | 60 ++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 94 insertions(+), 1 deletion(-)
diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
index fc146bdbf..f4edfc36b 100644
--- a/src/qemu/qemu_monitor.c
+++ b/src/qemu/qemu_monitor.c
@@ -210,6 +210,10 @@ VIR_ENUM_IMPL(qemuMonitorBlockIOStatus,
QEMU_MONITOR_BLOCK_IO_STATUS_LAST,
"ok", "failed", "nospace")
+VIR_ENUM_IMPL(qemuMonitorDumpStatus,
+ QEMU_MONITOR_DUMP_STATUS_LAST,
+ "none", "active", "completed", "failed")
+
char *
qemuMonitorEscapeArg(const char *in)
{
@@ -1667,6 +1671,23 @@ qemuMonitorEmitBlockThreshold(qemuMonitorPtr mon,
int
+qemuMonitorEmitDumpCompleted(qemuMonitorPtr mon,
+ int status,
+ qemuMonitorDumpStatsPtr stats,
+ const char *error)
+{
+ int ret = -1;
+
+ VIR_DEBUG("mon=%p", mon);
+
+ QEMU_MONITOR_CALLBACK(mon, ret, domainDumpCompleted, mon->vm,
+ status, stats, error);
+
+ return ret;
+}
+
+
+int
qemuMonitorSetCapabilities(qemuMonitorPtr mon)
{
QEMU_CHECK_MONITOR(mon);
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index c58839ca7..63b121cb1 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -246,7 +246,6 @@ typedef int (*qemuMonitorDomainBlockThresholdCallback)(qemuMonitorPtr mon,
unsigned long long excess,
void *opaque);
-
typedef enum {
QEMU_MONITOR_DUMP_STATUS_NONE,
QEMU_MONITOR_DUMP_STATUS_ACTIVE,
@@ -266,6 +265,13 @@ struct _qemuMonitorDumpStats {
unsigned long long total; /* total bytes to be written */
};
+typedef int (*qemuMonitorDomainDumpCompletedCallback)(qemuMonitorPtr mon,
+ virDomainObjPtr vm,
+ int status,
+ qemuMonitorDumpStatsPtr stats,
+ const char *error,
+ void *opaque);
+
typedef struct _qemuMonitorCallbacks qemuMonitorCallbacks;
typedef qemuMonitorCallbacks *qemuMonitorCallbacksPtr;
struct _qemuMonitorCallbacks {
@@ -298,6 +304,7 @@ struct _qemuMonitorCallbacks {
qemuMonitorDomainMigrationPassCallback domainMigrationPass;
qemuMonitorDomainAcpiOstInfoCallback domainAcpiOstInfo;
qemuMonitorDomainBlockThresholdCallback domainBlockThreshold;
+ qemuMonitorDomainDumpCompletedCallback domainDumpCompleted;
};
char *qemuMonitorEscapeArg(const char *in);
@@ -427,6 +434,11 @@ int qemuMonitorEmitBlockThreshold(qemuMonitorPtr mon,
unsigned long long threshold,
unsigned long long excess);
+int qemuMonitorEmitDumpCompleted(qemuMonitorPtr mon,
+ int status,
+ qemuMonitorDumpStatsPtr stats,
+ const char *error);
+
int qemuMonitorStartCPUs(qemuMonitorPtr mon,
virConnectPtr conn);
int qemuMonitorStopCPUs(qemuMonitorPtr mon);
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index 442b21860..e9b407aa4 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -90,6 +90,7 @@ static void qemuMonitorJSONHandleMigrationStatus(qemuMonitorPtr mon, virJSONValu
static void qemuMonitorJSONHandleMigrationPass(qemuMonitorPtr mon, virJSONValuePtr data);
static void qemuMonitorJSONHandleAcpiOstInfo(qemuMonitorPtr mon, virJSONValuePtr data);
static void qemuMonitorJSONHandleBlockThreshold(qemuMonitorPtr mon, virJSONValuePtr data);
+static void qemuMonitorJSONHandleDumpCompleted(qemuMonitorPtr mon, virJSONValuePtr data);
typedef struct {
const char *type;
@@ -106,6 +107,7 @@ static qemuEventHandler eventHandlers[] = {
{ "BLOCK_WRITE_THRESHOLD", qemuMonitorJSONHandleBlockThreshold, },
{ "DEVICE_DELETED", qemuMonitorJSONHandleDeviceDeleted, },
{ "DEVICE_TRAY_MOVED", qemuMonitorJSONHandleTrayChange, },
+ { "DUMP_COMPLETED", qemuMonitorJSONHandleDumpCompleted, },
{ "GUEST_PANICKED", qemuMonitorJSONHandleGuestPanic, },
{ "MIGRATION", qemuMonitorJSONHandleMigrationStatus, },
{ "MIGRATION_PASS", qemuMonitorJSONHandleMigrationPass, },
@@ -1143,6 +1145,64 @@ qemuMonitorJSONHandleBlockThreshold(qemuMonitorPtr mon, virJSONValuePtr data)
}
+static int
+qemuMonitorJSONExtractDumpStats(virJSONValuePtr result,
+ qemuMonitorDumpStatsPtr ret)
+{
+ const char *statusstr;
+
+ if (!(statusstr = virJSONValueObjectGetString(result, "status"))) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("incomplete result, failed to get status"));
+ return -1;
+ }
+
+ ret->status = qemuMonitorDumpStatusTypeFromString(statusstr);
+ if (ret->status < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ _("incomplete result, unknown status string '%s'"),
+ statusstr);
+ return -1;
+ }
+
+ if (virJSONValueObjectGetNumberUlong(result, "completed", &ret->completed) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("incomplete result, failed to get completed"));
+ return -1;
+ }
+
+ if (virJSONValueObjectGetNumberUlong(result, "total", &ret->total) < 0) {
+ virReportError(VIR_ERR_INTERNAL_ERROR, "%s",
+ _("incomplete result, failed to get total"));
+ return -1;
+ }
+
+ return 0;
+}
+
+
+static void
+qemuMonitorJSONHandleDumpCompleted(qemuMonitorPtr mon,
+ virJSONValuePtr data)
+{
+ virJSONValuePtr result;
+ int status;
+ qemuMonitorDumpStats stats = { 0 };
+ const char *error = NULL;
+
+ if (!(result = virJSONValueObjectGetObject(data, "result"))) {
+ VIR_WARN("missing result in dump completed event");
+ return;
+ }
+
+ status = qemuMonitorJSONExtractDumpStats(result, &stats);
+
+ error = virJSONValueObjectGetString(data, "error");
+
+ qemuMonitorEmitDumpCompleted(mon, status, &stats, error);
+}
+
+
int
qemuMonitorJSONHumanCommandWithFd(qemuMonitorPtr mon,
const char *cmd_str,
--
2.13.6
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
On Thu, Feb 01, 2018 at 18:24:36 -0500, John Ferlan wrote:
> The event will be fired when the domain memory only dump completes.
>
> Fill in a return buffer to store/pass along the dump statistics that
> will be eventually shared by a query-dump command. Also pass along
> the status of the filling and any possible error received.
>
> Signed-off-by: John Ferlan <jferlan@redhat.com>
> ---
> src/qemu/qemu_monitor.c | 21 ++++++++++++++++
> src/qemu/qemu_monitor.h | 14 ++++++++++-
> src/qemu/qemu_monitor_json.c | 60 ++++++++++++++++++++++++++++++++++++++++++++
> 3 files changed, 94 insertions(+), 1 deletion(-)
>
> diff --git a/src/qemu/qemu_monitor.c b/src/qemu/qemu_monitor.c
> index fc146bdbf..f4edfc36b 100644
> --- a/src/qemu/qemu_monitor.c
> +++ b/src/qemu/qemu_monitor.c
> @@ -210,6 +210,10 @@ VIR_ENUM_IMPL(qemuMonitorBlockIOStatus,
> QEMU_MONITOR_BLOCK_IO_STATUS_LAST,
> "ok", "failed", "nospace")
>
> +VIR_ENUM_IMPL(qemuMonitorDumpStatus,
> + QEMU_MONITOR_DUMP_STATUS_LAST,
> + "none", "active", "completed", "failed")
> +
> char *
> qemuMonitorEscapeArg(const char *in)
> {
> @@ -1667,6 +1671,23 @@ qemuMonitorEmitBlockThreshold(qemuMonitorPtr mon,
>
>
> int
> +qemuMonitorEmitDumpCompleted(qemuMonitorPtr mon,
> + int status,
> + qemuMonitorDumpStatsPtr stats,
> + const char *error)
> +{
> + int ret = -1;
> +
> + VIR_DEBUG("mon=%p", mon);
> +
> + QEMU_MONITOR_CALLBACK(mon, ret, domainDumpCompleted, mon->vm,
> + status, stats, error);
> +
> + return ret;
> +}
> +
> +
> +int
> qemuMonitorSetCapabilities(qemuMonitorPtr mon)
> {
> QEMU_CHECK_MONITOR(mon);
> diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
> index c58839ca7..63b121cb1 100644
> --- a/src/qemu/qemu_monitor.h
> +++ b/src/qemu/qemu_monitor.h
> @@ -246,7 +246,6 @@ typedef int (*qemuMonitorDomainBlockThresholdCallback)(qemuMonitorPtr mon,
> unsigned long long excess,
> void *opaque);
>
> -
> typedef enum {
> QEMU_MONITOR_DUMP_STATUS_NONE,
> QEMU_MONITOR_DUMP_STATUS_ACTIVE,
Looks like an artifact from moving the hunk into a different patch.
...
Reviewed-by: Jiri Denemark <jdenemar@redhat.com>
--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
© 2016 - 2026 Red Hat, Inc.