From nobody Wed Nov 12 00:13:36 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1566907643; cv=none; d=zoho.com; s=zohoarc; b=ay/wdKNqJTLGyqnP0hr8W0WC6KPFPmp0yVKvrHZYn3eKw+ZNuoQr0iEQfprDmc7m0kzAZC1x291qqCPwmLMgSEL+CQ/+LgR2d50OeLt2MEKuzUZjkbt7Ko+AvWSc2XsHOU836JFdF0USeFBsnfOK8dvmgd9ZDG1rwJszbqj47iQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566907643; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=eI60cSbvKTxAVIg6kdg5P/da2dJGMrSEwCMVL8oEclU=; b=XwlegLojpJX9bv/AXs8lr3cDYGNutu2NBXBhDi0D7D23Jnec8spTiuE3f7DJEP0JpvyDmc3PXI2DMOg7rXrc3I0BzhxE+fCcT1tykMCBpjX2YnJnH+Phyd7yaQLs3h6BqJT3gOfoR6HNX5f92yi/i15H6TusrJXtGmuZOFtuuFM= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1566907643674187.12561804453458; Tue, 27 Aug 2019 05:07:23 -0700 (PDT) Received: from localhost ([::1]:50446 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2aFt-0005KV-Ue for importer@patchew.org; Tue, 27 Aug 2019 08:07:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46257) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2aBM-0001v5-G3 for qemu-devel@nongnu.org; Tue, 27 Aug 2019 08:02:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2aBI-0003Yz-IR for qemu-devel@nongnu.org; Tue, 27 Aug 2019 08:02:37 -0400 Received: from forwardcorp1j.mail.yandex.net ([5.45.199.163]:57810) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i2aBH-0003XX-TV for qemu-devel@nongnu.org; Tue, 27 Aug 2019 08:02:36 -0400 Received: from mxbackcorp2j.mail.yandex.net (mxbackcorp2j.mail.yandex.net [IPv6:2a02:6b8:0:1619::119]) by forwardcorp1j.mail.yandex.net (Yandex) with ESMTP id 21C592E14E7; Tue, 27 Aug 2019 15:02:31 +0300 (MSK) Received: from smtpcorp1j.mail.yandex.net (smtpcorp1j.mail.yandex.net [2a02:6b8:0:1619::137]) by mxbackcorp2j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id i2mC3ndqu0-2UJub6im; Tue, 27 Aug 2019 15:02:31 +0300 Received: from dynamic-red.dhcp.yndx.net (dynamic-red.dhcp.yndx.net [2a02:6b8:0:408:dc67:69ff:2705:c046]) by smtpcorp1j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 2qbfJ2c4Zu-2U6Kudm9; Tue, 27 Aug 2019 15:02:30 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) Precedence: bulk DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1566907351; bh=dCSJPbZU+iZN5gqAcnyu3r4bAMAkilM+jDdJjIk646U=; h=In-Reply-To:Message-Id:References:Date:Subject:To:From:Cc; b=tm/AqYZuqN4vav/b/inlLsVcIuL08FbNNzz8HWFAPFBh/KQ+4158olOfLa+uDCHnn rjOk2eD0CeLUXfSbVSJNrAuHTO2Mc5puixFpjTy1DCKjYSNAAVpxm+Jx89SKjoXE5D Vh0F9e6UE1YCx7pHFY1HlcfXrv/oAcm0URgYmcz8= Authentication-Results: mxbackcorp2j.mail.yandex.net; dkim=pass header.i=@yandex-team.ru From: Yury Kotov To: Juan Quintela , "Dr. David Alan Gilbert" , Eric Blake , Markus Armbruster , Thomas Huth , Laurent Vivier , Paolo Bonzini Date: Tue, 27 Aug 2019 15:02:19 +0300 Message-Id: <20190827120221.15725-2-yury-kotov@yandex-team.ru> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190827120221.15725-1-yury-kotov@yandex-team.ru> References: <20190827120221.15725-1-yury-kotov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 5.45.199.163 Subject: [Qemu-devel] [PATCH 1/3] migration: Add x-validate-uuid capability X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "open list:All patches CC here" , yc-core@yandex-team.ru Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" This capability realizes simple source validation by UUID. It's useful for live migration between hosts. Signed-off-by: Yury Kotov --- migration/migration.c | 9 +++++++++ migration/migration.h | 1 + migration/savevm.c | 45 +++++++++++++++++++++++++++++++++++++++++++ qapi/migration.json | 5 ++++- 4 files changed, 59 insertions(+), 1 deletion(-) diff --git a/migration/migration.c b/migration/migration.c index 8b9f2fe30a..910e11b7d7 100644 --- a/migration/migration.c +++ b/migration/migration.c @@ -2140,6 +2140,15 @@ bool migrate_ignore_shared(void) return s->enabled_capabilities[MIGRATION_CAPABILITY_X_IGNORE_SHARED]; } =20 +bool migrate_validate_uuid(void) +{ + MigrationState *s; + + s =3D migrate_get_current(); + + return s->enabled_capabilities[MIGRATION_CAPABILITY_X_VALIDATE_UUID]; +} + bool migrate_use_events(void) { MigrationState *s; diff --git a/migration/migration.h b/migration/migration.h index 3e1ea2b5dc..4f2fe193dc 100644 --- a/migration/migration.h +++ b/migration/migration.h @@ -290,6 +290,7 @@ bool migrate_postcopy_ram(void); bool migrate_zero_blocks(void); bool migrate_dirty_bitmaps(void); bool migrate_ignore_shared(void); +bool migrate_validate_uuid(void); =20 bool migrate_auto_converge(void); bool migrate_use_multifd(void); diff --git a/migration/savevm.c b/migration/savevm.c index 4a86128ac4..493dc24fd2 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -256,6 +256,7 @@ typedef struct SaveState { uint32_t target_page_bits; uint32_t caps_count; MigrationCapability *capabilities; + QemuUUID uuid; } SaveState; =20 static SaveState savevm_state =3D { @@ -307,6 +308,7 @@ static int configuration_pre_save(void *opaque) state->capabilities[j++] =3D i; } } + state->uuid =3D qemu_uuid; =20 return 0; } @@ -464,6 +466,48 @@ static const VMStateDescription vmstate_capabilites = =3D { } }; =20 +static bool vmstate_uuid_needed(void *opaque) +{ + return qemu_uuid_set && migrate_validate_uuid(); +} + +static int vmstate_uuid_post_load(void *opaque, int version_id) +{ + SaveState *state =3D opaque; + char uuid_src[UUID_FMT_LEN + 1]; + char uuid_dst[UUID_FMT_LEN + 1]; + + if (!qemu_uuid_set) { + /* + * It's warning because user might not know UUID in some cases, + * e.g. load an old snapshot + */ + qemu_uuid_unparse(&state->uuid, uuid_src); + warn_report("UUID is received %s, but local uuid isn't set", + uuid_src); + return 0; + } + if (!qemu_uuid_is_equal(&state->uuid, &qemu_uuid)) { + qemu_uuid_unparse(&state->uuid, uuid_src); + qemu_uuid_unparse(&qemu_uuid, uuid_dst); + error_report("UUID received is %s and local is %s", uuid_src, uuid= _dst); + return -EINVAL; + } + return 0; +} + +static const VMStateDescription vmstate_uuid =3D { + .name =3D "configuration/uuid", + .version_id =3D 1, + .minimum_version_id =3D 1, + .needed =3D vmstate_uuid_needed, + .post_load =3D vmstate_uuid_post_load, + .fields =3D (VMStateField[]) { + VMSTATE_UINT8_ARRAY_V(uuid.data, SaveState, sizeof(QemuUUID), 1), + VMSTATE_END_OF_LIST() + } +}; + static const VMStateDescription vmstate_configuration =3D { .name =3D "configuration", .version_id =3D 1, @@ -478,6 +522,7 @@ static const VMStateDescription vmstate_configuration = =3D { .subsections =3D (const VMStateDescription*[]) { &vmstate_target_page_bits, &vmstate_capabilites, + &vmstate_uuid, NULL } }; diff --git a/qapi/migration.json b/qapi/migration.json index 9cfbaf8c6c..b7a8064745 100644 --- a/qapi/migration.json +++ b/qapi/migration.json @@ -415,6 +415,9 @@ # # @x-ignore-shared: If enabled, QEMU will not migrate shared memory (since= 4.0) # +# @x-validate-uuid: Check whether the UUID is the same on both sides or no= t. +# (since 4.2) +# # Since: 1.2 ## { 'enum': 'MigrationCapability', @@ -422,7 +425,7 @@ 'compress', 'events', 'postcopy-ram', 'x-colo', 'release-ram', 'block', 'return-path', 'pause-before-switchover', 'multifd', 'dirty-bitmaps', 'postcopy-blocktime', 'late-block-activate', - 'x-ignore-shared' ] } + 'x-ignore-shared', 'x-validate-uuid' ] } =20 ## # @MigrationCapabilityStatus: --=20 2.22.0 From nobody Wed Nov 12 00:13:36 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1566907842; cv=none; d=zoho.com; s=zohoarc; b=fTJyTCSTz/DicDqfeOLeNjet+bEAa/6PObG3wdvc4OHwJMRtPa9OQ033emp+OSnlChUgTKzPPR59yo++W7iiFElUfXXEMHMKwpTqHRnaH2YTBetvGlHdMC3pRCY5qY2bKWauL5xahsQ04aGX1s6oM6gfmI6mCjaX6D9BtLVSYwY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566907842; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=QlXz0sSFuiqirwFHEdJBJkF2e5oxpFe/dtOGsufqAFo=; b=Xp94O86NojgszMJRj/XBnXusn21vWKv/CPBVEFTQAjHHOKYn3ShWgdcFdVQSHd7kFsbmj1TskL27wS7k+i1V9f44WQ4K5nwi4g4xPi953KLF7SE81PQtpg+rKMJEUktIdJWtoREu8X6V5diXzjn1iQ953FZRFl864tUP8ufhIX8= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1566907842654726.8524369716891; Tue, 27 Aug 2019 05:10:42 -0700 (PDT) Received: from localhost ([::1]:50544 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2aJ7-0000qn-CD for importer@patchew.org; Tue, 27 Aug 2019 08:10:41 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46262) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2aBM-0001vN-IK for qemu-devel@nongnu.org; Tue, 27 Aug 2019 08:02:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2aBI-0003Z4-Ip for qemu-devel@nongnu.org; Tue, 27 Aug 2019 08:02:38 -0400 Received: from forwardcorp1j.mail.yandex.net ([5.45.199.163]:57822) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i2aBI-0003Xg-49 for qemu-devel@nongnu.org; Tue, 27 Aug 2019 08:02:36 -0400 Received: from mxbackcorp1g.mail.yandex.net (mxbackcorp1g.mail.yandex.net [IPv6:2a02:6b8:0:1402::301]) by forwardcorp1j.mail.yandex.net (Yandex) with ESMTP id D406F2E14EF; Tue, 27 Aug 2019 15:02:31 +0300 (MSK) Received: from smtpcorp1j.mail.yandex.net (smtpcorp1j.mail.yandex.net [2a02:6b8:0:1619::137]) by mxbackcorp1g.mail.yandex.net (nwsmtp/Yandex) with ESMTP id 1xQj1W69MZ-2VJqimte; Tue, 27 Aug 2019 15:02:31 +0300 Received: from dynamic-red.dhcp.yndx.net (dynamic-red.dhcp.yndx.net [2a02:6b8:0:408:dc67:69ff:2705:c046]) by smtpcorp1j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 2qbfJ2c4Zu-2V6KCSKX; Tue, 27 Aug 2019 15:02:31 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) Precedence: bulk DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1566907351; bh=rjNZZ+XG5CcNkF0t6gN4egiScU4pZsE9TvlPlTSTsdk=; h=In-Reply-To:Message-Id:References:Date:Subject:To:From:Cc; b=PNkZGCRcXRLD3yp3hftWGJVvbJJPJ/nAPR14r913odENmG2rXZs1INt9uqlCAVy5e lMIPrKwWyTwdMzleBGg5T+4B6E8Bwm02KuLK75Uwn9x60DvBueEi/Ug820NPi0rShy zLCYmrzZ9rVaTXNa9z7lZObr3EfOy1s0iO9+s5zo= Authentication-Results: mxbackcorp1g.mail.yandex.net; dkim=pass header.i=@yandex-team.ru From: Yury Kotov To: Juan Quintela , "Dr. David Alan Gilbert" , Eric Blake , Markus Armbruster , Thomas Huth , Laurent Vivier , Paolo Bonzini Date: Tue, 27 Aug 2019 15:02:20 +0300 Message-Id: <20190827120221.15725-3-yury-kotov@yandex-team.ru> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190827120221.15725-1-yury-kotov@yandex-team.ru> References: <20190827120221.15725-1-yury-kotov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 5.45.199.163 Subject: [Qemu-devel] [PATCH 2/3] tests/libqtest: Allow to set expected exit status X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "open list:All patches CC here" , yc-core@yandex-team.ru Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Add qtest_set_expected_status function to set expected exit status of child process. By default expected exit status is 0. Signed-off-by: Yury Kotov --- tests/libqtest.c | 14 +++++++++++--- tests/libqtest.h | 9 +++++++++ 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/tests/libqtest.c b/tests/libqtest.c index 2713b86cf7..118d779c1b 100644 --- a/tests/libqtest.c +++ b/tests/libqtest.c @@ -43,6 +43,7 @@ struct QTestState int qmp_fd; pid_t qemu_pid; /* our child QEMU process */ int wstatus; + int expected_status; bool big_endian; bool irq_level[MAX_IRQ]; GString *rx; @@ -113,6 +114,11 @@ bool qtest_probe_child(QTestState *s) return false; } =20 +void qtest_set_expected_status(QTestState *s, int status) +{ + s->expected_status =3D status; +} + static void kill_qemu(QTestState *s) { pid_t pid =3D s->qemu_pid; @@ -130,11 +136,12 @@ static void kill_qemu(QTestState *s) * fishy and should be logged with as much detail as possible. */ wstatus =3D s->wstatus; - if (wstatus) { + if (WEXITSTATUS(wstatus) !=3D s->expected_status) { if (WIFEXITED(wstatus)) { fprintf(stderr, "%s:%d: kill_qemu() tried to terminate QEMU " - "process but encountered exit status %d\n", - __FILE__, __LINE__, WEXITSTATUS(wstatus)); + "process but encountered exit status %d (expected %d)\= n", + __FILE__, __LINE__, WEXITSTATUS(wstatus), + s->expected_status); } else if (WIFSIGNALED(wstatus)) { int sig =3D WTERMSIG(wstatus); const char *signame =3D strsignal(sig) ?: "unknown ???"; @@ -248,6 +255,7 @@ QTestState *qtest_init_without_qmp_handshake(const char= *extra_args) g_test_message("starting QEMU: %s", command); =20 s->wstatus =3D 0; + s->expected_status =3D 0; s->qemu_pid =3D fork(); if (s->qemu_pid =3D=3D 0) { setenv("QEMU_AUDIO_DRV", "none", true); diff --git a/tests/libqtest.h b/tests/libqtest.h index 07ea35867c..c00bca94af 100644 --- a/tests/libqtest.h +++ b/tests/libqtest.h @@ -997,4 +997,13 @@ void qmp_assert_error_class(QDict *rsp, const char *cl= ass); */ bool qtest_probe_child(QTestState *s); =20 +/** + * qtest_set_expected_status: + * @s: QTestState instance to operate on. + * @status: an expected exit status. + * + * Set expected exit status of the child. + */ +void qtest_set_expected_status(QTestState *s, int status); + #endif --=20 2.22.0 From nobody Wed Nov 12 00:13:36 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail(p=none dis=none) header.from=yandex-team.ru ARC-Seal: i=1; a=rsa-sha256; t=1566907665; cv=none; d=zoho.com; s=zohoarc; b=Py8Nb7Eb5ICFTJ75rWBKcSHAt+d3v0xcFAdxGqkd7Qi+wiRgnQGMba0acRk4V8Y6q3L8SspRlYKTZjNRojxefFecAws3l0q5kEG50ly4gBNrrP6hYvz28Vh7Ttsnc/dbx+yKEqSR47wh2huD7Ipy64ZE7sSsuTfBTXYgDQj2QoQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566907665; h=Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=mmqb4S0iN4bai6myuyX+mERVbBrzboIBB/9kpYphXbE=; b=OKhzH32cdptGdgtbVJN+AAo/mQIOn8BClW3BX4Poe5VGg3ZQw83Jfsh5oPqgfHbGl9ShScZ25RSGo4NTqz0eBcWT6pgjspjFnVMcihAzCthHhJnLAkqqd6BLR45uu3s4UeN7sq6ayiyFcE3SN2K5B3/E34VJd9Wt2LmZ5lgv6J4= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1566907665383467.74152197099147; Tue, 27 Aug 2019 05:07:45 -0700 (PDT) Received: from localhost ([::1]:50502 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2aGF-0005ku-Ns for importer@patchew.org; Tue, 27 Aug 2019 08:07:43 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:46264) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1i2aBN-0001vn-1n for qemu-devel@nongnu.org; Tue, 27 Aug 2019 08:02:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1i2aBI-0003Yo-Gy for qemu-devel@nongnu.org; Tue, 27 Aug 2019 08:02:39 -0400 Received: from forwardcorp1o.mail.yandex.net ([95.108.205.193]:46742) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1i2aBH-0003Xy-NQ for qemu-devel@nongnu.org; Tue, 27 Aug 2019 08:02:36 -0400 Received: from mxbackcorp2j.mail.yandex.net (mxbackcorp2j.mail.yandex.net [IPv6:2a02:6b8:0:1619::119]) by forwardcorp1o.mail.yandex.net (Yandex) with ESMTP id 835EC2E14FF; Tue, 27 Aug 2019 15:02:32 +0300 (MSK) Received: from smtpcorp1j.mail.yandex.net (smtpcorp1j.mail.yandex.net [2a02:6b8:0:1619::137]) by mxbackcorp2j.mail.yandex.net (nwsmtp/Yandex) with ESMTP id MbCpUx1oXu-2WJeUEAj; Tue, 27 Aug 2019 15:02:32 +0300 Received: from dynamic-red.dhcp.yndx.net (dynamic-red.dhcp.yndx.net [2a02:6b8:0:408:dc67:69ff:2705:c046]) by smtpcorp1j.mail.yandex.net (nwsmtp/Yandex) with ESMTPSA id 2qbfJ2c4Zu-2V6KFuSu; Tue, 27 Aug 2019 15:02:32 +0300 (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits)) (Client certificate not present) Precedence: bulk DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yandex-team.ru; s=default; t=1566907352; bh=zPzwlwhlwtvv/WeaObMF2wTPZahOtB6IK6Iib2JYHxI=; h=In-Reply-To:Message-Id:References:Date:Subject:To:From:Cc; b=HxNrneshfez1hK3ga0ol0KLRdTlAZeTGYvm7CGiHmoCFQg+fm5v83u3p1SntxbiDN P5LA23QTa9LRkwHv1n1MHhWmnIzxgtB0aqwQ2FdNyhBf1widIVvt+hz9ssyMyCBE4R 1mMTfNDdwv6A9/V8UZSBz4YoQvmeUWjF4cAqIz4U= Authentication-Results: mxbackcorp2j.mail.yandex.net; dkim=pass header.i=@yandex-team.ru From: Yury Kotov To: Juan Quintela , "Dr. David Alan Gilbert" , Eric Blake , Markus Armbruster , Thomas Huth , Laurent Vivier , Paolo Bonzini Date: Tue, 27 Aug 2019 15:02:21 +0300 Message-Id: <20190827120221.15725-4-yury-kotov@yandex-team.ru> X-Mailer: git-send-email 2.22.0 In-Reply-To: <20190827120221.15725-1-yury-kotov@yandex-team.ru> References: <20190827120221.15725-1-yury-kotov@yandex-team.ru> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 95.108.205.193 Subject: [Qemu-devel] [PATCH 3/3] tests/migration: Add a test for x-validate-uuid capability X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "open list:All patches CC here" , yc-core@yandex-team.ru Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" Signed-off-by: Yury Kotov --- tests/migration-test.c | 140 ++++++++++++++++++++++++++++++++--------- 1 file changed, 110 insertions(+), 30 deletions(-) diff --git a/tests/migration-test.c b/tests/migration-test.c index b87ba99a9e..adac1c01a2 100644 --- a/tests/migration-test.c +++ b/tests/migration-test.c @@ -512,7 +512,8 @@ static void migrate_postcopy_start(QTestState *from, QT= estState *to) =20 static int test_migrate_start(QTestState **from, QTestState **to, const char *uri, bool hide_stderr, - bool use_shmem) + bool use_shmem, const char *opts_src, + const char *opts_dst) { gchar *cmd_src, *cmd_dst; char *bootpath =3D NULL; @@ -521,6 +522,9 @@ static int test_migrate_start(QTestState **from, QTestS= tate **to, const char *arch =3D qtest_get_arch(); const char *accel =3D "kvm:tcg"; =20 + opts_src =3D opts_src ? opts_src : ""; + opts_dst =3D opts_dst ? opts_dst : ""; + if (use_shmem) { if (!g_file_test("/dev/shm", G_FILE_TEST_IS_DIR)) { g_test_skip("/dev/shm is not supported"); @@ -539,16 +543,16 @@ static int test_migrate_start(QTestState **from, QTes= tState **to, cmd_src =3D g_strdup_printf("-machine accel=3D%s -m 150M" " -name source,debug-threads=3Don" " -serial file:%s/src_serial" - " -drive file=3D%s,format=3Draw %s", + " -drive file=3D%s,format=3Draw %s %s", accel, tmpfs, bootpath, - extra_opts ? extra_opts : ""); + extra_opts ? extra_opts : "", opts_src); cmd_dst =3D g_strdup_printf("-machine accel=3D%s -m 150M" " -name target,debug-threads=3Don" " -serial file:%s/dest_serial" " -drive file=3D%s,format=3Draw" - " -incoming %s %s", + " -incoming %s %s %s", accel, tmpfs, bootpath, uri, - extra_opts ? extra_opts : ""); + extra_opts ? extra_opts : "", opts_dst); start_address =3D X86_TEST_MEM_START; end_address =3D X86_TEST_MEM_END; } else if (g_str_equal(arch, "s390x")) { @@ -556,15 +560,15 @@ static int test_migrate_start(QTestState **from, QTes= tState **to, extra_opts =3D use_shmem ? get_shmem_opts("128M", shmem_path) : NU= LL; cmd_src =3D g_strdup_printf("-machine accel=3D%s -m 128M" " -name source,debug-threads=3Don" - " -serial file:%s/src_serial -bios %s %s= ", + " -serial file:%s/src_serial -bios %s %s= %s", accel, tmpfs, bootpath, - extra_opts ? extra_opts : ""); + extra_opts ? extra_opts : "", opts_src); cmd_dst =3D g_strdup_printf("-machine accel=3D%s -m 128M" " -name target,debug-threads=3Don" " -serial file:%s/dest_serial -bios %s" - " -incoming %s %s", + " -incoming %s %s %s", accel, tmpfs, bootpath, uri, - extra_opts ? extra_opts : ""); + extra_opts ? extra_opts : "", opts_dst); start_address =3D S390_TEST_MEM_START; end_address =3D S390_TEST_MEM_END; } else if (strcmp(arch, "ppc64") =3D=3D 0) { @@ -575,14 +579,15 @@ static int test_migrate_start(QTestState **from, QTes= tState **to, " -prom-env 'use-nvramrc?=3Dtrue' -prom-= env " "'nvramrc=3Dhex .\" _\" begin %x %x " "do i c@ 1 + i c! 1000 +loop .\" B\" 0 " - "until' %s", accel, tmpfs, end_address, - start_address, extra_opts ? extra_opts := ""); + "until' %s %s", accel, tmpfs, end_addre= ss, + start_address, extra_opts ? extra_opts := "", + opts_src); cmd_dst =3D g_strdup_printf("-machine accel=3D%s -m 256M" " -name target,debug-threads=3Don" " -serial file:%s/dest_serial" - " -incoming %s %s", + " -incoming %s %s %s", accel, tmpfs, uri, - extra_opts ? extra_opts : ""); + extra_opts ? extra_opts : "", opts_dst); =20 start_address =3D PPC_TEST_MEM_START; end_address =3D PPC_TEST_MEM_END; @@ -592,16 +597,16 @@ static int test_migrate_start(QTestState **from, QTes= tState **to, cmd_src =3D g_strdup_printf("-machine virt,accel=3D%s,gic-version= =3Dmax " "-name vmsource,debug-threads=3Don -cpu = max " "-m 150M -serial file:%s/src_serial " - "-kernel %s %s", + "-kernel %s %s %s", accel, tmpfs, bootpath, - extra_opts ? extra_opts : ""); + extra_opts ? extra_opts : "", opts_src); cmd_dst =3D g_strdup_printf("-machine virt,accel=3D%s,gic-version= =3Dmax " "-name vmdest,debug-threads=3Don -cpu ma= x " "-m 150M -serial file:%s/dest_serial " "-kernel %s " - "-incoming %s %s", + "-incoming %s %s %s", accel, tmpfs, bootpath, uri, - extra_opts ? extra_opts : ""); + extra_opts ? extra_opts : "", opts_dst); =20 start_address =3D ARM_TEST_MEM_START; end_address =3D ARM_TEST_MEM_END; @@ -731,7 +736,7 @@ static int migrate_postcopy_prepare(QTestState **from_p= tr, char *uri =3D g_strdup_printf("unix:%s/migsocket", tmpfs); QTestState *from, *to; =20 - if (test_migrate_start(&from, &to, uri, hide_error, false)) { + if (test_migrate_start(&from, &to, uri, hide_error, false, NULL, NULL)= ) { return -1; } =20 @@ -841,20 +846,16 @@ static void test_postcopy_recovery(void) migrate_postcopy_complete(from, to); } =20 -static void test_baddest(void) +static void wait_for_migration_fail(QTestState *from, bool allow_active) { - QTestState *from, *to; QDict *rsp_return; char *status; bool failed; =20 - if (test_migrate_start(&from, &to, "tcp:0:0", true, false)) { - return; - } - migrate(from, "tcp:0:0", "{}"); do { status =3D migrate_query_status(from); - g_assert(!strcmp(status, "setup") || !(strcmp(status, "failed"))); + g_assert(!strcmp(status, "setup") || !strcmp(status, "failed") || + (allow_active && !strcmp(status, "active"))); failed =3D !strcmp(status, "failed"); g_free(status); } while (!failed); @@ -864,7 +865,17 @@ static void test_baddest(void) g_assert(qdict_haskey(rsp_return, "running")); g_assert(qdict_get_bool(rsp_return, "running")); qobject_unref(rsp_return); +} + +static void test_baddest(void) +{ + QTestState *from, *to; =20 + if (test_migrate_start(&from, &to, "tcp:0:0", true, false, NULL, NULL)= ) { + return; + } + migrate(from, "tcp:0:0", "{}"); + wait_for_migration_fail(from, false); test_migrate_end(from, to, false); } =20 @@ -873,7 +884,7 @@ static void test_precopy_unix(void) char *uri =3D g_strdup_printf("unix:%s/migsocket", tmpfs); QTestState *from, *to; =20 - if (test_migrate_start(&from, &to, uri, false, false)) { + if (test_migrate_start(&from, &to, uri, false, false, NULL, NULL)) { return; } =20 @@ -916,7 +927,7 @@ static void test_ignore_shared(void) char *uri =3D g_strdup_printf("unix:%s/migsocket", tmpfs); QTestState *from, *to; =20 - if (test_migrate_start(&from, &to, uri, false, true)) { + if (test_migrate_start(&from, &to, uri, false, true, NULL, NULL)) { return; } =20 @@ -951,7 +962,7 @@ static void test_xbzrle(const char *uri) { QTestState *from, *to; =20 - if (test_migrate_start(&from, &to, uri, false, false)) { + if (test_migrate_start(&from, &to, uri, false, false, NULL, NULL)) { return; } =20 @@ -1003,7 +1014,8 @@ static void test_precopy_tcp(void) char *uri; QTestState *from, *to; =20 - if (test_migrate_start(&from, &to, "tcp:127.0.0.1:0", false, false)) { + if (test_migrate_start(&from, &to, "tcp:127.0.0.1:0", false, false, + NULL, NULL)) { return; } =20 @@ -1049,7 +1061,7 @@ static void test_migrate_fd_proto(void) QDict *rsp; const char *error_desc; =20 - if (test_migrate_start(&from, &to, "defer", false, false)) { + if (test_migrate_start(&from, &to, "defer", false, false, NULL, NULL))= { return; } =20 @@ -1125,6 +1137,68 @@ static void test_migrate_fd_proto(void) test_migrate_end(from, to, true); } =20 +static void do_test_validate_uuid(const char *uuid_arg_src, + const char *uuid_arg_dst, + bool should_fail, bool hide_stderr) +{ + char *uri =3D g_strdup_printf("unix:%s/migsocket", tmpfs); + QTestState *from, *to; + + if (test_migrate_start(&from, &to, uri, hide_stderr, false, + uuid_arg_src, uuid_arg_dst)) { + return; + } + + /* + * UUID validation is at the begin of migration. So, the main process = of + * migration is not interesting for us here. Thus, set huge downtime f= or + * very fast migration. + */ + migrate_set_parameter_int(from, "downtime-limit", 1000000); + migrate_set_capability(from, "x-validate-uuid", true); + + /* Wait for the first serial output from the source */ + wait_for_serial("src_serial"); + + migrate(from, uri, "{}"); + + if (should_fail) { + qtest_set_expected_status(to, 1); + wait_for_migration_fail(from, true); + } else { + wait_for_migration_complete(from); + } + + test_migrate_end(from, to, false); + g_free(uri); +} + +static void test_validate_uuid(void) +{ + do_test_validate_uuid("-uuid 11111111-1111-1111-1111-111111111111", + "-uuid 11111111-1111-1111-1111-111111111111", + false, false); +} + +static void test_validate_uuid_error(void) +{ + do_test_validate_uuid("-uuid 11111111-1111-1111-1111-111111111111", + "-uuid 22222222-2222-2222-2222-222222222222", + true, true); +} + +static void test_validate_uuid_src_not_set(void) +{ + do_test_validate_uuid(NULL, "-uuid 11111111-1111-1111-1111-11111111111= 1", + false, true); +} + +static void test_validate_uuid_dst_not_set(void) +{ + do_test_validate_uuid("-uuid 11111111-1111-1111-1111-111111111111", NU= LL, + false, true); +} + int main(int argc, char **argv) { char template[] =3D "/tmp/migration-test-XXXXXX"; @@ -1180,6 +1254,12 @@ int main(int argc, char **argv) /* qtest_add_func("/migration/ignore_shared", test_ignore_shared); */ qtest_add_func("/migration/xbzrle/unix", test_xbzrle_unix); qtest_add_func("/migration/fd_proto", test_migrate_fd_proto); + qtest_add_func("/migration/validate_uuid", test_validate_uuid); + qtest_add_func("/migration/validate_uuid_error", test_validate_uuid_er= ror); + qtest_add_func("/migration/validate_uuid_src_not_set", + test_validate_uuid_src_not_set); + qtest_add_func("/migration/validate_uuid_dst_not_set", + test_validate_uuid_dst_not_set); =20 ret =3D g_test_run(); =20 --=20 2.22.0