From patchwork Fri Apr 8 16:10:03 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Asias He X-Patchwork-Id: 695161 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id p38GBin4005128 for ; Fri, 8 Apr 2011 16:11:44 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752681Ab1DHQLk (ORCPT ); Fri, 8 Apr 2011 12:11:40 -0400 Received: from mail-pv0-f174.google.com ([74.125.83.174]:55883 "EHLO mail-pv0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752656Ab1DHQLk (ORCPT ); Fri, 8 Apr 2011 12:11:40 -0400 Received: by pvg12 with SMTP id 12so1285585pvg.19 for ; Fri, 08 Apr 2011 09:11:39 -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=cXmKmfAmDLiNcuRlSDLS/YBw7PF5K03vMX847GcQxI8=; b=ZI/dte9gVWkjIQ/2sXq83u+Ch37prsKeou7EJ77yxV1YdBJ265m/MvgXtAor+38r/l VYl/Q1l2sdXoPbBu1ReC+vr7qHyaEG/HDGrjEVA0T4dYpVoA0Dn1J5G8JnFEjSs4R1jx pRcfiXemDqLCQeEsCny/+fppOPbm6X7D7E0ZE= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:to:cc:subject:date:message-id:x-mailer; b=jW5kywE29hd6PVZBHjEfK/l+vq1l6G1PlkltD++V+C8PriXDpNCQ7SZEKwJdO/1uAW EDNCLnSNuZOftZbsyYilb1Xh0neQINJGoQ8KRTHF6S1FFp+Q5EBlLwmBs9ImD6y7libQ iqKKK980CFTO4ckPKRo5LwX48yAl069CUNzao= Received: by 10.142.224.11 with SMTP id w11mr1979659wfg.136.1302279099520; Fri, 08 Apr 2011 09:11:39 -0700 (PDT) Received: from localhost.localdomain ([219.224.169.130]) by mx.google.com with ESMTPS id s39sm3812390wfc.16.2011.04.08.09.11.35 (version=TLSv1/SSLv3 cipher=OTHER); Fri, 08 Apr 2011 09:11:38 -0700 (PDT) From: Asias He To: Pekka Enberg , Cyrill Gorcunov , Ingo Molnar Cc: kvm@vger.kernel.org, Asias He Subject: [PATCH 1/5] kvm tools: change struct device to struct blk_device for block device Date: Sat, 9 Apr 2011 00:10:03 +0800 Message-Id: <1302279007-15710-1-git-send-email-asias.hejun@gmail.com> X-Mailer: git-send-email 1.7.4.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 (demeter1.kernel.org [140.211.167.41]); Fri, 08 Apr 2011 16:11:44 +0000 (UTC) Signed-off-by: Asias He --- tools/kvm/blk-virtio.c | 28 ++++++++++++++-------------- 1 files changed, 14 insertions(+), 14 deletions(-) diff --git a/tools/kvm/blk-virtio.c b/tools/kvm/blk-virtio.c index 9a723cc..e94d7b3 100644 --- a/tools/kvm/blk-virtio.c +++ b/tools/kvm/blk-virtio.c @@ -20,7 +20,7 @@ #define VIRTIO_BLK_QUEUE_SIZE 128 -struct device { +struct blk_device { struct virtio_blk_config blk_config; uint32_t host_features; uint32_t guest_features; @@ -35,7 +35,7 @@ struct device { #define DISK_SEG_MAX 126 -static struct device device = { +static struct blk_device blk_device = { .blk_config = (struct virtio_blk_config) { /* VIRTIO_BLK_F_SEG_MAX */ .seg_max = DISK_SEG_MAX, @@ -50,7 +50,7 @@ static struct device device = { static bool virtio_blk_config_in(void *data, unsigned long offset, int size, uint32_t count) { - uint8_t *config_space = (uint8_t *) &device.blk_config; + uint8_t *config_space = (uint8_t *) &blk_device.blk_config; if (size != 1 || count != 1) return false; @@ -68,12 +68,12 @@ static bool blk_virtio_in(struct kvm *self, uint16_t port, void *data, int size, switch (offset) { case VIRTIO_PCI_HOST_FEATURES: - ioport__write32(data, device.host_features); + ioport__write32(data, blk_device.host_features); break; case VIRTIO_PCI_GUEST_FEATURES: return false; case VIRTIO_PCI_QUEUE_PFN: - ioport__write32(data, device.virt_queues[device.queue_selector].pfn); + ioport__write32(data, blk_device.virt_queues[blk_device.queue_selector].pfn); break; case VIRTIO_PCI_QUEUE_NUM: ioport__write16(data, VIRTIO_BLK_QUEUE_SIZE); @@ -82,14 +82,14 @@ static bool blk_virtio_in(struct kvm *self, uint16_t port, void *data, int size, case VIRTIO_PCI_QUEUE_NOTIFY: return false; case VIRTIO_PCI_STATUS: - ioport__write8(data, device.status); + ioport__write8(data, blk_device.status); break; case VIRTIO_PCI_ISR: ioport__write8(data, 0x1); kvm__irq_line(self, VIRTIO_BLK_IRQ, 0); break; case VIRTIO_MSI_CONFIG_VECTOR: - ioport__write16(data, device.config_vector); + ioport__write16(data, blk_device.config_vector); break; default: return virtio_blk_config_in(data, offset, size, count); @@ -205,13 +205,13 @@ static bool blk_virtio_out(struct kvm *self, uint16_t port, void *data, int size switch (offset) { case VIRTIO_PCI_GUEST_FEATURES: - device.guest_features = ioport__read32(data); + blk_device.guest_features = ioport__read32(data); break; case VIRTIO_PCI_QUEUE_PFN: { struct virt_queue *queue; void *p; - queue = &device.virt_queues[device.queue_selector]; + queue = &blk_device.virt_queues[blk_device.queue_selector]; queue->pfn = ioport__read32(data); @@ -222,7 +222,7 @@ static bool blk_virtio_out(struct kvm *self, uint16_t port, void *data, int size break; } case VIRTIO_PCI_QUEUE_SEL: - device.queue_selector = ioport__read16(data); + blk_device.queue_selector = ioport__read16(data); break; case VIRTIO_PCI_QUEUE_NOTIFY: { struct virt_queue *queue; @@ -230,7 +230,7 @@ static bool blk_virtio_out(struct kvm *self, uint16_t port, void *data, int size queue_index = ioport__read16(data); - queue = &device.virt_queues[queue_index]; + queue = &blk_device.virt_queues[queue_index]; while (queue->vring.avail->idx != queue->last_avail_idx) { if (!blk_virtio_request(self, queue)) @@ -241,10 +241,10 @@ static bool blk_virtio_out(struct kvm *self, uint16_t port, void *data, int size break; } case VIRTIO_PCI_STATUS: - device.status = ioport__read8(data); + blk_device.status = ioport__read8(data); break; case VIRTIO_MSI_CONFIG_VECTOR: - device.config_vector = VIRTIO_MSI_NO_VECTOR; + blk_device.config_vector = VIRTIO_MSI_NO_VECTOR; break; case VIRTIO_MSI_QUEUE_VECTOR: break; @@ -285,7 +285,7 @@ void blk_virtio__init(struct kvm *self) if (!self->disk_image) return; - device.blk_config.capacity = self->disk_image->size / SECTOR_SIZE; + blk_device.blk_config.capacity = self->disk_image->size / SECTOR_SIZE; pci__register(&blk_virtio_pci_device, PCI_VIRTIO_BLK_DEVNUM);