From nobody Sun Oct 5 19:23:33 2025 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.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=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1613172441; cv=none; d=zohomail.com; s=zohoarc; b=jDu2bFjT3rR5jbKWgQKQu3D2F5MKHvVjDPs219w4RLj/O7Aw4mgC937ZmrZ4W93qvNBYzzBiuFkVfudE6kGAJapXmRIkbLQwlhcfOgAnYvhy5nzdTzlH/91DiYeOHaFO1XS72DrkRa0H77DLTb4uXy67gAUTac07iRKhdeceY/g= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1613172441; h=Content-Type: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; bh=r+zdWS2o2oVkRJLXmriaeAsHj3paX/QYsPu64ViLgpI=; b=RBVhIXZRlPjg70wTlZTg7w2ITkittxyqdnH6tOeQDBZn6chhwV06fm8onoOesMkZ+Gl5kx/BTHtWvbVMzd2k51S8XQ/2abfN9aFw2C+WtG5LVL4qHxvrDsBAqv8e+YtEV/MCGMcBEI9GTTQXB8nBYHsyzEpUz9fpFofgP9/PLxQ= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.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 1613172440548267.3664255999074; Fri, 12 Feb 2021 15:27:20 -0800 (PST) Received: from localhost ([::1]:49196 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1lAhqE-0000hu-Pw for importer@patchew.org; Fri, 12 Feb 2021 18:27:14 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:36514) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1lAhky-0003yx-P1 for qemu-devel@nongnu.org; Fri, 12 Feb 2021 18:21:48 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:50569) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1lAhkw-0005oD-Si for qemu-devel@nongnu.org; Fri, 12 Feb 2021 18:21:48 -0500 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-196-xPrarvH7MRSiw7UICoFaFg-1; Fri, 12 Feb 2021 18:21:42 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1BE90801962; Fri, 12 Feb 2021 23:21:41 +0000 (UTC) Received: from blue.redhat.com (ovpn-114-150.phx2.redhat.com [10.3.114.150]) by smtp.corp.redhat.com (Postfix) with ESMTP id 53A441F04C; Fri, 12 Feb 2021 23:21:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1613172106; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=r+zdWS2o2oVkRJLXmriaeAsHj3paX/QYsPu64ViLgpI=; b=Olp4QeJ+mtRsEeJL5UVFm72K4FtvhMduSXJH/T6ExvR6ghBbB9+lpqT2NHDtQRsJxICFqM nM1mKDZ/xZjoTP/b6udpIOKsg07dJK+We2a6mtVyFyvKMCZarNBJCRi6ZwvcC+Vv9Tzzcq daFYOUjLClSiQFjzlL9LOn/AuHApgbQ= X-MC-Unique: xPrarvH7MRSiw7UICoFaFg-1 From: Eric Blake To: qemu-devel@nongnu.org Subject: [PULL 1/5] migration: dirty-bitmap: Use struct for alias map inner members Date: Fri, 12 Feb 2021 17:21:30 -0600 Message-Id: <20210212232134.1462756-2-eblake@redhat.com> In-Reply-To: <20210212232134.1462756-1-eblake@redhat.com> References: <20210212232134.1462756-1-eblake@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=eblake@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=63.128.21.124; envelope-from=eblake@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -33 X-Spam_score: -3.4 X-Spam_bar: --- X-Spam_report: (-3.4 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.569, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_LOW=-0.7, RCVD_IN_MSPIKE_H4=0.001, RCVD_IN_MSPIKE_WL=0.001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001 autolearn=unavailable autolearn_force=no X-Spam_action: no action 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: Fam Zheng , Peter Krempa , "open list:Dirty Bitmaps" , Juan Quintela , "Dr. David Alan Gilbert" , Vladimir Sementsov-Ogievskiy , Stefan Hajnoczi , John Snow 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" From: Peter Krempa Currently the alias mapping hash stores just strings of the target objects internally. In further patches we'll be adding another member which will need to be stored in the map so pass a copy of the whole BitmapMigrationBitmapAlias QAPI struct into the map. Signed-off-by: Peter Krempa Message-Id: Reviewed-by: Eric Blake [eblake: adjust long lines] Signed-off-by: Eric Blake --- migration/block-dirty-bitmap.c | 33 +++++++++++++++++++++------------ 1 file changed, 21 insertions(+), 12 deletions(-) diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c index c61d382be87c..b39c13ce4ebe 100644 --- a/migration/block-dirty-bitmap.c +++ b/migration/block-dirty-bitmap.c @@ -75,6 +75,8 @@ #include "qemu/id.h" #include "qapi/error.h" #include "qapi/qapi-commands-migration.h" +#include "qapi/qapi-visit-migration.h" +#include "qapi/clone-visitor.h" #include "trace.h" #define CHUNK_SIZE (1 << 10) @@ -224,6 +226,7 @@ static GHashTable *construct_alias_map(const BitmapMigr= ationNodeAliasList *bbm, AliasMapInnerNode *amin; GHashTable *bitmaps_map; const char *node_map_from, *node_map_to; + GDestroyNotify gdn; if (!id_wellformed(bmna->alias)) { error_setg(errp, "The node alias '%s' is not well-formed", @@ -263,8 +266,9 @@ static GHashTable *construct_alias_map(const BitmapMigr= ationNodeAliasList *bbm, node_map_to =3D bmna->node_name; } - bitmaps_map =3D g_hash_table_new_full(g_str_hash, g_str_equal, - g_free, g_free); + gdn =3D (GDestroyNotify) qapi_free_BitmapMigrationBitmapAlias; + bitmaps_map =3D g_hash_table_new_full(g_str_hash, g_str_equal, g_f= ree, + gdn); amin =3D g_new(AliasMapInnerNode, 1); *amin =3D (AliasMapInnerNode){ @@ -276,7 +280,7 @@ static GHashTable *construct_alias_map(const BitmapMigr= ationNodeAliasList *bbm, for (bmbal =3D bmna->bitmaps; bmbal; bmbal =3D bmbal->next) { const BitmapMigrationBitmapAlias *bmba =3D bmbal->value; - const char *bmap_map_from, *bmap_map_to; + const char *bmap_map_from; if (strlen(bmba->alias) > UINT8_MAX) { error_setg(errp, @@ -293,7 +297,6 @@ static GHashTable *construct_alias_map(const BitmapMigr= ationNodeAliasList *bbm, if (name_to_alias) { bmap_map_from =3D bmba->name; - bmap_map_to =3D bmba->alias; if (g_hash_table_contains(bitmaps_map, bmba->name)) { error_setg(errp, "The bitmap '%s'/'%s' is mapped twice= ", @@ -302,7 +305,6 @@ static GHashTable *construct_alias_map(const BitmapMigr= ationNodeAliasList *bbm, } } else { bmap_map_from =3D bmba->alias; - bmap_map_to =3D bmba->name; if (g_hash_table_contains(bitmaps_map, bmba->alias)) { error_setg(errp, "The bitmap alias '%s'/'%s' is used t= wice", @@ -311,8 +313,8 @@ static GHashTable *construct_alias_map(const BitmapMigr= ationNodeAliasList *bbm, } } - g_hash_table_insert(bitmaps_map, - g_strdup(bmap_map_from), g_strdup(bmap_map= _to)); + g_hash_table_insert(bitmaps_map, g_strdup(bmap_map_from), + QAPI_CLONE(BitmapMigrationBitmapAlias, bmb= a)); } } @@ -538,11 +540,15 @@ static int add_bitmaps_to_list(DBMSaveState *s, Block= DriverState *bs, } if (bitmap_aliases) { - bitmap_alias =3D g_hash_table_lookup(bitmap_aliases, bitmap_na= me); - if (!bitmap_alias) { + BitmapMigrationBitmapAlias *bmap_inner; + + bmap_inner =3D g_hash_table_lookup(bitmap_aliases, bitmap_name= ); + if (!bmap_inner) { /* Skip bitmaps with no alias */ continue; } + + bitmap_alias =3D bmap_inner->alias; } else { if (strlen(bitmap_name) > UINT8_MAX) { error_report("Cannot migrate bitmap '%s' on node '%s': " @@ -1074,13 +1080,16 @@ static int dirty_bitmap_load_header(QEMUFile *f, DB= MLoadState *s, bitmap_name =3D s->bitmap_alias; if (!s->cancelled && bitmap_alias_map) { - bitmap_name =3D g_hash_table_lookup(bitmap_alias_map, - s->bitmap_alias); - if (!bitmap_name) { + BitmapMigrationBitmapAlias *bmap_inner; + + bmap_inner =3D g_hash_table_lookup(bitmap_alias_map, s->bitmap= _alias); + if (!bmap_inner) { error_report("Error: Unknown bitmap alias '%s' on node " "'%s' (alias '%s')", s->bitmap_alias, s->bs->node_name, s->node_alias); cancel_incoming_locked(s); + } else { + bitmap_name =3D bmap_inner->name; } } --=20 2.30.1