From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:36354) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QpE9t-0006zW-JL for qemu-devel@nongnu.org; Fri, 05 Aug 2011 02:45:26 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QpE9s-0002PS-9O for qemu-devel@nongnu.org; Fri, 05 Aug 2011 02:45:25 -0400 Received: from e34.co.us.ibm.com ([32.97.110.152]:53590) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QpE9s-0002PO-3r for qemu-devel@nongnu.org; Fri, 05 Aug 2011 02:45:24 -0400 Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by e34.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id p756jNnM016438 for ; Fri, 5 Aug 2011 00:45:23 -0600 Received: from d03av04.boulder.ibm.com (d03av04.boulder.ibm.com [9.17.195.170]) by d03relay04.boulder.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p756jNiq133948 for ; Fri, 5 Aug 2011 00:45:23 -0600 Received: from d03av04.boulder.ibm.com (loopback [127.0.0.1]) by d03av04.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p750jLEq028357 for ; Thu, 4 Aug 2011 18:45:22 -0600 From: Supriya Kannery Date: Fri, 05 Aug 2011 12:27:04 +0530 Message-Id: <20110805065704.5829.84280.sendpatchset@skannery> In-Reply-To: <20110805065603.5829.56173.sendpatchset@skannery> References: <20110805065603.5829.56173.sendpatchset@skannery> Subject: [Qemu-devel] [v6 Patch 4/4]Qemu: Add commandline -drive option 'hostcache' List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Kevin Wolf , Stefan Hajnoczi , Christoph Hellwig qemu command option 'hostcache' added to -drive for block devices. While starting a VM from qemu commandline, this option can be used for setting host cache usage for block data access. It is not allowed to specify both 'hostcache' and 'cache' options in the same commandline. Signed-off-by: Supriya Kannery --- blockdev.c | 13 +++++++++++++ qemu-config.c | 4 ++++ qemu-options.hx | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) Index: qemu/blockdev.c =================================================================== --- qemu.orig/blockdev.c +++ qemu/blockdev.c @@ -238,6 +238,7 @@ DriveInfo *drive_init(QemuOpts *opts, in DriveInfo *dinfo; int snapshot = 0; int ret; + int hostcache = 0; translation = BIOS_ATA_TRANSLATION_AUTO; media = MEDIA_DISK; @@ -320,7 +321,19 @@ DriveInfo *drive_init(QemuOpts *opts, in } } + if ((hostcache = qemu_opt_get_bool(opts, "hostcache", -1)) != -1) { + if (!hostcache) { + bdrv_flags |= BDRV_O_NOCACHE; + } else { + bdrv_flags &= ~BDRV_O_NOCACHE; + } + } + if ((buf = qemu_opt_get(opts, "cache")) != NULL) { + if (hostcache != -1) { + error_report("'hostcache' and 'cache' cannot co-exist"); + return NULL; + } if (!strcmp(buf, "off") || !strcmp(buf, "none")) { bdrv_flags |= BDRV_O_NOCACHE | BDRV_O_CACHE_WB; } else if (!strcmp(buf, "writeback")) { Index: qemu/qemu-options.hx =================================================================== --- qemu.orig/qemu-options.hx +++ qemu/qemu-options.hx @@ -135,7 +135,7 @@ DEF("drive", HAS_ARG, QEMU_OPTION_drive, " [,cyls=c,heads=h,secs=s[,trans=t]][,snapshot=on|off]\n" " [,cache=writethrough|writeback|none|unsafe][,format=f]\n" " [,serial=s][,addr=A][,id=name][,aio=threads|native]\n" - " [,readonly=on|off]\n" + " [,readonly=on|off][,hostcache=on|off]\n" " use 'file' as a drive image\n", QEMU_ARCH_ALL) STEXI @item -drive @var{option}[,@var{option}[,@var{option}[,...]]] Index: qemu/qemu-config.c =================================================================== --- qemu.orig/qemu-config.c +++ qemu/qemu-config.c @@ -84,6 +84,10 @@ static QemuOptsList qemu_drive_opts = { .name = "readonly", .type = QEMU_OPT_BOOL, .help = "open drive file as read-only", + },{ + .name = "hostcache", + .type = QEMU_OPT_BOOL, + .help = "set or reset hostcache (on/off)" }, { /* end of list */ } },