From patchwork Mon Jul 4 10:43:46 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Supriya Kannery X-Patchwork-Id: 103087 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 DBA20B6EE8 for ; Mon, 4 Jul 2011 20:54:19 +1000 (EST) Received: from localhost ([::1]:33263 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qdgn9-0000Ta-TP for incoming@patchwork.ozlabs.org; Mon, 04 Jul 2011 06:54:15 -0400 Received: from eggs.gnu.org ([140.186.70.92]:54388) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QdgRU-0004Bg-Rh for qemu-devel@nongnu.org; Mon, 04 Jul 2011 06:31:54 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QdgRS-0004Gp-Kc for qemu-devel@nongnu.org; Mon, 04 Jul 2011 06:31:52 -0400 Received: from e36.co.us.ibm.com ([32.97.110.154]:33562) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QdgRR-0004Gf-Ub for qemu-devel@nongnu.org; Mon, 04 Jul 2011 06:31:50 -0400 Received: from d03relay04.boulder.ibm.com (d03relay04.boulder.ibm.com [9.17.195.106]) by e36.co.us.ibm.com (8.14.4/8.13.1) with ESMTP id p64APjIu009522 for ; Mon, 4 Jul 2011 04:25:45 -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 p64AVmFt096706 for ; Mon, 4 Jul 2011 04:31:49 -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 p644Vlu4021595 for ; Sun, 3 Jul 2011 22:31:48 -0600 Received: from [127.0.0.1] ([9.77.84.173]) by d03av04.boulder.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p644ViPn021466; Sun, 3 Jul 2011 22:31:45 -0600 From: Supriya Kannery To: qemu-devel@nongnu.org Date: Mon, 04 Jul 2011 16:13:46 +0530 Message-Id: <20110704104343.28170.4657.sendpatchset@skannery> In-Reply-To: <20110704104237.28170.97021.sendpatchset@skannery> References: <20110704104237.28170.97021.sendpatchset@skannery> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 32.97.110.154 Cc: Kevin Wolf , Supriya Kannery , Christoph Hellwig Subject: [Qemu-devel] [V4 Patch 4/4]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. It is not allowed to specify both 'hostcache' and 'cache' options in the same commandline. User has to specify only one among these. Signed-off-by: Supriya Kannery --- blockdev.c | 17 +++++++++++++++++ qemu-config.c | 4 ++++ qemu-options.hx | 2 +- qemu.pod | 5 +++++ 4 files changed, 27 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; + bool option_hostcache = false; translation = BIOS_ATA_TRANSLATION_AUTO; @@ -324,7 +325,23 @@ DriveInfo *drive_init(QemuOpts *opts, in } } + if ((buf = qemu_opt_get(opts, "hostcache")) != NULL) { + if (!strcmp(buf, "off")) { + bdrv_flags |= BDRV_O_NOCACHE; + } else if (!strcmp(buf, "on")) { + bdrv_flags &= ~BDRV_O_NOCACHE; + } else { + error_report("invalid hostcache option"); + return NULL; + } + option_hostcache = true; + } + if ((buf = qemu_opt_get(opts, "cache")) != NULL) { + if (option_hostcache) { + 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 @@ -120,7 +120,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 @@ -78,6 +78,10 @@ static QemuOptsList qemu_drive_opts = { },{ .name = "readonly", .type = QEMU_OPT_BOOL, + },{ + .name = "hostcache", + .type = QEMU_OPT_BOOL, + .help = "set or reset hostcache (on/off)" }, { /* end of list */ } }, Index: qemu/qemu.pod =================================================================== --- qemu.orig/qemu.pod +++ qemu/qemu.pod @@ -226,6 +226,11 @@ I is "on" or "off" and allows I is "none", "writeback", "unsafe", or "writethrough" and controls how the host cache is used to access block data. +=item BI + +I is "on" or "off" and allows to enable or disable hostcache while accessing block data. +Both 'cache=' and 'hostcache=' should not used in same command line. Use only one among them. + =item BI I is "threads", or "native" and selects between pthread based disk I/O and native Linux AIO.