From patchwork Thu Jul 21 21:21:16 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Greg Kurz X-Patchwork-Id: 9242549 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B18F1602F0 for ; Thu, 21 Jul 2016 21:21:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9FD5B27F88 for ; Thu, 21 Jul 2016 21:21:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 947D827F93; Thu, 21 Jul 2016 21:21:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 0B64D27F88 for ; Thu, 21 Jul 2016 21:21:47 +0000 (UTC) Received: from localhost ([::1]:43773 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQLPd-0002YR-Rh for patchwork-qemu-devel@patchwork.kernel.org; Thu, 21 Jul 2016 17:21:45 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:59449) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQLPP-0002YJ-29 for qemu-devel@nongnu.org; Thu, 21 Jul 2016 17:21:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bQLPJ-0007A6-PE for qemu-devel@nongnu.org; Thu, 21 Jul 2016 17:21:29 -0400 Received: from mx0a-001b2d01.pphosted.com ([148.163.156.1]:19920) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bQLPJ-00078y-GR for qemu-devel@nongnu.org; Thu, 21 Jul 2016 17:21:25 -0400 Received: from pps.filterd (m0098404.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id u6LLJQWS017194 for ; Thu, 21 Jul 2016 17:21:24 -0400 Received: from e34.co.us.ibm.com (e34.co.us.ibm.com [32.97.110.152]) by mx0a-001b2d01.pphosted.com with ESMTP id 24a8f0xv7n-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 21 Jul 2016 17:21:23 -0400 Received: from localhost by e34.co.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 21 Jul 2016 15:21:23 -0600 Received: from d03dlp03.boulder.ibm.com (9.17.202.179) by e34.co.us.ibm.com (192.168.1.134) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 21 Jul 2016 15:21:21 -0600 X-IBM-Helo: d03dlp03.boulder.ibm.com X-IBM-MailFrom: groug@kaod.org Received: from b01cxnp22034.gho.pok.ibm.com (b01cxnp22034.gho.pok.ibm.com [9.57.198.24]) by d03dlp03.boulder.ibm.com (Postfix) with ESMTP id 356C019D804A; Thu, 21 Jul 2016 15:20:56 -0600 (MDT) Received: from b01ledav001.gho.pok.ibm.com (b01ledav001.gho.pok.ibm.com [9.57.199.106]) by b01cxnp22034.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id u6LLLKCh64749728; Thu, 21 Jul 2016 21:21:20 GMT Received: from b01ledav001.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 28D9A2803A; Thu, 21 Jul 2016 17:21:20 -0400 (EDT) Received: from bahia.lan (unknown [9.164.152.235]) by b01ledav001.gho.pok.ibm.com (Postfix) with ESMTP id 9112D2803E; Thu, 21 Jul 2016 17:21:18 -0400 (EDT) From: Greg Kurz To: "Michael S. Tsirkin" Date: Thu, 21 Jul 2016 23:21:16 +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: 16072121-0016-0000-0000-0000043C9323 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 16072121-0017-0000-0000-00003154BB9C Message-Id: <146913602256.26732.547184422534259409.stgit@bahia.lan> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-07-21_11:, , 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-1607210229 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x [generic] X-Received-From: 148.163.156.1 Subject: [Qemu-devel] [PATCH v4] 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+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP 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 Reviewed-by: Marcel Apfelbaum Signed-off-by: Greg Kurz Reviewed-by: Cornelia Huck --- v4: - rephrased error message and provide a hint to the user - split string literals to stay below 80 characters - added Marcel's R-b tag --- hw/virtio/virtio-pci.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hw/virtio/virtio-pci.c b/hw/virtio/virtio-pci.c index 755f9218b77d..72c4b392ffda 100644 --- a/hw/virtio/virtio-pci.c +++ b/hw/virtio/virtio-pci.c @@ -1842,6 +1842,14 @@ 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 modern and legacy modes" + " are disabled"); + error_append_hint(errp, "Set either disable-modern or disable-legacy" + " to off\n"); + return; + } + if (!(proxy->flags & VIRTIO_PCI_FLAG_DISABLE_PCIE) && virtio_pci_modern(proxy)) { pci_dev->cap_present |= QEMU_PCI_CAP_EXPRESS;