Sophie

Sophie

distrib > Scientific%20Linux > 5x > x86_64 > by-pkgid > 340e01248478ba8b78a6d4d1809b1eff > files > 63

kvm-83-270.el5_11.src.rpm

From 62651fd38126fd854711c402aab23be13fc20d1b Mon Sep 17 00:00:00 2001
From: Kevin Wolf <kwolf@redhat.com>
Date: Tue, 31 Aug 2010 13:06:47 -0300
Subject: [PATCH 1/7] Add cache=unsafe parameter to -drive

RH-Author: Kevin Wolf <kwolf@redhat.com>
Message-id: <1283260008-3294-2-git-send-email-kwolf@redhat.com>
Patchwork-id: 11634
O-Subject: [RHEL-5.6 KVM PATCH 1/2] Add cache=unsafe parameter to -drive
Bugzilla: 623484
RH-Acked-by: Jes Sorensen <Jes.Sorensen@redhat.com>
RH-Acked-by: Don Dutile <ddutile@redhat.com>
RH-Acked-by: Paolo Bonzini <pbonzini@redhat.com>
RH-Acked-by: Christoph Hellwig <chellwig@redhat.com>

From: Alexander Graf <agraf@suse.de>

Bugzilla: 623484
Upstream commit: 016f5cf6ff465411733878a17c8f8febb7668321

This is half of the upstream commit to add cache=unsafe. The bdrv_aio_flush
part is completely left out, so we will still flush for these (the reason is
that we have no ACB pools in RHEL 5 and we would need them to use the right
bdrv_aio_cancel implementation even with fake flushes). However, what
we're really interested in are metadata flushes in qcow2 and those are
synchronous anyway.

Signed-off-by: Alexander Graf <agraf@suse.de>
Signed-off-by: Aurelien Jarno <aurelien@aurel32.net>
Signed-off-by: Kevin Wolf <kwolf@redhat.com>
---
 qemu/block.c |    4 ++++
 qemu/block.h |    4 +++-
 qemu/vl.c    |    6 +++++-
 3 files changed, 12 insertions(+), 2 deletions(-)

Signed-off-by: Eduardo Habkost <ehabkost@redhat.com>
---
 qemu/block.c |    4 ++++
 qemu/block.h |    4 +++-
 qemu/vl.c    |    6 +++++-
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/qemu/block.c b/qemu/block.c
index edd0d9d..712150c 100644
--- a/qemu/block.c
+++ b/qemu/block.c
@@ -1299,6 +1299,10 @@ const char *bdrv_get_device_name(BlockDriverState *bs)
 
 void bdrv_flush(BlockDriverState *bs)
 {
+    if (bs->open_flags & BDRV_O_NO_FLUSH) {
+        return;
+    }
+
     if (bs->drv->bdrv_flush)
         bs->drv->bdrv_flush(bs);
     if (bs->backing_hd)
diff --git a/qemu/block.h b/qemu/block.h
index 0858935..1a5a9f1 100644
--- a/qemu/block.h
+++ b/qemu/block.h
@@ -46,8 +46,10 @@ typedef struct QEMUSnapshotInfo {
 #define BDRV_O_CACHE_WB    0x0040 /* use write-back caching */
 #define BDRV_O_CACHE_DEF   0x0080 /* use default caching */
 #define BDRV_O_NO_BACKING  0x0100 /* don't open the backing file */
+#define BDRV_O_NO_FLUSH    0x0200 /* disable flushing on this disk */
 
-#define BDRV_O_CACHE_MASK  (BDRV_O_NOCACHE | BDRV_O_CACHE_WB | BDRV_O_CACHE_DEF)
+#define BDRV_O_CACHE_MASK \
+    (BDRV_O_NOCACHE | BDRV_O_CACHE_WB | BDRV_O_CACHE_DEF | BDRV_O_NO_FLUSH)
 
 void bdrv_info(void);
 void bdrv_info_stats(void);
diff --git a/qemu/vl.c b/qemu/vl.c
index db68da9..2300b3f 100644
--- a/qemu/vl.c
+++ b/qemu/vl.c
@@ -2569,6 +2569,8 @@ int drive_init(struct drive_opt *arg, int snapshot,
             cache = 1;
         else if (!strcmp(buf, "writeback"))
             cache = 2;
+        else if (!strcmp(buf, "unsafe"))
+            cache = 4;
         else {
            fprintf(stderr, "qemu: invalid cache option\n");
            return -1;
@@ -2738,6 +2740,8 @@ int drive_init(struct drive_opt *arg, int snapshot,
         bdrv_flags |= BDRV_O_CACHE_WB;
     else if (cache == 3) /* not specified */
         bdrv_flags |= BDRV_O_CACHE_DEF;
+    else if (cache == 4) /* unsafe */
+        bdrv_flags |= BDRV_O_CACHE_WB | BDRV_O_NO_FLUSH;
 
     ro = 0;
     if (media == MEDIA_CDROM) {
@@ -4260,7 +4264,7 @@ static void help(int exitcode)
            "-cdrom file     use 'file' as IDE cdrom image (cdrom is ide1 master)\n"
 	   "-drive [file=file][,if=type][,bus=n][,unit=m][,media=d][,index=i]\n"
            "       [,cyls=c,heads=h,secs=s[,trans=t]][,snapshot=on|off]\n"
-           "       [,cache=writethrough|writeback|none][,format=f][,serial=s]\n"
+           "       [,cache=writethrough|writeback|none|unsafe][,format=f][,serial=s]\n"
            "       [,boot=on|off]\n"
 	   "                use 'file' as a drive image\n"
            "-mtdblock file  use 'file' as on-board Flash memory image\n"
-- 
1.6.5.5