From patchwork Wed Jul 27 11:31:06 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Supriya Kannery X-Patchwork-Id: 107034 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 1A943B6F64 for ; Wed, 27 Jul 2011 21:19:41 +1000 (EST) Received: from localhost ([::1]:53322 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qm29F-0003B1-5g for incoming@patchwork.ozlabs.org; Wed, 27 Jul 2011 07:19:33 -0400 Received: from eggs.gnu.org ([140.186.70.92]:44591) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qm299-0003Aw-Pw for qemu-devel@nongnu.org; Wed, 27 Jul 2011 07:19:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Qm298-00081U-NA for qemu-devel@nongnu.org; Wed, 27 Jul 2011 07:19:27 -0400 Received: from e3.ny.us.ibm.com ([32.97.182.143]:37023) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Qm298-00081Q-I4 for qemu-devel@nongnu.org; Wed, 27 Jul 2011 07:19:26 -0400 Received: from d01relay01.pok.ibm.com (d01relay01.pok.ibm.com [9.56.227.233]) by e3.ny.us.ibm.com (8.14.4/8.13.1) with ESMTP id p6RAtj9T014125 for ; Wed, 27 Jul 2011 06:55:45 -0400 Received: from d01av02.pok.ibm.com (d01av02.pok.ibm.com [9.56.224.216]) by d01relay01.pok.ibm.com (8.13.8/8.13.8/NCO v10.0) with ESMTP id p6RBJQTc068004 for ; Wed, 27 Jul 2011 07:19:26 -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 p6RBJOb7013144 for ; Wed, 27 Jul 2011 08:19:25 -0300 Received: from [127.0.0.1] ([9.78.197.26]) by d01av02.pok.ibm.com (8.14.4/8.13.1/NCO v10.0 AVin) with ESMTP id p6RBJGQl012648; Wed, 27 Jul 2011 08:19:22 -0300 From: Supriya Kannery To: qemu-devel@nongnu.org Date: Wed, 27 Jul 2011 17:01:06 +0530 Message-Id: <20110727113101.25109.41971.sendpatchset@skannery> In-Reply-To: <20110727113000.25109.16204.sendpatchset@skannery> References: <20110727113000.25109.16204.sendpatchset@skannery> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6, seldom 2.4 (older, 4) X-Received-From: 32.97.182.143 Cc: Kevin Wolf , Stefan Hajnoczi , Christoph Hellwig , Supriya Kannery Subject: [Qemu-devel] [V5 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 | 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 */ } },