From patchwork Thu Jul 21 17:43:14 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 651363 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [IPv6:2001:4830:134:3::11]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3rwMRZ60jxz9sxS for ; Fri, 22 Jul 2016 04:16:26 +1000 (AEST) Received: from localhost ([::1]:42705 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQIWF-00085y-Lc for incoming@patchwork.ozlabs.org; Thu, 21 Jul 2016 14:16:23 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:35385) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQI0O-00022p-Ie for qemu-devel@nongnu.org; Thu, 21 Jul 2016 13:43:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bQI0L-0008Hl-DY for qemu-devel@nongnu.org; Thu, 21 Jul 2016 13:43:28 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:47065) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQI0L-0008H4-4i for qemu-devel@nongnu.org; Thu, 21 Jul 2016 13:43:25 -0400 Received: from pps.filterd (m0098393.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u6LHdBC2103597 for ; Thu, 21 Jul 2016 13:43:24 -0400 Received: from e17.ny.us.ibm.com (e17.ny.us.ibm.com [129.33.205.207]) by mx0a-001b2d01.pphosted.com with ESMTP id 24b0b2e9ej-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 21 Jul 2016 13:43:24 -0400 Received: from localhost by e17.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 21 Jul 2016 13:43:22 -0400 Received: from d01dlp03.pok.ibm.com (9.56.250.168) by e17.ny.us.ibm.com (146.89.104.204) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 21 Jul 2016 13:43:19 -0400 X-IBM-Helo: d01dlp03.pok.ibm.com X-IBM-MailFrom: groug@kaod.org Received: from b01cxnp22035.gho.pok.ibm.com (b01cxnp22035.gho.pok.ibm.com [9.57.198.25]) by d01dlp03.pok.ibm.com (Postfix) with ESMTP id 68B0FC90042; Thu, 21 Jul 2016 13:43:08 -0400 (EDT) Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22035.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u6LHhIHv56557774; Thu, 21 Jul 2016 17:43:18 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 61A55112081; Thu, 21 Jul 2016 13:43:18 -0400 (EDT) Received: from bahia.lan (unknown [9.164.152.235]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP id C5898112073; Thu, 21 Jul 2016 13:43:16 -0400 (EDT) From: Greg Kurz To: "Michael S. Tsirkin" Date: Thu, 21 Jul 2016 19:43:14 +0200 User-Agent: StGit/0.17.1-dirty MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Content-Scanned: Fidelis XPS MAILER x-cbid: 16072117-0040-0000-0000-000000DE19CD X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16072117-0041-0000-0000-000004B85C91 Message-Id: <146912266605.14450.16219526000301775326.stgit@bahia.lan> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-07-21_08:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 spamscore=0 suspectscore=0 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1604210000 definitions=main-1607210192 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH v3] virtio-pci: error out when both legacy and modern modes are disabled 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: Cornelia Huck , qemu-devel@nongnu.org, Marcel Apfelbaum Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" From: Greg Kurz Without presuming if we got there because of a user mistake or some more subtle bug in the tooling, it really does not make sense to implement a non-functional device. Signed-off-by: Greg Kurz Signed-off-by: Greg Kurz Reviewed-by: Marcel Apfelbaum --- v3: - rebased on top of: https://lists.gnu.org/archive/html/qemu-devel/2016-07/msg04744.html - use virtio_pci_legacy/modern helpers - rephrased error message to be shorter and use the on/off logic Marcel, this still results in > 80 char line in the code but I'd rather not split it to ease grepping, nor shorten the message even more to keep it meaningful. --- hw/virtio/virtio-pci.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 755f9218b77d..1f5f00a50a0b 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1842,6 +1842,11 @@ static void virtio_pci_dc_realize(DeviceState *qdev, Error **errp) VirtIOPCIProxy *proxy = VIRTIO_PCI(qdev); PCIDevice *pci_dev = &proxy->pci_dev; + if (!(virtio_pci_modern(proxy) || virtio_pci_legacy(proxy))) { + error_setg(errp, "device cannot work when both disable-modern and disable-legacy are set to on."); + return; + } + if (!(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_PCIE) && virtio_pci_modern(proxy)) { pci_dev->cap_present |= QEMU_PCI_CAP_EXPRESS;