1
The following changes since commit 20d6c7312f1b812bb9c750f4087f69ac8485cc90:
1
The following changes since commit 9c125d17e9402c232c46610802e5931b3639d77b:
2
2
3
Merge remote-tracking branch 'remotes/palmer/tags/riscv-for-master-3.2-part1' into staging (2019-01-03 13:26:30 +0000)
3
Merge tag 'pull-tcg-20220420' of https://gitlab.com/rth7680/qemu into staging (2022-04-20 16:43:11 -0700)
4
4
5
are available in the Git repository at:
5
are available in the Git repository at:
6
6
7
git://github.com/stefanha/qemu.git tags/block-pull-request
7
https://gitlab.com/stefanha/qemu.git tags/block-pull-request
8
8
9
for you to fetch changes up to 39a0408e768cd00142f5b57d27ab234282bf4df5:
9
for you to fetch changes up to d45c83328feab2e4083991693160f0a417cfd9b0:
10
10
11
dmg: don't skip zero chunk (2019-01-04 11:15:09 +0000)
11
virtiofsd: Add docs/helper for killpriv_v2/no_killpriv_v2 option (2022-04-21 12:05:15 +0200)
12
12
13
----------------------------------------------------------------
13
----------------------------------------------------------------
14
Pull request
14
Pull request
15
15
16
Bug fixes for the .dmg image file format.
16
Small contrib/vhost-user-blk, contrib/vhost-user-scsi, and tools/virtiofsd
17
improvements.
17
18
18
----------------------------------------------------------------
19
----------------------------------------------------------------
19
20
20
Julio Faracco (1):
21
Liu Yiding (1):
21
dmg: Fixing wrong dmg block type value for block terminator.
22
virtiofsd: Add docs/helper for killpriv_v2/no_killpriv_v2 option
22
23
23
yuchenlin (3):
24
Sakshi Kaushik (1):
24
dmg: fix binary search
25
Implements Backend Program conventions for vhost-user-scsi
25
dmg: use enumeration type instead of hard coding number
26
dmg: don't skip zero chunk
27
26
28
block/dmg.c | 31 ++++++++++++++++++++-----------
27
Stefan Hajnoczi (1):
29
1 file changed, 20 insertions(+), 11 deletions(-)
28
contrib/vhost-user-blk: add missing GOptionEntry NULL terminator
29
30
docs/tools/virtiofsd.rst | 5 ++
31
contrib/vhost-user-blk/vhost-user-blk.c | 3 +-
32
contrib/vhost-user-scsi/vhost-user-scsi.c | 77 +++++++++++++++--------
33
tools/virtiofsd/helper.c | 3 +
34
4 files changed, 62 insertions(+), 26 deletions(-)
30
35
31
--
36
--
32
2.20.1
37
2.35.1
33
34
diff view generated by jsdifflib
1
From: yuchenlin <npes87184@gmail.com>
1
From: Sakshi Kaushik <sakshikaushik717@gmail.com>
2
2
3
The dmg file has many tables which describe: "start from sector XXX to
3
Signed-off-by: Sakshi Kaushik <sakshikaushik717@gmail.com>
4
sector XXX, the compression method is XXX and where the compressed data
4
Message-id: 20220406162410.8536-1-sakshikaushik717@gmail.com
5
resides on".
6
5
7
Each sector in the expanded file should be covered by a table. The table
6
[Name the iSCSI URL long option --iscsi-uri instead of --iscsi_uri for
8
will describe the offset of compressed data (or raw depends on the type)
7
consistency, fix --fd which was rejected due to an outdated
9
in the dmg.
8
--socket-path check, and add missing entries[] terminator.
9
--Stefan]
10
10
11
For example:
12
13
[-----------The expanded file------------]
14
[---bzip table ---]/* zeros */[---zlib---]
15
^
16
| if we want to read this sector.
17
18
we will find bzip table which contains this sector, and get the
19
compressed data offset, read it from dmg, uncompress it, finally write to
20
expanded file.
21
22
If we skip zero chunk (table), some sector cannot find the table which
23
will cause search_chunk() return s->n_chunks, dmg_read_chunk() return -1
24
and finally causing dmg_co_preadv() return EIO.
25
26
See:
27
28
[-----------The expanded file------------]
29
[---bzip table ---]/* zeros */[---zlib---]
30
^
31
| if we want to read this sector.
32
33
Oops, we cannot find the table contains it...
34
35
In the original implementation, we don't have zero table. When we try to
36
read sector inside the zero chunk. We will get EIO, and skip reading.
37
38
After this patch, we treat zero chunk the same as ignore chunk, it will
39
directly write zero and avoid some sector may not find the table.
40
41
After this patch:
42
43
[-----------The expanded file------------]
44
[---bzip table ---][--zeros--][---zlib---]
45
46
Signed-off-by: yuchenlin <npes87184@gmail.com>
47
Reviewed-by: Julio Faracco <jcfaracco@gmail.com>
48
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
49
Message-id: 20190103114700.9686-4-npes87184@gmail.com
50
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
51
---
12
---
52
block/dmg.c | 19 ++++++++++++-------
13
contrib/vhost-user-scsi/vhost-user-scsi.c | 77 +++++++++++++++--------
53
1 file changed, 12 insertions(+), 7 deletions(-)
14
1 file changed, 52 insertions(+), 25 deletions(-)
54
15
55
diff --git a/block/dmg.c b/block/dmg.c
16
diff --git a/contrib/vhost-user-scsi/vhost-user-scsi.c b/contrib/vhost-user-scsi/vhost-user-scsi.c
56
index XXXXXXX..XXXXXXX 100644
17
index XXXXXXX..XXXXXXX 100644
57
--- a/block/dmg.c
18
--- a/contrib/vhost-user-scsi/vhost-user-scsi.c
58
+++ b/block/dmg.c
19
+++ b/contrib/vhost-user-scsi/vhost-user-scsi.c
59
@@ -XXX,XX +XXX,XX @@ static void update_max_chunk_size(BDRVDMGState *s, uint32_t chunk,
20
@@ -XXX,XX +XXX,XX @@ fail:
60
case UDRW: /* copy */
21
61
uncompressed_sectors = DIV_ROUND_UP(s->lengths[chunk], 512);
22
/** vhost-user-scsi **/
62
break;
23
63
- case UDIG: /* zero */
24
+static int opt_fdnum = -1;
64
+ case UDZE: /* zero */
25
+static char *opt_socket_path;
65
+ case UDIG: /* ignore */
26
+static gboolean opt_print_caps;
66
/* as the all-zeroes block may be large, it is treated specially: the
27
+static char *iscsi_uri;
67
* sector is not copied from a large buffer, a simple memset is used
28
+
68
* instead. Therefore uncompressed_sectors does not need to be set. */
29
+static GOptionEntry entries[] = {
69
@@ -XXX,XX +XXX,XX @@ typedef struct DmgHeaderState {
30
+ { "print-capabilities", 'c', 0, G_OPTION_ARG_NONE, &opt_print_caps,
70
static bool dmg_is_known_block_type(uint32_t entry_type)
31
+ "Print capabilities", NULL },
32
+ { "fd", 'f', 0, G_OPTION_ARG_INT, &opt_fdnum,
33
+ "Use inherited fd socket", "FDNUM" },
34
+ { "iscsi-uri", 'i', 0, G_OPTION_ARG_FILENAME, &iscsi_uri,
35
+ "iSCSI URI to connect to", "FDNUM" },
36
+ { "socket-path", 's', 0, G_OPTION_ARG_FILENAME, &opt_socket_path,
37
+ "Use UNIX socket path", "PATH" },
38
+ { NULL, }
39
+};
40
+
41
int main(int argc, char **argv)
71
{
42
{
72
switch (entry_type) {
43
VusDev *vdev_scsi = NULL;
73
+ case UDZE: /* zeros */
44
- char *unix_fn = NULL;
74
case UDRW: /* uncompressed */
45
- char *iscsi_uri = NULL;
75
- case UDIG: /* zeroes */
46
- int lsock = -1, csock = -1, opt, err = EXIT_SUCCESS;
76
+ case UDIG: /* ignore */
47
+ int lsock = -1, csock = -1, err = EXIT_SUCCESS;
77
case UDZO: /* zlib */
48
78
return true;
49
- while ((opt = getopt(argc, argv, "u:i:")) != -1) {
79
case UDBZ: /* bzip2 */
50
- switch (opt) {
80
@@ -XXX,XX +XXX,XX @@ static int dmg_read_mish_block(BDRVDMGState *s, DmgHeaderState *ds,
51
- case 'h':
81
/* sector count */
52
- goto help;
82
s->sectorcounts[i] = buff_read_uint64(buffer, offset + 0x10);
53
- case 'u':
83
54
- unix_fn = g_strdup(optarg);
84
- /* all-zeroes sector (type 2) does not need to be "uncompressed" and can
55
- break;
85
- * therefore be unbounded. */
56
- case 'i':
86
- if (s->types[i] != UDIG && s->sectorcounts[i] > DMG_SECTORCOUNTS_MAX) {
57
- iscsi_uri = g_strdup(optarg);
87
+ /* all-zeroes sector (type UDZE and UDIG) does not need to be
58
- break;
88
+ * "uncompressed" and can therefore be unbounded. */
59
- default:
89
+ if (s->types[i] != UDZE && s->types[i] != UDIG
60
- goto help;
90
+ && s->sectorcounts[i] > DMG_SECTORCOUNTS_MAX) {
61
- }
91
error_report("sector count %" PRIu64 " for chunk %" PRIu32
62
+ GError *error = NULL;
92
" is larger than max (%u)",
63
+ GOptionContext *context;
93
s->sectorcounts[i], i, DMG_SECTORCOUNTS_MAX);
64
+
94
@@ -XXX,XX +XXX,XX @@ static inline int dmg_read_chunk(BlockDriverState *bs, uint64_t sector_num)
65
+ context = g_option_context_new(NULL);
95
return -1;
66
+ g_option_context_add_main_entries(context, entries, NULL);
96
}
67
+ if (!g_option_context_parse(context, &argc, &argv, &error)) {
97
break;
68
+ g_printerr("Option parsing failed: %s\n", error->message);
98
- case UDIG: /* zero */
69
+ exit(EXIT_FAILURE);
99
+ case UDZE: /* zeros */
70
+ }
100
+ case UDIG: /* ignore */
71
+
101
/* see dmg_read, it is treated specially. No buffer needs to be
72
+ if (opt_print_caps) {
102
* pre-filled, the zeroes can be set directly. */
73
+ g_print("{\n");
103
break;
74
+ g_print(" \"type\": \"scsi\"\n");
104
@@ -XXX,XX +XXX,XX @@ dmg_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes,
75
+ g_print("}\n");
105
/* Special case: current chunk is all zeroes. Do not perform a memcpy as
76
+ goto out;
106
* s->uncompressed_chunk may be too small to cover the large all-zeroes
77
}
107
* section. dmg_read_chunk is called to find s->current_chunk */
78
- if (!unix_fn || !iscsi_uri) {
108
- if (s->types[s->current_chunk] == UDIG) { /* all zeroes block entry */
79
+
109
+ if (s->types[s->current_chunk] == UDZE
80
+ if (!iscsi_uri) {
110
+ || s->types[s->current_chunk] == UDIG) { /* all zeroes block entry */
81
goto help;
111
qemu_iovec_memset(qiov, i * 512, 0, 512);
82
}
112
continue;
83
113
}
84
- lsock = unix_sock_new(unix_fn);
85
- if (lsock < 0) {
86
- goto err;
87
+ if (opt_socket_path) {
88
+ lsock = unix_sock_new(opt_socket_path);
89
+ if (lsock < 0) {
90
+ exit(EXIT_FAILURE);
91
+ }
92
+ } else if (opt_fdnum < 0) {
93
+ g_print("%s\n", g_option_context_get_help(context, true, NULL));
94
+ exit(EXIT_FAILURE);
95
+ } else {
96
+ lsock = opt_fdnum;
97
}
98
99
csock = accept(lsock, NULL, NULL);
100
@@ -XXX,XX +XXX,XX @@ out:
101
if (vdev_scsi) {
102
g_main_loop_unref(vdev_scsi->loop);
103
g_free(vdev_scsi);
104
- unlink(unix_fn);
105
+ unlink(opt_socket_path);
106
}
107
if (csock >= 0) {
108
close(csock);
109
@@ -XXX,XX +XXX,XX @@ out:
110
if (lsock >= 0) {
111
close(lsock);
112
}
113
- g_free(unix_fn);
114
+ g_free(opt_socket_path);
115
g_free(iscsi_uri);
116
117
return err;
118
@@ -XXX,XX +XXX,XX @@ err:
119
goto out;
120
121
help:
122
- fprintf(stderr, "Usage: %s [ -u unix_sock_path -i iscsi_uri ] | [ -h ]\n",
123
+ fprintf(stderr, "Usage: %s [ -s socket-path -i iscsi-uri -f fd -p print-capabilities ] | [ -h ]\n",
124
argv[0]);
125
- fprintf(stderr, " -u path to unix socket\n");
126
- fprintf(stderr, " -i iscsi uri for lun 0\n");
127
+ fprintf(stderr, " -s, --socket-path=SOCKET_PATH path to unix socket\n");
128
+ fprintf(stderr, " -i, --iscsi-uri=ISCSI_URI iscsi uri for lun 0\n");
129
+ fprintf(stderr, " -f, --fd=FILE_DESCRIPTOR file-descriptor\n");
130
+ fprintf(stderr, " -p, --print-capabilities=PRINT_CAPABILITIES denotes print-capabilities\n");
131
fprintf(stderr, " -h print help and quit\n");
132
133
goto err;
114
--
134
--
115
2.20.1
135
2.35.1
116
117
diff view generated by jsdifflib
1
From: Julio Faracco <jcfaracco@gmail.com>
1
The GLib documentation says "a NULL-terminated array of GOptionEntrys"
2
so we'd better make sure there is a terminator that lets
3
g_option_context_add_main_entries() know when the end of the array has
4
been reached.
2
5
3
This is a trivial patch to fix a wrong value for block terminator.
6
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
4
The old value was 0x7fffffff which is wrong. It was not affecting the
7
Reviewed-by: Michael S. Tsirkin <mst@redhat.com>
5
code because QEMU dmg block is not handling block terminator right now.
8
Message-id: 20220411150057.3009667-1-stefanha@redhat.com
6
Neverthless, it should be fixed.
7
8
Signed-off-by: Julio Faracco <jcfaracco@gmail.com>
9
Reviewed-by: yuchenlin <yuchenlin@synology.com>
10
Message-id: 20181228145055.18039-1-jcfaracco@gmail.com
11
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
9
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
12
---
10
---
13
block/dmg.c | 2 +-
11
contrib/vhost-user-blk/vhost-user-blk.c | 3 ++-
14
1 file changed, 1 insertion(+), 1 deletion(-)
12
1 file changed, 2 insertions(+), 1 deletion(-)
15
13
16
diff --git a/block/dmg.c b/block/dmg.c
14
diff --git a/contrib/vhost-user-blk/vhost-user-blk.c b/contrib/vhost-user-blk/vhost-user-blk.c
17
index XXXXXXX..XXXXXXX 100644
15
index XXXXXXX..XXXXXXX 100644
18
--- a/block/dmg.c
16
--- a/contrib/vhost-user-blk/vhost-user-blk.c
19
+++ b/block/dmg.c
17
+++ b/contrib/vhost-user-blk/vhost-user-blk.c
20
@@ -XXX,XX +XXX,XX @@ enum {
18
@@ -XXX,XX +XXX,XX @@ static GOptionEntry entries[] = {
21
UDBZ,
19
{"blk-file", 'b', 0, G_OPTION_ARG_FILENAME, &opt_blk_file,
22
ULFO,
20
"block device or file path", "PATH"},
23
UDCM = 0x7ffffffe, /* Comments */
21
{ "read-only", 'r', 0, G_OPTION_ARG_NONE, &opt_read_only,
24
- UDLE /* Last Entry */
22
- "Enable read-only", NULL }
25
+ UDLE = 0xffffffff /* Last Entry */
23
+ "Enable read-only", NULL },
24
+ { NULL, },
26
};
25
};
27
26
28
static int dmg_probe(const uint8_t *buf, int buf_size, const char *filename)
27
int main(int argc, char **argv)
29
--
28
--
30
2.20.1
29
2.35.1
31
32
diff view generated by jsdifflib
1
From: yuchenlin <npes87184@gmail.com>
1
From: Liu Yiding <liuyd.fnst@fujitsu.com>
2
2
3
There is a possible hang in original binary search implementation. That is
3
virtiofsd has introduced killpriv_v2/no_killpriv_v2 for a while. Add
4
if chunk1 = 4, chunk2 = 5, chunk3 = 4, and we go else case.
4
description of it to docs/helper.
5
5
6
The chunk1 will be still 4, and so on.
6
Signed-off-by: Liu Yiding <liuyd.fnst@fujitsu.com>
7
Message-Id: <20220421095151.2231099-1-liuyd.fnst@fujitsu.com>
7
8
8
Signed-off-by: yuchenlin <npes87184@gmail.com>
9
[Small documentation fixes: s/as client supports/as the client supports/
9
Message-id: 20190103114700.9686-2-npes87184@gmail.com
10
and s/. /. /.
11
--Stefan]
12
10
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
13
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
11
---
14
---
12
block/dmg.c | 10 +++++++---
15
docs/tools/virtiofsd.rst | 5 +++++
13
1 file changed, 7 insertions(+), 3 deletions(-)
16
tools/virtiofsd/helper.c | 3 +++
17
2 files changed, 8 insertions(+)
14
18
15
diff --git a/block/dmg.c b/block/dmg.c
19
diff --git a/docs/tools/virtiofsd.rst b/docs/tools/virtiofsd.rst
16
index XXXXXXX..XXXXXXX 100644
20
index XXXXXXX..XXXXXXX 100644
17
--- a/block/dmg.c
21
--- a/docs/tools/virtiofsd.rst
18
+++ b/block/dmg.c
22
+++ b/docs/tools/virtiofsd.rst
19
@@ -XXX,XX +XXX,XX @@ static inline uint32_t search_chunk(BDRVDMGState *s, uint64_t sector_num)
23
@@ -XXX,XX +XXX,XX @@ Options
20
{
24
label. Server will try to set that label on newly created file
21
/* binary search */
25
atomically wherever possible.
22
uint32_t chunk1 = 0, chunk2 = s->n_chunks, chunk3;
26
23
- while (chunk1 != chunk2) {
27
+ * killpriv_v2|no_killpriv_v2 -
24
+ while (chunk1 <= chunk2) {
28
+ Enable/disable ``FUSE_HANDLE_KILLPRIV_V2`` support. KILLPRIV_V2 is enabled
25
chunk3 = (chunk1 + chunk2) / 2;
29
+ by default as long as the client supports it. Enabling this option helps
26
if (s->sectors[chunk3] > sector_num) {
30
+ with performance in write path.
27
- chunk2 = chunk3;
31
+
28
+ if (chunk3 == 0) {
32
.. option:: --socket-path=PATH
29
+ goto err;
33
30
+ }
34
Listen on vhost-user UNIX domain socket at PATH.
31
+ chunk2 = chunk3 - 1;
35
diff --git a/tools/virtiofsd/helper.c b/tools/virtiofsd/helper.c
32
} else if (s->sectors[chunk3] + s->sectorcounts[chunk3] > sector_num) {
36
index XXXXXXX..XXXXXXX 100644
33
return chunk3;
37
--- a/tools/virtiofsd/helper.c
34
} else {
38
+++ b/tools/virtiofsd/helper.c
35
- chunk1 = chunk3;
39
@@ -XXX,XX +XXX,XX @@ void fuse_cmdline_help(void)
36
+ chunk1 = chunk3 + 1;
40
" -o announce_submounts Announce sub-mount points to the guest\n"
37
}
41
" -o posix_acl/no_posix_acl Enable/Disable posix_acl. (default: disabled)\n"
38
}
42
" -o security_label/no_security_label Enable/Disable security label. (default: disabled)\n"
39
+err:
43
+ " -o killpriv_v2/no_killpriv_v2\n"
40
return s->n_chunks; /* error */
44
+ " Enable/Disable FUSE_HANDLE_KILLPRIV_V2.\n"
45
+ " (default: enabled as long as client supports it)\n"
46
);
41
}
47
}
42
48
43
--
49
--
44
2.20.1
50
2.35.1
45
46
diff view generated by jsdifflib
Deleted patch
1
From: yuchenlin <npes87184@gmail.com>
2
1
3
Signed-off-by: yuchenlin <npes87184@gmail.com>
4
Reviewed-by: Julio Faracco <jcfaracco@gmail.com>
5
Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
6
Message-id: 20190103114700.9686-3-npes87184@gmail.com
7
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
8
---
9
block/dmg.c | 4 ++--
10
1 file changed, 2 insertions(+), 2 deletions(-)
11
12
diff --git a/block/dmg.c b/block/dmg.c
13
index XXXXXXX..XXXXXXX 100644
14
--- a/block/dmg.c
15
+++ b/block/dmg.c
16
@@ -XXX,XX +XXX,XX @@ static int dmg_read_mish_block(BDRVDMGState *s, DmgHeaderState *ds,
17
18
/* all-zeroes sector (type 2) does not need to be "uncompressed" and can
19
* therefore be unbounded. */
20
- if (s->types[i] != 2 && s->sectorcounts[i] > DMG_SECTORCOUNTS_MAX) {
21
+ if (s->types[i] != UDIG && s->sectorcounts[i] > DMG_SECTORCOUNTS_MAX) {
22
error_report("sector count %" PRIu64 " for chunk %" PRIu32
23
" is larger than max (%u)",
24
s->sectorcounts[i], i, DMG_SECTORCOUNTS_MAX);
25
@@ -XXX,XX +XXX,XX @@ dmg_co_preadv(BlockDriverState *bs, uint64_t offset, uint64_t bytes,
26
/* Special case: current chunk is all zeroes. Do not perform a memcpy as
27
* s->uncompressed_chunk may be too small to cover the large all-zeroes
28
* section. dmg_read_chunk is called to find s->current_chunk */
29
- if (s->types[s->current_chunk] == 2) { /* all zeroes block entry */
30
+ if (s->types[s->current_chunk] == UDIG) { /* all zeroes block entry */
31
qemu_iovec_memset(qiov, i * 512, 0, 512);
32
continue;
33
}
34
--
35
2.20.1
36
37
diff view generated by jsdifflib