Skip to content

Commit eefe34e

Browse files
committed
Merge remote-tracking branch 'remotes/dgilbert/tags/pull-migration-20200617a' into staging
Migration (and HMP and virtiofs) pull 2020-06-17 Migration: HMP/migration and test changes from Mao Zhongyi multifd fix from Laurent Vivier HMP qom-set partial reversion/change from David Hildenbrand now you need -j to pass json format, but it's regained the old 100M type format. Memory leak fix from Pan Nengyuan Virtiofs fchmod seccomp fix from Max Reitz Signed-off-by: Dr. David Alan Gilbert <[email protected]> # gpg: Signature made Wed 17 Jun 2020 19:34:58 BST # gpg: using RSA key 45F5C71B4A0CB7FB977A9FA90516331EBC5BFDE7 # gpg: Good signature from "Dr. David Alan Gilbert (RH2) <[email protected]>" [full] # Primary key fingerprint: 45F5 C71B 4A0C B7FB 977A 9FA9 0516 331E BC5B FDE7 * remotes/dgilbert/tags/pull-migration-20200617a: migration: fix multifd_send_pages() next channel docs/xbzrle: update 'cache miss rate' and 'encoding rate' to docs monitor/hmp-cmds: improvements for the 'info migrate' monitor/hmp-cmds: add 'goto end' to reduce duplicate code. monitor/hmp-cmds: delete redundant Error check before invoke hmp_handle_error() monitor/hmp-cmds: don't silently output when running 'migrate_set_downtime' fails monitor/hmp-cmds: add units for migrate_parameters tests/migration: fix unreachable path in stress test tests/migration: mem leak fix hmp: Make json format optional for qom-set qom-hmp-cmds: fix a memleak in hmp_qom_get virtiofsd: Whitelist fchmod Signed-off-by: Peter Maydell <[email protected]>
2 parents 3b26876 + 7e89a14 commit eefe34e

File tree

7 files changed

+56
-51
lines changed

7 files changed

+56
-51
lines changed

docs/xbzrle.txt

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,12 @@ is recommended.
112112
cache size: H bytes
113113
xbzrle transferred: I kbytes
114114
xbzrle pages: J pages
115-
xbzrle cache miss: K
116-
xbzrle overflow: L
115+
xbzrle cache miss: K pages
116+
xbzrle cache miss rate: L
117+
xbzrle encoding rate: M
118+
xbzrle overflow: N
117119

118-
xbzrle cache-miss: the number of cache misses to date - high cache-miss rate
120+
xbzrle cache miss: the number of cache misses to date - high cache-miss rate
119121
indicates that the cache size is set too low.
120122
xbzrle overflow: the number of overflows in the decoding which where the delta
121123
could not be compressed. This can happen if the changes in the pages are too

hmp-commands.hx

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1806,9 +1806,10 @@ ERST
18061806

18071807
{
18081808
.name = "qom-set",
1809-
.args_type = "path:s,property:s,value:S",
1810-
.params = "path property value",
1811-
.help = "set QOM property",
1809+
.args_type = "json:-j,path:s,property:s,value:S",
1810+
.params = "[-j] path property value",
1811+
.help = "set QOM property.\n\t\t\t"
1812+
"-j: the value is specified in json format.",
18121813
.cmd = hmp_qom_set,
18131814
.flags = "p",
18141815
},

migration/multifd.c

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -415,6 +415,12 @@ static int multifd_send_pages(QEMUFile *f)
415415
}
416416

