From nobody Mon Feb 9 10:51:40 2026 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=1612357366; cv=none; d=zohomail.com; s=zohoarc; b=CKkp9uVc9y+os4gn9QIBCvIdVko1SVKfwpOfdQchMLG6B+pl13Bt81Vpjju+1S2dL1oO+/nr8qStOtg82CAgh6GMxjRkjKXb7bqAxoIZgTs1PDGXCxz81N02Z1LXIrw9FHMXSm7dFrXkRCnyzbltJNrENfjMjzrmZr21u9ujrVM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1612357366; 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=DmIAzyRnhWry6wAxQk/s329dcyRgVitrm2Gl7GwqFsE=; b=htdmXehGDbIDKcUNjbYi7pvlXJ43QLAro3pwhzlJLnXIlwQS2edehFW8yYFqAU2I0xoToxRax9aXxaUr1Uc454cuzg3mAYRTc8/Iveuw3H/Y8bf37kX31CLOdk0ZllYjuRJC/23/cG1jSMd0v3XzsE6x+4XcxnVdoGh4ooyNd0Y= 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 1612357366169736.8099135742171; Wed, 3 Feb 2021 05:02:46 -0800 (PST) Received: from localhost ([::1]:53060 helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1l7Hnw-0005NC-4z for importer@patchew.org; Wed, 03 Feb 2021 08:02:44 -0500 Received: from eggs.gnu.org ([2001:470:142:3::10]:50150) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1l7HlU-00040V-7z for qemu-devel@nongnu.org; Wed, 03 Feb 2021 08:00:12 -0500 Received: from us-smtp-delivery-124.mimecast.com ([63.128.21.124]:36125) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA1:256) (Exim 4.90_1) (envelope-from ) id 1l7HlR-0003ng-Ov for qemu-devel@nongnu.org; Wed, 03 Feb 2021 08:00:11 -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-46-4CMFSSlfOW6xQhsqRIroEQ-1; Wed, 03 Feb 2021 08:00:07 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0AACD79EC4; Wed, 3 Feb 2021 13:00:06 +0000 (UTC) Received: from speedmetal.lan (unknown [10.40.208.53]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3E63A6F979; Wed, 3 Feb 2021 13:00:04 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1612357208; 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=DmIAzyRnhWry6wAxQk/s329dcyRgVitrm2Gl7GwqFsE=; b=VX1MRmNRXsj2ve8QTDbStdT2zYd8daV0xqho87v3feiX+wgUIQ4PRdsj+MaD+1VVQMOgVn rQLWibf+A4Sw5ju137czANufov6acyucCAqM2q3eXuJSZjaCG35jcVHWGYF8cIF1BvcxN6 8HyKQIKoDVzLCDx7CaL6nwscVhtB/QE= X-MC-Unique: 4CMFSSlfOW6xQhsqRIroEQ-1 From: Peter Krempa To: qemu-devel@nongnu.org Subject: [PATCH 1/2] migration: dirty-bitmap: Convert alias map inner members to a struct Date: Wed, 3 Feb 2021 13:59:59 +0100 Message-Id: <8e40a7337e3b9a0a4f11ee3b0e2f3ae4c76f2dbd.1612356810.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=pkrempa@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=pkrempa@redhat.com; helo=us-smtp-delivery-124.mimecast.com X-Spam_score_int: -32 X-Spam_score: -3.3 X-Spam_bar: --- X-Spam_report: (-3.3 / 5.0 requ) BAYES_00=-1.9, DKIMWL_WL_HIGH=-0.539, 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=ham 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: John Snow , Vladimir Sementsov-Ogievskiy , Markus Armbruster , qemu-block@nongnu.org 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" 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 convert the members to a struct. Signed-off-by: Peter Krempa Reviewed-by: Eric Blake Reviewed-by: Vladimir Sementsov-Ogievskiy --- migration/block-dirty-bitmap.c | 37 ++++++++++++++++++++++++++++------ 1 file changed, 31 insertions(+), 6 deletions(-) diff --git a/migration/block-dirty-bitmap.c b/migration/block-dirty-bitmap.c index c61d382be8..b0403dd00c 100644 --- a/migration/block-dirty-bitmap.c +++ b/migration/block-dirty-bitmap.c @@ -169,6 +169,18 @@ typedef struct DBMState { static DBMState dbm_state; +typedef struct AliasMapInnerBitmap { + char *string; +} AliasMapInnerBitmap; + +static void free_alias_map_inner_bitmap(void *amin_ptr) +{ + AliasMapInnerBitmap *amin =3D amin_ptr; + + g_free(amin->string); + g_free(amin); +} + /* For hash tables that map node/bitmap names to aliases */ typedef struct AliasMapInnerNode { char *string; @@ -264,7 +276,7 @@ static GHashTable *construct_alias_map(const BitmapMigr= ationNodeAliasList *bbm, } bitmaps_map =3D g_hash_table_new_full(g_str_hash, g_str_equal, - g_free, g_free); + g_free, free_alias_map_inner_b= itmap); amin =3D g_new(AliasMapInnerNode, 1); *amin =3D (AliasMapInnerNode){ @@ -277,6 +289,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; + AliasMapInnerBitmap *bmap_inner; if (strlen(bmba->alias) > UINT8_MAX) { error_setg(errp, @@ -311,8 +324,11 @@ static GHashTable *construct_alias_map(const BitmapMig= rationNodeAliasList *bbm, } } + bmap_inner =3D g_new0(AliasMapInnerBitmap, 1); + bmap_inner->string =3D g_strdup(bmap_map_to); + g_hash_table_insert(bitmaps_map, - g_strdup(bmap_map_from), g_strdup(bmap_map= _to)); + g_strdup(bmap_map_from), bmap_inner); } } @@ -538,11 +554,16 @@ 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) { + AliasMapInnerBitmap *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->string; } else { if (strlen(bitmap_name) > UINT8_MAX) { error_report("Cannot migrate bitmap '%s' on node '%s': " @@ -1074,14 +1095,18 @@ 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, + AliasMapInnerBitmap *bmap_inner; + + bmap_inner =3D g_hash_table_lookup(bitmap_alias_map, s->bitmap_alias); - if (!bitmap_name) { + 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); } + + bitmap_name =3D bmap_inner->string; } if (!s->cancelled) { --=20 2.29.2