From nobody Sun May 5 06:45:37 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1532590087102565.5945245041505; Thu, 26 Jul 2018 00:28:07 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.phx2.redhat.com [10.5.11.25]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4767F8110B; Thu, 26 Jul 2018 07:28:05 +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 120452007832; Thu, 26 Jul 2018 07:28:05 +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 A6E0418037F0; Thu, 26 Jul 2018 07:28:04 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w6Q7S2j8030959 for ; Thu, 26 Jul 2018 03:28:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id CF7082027047; Thu, 26 Jul 2018 07:28:02 +0000 (UTC) Received: from hansolo.nay.redhat.com (wlan-69-196.nay.redhat.com [10.66.69.196]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3AA0F2026D68; Thu, 26 Jul 2018 07:28:00 +0000 (UTC) From: Han Han To: libvir-list@redhat.com Date: Thu, 26 Jul 2018 15:27:33 +0800 Message-Id: <20180726072733.1998-2-hhan@redhat.com> In-Reply-To: <20180726072733.1998-1-hhan@redhat.com> References: <20180726072733.1998-1-hhan@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Cc: Han Han Subject: [libvirt] [PATCH v2 1/1] conf: Add validation of input devices 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.25 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.28]); Thu, 26 Jul 2018 07:28:05 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" https://bugzilla.redhat.com/show_bug.cgi?id=3D1591151 Add function virDomainInputDefValidate to validate input devices. Make sure evdev attribute of source element is not used by mouse, keyboard, and tablet input device. Signed-off-by: Han Han Reviewed-by: John Ferlan --- src/conf/domain_conf.c | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 178c6d2711..a65b53b70c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5723,6 +5723,24 @@ virDomainVsockDefValidate(const virDomainVsockDef *v= sock) return 0; } =20 +static int +virDomainInputDefValidate(const virDomainInputDef *input) +{ + switch (input->type) { + case VIR_DOMAIN_INPUT_TYPE_MOUSE: + case VIR_DOMAIN_INPUT_TYPE_TABLET: + case VIR_DOMAIN_INPUT_TYPE_KBD: + if (input->source.evdev) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("setting source evdev path only supporte= d for " + "passthrough input devices")); + return -1; + } + } + + return 0; +} + =20 static int virDomainDeviceDefValidateInternal(const virDomainDeviceDef *dev, @@ -5762,9 +5780,11 @@ virDomainDeviceDefValidateInternal(const virDomainDe= viceDef *dev, case VIR_DOMAIN_DEVICE_VSOCK: return virDomainVsockDefValidate(dev->data.vsock); =20 + case VIR_DOMAIN_DEVICE_INPUT: + return virDomainInputDefValidate(dev->data.input); + case VIR_DOMAIN_DEVICE_LEASE: case VIR_DOMAIN_DEVICE_FS: - case VIR_DOMAIN_DEVICE_INPUT: case VIR_DOMAIN_DEVICE_SOUND: case VIR_DOMAIN_DEVICE_WATCHDOG: case VIR_DOMAIN_DEVICE_GRAPHICS: --=20 2.18.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list