migration/next for 20161114

-----BEGIN PGP SIGNATURE-----
 
 iQIcBAABCAAGBQJYKha+AAoJEPSH7xhYctcjlssP/2/PClX0oB04jtggfaypocvn
 XugTm1GsS1OfaHkgsXYM7cakc0Tij4ZPYB/97itdEVdcpUhiElH0k2Nxsj2RoPx+
 8yBUS7sbY0g9E06QzQSUe07iBGlRTmfL3hb/0hjDKLBCRPz5g5LIU+SP4kAtoAXR
 LLypk1EgvrxqOD7Jj7FSCEF38xJgJQULv9xVjWvtO5Kg0jd9x6vWd+9XBvG562E7
 2N03LXA63pM5yY7K6H5Ppuz8ha6nSVjlF2NcRTq6CSMLR8dvnCO5lC5VhVEfIViH
 vBpN3GdUUARH+MMVOcSVI3dgsAEhh1HdPiwdHYXXvaNsoU+rluFP0uowaK9dtn8c
 VJ219cXRrUHMYStruWLlsiUTSGdfY3t3vQkXZVY4SS7H+mqpysPoP4Iv9VIqhgon
 ausUUGhf1HDHMGkLe6kJ6g+YaA9wV+HfL8/e3eQRDbMP0usK/AKyrHQhU14coSZH
 oEaSOlcR8qNMYFS+oKuUmd7v8+VN6z0o7HDX2WAJM0lmZG5lQl5/Yj0OOhq3XQZr
 Q60/nt2vVp8cmRlfmStimAZz8ko5wEPnJH5s7gZR/7HrFh+P6LXSSolEBGvrlBKI
 eZyZjykKpvV1uyklp64cHg/TtKz1jKokhZaddzy2p95mBoWgNTjaBBvqxfXBJs3c
 +Tm/a86OFCVV6vjeyVdn
 =+UNW
 -----END PGP SIGNATURE-----

Merge remote-tracking branch 'quintela/tags/migration/20161114' into staging

migration/next for 20161114

# gpg: Signature made Mon 14 Nov 2016 07:55:42 PM GMT
# gpg:                using RSA key 0xF487EF185872D723
# gpg: Good signature from "Juan Quintela <quintela@redhat.com>"
# gpg:                 aka "Juan Quintela <quintela@trasno.org>"
# Primary key fingerprint: 1899 FF8E DEBF 58CC EE03  4B82 F487 EF18 5872 D723

* quintela/tags/migration/20161114:
  migration: Fix return code of ram_save_iterate()
  tests/test-vmstate.c: add array of pointer to struct
  tests/test-vmstate.c: add save_buffer util func
  migration: fix missing assignment for has_x_checkpoint_delay

Message-id: 1479153474-2401-1-git-send-email-quintela@redhat.com
Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
Stefan Hajnoczi 2016-11-15 11:49:46 +00:00
commit 972d233b1d
4 changed files with 90 additions and 15 deletions

1
hmp.c
View File

@ -318,6 +318,7 @@ void hmp_info_migrate_parameters(Monitor *mon, const QDict *qdict)
monitor_printf(mon, " %s: %" PRId64 " milliseconds",
MigrationParameter_lookup[MIGRATION_PARAMETER_DOWNTIME_LIMIT],
params->downtime_limit);
assert(params->has_x_checkpoint_delay);
monitor_printf(mon, " %s: %" PRId64,
MigrationParameter_lookup[MIGRATION_PARAMETER_X_CHECKPOINT_DELAY],
params->x_checkpoint_delay);

View File

@ -593,6 +593,7 @@ MigrationParameters *qmp_query_migrate_parameters(Error **errp)
params->max_bandwidth = s->parameters.max_bandwidth;
params->has_downtime_limit = true;
params->downtime_limit = s->parameters.downtime_limit;
params->has_x_checkpoint_delay = true;
params->x_checkpoint_delay = s->parameters.x_checkpoint_delay;
return params;

View File

