From nobody Mon Apr 29 10:46:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 15803960283188.062783166258669; Thu, 30 Jan 2020 06:53:48 -0800 (PST) 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-252-WJ8Bdin-P6ae1t81RZdnHg-1; Thu, 30 Jan 2020 09:53:43 -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 37AAD18CA25D; Thu, 30 Jan 2020 14:53:38 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 119E58E9E4; Thu, 30 Jan 2020 14:53:38 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id B5FFB18089C8; Thu, 30 Jan 2020 14:53:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00UErZVv026801 for ; Thu, 30 Jan 2020 09:53:35 -0500 Received: by smtp.corp.redhat.com (Postfix) id 689C377954; Thu, 30 Jan 2020 14:53:35 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id E5BF677951 for ; Thu, 30 Jan 2020 14:53:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580396026; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=aNKhXlD6N+k86wbnGzp8sdvfsytIC4yb0j6+0Ladei4=; b=TBuvDhOO+6RNtQ/yHAV7BBtA/kko51rJwDA8Id5PGTngDSx8mBT759Im0vgKbunrMfUv9z lRrJxumy4jXYUoJpsAWMG/4x36yAtiQ8svNjQkfQQSuMg+Q5ATQl4QgRVbs3uw7Jk1FUYt ezkbzvEj6YLPFiOrP4fSx4BPrt1O3Wg= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 01/10] util: hash: Use g_new0 for allocating hash internals Date: Thu, 30 Jan 2020 15:53:21 +0100 Message-Id: <4aea28a3ffb2157d15284ac053e0a1e6acceea88.1580395954.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: WJ8Bdin-P6ae1t81RZdnHg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Use the glib helpers and remove the mention of returning NULL on failure of virHashNew, virHashCreate and virHashCreateFull. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/util/virhash.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/util/virhash.c b/src/util/virhash.c index edf11e8b7a..d5c5e017a1 100644 --- a/src/util/virhash.c +++ b/src/util/virhash.c @@ -138,7 +138,7 @@ virHashComputeKey(const virHashTable *table, const void= *name) * * Create a new virHashTablePtr. * - * Returns the newly created object, or NULL if an error occurred. + * Returns the newly created object. */ virHashTablePtr virHashCreateFull(ssize_t size, virHashDataFree dataFree, @@ -153,8 +153,7 @@ virHashTablePtr virHashCreateFull(ssize_t size, if (size <=3D 0) size =3D 256; - if (VIR_ALLOC(table) < 0) - return NULL; + table =3D g_new0(virHashTable, 1); table->seed =3D virRandomBits(32); table->size =3D size; @@ -166,10 +165,7 @@ virHashTablePtr virHashCreateFull(ssize_t size, table->keyPrint =3D keyPrint; table->keyFree =3D keyFree; - if (VIR_ALLOC_N(table->table, size) < 0) { - VIR_FREE(table); - return NULL; - } + table->table =3D g_new0(virHashEntryPtr, table->size); return table; } @@ -181,7 +177,7 @@ virHashTablePtr virHashCreateFull(ssize_t size, * * Create a new virHashTablePtr. * - * Returns the newly created object, or NULL if an error occurred. + * Returns the newly created object. */ virHashTablePtr virHashNew(virHashDataFree dataFree) @@ -203,7 +199,7 @@ virHashNew(virHashDataFree dataFree) * * Create a new virHashTablePtr. * - * Returns the newly created object, or NULL if an error occurred. + * Returns the newly created object. */ virHashTablePtr virHashCreate(ssize_t size, virHashDataFree dataFree) { --=20 2.24.1 From nobody Mon Apr 29 10:46:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1580396028638940.616574304104; Thu, 30 Jan 2020 06:53:48 -0800 (PST) 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-147-uNQGh-uYO_mJ1ycfNdclzA-1; Thu, 30 Jan 2020 09:53:44 -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 EFED3108839C; Thu, 30 Jan 2020 14:53:38 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C29AECFD9; Thu, 30 Jan 2020 14:53:38 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 7BCCA18089CE; Thu, 30 Jan 2020 14:53:38 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00UEraYc026806 for ; Thu, 30 Jan 2020 09:53:36 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3493177959; Thu, 30 Jan 2020 14:53:36 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id B3B3877951 for ; Thu, 30 Jan 2020 14:53:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580396027; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=H+FYmjB0Lh6RRw+4z9j5FxDuKv3wYBTaNsaoiCx50+c=; b=iBICXWRibBNbSu8czuekWkZFC258zzZOwlvwXCRu8Ne9Ipcmi6S0Qx9/fkeBsD2D3D4sbz VUipQcWZ9Eg7LucfoY29i+8Kaevo7uUOVPcrEvjj80KKdQTwWMS+N6NowWddg3iqVH2dK3 JuXE2NmRlNLZyBoTLMex/SWGnA5Vwqs= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 02/10] conf: domain: Remove checking of return value of virHashCreateFull Date: Thu, 30 Jan 2020 15:53:22 +0100 Message-Id: <49a55bc3f1a0967fa1d289c3b2b9a76986a1cdb3.1580395954.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: uNQGh-uYO_mJ1ycfNdclzA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" This module has last two direct checks whether the value returned by virHashCreateFull is NULL. Remove them so that static analyzers don't get the false idea that checking the value is necessary. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/conf/domain_addr.c | 32 +++++++++++++------------------- 1 file changed, 13 insertions(+), 19 deletions(-) diff --git a/src/conf/domain_addr.c b/src/conf/domain_addr.c index 607ba56efd..f07b3d9725 100644 --- a/src/conf/domain_addr.c +++ b/src/conf/domain_addr.c @@ -1044,28 +1044,22 @@ virDomainPCIAddressSetExtensionAlloc(virDomainPCIAd= dressSetPtr addrs, if (VIR_ALLOC(addrs->zpciIds) < 0) return -1; - if (!(addrs->zpciIds->uids =3D virHashCreateFull(10, NULL, - virZPCIAddrKeyCode, - virZPCIAddrKeyEqual, - virZPCIAddrKeyCopy, - virZPCIAddrKeyPrint= Human, - virZPCIAddrKeyFree)= )) - goto error; - - if (!(addrs->zpciIds->fids =3D virHashCreateFull(10, NULL, - virZPCIAddrKeyCode, - virZPCIAddrKeyEqual, - virZPCIAddrKeyCopy, - virZPCIAddrKeyPrint= Human, - virZPCIAddrKeyFree)= )) - goto error; + addrs->zpciIds->uids =3D virHashCreateFull(10, NULL, + virZPCIAddrKeyCode, + virZPCIAddrKeyEqual, + virZPCIAddrKeyCopy, + virZPCIAddrKeyPrintHuman, + virZPCIAddrKeyFree); + + addrs->zpciIds->fids =3D virHashCreateFull(10, NULL, + virZPCIAddrKeyCode, + virZPCIAddrKeyEqual, + virZPCIAddrKeyCopy, + virZPCIAddrKeyPrintHuman, + virZPCIAddrKeyFree); } return 0; - - error: - virDomainPCIAddressSetExtensionFree(addrs); - return -1; } --=20 2.24.1 From nobody Mon Apr 29 10:46:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1580396225029206.39764400210072; Thu, 30 Jan 2020 06:57:05 -0800 (PST) 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-280-8ibpj7r6OJas_hh4Dv9Lfg-1; Thu, 30 Jan 2020 09:53:49 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id AEC3A800D55; Thu, 30 Jan 2020 14:53:41 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 837F11B42C; Thu, 30 Jan 2020 14:53:41 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 4083F18089D5; Thu, 30 Jan 2020 14:53:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00UErbmE026816 for ; Thu, 30 Jan 2020 09:53:37 -0500 Received: by smtp.corp.redhat.com (Postfix) id 95F9677951; Thu, 30 Jan 2020 14:53:37 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 211E177956 for ; Thu, 30 Jan 2020 14:53:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580396222; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Eu2dDUXf8fW8i/u5DJiN9mYr65KZEOk0PCp7oj+ACe8=; b=hGi/ZV+ymMlKacCQt91kPD+HwQKU2oJcGTX1ONfL1t32cyL9kcPs/Xk/hF0ox1HYDYH0c4 j9XbkK5FGyCVt6c9eAEuYP1hchDnTChbgqXIie98GDiIm0OM9NQOU6ULpMaCMQ99NIV+2q PTQKGCto4VgCXOiUpfSy9SecnDdtNSs= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 03/10] Remove checking of return value of virHashNew Date: Thu, 30 Jan 2020 15:53:23 +0100 Message-Id: <6f02d7e8beff96d25891688298ad08b69b3cf342.1580395954.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: 8ibpj7r6OJas_hh4Dv9Lfg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" There are two calls to virHashNew which check the return value. It's not necessary any more as virHashNew always returns a valid pointer. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/conf/backup_conf.c | 6 +----- src/qemu/qemu_monitor_json.c | 3 +-- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/conf/backup_conf.c b/src/conf/backup_conf.c index b370b686f1..64c8f6cc09 100644 --- a/src/conf/backup_conf.c +++ b/src/conf/backup_conf.c @@ -439,15 +439,11 @@ virDomainBackupAlignDisks(virDomainBackupDefPtr def, virDomainDefPtr dom, const char *suffix) { - g_autoptr(virHashTable) disks =3D NULL; + g_autoptr(virHashTable) disks =3D virHashNew(NULL); size_t i; int ndisks; bool backup_all =3D false; - - if (!(disks =3D virHashNew(NULL))) - return -1; - /* Unlikely to have a guest without disks but technically possible. */ if (!dom->ndisks) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c index e27f3085c4..981d091ba0 100644 --- a/src/qemu/qemu_monitor_json.c +++ b/src/qemu/qemu_monitor_json.c @@ -2990,8 +2990,7 @@ qemuMonitorJSONBlockGetNamedNodeDataJSON(virJSONValue= Ptr nodes) { g_autoptr(virHashTable) ret =3D NULL; - if (!(ret =3D virHashNew((virHashDataFree) qemuMonitorJSONBlockNamedNo= deDataFree))) - return NULL; + ret =3D virHashNew((virHashDataFree) qemuMonitorJSONBlockNamedNodeData= Free); if (virJSONValueArrayForeachSteal(nodes, qemuMonitorJSONBlockGetNamedNodeData= Worker, --=20 2.24.1 From nobody Mon Apr 29 10:46:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1580396036165181.4029140757914; Thu, 30 Jan 2020 06:53:56 -0800 (PST) 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-375-zuv-IexsOYmTZCkQxNQNXw-1; Thu, 30 Jan 2020 09:53:53 -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 74B0F108BC53; Thu, 30 Jan 2020 14:53:45 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4C947CFF0; Thu, 30 Jan 2020 14:53:45 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 09C7787A94; Thu, 30 Jan 2020 14:53:45 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00UErc3w026825 for ; Thu, 30 Jan 2020 09:53:38 -0500 Received: by smtp.corp.redhat.com (Postfix) id 7A8C577951; Thu, 30 Jan 2020 14:53:38 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 03B8377958 for ; Thu, 30 Jan 2020 14:53:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580396035; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=aDtAwnw3b5exr+/VnAPC7cC33OeOvTAuZm45FaILrOI=; b=AXL4pYjz6xppztGBPvvwFKDzpmn2VQkbTqNSw2aZNXWdX7WEbrcSpP41eK2Ph+YDwGZZB2 1v14e1gJ721KEvyC99tp2FH3pudsrlsyOrpQi8GdTvM9d7waDd9NKT3qZgO6n50/uC1+p5 ji6SUUZ6Ng7IjmtNg7saOS6ZxVF1YE4= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 04/10] qemuMigrationCookieAddNBD: Exit early if there are no disks Date: Thu, 30 Jan 2020 15:53:24 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-MC-Unique: zuv-IexsOYmTZCkQxNQNXw-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Refactor the logic to skip the body of the function if there's nothing to do. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_migration_cookie.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_coo= kie.c index 299bf17c9e..73ae815818 100644 --- a/src/qemu/qemu_migration_cookie.c +++ b/src/qemu/qemu_migration_cookie.c @@ -464,8 +464,13 @@ qemuMigrationCookieAddNBD(qemuMigrationCookiePtr mig, if (VIR_ALLOC(mig->nbd) < 0) return -1; - if (vm->def->ndisks && - VIR_ALLOC_N(mig->nbd->disks, vm->def->ndisks) < 0) + mig->nbd->port =3D priv->nbdPort; + mig->flags |=3D QEMU_MIGRATION_COOKIE_NBD; + + if (vm->def->ndisks =3D=3D 0) + return 0; + + if (VIR_ALLOC_N(mig->nbd->disks, vm->def->ndisks) < 0) return -1; mig->nbd->ndisks =3D 0; @@ -496,9 +501,6 @@ qemuMigrationCookieAddNBD(qemuMigrationCookiePtr mig, mig->nbd->ndisks++; } - mig->nbd->port =3D priv->nbdPort; - mig->flags |=3D QEMU_MIGRATION_COOKIE_NBD; - ret =3D 0; cleanup: virHashFree(stats); --=20 2.24.1 From nobody Mon Apr 29 10:46:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 1580396033517736.8991919352475; Thu, 30 Jan 2020 06:53:53 -0800 (PST) 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-243-j9swvMN6NqWluCDNJabhNg-1; Thu, 30 Jan 2020 09:53:49 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9E87BDBB1; Thu, 30 Jan 2020 14:53:42 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6CB6F5E244; Thu, 30 Jan 2020 14:53:42 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id F187A87A91; Thu, 30 Jan 2020 14:53:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00UEre3M026837 for ; Thu, 30 Jan 2020 09:53:40 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5FF6C845C9; Thu, 30 Jan 2020 14:53:40 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id DEC8B7C42C for ; Thu, 30 Jan 2020 14:53:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580396032; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=NPtvaih28lInIk05P9T/exFjcx3iG1r/AtAchHXfIFE=; b=AkCPtkMw3MehAuTXpR5X/6fkLWzG0hYGcchG+DknOpzsEMe9CdDWkVe6sEWTrpBMkfPLLO x20VV8kk8KGBSeqQ/vlPgGq9UWEDqfAY0hEv7bIvIEQQPDQbREQyp1E14rXhsh5SEIRouO ALrPSS8nmYKLGOtYSKhKvmK9CKF9qtw= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 05/10] qemuMigrationCookieNBD: Extract embedded struct Date: Thu, 30 Jan 2020 15:53:25 +0100 Message-Id: <0463ffd12bb19a8ef48c95314876931d76d299b4.1580395954.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: j9swvMN6NqWluCDNJabhNg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Extract the struct so that it's type has a name. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_migration_cookie.h | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_migration_cookie.h b/src/qemu/qemu_migration_coo= kie.h index 20e1ed60ca..1e88684589 100644 --- a/src/qemu/qemu_migration_cookie.h +++ b/src/qemu/qemu_migration_cookie.h @@ -84,16 +84,18 @@ struct _qemuMigrationCookieNetwork { qemuMigrationCookieNetDataPtr net; }; +struct qemuMigrationCookieNBDDisk { + char *target; /* Disk target */ + unsigned long long capacity; /* And its capacity */ +}; + typedef struct _qemuMigrationCookieNBD qemuMigrationCookieNBD; typedef qemuMigrationCookieNBD *qemuMigrationCookieNBDPtr; struct _qemuMigrationCookieNBD { int port; /* on which port does NBD server listen for incoming data */ size_t ndisks; /* Number of items in @disk array */ - struct { - char *target; /* Disk target */ - unsigned long long capacity; /* And its capacity */ - } *disks; + struct qemuMigrationCookieNBDDisk *disks; }; typedef struct _qemuMigrationCookieCaps qemuMigrationCookieCaps; --=20 2.24.1 From nobody Mon Apr 29 10:46:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 15803960390631.882450838881141; Thu, 30 Jan 2020 06:53:59 -0800 (PST) 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-169-GC71qlDTNGi_iFXbopb5LA-1; Thu, 30 Jan 2020 09:53:55 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2E53F1005513; Thu, 30 Jan 2020 14:53:49 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 056C58883E; Thu, 30 Jan 2020 14:53:49 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id B28D818089D6; Thu, 30 Jan 2020 14:53:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00UErf7w026842 for ; Thu, 30 Jan 2020 09:53:41 -0500 Received: by smtp.corp.redhat.com (Postfix) id 598797C012; Thu, 30 Jan 2020 14:53:41 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id D2C5D77958 for ; Thu, 30 Jan 2020 14:53:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580396037; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=FTaxKl0TMFB0wQlVoXWM+mwWIWhx5vRXYSXknG+E60o=; b=eAbz5U0qIKcjdG1Q8FrKewDY46fdjxAfmKjvjh8JNMFcLTkT21SDNa/xiLNqG22hsNa2Sa ZAbE+ZAYiOc5qx0Z9L1eKbsGLHADhhbhXQBPVYF6gI5Kqsw9/DLfoThnMjUItBAi7zmEhX mMy9heb7c2J7ENBbQwlh/upPiA6f4+E= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 06/10] qemuMigrationCookieAddNBD: Use glib memory allocators Date: Thu, 30 Jan 2020 15:53:26 +0100 Message-Id: <788e25ebff91071cc831421bda695780742f9e22.1580395954.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-MC-Unique: GC71qlDTNGi_iFXbopb5LA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_migration_cookie.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_coo= kie.c index 73ae815818..1c3de13983 100644 --- a/src/qemu/qemu_migration_cookie.c +++ b/src/qemu/qemu_migration_cookie.c @@ -461,8 +461,7 @@ qemuMigrationCookieAddNBD(qemuMigrationCookiePtr mig, /* It is not a bug if there already is a NBD data */ qemuMigrationCookieNBDFree(mig->nbd); - if (VIR_ALLOC(mig->nbd) < 0) - return -1; + mig->nbd =3D g_new0(qemuMigrationCookieNBD, 1); mig->nbd->port =3D priv->nbdPort; mig->flags |=3D QEMU_MIGRATION_COOKIE_NBD; @@ -470,8 +469,7 @@ qemuMigrationCookieAddNBD(qemuMigrationCookiePtr mig, if (vm->def->ndisks =3D=3D 0) return 0; - if (VIR_ALLOC_N(mig->nbd->disks, vm->def->ndisks) < 0) - return -1; + mig->nbd->disks =3D g_new0(struct qemuMigrationCookieNBDDisk, vm->def-= >ndisks); mig->nbd->ndisks =3D 0; for (i =3D 0; i < vm->def->ndisks; i++) { --=20 2.24.1 From nobody Mon Apr 29 10:46:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1580396114834391.8570677574137; Thu, 30 Jan 2020 06:55:14 -0800 (PST) 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-79-M_yaMKgrMl6Kif_qu51_iQ-1; Thu, 30 Jan 2020 09:53:59 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id CA658801E6C; Thu, 30 Jan 2020 14:53:52 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id A5D441B5AE; Thu, 30 Jan 2020 14:53:52 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 6378587A9C; Thu, 30 Jan 2020 14:53:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00UErhbo026855 for ; Thu, 30 Jan 2020 09:53:43 -0500 Received: by smtp.corp.redhat.com (Postfix) id 4114777946; Thu, 30 Jan 2020 14:53:43 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id BE91B845D3 for ; Thu, 30 Jan 2020 14:53:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580396112; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=oaUlob5dW49DrH/Phi35cPcx3Ebbl3vrkt8bI4QxU7g=; b=bL+Hje8LwcnLKU0OMQaoRJ8DM8Nn5/PWCkC4uZo2lKgMC+CJbwdUjaRx2MVy8pcpc4dBs1 3wFCKtpG67OECVwH4adsN+P9CwZV6EE5mVN+oRavGqql+1DE0cha/lUMU8zRxPKU3xyNVL SD50fEKXmaElpxHO9SWsG/45CsnCGWc= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 07/10] qemuMigrationCookieAddNBD: Move monitor call out of the loop Date: Thu, 30 Jan 2020 15:53:27 +0100 Message-Id: <2450de8e2f8011c3d940ab5024c7160dc0e743c9.1580395954.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: M_yaMKgrMl6Kif_qu51_iQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" The data is gathered only once so we can move the whole block which fetches the data out of the loop and get rid of the logic which prevents multiple calls. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_migration_cookie.c | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_coo= kie.c index 1c3de13983..33ab6cb7a5 100644 --- a/src/qemu/qemu_migration_cookie.c +++ b/src/qemu/qemu_migration_cookie.c @@ -472,24 +472,19 @@ qemuMigrationCookieAddNBD(qemuMigrationCookiePtr mig, mig->nbd->disks =3D g_new0(struct qemuMigrationCookieNBDDisk, vm->def-= >ndisks); mig->nbd->ndisks =3D 0; + if (!(stats =3D virHashCreate(10, virHashValueFree))) + goto cleanup; + + if (qemuDomainObjEnterMonitorAsync(driver, vm, priv->job.asyncJob) < 0) + goto cleanup; + rc =3D qemuMonitorBlockStatsUpdateCapacity(priv->mon, stats, false); + if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) + goto cleanup; + for (i =3D 0; i < vm->def->ndisks; i++) { virDomainDiskDefPtr disk =3D vm->def->disks[i]; qemuBlockStats *entry; - if (!stats) { - if (!(stats =3D virHashCreate(10, virHashValueFree))) - goto cleanup; - - if (qemuDomainObjEnterMonitorAsync(driver, vm, - priv->job.asyncJob) < 0) - goto cleanup; - rc =3D qemuMonitorBlockStatsUpdateCapacity(priv->mon, stats, f= alse); - if (qemuDomainObjExitMonitor(driver, vm) < 0) - goto cleanup; - if (rc < 0) - goto cleanup; - } - if (!disk->info.alias || !(entry =3D virHashLookup(stats, disk->info.alias))) continue; --=20 2.24.1 From nobody Mon Apr 29 10:46:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) client-ip=207.211.31.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) by mx.zohomail.com with SMTPS id 158039610724689.44166298771472; Thu, 30 Jan 2020 06:55:07 -0800 (PST) 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-248-4GAnMiBhNzCfc7Crb7jVUQ-1; Thu, 30 Jan 2020 09:53:54 -0500 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 52B7F107ACCC; Thu, 30 Jan 2020 14:53:49 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2D5481B49E; Thu, 30 Jan 2020 14:53:49 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id DAA4B87A98; Thu, 30 Jan 2020 14:53:48 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00UErkC0026870 for ; Thu, 30 Jan 2020 09:53:46 -0500 Received: by smtp.corp.redhat.com (Postfix) id 00F6D7C012; Thu, 30 Jan 2020 14:53:46 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id A342684773 for ; Thu, 30 Jan 2020 14:53:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580396106; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=PGSlV2sRAdCElh1+3jDIrDbxjGN6Qlz/WtLBJ74IT0Y=; b=Wdlw4X0E70h0LrSRBtyUhSRLm/u7U1SwATzK9yIDyjl13CIjkbjJx5+ZrxwCcMdqWwpXWo VqBGhgKP9QBH9uiD+ADidD31005+z46tZ3ZEO4FPoVpA/2tKSifaXGl/Qa6AG4NifupasX l9DgH59FJTFyw/11sIO056QYr4vb0q4= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 08/10] qemuMigrationCookieAddNBD: Use virHashNew and automatic freeing of virHashTablePtr Date: Thu, 30 Jan 2020 15:53:28 +0100 Message-Id: <8d430ef9cec5a2579077fae8a4ffed034c4ec3c3.1580395954.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-MC-Unique: 4GAnMiBhNzCfc7Crb7jVUQ-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Swithc to the helper which doesn't require checking of the return value. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_migration_cookie.c | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_coo= kie.c index 33ab6cb7a5..968a9b589c 100644 --- a/src/qemu/qemu_migration_cookie.c +++ b/src/qemu/qemu_migration_cookie.c @@ -454,7 +454,7 @@ qemuMigrationCookieAddNBD(qemuMigrationCookiePtr mig, virDomainObjPtr vm) { qemuDomainObjPrivatePtr priv =3D vm->privateData; - virHashTablePtr stats =3D NULL; + g_autoptr(virHashTable) stats =3D virHashNew(virHashValueFree); size_t i; int ret =3D -1, rc; @@ -472,9 +472,6 @@ qemuMigrationCookieAddNBD(qemuMigrationCookiePtr mig, mig->nbd->disks =3D g_new0(struct qemuMigrationCookieNBDDisk, vm->def-= >ndisks); mig->nbd->ndisks =3D 0; - if (!(stats =3D virHashCreate(10, virHashValueFree))) - goto cleanup; - if (qemuDomainObjEnterMonitorAsync(driver, vm, priv->job.asyncJob) < 0) goto cleanup; rc =3D qemuMonitorBlockStatsUpdateCapacity(priv->mon, stats, false); @@ -496,7 +493,6 @@ qemuMigrationCookieAddNBD(qemuMigrationCookiePtr mig, ret =3D 0; cleanup: - virHashFree(stats); return ret; } --=20 2.24.1 From nobody Mon Apr 29 10:46:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 1580396047435670.7731713087562; Thu, 30 Jan 2020 06:54:07 -0800 (PST) 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-7-Md4aDrL1PHOKDzaO2ZJYcA-1; Thu, 30 Jan 2020 09:54:02 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B4C568010E8; Thu, 30 Jan 2020 14:53:56 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 86EF13841; Thu, 30 Jan 2020 14:53:56 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 36EF0180880D; Thu, 30 Jan 2020 14:53:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00UErkar026878 for ; Thu, 30 Jan 2020 09:53:46 -0500 Received: by smtp.corp.redhat.com (Postfix) id E2B1C7C012; Thu, 30 Jan 2020 14:53:46 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6DB888478D for ; Thu, 30 Jan 2020 14:53:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580396046; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=lzu05aSM5Qt9nrqNS3nPqnN1RGrHiQwSY5jUpPI1ZdM=; b=Qb2uuosEYnKVEv0dNVNy0Pzf6qjxT//AvElVtSPJp4yFpV0/ibU3p32KlT80+8ltbDfi0+ yhAQ6claoXLKnVwwwVUOAvYIex8+IVL6ei+z7hj/vMa0NPIhicr1tHKNdQCdtf1OnPyLV+ JObvnBM9oG8SrzV9IVSap2VMq9DnWks= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 09/10] qemuMigrationCookieAddNBD: Remove 'ret' variable and 'cleanup' label Date: Thu, 30 Jan 2020 15:53:29 +0100 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-MC-Unique: Md4aDrL1PHOKDzaO2ZJYcA-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_migration_cookie.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_coo= kie.c index 968a9b589c..734d95f4f1 100644 --- a/src/qemu/qemu_migration_cookie.c +++ b/src/qemu/qemu_migration_cookie.c @@ -456,7 +456,7 @@ qemuMigrationCookieAddNBD(qemuMigrationCookiePtr mig, qemuDomainObjPrivatePtr priv =3D vm->privateData; g_autoptr(virHashTable) stats =3D virHashNew(virHashValueFree); size_t i; - int ret =3D -1, rc; + int rc; /* It is not a bug if there already is a NBD data */ qemuMigrationCookieNBDFree(mig->nbd); @@ -473,10 +473,10 @@ qemuMigrationCookieAddNBD(qemuMigrationCookiePtr mig, mig->nbd->ndisks =3D 0; if (qemuDomainObjEnterMonitorAsync(driver, vm, priv->job.asyncJob) < 0) - goto cleanup; + return -1; rc =3D qemuMonitorBlockStatsUpdateCapacity(priv->mon, stats, false); if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) - goto cleanup; + return -1; for (i =3D 0; i < vm->def->ndisks; i++) { virDomainDiskDefPtr disk =3D vm->def->disks[i]; @@ -491,9 +491,7 @@ qemuMigrationCookieAddNBD(qemuMigrationCookiePtr mig, mig->nbd->ndisks++; } - ret =3D 0; - cleanup: - return ret; + return 0; } --=20 2.24.1 From nobody Mon Apr 29 10:46:43 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-1.mimecast.com (us-smtp-2.mimecast.com [207.211.31.81]) by mx.zohomail.com with SMTPS id 15803960415521005.713558073891; Thu, 30 Jan 2020 06:54:01 -0800 (PST) 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-201-B0NaMb4KMemeEewFwevjqg-1; Thu, 30 Jan 2020 09:53:58 -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 1CF70108BD0E; Thu, 30 Jan 2020 14:53:53 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E88BF89E82; Thu, 30 Jan 2020 14:53:52 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id A87511808855; Thu, 30 Jan 2020 14:53:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 00UErn11026891 for ; Thu, 30 Jan 2020 09:53:49 -0500 Received: by smtp.corp.redhat.com (Postfix) id 624A7845C9; Thu, 30 Jan 2020 14:53:49 +0000 (UTC) Received: from angien.redhat.com (unknown [10.43.2.48]) by smtp.corp.redhat.com (Postfix) with ESMTP id E00AC84773 for ; Thu, 30 Jan 2020 14:53:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1580396040; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=pFx/5G8XX4jnhXeUoBwhLNDXnaHDk+JtjcQR6m1KR+0=; b=InsYUt24OlmmrrAfodUL4z+y901Lu+LlSnIjzdpQ/5F0Oly7m93RxFt0GDuH9/M/ZYJhmY ooS5BXnRm29nQFPTJxv6rYJC1JdV/Ws5rRCNGH5i64OHPlnsuEGIZ9bXrFwQFIxHOV5SCb iegys8HwfLm3jf/60Z3JQD3+N4orgXI= From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 10/10] qemuMigrationCookieAddNBD: Fix filling of 'capacity' when blockdev is used Date: Thu, 30 Jan 2020 15:53:30 +0100 Message-Id: <59fefd0a3c71a7cd8a72bc26427e71c46cf4da2e.1580395954.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-MC-Unique: B0NaMb4KMemeEewFwevjqg-1 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" With -blockdev we must look up via the nodename rather than the 'drive' alias which is not present any more. This fixes the pre-creation of storage volumes on migration with non-shared storage. https://bugzilla.redhat.com/show_bug.cgi?id=3D1793263 Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_migration_cookie.c | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_coo= kie.c index 734d95f4f1..a5a9edffc3 100644 --- a/src/qemu/qemu_migration_cookie.c +++ b/src/qemu/qemu_migration_cookie.c @@ -455,6 +455,7 @@ qemuMigrationCookieAddNBD(qemuMigrationCookiePtr mig, { qemuDomainObjPrivatePtr priv =3D vm->privateData; g_autoptr(virHashTable) stats =3D virHashNew(virHashValueFree); + bool blockdev =3D virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV); size_t i; int rc; @@ -474,7 +475,10 @@ qemuMigrationCookieAddNBD(qemuMigrationCookiePtr mig, if (qemuDomainObjEnterMonitorAsync(driver, vm, priv->job.asyncJob) < 0) return -1; - rc =3D qemuMonitorBlockStatsUpdateCapacity(priv->mon, stats, false); + if (blockdev) + rc =3D qemuMonitorBlockStatsUpdateCapacityBlockdev(priv->mon, stat= s); + else + rc =3D qemuMonitorBlockStatsUpdateCapacity(priv->mon, stats, false= ); if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) return -1; @@ -482,9 +486,14 @@ qemuMigrationCookieAddNBD(qemuMigrationCookiePtr mig, virDomainDiskDefPtr disk =3D vm->def->disks[i]; qemuBlockStats *entry; - if (!disk->info.alias || - !(entry =3D virHashLookup(stats, disk->info.alias))) - continue; + if (blockdev) { + if (!(entry =3D virHashLookup(stats, disk->src->nodeformat))) + continue; + } else { + if (!disk->info.alias || + !(entry =3D virHashLookup(stats, disk->info.alias))) + continue; + } mig->nbd->disks[mig->nbd->ndisks].target =3D g_strdup(disk->dst); mig->nbd->disks[mig->nbd->ndisks].capacity =3D entry->capacity; --=20 2.24.1