Commit 469638f9 authored by Peter Xu's avatar Peter Xu Committed by Eric Blake
Browse files

qmp: add command "x-oob-test"



This command is only used to test OOB functionality.  It should not be
used for any other purposes.

Reviewed-by: default avatarStefan Hajnoczi <stefanha@redhat.com>
Reviewed-by: default avatarFam Zheng <famz@redhat.com>
Signed-off-by: default avatarPeter Xu <peterx@redhat.com>
Message-Id: <20180309090006.10018-22-peterx@redhat.com>
Reviewed-by: default avatarEric Blake <eblake@redhat.com>
[eblake: grammar tweak]
Signed-off-by: default avatarEric Blake <eblake@redhat.com>
parent 3fd2457d
Loading
Loading
Loading
Loading
+18 −0
Original line number Diff line number Diff line
@@ -3427,3 +3427,21 @@
##
{ 'event': 'COMMAND_DROPPED' ,
  'data': { 'id': 'any', 'reason': 'CommandDropReason' } }

##
# @x-oob-test:
#
# Test OOB functionality.  When sending this command with lock=true,
# it'll try to hang the dispatcher.  When sending 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 }
+16 −0
Original line number Diff line number Diff line
@@ -770,3 +770,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);
    }
}