From patchwork Fri Jan 14 16:21:13 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christoph Hellwig X-Patchwork-Id: 78954 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [199.232.76.165]) by ozlabs.org (Postfix) with ESMTP id DB60BB70B3 for ; Sat, 15 Jan 2011 03:28:09 +1100 (EST) Received: from localhost ([127.0.0.1]:39477 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1PdmPo-0005KQ-BD for incoming@patchwork.ozlabs.org; Fri, 14 Jan 2011 11:22:16 -0500 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 To: qemu-devel@nongnu.org Message-ID: <20110114162113.GC19184@lst.de> References: <20110114162044.GA19114@lst.de> Mime-Version: 1.0 Content-Disposition: inline In-Reply-To: <20110114162044.GA19114@lst.de> User-Agent: Mutt/1.3.28i X-Scanned-By: MIMEDefang 2.39 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6 (newer, 2) Subject: [Qemu-devel] [PATCH 3/3] virtio-blk: tell the guest about size changes X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: qemu-devel.nongnu.org List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@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");