From patchwork Fri Feb 22 15:32:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Stefan Hajnoczi X-Patchwork-Id: 1046985 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 445bMN6Qw6z9s71 for ; Sat, 23 Feb 2019 02:47:44 +1100 (AEDT) Received: from localhost ([127.0.0.1]:53099 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gxD38-0000yB-PX for incoming@patchwork.ozlabs.org; Fri, 22 Feb 2019 10:47:42 -0500 Received: from eggs.gnu.org ([209.51.188.92]:52820) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1gxCoz-0003SC-IC for qemu-devel@nongnu.org; Fri, 22 Feb 2019 10:33:07 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1gxCoy-0002Zg-8Q for qemu-devel@nongnu.org; Fri, 22 Feb 2019 10:33:05 -0500 Received: from mx1.redhat.com ([209.132.183.28]:54576) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1gxCox-0002Si-UX for qemu-devel@nongnu.org; Fri, 22 Feb 2019 10:33:04 -0500 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id CEE2BE6A83 for ; Fri, 22 Feb 2019 15:32:59 +0000 (UTC) Received: from localhost (unknown [10.36.118.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8B8185D70D; Fri, 22 Feb 2019 15:32:55 +0000 (UTC) From: Stefan Hajnoczi To: qemu-devel@nongnu.org Date: Fri, 22 Feb 2019 15:32:54 +0000 Message-Id: <20190222153254.22739-1-stefanha@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Fri, 22 Feb 2019 15:32:59 +0000 (UTC) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 209.132.183.28 Subject: [Qemu-devel] [PATCH] qmp: add query-qemu-capabilities X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Peter Krempa , Markus Armbruster , Stefan Hajnoczi Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" QMP clients can usually detect the presence of features via schema introspection. There are rare features that do not involve schema changes and are therefore impossible to detect with schema introspection. This patch adds the query-qemu-capabilities command. It returns a list of capabilities that this QEMU supports. The decision to make this a command rather than something statically defined in the schema is intentional. It allows QEMU to decide which capabilities are available at runtime, if necessary. This new interface is necessary so that QMP clients can discover that migrating disk image files is safe with cache.direct=off on Linux. There is no other way to detect whether or not QEMU supports this. Cc: Markus Armbruster Cc: Peter Krempa Signed-off-by: Stefan Hajnoczi --- qapi/misc.json | 42 ++++++++++++++++++++++++++++++++++++++++++ qmp.c | 18 ++++++++++++++++++ 2 files changed, 60 insertions(+) diff --git a/qapi/misc.json b/qapi/misc.json index 8b3ca4fdd3..9cf24919a3 100644 --- a/qapi/misc.json +++ b/qapi/misc.json @@ -3051,3 +3051,45 @@ 'data': 'NumaOptions', 'allow-preconfig': true } + +## +# @QemuCapability: +# +# Capabilities that are not otherwise introspectable. +# +# @migrate-with-cache-direct-off-on-linux: +# It is safe to migrate disk image files with cache.direct=off on Linux. +# Previously only cache.direct=on was supported for live migration. +# +# Since: 4.0 +## +{ 'enum': 'QemuCapability', + 'data': [ + 'migrate-with-cache-direct-off-on-linux' + ] +} + +## +# @QemuCapabilities: +# +# Capability information. +# +# @capabilities: supported capabilities +# +# Since: 4.0 +## +{ 'struct': 'QemuCapabilities', + 'data': { 'capabilities': ['QemuCapability'] } } + +## +# @query-qemu-capabilities: +# +# Return the capabilities supported by this QEMU. Most features can be +# detected via schema introspection but some are not observable from the +# schema. This command offers a way to check for the presence of such +# features. +# +# Since: 4.0 +## +{ 'command': 'query-qemu-capabilities', + 'returns': 'QemuCapabilities' } diff --git a/qmp.c b/qmp.c index b92d62cd5f..91a1228be7 100644 --- a/qmp.c +++ b/qmp.c @@ -717,3 +717,21 @@ MemoryInfo *qmp_query_memory_size_summary(Error **errp) return mem_info; } + +QemuCapabilities *qmp_query_qemu_capabilities(Error **errp) +{ + QemuCapabilities *caps = g_new0(QemuCapabilities, 1); + QemuCapabilityList **prev = &caps->capabilities; + QemuCapability cap_val; + + /* Add all QemuCapability enum values defined in the schema */ + for (cap_val = 0; cap_val < QEMU_CAPABILITY__MAX; cap_val++) { + QemuCapabilityList *cap = g_new0(QemuCapabilityList, 1); + + cap->value = cap_val; + *prev = cap; + prev = &cap->next; + } + + return caps; +}