From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from [140.186.70.92] (port=48009 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PhLbY-00031x-1N for qemu-devel@nongnu.org; Mon, 24 Jan 2011 07:33:34 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1PhLbI-0007pR-JQ for qemu-devel@nongnu.org; Mon, 24 Jan 2011 07:32:53 -0500 Received: from verein.lst.de ([213.95.11.210]:54228) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1PhLbI-0007pM-8L for qemu-devel@nongnu.org; Mon, 24 Jan 2011 07:32:52 -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 p0OCWpE5016648 (version=TLSv1/SSLv3 cipher=EDH-RSA-DES-CBC3-SHA bits=168 verify=NO) for ; Mon, 24 Jan 2011 13:32:51 +0100 Received: (from hch@localhost) by verein.lst.de (8.12.3/8.12.3/Debian-7.2) id p0OCWpTF016647 for qemu-devel@nongnu.org; Mon, 24 Jan 2011 13:32:51 +0100 Date: Mon, 24 Jan 2011 13:32:51 +0100 From: Christoph Hellwig Message-ID: <20110124123251.GC16613@lst.de> References: <20110124123223.GA16558@lst.de> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20110124123223.GA16558@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-20 10:32:50.455032625 +0100 +++ qemu/hw/virtio-blk.c 2011-01-24 11:56:42.833004269 +0100 @@ -504,6 +504,15 @@ static int virtio_blk_load(QEMUFile *f, return 0; } +static void virtio_blk_change_cb(void *opaque, int reason) +{ + VirtIOBlock *s = opaque; + + if (reason & CHANGE_SIZE) { + virtio_notify_config(&s->vdev); + } +} + VirtIODevice *virtio_blk_init(DeviceState *dev, BlockConf *conf) { VirtIOBlock *s; @@ -546,6 +555,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");