From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39411) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eFJuP-0000xN-6X for qemu-devel@nongnu.org; Thu, 16 Nov 2017 08:08:51 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eFJuO-0001GO-59 for qemu-devel@nongnu.org; Thu, 16 Nov 2017 08:08:45 -0500 Received: from mx1.redhat.com ([209.132.183.28]:32840) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1eFJuN-0001FE-Uq for qemu-devel@nongnu.org; Thu, 16 Nov 2017 08:08:44 -0500 From: Peter Xu Date: Thu, 16 Nov 2017 21:06:07 +0800 Message-Id: <20171116130610.23582-25-peterx@redhat.com> In-Reply-To: <20171116130610.23582-1-peterx@redhat.com> References: <20171116130610.23582-1-peterx@redhat.com> Subject: [Qemu-devel] [RFC v4 24/27] qmp: add command "x-oob-test" List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Stefan Hajnoczi , "Daniel P . Berrange" , Paolo Bonzini , Fam Zheng , Juan Quintela , mdroth@linux.vnet.ibm.com, peterx@redhat.com, Eric Blake , Laurent Vivier , Markus Armbruster , marcandre.lureau@redhat.com, "Dr . David Alan Gilbert" This command is only used to test OOB functionality. It should not be used for any other purposes. Signed-off-by: Peter Xu --- qapi-schema.json | 18 ++++++++++++++++++ qmp.c | 16 ++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/qapi-schema.json b/qapi-schema.json index 9d2625b6b3..5bd59bd266 100644 --- a/qapi-schema.json +++ b/qapi-schema.json @@ -3256,3 +3256,21 @@ ## { 'event': 'REQUEST_DROPPED' , 'data': { 'id': 'any', 'reason': 'RequestDropReason' } } + +## +# @x-oob-test: +# +# Test OOB functionality. When send this command with lock=true, +# it'll try to hang the dispatcher. When send it with lock=false, +# it'll try to notify the locked thread to continue. Note: it should +# only be used by QMP test program rather than anything else. +# +# Since: 2.12 +# +# Example: +# +# { "execute": "x-oob-test", +# "arguments": { "lock": true } } +## +{ 'command': 'x-oob-test', 'data' : { 'lock': 'bool' }, + 'allow-oob': true } diff --git a/qmp.c b/qmp.c index e8c303116a..ca2968aad2 100644 --- a/qmp.c +++ b/qmp.c @@ -722,3 +722,19 @@ MemoryInfo *qmp_query_memory_size_summary(Error **errp) return mem_info; } + +static QemuSemaphore x_oob_test_sem; + +static void __attribute__((constructor)) x_oob_test_init(void) +{ + qemu_sem_init(&x_oob_test_sem, 0); +} + +void qmp_x_oob_test(bool lock, Error **errp) +{ + if (lock) { + qemu_sem_wait(&x_oob_test_sem); + } else { + qemu_sem_post(&x_oob_test_sem); + } +} -- 2.13.6