>From 1c114e00b389a1df20addc6fa2cfb736d655f2a8 Mon Sep 17 00:00:00 2001 From: Vadim Rozenfeld <vrozenfe@xxxxxxxxxx> Date: Mon, 2 May 2011 21:29:12 +0300 Subject: [COMMIT] [balloon] check balloon size on device init. --- Balloon/sys/ProtoTypes.h | 4 ++++ Balloon/sys/balloon.c | 34 ++++++++++++++++++++++++++++++++++ 2 files changed, 38 insertions(+), 0 deletions(-) diff --git a/Balloon/sys/ProtoTypes.h b/Balloon/sys/ProtoTypes.h index 85c5f05..099d97e 100644 --- a/Balloon/sys/ProtoTypes.h +++ b/Balloon/sys/ProtoTypes.h @@ -194,6 +194,10 @@ DisableInterrupt( } } +VOID +FillLeakWorkItem( + IN WDFWORKITEM WorkItem + ); VOID SetBalloonSize( diff --git a/Balloon/sys/balloon.c b/Balloon/sys/balloon.c index 39ad3bc..9d90eeb 100644 --- a/Balloon/sys/balloon.c +++ b/Balloon/sys/balloon.c @@ -80,7 +80,41 @@ free_mem: if(NT_SUCCESS(status)) { + LONGLONG diff = GetBalloonSize(WdfDevice); VirtIODeviceAddStatus(&devCtx->VDevice, VIRTIO_CONFIG_S_DRIVER_OK); + + if (diff != 0) { + PWORKITEM_CONTEXT context; + WDF_OBJECT_ATTRIBUTES attributes; + WDF_WORKITEM_CONFIG workitemConfig; + WDFWORKITEM hWorkItem; + WDF_OBJECT_ATTRIBUTES_INIT(&attributes); + WDF_OBJECT_ATTRIBUTES_SET_CONTEXT_TYPE(&attributes, WORKITEM_CONTEXT); + attributes.ParentObject = WdfDevice; + + WDF_WORKITEM_CONFIG_INIT(&workitemConfig, FillLeakWorkItem); + + status = WdfWorkItemCreate( &workitemConfig, + &attributes, + &hWorkItem); + + if (NT_SUCCESS(status)) { + context = GetWorkItemContext(hWorkItem); + + context->Device = WdfDevice; + context->Diff = GetBalloonSize(WdfDevice); + + context->bStatUpdate = FALSE; + + WdfWorkItemEnqueue(hWorkItem); + + } + else + { + VirtIODeviceAddStatus(&devCtx->VDevice, VIRTIO_CONFIG_S_FAILED); + TraceEvents(TRACE_LEVEL_INFORMATION, DBG_DPC, "WdfWorkItemCreate failed with status = 0x%08x\n", status); + } + } } else { -- 1.7.0.2.msysgit.0 -- To unsubscribe from this list: send the line "unsubscribe kvm-commits" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html