[libvirt] [PATCHv3 09/10] threshold: add threshold event handling in qemu
Peter Krempa
pkrempa at redhat.com
Tue Jun 23 13:52:44 UTC 2015
On Mon, Jun 22, 2015 at 17:06:45 -0600, Eric Blake wrote:
> With this patch, block write threshold events delivered by qemu
> are converted into libvirt events.
>
> This patch takes the easy road, and only reports events if
> the node name is still cached by libvirtd (true in the common
> case when libvirtd is not restarted, since you can't get an
> event if you didn't register a threshold). A followup patch
> will be needed to properly handle grabbing the job lock and
> getting the node name when the cache lookup fails, using code
> similar to how we update domain XML after a block job
> completes. But for getting the initial API in place, I
> figured this was a good enough start.
>
> * src/qemu/qemu_monitor_json.c
> (qemuMonitorJSONHandleBlockWriteThreshold): New function.
> * src/qemu/qemu_monitor.c (qemuMonitorEmitBlockThreshold):
> Likewise.
> * src/qemu/qemu_monitor.h (qemuMonitorEmitBlockThreshold):
> Likewise.
> * src/qemu/qemu_process.c (qemuProcessHandleBlockThreshold):
> Likewise.
>
> Signed-off-by: Eric Blake <eblake at redhat.com>
> ---
> src/qemu/qemu_monitor.c | 14 ++++++++++++++
> src/qemu/qemu_monitor.h | 11 +++++++++++
> src/qemu/qemu_monitor_json.c | 31 +++++++++++++++++++++++++++++++
> src/qemu/qemu_process.c | 44 ++++++++++++++++++++++++++++++++++++++++++++
> 4 files changed, 100 insertions(+)
...
>
> diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c
> index ba84182..5f582e5 100644
> --- a/src/qemu/qemu_process.c
> +++ b/src/qemu/qemu_process.c
> @@ -1037,6 +1037,49 @@ qemuProcessHandleBlockJob(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
>
>
> static int
> +qemuProcessHandleBlockThreshold(qemuMonitorPtr mon ATTRIBUTE_UNUSED,
> + virDomainObjPtr vm,
> + const char *node,
> + unsigned long long threshold,
> + unsigned long long length,
> + void *opaque)
> +{
> + virQEMUDriverPtr driver = opaque;
> + virDomainDiskDefPtr disk;
> + virObjectEventPtr event = NULL;
> + const char *path = NULL;
> +
> + virObjectLock(vm);
> +
> + VIR_DEBUG("Block threshold for node %s (domain: %p,%s) threshold %llu "
> + "length %llu", node, vm, vm->def->name, threshold, length);
> +
> + /* TODO: If the node name is not found in the current domain XML,
> + * we need to grab a job lock and query the monitor to repopulate
> + * the node name cache. For now, if that happens, we just discard
> + * the event. */
This duality of operations is why we should cache the node names
upfront.
> + if (!(disk = qemuDomainDiskResolveAllocationNode(driver, vm, node,
> + false))) {
> + VIR_WARN("failed to locate disk matching node '%s'", node);
> + goto cleanup;
> + }
> + if (virStorageSourceIsLocalStorage(disk->src))
> + path = disk->src->path;
> +
> + /* TODO: Once we support node names for more than just the active
> + * layer, we will need to map this into 'vda[1]' notation. */
> + event = virDomainEventWriteThresholdNewFromObj(vm, disk->dst, path,
> + threshold, length);
> +
Peter
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://listman.redhat.com/archives/libvir-list/attachments/20150623/118efad1/attachment-0001.sig>
More information about the libvir-list
mailing list