qemu: process: Wire up firing of the VIR_DOMAIN_EVENT_ID_BLOCK_THRESHOLD event

Bind it to qemu's BLOCK_WRITE_THRESHOLD event. Look up the disk by
nodename and construct the string to return.
This commit is contained in:
Peter Krempa 2017-02-22 17:51:26 +01:00
parent 4e1618ce72
commit e96130dcc8

View File

@ -1440,6 +1440,46 @@ qemuProcessHandleAcpiOstInfo(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
}
static int
qemuProcessHandleBlockThreshold(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
virDomainObjPtr vm,
const char *nodename,
unsigned long long threshold,
unsigned long long excess,
void *opaque)
{
virQEMUDriverPtr driver = opaque;
virObjectEventPtr event = NULL;
virDomainDiskDefPtr disk;
virStorageSourcePtr src;
unsigned int idx;
char *dev = NULL;
const char *path = NULL;
virObjectLock(vm);
VIR_DEBUG("BLOCK_WRITE_THRESHOLD event for block node '%s' in domain %p %s:"
"threshold '%llu' exceeded by '%llu'",
nodename, vm, vm->def->name, threshold, excess);
if ((disk = qemuDomainDiskLookupByNodename(vm->def, nodename, &src, &idx))) {
if (virStorageSourceIsLocalStorage(src))
path = src->path;
if ((dev = qemuDomainDiskBackingStoreGetName(disk, src, idx))) {
event = virDomainEventBlockThresholdNewFromObj(vm, dev, path,
threshold, excess);
VIR_FREE(dev);
}
}
virObjectUnlock(vm);
qemuDomainEventQueue(driver, event);
return 0;
}
static int
qemuProcessHandleNicRxFilterChanged(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
virDomainObjPtr vm,
@ -1636,6 +1676,7 @@ static qemuMonitorCallbacks monitorCallbacks = {
.domainMigrationStatus = qemuProcessHandleMigrationStatus,
.domainMigrationPass = qemuProcessHandleMigrationPass,
.domainAcpiOstInfo = qemuProcessHandleAcpiOstInfo,
.domainBlockThreshold = qemuProcessHandleBlockThreshold,
};
static void