From mboxrd@z Thu Jan 1 00:00:00 1970 From: Ingo Molnar Subject: Re: [PATCH 2/3 V2] kvm tools: Add support for multiple virtio-blk Date: Wed, 4 May 2011 15:56:16 +0200 Message-ID: <20110504135616.GA11941@elte.hu> References: <1304516717-24512-1-git-send-email-levinsasha928@gmail.com> <1304516717-24512-3-git-send-email-levinsasha928@gmail.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Cc: penberg@kernel.org, kvm@vger.kernel.org, asias.hejun@gmail.com, gorcunov@gmail.com, prasadjoshi124@gmail.com To: Sasha Levin Return-path: Received: from mx2.mail.elte.hu ([157.181.151.9]:59692 "EHLO mx2.mail.elte.hu" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753009Ab1EDN40 (ORCPT ); Wed, 4 May 2011 09:56:26 -0400 Content-Disposition: inline In-Reply-To: <1304516717-24512-3-git-send-email-levinsasha928@gmail.com> Sender: kvm-owner@vger.kernel.org List-ID: * Sasha Levin wrote: > Add support for multiple blk_devices by un-globalizing > the current blk_device and allow multiple blk_devices. Very nice! One nit: > + mpc_intsrc = last_addr; > + mpc_intsrc->type = MP_INTSRC; > + mpc_intsrc->irqtype = mp_INT; > + mpc_intsrc->irqflag = MP_IRQDIR_DEFAULT; > + mpc_intsrc->srcbus = pcibusid; > + mpc_intsrc->srcbusirq = 1; /* virtio block irq pin */ > + mpc_intsrc->dstapic = ioapicid; > + mpc_intsrc->dstirq = 10; /* VIRTIO_BLK_IRQ */ > + > + last_addr = (void *)&mpc_intsrc[1]; > + nentries++; > + > + mpc_intsrc = last_addr; > + mpc_intsrc->type = MP_INTSRC; > + mpc_intsrc->irqtype = mp_INT; > + mpc_intsrc->irqflag = MP_IRQDIR_DEFAULT; > + mpc_intsrc->srcbus = pcibusid; > + mpc_intsrc->srcbusirq = 1; /* virtio block irq pin */ > + mpc_intsrc->dstapic = ioapicid; > + mpc_intsrc->dstirq = 11; /* VIRTIO_BLK_IRQ */ > + > + last_addr = (void *)&mpc_intsrc[1]; > + nentries++; > + > + mpc_intsrc = last_addr; > + mpc_intsrc->type = MP_INTSRC; > + mpc_intsrc->irqtype = mp_INT; > + mpc_intsrc->irqflag = MP_IRQDIR_DEFAULT; > + mpc_intsrc->srcbus = pcibusid; > + mpc_intsrc->srcbusirq = 1; /* virtio block irq pin */ > + mpc_intsrc->dstapic = ioapicid; > + mpc_intsrc->dstirq = 12; /* VIRTIO_BLK_IRQ */ There should really be a helper function for these initializations - and a loop that creates VIRTIO_BLK_MAX_DEV of them, right? Also, the IRQs used by kvm should be enumerated in an include file in a single place, with ranges allocated for specific purposes, otherwise we'll quickly lose track of them. And a pet peeve of mine: > +struct blk_device_job { > + struct virt_queue *vq; > + struct blk_device *blk_device; > + void *job_id; > +}; > + > struct blk_device { > pthread_mutex_t mutex; > > struct virtio_blk_config blk_config; > - struct disk_image *disk; > + struct disk_image *disk; > uint32_t host_features; > uint32_t guest_features; > uint16_t config_vector; > uint8_t status; > + u8 idx; The vertical spacing of those two structures (blk_device_job and blk_device) is inconsistent. > static bool virtio_blk_pci_io_in(struct kvm *self, uint16_t port, void *data, int size, uint32_t count) > { > - unsigned long offset; > + u16 offset, dev_idx; > bool ret = true; > + struct blk_device *blk_device; Suggestion: please standardize on shorter but still obvious variable names. For blk_device a good one could be 'bdev'. Given how frequently it's used you might even abbreviate 'struct blk_device' to 'struct blk_dev' - even in that shortr form it's still very obvious what it means. The new, standardized and streamlined naming convention should be propagated to all 'struct blk_device' using functions. (in separate patches) Thanks, Ingo