From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:56962) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RDSl5-00022j-6W for qemu-devel@nongnu.org; Mon, 10 Oct 2011 23:12:00 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RDSl4-0001IX-4U for qemu-devel@nongnu.org; Mon, 10 Oct 2011 23:11:59 -0400 Received: from e3.ny.us.ibm.com ([32.97.182.143]:51477) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RDSl4-0001IT-20 for qemu-devel@nongnu.org; Mon, 10 Oct 2011 23:11:58 -0400 Received: from /spool/local by us.ibm.com with XMail ESMTP for from ; Mon, 10 Oct 2011 23:11:57 -0400 Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by d01relay03.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p9B3Bn2f256626 for ; Mon, 10 Oct 2011 23:11:49 -0400 Received: from d01av02.pok.ibm.com (loopback [127.0.0.1]) by d01av02.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p9B3BnQn010627 for ; Tue, 11 Oct 2011 00:11:49 -0300 From: Supriya Kannery Date: Tue, 11 Oct 2011 08:41:45 +0530 Message-Id: <20111011031145.9587.93507.sendpatchset@skannery.in.ibm.com> In-Reply-To: <20111011031046.9587.44474.sendpatchset@skannery.in.ibm.com> References: <20111011031046.9587.44474.sendpatchset@skannery.in.ibm.com> Subject: [Qemu-devel] [v7 Patch 4/5]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. Simultaneous use of 'hostcache' and 'cache' options not allowed. 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 @@ -237,6 +237,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; @@ -319,7 +320,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 (bdrv_parse_cache_flags(buf, &bdrv_flags) != 0) { error_report("invalid cache option"); return NULL; 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|directsync|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 @@ -85,6 +85,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 */ } },