From patchwork Thu Apr 4 23:37:21 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 161817 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp2204437jan; Thu, 4 Apr 2019 16:38:20 -0700 (PDT) X-Google-Smtp-Source: APXvYqwySP+FOEhKr40a1IsdZ57lHU63tn5wPBe2CkHcES1UQA/Cdw+hoLbcLxzIFwVXhiq9mTDr X-Received: by 2002:a0c:ad15:: with SMTP id u21mr7682448qvc.37.1554421100908; Thu, 04 Apr 2019 16:38:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554421100; cv=none; d=google.com; s=arc-20160816; b=U0oKpodpCNNca8ORKSj6YD8SIgIIh4usvcBhi7JSjSZLGLJKKV8NBTMMFwMapkF/el LqXnqU+qG/Gv0+Hr6T0Kfe9TvznAYHplKTY+XqJp7IYG4EDo0dxCgQd6qb/y37orHdU3 QKr7ZBky1EpRNEvuBZbnVVMvaLLFkeXtd3RVj0vGSuR3bgKCvTmMOZ7R4bB6HfsSQMy3 ibMQXuPdFVz5nCAAN9igXkUDghRdzD/yfo3tioADHucxEhz/AZOstJOcUq6fEG5Bhw5u 7p6LReHPQzivfNVai9LIm2b8Gz/1DbHxoxFqURUcTz1Zp29wwHIZeIXfKHCZB2Mk8cTa nWVA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=/VVQYH5Pow+1vkG6B8Dt68vRa+JQEDQRnks+CTawWXs=; b=SsZRb49bO8mlaRpU8CWC42FL1X5wkbqjfsF7sLYtsOkbDT7iXMc0m3tYr6HEVUiCPG qPpEpEo7uSwotrDfiajF5vfVLG+pG71czUYQ7BX7/u2mZBku5ZpZD8gJZeiA7wdXkjO5 qDiVL1B+OdtDJ2AnCxswLRKz+BTAeOIezE48SVSJhBcqJg7pgDGfUb5VQFGuX6sTsKPZ 0etnC3uJmE1EYHQjEBMlv1ZhVzTWS7JxlUUwov7FVNwaqoxv1McJIex5WKo0ehYNOtr/ rG3DbOqOkuFLv0ezFj35SjWEm9TUB3KWKvWS30V/kFJrirw3d1Fi3NwGvZUTz2ckQbUi PCzw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id z31si1402162qvc.171.2019.04.04.16.38.20 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Apr 2019 16:38:20 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 6457B30832CB; Thu, 4 Apr 2019 23:38:19 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3C48C1001E99; Thu, 4 Apr 2019 23:38:19 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 064053FB13; Thu, 4 Apr 2019 23:38:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x34NbcaK011007 for ; Thu, 4 Apr 2019 19:37:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id 95E0B6091F; Thu, 4 Apr 2019 23:37:38 +0000 (UTC) Delivered-To: libvirt-list@redhat.com Received: from worklaptop.redhat.com (ovpn-124-22.rdu2.redhat.com [10.10.124.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id C125C608E5; Thu, 4 Apr 2019 23:37:37 +0000 (UTC) From: Cole Robinson To: libvirt-list@redhat.com Date: Thu, 4 Apr 2019 19:37:21 -0400 Message-Id: <6160973443b95d23525f6e557151f0bd97dd0c44.1554419814.git.crobinso@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/7] conf: domcaps: Report device X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.44]); Thu, 04 Apr 2019 23:38:19 +0000 (UTC) This adds device reporting. Example output: virtio virtio-transitional virtio-non-transitional random egd Signed-off-by: Cole Robinson --- docs/formatdomaincaps.html.in | 35 ++++++++++++++++++++++++++++++++++ docs/schemas/domaincaps.rng | 10 ++++++++++ src/conf/domain_capabilities.c | 14 ++++++++++++++ src/conf/domain_capabilities.h | 9 +++++++++ 4 files changed, 68 insertions(+) -- 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list diff --git a/docs/formatdomaincaps.html.in b/docs/formatdomaincaps.html.in index 2583f9bead..22ddab4301 100644 --- a/docs/formatdomaincaps.html.in +++ b/docs/formatdomaincaps.html.in @@ -427,6 +427,41 @@ element. + +

RNG device

+

RNG device capabilities are exposed under the + rng element. For instance:

+ +
+<domainCapabilities>
+  ...
+  <devices>
+    <rng supported='yes'>
+      <enum name='model'>
+        <value>virtio</value>
+        <value>virtio-transitional</value>
+        <value>virtio-non-transitional</value>
+      </enum>
+      <enum name='backendModel'>
+        <value>random</value>
+        <value>egd</value>
+      </enum>
+    </rng>
+    ...
+  </devices>
+</domainCapabilities>
+
+ +
+
model
+
Options for the model attribute of the + <rng> element.
+
backendModel
+
Options for the model attribute of the + <rng><backend> element.
+
+ +

Features

