From patchwork Sun Oct 30 10:34:51 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Supriya Kannery X-Patchwork-Id: 122593 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.gnu.org (lists.gnu.org [140.186.70.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by ozlabs.org (Postfix) with ESMTPS id F14A5B6F77 for ; Sun, 30 Oct 2011 21:35:24 +1100 (EST) Received: from localhost ([::1]:58043 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RKSjU-0003HV-4L for incoming@patchwork.ozlabs.org; Sun, 30 Oct 2011 06:35:16 -0400 Received: from eggs.gnu.org ([140.186.70.92]:45827) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RKSjJ-0003Ft-8j for qemu-devel@nongnu.org; Sun, 30 Oct 2011 06:35:06 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1RKSjH-0002YY-He for qemu-devel@nongnu.org; Sun, 30 Oct 2011 06:35:05 -0400 Received: from e3.ny.us.ibm.com ([32.97.182.143]:58214) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1RKSjH-0002XM-Ar for qemu-devel@nongnu.org; Sun, 30 Oct 2011 06:35:03 -0400 Received: from /spool/local by e3.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Sun, 30 Oct 2011 06:35:02 -0400 Received: from d01relay04.pok.ibm.com ([9.56.227.236]) by e3.ny.us.ibm.com ([192.168.1.103]) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Sun, 30 Oct 2011 06:35:01 -0400 Received: from d03av02.boulder.ibm.com (d03av02.boulder.ibm.com [9.17.195.168]) by d01relay04.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p9UAZ0sc301334 for ; Sun, 30 Oct 2011 06:35:01 -0400 Received: from d03av02.boulder.ibm.com (loopback [127.0.0.1]) by d03av02.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVout) with ESMTP id p9UAYxjx030528 for ; Sun, 30 Oct 2011 04:35:00 -0600 Received: from skannery.in.ibm.com ([9.77.202.63]) by d03av02.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p9UAYqvB030337; Sun, 30 Oct 2011 04:34:55 -0600 From: Supriya Kannery To: qemu-devel@nongnu.org Date: Sun, 30 Oct 2011 16:04:51 +0530 Message-Id: <20111030103451.31685.23002.sendpatchset@skannery.in.ibm.com> In-Reply-To: <20111030103327.31685.17045.sendpatchset@skannery.in.ibm.com> References: <20111030103327.31685.17045.sendpatchset@skannery.in.ibm.com> x-cbid: 11103010-8974-0000-0000-0000013CEF4D X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 32.97.182.143 Cc: Kevin Wolf , Stefan Hajnoczi , Christoph Hellwig Subject: [Qemu-devel] [v8 Patch 4/6]Qemu: Add commandline -drive option 'hostcache' X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org 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. 'cache=xx' overrides 'hostcache=yy' when specified simultaneously. 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; @@ -324,6 +325,12 @@ DriveInfo *drive_init(QemuOpts *opts, in error_report("invalid cache option"); return NULL; } + } else { + if ((hostcache = qemu_opt_get_bool(opts, "hostcache", -1)) != -1) { + if (!hostcache) { + bdrv_flags |= BDRV_O_NOCACHE; + } + } } #ifdef CONFIG_LINUX_AIO 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 */ } },