From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=54591 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PdmOz-0005Hd-DF for qemu-devel@nongnu.org; Fri, 14 Jan 2011 11:21:26 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PdmOp-00047c-5G for qemu-devel@nongnu.org; Fri, 14 Jan 2011 11:21:19 -0500 Received: from verein.lst.de ([213.95.11.210]:37079) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PdmOo-00047V-ON for qemu-devel@nongnu.org; Fri, 14 Jan 2011 11:21:15 -0500 Received: from verein.lst.de (localhost [127.0.0.1]) by verein.lst.de (8.12.3/8.12.3/Debian-7.1) with ESMTP id p0EGLDE5019217 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Fri, 14 Jan 2011 17:21:14 +0100 Received: (from hch@localhost) by verein.lst.de (8.12.3/8.12.3/Debian-7.2) id p0EGLDpu019216 for qemu-devel@nongnu.org; Fri, 14 Jan 2011 17:21:13 +0100 Date: Fri, 14 Jan 2011 17:21:13 +0100 From: Christoph Hellwig Message-ID: <20110114162113.GC19184@lst.de> References: <20110114162044.GA19114@lst.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20110114162044.GA19114@lst.de> Subject: [Qemu-devel] [PATCH 3/3] virtio-blk: tell the guest about size changes List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Raise a config change interrupt when the size changed. This allows virtio-blk guest drivers to read-read the information from the config space once it got the config chaged interrupt. Signed-off-by: Christoph Hellwig Index: qemu/hw/virtio-blk.c =================================================================== --- qemu.orig/hw/virtio-blk.c 2011-01-14 17:00:07.468262896 +0100 +++ qemu/hw/virtio-blk.c 2011-01-14 17:07:06.897257239 +0100 @@ -504,6 +504,16 @@ static int virtio_blk_load(QEMUFile *f, return 0; } +static void virtio_blk_change_cb(void *opaque) +{ + VirtIOBlock *s = opaque; + + if (s->bs->size_changed) { + virtio_notify_config(&s->vdev); + s->bs->size_changed = 0; + } +} + VirtIODevice *virtio_blk_init(DeviceState *dev, BlockConf *conf) { VirtIOBlock *s; @@ -546,6 +556,7 @@ VirtIODevice *virtio_blk_init(DeviceStat register_savevm(dev, "virtio-blk", virtio_blk_id++, 2, virtio_blk_save, virtio_blk_load, s); bdrv_set_removable(s->bs, 0); + bdrv_set_change_cb(s->bs, virtio_blk_change_cb, s); s->bs->buffer_alignment = conf->logical_block_size; add_boot_device_path(conf->bootindex, dev, "/disk@0,0");