From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:33046) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qm4OO-0006OL-Fz for qemu-devel@nongnu.org; Wed, 27 Jul 2011 09:43:21 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qm4ON-0004GS-IV for qemu-devel@nongnu.org; Wed, 27 Jul 2011 09:43:20 -0400 Received: from isrv.corpit.ru ([86.62.121.231]:35314) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qm4ON-0004Ec-CQ for qemu-devel@nongnu.org; Wed, 27 Jul 2011 09:43:19 -0400 Message-ID: <4E3015EC.7070004@msgid.tls.msk.ru> Date: Wed, 27 Jul 2011 17:43:08 +0400 From: Michael Tokarev MIME-Version: 1.0 References: <20110727113000.25109.16204.sendpatchset@skannery> <20110727113045.25109.54866.sendpatchset@skannery> In-Reply-To: <20110727113045.25109.54866.sendpatchset@skannery> Content-Type: text/plain; charset=KOI8-R Content-Transfer-Encoding: 7bit Subject: Re: [Qemu-devel] [V5 Patch 3/4]Qemu: Command "block_set" for dynamic block params change List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Supriya Kannery Cc: Kevin Wolf , Stefan Hajnoczi , qemu-devel@nongnu.org, Christoph Hellwig 27.07.2011 15:30, Supriya Kannery wrote: > New command "block_set" added for dynamically changing any of the block > device parameters. For now, dynamic setting of hostcache params using this > command is implemented. Other block device parameter changes, can be > integrated in similar lines. > > Signed-off-by: Supriya Kannery > > --- > block.c | 54 +++++++++++++++++++++++++++++++++++++++++++++++++ > block.h | 2 + > blockdev.c | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++ > blockdev.h | 1 > hmp-commands.hx | 14 ++++++++++++ > qemu-config.c | 13 +++++++++++ > qemu-option.c | 25 ++++++++++++++++++++++ > qemu-option.h | 2 + > qmp-commands.hx | 28 +++++++++++++++++++++++++ > 9 files changed, 200 insertions(+) > > Index: qemu/block.c > =================================================================== > --- qemu.orig/block.c > +++ qemu/block.c > @@ -651,6 +651,34 @@ unlink_and_fail: > return ret; > } > > +int bdrv_reopen(BlockDriverState *bs, int bdrv_flags) > +{ > + BlockDriver *drv = bs->drv; > + int ret = 0, open_flags; > + > + /* Quiesce IO for the given block device */ > + qemu_aio_flush(); > + if (bdrv_flush(bs)) { > + qerror_report(QERR_DATA_SYNC_FAILED, bs->device_name); > + return ret; > + } > + open_flags = bs->open_flags; > + bdrv_close(bs); > + > + ret = bdrv_open(bs, bs->filename, bdrv_flags, drv); > + if (ret < 0) { > + /* Reopen failed. Try to open with original flags */ > + qerror_report(QERR_REOPEN_FILE_FAILED, bs->filename); > + ret = bdrv_open(bs, bs->filename, open_flags, drv); > + if (ret < 0) { > + /* Reopen failed with orig and modified flags */ > + abort(); > + } Can we please avoid this stuff completely? Just keep the old device open still, until you're sure new one is ok. Or else it will be quite dangerous command in many cases. For example, after -runas/-chroot, or additional selinux settings or whatnot. And in this case, instead of merely returning an error, we'll see abort(). Boom. Thanks, /mjt