-
Notifications
You must be signed in to change notification settings - Fork 2
/
seabios-add-write-support-to-virtio-blk.patch
85 lines (71 loc) · 2.3 KB
/
seabios-add-write-support-to-virtio-blk.patch
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
From 9664cae167be76a39c4a08c4bc16592c312b404c Mon Sep 17 00:00:00 2001
From: Gleb Natapov <[email protected]>
Date: Wed, 18 Aug 2010 14:41:57 -0300
Subject: [PATCH] add write support to virtio-blk
RH-Author: Gleb Natapov <[email protected]>
Message-id: <[email protected]>
Patchwork-id: 11398
O-Subject: [PATCH RHEL6 SEABIOS v2] add write support to virtio-blk
Bugzilla: 607500
RH-Acked-by: Eduardo Habkost <[email protected]>
RH-Acked-by: Jes Sorensen <[email protected]>
Windows XP writes to sector 0 during installation and if write fails it
prints mysterious error.
BZ: 607500
Upstream status: sent upstream
Signed-off-by: Gleb Natapov <[email protected]>
--
v1->v2:
Call vring_add_buf correctly for write.
This time I checked that sector 0 is actually changes in the image.
--
Gleb.
Signed-off-by: Eduardo Habkost <[email protected]>
---
src/virtio-blk.c | 15 ++++++++++-----
1 files changed, 10 insertions(+), 5 deletions(-)
diff --git a/src/virtio-blk.c b/src/virtio-blk.c
index c7144b5..ddc900a 100644
--- a/src/virtio-blk.c
+++ b/src/virtio-blk.c
@@ -25,13 +25,13 @@ struct virtiodrive_s {
};
static int
-virtio_blk_read(struct disk_op_s *op)
+virtio_blk_op(struct disk_op_s *op, int write)
{
struct drive_s *drive_g = op->drive_g;
struct virtiodrive_s *vdrive_g = (void*)GET_GLOBAL(drive_g->cntl_info);
struct vring_virtqueue *vq = GET_FLATPTR(vdrive_g->vq);
struct virtio_blk_outhdr hdr = {
- .type = VIRTIO_BLK_T_IN,
+ .type = write ? VIRTIO_BLK_T_OUT : VIRTIO_BLK_T_IN,
.ioprio = 0,
.sector = op->lba,
};
@@ -52,7 +52,11 @@ virtio_blk_read(struct disk_op_s *op)
};
/* Add to virtqueue and kick host */
- vring_add_buf(vq, sg, 1, 2, 0, 0);
+ if (write)
+ vring_add_buf(vq, sg, 2, 1, 0, 0);
+ else
+ vring_add_buf(vq, sg, 1, 2, 0, 0);
+
vring_kick(GET_FLATPTR(vdrive_g->ioaddr), vq, 1);
/* Wait for reply */
@@ -69,9 +73,10 @@ process_virtio_op(struct disk_op_s *op)
{
switch (op->command) {
case CMD_READ:
- return virtio_blk_read(op);
- case CMD_FORMAT:
+ return virtio_blk_op(op, 0);
case CMD_WRITE:
+ return virtio_blk_op(op, 1);
+ case CMD_FORMAT:
return DISK_RET_EWRITEPROTECT;
case CMD_RESET:
case CMD_ISREADY:
--
1.7.2.1