@ -1987,7 +1987,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque)
int ret;
int i;
int64_t t0;
int pages_sent = 0;
int done = 0;
rcu_read_lock();
if (ram_list.version != last_version) {
@ -2007,9 +2007,9 @@ static int ram_save_iterate(QEMUFile *f, void *opaque)
pages = ram_find_and_save_block(f, false, &bytes_transferred);
/* no more pages to sent */
if (pages == 0) {
done = 1;
break;
}
pages_sent += pages;
acct_info.iterations++;
/* we want to check in the 1st loop, just in case it was the 1st time
@ -2044,7 +2044,7 @@ static int ram_save_iterate(QEMUFile *f, void *opaque)
return ret;
}
return pages_sent;
return done;
}
/* Called with iothread lock */

View File

@ -83,6 +83,13 @@ static void save_vmstate(const VMStateDescription *desc, void *obj)
qemu_fclose(f);
}
static void save_buffer(const uint8_t *buf, size_t buf_size)
{
QEMUFile *fsave = open_test_file(true);
qemu_put_buffer(fsave, buf, buf_size);
qemu_fclose(fsave);
}
static void compare_vmstate(uint8_t *wire, size_t size)
{
QEMUFile *f = open_test_file(false);
@ -309,15 +316,13 @@ static const VMStateDescription vmstate_versioned = {
static void test_load_v1(void)
{
QEMUFile *fsave = open_test_file(true);
uint8_t buf[] = {
0, 0, 0, 10, /* a */
0, 0, 0, 30, /* c */
0, 0, 0, 0, 0, 0, 0, 40, /* d */
QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
};
qemu_put_buffer(fsave, buf, sizeof(buf));
qemu_fclose(fsave);
save_buffer(buf, sizeof(buf));
QEMUFile *loading = open_test_file(false);
TestStruct obj = { .b = 200, .e = 500, .f = 600 };
@ -334,7 +339,6 @@ static void test_load_v1(void)
static void test_load_v2(void)
{
QEMUFile *fsave = open_test_file(true);
uint8_t buf[] = {
0, 0, 0, 10, /* a */
0, 0, 0, 20, /* b */
@ -344,8 +348,7 @@ static void test_load_v2(void)
0, 0, 0, 0, 0, 0, 0, 60, /* f */
QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
};
qemu_put_buffer(fsave, buf, sizeof(buf));
qemu_fclose(fsave);
save_buffer(buf, sizeof(buf));
QEMUFile *loading = open_test_file(false);
TestStruct obj;
@ -423,7 +426,6 @@ static void test_save_skip(void)
static void test_load_noskip(void)
{
QEMUFile *fsave = open_test_file(true);
uint8_t buf[] = {
0, 0, 0, 10, /* a */
0, 0, 0, 20, /* b */
@ -433,8 +435,7 @@ static void test_load_noskip(void)
0, 0, 0, 0, 0, 0, 0, 60, /* f */
QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
};
qemu_put_buffer(fsave, buf, sizeof(buf));
qemu_fclose(fsave);
save_buffer(buf, sizeof(buf));
QEMUFile *loading = open_test_file(false);
TestStruct obj = { .skip_c_e = false };
@ -451,7 +452,6 @@ static void test_load_noskip(void)
static void test_load_skip(void)
{
QEMUFile *fsave = open_test_file(true);
uint8_t buf[] = {
0, 0, 0, 10, /* a */
0, 0, 0, 20, /* b */
@ -459,8 +459,7 @@ static void test_load_skip(void)
0, 0, 0, 0, 0, 0, 0, 60, /* f */
QEMU_VM_EOF, /* just to ensure we won't get EOF reported prematurely */
};
qemu_put_buffer(fsave, buf, sizeof(buf));
qemu_fclose(fsave);
save_buffer(buf, sizeof(buf));
QEMUFile *loading = open_test_file(false);
TestStruct obj = { .skip_c_e = true, .c = 300, .e = 500 };
@ -475,6 +474,76 @@ static void test_load_skip(void)
qemu_fclose(loading);
}
typedef struct {
int32_t i;
} TestStructTriv;
const VMStateDescription vmsd_tst = {
.name = "test/tst",
.version_id = 1,
.minimum_version_id = 1,
.fields = (VMStateField[]) {
VMSTATE_INT32(i, TestStructTriv),
VMSTATE_END_OF_LIST()
}
};
#define AR_SIZE 4
typedef struct {
TestStructTriv *ar[AR_SIZE];
} TestArrayOfPtrToStuct;
const VMStateDescription vmsd_arps = {
.name = "test/arps",
.version_id = 1,
.minimum_version_id = 1,
.fields = (VMStateField[]) {
VMSTATE_ARRAY_OF_POINTER_TO_STRUCT(ar, TestArrayOfPtrToStuct,
AR_SIZE, 0, vmsd_tst, TestStructTriv),
VMSTATE_END_OF_LIST()
}
};
static void test_arr_ptr_str_no0_save(void)
{
TestStructTriv ar[AR_SIZE] = {{.i = 0}, {.i = 1}, {.i = 2}, {.i = 3} };
TestArrayOfPtrToStuct sample = {.ar = {&ar[0], &ar[1], &ar[2], &ar[3]} };
uint8_t wire_sample[] = {
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x02,
0x00, 0x00, 0x00, 0x03,
QEMU_VM_EOF
};
save_vmstate(&vmsd_arps, &sample);
compare_vmstate(wire_sample, sizeof(wire_sample));
}
static void test_arr_ptr_str_no0_load(void)
{
TestStructTriv ar_gt[AR_SIZE] = {{.i = 0}, {.i = 1}, {.i = 2}, {.i = 3} };
TestStructTriv ar[AR_SIZE] = {};
TestArrayOfPtrToStuct obj = {.ar = {&ar[0], &ar[1], &ar[2], &ar[3]} };
int idx;
uint8_t wire_sample[] = {
0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x01,
0x00, 0x00, 0x00, 0x02,
0x00, 0x00, 0x00, 0x03,
QEMU_VM_EOF
};
save_buffer(wire_sample, sizeof(wire_sample));
SUCCESS(load_vmstate_one(&vmsd_arps, &obj, 1,
wire_sample, sizeof(wire_sample)));
for (idx = 0; idx < AR_SIZE; ++idx) {
/* compare the target array ar with the ground truth array ar_gt */
g_assert_cmpint(ar_gt[idx].i, ==, ar[idx].i);
}
}
int main(int argc, char **argv)
{
temp_fd = mkstemp(temp_file);
@ -489,6 +558,10 @@ int main(int argc, char **argv)
g_test_add_func("/vmstate/field_exists/load/skip", test_load_skip);
g_test_add_func("/vmstate/field_exists/save/noskip", test_save_noskip);
g_test_add_func("/vmstate/field_exists/save/skip", test_save_skip);
g_test_add_func("/vmstate/array/ptr/str/no0/save",
test_arr_ptr_str_no0_save);
g_test_add_func("/vmstate/array/ptr/str/no0/load",
test_arr_ptr_str_no0_load);
g_test_run();
close(temp_fd);