417417
qemu_sem_wait(&multifd_send_state->channels_ready);
418+
/*
419+
* next_channel can remain from a previous migration that was
420+
* using more channels, so ensure it doesn't overflow if the
421+
* limit is lower now.
422+
*/
423+
next_channel %= migrate_multifd_channels();
418424
for (i = next_channel;; i = (i + 1) % migrate_multifd_channels()) {
419425
p = &multifd_send_state->params[i];
420426

monitor/hmp-cmds.c

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict)
299299
info->xbzrle_cache->bytes >> 10);
300300
monitor_printf(mon, "xbzrle pages: %" PRIu64 " pages\n",
301301
info->xbzrle_cache->pages);
302-
monitor_printf(mon, "xbzrle cache miss: %" PRIu64 "\n",
302+
monitor_printf(mon, "xbzrle cache miss: %" PRIu64 " pages\n",
303303
info->xbzrle_cache->cache_miss);
304304
monitor_printf(mon, "xbzrle cache miss rate: %0.2f\n",
305305
info->xbzrle_cache->cache_miss_rate);
@@ -316,8 +316,8 @@ void hmp_info_migrate(Monitor *mon, const QDict *qdict)
316316
info->compression->busy);
317317
monitor_printf(mon, "compression busy rate: %0.2f\n",
318318
info->compression->busy_rate);
319-
monitor_printf(mon, "compressed size: %" PRIu64 "\n",
320-
info->compression->compressed_size);
319+
monitor_printf(mon, "compressed size: %" PRIu64 " kbytes\n",
320+
info->compression->compressed_size >> 10);
321321
monitor_printf(mon, "compression rate: %0.2f\n",
322322
info->compression->compression_rate);
323323
}
@@ -443,11 +443,11 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict)
443443
MigrationParameter_str(MIGRATION_PARAMETER_MAX_BANDWIDTH),
444444
params->max_bandwidth);
445445
assert(params->has_downtime_limit);
446-
monitor_printf(mon, "%s: %" PRIu64 " milliseconds\n",
446+
monitor_printf(mon, "%s: %" PRIu64 " ms\n",
447447
MigrationParameter_str(MIGRATION_PARAMETER_DOWNTIME_LIMIT),
448448
params->downtime_limit);
449449
assert(params->has_x_checkpoint_delay);
450-
monitor_printf(mon, "%s: %u\n",
450+
monitor_printf(mon, "%s: %u ms\n",
451451
MigrationParameter_str(MIGRATION_PARAMETER_X_CHECKPOINT_DELAY),
452452
params->x_checkpoint_delay);
453453
assert(params->has_block_incremental);
@@ -460,7 +460,7 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict)
460460
monitor_printf(mon, "%s: %s\n",
461461
MigrationParameter_str(MIGRATION_PARAMETER_MULTIFD_COMPRESSION),
462462
MultiFDCompression_str(params->multifd_compression));
463-
monitor_printf(mon, "%s: %" PRIu64 "\n",
463+
monitor_printf(mon, "%s: %" PRIu64 " bytes\n",
464464
MigrationParameter_str(MIGRATION_PARAMETER_XBZRLE_CACHE_SIZE),
465465
params->xbzrle_cache_size);
466466
monitor_printf(mon, "%s: %" PRIu64 "\n",
@@ -1189,8 +1189,11 @@ void hmp_migrate_pause(Monitor *mon, const QDict *qdict)
11891189
/* Kept for backwards compatibility */
11901190
void hmp_migrate_set_downtime(Monitor *mon, const QDict *qdict)
11911191
{
1192+
Error *err = NULL;
1193+
11921194
double value = qdict_get_double(qdict, "value");
1193-
qmp_migrate_set_downtime(value, NULL);
1195+
qmp_migrate_set_downtime(value, &err);
1196+
hmp_handle_error(mon, err);
11941197
}
11951198

11961199
void hmp_migrate_set_cache_size(Monitor *mon, const QDict *qdict)
@@ -1499,8 +1502,7 @@ void hmp_change(Monitor *mon, const QDict *qdict)
14991502
read_only,
15001503
BLOCKDEV_CHANGE_READ_ONLY_MODE_RETAIN, &err);
15011504
if (err) {
1502-
hmp_handle_error(mon, err);
1503-
return;
1505+
goto end;
15041506
}
15051507
}
15061508

@@ -1509,6 +1511,7 @@ void hmp_change(Monitor *mon, const QDict *qdict)
15091511
&err);
15101512
}
15111513

1514+
end:
15121515
hmp_handle_error(mon, err);
15131516
}
15141517

@@ -1627,16 +1630,15 @@ void hmp_object_add(Monitor *mon, const QDict *qdict)
16271630

16281631
opts = qemu_opts_from_qdict(qemu_find_opts("object"), qdict, &err);
16291632
if (err) {
1630-
hmp_handle_error(mon, err);
1631-
return;
1633+
goto end;
16321634
}
16331635

16341636
obj = user_creatable_add_opts(opts, &err);
16351637
qemu_opts_del(opts);
16361638

1637-
if (err) {
1638-
hmp_handle_error(mon, err);
1639-
}
1639+
end:
1640+
hmp_handle_error(mon, err);
1641+
16401642
if (obj) {
16411643
object_unref(obj);
16421644
}

qom/qom-hmp-cmds.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,15 +44,27 @@ void hmp_qom_list(Monitor *mon, const QDict *qdict)
4444

