提交 73d4b324 编写于 作者: P Peter Krempa

qemu: monitor: Add support for BLOCK_WRITE_THRESHOLD event

The event is fired when a given block backend node (identified by the
node name) experiences a write beyond the bound set via
block-set-write-threshold QMP command. This wires up the monitor code to
extract the data and allow us receiving the events and the capability.
上级 085e794a
......@@ -363,6 +363,7 @@ VIR_ENUM_IMPL(virQEMUCaps, QEMU_CAPS_LAST,
"pcie-root-port",
"query-cpu-definitions", /* 250 */
"block-write-threshold",
);
......@@ -1534,6 +1535,7 @@ struct virQEMUCapsStringFlags virQEMUCapsEvents[] = {
{ "MIGRATION", QEMU_CAPS_MIGRATION_EVENT },
{ "VSERPORT_CHANGE", QEMU_CAPS_VSERPORT_CHANGE },
{ "DEVICE_TRAY_MOVED", QEMU_CAPS_DEVICE_TRAY_MOVED },
{ "BLOCK_WRITE_THRESHOLD", QEMU_CAPS_BLOCK_WRITE_THRESHOLD },
};
struct virQEMUCapsStringFlags virQEMUCapsObjectTypes[] = {
......
......@@ -399,6 +399,7 @@ typedef enum {
/* 250 */
QEMU_CAPS_QUERY_CPU_DEFINITIONS, /* qmp query-cpu-definitions */
QEMU_CAPS_BLOCK_WRITE_THRESHOLD, /* BLOCK_WRITE_THRESHOLD event */
QEMU_CAPS_LAST /* this must always be the last item */
} virQEMUCapsFlags;
......
......@@ -1604,6 +1604,24 @@ qemuMonitorEmitAcpiOstInfo(qemuMonitorPtr mon,
}
int
qemuMonitorEmitBlockThreshold(qemuMonitorPtr mon,
const char *nodename,
unsigned long long threshold,
unsigned long long excess)
{
int ret = -1;
VIR_DEBUG("mon=%p, node-name='%s', threshold='%llu', excess='%llu'",
mon, nodename, threshold, excess);
QEMU_MONITOR_CALLBACK(mon, ret, domainBlockThreshold, mon->vm,
nodename, threshold, excess);
return ret;
}
int
qemuMonitorSetCapabilities(qemuMonitorPtr mon)
{
......
......@@ -207,6 +207,14 @@ typedef int (*qemuMonitorDomainAcpiOstInfoCallback)(qemuMonitorPtr mon,
void *opaque);
typedef int (*qemuMonitorDomainBlockThresholdCallback)(qemuMonitorPtr mon,
virDomainObjPtr vm,
const char *nodename,
unsigned long long threshold,
unsigned long long excess,
void *opaque);
typedef struct _qemuMonitorCallbacks qemuMonitorCallbacks;
typedef qemuMonitorCallbacks *qemuMonitorCallbacksPtr;
struct _qemuMonitorCallbacks {
......@@ -238,6 +246,7 @@ struct _qemuMonitorCallbacks {
qemuMonitorDomainMigrationStatusCallback domainMigrationStatus;
qemuMonitorDomainMigrationPassCallback domainMigrationPass;
qemuMonitorDomainAcpiOstInfoCallback domainAcpiOstInfo;
qemuMonitorDomainBlockThresholdCallback domainBlockThreshold;
};
char *qemuMonitorEscapeArg(const char *in);
......@@ -358,6 +367,11 @@ int qemuMonitorEmitAcpiOstInfo(qemuMonitorPtr mon,
unsigned int source,
unsigned int status);
int qemuMonitorEmitBlockThreshold(qemuMonitorPtr mon,
const char *nodename,
unsigned long long threshold,
unsigned long long excess);
int qemuMonitorStartCPUs(qemuMonitorPtr mon,
virConnectPtr conn);
int qemuMonitorStopCPUs(qemuMonitorPtr mon);
......
......@@ -89,6 +89,7 @@ static void qemuMonitorJSONHandleSpiceMigrated(qemuMonitorPtr mon, virJSONValueP
static void qemuMonitorJSONHandleMigrationStatus(qemuMonitorPtr mon, virJSONValuePtr data);
static void qemuMonitorJSONHandleMigrationPass(qemuMonitorPtr mon, virJSONValuePtr data);
static void qemuMonitorJSONHandleAcpiOstInfo(qemuMonitorPtr mon, virJSONValuePtr data);
static void qemuMonitorJSONHandleBlockThreshold(qemuMonitorPtr mon, virJSONValuePtr data);
typedef struct {
const char *type;
......@@ -102,6 +103,7 @@ static qemuEventHandler eventHandlers[] = {
{ "BLOCK_JOB_CANCELLED", qemuMonitorJSONHandleBlockJobCanceled, },
{ "BLOCK_JOB_COMPLETED", qemuMonitorJSONHandleBlockJobCompleted, },
{ "BLOCK_JOB_READY", qemuMonitorJSONHandleBlockJobReady, },
{ "BLOCK_WRITE_THRESHOLD", qemuMonitorJSONHandleBlockThreshold, },
{ "DEVICE_DELETED", qemuMonitorJSONHandleDeviceDeleted, },
{ "DEVICE_TRAY_MOVED", qemuMonitorJSONHandleTrayChange, },
{ "GUEST_PANICKED", qemuMonitorJSONHandleGuestPanic, },
......@@ -1065,6 +1067,30 @@ qemuMonitorJSONHandleAcpiOstInfo(qemuMonitorPtr mon, virJSONValuePtr data)
}
static void
qemuMonitorJSONHandleBlockThreshold(qemuMonitorPtr mon, virJSONValuePtr data)
{
const char *nodename;
unsigned long long threshold;
unsigned long long excess;
if (!(nodename = virJSONValueObjectGetString(data, "node-name")))
goto error;
if (virJSONValueObjectGetNumberUlong(data, "write-threshold", &threshold) < 0)
goto error;
if (virJSONValueObjectGetNumberUlong(data, "amount-exceeded", &excess) < 0)
goto error;
qemuMonitorEmitBlockThreshold(mon, nodename, threshold, excess);
return;
error:
VIR_WARN("malformed 'BLOCK_WRITE_THRESHOLD' event");
}
int
qemuMonitorJSONHumanCommandWithFd(qemuMonitorPtr mon,
const char *cmd_str,
......
......@@ -183,6 +183,7 @@
<flag name='vhost-scsi'/>
<flag name='drive-iotune-group'/>
<flag name='query-cpu-definitions'/>
<flag name='block-write-threshold'/>
<version>2004000</version>
<kvmVersion>0</kvmVersion>
<package></package>
......
......@@ -189,6 +189,7 @@
<flag name='vhost-scsi'/>
<flag name='drive-iotune-group'/>
<flag name='query-cpu-definitions'/>
<flag name='block-write-threshold'/>
<version>2005000</version>
<kvmVersion>0</kvmVersion>
<package></package>
......
......@@ -165,6 +165,7 @@
<flag name='vhost-scsi'/>
<flag name='drive-iotune-group'/>
<flag name='query-cpu-definitions'/>
<flag name='block-write-threshold'/>
<version>2006000</version>
<kvmVersion>0</kvmVersion>
<package></package>
......
......@@ -165,6 +165,7 @@
<flag name='vhost-scsi'/>
<flag name='drive-iotune-group'/>
<flag name='query-cpu-definitions'/>
<flag name='block-write-threshold'/>
<version>2006000</version>
<kvmVersion>0</kvmVersion>
<package></package>
......
......@@ -160,6 +160,7 @@
<flag name='vhost-scsi'/>
<flag name='drive-iotune-group'/>
<flag name='query-cpu-definitions'/>
<flag name='block-write-threshold'/>
<version>2006000</version>
<kvmVersion>0</kvmVersion>
<package></package>
......
......@@ -198,6 +198,7 @@
<flag name='vhost-scsi'/>
<flag name='drive-iotune-group'/>
<flag name='query-cpu-definitions'/>
<flag name='block-write-threshold'/>
<version>2006000</version>
<kvmVersion>0</kvmVersion>
<package></package>
......
......@@ -128,6 +128,7 @@
<flag name='vhost-scsi'/>
<flag name='drive-iotune-group'/>
<flag name='query-cpu-definitions'/>
<flag name='block-write-threshold'/>
<version>2007000</version>
<kvmVersion>0</kvmVersion>
<package></package>
......
......@@ -200,6 +200,7 @@
<flag name='vhost-scsi'/>
<flag name='drive-iotune-group'/>
<flag name='query-cpu-definitions'/>
<flag name='block-write-threshold'/>
<version>2007000</version>
<kvmVersion>0</kvmVersion>
<package> (v2.7.0)</package>
......
......@@ -130,6 +130,7 @@
<flag name='drive-iotune-group'/>
<flag name='query-cpu-model-expansion'/>
<flag name='query-cpu-definitions'/>
<flag name='block-write-threshold'/>
<version>2007093</version>
<kvmVersion>0</kvmVersion>
<package></package>
......
......@@ -201,6 +201,7 @@
<flag name='vhost-scsi'/>
<flag name='drive-iotune-group'/>
<flag name='query-cpu-definitions'/>
<flag name='block-write-threshold'/>
<version>2008000</version>
<kvmVersion>0</kvmVersion>
<package> (v2.8.0)</package>
......
......@@ -205,6 +205,7 @@
<flag name='spice-rendernode'/>
<flag name='pcie-root-port'/>
<flag name='query-cpu-definitions'/>
<flag name='block-write-threshold'/>
<version>2008090</version>
<kvmVersion>0</kvmVersion>
<package> (v2.9.0-rc0-142-g940a8ce)</package>
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册