qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-devel] [V4 Patch 4/4]Qemu: Add commandline -drive option 'hostcach


From: Supriya Kannery
Subject: [Qemu-devel] [V4 Patch 4/4]Qemu: Add commandline -drive option 'hostcache'
Date: Mon, 04 Jul 2011 16:13:46 +0530

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 <address@hidden>

---
 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<snapshot> is "on" or "off" and allows 
 
 I<cache> is "none", "writeback", "unsafe", or "writethrough" and controls how 
the host cache is used to access block data.
 
+=item B<hostcache=>I<hostcache>
+
+I<hostcache> 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 B<aio=>I<aio>
 
 I<aio> is "threads", or "native" and selects between pthread based disk I/O 
and native Linux AIO.



reply via email to

[Prev in Thread] Current Thread [Next in Thread]