1 | The following changes since commit e5cd695266c5709308aa95b1baae499e4b5d4544: | 1 | The following changes since commit 15ef89d2a1a7b93845a6b09c2ee8e1979f6eb30b: |
---|---|---|---|
2 | 2 | ||
3 | Merge remote-tracking branch 'remotes/cody/tags/block-pull-request' into staging (2018-05-08 17:05:58 +0100) | 3 | Update version for v7.0.0-rc1 release (2022-03-22 22:58:44 +0000) |
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 31be8a2a97ecba7d31a82932286489cac318e9e9: | 9 | for you to fetch changes up to 2539eade4f689eda7e9fe45486f18334bfbafaf0: |
10 | 10 | ||
11 | block/file-posix: add x-check-page-cache=on|off option (2018-05-11 16:43:05 +0100) | 11 | hw: Fix misleading hexadecimal format (2022-03-24 10:38:42 +0000) |
12 | 12 | ||
13 | ---------------------------------------------------------------- | 13 | ---------------------------------------------------------------- |
14 | Block pull request | 14 | Pull request |
15 | 15 | ||
16 | * Support -drive cache.direct=off live migration for POSIX files | 16 | Philippe found cases where the 0x%d format string was used, leading to |
17 | misleading output. The patches look harmless and could save people time, so I | ||
18 | think it's worth including them in 7.0. | ||
17 | 19 | ||
18 | ---------------------------------------------------------------- | 20 | ---------------------------------------------------------------- |
19 | 21 | ||
20 | Joe Perches (4): | 22 | Philippe Mathieu-Daudé (2): |
21 | checkpatch: add a --strict check for utf-8 in commit logs | 23 | block: Fix misleading hexadecimal format |
22 | checkpatch: ignore email headers better | 24 | hw: Fix misleading hexadecimal format |
23 | checkpatch: emit a warning on file add/move/delete | ||
24 | checkpatch: reduce MAINTAINERS update message frequency | ||
25 | 25 | ||
26 | Pasi Savanainen (1): | 26 | block/parallels-ext.c | 2 +- |
27 | checkpatch: check utf-8 content from a commit log when it's missing | 27 | hw/i386/sgx.c | 2 +- |
28 | from charset | 28 | hw/i386/trace-events | 6 +++--- |
29 | 29 | hw/misc/trace-events | 4 ++-- | |
30 | Stefan Hajnoczi (3): | 30 | hw/scsi/trace-events | 4 ++-- |
31 | blockjob: drop block_job_pause/resume_all() | 31 | 5 files changed, 9 insertions(+), 9 deletions(-) |
32 | block/file-posix: implement bdrv_co_invalidate_cache() on Linux | ||
33 | block/file-posix: add x-check-page-cache=on|off option | ||
34 | |||
35 | qapi/block-core.json | 7 +- | ||
36 | include/block/blockjob_int.h | 14 ---- | ||
37 | block/file-posix.c | 146 ++++++++++++++++++++++++++++++++++- | ||
38 | blockjob.c | 27 ------- | ||
39 | scripts/checkpatch.pl | 56 +++++++++++++- | ||
40 | 5 files changed, 202 insertions(+), 48 deletions(-) | ||
41 | 32 | ||
42 | -- | 33 | -- |
43 | 2.17.0 | 34 | 2.35.1 |
44 | 35 | ||
45 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | Commit 8119334918e86f45877cfc139192d54f2449a239 ("block: Don't | ||
2 | block_job_pause_all() in bdrv_drain_all()") removed the only callers of | ||
3 | block_job_pause/resume_all(). | ||
4 | 1 | ||
5 | Pausing and resuming now happens in child_job_drained_begin/end() so | ||
6 | it's no longer necessary to globally pause/resume jobs. | ||
7 | |||
8 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
9 | Reviewed-by: John Snow <jsnow@redhat.com> | ||
10 | Reviewed-by: Alberto Garcia <berto@igalia.com> | ||
11 | Message-id: 20180424085240.5798-1-stefanha@redhat.com | ||
12 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
13 | --- | ||
14 | include/block/blockjob_int.h | 14 -------------- | ||
15 | blockjob.c | 27 --------------------------- | ||
16 | 2 files changed, 41 deletions(-) | ||
17 | |||
18 | diff --git a/include/block/blockjob_int.h b/include/block/blockjob_int.h | ||
19 | index XXXXXXX..XXXXXXX 100644 | ||
20 | --- a/include/block/blockjob_int.h | ||
21 | +++ b/include/block/blockjob_int.h | ||
22 | @@ -XXX,XX +XXX,XX @@ void block_job_sleep_ns(BlockJob *job, int64_t ns); | ||
23 | */ | ||
24 | void block_job_yield(BlockJob *job); | ||
25 | |||
26 | -/** | ||
27 | - * block_job_pause_all: | ||
28 | - * | ||
29 | - * Asynchronously pause all jobs. | ||
30 | - */ | ||
31 | -void block_job_pause_all(void); | ||
32 | - | ||
33 | -/** | ||
34 | - * block_job_resume_all: | ||
35 | - * | ||
36 | - * Resume all block jobs. Must be paired with a preceding block_job_pause_all. | ||
37 | - */ | ||
38 | -void block_job_resume_all(void); | ||
39 | - | ||
40 | /** | ||
41 | * block_job_early_fail: | ||
42 | * @bs: The block device. | ||
43 | diff --git a/blockjob.c b/blockjob.c | ||
44 | index XXXXXXX..XXXXXXX 100644 | ||
45 | --- a/blockjob.c | ||
46 | +++ b/blockjob.c | ||
47 | @@ -XXX,XX +XXX,XX @@ void *block_job_create(const char *job_id, const BlockJobDriver *driver, | ||
48 | return job; | ||
49 | } | ||
50 | |||
51 | -void block_job_pause_all(void) | ||
52 | -{ | ||
53 | - BlockJob *job = NULL; | ||
54 | - while ((job = block_job_next(job))) { | ||
55 | - AioContext *aio_context = blk_get_aio_context(job->blk); | ||
56 | - | ||
57 | - aio_context_acquire(aio_context); | ||
58 | - block_job_ref(job); | ||
59 | - block_job_pause(job); | ||
60 | - aio_context_release(aio_context); | ||
61 | - } | ||
62 | -} | ||
63 | - | ||
64 | void block_job_early_fail(BlockJob *job) | ||
65 | { | ||
66 | assert(job->status == BLOCK_JOB_STATUS_CREATED); | ||
67 | @@ -XXX,XX +XXX,XX @@ void coroutine_fn block_job_pause_point(BlockJob *job) | ||
68 | } | ||
69 | } | ||
70 | |||
71 | -void block_job_resume_all(void) | ||
72 | -{ | ||
73 | - BlockJob *job, *next; | ||
74 | - | ||
75 | - QLIST_FOREACH_SAFE(job, &block_jobs, job_list, next) { | ||
76 | - AioContext *aio_context = blk_get_aio_context(job->blk); | ||
77 | - | ||
78 | - aio_context_acquire(aio_context); | ||
79 | - block_job_resume(job); | ||
80 | - block_job_unref(job); | ||
81 | - aio_context_release(aio_context); | ||
82 | - } | ||
83 | -} | ||
84 | - | ||
85 | /* | ||
86 | * Conditionally enter a block_job pending a call to fn() while | ||
87 | * under the block_job_lock critical section. | ||
88 | -- | ||
89 | 2.17.0 | ||
90 | |||
91 | diff view generated by jsdifflib |
1 | From: Joe Perches <joe@perches.com> | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | 2 | ||
3 | Some find using utf-8 in commit logs inappropriate. | 3 | "0x%u" format is very misleading, replace by "0x%x". |
4 | 4 | ||
5 | Some patch commit logs contain unintended utf-8 characters when doing | 5 | Found running: |
6 | things like copy/pasting compilation output. | ||
7 | 6 | ||
8 | Look for the start of any commit log by skipping initial lines that look | 7 | $ git grep -E '0x%[0-9]*([lL]*|" ?PRI)[dDuU]' block/ |
9 | like email headers and "From: " lines. | ||
10 | 8 | ||
11 | Stop looking for utf-8 at the first signature line. | 9 | Inspired-by: Richard Henderson <richard.henderson@linaro.org> |
12 | 10 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | |
13 | Signed-off-by: Joe Perches <joe@perches.com> | 11 | Reviewed-by: Hanna Reitz <hreitz@redhat.com> |
14 | Reviewed-by: Markus Armbruster <armbru@redhat.com> | 12 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> |
15 | Reviewed-by: Thomas Huth <thuth@redhat.com> | 13 | Reviewed-by: Denis V. Lunev <den@openvz.org> |
16 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 14 | Message-id: 20220323114718.58714-2-philippe.mathieu.daude@gmail.com |
17 | Signed-off-by: Andrew Morton <akpm@linux-foundation.org> | ||
18 | Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> | ||
19 | Message-id: 20180430124651.10340-2-stefanha@redhat.com | ||
20 | Suggested-by: Andrew Morton <akpm@linux-foundation.org> | ||
21 | Cc: Andy Whitcroft <apw@shadowen.org> | ||
22 | Signed-off-by: Andrew Morton <akpm@linux-foundation.org> | ||
23 | Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> | ||
24 | (cherry picked from commit 15662b3e8644905032c2e26808401a487d4e90c1) | ||
25 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
26 | |||
27 | Conflicts: | ||
28 | QEMU does not have CHK(), use WARN() instead. | ||
29 | |||
30 | QEMU WARN() only takes one argument, drop the 'type' value in the | ||
31 | first argument. | ||
32 | |||
33 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 15 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
34 | --- | 16 | --- |
35 | scripts/checkpatch.pl | 30 ++++++++++++++++++++++++++---- | 17 | block/parallels-ext.c | 2 +- |
36 | 1 file changed, 26 insertions(+), 4 deletions(-) | 18 | 1 file changed, 1 insertion(+), 1 deletion(-) |
37 | 19 | ||
38 | diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl | 20 | diff --git a/block/parallels-ext.c b/block/parallels-ext.c |
39 | index XXXXXXX..XXXXXXX 100755 | 21 | index XXXXXXX..XXXXXXX 100644 |
40 | --- a/scripts/checkpatch.pl | 22 | --- a/block/parallels-ext.c |
41 | +++ b/scripts/checkpatch.pl | 23 | +++ b/block/parallels-ext.c |
42 | @@ -XXX,XX +XXX,XX @@ our $NonptrType; | 24 | @@ -XXX,XX +XXX,XX @@ static int parallels_parse_format_extension(BlockDriverState *bs, |
43 | our $Type; | 25 | break; |
44 | our $Declare; | 26 | |
45 | 27 | default: | |
46 | -our $UTF8 = qr { | 28 | - error_setg(errp, "Unknown feature: 0x%" PRIu64, fh.magic); |
47 | - [\x09\x0A\x0D\x20-\x7E] # ASCII | 29 | + error_setg(errp, "Unknown feature: 0x%" PRIx64, fh.magic); |
48 | - | [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte | 30 | goto fail; |
49 | +our $NON_ASCII_UTF8 = qr{ | 31 | } |
50 | + [\xC2-\xDF][\x80-\xBF] # non-overlong 2-byte | ||
51 | | \xE0[\xA0-\xBF][\x80-\xBF] # excluding overlongs | ||
52 | | [\xE1-\xEC\xEE\xEF][\x80-\xBF]{2} # straight 3-byte | ||
53 | | \xED[\x80-\x9F][\x80-\xBF] # excluding surrogates | ||
54 | @@ -XXX,XX +XXX,XX @@ our $UTF8 = qr { | ||
55 | | \xF4[\x80-\x8F][\x80-\xBF]{2} # plane 16 | ||
56 | }x; | ||
57 | |||
58 | +our $UTF8 = qr{ | ||
59 | + [\x09\x0A\x0D\x20-\x7E] # ASCII | ||
60 | + | $NON_ASCII_UTF8 | ||
61 | +}x; | ||
62 | + | ||
63 | # There are still some false positives, but this catches most | ||
64 | # common cases. | ||
65 | our $typeTypedefs = qr{(?x: | ||
66 | @@ -XXX,XX +XXX,XX @@ sub process { | ||
67 | my $signoff = 0; | ||
68 | my $is_patch = 0; | ||
69 | |||
70 | + my $in_header_lines = 1; | ||
71 | + my $in_commit_log = 0; #Scanning lines before patch | ||
72 | + | ||
73 | our @report = (); | ||
74 | our $cnt_lines = 0; | ||
75 | our $cnt_error = 0; | ||
76 | @@ -XXX,XX +XXX,XX @@ sub process { | ||
77 | if ($line =~ /^diff --git.*?(\S+)$/) { | ||
78 | $realfile = $1; | ||
79 | $realfile =~ s@^([^/]*)/@@; | ||
80 | - | ||
81 | } elsif ($line =~ /^\+\+\+\s+(\S+)/) { | ||
82 | $realfile = $1; | ||
83 | $realfile =~ s@^([^/]*)/@@; | ||
84 | @@ -XXX,XX +XXX,XX @@ sub process { | ||
85 | if ($line =~ /^\s*signed-off-by:/i) { | ||
86 | # This is a signoff, if ugly, so do not double report. | ||
87 | $signoff++; | ||
88 | + $in_commit_log = 0; | ||
89 | + | ||
90 | if (!($line =~ /^\s*Signed-off-by:/)) { | ||
91 | ERROR("The correct form is \"Signed-off-by\"\n" . | ||
92 | $herecurr); | ||
93 | @@ -XXX,XX +XXX,XX @@ sub process { | ||
94 | ERROR("Invalid UTF-8, patch and commit message should be encoded in UTF-8\n" . $hereptr); | ||
95 | } | ||
96 | |||
97 | +# Check if it's the start of a commit log | ||
98 | +# (not a header line and we haven't seen the patch filename) | ||
99 | + if ($in_header_lines && $realfile =~ /^$/ && | ||
100 | + $rawline !~ /^(commit\b|from\b|\w+:).+$/i) { | ||
101 | + $in_header_lines = 0; | ||
102 | + $in_commit_log = 1; | ||
103 | + } | ||
104 | + | ||
105 | +# Still not yet in a patch, check for any UTF-8 | ||
106 | + if ($in_commit_log && $realfile =~ /^$/ && | ||
107 | + $rawline =~ /$NON_ASCII_UTF8/) { | ||
108 | + WARN("8-bit UTF-8 used in possible commit log\n" . $herecurr); | ||
109 | + } | ||
110 | + | ||
111 | # ignore non-hunk lines and lines being removed | ||
112 | next if (!$hunk_line || $line =~ /^-/); | ||
113 | 32 | ||
114 | -- | 33 | -- |
115 | 2.17.0 | 34 | 2.35.1 |
116 | 35 | ||
117 | 36 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Pasi Savanainen <pasi.savanainen@nixu.com> | ||
2 | 1 | ||
3 | Check that a commit log doesn't contain UTF-8 when a mail header | ||
4 | explicitly defines a different charset, like | ||
5 | |||
6 | 'Content-Type: text/plain; charset="us-ascii"' | ||
7 | |||
8 | Signed-off-by: Pasi Savanainen <pasi.savanainen@nixu.com> | ||
9 | Reviewed-by: Markus Armbruster <armbru@redhat.com> | ||
10 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
11 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
12 | Signed-off-by: Andrew Morton <akpm@linux-foundation.org> | ||
13 | Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> | ||
14 | Message-id: 20180430124651.10340-3-stefanha@redhat.com | ||
15 | Cc: Joe Perches <joe@perches.com> | ||
16 | Cc: Andy Whitcroft <apw@canonical.com> | ||
17 | Signed-off-by: Andrew Morton <akpm@linux-foundation.org> | ||
18 | Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> | ||
19 | (cherry picked from commit fa64205df9dfd7b7662cc64a7e82115c00e428e5) | ||
20 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
21 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
22 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
23 | --- | ||
24 | scripts/checkpatch.pl | 13 +++++++++++-- | ||
25 | 1 file changed, 11 insertions(+), 2 deletions(-) | ||
26 | |||
27 | diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl | ||
28 | index XXXXXXX..XXXXXXX 100755 | ||
29 | --- a/scripts/checkpatch.pl | ||
30 | +++ b/scripts/checkpatch.pl | ||
31 | @@ -XXX,XX +XXX,XX @@ sub process { | ||
32 | my $in_header_lines = 1; | ||
33 | my $in_commit_log = 0; #Scanning lines before patch | ||
34 | |||
35 | + my $non_utf8_charset = 0; | ||
36 | + | ||
37 | our @report = (); | ||
38 | our $cnt_lines = 0; | ||
39 | our $cnt_error = 0; | ||
40 | @@ -XXX,XX +XXX,XX @@ sub process { | ||
41 | $in_commit_log = 1; | ||
42 | } | ||
43 | |||
44 | -# Still not yet in a patch, check for any UTF-8 | ||
45 | - if ($in_commit_log && $realfile =~ /^$/ && | ||
46 | +# Check if there is UTF-8 in a commit log when a mail header has explicitly | ||
47 | +# declined it, i.e defined some charset where it is missing. | ||
48 | + if ($in_header_lines && | ||
49 | + $rawline =~ /^Content-Type:.+charset="(.+)".*$/ && | ||
50 | + $1 !~ /utf-8/i) { | ||
51 | + $non_utf8_charset = 1; | ||
52 | + } | ||
53 | + | ||
54 | + if ($in_commit_log && $non_utf8_charset && $realfile =~ /^$/ && | ||
55 | $rawline =~ /$NON_ASCII_UTF8/) { | ||
56 | WARN("8-bit UTF-8 used in possible commit log\n" . $herecurr); | ||
57 | } | ||
58 | -- | ||
59 | 2.17.0 | ||
60 | |||
61 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Joe Perches <joe@perches.com> | ||
2 | 1 | ||
3 | There are some patches created by git format-patch that when scanned by | ||
4 | checkpatch report errors on lines like | ||
5 | |||
6 | To: address.tld | ||
7 | |||
8 | This is a checkpatch false positive. | ||
9 | |||
10 | Improve the logic a bit to ignore folded email headers to avoid emitting | ||
11 | these messages. | ||
12 | |||
13 | Signed-off-by: Joe Perches <joe@perches.com> | ||
14 | Signed-off-by: Andrew Morton <akpm@linux-foundation.org> | ||
15 | Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> | ||
16 | Reviewed-by: Markus Armbruster <armbru@redhat.com> | ||
17 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
18 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
19 | Message-id: 20180430124651.10340-4-stefanha@redhat.com | ||
20 | (cherry picked from commit 29ee1b0c67e0dd7dea8dd718e8326076bce5b6fe) | ||
21 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
22 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
23 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
24 | --- | ||
25 | scripts/checkpatch.pl | 5 +++-- | ||
26 | 1 file changed, 3 insertions(+), 2 deletions(-) | ||
27 | |||
28 | diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl | ||
29 | index XXXXXXX..XXXXXXX 100755 | ||
30 | --- a/scripts/checkpatch.pl | ||
31 | +++ b/scripts/checkpatch.pl | ||
32 | @@ -XXX,XX +XXX,XX @@ sub process { | ||
33 | my $signoff = 0; | ||
34 | my $is_patch = 0; | ||
35 | |||
36 | - my $in_header_lines = 1; | ||
37 | + my $in_header_lines = $file ? 0 : 1; | ||
38 | my $in_commit_log = 0; #Scanning lines before patch | ||
39 | |||
40 | my $non_utf8_charset = 0; | ||
41 | @@ -XXX,XX +XXX,XX @@ sub process { | ||
42 | # Check if it's the start of a commit log | ||
43 | # (not a header line and we haven't seen the patch filename) | ||
44 | if ($in_header_lines && $realfile =~ /^$/ && | ||
45 | - $rawline !~ /^(commit\b|from\b|\w+:).+$/i) { | ||
46 | + !($rawline =~ /^\s+\S/ || | ||
47 | + $rawline =~ /^(commit\b|from\b|[\w-]+:).*$/i)) { | ||
48 | $in_header_lines = 0; | ||
49 | $in_commit_log = 1; | ||
50 | } | ||
51 | -- | ||
52 | 2.17.0 | ||
53 | |||
54 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Joe Perches <joe@perches.com> | ||
2 | 1 | ||
3 | Whenever files are added, moved, or deleted, the MAINTAINERS file | ||
4 | patterns can be out of sync or outdated. | ||
5 | |||
6 | To try to keep MAINTAINERS more up-to-date, add a one-time warning | ||
7 | whenever a patch does any of those. | ||
8 | |||
9 | Signed-off-by: Joe Perches <joe@perches.com> | ||
10 | Acked-by: Andy Whitcroft <apw@canonical.com> | ||
11 | Signed-off-by: Andrew Morton <akpm@linux-foundation.org> | ||
12 | Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> | ||
13 | Reviewed-by: Markus Armbruster <armbru@redhat.com> | ||
14 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
15 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
16 | Message-id: 20180430124651.10340-5-stefanha@redhat.com | ||
17 | (cherry picked from commit 13f1937ef33950b1112049972249e6191b82e6c9) | ||
18 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
19 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
20 | |||
21 | Conflicts: | ||
22 | QEMU WARN() only takes one argument, drop the 'type' value in the | ||
23 | first argument. | ||
24 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
25 | --- | ||
26 | scripts/checkpatch.pl | 12 +++++++++++- | ||
27 | 1 file changed, 11 insertions(+), 1 deletion(-) | ||
28 | |||
29 | diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl | ||
30 | index XXXXXXX..XXXXXXX 100755 | ||
31 | --- a/scripts/checkpatch.pl | ||
32 | +++ b/scripts/checkpatch.pl | ||
33 | @@ -XXX,XX +XXX,XX @@ sub process { | ||
34 | |||
35 | my $in_header_lines = $file ? 0 : 1; | ||
36 | my $in_commit_log = 0; #Scanning lines before patch | ||
37 | - | ||
38 | + my $reported_maintainer_file = 0; | ||
39 | my $non_utf8_charset = 0; | ||
40 | |||
41 | our @report = (); | ||
42 | @@ -XXX,XX +XXX,XX @@ sub process { | ||
43 | } | ||
44 | } | ||
45 | |||
46 | +# Check for added, moved or deleted files | ||
47 | + if (!$reported_maintainer_file && !$in_commit_log && | ||
48 | + ($line =~ /^(?:new|deleted) file mode\s*\d+\s*$/ || | ||
49 | + $line =~ /^rename (?:from|to) [\w\/\.\-]+\s*$/ || | ||
50 | + ($line =~ /\{\s*([\w\/\.\-]*)\s*\=\>\s*([\w\/\.\-]*)\s*\}/ && | ||
51 | + (defined($1) || defined($2))))) { | ||
52 | + $reported_maintainer_file = 1; | ||
53 | + WARN("added, moved or deleted file(s), does MAINTAINERS need updating?\n" . $herecurr); | ||
54 | + } | ||
55 | + | ||
56 | # Check for wrappage within a valid hunk of the file | ||
57 | if ($realcnt != 0 && $line !~ m{^(?:\+|-| |\\ No newline|$)}) { | ||
58 | ERROR("patch seems to be corrupt (line wrapped?)\n" . | ||
59 | -- | ||
60 | 2.17.0 | ||
61 | |||
62 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | From: Joe Perches <joe@perches.com> | ||
2 | 1 | ||
3 | When files are being added/moved/deleted and a patch contains an update to | ||
4 | the MAINTAINERS file, assume it's to update the MAINTAINERS file correctly | ||
5 | and do not emit the "does MAINTAINERS need updating?" message. | ||
6 | |||
7 | Reported by many people. | ||
8 | |||
9 | Signed-off-by: Joe Perches <joe@perches.com> | ||
10 | Signed-off-by: Andrew Morton <akpm@linux-foundation.org> | ||
11 | Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org> | ||
12 | Reviewed-by: Markus Armbruster <armbru@redhat.com> | ||
13 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
14 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
15 | Message-id: 20180430124651.10340-6-stefanha@redhat.com | ||
16 | (cherry picked from e0d975b1b439c4fef58fbc306c542c94f48bb849) | ||
17 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
18 | Reviewed-by: Thomas Huth <thuth@redhat.com> | ||
19 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
20 | --- | ||
21 | scripts/checkpatch.pl | 6 ++++++ | ||
22 | 1 file changed, 6 insertions(+) | ||
23 | |||
24 | diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl | ||
25 | index XXXXXXX..XXXXXXX 100755 | ||
26 | --- a/scripts/checkpatch.pl | ||
27 | +++ b/scripts/checkpatch.pl | ||
28 | @@ -XXX,XX +XXX,XX @@ sub process { | ||
29 | } | ||
30 | } | ||
31 | |||
32 | +# Check if MAINTAINERS is being updated. If so, there's probably no need to | ||
33 | +# emit the "does MAINTAINERS need updating?" message on file add/move/delete | ||
34 | + if ($line =~ /^\s*MAINTAINERS\s*\|/) { | ||
35 | + $reported_maintainer_file = 1; | ||
36 | + } | ||
37 | + | ||
38 | # Check for added, moved or deleted files | ||
39 | if (!$reported_maintainer_file && !$in_commit_log && | ||
40 | ($line =~ /^(?:new|deleted) file mode\s*\d+\s*$/ || | ||
41 | -- | ||
42 | 2.17.0 | ||
43 | |||
44 | diff view generated by jsdifflib |
Deleted patch | |||
---|---|---|---|
1 | On Linux posix_fadvise(POSIX_FADV_DONTNEED) invalidates pages*. Use | ||
2 | this to drop page cache on the destination host during shared storage | ||
3 | migration. This way the destination host will read the latest copy of | ||
4 | the data and will not use stale data from the page cache. | ||
5 | 1 | ||
6 | The flow is as follows: | ||
7 | |||
8 | 1. Source host writes out all dirty pages and inactivates drives. | ||
9 | 2. QEMU_VM_EOF is sent on migration stream. | ||
10 | 3. Destination host invalidates caches before accessing drives. | ||
11 | |||
12 | This patch enables live migration even with -drive cache.direct=off. | ||
13 | |||
14 | * Terms and conditions may apply, please see patch for details. | ||
15 | |||
16 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
17 | Reviewed-by: Fam Zheng <famz@redhat.com> | ||
18 | Message-id: 20180427162312.18583-2-stefanha@redhat.com | ||
19 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | ||
20 | --- | ||
21 | block/file-posix.c | 46 ++++++++++++++++++++++++++++++++++++++++++++++ | ||
22 | 1 file changed, 46 insertions(+) | ||
23 | |||
24 | diff --git a/block/file-posix.c b/block/file-posix.c | ||
25 | index XXXXXXX..XXXXXXX 100644 | ||
26 | --- a/block/file-posix.c | ||
27 | +++ b/block/file-posix.c | ||
28 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn raw_co_block_status(BlockDriverState *bs, | ||
29 | return ret | BDRV_BLOCK_OFFSET_VALID; | ||
30 | } | ||
31 | |||
32 | +static void coroutine_fn raw_co_invalidate_cache(BlockDriverState *bs, | ||
33 | + Error **errp) | ||
34 | +{ | ||
35 | + BDRVRawState *s = bs->opaque; | ||
36 | + int ret; | ||
37 | + | ||
38 | + ret = fd_open(bs); | ||
39 | + if (ret < 0) { | ||
40 | + error_setg_errno(errp, -ret, "The file descriptor is not open"); | ||
41 | + return; | ||
42 | + } | ||
43 | + | ||
44 | + if (s->open_flags & O_DIRECT) { | ||
45 | + return; /* No host kernel page cache */ | ||
46 | + } | ||
47 | + | ||
48 | +#if defined(__linux__) | ||
49 | + /* This sets the scene for the next syscall... */ | ||
50 | + ret = bdrv_co_flush(bs); | ||
51 | + if (ret < 0) { | ||
52 | + error_setg_errno(errp, -ret, "flush failed"); | ||
53 | + return; | ||
54 | + } | ||
55 | + | ||
56 | + /* Linux does not invalidate pages that are dirty, locked, or mmapped by a | ||
57 | + * process. These limitations are okay because we just fsynced the file, | ||
58 | + * we don't use mmap, and the file should not be in use by other processes. | ||
59 | + */ | ||
60 | + ret = posix_fadvise(s->fd, 0, 0, POSIX_FADV_DONTNEED); | ||
61 | + if (ret != 0) { /* the return value is a positive errno */ | ||
62 | + error_setg_errno(errp, ret, "fadvise failed"); | ||
63 | + return; | ||
64 | + } | ||
65 | +#else /* __linux__ */ | ||
66 | + /* Do nothing. Live migration to a remote host with cache.direct=off is | ||
67 | + * unsupported on other host operating systems. Cache consistency issues | ||
68 | + * may occur but no error is reported here, partly because that's the | ||
69 | + * historical behavior and partly because it's hard to differentiate valid | ||
70 | + * configurations that should not cause errors. | ||
71 | + */ | ||
72 | +#endif /* !__linux__ */ | ||
73 | +} | ||
74 | + | ||
75 | static coroutine_fn BlockAIOCB *raw_aio_pdiscard(BlockDriverState *bs, | ||
76 | int64_t offset, int bytes, | ||
77 | BlockCompletionFunc *cb, void *opaque) | ||
78 | @@ -XXX,XX +XXX,XX @@ BlockDriver bdrv_file = { | ||
79 | .bdrv_co_create_opts = raw_co_create_opts, | ||
80 | .bdrv_has_zero_init = bdrv_has_zero_init_1, | ||
81 | .bdrv_co_block_status = raw_co_block_status, | ||
82 | + .bdrv_co_invalidate_cache = raw_co_invalidate_cache, | ||
83 | .bdrv_co_pwrite_zeroes = raw_co_pwrite_zeroes, | ||
84 | |||
85 | .bdrv_co_preadv = raw_co_preadv, | ||
86 | @@ -XXX,XX +XXX,XX @@ static BlockDriver bdrv_host_device = { | ||
87 | .bdrv_reopen_abort = raw_reopen_abort, | ||
88 | .bdrv_co_create_opts = hdev_co_create_opts, | ||
89 | .create_opts = &raw_create_opts, | ||
90 | + .bdrv_co_invalidate_cache = raw_co_invalidate_cache, | ||
91 | .bdrv_co_pwrite_zeroes = hdev_co_pwrite_zeroes, | ||
92 | |||
93 | .bdrv_co_preadv = raw_co_preadv, | ||
94 | @@ -XXX,XX +XXX,XX @@ static BlockDriver bdrv_host_cdrom = { | ||
95 | .bdrv_reopen_abort = raw_reopen_abort, | ||
96 | .bdrv_co_create_opts = hdev_co_create_opts, | ||
97 | .create_opts = &raw_create_opts, | ||
98 | + .bdrv_co_invalidate_cache = raw_co_invalidate_cache, | ||
99 | |||
100 | |||
101 | .bdrv_co_preadv = raw_co_preadv, | ||
102 | -- | ||
103 | 2.17.0 | ||
104 | |||
105 | diff view generated by jsdifflib |
1 | mincore(2) checks whether pages are resident. Use it to verify that | 1 | From: Philippe Mathieu-Daudé <f4bug@amsat.org> |
---|---|---|---|
2 | page cache has been dropped. | ||
3 | 2 | ||
4 | You can trigger a verification failure by mmapping the image file from | 3 | "0x%u" format is very misleading, replace by "0x%x". |
5 | another process that loads a byte from a page, forcing it to become | ||
6 | resident. bdrv_co_invalidate_cache() will fail while that process is | ||
7 | alive. | ||
8 | 4 | ||
9 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 5 | Found running: |
10 | Reviewed-by: Fam Zheng <famz@redhat.com> | 6 | |
11 | Message-id: 20180427162312.18583-3-stefanha@redhat.com | 7 | $ git grep -E '0x%[0-9]*([lL]*|" ?PRI)[dDuU]' hw/ |
8 | |||
9 | Inspired-by: Richard Henderson <richard.henderson@linaro.org> | ||
10 | Signed-off-by: Philippe Mathieu-Daudé <f4bug@amsat.org> | ||
11 | Reviewed-by: Daniel P. Berrangé <berrange@redhat.com> | ||
12 | Message-id: 20220323114718.58714-3-philippe.mathieu.daude@gmail.com | ||
12 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> | 13 | Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com> |
13 | --- | 14 | --- |
14 | qapi/block-core.json | 7 ++- | 15 | hw/i386/sgx.c | 2 +- |
15 | block/file-posix.c | 100 ++++++++++++++++++++++++++++++++++++++++++- | 16 | hw/i386/trace-events | 6 +++--- |
16 | 2 files changed, 104 insertions(+), 3 deletions(-) | 17 | hw/misc/trace-events | 4 ++-- |
18 | hw/scsi/trace-events | 4 ++-- | ||
19 | 4 files changed, 8 insertions(+), 8 deletions(-) | ||
17 | 20 | ||
18 | diff --git a/qapi/block-core.json b/qapi/block-core.json | 21 | diff --git a/hw/i386/sgx.c b/hw/i386/sgx.c |
19 | index XXXXXXX..XXXXXXX 100644 | 22 | index XXXXXXX..XXXXXXX 100644 |
20 | --- a/qapi/block-core.json | 23 | --- a/hw/i386/sgx.c |
21 | +++ b/qapi/block-core.json | 24 | +++ b/hw/i386/sgx.c |
25 | @@ -XXX,XX +XXX,XX @@ void pc_machine_init_sgx_epc(PCMachineState *pcms) | ||
26 | } | ||
27 | |||
28 | if ((sgx_epc->base + sgx_epc->size) < sgx_epc->base) { | ||
29 | - error_report("Size of all 'sgx-epc' =0x%"PRIu64" causes EPC to wrap", | ||
30 | + error_report("Size of all 'sgx-epc' =0x%"PRIx64" causes EPC to wrap", | ||
31 | sgx_epc->size); | ||
32 | exit(EXIT_FAILURE); | ||
33 | } | ||
34 | diff --git a/hw/i386/trace-events b/hw/i386/trace-events | ||
35 | index XXXXXXX..XXXXXXX 100644 | ||
36 | --- a/hw/i386/trace-events | ||
37 | +++ b/hw/i386/trace-events | ||
38 | @@ -XXX,XX +XXX,XX @@ vtd_fault_disabled(void) "Fault processing disabled for context entry" | ||
39 | vtd_replay_ce_valid(const char *mode, uint8_t bus, uint8_t dev, uint8_t fn, uint16_t domain, uint64_t hi, uint64_t lo) "%s: replay valid context device %02"PRIx8":%02"PRIx8".%02"PRIx8" domain 0x%"PRIx16" hi 0x%"PRIx64" lo 0x%"PRIx64 | ||
40 | vtd_replay_ce_invalid(uint8_t bus, uint8_t dev, uint8_t fn) "replay invalid context device %02"PRIx8":%02"PRIx8".%02"PRIx8 | ||
41 | vtd_page_walk_level(uint64_t addr, uint32_t level, uint64_t start, uint64_t end) "walk (base=0x%"PRIx64", level=%"PRIu32") iova range 0x%"PRIx64" - 0x%"PRIx64 | ||
42 | -vtd_page_walk_one(uint16_t domain, uint64_t iova, uint64_t gpa, uint64_t mask, int perm) "domain 0x%"PRIu16" iova 0x%"PRIx64" -> gpa 0x%"PRIx64" mask 0x%"PRIx64" perm %d" | ||
43 | +vtd_page_walk_one(uint16_t domain, uint64_t iova, uint64_t gpa, uint64_t mask, int perm) "domain 0x%"PRIx16" iova 0x%"PRIx64" -> gpa 0x%"PRIx64" mask 0x%"PRIx64" perm %d" | ||
44 | vtd_page_walk_one_skip_map(uint64_t iova, uint64_t mask, uint64_t translated) "iova 0x%"PRIx64" mask 0x%"PRIx64" translated 0x%"PRIx64 | ||
45 | vtd_page_walk_one_skip_unmap(uint64_t iova, uint64_t mask) "iova 0x%"PRIx64" mask 0x%"PRIx64 | ||
46 | vtd_page_walk_skip_read(uint64_t iova, uint64_t next) "Page walk skip iova 0x%"PRIx64" - 0x%"PRIx64" due to unable to read" | ||
47 | vtd_page_walk_skip_reserve(uint64_t iova, uint64_t next) "Page walk skip iova 0x%"PRIx64" - 0x%"PRIx64" due to rsrv set" | ||
48 | vtd_switch_address_space(uint8_t bus, uint8_t slot, uint8_t fn, bool on) "Device %02x:%02x.%x switching address space (iommu enabled=%d)" | ||
49 | vtd_as_unmap_whole(uint8_t bus, uint8_t slot, uint8_t fn, uint64_t iova, uint64_t size) "Device %02x:%02x.%x start 0x%"PRIx64" size 0x%"PRIx64 | ||
50 | -vtd_translate_pt(uint16_t sid, uint64_t addr) "source id 0x%"PRIu16", iova 0x%"PRIx64 | ||
51 | -vtd_pt_enable_fast_path(uint16_t sid, bool success) "sid 0x%"PRIu16" %d" | ||
52 | +vtd_translate_pt(uint16_t sid, uint64_t addr) "source id 0x%"PRIx16", iova 0x%"PRIx64 | ||
53 | +vtd_pt_enable_fast_path(uint16_t sid, bool success) "sid 0x%"PRIx16" %d" | ||
54 | vtd_irq_generate(uint64_t addr, uint64_t data) "addr 0x%"PRIx64" data 0x%"PRIx64 | ||
55 | vtd_reg_read(uint64_t addr, uint64_t size) "addr 0x%"PRIx64" size 0x%"PRIx64 | ||
56 | vtd_reg_write(uint64_t addr, uint64_t size, uint64_t val) "addr 0x%"PRIx64" size 0x%"PRIx64" value 0x%"PRIx64 | ||
57 | diff --git a/hw/misc/trace-events b/hw/misc/trace-events | ||
58 | index XXXXXXX..XXXXXXX 100644 | ||
59 | --- a/hw/misc/trace-events | ||
60 | +++ b/hw/misc/trace-events | ||
22 | @@ -XXX,XX +XXX,XX @@ | 61 | @@ -XXX,XX +XXX,XX @@ |
23 | # @locking: whether to enable file locking. If set to 'auto', only enable | 62 | # See docs/devel/tracing.rst for syntax documentation. |
24 | # when Open File Descriptor (OFD) locking API is available | 63 | |
25 | # (default: auto, since 2.10) | 64 | # allwinner-cpucfg.c |
26 | +# @x-check-cache-dropped: whether to check that page cache was dropped on live | 65 | -allwinner_cpucfg_cpu_reset(uint8_t cpu_id, uint32_t reset_addr) "id %u, reset_addr 0x%" PRIu32 |
27 | +# migration. May cause noticeable delays if the image | 66 | +allwinner_cpucfg_cpu_reset(uint8_t cpu_id, uint32_t reset_addr) "id %u, reset_addr 0x%" PRIx32 |
28 | +# file is large, do not use in production. | 67 | allwinner_cpucfg_read(uint64_t offset, uint64_t data, unsigned size) "offset 0x%" PRIx64 " data 0x%" PRIx64 " size %" PRIu32 |
29 | +# (default: off) (since: 2.13) | 68 | allwinner_cpucfg_write(uint64_t offset, uint64_t data, unsigned size) "offset 0x%" PRIx64 " data 0x%" PRIx64 " size %" PRIu32 |
30 | # | 69 | |
31 | # Since: 2.9 | 70 | @@ -XXX,XX +XXX,XX @@ imx7_gpr_write(uint64_t offset, uint64_t value) "addr 0x%08" PRIx64 "value 0x%08 |
32 | ## | 71 | |
33 | @@ -XXX,XX +XXX,XX @@ | 72 | # mos6522.c |
34 | 'data': { 'filename': 'str', | 73 | mos6522_set_counter(int index, unsigned int val) "T%d.counter=%d" |
35 | '*pr-manager': 'str', | 74 | -mos6522_get_next_irq_time(uint16_t latch, int64_t d, int64_t delta) "latch=%d counter=0x%"PRId64 " delta_next=0x%"PRId64 |
36 | '*locking': 'OnOffAuto', | 75 | +mos6522_get_next_irq_time(uint16_t latch, int64_t d, int64_t delta) "latch=%d counter=0x%"PRIx64 " delta_next=0x%"PRIx64 |
37 | - '*aio': 'BlockdevAioOptions' } } | 76 | mos6522_set_sr_int(void) "set sr_int" |
38 | + '*aio': 'BlockdevAioOptions', | 77 | mos6522_write(uint64_t addr, const char *name, uint64_t val) "reg=0x%"PRIx64 " [%s] val=0x%"PRIx64 |
39 | + '*x-check-cache-dropped': 'bool' } } | 78 | mos6522_read(uint64_t addr, const char *name, unsigned val) "reg=0x%"PRIx64 " [%s] val=0x%x" |
40 | 79 | diff --git a/hw/scsi/trace-events b/hw/scsi/trace-events | |
41 | ## | ||
42 | # @BlockdevOptionsNull: | ||
43 | diff --git a/block/file-posix.c b/block/file-posix.c | ||
44 | index XXXXXXX..XXXXXXX 100644 | 80 | index XXXXXXX..XXXXXXX 100644 |
45 | --- a/block/file-posix.c | 81 | --- a/hw/scsi/trace-events |
46 | +++ b/block/file-posix.c | 82 | +++ b/hw/scsi/trace-events |
47 | @@ -XXX,XX +XXX,XX @@ typedef struct BDRVRawState { | 83 | @@ -XXX,XX +XXX,XX @@ lsi_bad_phase_interrupt(void) "Phase mismatch interrupt" |
48 | bool page_cache_inconsistent:1; | 84 | lsi_bad_selection(uint32_t id) "Selected absent target %"PRIu32 |
49 | bool has_fallocate; | 85 | lsi_do_dma_unavailable(void) "DMA no data available" |
50 | bool needs_alignment; | 86 | lsi_do_dma(uint64_t addr, int len) "DMA addr=0x%"PRIx64" len=%d" |
51 | + bool check_cache_dropped; | 87 | -lsi_queue_command(uint32_t tag) "Queueing tag=0x%"PRId32 |
52 | 88 | +lsi_queue_command(uint32_t tag) "Queueing tag=0x%"PRIx32 | |
53 | PRManager *pr_mgr; | 89 | lsi_add_msg_byte_error(void) "MSG IN data too long" |
54 | } BDRVRawState; | 90 | lsi_add_msg_byte(uint8_t data) "MSG IN 0x%02x" |
55 | @@ -XXX,XX +XXX,XX @@ typedef struct BDRVRawState { | 91 | lsi_reselect(int id) "Reselected target %d" |
56 | typedef struct BDRVRawReopenState { | 92 | @@ -XXX,XX +XXX,XX @@ lsi_do_msgout_noop(void) "MSG: No Operation" |
57 | int fd; | 93 | lsi_do_msgout_extended(uint8_t msg, uint8_t len) "Extended message 0x%x (len %d)" |
58 | int open_flags; | 94 | lsi_do_msgout_ignored(const char *msg) "%s (ignored)" |
59 | + bool check_cache_dropped; | 95 | lsi_do_msgout_simplequeue(uint8_t select_tag) "SIMPLE queue tag=0x%x" |
60 | } BDRVRawReopenState; | 96 | -lsi_do_msgout_abort(uint32_t tag) "MSG: ABORT TAG tag=0x%"PRId32 |
61 | 97 | +lsi_do_msgout_abort(uint32_t tag) "MSG: ABORT TAG tag=0x%"PRIx32 | |
62 | static int fd_open(BlockDriverState *bs); | 98 | lsi_do_msgout_clearqueue(uint32_t tag) "MSG: CLEAR QUEUE tag=0x%"PRIx32 |
63 | @@ -XXX,XX +XXX,XX @@ static QemuOptsList raw_runtime_opts = { | 99 | lsi_do_msgout_busdevicereset(uint32_t tag) "MSG: BUS DEVICE RESET tag=0x%"PRIx32 |
64 | .type = QEMU_OPT_STRING, | 100 | lsi_do_msgout_select(int id) "Select LUN %d" |
65 | .help = "id of persistent reservation manager object (default: none)", | ||
66 | }, | ||
67 | + { | ||
68 | + .name = "x-check-cache-dropped", | ||
69 | + .type = QEMU_OPT_BOOL, | ||
70 | + .help = "check that page cache was dropped on live migration (default: off)" | ||
71 | + }, | ||
72 | { /* end of list */ } | ||
73 | }, | ||
74 | }; | ||
75 | @@ -XXX,XX +XXX,XX @@ static int raw_open_common(BlockDriverState *bs, QDict *options, | ||
76 | } | ||
77 | } | ||
78 | |||
79 | + s->check_cache_dropped = qemu_opt_get_bool(opts, "x-check-cache-dropped", | ||
80 | + false); | ||
81 | + | ||
82 | s->open_flags = open_flags; | ||
83 | raw_parse_flags(bdrv_flags, &s->open_flags); | ||
84 | |||
85 | @@ -XXX,XX +XXX,XX @@ static int raw_reopen_prepare(BDRVReopenState *state, | ||
86 | { | ||
87 | BDRVRawState *s; | ||
88 | BDRVRawReopenState *rs; | ||
89 | + QemuOpts *opts; | ||
90 | int ret = 0; | ||
91 | Error *local_err = NULL; | ||
92 | |||
93 | @@ -XXX,XX +XXX,XX @@ static int raw_reopen_prepare(BDRVReopenState *state, | ||
94 | |||
95 | state->opaque = g_new0(BDRVRawReopenState, 1); | ||
96 | rs = state->opaque; | ||
97 | + rs->fd = -1; | ||
98 | + | ||
99 | + /* Handle options changes */ | ||
100 | + opts = qemu_opts_create(&raw_runtime_opts, NULL, 0, &error_abort); | ||
101 | + qemu_opts_absorb_qdict(opts, state->options, &local_err); | ||
102 | + if (local_err) { | ||
103 | + error_propagate(errp, local_err); | ||
104 | + ret = -EINVAL; | ||
105 | + goto out; | ||
106 | + } | ||
107 | + | ||
108 | + rs->check_cache_dropped = qemu_opt_get_bool(opts, "x-check-cache-dropped", | ||
109 | + s->check_cache_dropped); | ||
110 | |||
111 | if (s->type == FTYPE_CD) { | ||
112 | rs->open_flags |= O_NONBLOCK; | ||
113 | @@ -XXX,XX +XXX,XX @@ static int raw_reopen_prepare(BDRVReopenState *state, | ||
114 | |||
115 | raw_parse_flags(state->flags, &rs->open_flags); | ||
116 | |||
117 | - rs->fd = -1; | ||
118 | - | ||
119 | int fcntl_flags = O_APPEND | O_NONBLOCK; | ||
120 | #ifdef O_NOATIME | ||
121 | fcntl_flags |= O_NOATIME; | ||
122 | @@ -XXX,XX +XXX,XX @@ static int raw_reopen_prepare(BDRVReopenState *state, | ||
123 | } | ||
124 | } | ||
125 | |||
126 | +out: | ||
127 | + qemu_opts_del(opts); | ||
128 | return ret; | ||
129 | } | ||
130 | |||
131 | @@ -XXX,XX +XXX,XX @@ static void raw_reopen_commit(BDRVReopenState *state) | ||
132 | BDRVRawReopenState *rs = state->opaque; | ||
133 | BDRVRawState *s = state->bs->opaque; | ||
134 | |||
135 | + s->check_cache_dropped = rs->check_cache_dropped; | ||
136 | s->open_flags = rs->open_flags; | ||
137 | |||
138 | qemu_close(s->fd); | ||
139 | @@ -XXX,XX +XXX,XX @@ static int coroutine_fn raw_co_block_status(BlockDriverState *bs, | ||
140 | return ret | BDRV_BLOCK_OFFSET_VALID; | ||
141 | } | ||
142 | |||
143 | +#if defined(__linux__) | ||
144 | +/* Verify that the file is not in the page cache */ | ||
145 | +static void check_cache_dropped(BlockDriverState *bs, Error **errp) | ||
146 | +{ | ||
147 | + const size_t window_size = 128 * 1024 * 1024; | ||
148 | + BDRVRawState *s = bs->opaque; | ||
149 | + void *window = NULL; | ||
150 | + size_t length = 0; | ||
151 | + unsigned char *vec; | ||
152 | + size_t page_size; | ||
153 | + off_t offset; | ||
154 | + off_t end; | ||
155 | + | ||
156 | + /* mincore(2) page status information requires 1 byte per page */ | ||
157 | + page_size = sysconf(_SC_PAGESIZE); | ||
158 | + vec = g_malloc(DIV_ROUND_UP(window_size, page_size)); | ||
159 | + | ||
160 | + end = raw_getlength(bs); | ||
161 | + | ||
162 | + for (offset = 0; offset < end; offset += window_size) { | ||
163 | + void *new_window; | ||
164 | + size_t new_length; | ||
165 | + size_t vec_end; | ||
166 | + size_t i; | ||
167 | + int ret; | ||
168 | + | ||
169 | + /* Unmap previous window if size has changed */ | ||
170 | + new_length = MIN(end - offset, window_size); | ||
171 | + if (new_length != length) { | ||
172 | + munmap(window, length); | ||
173 | + window = NULL; | ||
174 | + length = 0; | ||
175 | + } | ||
176 | + | ||
177 | + new_window = mmap(window, new_length, PROT_NONE, MAP_PRIVATE, | ||
178 | + s->fd, offset); | ||
179 | + if (new_window == MAP_FAILED) { | ||
180 | + error_setg_errno(errp, errno, "mmap failed"); | ||
181 | + break; | ||
182 | + } | ||
183 | + | ||
184 | + window = new_window; | ||
185 | + length = new_length; | ||
186 | + | ||
187 | + ret = mincore(window, length, vec); | ||
188 | + if (ret < 0) { | ||
189 | + error_setg_errno(errp, errno, "mincore failed"); | ||
190 | + break; | ||
191 | + } | ||
192 | + | ||
193 | + vec_end = DIV_ROUND_UP(length, page_size); | ||
194 | + for (i = 0; i < vec_end; i++) { | ||
195 | + if (vec[i] & 0x1) { | ||
196 | + error_setg(errp, "page cache still in use!"); | ||
197 | + break; | ||
198 | + } | ||
199 | + } | ||
200 | + } | ||
201 | + | ||
202 | + if (window) { | ||
203 | + munmap(window, length); | ||
204 | + } | ||
205 | + | ||
206 | + g_free(vec); | ||
207 | +} | ||
208 | +#endif /* __linux__ */ | ||
209 | + | ||
210 | static void coroutine_fn raw_co_invalidate_cache(BlockDriverState *bs, | ||
211 | Error **errp) | ||
212 | { | ||
213 | @@ -XXX,XX +XXX,XX @@ static void coroutine_fn raw_co_invalidate_cache(BlockDriverState *bs, | ||
214 | error_setg_errno(errp, ret, "fadvise failed"); | ||
215 | return; | ||
216 | } | ||
217 | + | ||
218 | + if (s->check_cache_dropped) { | ||
219 | + check_cache_dropped(bs, errp); | ||
220 | + } | ||
221 | #else /* __linux__ */ | ||
222 | /* Do nothing. Live migration to a remote host with cache.direct=off is | ||
223 | * unsupported on other host operating systems. Cache consistency issues | ||
224 | -- | 101 | -- |
225 | 2.17.0 | 102 | 2.35.1 |
226 | 103 | ||
227 | 104 | diff view generated by jsdifflib |