From patchwork Wed Oct 16 02:29:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Xu X-Patchwork-Id: 1177503 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 46tGb33qQyz9sPK for ; Wed, 16 Oct 2019 13:34:23 +1100 (AEDT) Received: from localhost ([::1]:35270 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKZ8n-0004X2-Cz for incoming@patchwork.ozlabs.org; Tue, 15 Oct 2019 22:34:21 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]:59411) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1iKZ4f-0000yt-Hm for qemu-devel@nongnu.org; Tue, 15 Oct 2019 22:30:07 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1iKZ4e-0004kj-DM for qemu-devel@nongnu.org; Tue, 15 Oct 2019 22:30:05 -0400 Received: from mx1.redhat.com ([209.132.183.28]:37642) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1iKZ4e-0004kb-4w for qemu-devel@nongnu.org; Tue, 15 Oct 2019 22:30:04 -0400 Received: from mail-pf1-f198.google.com (mail-pf1-f198.google.com [209.85.210.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 5F44E2A09AE for ; Wed, 16 Oct 2019 02:30:03 +0000 (UTC) Received: by mail-pf1-f198.google.com with SMTP id 194so17518956pfu.3 for ; Tue, 15 Oct 2019 19:30:03 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7bd+lVFSE5RnEgJZXIACTVDkbxanzqoTb19QHbkBI5s=; b=mqs0iMiKIPQF2+Xhv8GIerVyJjeg+8MkMu08cgo+uq/CH/r5sKUVJKy9gbtipFqcT1 cdXGzrYddig0BXIkiaKp77DNJcUbhC2YhQqKea7aTqV+cp/QmhMP2ZAbLrvog8qgwDk/ pBQbs3fZ5Jzsj0KisOf5bC9PvgMBQ0hfgtZNKtSpgx/hf1airoE82us7vlnqQxZ2TNdk ld6Z9BLBGpbgAqFUnQvicpcyCenVxGMhMsLFWoHrV55DTH4tQUqwKDRF/Y8CT3iQm3xv UvA9Wgvc3ltx9YROqee1/O4FiGP48NHUseej8oR0TGcpobxgcPYZBcr74Z7kXWtE+C6z R6BA== X-Gm-Message-State: APjAAAU0NqGaSxNrb4yXOKyvkxXnuQAcG/dTxTJIZXHBYLMxvKoGzepx cQpa3iJ+w9iG8P+0ka/imQ1a+1a2/V2hjSgBBIvNDCOj75r8SN82rG7nhtr5P4QzJgdkV0pLwkx Bewik0Dm0oy3r800= X-Received: by 2002:a17:90b:288:: with SMTP id az8mr1980584pjb.18.1571193002355; Tue, 15 Oct 2019 19:30:02 -0700 (PDT) X-Google-Smtp-Source: APXvYqxdkpSdsV62EU9GADl1SOVDSbmhziF/4LpFB6fp9yUchi9Ia/Pd3Yfewl5GU9xHcClA3ln5Uw== X-Received: by 2002:a17:90b:288:: with SMTP id az8mr1980563pjb.18.1571193002133; Tue, 15 Oct 2019 19:30:02 -0700 (PDT) Received: from xz-x1.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id b5sm26175722pfp.38.2019.10.15.19.29.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 15 Oct 2019 19:30:01 -0700 (PDT) From: Peter Xu To: qemu-devel@nongnu.org Subject: [PATCH v2 4/4] migration: Check in savevm_state_handler_insert for dups Date: Wed, 16 Oct 2019 10:29:33 +0800 Message-Id: <20191016022933.7276-5-peterx@redhat.com> X-Mailer: git-send-email 2.21.0 In-Reply-To: <20191016022933.7276-1-peterx@redhat.com> References: <20191016022933.7276-1-peterx@redhat.com> MIME-Version: 1.0 X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] [fuzzy] X-Received-From: 209.132.183.28 X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Eduardo Habkost , Juan Quintela , "Dr . David Alan Gilbert" , peterx@redhat.com, Igor Mammedov , Paolo Bonzini Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" Before finally register one SaveStateEntry, we detect for duplicated entries. This could be helpful to notify us asap instead of get silent migration failures which could be hard to diagnose. For example, this patch will generate a message like this (if without previous fixes on x2apic) as long as we wants to boot a VM instance with "-smp 200,maxcpus=288,sockets=2,cores=72,threads=2" and QEMU will bail out even before VM starts: savevm_state_handler_insert: Detected duplicate SaveStateEntry: id=apic, instance_id=0x0 Suggested-by: Dr. David Alan Gilbert Signed-off-by: Peter Xu Reviewed-by: Dr. David Alan Gilbert Reviewed-by: Juan Quintela --- migration/savevm.c | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/migration/savevm.c b/migration/savevm.c index 1e44f06d7a..83e91ddafa 100644 --- a/migration/savevm.c +++ b/migration/savevm.c @@ -264,6 +264,8 @@ static SaveState savevm_state = { .global_section_id = 0, }; +static SaveStateEntry *find_se(const char *idstr, uint32_t instance_id); + static bool should_validate_capability(int capability) { assert(capability >= 0 && capability < MIGRATION_CAPABILITY__MAX); @@ -714,6 +716,18 @@ static void savevm_state_handler_insert(SaveStateEntry *nse) assert(priority <= MIG_PRI_MAX); + /* + * This should never happen otherwise migration will probably fail + * silently somewhere because we can be wrongly applying one + * object properties upon another one. Bail out ASAP. + */ + if (find_se(nse->idstr, nse->instance_id)) { + error_report("%s: Detected duplicate SaveStateEntry: " + "id=%s, instance_id=0x%"PRIx32, __func__, + nse->idstr, nse->instance_id); + exit(EXIT_FAILURE); + } + QTAILQ_FOREACH(se, &savevm_state.handlers, entry) { if (save_state_priority(se) < priority) { break;