4545
void hmp_qom_set(Monitor *mon, const QDict *qdict)
4646
{
47+
const bool json = qdict_get_try_bool(qdict, "json", false);
4748
const char *path = qdict_get_str(qdict, "path");
4849
const char *property = qdict_get_str(qdict, "property");
4950
const char *value = qdict_get_str(qdict, "value");
5051
Error *err = NULL;
51-
QObject *obj;
5252

53-
obj = qobject_from_json(value, &err);
54-
if (err == NULL) {
55-
qmp_qom_set(path, property, obj, &err);
53+
if (!json) {
54+
Object *obj = object_resolve_path(path, NULL);
55+
56+
if (!obj) {
57+
error_set(&err, ERROR_CLASS_DEVICE_NOT_FOUND,
58+
"Device '%s' not found", path);
59+
} else {
60+
object_property_parse(obj, value, property, &err);
61+
}
62+
} else {
63+
QObject *obj = qobject_from_json(value, &err);
64+
65+
if (!err) {
66+
qmp_qom_set(path, property, obj, &err);
67+
}
5668
}
5769

5870
hmp_handle_error(mon, err);
@@ -71,6 +83,7 @@ void hmp_qom_get(Monitor *mon, const QDict *qdict)
7183
qobject_unref(str);
7284
}
7385

86+
qobject_unref(obj);
7487
hmp_handle_error(mon, err);
7588
}
7689

tests/migration/stress.c

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -167,29 +167,17 @@ static unsigned long long now(void)
167167
return (tv.tv_sec * 1000ull) + (tv.tv_usec / 1000ull);
168168
}
169169

170-
static int stressone(unsigned long long ramsizeMB)
170+
static void stressone(unsigned long long ramsizeMB)
171171
{
172172
size_t pagesPerMB = 1024 * 1024 / PAGE_SIZE;
173-
char *ram = malloc(ramsizeMB * 1024 * 1024);
173+
g_autofree char *ram = g_malloc(ramsizeMB * 1024 * 1024);
174174
char *ramptr;
175175
size_t i, j, k;
176-
char *data = malloc(PAGE_SIZE);
176+
g_autofree char *data = g_malloc(PAGE_SIZE);
177177
char *dataptr;
178178
size_t nMB = 0;
179179
unsigned long long before, after;
180180

181-
if (!ram) {
182-
fprintf(stderr, "%s (%05d): ERROR: cannot allocate %llu MB of RAM: %s\n",
183-
argv0, gettid(), ramsizeMB, strerror(errno));
184-
return -1;
185-
}
186-
if (!data) {
187-
fprintf(stderr, "%s (%d): ERROR: cannot allocate %d bytes of RAM: %s\n",
188-
argv0, gettid(), PAGE_SIZE, strerror(errno));
189-
free(ram);
190-
return -1;
191-
}
192-
193181
/* We don't care about initial state, but we do want
194182
* to fault it all into RAM, otherwise the first iter
195183
* of the loop below will be quite slow. We can't use
@@ -198,9 +186,7 @@ static int stressone(unsigned long long ramsizeMB)
198186
memset(ram, 0xfe, ramsizeMB * 1024 * 1024);
199187

200188
if (random_bytes(data, PAGE_SIZE) < 0) {
201-
free(ram);
202-
free(data);
203-
return -1;
189+
return;
204190
}
205191

206192
before = now();
@@ -227,9 +213,6 @@ static int stressone(unsigned long long ramsizeMB)
227213
}
228214
}
229215
}
230-
231-
free(data);
232-
free(ram);
233216
}
234217

235218

@@ -242,7 +225,7 @@ static void *stressthread(void *arg)
242225
return NULL;
243226
}
244227

245-
static int stress(unsigned long long ramsizeGB, int ncpus)
228+
static void stress(unsigned long long ramsizeGB, int ncpus)
246229
{
247230
size_t i;
248231
unsigned long long ramsizeMB = ramsizeGB * 1024 / ncpus;
@@ -255,8 +238,6 @@ static int stress(unsigned long long ramsizeGB, int ncpus)
255238
}
256239

257240
stressone(ramsizeMB);
258-
259-
return 0;
260241
}
261242

262243

@@ -352,8 +333,7 @@ int main(int argc, char **argv)
352333
fprintf(stdout, "%s (%05d): INFO: RAM %llu GiB across %d CPUs\n",
353334
argv0, gettid(), ramsizeGB, ncpus);
354335

355-
if (stress(ramsizeGB, ncpus) < 0)
356-
exit_failure();
336+
stress(ramsizeGB, ncpus);
357337

358-
exit_success();
338+
exit_failure();
359339
}

tools/virtiofsd/seccomp.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,7 @@ static const int syscall_whitelist[] = {
4242
SCMP_SYS(exit_group),
4343
SCMP_SYS(fallocate),
4444
SCMP_SYS(fchdir),
45+
SCMP_SYS(fchmod),
4546
SCMP_SYS(fchmodat),
4647
SCMP_SYS(fchownat),
4748
SCMP_SYS(fcntl),

0 commit comments

Comments
 (0)