~ubuntu-branches/ubuntu/oneiric/seabios/oneiric

« back to all changes in this revision

Viewing changes to debian/patches/0019-fix-two-issues-with-virtio-blk.patch

  • Committer: Bazaar Package Importer
  • Author(s): Serge Hallyn
  • Date: 2010-10-22 11:04:31 UTC
  • Revision ID: james.westby@ubuntu.com-20101022110431-fnfj73ra6xkq623n
Tags: 0.6.0-0ubuntu2
Add all patches which were included in qemu-0.13.0-rc2 (per
commit on Jul 13, 2010).

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
From 4030db0d2c5a79de2a1b5c31514503e4ff2a3cd1 Mon Sep 17 00:00:00 2001
 
2
From: Gleb Natapov <gleb@redhat.com>
 
3
Date: Mon, 17 May 2010 16:27:27 +0300
 
4
Subject: [PATCH 19/54] fix two issues with virtio-blk
 
5
 
 
6
1. Check if blk_size is valid in virtio_blk config.
 
7
2. Disable interrupt otherwise interrupt may stuck
 
8
   with some guests.
 
9
 
 
10
Signed-off-by: Gleb Natapov <gleb@redhat.com>
 
11
 
 
12
ChangeLog:
 
13
 v1->v2:
 
14
  - Treat sector size not equal to 512 bytes as error.
 
15
---
 
16
 src/virtio-blk.c  |   17 ++++++++++++++---
 
17
 src/virtio-blk.h  |    2 ++
 
18
 src/virtio-ring.h |    2 ++
 
19
 3 files changed, 18 insertions(+), 3 deletions(-)
 
20
 
 
21
diff --git a/src/virtio-blk.c b/src/virtio-blk.c
 
22
index 7cc2edb..e6167e9 100644
 
23
--- a/src/virtio-blk.c
 
24
+++ b/src/virtio-blk.c
 
25
@@ -127,23 +127,34 @@ virtio_blk_setup(void)
 
26
                       VIRTIO_CONFIG_S_DRIVER );
 
27
 
 
28
         if (vp_find_vq(ioaddr, 0, vdrive_g->vq) < 0 ) {
 
29
+            dprintf(1, "fail to find vq for virtio-blk %x:%x\n",
 
30
+                    pci_bdf_to_bus(bdf), pci_bdf_to_dev(bdf));
 
31
+        next:
 
32
             free(vdrive_g);
 
33
             free(desc);
 
34
             free(vq);
 
35
-            dprintf(1, "fail to find vq for virtio-blk %x:%x\n",
 
36
-                    pci_bdf_to_bus(bdf), pci_bdf_to_dev(bdf));
 
37
             continue;
 
38
         }
 
39
 
 
40
         struct virtio_blk_config cfg;
 
41
         vp_get(ioaddr, 0, &cfg, sizeof(cfg));
 
42
 
 
43
-        vdrive_g->drive.blksize = cfg.blk_size;
 
44
+        u32 f = vp_get_features(ioaddr);
 
45
+        vdrive_g->drive.blksize = (f & (1 << VIRTIO_BLK_F_BLK_SIZE)) ?
 
46
+            cfg.blk_size : DISK_SECTOR_SIZE;
 
47
+
 
48
         vdrive_g->drive.sectors = cfg.capacity;
 
49
         dprintf(3, "virtio-blk %x:%x blksize=%d sectors=%u\n",
 
50
                 pci_bdf_to_bus(bdf), pci_bdf_to_dev(bdf),
 
51
                 vdrive_g->drive.blksize, (u32)vdrive_g->drive.sectors);
 
52
 
 
53
+        if (vdrive_g->drive.blksize != DISK_SECTOR_SIZE) {
 
54
+            dprintf(1, "virtio-blk %x:%x block size %d is unsupported\n",
 
55
+                    pci_bdf_to_bus(bdf), pci_bdf_to_dev(bdf),
 
56
+                    vdrive_g->drive.blksize);
 
57
+            goto next;
 
58
+        }
 
59
+
 
60
         vdrive_g->drive.pchs.cylinders = cfg.cylinders;
 
61
         vdrive_g->drive.pchs.heads = cfg.heads;
 
62
         vdrive_g->drive.pchs.spt = cfg.sectors;
 
63
diff --git a/src/virtio-blk.h b/src/virtio-blk.h
 
64
index 8095d5b..7243704 100644
 
65
--- a/src/virtio-blk.h
 
66
+++ b/src/virtio-blk.h
 
67
@@ -16,6 +16,8 @@ struct virtio_blk_config
 
68
     u32 opt_io_size;
 
69
 } __attribute__((packed));
 
70
 
 
71
+#define VIRTIO_BLK_F_BLK_SIZE 6
 
72
+
 
73
 /* These two define direction. */
 
74
 #define VIRTIO_BLK_T_IN                0
 
75
 #define VIRTIO_BLK_T_OUT       1
 
76
diff --git a/src/virtio-ring.h b/src/virtio-ring.h
 
77
index 3fb86fe..014defc 100644
 
78
--- a/src/virtio-ring.h
 
79
+++ b/src/virtio-ring.h
 
80
@@ -105,6 +105,8 @@ static inline void vring_init(struct vring *vr,
 
81
    vr->desc = phys_to_virt(pa);
 
82
 
 
83
    vr->avail = (struct vring_avail *)&vr->desc[num];
 
84
+   /* disable interrupts */
 
85
+   vr->avail->flags |= VRING_AVAIL_F_NO_INTERRUPT;
 
86
 
 
87
    /* physical address of used must be page aligned */
 
88
 
 
89
-- 
 
90
1.7.1
 
91