From patchwork Thu Oct 6 11:36:44 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gonglei (Arei)" X-Patchwork-Id: 9364599 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 39EDB6077E for ; Thu, 6 Oct 2016 11:39:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 29EA422AFC for ; Thu, 6 Oct 2016 11:39:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1E7AD28F4D; Thu, 6 Oct 2016 11:39:11 +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 7025A22AFC for ; Thu, 6 Oct 2016 11:39:10 +0000 (UTC) Received: from localhost ([::1]:54964 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bs713-0007in-Fn for patchwork-qemu-devel@patchwork.kernel.org; Thu, 06 Oct 2016 07:39:09 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:41021) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bs70O-0007dV-UJ for qemu-devel@nongnu.org; Thu, 06 Oct 2016 07:38:32 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bs70N-0000ts-IH for qemu-devel@nongnu.org; Thu, 06 Oct 2016 07:38:28 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:20891) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bs70M-0000tC-Sp for qemu-devel@nongnu.org; Thu, 06 Oct 2016 07:38:27 -0400 Received: from 172.24.1.36 (EHLO szxeml426-hub.china.huawei.com) ([172.24.1.36]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DOF93367; Thu, 06 Oct 2016 19:37:43 +0800 (CST) Received: from localhost (10.177.18.62) by szxeml426-hub.china.huawei.com (10.82.67.181) with Microsoft SMTP Server id 14.3.235.1; Thu, 6 Oct 2016 19:37:34 +0800 From: Gonglei To: , Date: Thu, 6 Oct 2016 19:36:44 +0800 Message-ID: <1475753807-37624-12-git-send-email-arei.gonglei@huawei.com> X-Mailer: git-send-email 2.6.3.windows.1 In-Reply-To: <1475753807-37624-1-git-send-email-arei.gonglei@huawei.com> References: <1475753807-37624-1-git-send-email-arei.gonglei@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.18.62] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] X-Received-From: 119.145.14.65 Subject: [Qemu-devel] [PATCH v5 11/14] virtio-crypto: emulate virtio crypto as a legacy device by default 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: weidong.huang@huawei.com, claudio.fontana@huawei.com, mst@redhat.com, xin.zeng@intel.com, hanweidong@huawei.com, luonengjun@huawei.com, agraf@suse.de, nmorey@kalray.eu, mike.caraman@nxp.com, Gonglei , stefanha@redhat.com, jianjay.zhou@huawei.com, pbonzini@redhat.com, peter.huangpeng@huawei.com, vincent.jardin@6wind.com, wu.wubin@huawei.com, arei.gonglei@hotmail.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP the scenario of virtio crypto device is mostly NFV, which require the existing Guest can't need to do any changes to support virtio crypto, so that they can easily migrate the existing network units to VM. That's also a basic requirement came from our customers in production environment. For virtio crypto driver, we can both support virtio-1.0 or earlier. But Virtio pci driver module can't discovery the virtio-1.0 devices in most existing Guests. If we want do this, we have to require the customers change the virtio pci module for existing guests influence all virtio devices, which is impossible. So, let's emulate the virtio crypto device as a legacy virtio device by default. Using 0x1014 as virtio crypto pci device ID because virtio crypto ID is 20 (0x14). Signed-off-by: Gonglei --- docs/specs/pci-ids.txt | 2 ++ hw/virtio/virtio-crypto-pci.c | 4 +++- include/hw/pci/pci.h | 2 ++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/docs/specs/pci-ids.txt b/docs/specs/pci-ids.txt index fd27c67..662d4f8 100644 --- a/docs/specs/pci-ids.txt +++ b/docs/specs/pci-ids.txt @@ -22,6 +22,7 @@ maintained as part of the virtio specification. 1af4:1004 SCSI host bus adapter device (legacy) 1af4:1005 entropy generator device (legacy) 1af4:1009 9p filesystem device (legacy) +1af4:1014 crypto device (legacy) 1af4:1041 network device (modern) 1af4:1042 block device (modern) @@ -32,6 +33,7 @@ maintained as part of the virtio specification. 1af4:1049 9p filesystem device (modern) 1af4:1050 virtio gpu device (modern) 1af4:1052 virtio input device (modern) +1af4:1054 crypto device (modern) 1af4:10f0 Available for experimental usage without registration. Must get to official ID when the code leaves the test lab (i.e. when seeking diff --git a/hw/virtio/virtio-crypto-pci.c b/hw/virtio/virtio-crypto-pci.c index 21d9984..30c10f0 100644 --- a/hw/virtio/virtio-crypto-pci.c +++ b/hw/virtio/virtio-crypto-pci.c @@ -32,7 +32,6 @@ static void virtio_crypto_pci_realize(VirtIOPCIProxy *vpci_dev, Error **errp) DeviceState *vdev = DEVICE(&vcrypto->vdev); qdev_set_parent_bus(vdev, BUS(&vpci_dev->bus)); - virtio_pci_force_virtio_1(vpci_dev); object_property_set_bool(OBJECT(vdev), true, "realized", errp); object_property_set_link(OBJECT(vcrypto), OBJECT(vcrypto->vdev.conf.cryptodev), "cryptodev", @@ -49,6 +48,9 @@ static void virtio_crypto_pci_class_init(ObjectClass *klass, void *data) set_bit(DEVICE_CATEGORY_MISC, dc->categories); dc->props = virtio_crypto_pci_properties; + pcidev_k->vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET; + pcidev_k->device_id = PCI_DEVICE_ID_VIRTIO_CRYPTO; + pcidev_k->revision = 0; pcidev_k->class_id = PCI_CLASS_OTHERS; } diff --git a/include/hw/pci/pci.h b/include/hw/pci/pci.h index 772692f..5881101 100644 --- a/include/hw/pci/pci.h +++ b/include/hw/pci/pci.h @@ -83,6 +83,8 @@ #define PCI_DEVICE_ID_VIRTIO_RNG 0x1005 #define PCI_DEVICE_ID_VIRTIO_9P 0x1009 #define PCI_DEVICE_ID_VIRTIO_VSOCK 0x1012 +#define PCI_DEVICE_ID_VIRTIO_CRYPTO 0x1014 + #define PCI_VENDOR_ID_REDHAT 0x1b36 #define PCI_DEVICE_ID_REDHAT_BRIDGE 0x0001