One more set of XML elements describe the supported features and diff --git a/docs/schemas/domaincaps.rng b/docs/schemas/domaincaps.rng index 3c42cb8075..d1b4d930d9 100644 --- a/docs/schemas/domaincaps.rng +++ b/docs/schemas/domaincaps.rng @@ -154,6 +154,9 @@ + + + @@ -185,6 +188,13 @@ + + + + + + + diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c index 5a8f48da61..03757ba8cd 100644 --- a/src/conf/domain_capabilities.c +++ b/src/conf/domain_capabilities.c @@ -543,6 +543,19 @@ virDomainCapsDeviceHostdevFormat(virBufferPtr buf, } +static void +virDomainCapsDeviceRNGFormat(virBufferPtr buf, + virDomainCapsDeviceRNGPtr const rng) +{ + FORMAT_PROLOGUE(rng); + + ENUM_PROCESS(rng, model, virDomainRNGModelTypeToString); + ENUM_PROCESS(rng, backendModel, virDomainRNGBackendTypeToString); + + FORMAT_EPILOGUE(rng); +} + + /** * virDomainCapsFeatureGICFormat: * @buf: target buffer @@ -621,6 +634,7 @@ virDomainCapsFormat(virDomainCapsPtr const caps) virDomainCapsDeviceGraphicsFormat(&buf, &caps->graphics); virDomainCapsDeviceVideoFormat(&buf, &caps->video); virDomainCapsDeviceHostdevFormat(&buf, &caps->hostdev); + virDomainCapsDeviceRNGFormat(&buf, &caps->rng); virBufferAdjustIndent(&buf, -2); virBufferAddLit(&buf, "\n"); diff --git a/src/conf/domain_capabilities.h b/src/conf/domain_capabilities.h index 26f4b8c394..052191d284 100644 --- a/src/conf/domain_capabilities.h +++ b/src/conf/domain_capabilities.h @@ -96,6 +96,14 @@ struct _virDomainCapsDeviceHostdev { /* add new fields here */ }; +typedef struct _virDomainCapsDeviceRNG virDomainCapsDeviceRNG; +typedef virDomainCapsDeviceRNG *virDomainCapsDeviceRNGPtr; +struct _virDomainCapsDeviceRNG { + virTristateBool supported; + virDomainCapsEnum model; /* virDomainRNGModel */ + virDomainCapsEnum backendModel; /* virDomainRNGBackend */ +}; + typedef struct _virDomainCapsFeatureGIC virDomainCapsFeatureGIC; typedef virDomainCapsFeatureGIC *virDomainCapsFeatureGICPtr; struct _virDomainCapsFeatureGIC { @@ -165,6 +173,7 @@ struct _virDomainCaps { virDomainCapsDeviceGraphics graphics; virDomainCapsDeviceVideo video; virDomainCapsDeviceHostdev hostdev; + virDomainCapsDeviceRNG rng; /* add new domain devices here */ virDomainCapsFeatureGIC gic; From patchwork Thu Apr 4 23:37:22 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 161818 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp2204484jan; Thu, 4 Apr 2019 16:38:24 -0700 (PDT) X-Google-Smtp-Source: APXvYqwmtfn5JvbXJai5d23oo/FqdDKuuqcVYHfMlOvyh5CfnO96dyq13/6lQ5glu3lb1c9x5Qs0 X-Received: by 2002:ac8:3844:: with SMTP id r4mr8213767qtb.5.1554421104156; Thu, 04 Apr 2019 16:38:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554421104; cv=none; d=google.com; s=arc-20160816; b=bolxnmzNWz7X0BjCVu9NzMv9MBQzD6U3nggxCOfeDzL0ozP7hbY40PpsOZF0dMaAG6 MnmHTztbNL7eX/94on5TCP0+789JyL/3MuWuYUI4iE4fa1XkX8P8+wkRReCECWcfKbVj HdRs1EhTygmwW4WE5o03e0NUWBtNBX1Z1o4Y5FokLG6B1jX/Iy7IwYFxZNfmWs/IKdza YGQ5CtxCXDaaG9kjKch43iAWx3VhDeXvTBG2/eMWEFLIKLg8lAxZWq+vgAYPuvnRoI0e kjyXP/4VdY3/uBy/MQVzuUeDd7fvjwBOvJ069o0WN4uX6zktTQSnxtESeHwuaVzsTTqo /IEQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=18/MfqM02VfZ0+FbIBXKrSulWsh4+3TdW19lRYW+Y1o=; b=uoO+DaIT8mLU9XVqhcqCWTs4UqRAvU+1SKHBC2PPny/lQxvP6p00SfRR5VKpPcHmQK lsKxGvC6Q4E39NTSah03s03FkVz4u6JYq/IpLLDZLIivZpfn0ZC6Hml00q3eMHHLzEXC WgO3iX6bbyX5APFKa6UnezEdCrMpAYCY5W4iphouBZuzGuAp0vfbEThGoEslTxLZDTKB 28bAaD6TMDzs34b/11qwIm/tK/zyJJGjmSoPqIXbZtCR0GfYZ53+TU4HEQhzieDjSq9j wfr2QU/ZFM4au8p1p9A3BC+NhAJMGpZtSFL2tGW8qIC9hpJNNle5nfwFlPu0SLfcx0UX mjjw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id q10si6357871qtj.317.2019.04.04.16.38.23 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Apr 2019 16:38:24 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 8EA3481F01; Thu, 4 Apr 2019 23:38:22 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5F6ED6017E; Thu, 4 Apr 2019 23:38:22 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 241C03FB14; Thu, 4 Apr 2019 23:38:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x34NbeGP011020 for ; Thu, 4 Apr 2019 19:37:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id 0BD10608EE; Thu, 4 Apr 2019 23:37:40 +0000 (UTC) Delivered-To: libvirt-list@redhat.com Received: from worklaptop.redhat.com (ovpn-124-22.rdu2.redhat.com [10.10.124.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 01F526092D; Thu, 4 Apr 2019 23:37:38 +0000 (UTC) From: Cole Robinson To: libvirt-list@redhat.com Date: Thu, 4 Apr 2019 19:37:22 -0400 Message-Id: <13488456c6173b3d69b870a747372a2a6d5e3e6e.1554419814.git.crobinso@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/7] qemu: capabilities: fill in domcaps X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 04 Apr 2019 23:38:23 +0000 (UTC) The model logic is taken from qemuDomainRNGDefValidate Signed-off-by: Cole Robinson --- src/qemu/qemu_capabilities.c | 30 +++++++++++++++++++ .../qemu_1.7.0.x86_64.xml | 9 ++++++ .../qemu_2.12.0-virt.aarch64.xml | 11 +++++++ .../qemu_2.12.0.ppc64.xml | 11 +++++++ .../qemu_2.12.0.s390x.xml | 11 +++++++ .../qemu_2.12.0.x86_64.xml | 11 +++++++ .../qemu_2.6.0-virt.aarch64.xml | 11 +++++++ .../qemu_2.6.0.aarch64.xml | 11 +++++++ .../domaincapsschemadata/qemu_2.6.0.ppc64.xml | 11 +++++++ .../qemu_2.6.0.x86_64.xml | 11 +++++++ .../domaincapsschemadata/qemu_2.7.0.s390x.xml | 11 +++++++ .../qemu_2.8.0-tcg.x86_64.xml | 11 +++++++ .../domaincapsschemadata/qemu_2.8.0.s390x.xml | 11 +++++++ .../qemu_2.8.0.x86_64.xml | 11 +++++++ .../qemu_2.9.0-q35.x86_64.xml | 11 +++++++ .../qemu_2.9.0-tcg.x86_64.xml | 11 +++++++ .../qemu_2.9.0.x86_64.xml | 11 +++++++ .../domaincapsschemadata/qemu_3.0.0.s390x.xml | 11 +++++++ .../qemu_4.0.0.x86_64.xml | 11 +++++++ 19 files changed, 226 insertions(+) -- 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Signed-off-by: Cole Robinson <crobinso@redhat.com> diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 71d4c01296..46ba5e30b5 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -5165,6 +5165,34 @@ virQEMUCapsFillDomainDeviceHostdevCaps(virQEMUCapsPtr qemuCaps, } +static int +virQEMUCapsFillDomainDeviceRNGCaps(virQEMUCapsPtr qemuCaps, + virDomainCapsDeviceRNGPtr rng) +{ + rng->supported = VIR_TRISTATE_BOOL_YES; + rng->model.report = true; + rng->backendModel.report = true; + + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_RNG)) { + VIR_DOMAIN_CAPS_ENUM_SET(rng->model, VIR_DOMAIN_RNG_MODEL_VIRTIO); + + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL) || + virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY)) { + VIR_DOMAIN_CAPS_ENUM_SET(rng->model, + VIR_DOMAIN_RNG_MODEL_VIRTIO_TRANSITIONAL, + VIR_DOMAIN_RNG_MODEL_VIRTIO_NON_TRANSITIONAL); + } + } + + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_RNG_EGD)) + VIR_DOMAIN_CAPS_ENUM_SET(rng->backendModel, VIR_DOMAIN_RNG_BACKEND_EGD); + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_RNG_RANDOM)) + VIR_DOMAIN_CAPS_ENUM_SET(rng->backendModel, VIR_DOMAIN_RNG_BACKEND_RANDOM); + + return 0; +} + + /** * virQEMUCapsSupportsGICVersion: * @qemuCaps: QEMU capabilities @@ -5306,6 +5334,7 @@ virQEMUCapsFillDomainCaps(virCapsPtr caps, virDomainCapsDeviceHostdevPtr hostdev = &domCaps->hostdev; virDomainCapsDeviceGraphicsPtr graphics = &domCaps->graphics; virDomainCapsDeviceVideoPtr video = &domCaps->video; + virDomainCapsDeviceRNGPtr rng = &domCaps->rng; domCaps->maxvcpus = virQEMUCapsGetMachineMaxCpus(qemuCaps, domCaps->machine); @@ -5332,6 +5361,7 @@ virQEMUCapsFillDomainCaps(virCapsPtr caps, virQEMUCapsFillDomainDeviceGraphicsCaps(qemuCaps, graphics) < 0 || virQEMUCapsFillDomainDeviceVideoCaps(qemuCaps, video) < 0 || virQEMUCapsFillDomainDeviceHostdevCaps(qemuCaps, hostdev) < 0 || + virQEMUCapsFillDomainDeviceRNGCaps(qemuCaps, rng) < 0 || virQEMUCapsFillDomainFeatureGICCaps(qemuCaps, domCaps) < 0 || virQEMUCapsFillDomainFeatureSEVCaps(qemuCaps, domCaps) < 0) return -1; diff --git a/tests/domaincapsschemadata/qemu_1.7.0.x86_64.xml b/tests/domaincapsschemadata/qemu_1.7.0.x86_64.xml index 497363bbe9..a9b0efdbdb 100644 --- a/tests/domaincapsschemadata/qemu_1.7.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_1.7.0.x86_64.xml @@ -109,6 +109,15 @@ vfio + + + virtio + + + random + egd + + diff --git a/tests/domaincapsschemadata/qemu_2.12.0-virt.aarch64.xml b/tests/domaincapsschemadata/qemu_2.12.0-virt.aarch64.xml index 7639df44c6..654ce1f538 100644 --- a/tests/domaincapsschemadata/qemu_2.12.0-virt.aarch64.xml +++ b/tests/domaincapsschemadata/qemu_2.12.0-virt.aarch64.xml @@ -114,6 +114,17 @@ vfio + + + virtio + virtio-transitional + virtio-non-transitional + + + random + egd + + diff --git a/tests/domaincapsschemadata/qemu_2.12.0.ppc64.xml b/tests/domaincapsschemadata/qemu_2.12.0.ppc64.xml index f10d361359..2ac32fcb3b 100644 --- a/tests/domaincapsschemadata/qemu_2.12.0.ppc64.xml +++ b/tests/domaincapsschemadata/qemu_2.12.0.ppc64.xml @@ -80,6 +80,17 @@ vfio + + + virtio + virtio-transitional + virtio-non-transitional + + + random + egd + + diff --git a/tests/domaincapsschemadata/qemu_2.12.0.s390x.xml b/tests/domaincapsschemadata/qemu_2.12.0.s390x.xml index 41a81ff02f..fa377d33a0 100644 --- a/tests/domaincapsschemadata/qemu_2.12.0.s390x.xml +++ b/tests/domaincapsschemadata/qemu_2.12.0.s390x.xml @@ -172,6 +172,17 @@ vfio + + + virtio + virtio-transitional + virtio-non-transitional + + + random + egd + + diff --git a/tests/domaincapsschemadata/qemu_2.12.0.x86_64.xml b/tests/domaincapsschemadata/qemu_2.12.0.x86_64.xml index 5913e7fc63..712b83f443 100644 --- a/tests/domaincapsschemadata/qemu_2.12.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_2.12.0.x86_64.xml @@ -142,6 +142,17 @@ vfio + + + virtio + virtio-transitional + virtio-non-transitional + + + random + egd + + diff --git a/tests/domaincapsschemadata/qemu_2.6.0-virt.aarch64.xml b/tests/domaincapsschemadata/qemu_2.6.0-virt.aarch64.xml index 9ee801092e..26bd16788a 100644 --- a/tests/domaincapsschemadata/qemu_2.6.0-virt.aarch64.xml +++ b/tests/domaincapsschemadata/qemu_2.6.0-virt.aarch64.xml @@ -111,6 +111,17 @@ vfio + + + virtio + virtio-transitional + virtio-non-transitional + + + random + egd + + diff --git a/tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml b/tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml index 4dd0b52ed3..3aa5474e64 100644 --- a/tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml +++ b/tests/domaincapsschemadata/qemu_2.6.0.aarch64.xml @@ -111,6 +111,17 @@ vfio + + + virtio + virtio-transitional + virtio-non-transitional + + + random + egd + + diff --git a/tests/domaincapsschemadata/qemu_2.6.0.ppc64.xml b/tests/domaincapsschemadata/qemu_2.6.0.ppc64.xml index aa982d237e..cb179b34af 100644 --- a/tests/domaincapsschemadata/qemu_2.6.0.ppc64.xml +++ b/tests/domaincapsschemadata/qemu_2.6.0.ppc64.xml @@ -84,6 +84,17 @@ vfio + + + virtio + virtio-transitional + virtio-non-transitional + + + random + egd + + diff --git a/tests/domaincapsschemadata/qemu_2.6.0.x86_64.xml b/tests/domaincapsschemadata/qemu_2.6.0.x86_64.xml index 6aa3f52ee4..5a675e205f 100644 --- a/tests/domaincapsschemadata/qemu_2.6.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_2.6.0.x86_64.xml @@ -116,6 +116,17 @@ vfio + + + virtio + virtio-transitional + virtio-non-transitional + + + random + egd + + diff --git a/tests/domaincapsschemadata/qemu_2.7.0.s390x.xml b/tests/domaincapsschemadata/qemu_2.7.0.s390x.xml index 8daa15ab9d..f601922d5e 100644 --- a/tests/domaincapsschemadata/qemu_2.7.0.s390x.xml +++ b/tests/domaincapsschemadata/qemu_2.7.0.s390x.xml @@ -77,6 +77,17 @@ vfio + + + virtio + virtio-transitional + virtio-non-transitional + + + random + egd + + diff --git a/tests/domaincapsschemadata/qemu_2.8.0-tcg.x86_64.xml b/tests/domaincapsschemadata/qemu_2.8.0-tcg.x86_64.xml index 081805aa4a..4d48e7d251 100644 --- a/tests/domaincapsschemadata/qemu_2.8.0-tcg.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_2.8.0-tcg.x86_64.xml @@ -117,6 +117,17 @@ vfio + + + virtio + virtio-transitional + virtio-non-transitional + + + random + egd + + diff --git a/tests/domaincapsschemadata/qemu_2.8.0.s390x.xml b/tests/domaincapsschemadata/qemu_2.8.0.s390x.xml index 62c51e4087..f18dc262b4 100644 --- a/tests/domaincapsschemadata/qemu_2.8.0.s390x.xml +++ b/tests/domaincapsschemadata/qemu_2.8.0.s390x.xml @@ -158,6 +158,17 @@ vfio + + + virtio + virtio-transitional + virtio-non-transitional + + + random + egd + + diff --git a/tests/domaincapsschemadata/qemu_2.8.0.x86_64.xml b/tests/domaincapsschemadata/qemu_2.8.0.x86_64.xml index 1bb034aa4f..46d398949a 100644 --- a/tests/domaincapsschemadata/qemu_2.8.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_2.8.0.x86_64.xml @@ -117,6 +117,17 @@ vfio + + + virtio + virtio-transitional + virtio-non-transitional + + + random + egd + + diff --git a/tests/domaincapsschemadata/qemu_2.9.0-q35.x86_64.xml b/tests/domaincapsschemadata/qemu_2.9.0-q35.x86_64.xml index 67c6d5e77e..a7392c0929 100644 --- a/tests/domaincapsschemadata/qemu_2.9.0-q35.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_2.9.0-q35.x86_64.xml @@ -125,6 +125,17 @@ vfio + + + virtio + virtio-transitional + virtio-non-transitional + + + random + egd + + diff --git a/tests/domaincapsschemadata/qemu_2.9.0-tcg.x86_64.xml b/tests/domaincapsschemadata/qemu_2.9.0-tcg.x86_64.xml index 588ef08199..f94f805b81 100644 --- a/tests/domaincapsschemadata/qemu_2.9.0-tcg.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_2.9.0-tcg.x86_64.xml @@ -149,6 +149,17 @@ vfio + + + virtio + virtio-transitional + virtio-non-transitional + + + random + egd + + diff --git a/tests/domaincapsschemadata/qemu_2.9.0.x86_64.xml b/tests/domaincapsschemadata/qemu_2.9.0.x86_64.xml index 598937a971..b0039c8246 100644 --- a/tests/domaincapsschemadata/qemu_2.9.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_2.9.0.x86_64.xml @@ -126,6 +126,17 @@ vfio + + + virtio + virtio-transitional + virtio-non-transitional + + + random + egd + + diff --git a/tests/domaincapsschemadata/qemu_3.0.0.s390x.xml b/tests/domaincapsschemadata/qemu_3.0.0.s390x.xml index 1d97f1f344..b33ff6a09d 100644 --- a/tests/domaincapsschemadata/qemu_3.0.0.s390x.xml +++ b/tests/domaincapsschemadata/qemu_3.0.0.s390x.xml @@ -178,6 +178,17 @@ vfio + + + virtio + virtio-transitional + virtio-non-transitional + + + random + egd + + diff --git a/tests/domaincapsschemadata/qemu_4.0.0.x86_64.xml b/tests/domaincapsschemadata/qemu_4.0.0.x86_64.xml index df66be9e29..7596e414d6 100644 --- a/tests/domaincapsschemadata/qemu_4.0.0.x86_64.xml +++ b/tests/domaincapsschemadata/qemu_4.0.0.x86_64.xml @@ -143,6 +143,17 @@ vfio + + + virtio + virtio-transitional + virtio-non-transitional + + + random + egd + + From patchwork Thu Apr 4 23:37:23 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 161821 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp2205453jan; Thu, 4 Apr 2019 16:39:52 -0700 (PDT) X-Google-Smtp-Source: APXvYqxDuUp1VtJZhkAvsCdPgAus0cM3E+whMewxr1UktObNabN/5+c/xKRIHcnGXBKGRq55WdhO X-Received: by 2002:a0c:acf8:: with SMTP id n53mr7302817qvc.83.1554421192368; Thu, 04 Apr 2019 16:39:52 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554421192; cv=none; d=google.com; s=arc-20160816; b=BSlpOkYWQSK+LFufFaqMlgdLyz3bi2t9OcCqjG5CRa8e1zN8orYcnZboccRTmgzsxl +4I3w4rvP4Ur53QvkELc7xM7zoHZf5F4nsSDTI5Ng7e9T9X3WRhao3WWR9D+QULoW6MD mWrppF78IOHHW890SGjVtT2z55PrATMOqSa1kd6DdlAQIQaD2/Lyu+Rgod0NNvWoW9lX m6BDWHy8uzIfjsgGddqhQ/yFj7mOSS38gfEgv6wHZGfEt3v5+XIB+ZDq3T9CncnXd5Cm kHMniq6RyKC1I7UgLGbPTVzLWlHitQHfVCKPS38AMvGTnZLfwVKWOBSFUySTUKtPfvel snhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=SZj6HNpcgK+AOjMiIZN72rno99GG5RzXrC5UEqr9ZQM=; b=WBgzdqLTwsUeXPPwV/u5+jrzz/dsHqgvpGvSCUvBls01Ck89gk0bGZiXG2Jvwjxr6b 0O+Xg1EHYuyxUWRMzeG+7bCwD/35rMzPu6/yPme/qXuBVR6IeL3AJm+uFsGOLtlUMu/W OSOPEj57mR3Tu+pmyu7MwXgdvJ9iMsDcVwjhUU7LWs5Va3IzbA9WAKCRuVmF+WinRQBb wMl9JjbKIl3ecrpJG2oDe323iHR8+asub1JKrpE4eVWakNUwgSHNvye2oqOfQy/d7OX0 qKZ1tO9ffkpOl9BFqMMBSZ1LwxyyZt6dzm8QbKCI44UcE1WhfUSxHSb9Z2YRBE0soRUS gbQg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id q4si2100167qve.8.2019.04.04.16.39.52 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Apr 2019 16:39:52 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 1B7AD7D0C4; Thu, 4 Apr 2019 23:39:51 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E18E3600C5; Thu, 4 Apr 2019 23:39:50 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A755A3FB11; Thu, 4 Apr 2019 23:39:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x34NbfQu011030 for ; Thu, 4 Apr 2019 19:37:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id 43A4F60919; Thu, 4 Apr 2019 23:37:41 +0000 (UTC) Delivered-To: libvirt-list@redhat.com Received: from worklaptop.redhat.com (ovpn-124-22.rdu2.redhat.com [10.10.124.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6B5A8608E5; Thu, 4 Apr 2019 23:37:40 +0000 (UTC) From: Cole Robinson To: libvirt-list@redhat.com Date: Thu, 4 Apr 2019 19:37:23 -0400 Message-Id: <5b90f49b349c1d9379544a8a091a9d3a0618fc04.1554419814.git.crobinso@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/7] qemu: conf: add virQEMUDriverGetDomainCapabilities X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Thu, 04 Apr 2019 23:39:51 +0000 (UTC) For now it's just a helper for building a qemu virDomainCapsPtr. It will be used in upcoming patches Signed-off-by: Cole Robinson --- src/qemu/qemu_conf.c | 39 +++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_conf.h | 7 +++++++ src/qemu/qemu_driver.c | 18 +++--------------- 3 files changed, 49 insertions(+), 15 deletions(-) -- 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Reviewed-by: Daniel Henrique Barboza diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 41ce0a978d..635fdcc5a4 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1357,6 +1357,45 @@ virCapsPtr virQEMUDriverGetCapabilities(virQEMUDriverPtr driver, return ret; } + +/** + * virQEMUDriverGetDomainCapabilities: + * + * Build a virDomainCapsPtr instance for the passed data. + * + * Returns: a reference to a virDomainCapsPtr instance or NULL + */ +virDomainCapsPtr +virQEMUDriverGetDomainCapabilities(virQEMUDriverPtr driver, + virQEMUCapsPtr qemuCaps, + const char *machine, + virArch arch, + virDomainVirtType virttype) +{ + virDomainCapsPtr ret = NULL, domCaps = NULL; + virCapsPtr caps = NULL; + virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); + + if (!(caps = virQEMUDriverGetCapabilities(driver, false))) + goto cleanup; + + if (!(domCaps = virDomainCapsNew(virQEMUCapsGetBinary(qemuCaps), machine, + arch, virttype))) + goto cleanup; + + if (virQEMUCapsFillDomainCaps(caps, domCaps, qemuCaps, + cfg->firmwares, cfg->nfirmwares) < 0) + goto cleanup; + + VIR_STEAL_PTR(ret, domCaps); + cleanup: + virObjectUnref(domCaps); + virObjectUnref(cfg); + virObjectUnref(caps); + return ret; +} + + struct _qemuSharedDeviceEntry { size_t ref; char **domains; /* array of domain names */ diff --git a/src/qemu/qemu_conf.h b/src/qemu/qemu_conf.h index 14c9d15a72..ddf5ea4b8f 100644 --- a/src/qemu/qemu_conf.h +++ b/src/qemu/qemu_conf.h @@ -331,6 +331,13 @@ virCapsPtr virQEMUDriverCreateCapabilities(virQEMUDriverPtr driver); virCapsPtr virQEMUDriverGetCapabilities(virQEMUDriverPtr driver, bool refresh); +virDomainCapsPtr +virQEMUDriverGetDomainCapabilities(virQEMUDriverPtr driver, + virQEMUCapsPtr qemuCaps, + const char *machine, + virArch arch, + virDomainVirtType virttype); + typedef struct _qemuSharedDeviceEntry qemuSharedDeviceEntry; typedef qemuSharedDeviceEntry *qemuSharedDeviceEntryPtr; diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 7e5bbc3cc9..3e8ae8a4dc 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -19829,19 +19829,12 @@ qemuConnectGetDomainCapabilities(virConnectPtr conn, virArch arch; virDomainVirtType virttype; virDomainCapsPtr domCaps = NULL; - virQEMUDriverConfigPtr cfg = NULL; - virCapsPtr caps = NULL; virCheckFlags(0, ret); if (virConnectGetDomainCapabilitiesEnsureACL(conn) < 0) return ret; - cfg = virQEMUDriverGetConfig(driver); - - if (!(caps = virQEMUDriverGetCapabilities(driver, false))) - goto cleanup; - qemuCaps = virQEMUCapsCacheLookupDefault(driver->qemuCapsCache, emulatorbin, arch_str, @@ -19851,18 +19844,13 @@ qemuConnectGetDomainCapabilities(virConnectPtr conn, if (!qemuCaps) goto cleanup; - if (!(domCaps = virDomainCapsNew(virQEMUCapsGetBinary(qemuCaps), machine, - arch, virttype))) - goto cleanup; - - if (virQEMUCapsFillDomainCaps(caps, domCaps, qemuCaps, - cfg->firmwares, cfg->nfirmwares) < 0) + if (!(domCaps = virQEMUDriverGetDomainCapabilities(driver, + qemuCaps, machine, + arch, virttype))) goto cleanup; ret = virDomainCapsFormat(domCaps); cleanup: - virObjectUnref(cfg); - virObjectUnref(caps); virObjectUnref(domCaps); virObjectUnref(qemuCaps); return ret; From patchwork Thu Apr 4 23:37:24 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 161816 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp2204265jan; Thu, 4 Apr 2019 16:38:07 -0700 (PDT) X-Google-Smtp-Source: APXvYqzMZZnKEEWOKKW+5+tXxUXRG/qTkP/VvbUVgEgSttlYfQQkOOSXDEtWAh6EMHQqbNzOiW3Z X-Received: by 2002:a0c:f903:: with SMTP id v3mr7632482qvn.152.1554421087818; Thu, 04 Apr 2019 16:38:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554421087; cv=none; d=google.com; s=arc-20160816; b=Suv3sQ7rjW6GJFJiD9rQjbf79ChN2B+LBQVvtWn712s0/N3sl2bwuyW5pRvhOnRsGK O4jOcvHdZ2b/4KlU4nG8YtCAKKZKtkKe8AAAxuPE7ucUObgibUx3APhf68L4kXfYrGcW 4LkuBM1cgCxp2+22ZF6uiIHVtZ6CtOhMGRyzt/sEWKKkqjlQJenD8m3dpfmAdiQai/Pd 7QX9aDJD8/jKGc3qyvBCiSdrJxFuIcLvowRd22n6NVECS0JOyJy0acrlDCifAVfb5D/+ 9vJmEUms1sZvizFIm857r1UqNOVkVpE1JqY9aGuTBrI3pZo+NzAYwWk5hd1vilLvsjuC btvw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=ar4bmjAKuFJgiElDs9OtuHScXD3AHhAUOn4QSM16ihc=; b=ETXDoZ8UyX7hbgnIaURNJnKEnsSv19tBtmpYonlOiiVcJZ/W//OAHiYoEioWxHkrYi +bsgsH+IOehEW2Bf6Gbn6w5KirWUmI2/Z0mFrhxZ07uxubBnx5nQZrVOeMGSBs7bvT5R J3zXbm9jSy1KxQ7PG1Q+TRFAsMKjtuyLqKfGM+Th2N7CCqWENuVp/P9hxlmbbARGs1q9 Z/qiAK96FGHUsz5mSB1kNlunHoCfH9Ak9vRJtl8YRQiRrKRaF43BCZUcD8QZK3Suy6aj 2iRlT1o52LBskVyxyZb6cUNteh6mCkWnBgDH5K980tiKwfGylyaU8SVJafW1dNFFzzN/ WT7A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id h19si129631qto.168.2019.04.04.16.38.07 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Apr 2019 16:38:07 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5BBF53086223; Thu, 4 Apr 2019 23:38:06 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2F88E1001E99; Thu, 4 Apr 2019 23:38:06 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 7EC973FB13; Thu, 4 Apr 2019 23:38:05 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x34NbgKT011037 for ; Thu, 4 Apr 2019 19:37:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id 62F0260919; Thu, 4 Apr 2019 23:37:42 +0000 (UTC) Delivered-To: libvirt-list@redhat.com Received: from worklaptop.redhat.com (ovpn-124-22.rdu2.redhat.com [10.10.124.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id A362A608E5; Thu, 4 Apr 2019 23:37:41 +0000 (UTC) From: Cole Robinson To: libvirt-list@redhat.com Date: Thu, 4 Apr 2019 19:37:24 -0400 Message-Id: <980d16e0dd03fdebba118fc2ab8a3a0b5dc08b76.1554419814.git.crobinso@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/7] qemu: conf: Cache domCaps in qemuCaps X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.42]); Thu, 04 Apr 2019 23:38:06 +0000 (UTC) qemuCaps is tied to a binary on disk. domCaps is tied to a combo of binary+machine+arch+virttype values. For the qemu driver this almost entirely translates to a permutation of qemuCaps though Upcoming patches want to use the domCaps data store at XML validate time, but we need to cache the data so we aren't repeatedly regenerating it. Add a domCapsCache hash table to qemuCaps. This ensures that the domCaps cache is blown away whenever qemuCaps needs to be regenerated. Adjust virQEMUDriverGetDomainCapabilities to search the cache and add to it if we don't find a hit. Signed-off-by: Cole Robinson --- src/qemu/qemu_capabilities.c | 11 +++++++ src/qemu/qemu_capabilities.h | 1 + src/qemu/qemu_conf.c | 59 +++++++++++++++++++++++++++++++----- 3 files changed, 64 insertions(+), 7 deletions(-) -- 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list Reviewed-by: Daniel Henrique Barboza diff --git a/src/qemu/qemu_capabilities.c b/src/qemu/qemu_capabilities.c index 46ba5e30b5..a3c1348157 100644 --- a/src/qemu/qemu_capabilities.c +++ b/src/qemu/qemu_capabilities.c @@ -582,6 +582,7 @@ struct _virQEMUCaps { virArch arch; + virHashTablePtr domCapsCache; virDomainCapsCPUModelsPtr kvmCPUModels; virDomainCapsCPUModelsPtr tcgCPUModels; @@ -1476,6 +1477,9 @@ virQEMUCapsNew(void) if (!(qemuCaps->flags = virBitmapNew(QEMU_CAPS_LAST))) goto error; + if (!(qemuCaps->domCapsCache = virHashCreate(5, virObjectFreeHashData))) + goto error; + return qemuCaps; error: @@ -1628,6 +1632,7 @@ void virQEMUCapsDispose(void *obj) } VIR_FREE(qemuCaps->machineTypes); + virHashFree(qemuCaps->domCapsCache); virObjectUnref(qemuCaps->kvmCPUModels); virObjectUnref(qemuCaps->tcgCPUModels); @@ -1790,6 +1795,12 @@ const char *virQEMUCapsGetPackage(virQEMUCapsPtr qemuCaps) } +virHashTablePtr virQEMUCapsGetDomainCapsCache(virQEMUCapsPtr qemuCaps) +{ + return qemuCaps->domCapsCache; +} + + int virQEMUCapsAddCPUDefinitions(virQEMUCapsPtr qemuCaps, virDomainVirtType type, diff --git a/src/qemu/qemu_capabilities.h b/src/qemu/qemu_capabilities.h index c6f6980684..2a37f0c2ff 100644 --- a/src/qemu/qemu_capabilities.h +++ b/src/qemu/qemu_capabilities.h @@ -538,6 +538,7 @@ const char *virQEMUCapsGetBinary(virQEMUCapsPtr qemuCaps); virArch virQEMUCapsGetArch(virQEMUCapsPtr qemuCaps); unsigned int virQEMUCapsGetVersion(virQEMUCapsPtr qemuCaps); const char *virQEMUCapsGetPackage(virQEMUCapsPtr qemuCaps); +virHashTablePtr virQEMUCapsGetDomainCapsCache(virQEMUCapsPtr qemuCaps); unsigned int virQEMUCapsGetKVMVersion(virQEMUCapsPtr qemuCaps); int virQEMUCapsAddCPUDefinitions(virQEMUCapsPtr qemuCaps, virDomainVirtType type, diff --git a/src/qemu/qemu_conf.c b/src/qemu/qemu_conf.c index 635fdcc5a4..6a7c183075 100644 --- a/src/qemu/qemu_conf.c +++ b/src/qemu/qemu_conf.c @@ -1358,10 +1358,39 @@ virCapsPtr virQEMUDriverGetCapabilities(virQEMUDriverPtr driver, } +struct virQEMUDriverSearchDomcapsData { + const char *path; + const char *machine; + virArch arch; + virDomainVirtType virttype; +}; + + +static int +virQEMUDriverSearchDomcaps(const void *payload, + const void *name ATTRIBUTE_UNUSED, + const void *opaque) +{ + virDomainCapsPtr domCaps = (virDomainCapsPtr) payload; + struct virQEMUDriverSearchDomcapsData *data = (struct virQEMUDriverSearchDomcapsData *) opaque; + + if (STREQ_NULLABLE(data->path, domCaps->path) && + STREQ_NULLABLE(data->machine, domCaps->machine) && + data->arch == domCaps->arch && + data->virttype == domCaps->virttype) + return 1; + + return 0; +} + /** * virQEMUDriverGetDomainCapabilities: * - * Build a virDomainCapsPtr instance for the passed data. + * Get a reference to the virDomainCapsPtr instance from the virQEMUCapsPtr + * domCapsCache. If there's no domcaps in the cache, create a new instance, + * add it to the cache, and return a reference. + * + * The caller must release the reference with virObjetUnref * * Returns: a reference to a virDomainCapsPtr instance or NULL */ @@ -1375,18 +1404,34 @@ virQEMUDriverGetDomainCapabilities(virQEMUDriverPtr driver, virDomainCapsPtr ret = NULL, domCaps = NULL; virCapsPtr caps = NULL; virQEMUDriverConfigPtr cfg = virQEMUDriverGetConfig(driver); + virHashTablePtr domCapsCache = virQEMUCapsGetDomainCapsCache(qemuCaps); + struct virQEMUDriverSearchDomcapsData data = { + .path = virQEMUCapsGetBinary(qemuCaps), + .machine = machine, + .arch = arch, + .virttype = virttype, + }; if (!(caps = virQEMUDriverGetCapabilities(driver, false))) goto cleanup; - if (!(domCaps = virDomainCapsNew(virQEMUCapsGetBinary(qemuCaps), machine, - arch, virttype))) - goto cleanup; + domCaps = virHashSearch(domCapsCache, + virQEMUDriverSearchDomcaps, &data, NULL); + if (!domCaps) { + /* hash miss, build new domcaps */ + if (!(domCaps = virDomainCapsNew(data.path, data.machine, + data.arch, data.virttype))) + goto cleanup; - if (virQEMUCapsFillDomainCaps(caps, domCaps, qemuCaps, - cfg->firmwares, cfg->nfirmwares) < 0) - goto cleanup; + if (virQEMUCapsFillDomainCaps(caps, domCaps, qemuCaps, + cfg->firmwares, cfg->nfirmwares) < 0) + goto cleanup; + + if (virHashAddEntry(domCapsCache, machine, domCaps) < 0) + goto cleanup; + } + virObjectRef(domCaps); VIR_STEAL_PTR(ret, domCaps); cleanup: virObjectUnref(domCaps); From patchwork Thu Apr 4 23:37:25 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 161819 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp2204518jan; Thu, 4 Apr 2019 16:38:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqxXLyv/yVdqH43X3rGf3T0xOrC02M2F/BkWZodaKHo3UyOMTb3QmKzuWrUEitj1Oiy6hMxn X-Received: by 2002:ac8:1aec:: with SMTP id h41mr7610908qtk.345.1554421107092; Thu, 04 Apr 2019 16:38:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554421107; cv=none; d=google.com; s=arc-20160816; b=fTW77F2MnEUFsQ20Lybh+unj9yfSg0M3LaDUenHdVyIZZ5sRYX0ss6ZYjSmUejHRpW wfHKDoZbDyMG3duaOHjtWazTiJFVHXJFny5OLH10+qQA7fcJkEwOyS2AS8q34+Hpp0H5 lRmiBIWHNdzlk1bl3aRy6VIy59o8A7o0i7EyiIC2jLN32Fh6wRdjnSWa7mbdrOFCKng8 xOvK6hGJ4Ga4moTa6jJhzTJoBi7dswhXmiYvlBFjZgu/2IR/CdueNkEyVN6aw+eLf2XR wUCpV16MTF5UzBHr9qv0J5wD3kIMXQTcYbx6K1BWmFi9XTeLCGJ0szDj19/+A1luIl71 31Rg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=Rmnx1QrHXrzCcpgO7JH9whTNqQKnyJsctZl8wst+nd4=; b=K5+MO1AT1S5awpbGLd6JDRjOQpNQxoFfqA1UJtOWUbifq589DjP9d9LwrpYLkHsY8W JU9ZD+3rxR0e6m2dzpzc5THJW1voYm9/r2k1OALRKKEIh5cj5Iw/MUvZ06CbSlD6SLPB jNX9IDNi2ClQAymPnAVCKGm7qWEqddsyWy+RQ7AdwfGbzSWnfNVeY89P9GpeLbVGjHs5 kREGu2s/julNFT7CULELHzAXlrDIAQaJJ8QNq+F6QBygQh+m4PWj187n71cmjXUWKmJv 2dF8rf+OGoTRXi8d8gmlb4oZVA1YwTj7Wfi1BwwSP3y+VLVOAZO4RnvXqzUNFToFzec6 xMEQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id d2si2229604qvn.110.2019.04.04.16.38.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Apr 2019 16:38:27 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id D7C27307D9D0; Thu, 4 Apr 2019 23:38:25 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id ABE5F19C67; Thu, 4 Apr 2019 23:38:25 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 6D2F2181AC43; Thu, 4 Apr 2019 23:38:25 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x34Nbhs2011047 for ; Thu, 4 Apr 2019 19:37:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9951960925; Thu, 4 Apr 2019 23:37:43 +0000 (UTC) Delivered-To: libvirt-list@redhat.com Received: from worklaptop.redhat.com (ovpn-124-22.rdu2.redhat.com [10.10.124.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id C316A6091F; Thu, 4 Apr 2019 23:37:42 +0000 (UTC) From: Cole Robinson To: libvirt-list@redhat.com Date: Thu, 4 Apr 2019 19:37:25 -0400 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 5/7] conf: domcaps: Add virDomainCapsDeviceDefValidate X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Thu, 04 Apr 2019 23:38:26 +0000 (UTC) This is an entrypoint to validate a virDomainDeviceDef against values filled into virDomainCaps. Currently it's just a stub Signed-off-by: Cole Robinson --- src/conf/domain_capabilities.c | 40 ++++++++++++++++++++++++++++++++++ src/conf/domain_capabilities.h | 4 ++++ src/libvirt_private.syms | 1 + 3 files changed, 45 insertions(+) -- 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c index 03757ba8cd..aef5703df6 100644 --- a/src/conf/domain_capabilities.c +++ b/src/conf/domain_capabilities.c @@ -20,6 +20,7 @@ #include +#include "device_conf.h" #include "domain_capabilities.h" #include "domain_conf.h" #include "viralloc.h" @@ -656,3 +657,42 @@ virDomainCapsFormat(virDomainCapsPtr const caps) virBufferCheckError(&buf); return virBufferContentAndReset(&buf); } + + +int +virDomainCapsDeviceDefValidate(virDomainCapsPtr const caps ATTRIBUTE_UNUSED, + const virDomainDeviceDef *dev, + const virDomainDef *def ATTRIBUTE_UNUSED) +{ + switch ((virDomainDeviceType) dev->type) { + case VIR_DOMAIN_DEVICE_DISK: + case VIR_DOMAIN_DEVICE_REDIRDEV: + case VIR_DOMAIN_DEVICE_NET: + case VIR_DOMAIN_DEVICE_CONTROLLER: + case VIR_DOMAIN_DEVICE_CHR: + case VIR_DOMAIN_DEVICE_SMARTCARD: + case VIR_DOMAIN_DEVICE_RNG: + case VIR_DOMAIN_DEVICE_HOSTDEV: + case VIR_DOMAIN_DEVICE_VIDEO: + case VIR_DOMAIN_DEVICE_MEMORY: + case VIR_DOMAIN_DEVICE_VSOCK: + case VIR_DOMAIN_DEVICE_INPUT: + case VIR_DOMAIN_DEVICE_SHMEM: + case VIR_DOMAIN_DEVICE_LEASE: + case VIR_DOMAIN_DEVICE_FS: + case VIR_DOMAIN_DEVICE_SOUND: + case VIR_DOMAIN_DEVICE_WATCHDOG: + case VIR_DOMAIN_DEVICE_GRAPHICS: + case VIR_DOMAIN_DEVICE_HUB: + case VIR_DOMAIN_DEVICE_MEMBALLOON: + case VIR_DOMAIN_DEVICE_NVRAM: + case VIR_DOMAIN_DEVICE_TPM: + case VIR_DOMAIN_DEVICE_PANIC: + case VIR_DOMAIN_DEVICE_IOMMU: + case VIR_DOMAIN_DEVICE_NONE: + case VIR_DOMAIN_DEVICE_LAST: + break; + } + + return 0; +} diff --git a/src/conf/domain_capabilities.h b/src/conf/domain_capabilities.h index 052191d284..ffce2c2964 100644 --- a/src/conf/domain_capabilities.h +++ b/src/conf/domain_capabilities.h @@ -223,6 +223,10 @@ void virDomainCapsEnumClear(virDomainCapsEnumPtr capsEnum); char * virDomainCapsFormat(virDomainCapsPtr const caps); +int virDomainCapsDeviceDefValidate(virDomainCapsPtr const caps, + const virDomainDeviceDef *dev, + const virDomainDef *def); + void virSEVCapabilitiesFree(virSEVCapability *capabilities); diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 212adf53c1..231b487ab0 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -185,6 +185,7 @@ virDomainCapsCPUModelsGet; virDomainCapsCPUModelsNew; virDomainCapsCPUUsableTypeFromString; virDomainCapsCPUUsableTypeToString; +virDomainCapsDeviceDefValidate; virDomainCapsEnumClear; virDomainCapsEnumSet; virDomainCapsFormat; From patchwork Thu Apr 4 23:37:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 161820 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp2204550jan; Thu, 4 Apr 2019 16:38:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqxmhgSWAg4aM0awNbvFsM1POQielfpYTEldsKpbimfGaHkNBiD5jgj1kv9gH94WSfo52HxJ X-Received: by 2002:a0c:94d0:: with SMTP id k16mr7336588qvk.158.1554421110522; Thu, 04 Apr 2019 16:38:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554421110; cv=none; d=google.com; s=arc-20160816; b=nuEumDVo7Gb9jquKkHbY6DlNAUr02woXagrqTogdsov99MRTuTJeGiVRJDtuWR5fcs 5pcwodFeXMkKAJJAwk9HGKKhUeNOyhJpsbCogAipHjZvvX6neFFANAiYnsDqmn6UpYCj vR3jmoqIbrYyHtCl7TPUuksHno5l+Q0+zseD/RVQISqJsw4f/VtHlflaMW/VIe/F2Ga4 0IHV+mjMUz3EssRQv2Kmo/MQLFYyInB00ku8NbgYDkkc5C2hNXPE+BreMnuf++vSUY6W CZuFpTa0xOCHvNLdJaFYI7KoIe0bVcVhJ/WcAWea3lctpZd8PioMl2Od8i2Oqn533xwf zKJw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=O18Hov2hq0TiImun7rfHlQCY39hemEomaVPrMRO5ZMo=; b=P0mHXySaH+OhX8O7+QUT+9vNh+ZgV0/AOlOpWl3pRo8Y8HxRo+mwWwylgYtzapCQ7a RKWMMAqWQpXIA89YEtoD0aWKLHP2tcQcJquPaA7drMw4hRUz4OTzIOMGrbN/2MEwykcf 1qgPR4WLlWeADKaT2xFWKlqfKXYUYxhY+kC6E7tcSsMgJNbDfNIRlL7wABISbedBiogs lmJFbrWn+wHc9N/zJk9IeiJIv3ujutW7eikSrvwL/lANDc7yMe6kdjfnxTj5lpqUemzx jLDMLDTuqpkEcbaaf2I0T0TAuuNpK4zpfZ73jp8LUFuw6RU89oCxg+bKlHUgyrfNI2Wk 4WWQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id q47si2944395qvf.4.2019.04.04.16.38.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Apr 2019 16:38:30 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 3BC3019CBCD; Thu, 4 Apr 2019 23:38:29 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 17A831001E99; Thu, 4 Apr 2019 23:38:29 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id D45E33FB16; Thu, 4 Apr 2019 23:38:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x34Nbih1011064 for ; Thu, 4 Apr 2019 19:37:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id D458660922; Thu, 4 Apr 2019 23:37:44 +0000 (UTC) Delivered-To: libvirt-list@redhat.com Received: from worklaptop.redhat.com (ovpn-124-22.rdu2.redhat.com [10.10.124.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 062B96092D; Thu, 4 Apr 2019 23:37:43 +0000 (UTC) From: Cole Robinson To: libvirt-list@redhat.com Date: Thu, 4 Apr 2019 19:37:26 -0400 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 6/7] qemu: domain: Call virDomainCapsDeviceDefValidate X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Thu, 04 Apr 2019 23:38:29 +0000 (UTC) Fill in virDomainCaps at Validate time and use it to call virDomainCapsDeviceDefValidate Signed-off-by: Cole Robinson --- src/qemu/qemu_domain.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) -- 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index f0bf1aa4fe..6da27a79b0 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -41,6 +41,7 @@ #include "viruuid.h" #include "virfile.h" #include "domain_addr.h" +#include "domain_capabilities.h" #include "domain_event.h" #include "virtime.h" #include "virnetdevopenvswitch.h" @@ -6119,14 +6120,24 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev, int ret = 0; virQEMUDriverPtr driver = opaque; virQEMUCapsPtr qemuCaps = NULL; + virDomainCapsPtr domCaps = NULL; if (!(qemuCaps = virQEMUCapsCacheLookup(driver->qemuCapsCache, def->emulator))) return -1; + if (!(domCaps = virQEMUDriverGetDomainCapabilities(driver, qemuCaps, + def->os.machine, + def->os.arch, + def->virtType))) + goto cleanup; + if ((ret = qemuDomainDeviceDefValidateAddress(dev, qemuCaps)) < 0) goto cleanup; + if (virDomainCapsDeviceDefValidate(domCaps, dev, def) < 0) + goto cleanup; + switch ((virDomainDeviceType)dev->type) { case VIR_DOMAIN_DEVICE_NET: ret = qemuDomainDeviceDefValidateNetwork(dev->data.net); @@ -6207,6 +6218,7 @@ qemuDomainDeviceDefValidate(const virDomainDeviceDef *dev, cleanup: virObjectUnref(qemuCaps); + virObjectUnref(domCaps); return ret; } From patchwork Thu Apr 4 23:37:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 161822 Delivered-To: patch@linaro.org Received: by 2002:a02:c6d8:0:0:0:0:0 with SMTP id r24csp2205495jan; Thu, 4 Apr 2019 16:39:56 -0700 (PDT) X-Google-Smtp-Source: APXvYqxKpN5m+vNDexVGpk2A6f5Fp3Trb/0xASZKy/VzSAJsy2tElLBDChRag6+BnBY93Zz683mh X-Received: by 2002:ae9:e909:: with SMTP id x9mr7680302qkf.130.1554421196410; Thu, 04 Apr 2019 16:39:56 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1554421196; cv=none; d=google.com; s=arc-20160816; b=TxUOksTQMCJjezSUxqDa5s/RPnqt6S2YXjj+qotFxjTNjPHSQKXxe8L7leTmSC40Kn gelgXQpAoZPNfARgqos7h5VxSXQSZnsJS/nWR3MgC1m4xebVRIra4XOsUyOor1amCHQF j3ecOZvtA19h7ToIx3iLMmJ0XT3Woicaza76rl3yvm3Od7kvp6tFLuv8K63Opw4WHhJL EPmsdtJQsO2IgTa8RImEq9ZxRbkwOOswLXlm1eebUJF8U7KoTK5hM1nh6FPYEmt61Ju2 ZuBrVPwKcfJIjif4G2HVJUfxABoqv2NzGnQe7jshyLNwNPY4QZXAQ28LGEQQGUM1q9l/ Sz0Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:subject :mime-version:references:in-reply-to:message-id:date:to:from :delivered-to; bh=3kc4p88gsdQs5mdOdOMeK8r2FbIOa3WUWwaC3RQFk8o=; b=ZcZ/4sbZlK4eIQC1VNRGSUbaGVMZDOEiVMq6ph4RWtYgebrOJ1LAfd1541zaNZ6ZqC PjHkHv1bzmSgoWxRGhipm8C2ZaM6rvtb0t5gqbtmrLH1q0Avx5jUEMBFMPlRBFnAmats YWEVbqyo6BqIOCbjhYXWAC7r70kNmSQZpzTtBS1z3AqYOijHDdY1bH1ueuFO6jsxWEQ4 H+P9WKCDTkte7O39JaPtUiPdhZClEDp99p3O/lZQXymEyqG4ftZs0yqFbpm9TcDN8uVG EqIWnptUcLImTF3wXOx0qZaLr+5okawdmzAXVPs2vQnp1KSYAbIpp1yY1PFk/RMpf5Jw sgjw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com. [209.132.183.28]) by mx.google.com with ESMTPS id b194si955482qkg.58.2019.04.04.16.39.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 04 Apr 2019 16:39:56 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; Authentication-Results: mx.google.com; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com 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 274DF99DD7; Thu, 4 Apr 2019 23:39:55 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0003780FE; Thu, 4 Apr 2019 23:39:54 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id B9207181AC44; Thu, 4 Apr 2019 23:39:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x34Nbk5s011070 for ; Thu, 4 Apr 2019 19:37:46 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1679460919; Thu, 4 Apr 2019 23:37:46 +0000 (UTC) Delivered-To: libvirt-list@redhat.com Received: from worklaptop.redhat.com (ovpn-124-22.rdu2.redhat.com [10.10.124.22]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3DE91608E5; Thu, 4 Apr 2019 23:37:45 +0000 (UTC) From: Cole Robinson To: libvirt-list@redhat.com Date: Thu, 4 Apr 2019 19:37:27 -0400 Message-Id: <72fe0785355cf6a844416218dfba1d6aeaaba5bb.1554419814.git.crobinso@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 7/7] qemu: Move rng model validation to domcaps X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com 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]); Thu, 04 Apr 2019 23:39:55 +0000 (UTC) The qemu driver already does some model validation, based on qemuCaps. However, the logic for exposing model values in domcaps is basically identical. This drops the qemuCaps checking and compares against the domCaps data directly. This approach makes it basically impossible to add a new model to the qemu driver without extending domcaps. The validation can also be shared with other drivers eventually. Signed-off-by: Cole Robinson --- src/conf/domain_capabilities.c | 35 +++++++++++++++++++++++++++++++--- src/conf/domain_capabilities.h | 1 + src/qemu/qemu_domain.c | 26 +------------------------ 3 files changed, 34 insertions(+), 28 deletions(-) -- 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list diff --git a/src/conf/domain_capabilities.c b/src/conf/domain_capabilities.c index aef5703df6..977f15b9ed 100644 --- a/src/conf/domain_capabilities.c +++ b/src/conf/domain_capabilities.c @@ -659,19 +659,48 @@ virDomainCapsFormat(virDomainCapsPtr const caps) } +#define ENUM_VALUE_MISSING(capsEnum, value) !(capsEnum.values & (1 << value)) + +#define ENUM_VALUE_ERROR(valueLabel, valueString) \ + do { \ + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, \ + _("domain configuration does not support '%s' value '%s'"), \ + valueLabel, valueString); \ + } while (0) + + +static int +virDomainCapsDeviceRNGDefValidate(virDomainCapsPtr const caps, + const virDomainRNGDef *dev) +{ + if (ENUM_VALUE_MISSING(caps->rng.model, dev->model)) { + ENUM_VALUE_ERROR("rng model", + virDomainRNGModelTypeToString(dev->model)); + return -1; + } + + return 0; +} + + int -virDomainCapsDeviceDefValidate(virDomainCapsPtr const caps ATTRIBUTE_UNUSED, +virDomainCapsDeviceDefValidate(virDomainCapsPtr const caps, const virDomainDeviceDef *dev, const virDomainDef *def ATTRIBUTE_UNUSED) { + int ret = 0; + switch ((virDomainDeviceType) dev->type) { + case VIR_DOMAIN_DEVICE_RNG: + ret = virDomainCapsDeviceRNGDefValidate(caps, dev->data.rng); + break; + case VIR_DOMAIN_DEVICE_DISK: case VIR_DOMAIN_DEVICE_REDIRDEV: case VIR_DOMAIN_DEVICE_NET: case VIR_DOMAIN_DEVICE_CONTROLLER: case VIR_DOMAIN_DEVICE_CHR: case VIR_DOMAIN_DEVICE_SMARTCARD: - case VIR_DOMAIN_DEVICE_RNG: case VIR_DOMAIN_DEVICE_HOSTDEV: case VIR_DOMAIN_DEVICE_VIDEO: case VIR_DOMAIN_DEVICE_MEMORY: @@ -694,5 +723,5 @@ virDomainCapsDeviceDefValidate(virDomainCapsPtr const caps ATTRIBUTE_UNUSED, break; } - return 0; + return ret; } diff --git a/src/conf/domain_capabilities.h b/src/conf/domain_capabilities.h index ffce2c2964..997c7d9444 100644 --- a/src/conf/domain_capabilities.h +++ b/src/conf/domain_capabilities.h @@ -215,6 +215,7 @@ virDomainCapsCPUModelsGet(virDomainCapsCPUModelsPtr cpuModels, __nvalues, __values); \ } while (0) + int virDomainCapsEnumSet(virDomainCapsEnumPtr capsEnum, const char *capsEnumName, size_t nvalues, diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 6da27a79b0..cad08439b1 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4523,36 +4523,12 @@ qemuDomainSmartcardDefValidate(const virDomainSmartcardDef *def) static int qemuDomainRNGDefValidate(const virDomainRNGDef *def, - virQEMUCapsPtr qemuCaps) + virQEMUCapsPtr qemuCaps ATTRIBUTE_UNUSED) { - bool modelIsSupported = false; - if (def->backend == VIR_DOMAIN_RNG_BACKEND_EGD && qemuDomainChrSourceDefValidate(def->source.chardev) < 0) return -1; - switch ((virDomainRNGModel) def->model) { - case VIR_DOMAIN_RNG_MODEL_VIRTIO: - modelIsSupported = virQEMUCapsGet(qemuCaps, - QEMU_CAPS_DEVICE_VIRTIO_RNG); - break; - case VIR_DOMAIN_RNG_MODEL_VIRTIO_TRANSITIONAL: - case VIR_DOMAIN_RNG_MODEL_VIRTIO_NON_TRANSITIONAL: - modelIsSupported = (virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVICE_VIRTIO_RNG) && - (virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_TRANSITIONAL) || - virQEMUCapsGet(qemuCaps, QEMU_CAPS_VIRTIO_PCI_DISABLE_LEGACY))); - break; - case VIR_DOMAIN_RNG_MODEL_LAST: - break; - } - - if (!modelIsSupported) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("this qemu doesn't support RNG device type '%s'"), - virDomainRNGModelTypeToString(def->model)); - return -1; - } - return 0; }