From patchwork Fri May 13 02:40:08 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asias He X-Patchwork-Id: 781632 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.3) with ESMTP id p4D2fkAb016996 for ; Fri, 13 May 2011 02:41:47 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751261Ab1EMClo (ORCPT ); Thu, 12 May 2011 22:41:44 -0400 Received: from mail-pv0-f174.google.com ([74.125.83.174]:41044 "EHLO mail-pv0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751026Ab1EMCln (ORCPT ); Thu, 12 May 2011 22:41:43 -0400 Received: by pvg12 with SMTP id 12so968636pvg.19 for ; Thu, 12 May 2011 19:41:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:from:to:cc:subject:date:message-id:x-mailer; bh=uvbph01/p8YRGmY3g5z5LvxFoN6KJSJxoxx6apW22us=; b=NgyfyX1x3cLRfHQWL2G2UCLFP8/44ib0Krf0omqamqNHscSSxZlySiTQ+ci3Nsb+k+ pcj9fI2MhrwxPDNkCM0pcxeQvz6rEBYmmFn+T4pxvCrZQ8X1wud9bPGkW2H/m+0f71OM GFtk+xDZbDosZDBAwHtn6vahUrNd/YWQAuliQ= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=nerGJDB6qWto8S2I9rJY04lfBFXF2KWsHSM41Jvi+qV93Q60adcyaBiTsHOrEYU0X3 XFKWh3cA3zphRu3QQhtGOI7il/DFT4hJT1l+XW8LlJmt8zvCbugef4d1LIzr57LrAS3s mvaJkxWoY/jO3f2UnCfoGmLZistMeP7ru9d6o= Received: by 10.68.69.114 with SMTP id d18mr1417181pbu.275.1305254502543; Thu, 12 May 2011 19:41:42 -0700 (PDT) Received: from localhost.localdomain ([219.224.169.130]) by mx.google.com with ESMTPS id y5sm1034417pbb.99.2011.05.12.19.41.36 (version=TLSv1/SSLv3 cipher=OTHER); Thu, 12 May 2011 19:41:41 -0700 (PDT) From: Asias He To: Pekka Enberg Cc: Cyrill Gorcunov , Ingo Molnar , Sasha Levin , Prasad Joshi , kvm@vger.kernel.org, Asias He Subject: [PATCH 1/2] kvm tools: Bring VIRTIO_BLK_F_SEG_MAX feature back to virtio blk Date: Fri, 13 May 2011 10:40:08 +0800 Message-Id: <1305254409-9079-1-git-send-email-asias.hejun@gmail.com> X-Mailer: git-send-email 1.7.5.1 Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Fri, 13 May 2011 02:41:47 +0000 (UTC) commit b764422bb0b46b00b896f6d4538ac3d3dde9e56b (kvm tools: Add support for multiple virtio-blk) removed the VIRTIO_BLK_F_SEG_MAX publishment to guest. There is no reason we should not support it. Just bring it back. Signed-off-by: Asias He --- tools/kvm/virtio/blk.c | 19 +++++++++++++++---- 1 files changed, 15 insertions(+), 4 deletions(-) diff --git a/tools/kvm/virtio/blk.c b/tools/kvm/virtio/blk.c index 5085f1b..8740bc4 100644 --- a/tools/kvm/virtio/blk.c +++ b/tools/kvm/virtio/blk.c @@ -21,6 +21,10 @@ #define NUM_VIRT_QUEUES 1 #define VIRTIO_BLK_QUEUE_SIZE 128 +/* + * the header and status consume too entries + */ +#define DISK_SEG_MAX (VIRTIO_BLK_QUEUE_SIZE - 2) struct blk_dev_job { struct virt_queue *vq; @@ -278,11 +282,12 @@ void virtio_blk__init(struct kvm *kvm, struct disk_image *disk) blk_dev_base_addr = IOPORT_VIRTIO_BLK + new_dev_idx * IOPORT_VIRTIO_BLK_SIZE; *bdev = (struct blk_dev) { - .mutex = PTHREAD_MUTEX_INITIALIZER, - .disk = disk, - .idx = new_dev_idx, - .blk_config = (struct virtio_blk_config) { + .mutex = PTHREAD_MUTEX_INITIALIZER, + .disk = disk, + .idx = new_dev_idx, + .blk_config = (struct virtio_blk_config) { .capacity = disk->size / SECTOR_SIZE, + .seg_max = DISK_SEG_MAX, }, .pci_hdr = (struct pci_device_header) { .vendor_id = PCI_VENDOR_ID_REDHAT_QUMRANET, @@ -294,6 +299,12 @@ void virtio_blk__init(struct kvm *kvm, struct disk_image *disk) .subsys_id = PCI_SUBSYSTEM_ID_VIRTIO_BLK, .bar[0] = blk_dev_base_addr | PCI_BASE_ADDRESS_SPACE_IO, }, + /* + * Note we don't set VIRTIO_BLK_F_GEOMETRY here so the + * guest kernel will compute disk geometry by own, the + * same applies to VIRTIO_BLK_F_BLK_SIZE + */ + .host_features = (1UL << VIRTIO_BLK_F_SEG_MAX), }; if (irq__register_device(PCI_DEVICE_ID_VIRTIO_BLK, &dev, &pin, &line) < 0)