From patchwork Wed Sep 28 08:25:50 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gonglei (Arei)" X-Patchwork-Id: 9353247 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 F0F996077B for ; Wed, 28 Sep 2016 08:34:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DF83A2944B for ; Wed, 28 Sep 2016 08:34:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D2C502944E; Wed, 28 Sep 2016 08:34:15 +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 10B592944B for ; Wed, 28 Sep 2016 08:34:14 +0000 (UTC) Received: from localhost ([::1]:56779 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpAJh-0006WQ-Tq for patchwork-qemu-devel@patchwork.kernel.org; Wed, 28 Sep 2016 04:34:14 -0400 Received: from eggs.gnu.org ([2001:4830:134:3::10]:36792) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpAD9-0000Yh-Ce for qemu-devel@nongnu.org; Wed, 28 Sep 2016 04:27:29 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1bpAD6-0004sR-4r for qemu-devel@nongnu.org; Wed, 28 Sep 2016 04:27:27 -0400 Received: from szxga02-in.huawei.com ([119.145.14.65]:35855) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1bpAD5-0004r6-F0 for qemu-devel@nongnu.org; Wed, 28 Sep 2016 04:27:24 -0400 Received: from 172.24.1.60 (EHLO szxeml425-hub.china.huawei.com) ([172.24.1.60]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DNU26275; Wed, 28 Sep 2016 16:26:16 +0800 (CST) Received: from localhost (10.177.18.62) by szxeml425-hub.china.huawei.com (10.82.67.180) with Microsoft SMTP Server id 14.3.235.1; Wed, 28 Sep 2016 16:26:08 +0800 From: Gonglei To: , Date: Wed, 28 Sep 2016 16:25:50 +0800 Message-ID: <1475051152-400276-12-git-send-email-arei.gonglei@huawei.com> X-Mailer: git-send-email 2.6.3.windows.1 In-Reply-To: <1475051152-400276-1-git-send-email-arei.gonglei@huawei.com> References: <1475051152-400276-1-git-send-email-arei.gonglei@huawei.com> MIME-Version: 1.0 X-Originating-IP: [10.177.18.62] X-CFilter-Loop: Reflected X-Mirapoint-Virus-RAPID-Raw: score=unknown(0), refid=str=0001.0A020204.57EB7EA9.014E, ss=1, re=0.000, recu=0.000, reip=0.000, cl=1, cld=1, fgs=0, ip=0.0.0.0, so=2013-06-18 04:22:30, dmn=2013-03-21 17:37:32 X-Mirapoint-Loop-Id: 218731d08dac41e12dc42e132b68c404 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 v4 11/13] 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 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