From nobody Sun Dec 22 06:30:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1727703025493233.49852372696716; Mon, 30 Sep 2024 06:30:25 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 6E78F14BC; Mon, 30 Sep 2024 09:30:24 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id CC74F1252; Mon, 30 Sep 2024 09:29:45 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 858ACC61; Mon, 30 Sep 2024 09:29:41 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 17AA411BA for ; Mon, 30 Sep 2024 09:29:41 -0400 (EDT) Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-532-B1kLlrB_MP-gTdEMnJ0aGA-1; Mon, 30 Sep 2024 09:29:39 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (unknown [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id C3F1C1977025 for ; Mon, 30 Sep 2024 13:29:38 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.12]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 0407319541A0 for ; Mon, 30 Sep 2024 13:29:37 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727702980; h=from:from: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; bh=fnahIHwKlym0VH+EMXYzTiIBkMYDVXaOz+mTtiJQbOE=; b=AMC+Nh+Siq5rcVApxMaWfaJSo4CPUQp7Ni2PdhnPFb77rDRHhbZvWl4n1m3Euhel74rjFC A2CE1aQMTYn65F4xEIuXmwou6PfmlnXOkdwJQfMR2brSMxMkDZ0Ys1cldNhCkiF+DheJQD fDISVvnMCWfm2CArZzmrpaiIHtp5ZMM= X-MC-Unique: B1kLlrB_MP-gTdEMnJ0aGA-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 01/13] qemu: migration: Pre-create QCOW2 images for non-shared storage with 0 allocation Date: Mon, 30 Sep 2024 15:29:23 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: LNWHHNOCLZQ62JDFZVB6NPJJT2MV6IIT X-Message-ID-Hash: LNWHHNOCLZQ62JDFZVB6NPJJT2MV6IIT X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1727703026362116600 Content-Type: text/plain; charset="utf-8" Specify that the parameter for the newly-created qcow2 image is 0 so that only metadata gets preallocated. Otherwise the storage driver code instructs qemu to use 'fallocate' preallocation mode and considers the image fully allocated. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/qemu/qemu_migration.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 7f905f8584..b686e42e58 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -361,6 +361,8 @@ qemuMigrationDstPrecreateDisk(virConnectPtr *conn, virBufferAddLit(&buf, "\n"); virBufferAdjustIndent(&buf, 2); virBufferEscapeString(&buf, "%s\n", volName); + if (disk->src->format =3D=3D VIR_STORAGE_FILE_QCOW2) + virBufferAddLit(&buf, "0\n"); virBufferAsprintf(&buf, "%llu\n", capacity); virBufferAddLit(&buf, "\n"); virBufferAdjustIndent(&buf, 2); --=20 2.46.0 From nobody Sun Dec 22 06:30:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1727703048993140.18007905477452; Mon, 30 Sep 2024 06:30:48 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id E461D1522; Mon, 30 Sep 2024 09:30:47 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 077581452; Mon, 30 Sep 2024 09:29:49 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 3A066124D; Mon, 30 Sep 2024 09:29:43 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id B784DC61 for ; Mon, 30 Sep 2024 09:29:42 -0400 (EDT) Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-489-8LUhJYZ1OuWO0rmeeWevqg-1; Mon, 30 Sep 2024 09:29:40 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (unknown [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 0F5E619772F6 for ; Mon, 30 Sep 2024 13:29:40 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.12]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5125119541A0 for ; Mon, 30 Sep 2024 13:29:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727702982; h=from:from: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; bh=NjIm7/i3mvEYClBqnOvAf4uQ9Yf4L87GsJLy7e17go4=; b=BxAq6G97inKW+HMtx2hgWAChn6bNdWRy5T3iO2ROrvyV8W54ZcPJdv0OWizPfSQdL24DmY 5op+/bKR+JcL6Ju0UAajUaUdTYO5EGTQ61vrhv/H9W5qNxfjEcFhC+XdZMXPKJMlvJ7bdK xJVO3Rv+0aj/2Z7q868tS0/tklKvQXc= X-MC-Unique: 8LUhJYZ1OuWO0rmeeWevqg-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 02/13] virTypedParamsFilter: Adjust return type and docs Date: Mon, 30 Sep 2024 15:29:24 +0200 Message-ID: <9708a9fe5ae4eece26e73f89ce364b5b0cda5fd8.1727702835.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: UU4HKSZP2URXBYWQVZGVQ4SDHUVQD7O4 X-Message-ID-Hash: UU4HKSZP2URXBYWQVZGVQ4SDHUVQD7O4 X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1727703050566116600 Content-Type: text/plain; charset="utf-8" The 'virTypedParamsFilter' function can't fail and thus it never returns negative values. Change the return type to 'size_t' and adjust callers to not check the return value for being negative. Adjust the docs to hilight this and also the fact that the filtered typed param list returned via @ret is not a deep copy and thus callers must not use the common function to free it. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/util/virtypedparam.c | 19 ++++++++++--------- src/util/virtypedparam.h | 2 +- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c index 1be249d855..634385aa97 100644 --- a/src/util/virtypedparam.c +++ b/src/util/virtypedparam.c @@ -394,18 +394,22 @@ virTypedParamsCopy(virTypedParameterPtr *dst, * @ret: pointer to the returned array * * Filters @params retaining only the parameters named @name in the - * resulting array @ret. Caller should free the @ret array but not - * the items since they are pointing to the @params elements. + * resulting array @ret. * - * Returns amount of elements in @ret on success, -1 on error. + * Important Caller should free the @ret array but not the items since the= y are + * pointing to the @params elements. I.e. callers must not use + * 'virTypedParamsFree' or equivalent on pointer returned via @ret. + * + * Returns amount of elements in @ret. */ -int +size_t virTypedParamsFilter(virTypedParameterPtr params, int nparams, const char *name, virTypedParameterPtr **ret) { - size_t i, n =3D 0; + size_t i; + size_t n =3D 0; *ret =3D g_new0(virTypedParameterPtr, nparams); @@ -443,7 +447,7 @@ virTypedParamsGetStringList(virTypedParameterPtr params, const char ***values) { size_t i, n; - int nfiltered; + size_t nfiltered; virTypedParameterPtr *filtered =3D NULL; virCheckNonNullArgGoto(values, error); @@ -451,9 +455,6 @@ virTypedParamsGetStringList(virTypedParameterPtr params, nfiltered =3D virTypedParamsFilter(params, nparams, name, &filtered); - if (nfiltered < 0) - goto error; - if (nfiltered) *values =3D g_new0(const char *, nfiltered); diff --git a/src/util/virtypedparam.h b/src/util/virtypedparam.h index 7454ef3ce0..afd923aacb 100644 --- a/src/util/virtypedparam.h +++ b/src/util/virtypedparam.h @@ -81,7 +81,7 @@ virTypedParamsGetStringList(virTypedParameterPtr params, int nparams, const char *name, const char ***values); -int +size_t virTypedParamsFilter(virTypedParameterPtr params, int nparams, const char *name, --=20 2.46.0 From nobody Sun Dec 22 06:30:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1727703102027676.2740982865928; Mon, 30 Sep 2024 06:31:42 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 02AD2123C; Mon, 30 Sep 2024 09:31:41 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id DF07E1453; Mon, 30 Sep 2024 09:29:57 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 2CE3B13DA; Mon, 30 Sep 2024 09:29:53 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 5EE3A1417 for ; Mon, 30 Sep 2024 09:29:45 -0400 (EDT) Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-547-TUchAvG6Mge9Q7NEjCOT5Q-1; Mon, 30 Sep 2024 09:29:42 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (unknown [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 509FA1903361 for ; Mon, 30 Sep 2024 13:29:41 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.12]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 896F019541A0 for ; Mon, 30 Sep 2024 13:29:40 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727702985; h=from:from: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; bh=NVADxGRbZ9CPhsweuaxBqbxRKOiHAdoVGufwHQE1Hno=; b=Op+jci53/qeLbQnxNhIuuBffE9nvFZg4dVSICyXjUC1YjxBUo4cPj0vLDAxDXxhc0bq/fo xyv6FSXrm4/y60s4WYMCQ7HCwY22CITE7QGqnewQ1SAq/i8AoMSXI5q/GlAPo12iGuize6 jQ+d5p7liB3JV/K+oaD2E33gAdFqcoc= X-MC-Unique: TUchAvG6Mge9Q7NEjCOT5Q-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 03/13] virTypedParamsGetStringList: Refactor and adjust docs Date: Mon, 30 Sep 2024 15:29:25 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: FN3XAWHU2BS6FWJDSYGXEWBJMGQFSNSI X-Message-ID-Hash: FN3XAWHU2BS6FWJDSYGXEWBJMGQFSNSI X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1727703102842116600 Content-Type: text/plain; charset="utf-8" Use automatic freeing, declare one variable per line and return early when possible. As this is an internal helper there's no need to check that the caller passed non-NULL @values. Modify the documentation to be accurate and warn callers to not free the strings just the array. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/util/virtypedparam.c | 33 ++++++++++++++------------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c index 634385aa97..86fbaf5e9d 100644 --- a/src/util/virtypedparam.c +++ b/src/util/virtypedparam.c @@ -432,13 +432,13 @@ virTypedParamsFilter(virTypedParameterPtr params, * @values: array of returned values * * Finds all parameters with desired @name within @params and - * store their values into @values. The @values array is self - * allocated and its length is stored into @picked. When no - * longer needed, caller should free the returned array, but not - * the items since they are taken from @params array. + * store their values into @values. * - * Returns amount of strings in @values array on success, - * -1 otherwise. + * Important: The strings in the returned string list @values are borrowed= from + * @params and thus caller must free only the pointer returned as @values,= but + * not the contents. + * + * Returns amount of strings in @values array on success. */ int virTypedParamsGetStringList(virTypedParameterPtr params, @@ -446,31 +446,26 @@ virTypedParamsGetStringList(virTypedParameterPtr para= ms, const char *name, const char ***values) { - size_t i, n; + size_t i; + size_t n =3D 0; size_t nfiltered; - virTypedParameterPtr *filtered =3D NULL; + g_autofree virTypedParameterPtr *filtered =3D NULL; - virCheckNonNullArgGoto(values, error); *values =3D NULL; nfiltered =3D virTypedParamsFilter(params, nparams, name, &filtered); - if (nfiltered) - *values =3D g_new0(const char *, nfiltered); + if (nfiltered =3D=3D 0) + return 0; + + *values =3D g_new0(const char *, nfiltered); - for (n =3D 0, i =3D 0; i < nfiltered; i++) { + for (i =3D 0; i < nfiltered; i++) { if (filtered[i]->type =3D=3D VIR_TYPED_PARAM_STRING) (*values)[n++] =3D filtered[i]->value.s; } - VIR_FREE(filtered); return n; - - error: - if (values) - VIR_FREE(*values); - VIR_FREE(filtered); - return -1; } --=20 2.46.0 From nobody Sun Dec 22 06:30:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1727703079555519.0253124887761; Mon, 30 Sep 2024 06:31:19 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 539CE1539; Mon, 30 Sep 2024 09:31:18 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 34F701449; Mon, 30 Sep 2024 09:29:56 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 06E711351; Mon, 30 Sep 2024 09:29:50 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id AEA73138B for ; Mon, 30 Sep 2024 09:29:44 -0400 (EDT) Received: from mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-557-OOemoBndOyq8n4HPLL209Q-1; Mon, 30 Sep 2024 09:29:43 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (unknown [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-04.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 8164C1902FF0 for ; Mon, 30 Sep 2024 13:29:42 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.12]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id C2B8319541A0 for ; Mon, 30 Sep 2024 13:29:41 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727702984; h=from:from: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; bh=PRj1P3xCv0sR2zh5GrTV/j88L751Eut/CE7PCb5pypY=; b=MWixYU9twXQlVOUlJFbIquooSArIuv2wxd2rT62cLsy7/Qvjs7fqyzE7imYVjZxcl5iAPD S4ZAGhghfRA8jAruisP9vPfGi5F08RUZ1knn4eX1NbM+x+ZHi0u+0tUprA7ADQlv5wk8ct lxrWpprsDCj26Y+P2Xk1MYinZfAaAQk= X-MC-Unique: OOemoBndOyq8n4HPLL209Q-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 04/13] virTypedParamsFilter: Introduce option to filter also by type Date: Mon, 30 Sep 2024 15:29:26 +0200 Message-ID: <21f59b57965bac313d55e7e498f247fd5920dbac.1727702835.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: IJXCOSDKZ2HGPK66UZ76DW6T4LGNIJ7T X-Message-ID-Hash: IJXCOSDKZ2HGPK66UZ76DW6T4LGNIJ7T X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1727703080939116600 Content-Type: text/plain; charset="utf-8" The only caller of this function is doing some additional filtering so it's useful if the filtering function was able to do so internally. Introduce a 'type' parameter which will optionally filter the results by type and extend the testsuite to cover this scenario. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/util/virtypedparam.c | 19 +++++++++++++------ src/util/virtypedparam.h | 1 + tests/virtypedparamtest.c | 14 +++++++++++--- 3 files changed, 25 insertions(+), 9 deletions(-) diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c index 86fbaf5e9d..a080d7ba0f 100644 --- a/src/util/virtypedparam.c +++ b/src/util/virtypedparam.c @@ -391,10 +391,12 @@ virTypedParamsCopy(virTypedParameterPtr *dst, * @params: array of typed parameters * @nparams: number of parameters in the @params array * @name: name of the parameter to find + * @type: type of fields to filter (ignored if 0 is passed) * @ret: pointer to the returned array * * Filters @params retaining only the parameters named @name in the - * resulting array @ret. + * resulting array @ret. If @type is non-zero it also filters out paramete= rs + * whose type doesn't match @type. * * Important Caller should free the @ret array but not the items since the= y are * pointing to the @params elements. I.e. callers must not use @@ -406,6 +408,7 @@ size_t virTypedParamsFilter(virTypedParameterPtr params, int nparams, const char *name, + int type, virTypedParameterPtr **ret) { size_t i; @@ -414,10 +417,14 @@ virTypedParamsFilter(virTypedParameterPtr params, *ret =3D g_new0(virTypedParameterPtr, nparams); for (i =3D 0; i < nparams; i++) { - if (STREQ(params[i].field, name)) { - (*ret)[n] =3D ¶ms[i]; - n++; - } + if (STRNEQ(params[i].field, name)) + continue; + + if (type !=3D 0 && + params[i].type !=3D type) + continue; + + (*ret)[n++] =3D ¶ms[i]; } return n; @@ -453,7 +460,7 @@ virTypedParamsGetStringList(virTypedParameterPtr params, *values =3D NULL; - nfiltered =3D virTypedParamsFilter(params, nparams, name, &filtered); + nfiltered =3D virTypedParamsFilter(params, nparams, name, 0, &filtered= ); if (nfiltered =3D=3D 0) return 0; diff --git a/src/util/virtypedparam.h b/src/util/virtypedparam.h index afd923aacb..774744244a 100644 --- a/src/util/virtypedparam.h +++ b/src/util/virtypedparam.h @@ -85,6 +85,7 @@ size_t virTypedParamsFilter(virTypedParameterPtr params, int nparams, const char *name, + int type, virTypedParameterPtr **ret) G_GNUC_WARN_UNUSED_RESULT; diff --git a/tests/virtypedparamtest.c b/tests/virtypedparamtest.c index 5ced453be5..1a8b49383f 100644 --- a/tests/virtypedparamtest.c +++ b/tests/virtypedparamtest.c @@ -91,13 +91,14 @@ testTypedParamsFilter(const void *opaque G_GNUC_UNUSED) { .field =3D "bar", .type =3D VIR_TYPED_PARAM_UINT }, { .field =3D "foo", .type =3D VIR_TYPED_PARAM_INT }, { .field =3D "foobar", .type =3D VIR_TYPED_PARAM_STRING }, - { .field =3D "foo", .type =3D VIR_TYPED_PARAM_INT } + { .field =3D "foo", .type =3D VIR_TYPED_PARAM_INT }, + { .field =3D "foobar", .type =3D VIR_TYPED_PARAM_INT }, }; virTypedParameterPtr *filtered =3D NULL; nfiltered =3D virTypedParamsFilter(params, G_N_ELEMENTS(params), - "foo", &filtered); + "foo", 0, &filtered); if (nfiltered !=3D 3) goto cleanup; @@ -108,7 +109,7 @@ testTypedParamsFilter(const void *opaque G_GNUC_UNUSED) VIR_FREE(filtered); nfiltered =3D virTypedParamsFilter(params, G_N_ELEMENTS(params), - "bar", &filtered); + "bar", VIR_TYPED_PARAM_UINT, &filtere= d); if (nfiltered !=3D 2) goto cleanup; @@ -117,6 +118,13 @@ testTypedParamsFilter(const void *opaque G_GNUC_UNUSED) if (filtered[i] !=3D ¶ms[i * 2]) goto cleanup; } + VIR_FREE(filtered); + + nfiltered =3D virTypedParamsFilter(params, G_N_ELEMENTS(params), + "foobar", VIR_TYPED_PARAM_STRING, &fi= ltered); + + if (nfiltered !=3D 1) + goto cleanup; rv =3D 0; cleanup: --=20 2.46.0 From nobody Sun Dec 22 06:30:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1727703130316504.5071030760066; Mon, 30 Sep 2024 06:32:10 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 058ED14EC; Mon, 30 Sep 2024 09:32:08 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 8789A1467; Mon, 30 Sep 2024 09:30:03 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 1308A12E1; Mon, 30 Sep 2024 09:29:58 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 288D412E1 for ; Mon, 30 Sep 2024 09:29:46 -0400 (EDT) Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-177-H7IBBfLKOX6pTY3LmYWqrg-1; Mon, 30 Sep 2024 09:29:44 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (unknown [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id B9E65190DE24 for ; Mon, 30 Sep 2024 13:29:43 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.12]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id F357219541A0 for ; Mon, 30 Sep 2024 13:29:42 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727702985; h=from:from: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; bh=lNCnnEZr8z2I6WyMDOGOm45Wv5rgFXvA4IcLM4NgDns=; b=N6yMv/jz8egLlDZDVawHbZGZAgTWy05f7Coqq6R/9vVAAgsx3I9xvzVKUMSLHPVJ05nA+t ogbJBWDy3o6Pu3UV5Rcj4GH+WS1mm7/s1RY3kjZWOPVl0a369GNayKQITr3+OGFHgP0iop kI2wxOoalzLi9rjVGHhPJ6CFFYIdfbg= X-MC-Unique: H7IBBfLKOX6pTY3LmYWqrg-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 05/13] virTypedParamsGetStringList: Ensure that returned array is NULL if there are no matching fields Date: Mon, 30 Sep 2024 15:29:27 +0200 Message-ID: <97fad66240cd390ac7b602bafd7d28b457f87488.1727702835.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: O2ZFG6ZQFJJWBV4DZ2QTH7IWWDXBZ2FY X-Message-ID-Hash: O2ZFG6ZQFJJWBV4DZ2QTH7IWWDXBZ2FY X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1727703130979116600 Content-Type: text/plain; charset="utf-8" 'virTypedParamsGetStringList' fills the returned array only with string parameters with matching name. The filtering code though leaves the possibility that all items are filtered out but the return array is still (over)allocated. Since 'virTypedParamsFilter()' now also allows filtering by type we can move the filtering there ensuring that we always allocate the right number of elements and more importantly the returned array will be NULL if none elements are present. Rework the code and adjust docs. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/util/virtypedparam.c | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c index a080d7ba0f..564cb81acc 100644 --- a/src/util/virtypedparam.c +++ b/src/util/virtypedparam.c @@ -439,7 +439,8 @@ virTypedParamsFilter(virTypedParameterPtr params, * @values: array of returned values * * Finds all parameters with desired @name within @params and - * store their values into @values. + * store their values into @values. If none of the @params are strings nam= ed + * @name the returned @values will be NULL. * * Important: The strings in the returned string list @values are borrowed= from * @params and thus caller must free only the pointer returned as @values,= but @@ -454,13 +455,12 @@ virTypedParamsGetStringList(virTypedParameterPtr para= ms, const char ***values) { size_t i; - size_t n =3D 0; size_t nfiltered; g_autofree virTypedParameterPtr *filtered =3D NULL; *values =3D NULL; - nfiltered =3D virTypedParamsFilter(params, nparams, name, 0, &filtered= ); + nfiltered =3D virTypedParamsFilter(params, nparams, name, VIR_TYPED_PA= RAM_STRING, &filtered); if (nfiltered =3D=3D 0) return 0; @@ -468,11 +468,10 @@ virTypedParamsGetStringList(virTypedParameterPtr para= ms, *values =3D g_new0(const char *, nfiltered); for (i =3D 0; i < nfiltered; i++) { - if (filtered[i]->type =3D=3D VIR_TYPED_PARAM_STRING) - (*values)[n++] =3D filtered[i]->value.s; + (*values)[i] =3D filtered[i]->value.s; } - return n; + return nfiltered; } --=20 2.46.0 From nobody Sun Dec 22 06:30:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1727703148935460.1209773163881; Mon, 30 Sep 2024 06:32:28 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id CAF5012DF; Mon, 30 Sep 2024 09:32:27 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 6DC2D14F3; Mon, 30 Sep 2024 09:30:05 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id A47D112F8; Mon, 30 Sep 2024 09:29:58 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 4D0901281 for ; Mon, 30 Sep 2024 09:29:47 -0400 (EDT) Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-313-oiUgI1qRPKq4fqYSfpkeZw-1; Mon, 30 Sep 2024 09:29:45 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (unknown [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id F098318DB426 for ; Mon, 30 Sep 2024 13:29:44 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.12]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 37AC919541A0 for ; Mon, 30 Sep 2024 13:29:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727702986; h=from:from: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; bh=rJ/dnPLAYoBpuJ+CjsbXOvGKxRRJjNcF1rFRzn2kbyU=; b=L4lPhfUdvrl/KcfsY4ARxuPnC/FQeAS/HXxPfk3UN7TBMg9qvL0WeGOLaRbautC4oM3DnO 1p2cZZ51gXtUmE/TV9WavqackQawJFx/4LhWe4eS3yW/wdCHdlWhF9GjKh3FEj1wZPoSws f/RZuK7UV+l42kOdlnDy76Z6QKN7bDE= X-MC-Unique: oiUgI1qRPKq4fqYSfpkeZw-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 06/13] virTypedParamsGetStringList: Ensure that returned string list is NULL-terminated Date: Mon, 30 Sep 2024 15:29:28 +0200 Message-ID: <102a4a2f387177b3c357d8b5eb963cda46a1d1c4.1727702835.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 5MKWUXKFSOE5Y43GZAYFQIIYHGZEWZVF X-Message-ID-Hash: 5MKWUXKFSOE5Y43GZAYFQIIYHGZEWZVF X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1727703151144116600 Content-Type: text/plain; charset="utf-8" This can simplify callers who don't really need to know the number of elements to check that a particular element is present. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/util/virtypedparam.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/util/virtypedparam.c b/src/util/virtypedparam.c index 564cb81acc..f25530a735 100644 --- a/src/util/virtypedparam.c +++ b/src/util/virtypedparam.c @@ -439,8 +439,8 @@ virTypedParamsFilter(virTypedParameterPtr params, * @values: array of returned values * * Finds all parameters with desired @name within @params and - * store their values into @values. If none of the @params are strings nam= ed - * @name the returned @values will be NULL. + * store their values into a NULL-terminated string list @values. If none = of + * the @params are strings named @name the returned @values will be NULL. * * Important: The strings in the returned string list @values are borrowed= from * @params and thus caller must free only the pointer returned as @values,= but @@ -465,7 +465,7 @@ virTypedParamsGetStringList(virTypedParameterPtr params, if (nfiltered =3D=3D 0) return 0; - *values =3D g_new0(const char *, nfiltered); + *values =3D g_new0(const char *, nfiltered + 1); for (i =3D 0; i < nfiltered; i++) { (*values)[i] =3D filtered[i]->value.s; --=20 2.46.0 From nobody Sun Dec 22 06:30:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1727703195430436.8362624404323; Mon, 30 Sep 2024 06:33:15 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 665DA1187; Mon, 30 Sep 2024 09:33:14 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id A251D1458; Mon, 30 Sep 2024 09:30:09 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 725F11259; Mon, 30 Sep 2024 09:30:00 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id DC5F112DC for ; Mon, 30 Sep 2024 09:29:49 -0400 (EDT) Received: from mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-515-Ii71HGJRNgy8FPwbNuP9ag-1; Mon, 30 Sep 2024 09:29:46 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (unknown [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 32ACE19033CC for ; Mon, 30 Sep 2024 13:29:46 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.12]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 6E80319541A0 for ; Mon, 30 Sep 2024 13:29:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727702989; h=from:from: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; bh=MWJbt3f7/Kwe82/4dXPgCHjJNhMh0JLlKraRztf1f8M=; b=foHu5B4TfRHXVkmkgQyXCSPTByhTurSa9j5Cpg/t8C5su6uXazLJqGfL9L2heHSJhCr9kX ofDb3Adczx/p+ligjVXwGhqa+v+8YD9LNhss1iqwafYDzFjkkkgkxpcAhFH+8/1k1EmVj/ QgKS133LBgQJOQBOJR1ScF0LW6qL0Ms= X-MC-Unique: Ii71HGJRNgy8FPwbNuP9ag-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 07/13] qemuMigrationSrcBeginPhaseBlockDirtyBitmaps: Use qemuMigrationAnyCopyDisk() Date: Mon, 30 Sep 2024 15:29:29 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 4WMMHGDD3XC47PQ6L7ZZ6Z4Z57CBO5XO X-Message-ID-Hash: 4WMMHGDD3XC47PQ6L7ZZ6Z4Z57CBO5XO X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1727703197268116600 Content-Type: text/plain; charset="utf-8" The function open-coded the checking whether a disk is being migrated with non-shared storage and did so badly (not taking into account if user doesn't explicitly provide list of disks to migrate). Use the existing helper instead. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/qemu/qemu_migration.c | 15 ++------------- 1 file changed, 2 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index b686e42e58..a2c5be3e82 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2466,19 +2466,8 @@ qemuMigrationSrcBeginPhaseBlockDirtyBitmaps(qemuMigr= ationCookie *mig, if (!nodedata) continue; - if (migrate_disks) { - bool migrating =3D false; - - for (j =3D 0; j < nmigrate_disks; j++) { - if (STREQ(migrate_disks[j], diskdef->dst)) { - migrating =3D true; - break; - } - } - - if (!migrating) - continue; - } + if (!qemuMigrationAnyCopyDisk(diskdef, nmigrate_disks, migrate_dis= ks)) + continue; for (j =3D 0; j < nodedata->nbitmaps; j++) { qemuMigrationBlockDirtyBitmapsDiskBitmap *bitmap; --=20 2.46.0 From nobody Sun Dec 22 06:30:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1727703176194937.2478180440336; Mon, 30 Sep 2024 06:32:56 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 1B10711F8; Mon, 30 Sep 2024 09:32:55 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 6F3B9151A; Mon, 30 Sep 2024 09:30:07 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 86A2112BA; Mon, 30 Sep 2024 09:29:59 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id BE1591493 for ; Mon, 30 Sep 2024 09:29:49 -0400 (EDT) Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-106-vKJlykr3P66LXNHY6XYtKg-1; Mon, 30 Sep 2024 09:29:48 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (unknown [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 67978196C426 for ; Mon, 30 Sep 2024 13:29:47 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.12]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id A588C19541A0 for ; Mon, 30 Sep 2024 13:29:46 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: * X-Spam-Status: No, score=1.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,PDS_OTHER_BAD_TLD, RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL, RCVD_IN_VALIDITY_RPBL_BLOCKED,RCVD_IN_VALIDITY_SAFE_BLOCKED, SPF_HELO_NONE autolearn=no autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727702989; h=from:from: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; bh=Li0oYLJjHWfjEseev4z82fXJfNAdTPTDtDURc2+Cgvs=; b=VRaZAklCn0FQJxZm+33xtjkBU9KgmzVVgKdf3ShK2kEF2G162GRSDXTqBMuAaQvC+iH0fL Pl7Jra02MhpDyIx7zHQHpiu+ZtHH1lHccUFyA3zCBIWhZWUYg99e5a2dN8HxkY86hWxAsi GzGgzG4yOwcBKPaWAWOTA1eimA7UMII= X-MC-Unique: vKJlykr3P66LXNHY6XYtKg-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 08/13] qemu: migration: Don't log 'nmigrate_disks' Date: Mon, 30 Sep 2024 15:29:30 +0200 Message-ID: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: HF7U55OJEWQSVPAKY6FHAYS5ZUW3DMRJ X-Message-ID-Hash: HF7U55OJEWQSVPAKY6FHAYS5ZUW3DMRJ X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1727703177183116600 Content-Type: text/plain; charset="utf-8" The actual number of disks to migrate is not important. The presence of disks to migrate can be inferred from presence of the 'migrate_disks' pointer which is logged. Since 'nmigrate_disks' will eventually be removed remove the logging right now. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/qemu/qemu_migration.c | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index a2c5be3e82..506699333b 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2599,9 +2599,9 @@ qemuMigrationSrcBeginPhase(virQEMUDriver *driver, VIR_DEBUG("driver=3D%p, vm=3D%p, xmlin=3D%s, dname=3D%s," " cookieout=3D%p, cookieoutlen=3D%p," - " nmigrate_disks=3D%zu, migrate_disks=3D%p, flags=3D0x%x", + " migrate_disks=3D%p, flags=3D0x%x", driver, vm, NULLSTR(xmlin), NULLSTR(dname), - cookieout, cookieoutlen, nmigrate_disks, + cookieout, cookieoutlen, migrate_disks, flags); /* Only set the phase if we are inside VIR_ASYNC_JOB_MIGRATION_OUT. @@ -3735,12 +3735,12 @@ qemuMigrationDstPrepareDirect(virQEMUDriver *driver, VIR_DEBUG("driver=3D%p, dconn=3D%p, cookiein=3D%s, cookieinlen=3D%d, " "cookieout=3D%p, cookieoutlen=3D%p, uri_in=3D%s, uri_out=3D%= p, " "def=3D%p, origname=3D%s, listenAddress=3D%s, " - "nmigrate_disks=3D%zu, migrate_disks=3D%p, nbdPort=3D%d, " + "migrate_disks=3D%p, nbdPort=3D%d, " "nbdURI=3D%s, flags=3D0x%x", driver, dconn, NULLSTR(cookiein), cookieinlen, cookieout, cookieoutlen, NULLSTR(uri_in), uri_out, *def, origname, NULLSTR(listenAddress), - nmigrate_disks, migrate_disks, nbdPort, NULLSTR(nbdURI), + migrate_disks, nbdPort, NULLSTR(nbdURI), flags); *uri_out =3D NULL; @@ -4775,11 +4775,11 @@ qemuMigrationSrcRun(virQEMUDriver *driver, VIR_DEBUG("driver=3D%p, vm=3D%p, cookiein=3D%s, cookieinlen=3D%d, " "cookieout=3D%p, cookieoutlen=3D%p, flags=3D0x%x, resource= =3D%lu, " "spec=3D%p (dest=3D%d, fwd=3D%d), dconn=3D%p, graphicsuri=3D= %s, " - "nmigrate_disks=3D%zu, migrate_disks=3D%p", + "migrate_disks=3D%p", driver, vm, NULLSTR(cookiein), cookieinlen, cookieout, cookieoutlen, flags, resource, spec, spec->destType, spec->fwdType, dconn, - NULLSTR(graphicsuri), nmigrate_disks, migrate_disks); + NULLSTR(graphicsuri), migrate_disks); if (storageMigration) storageMigration =3D qemuMigrationHasAnyStorageMigrationDisks(vm->= def, @@ -5199,10 +5199,10 @@ qemuMigrationSrcPerformNative(virQEMUDriver *driver, VIR_DEBUG("driver=3D%p, vm=3D%p, uri=3D%s, cookiein=3D%s, cookieinlen= =3D%d, " "cookieout=3D%p, cookieoutlen=3D%p, flags=3D0x%x, resource= =3D%lu, " - "graphicsuri=3D%s, nmigrate_disks=3D%zu migrate_disks=3D%p", + "graphicsuri=3D%s, migrate_disks=3D%p", driver, vm, uri, NULLSTR(cookiein), cookieinlen, cookieout, cookieoutlen, flags, resource, - NULLSTR(graphicsuri), nmigrate_disks, migrate_disks); + NULLSTR(graphicsuri), migrate_disks); if (!(uribits =3D qemuMigrationAnyParseURI(uri, NULL))) return -1; @@ -5303,10 +5303,10 @@ qemuMigrationSrcPerformTunnel(virQEMUDriver *driver, VIR_DEBUG("driver=3D%p, vm=3D%p, st=3D%p, cookiein=3D%s, cookieinlen= =3D%d, " "cookieout=3D%p, cookieoutlen=3D%p, flags=3D0x%x, resource= =3D%lu, " - "graphicsuri=3D%s, nmigrate_disks=3D%zu, migrate_disks=3D%p", + "graphicsuri=3D%s, migrate_disks=3D%p", driver, vm, st, NULLSTR(cookiein), cookieinlen, cookieout, cookieoutlen, flags, resource, - NULLSTR(graphicsuri), nmigrate_disks, migrate_disks); + NULLSTR(graphicsuri), migrate_disks); spec.fwdType =3D MIGRATION_FWD_STREAM; spec.fwd.stream =3D st; @@ -5571,11 +5571,11 @@ qemuMigrationSrcPerformPeer2Peer3(virQEMUDriver *dr= iver, VIR_DEBUG("driver=3D%p, sconn=3D%p, dconn=3D%p, dconnuri=3D%s, vm=3D%p= , xmlin=3D%s, " "dname=3D%s, uri=3D%s, graphicsuri=3D%s, listenAddress=3D%s,= " - "nmigrate_disks=3D%zu, migrate_disks=3D%p, nbdPort=3D%d, nbd= URI=3D%s, " + "migrate_disks=3D%p, nbdPort=3D%d, nbdURI=3D%s, " "bandwidth=3D%llu, useParams=3D%d, flags=3D0x%x", driver, sconn, dconn, NULLSTR(dconnuri), vm, NULLSTR(xmlin), NULLSTR(dname), NULLSTR(uri), NULLSTR(graphicsuri), - NULLSTR(listenAddress), nmigrate_disks, migrate_disks, nbdPo= rt, + NULLSTR(listenAddress), migrate_disks, nbdPort, NULLSTR(nbdURI), bandwidth, useParams, flags); /* Unlike the virDomainMigrateVersion3 counterpart, we don't need @@ -5937,12 +5937,12 @@ qemuMigrationSrcPerformPeer2Peer(virQEMUDriver *dri= ver, int rc; VIR_DEBUG("driver=3D%p, sconn=3D%p, vm=3D%p, xmlin=3D%s, dconnuri=3D%s= , uri=3D%s, " - "graphicsuri=3D%s, listenAddress=3D%s, nmigrate_disks=3D%zu,= " + "graphicsuri=3D%s, listenAddress=3D%s, " "migrate_disks=3D%p, nbdPort=3D%d, nbdURI=3D%s, flags=3D0x%x= , " "dname=3D%s, resource=3D%lu", driver, sconn, vm, NULLSTR(xmlin), NULLSTR(dconnuri), NULLSTR(uri), NULLSTR(graphicsuri), NULLSTR(listenAddress), - nmigrate_disks, migrate_disks, nbdPort, NULLSTR(nbdURI), + migrate_disks, nbdPort, NULLSTR(nbdURI), flags, NULLSTR(dname), resource); if (flags & VIR_MIGRATE_TUNNELLED && uri) { @@ -6304,13 +6304,13 @@ qemuMigrationSrcPerform(virQEMUDriver *driver, VIR_DEBUG("driver=3D%p, conn=3D%p, vm=3D%p, xmlin=3D%s, dconnuri=3D%s,= " "uri=3D%s, graphicsuri=3D%s, listenAddress=3D%s, " - "nmigrate_disks=3D%zu, migrate_disks=3D%p, nbdPort=3D%d, " + "migrate_disks=3D%p, nbdPort=3D%d, " "nbdURI=3D%s, " "cookiein=3D%s, cookieinlen=3D%d, cookieout=3D%p, cookieoutl= en=3D%p, " "flags=3D0x%x, dname=3D%s, resource=3D%lu, v3proto=3D%d", driver, conn, vm, NULLSTR(xmlin), NULLSTR(dconnuri), NULLSTR(uri), NULLSTR(graphicsuri), NULLSTR(listenAddress), - nmigrate_disks, migrate_disks, nbdPort, NULLSTR(nbdURI), + migrate_disks, nbdPort, NULLSTR(nbdURI), NULLSTR(cookiein), cookieinlen, cookieout, cookieoutlen, flags, NULLSTR(dname), resource, v3proto); --=20 2.46.0 From nobody Sun Dec 22 06:30:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1727703239528901.7473847553241; Mon, 30 Sep 2024 06:33:59 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 4FA5A15CC; Mon, 30 Sep 2024 09:33:58 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 5CEA11223; Mon, 30 Sep 2024 09:30:14 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 191FF13DA; Mon, 30 Sep 2024 09:30:09 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 2C3151465 for ; Mon, 30 Sep 2024 09:29:54 -0400 (EDT) Received: from mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-30-qnUILzyQOMeuUzu9ZDARdQ-1; Mon, 30 Sep 2024 09:29:51 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (unknown [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 97474193E8E7 for ; Mon, 30 Sep 2024 13:29:48 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.12]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D889719541A0 for ; Mon, 30 Sep 2024 13:29:47 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727702993; h=from:from: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; bh=CXDqJ5SU5JXiIYzqsqUm/6kbK2zj8Tjqfo8A5C28mnw=; b=Xu6wJDBNpMZporPzZkRWrsBzbeiu8Be7M7XVXhF8gCg+WpXLMKrlOhxRpyMPc9yfY72VOW PGhkaGKmSZcUUD6QxnYcSjgqCxYDcZ86nZLrm9Abx9aevU58CX8zs1qQKVYoTobRmGJso6 JsBywUCkTC9vAREZwFLlnrdIJs+FYKY= X-MC-Unique: qnUILzyQOMeuUzu9ZDARdQ-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 09/13] qemu: migration: Avoid use of 'nmigration_disks' Date: Mon, 30 Sep 2024 15:29:31 +0200 Message-ID: <26de2285ef372352b23d0cad461780d0b3e0f1e5.1727702835.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: SDYMCBBH3GVB2CRDE6SSECELLRSDVIS7 X-Message-ID-Hash: SDYMCBBH3GVB2CRDE6SSECELLRSDVIS7 X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1727703241591116600 Content-Type: text/plain; charset="utf-8" 'migration_disks' is a NULL-terminated string list, so the code can be converted to either iterate the string-list, use existing accessors or check the presence of the pointers instead of checking the count. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/qemu/qemu_migration.c | 48 +++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 506699333b..bb466bf1ee 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -382,18 +382,12 @@ qemuMigrationDstPrecreateDisk(virConnectPtr *conn, static bool qemuMigrationAnyCopyDisk(virDomainDiskDef const *disk, - size_t nmigrate_disks, const char **migrate_disks) + size_t nmigrate_disks G_GNUC_UNUSED, + const char **migrate_disks) { - size_t i; - - /* Check if the disk alias is in the list */ - if (nmigrate_disks) { - for (i =3D 0; i < nmigrate_disks; i++) { - if (STREQ(disk->dst, migrate_disks[i])) - return true; - } - return false; - } + /* List of disks to migrate takes priority if present */ + if (migrate_disks) + return g_strv_contains(migrate_disks, disk->dst); /* Default is to migrate only non-shared non-readonly disks * with source */ @@ -2666,19 +2660,20 @@ qemuMigrationSrcBeginPhase(virQEMUDriver *driver, return NULL; } - if (nmigrate_disks) { - size_t i, j; + if (migrate_disks) { + size_t j; + const char **d; + /* Check user requested only known disk targets. */ - for (i =3D 0; i < nmigrate_disks; i++) { + for (d =3D migrate_disks; *d; d++) { for (j =3D 0; j < vm->def->ndisks; j++) { - if (STREQ(vm->def->disks[j]->dst, migrate_disks[i])) + if (STREQ(vm->def->disks[j]->dst, *d)) break; } if (j =3D=3D vm->def->ndisks) { virReportError(VIR_ERR_INVALID_ARG, - _("disk target %1$s not found"), - migrate_disks[i]); + _("disk target %1$s not found"), *d); return NULL; } } @@ -2691,7 +2686,7 @@ qemuMigrationSrcBeginPhase(virQEMUDriver *driver, nmigrate_disks)) cookieFlags |=3D QEMU_MIGRATION_COOKIE_NBD; } else { - if (nmigrate_disks > 0) { + if (migrate_disks) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", _("use of 'VIR_MIGRATE_PARAM_MIGRATE_DISKS' req= uires use of 'VIR_MIGRATE_NON_SHARED_DISK' or 'VIR_MIGRATE_NON_SHARED_INC' = flag")); return NULL; @@ -5566,7 +5561,6 @@ qemuMigrationSrcPerformPeer2Peer3(virQEMUDriver *driv= er, virTypedParameterPtr params =3D NULL; int nparams =3D 0; int maxparams =3D 0; - size_t i; bool offline =3D !!(flags & VIR_MIGRATE_OFFLINE); VIR_DEBUG("driver=3D%p, sconn=3D%p, dconn=3D%p, dconnuri=3D%s, vm=3D%p= , xmlin=3D%s, " @@ -5625,11 +5619,15 @@ qemuMigrationSrcPerformPeer2Peer3(virQEMUDriver *dr= iver, VIR_MIGRATE_PARAM_LISTEN_ADDRESS, listenAddress) < 0) goto cleanup; - for (i =3D 0; i < nmigrate_disks; i++) - if (virTypedParamsAddString(¶ms, &nparams, &maxparams, - VIR_MIGRATE_PARAM_MIGRATE_DISKS, - migrate_disks[i]) < 0) - goto cleanup; + if (migrate_disks) { + const char **d; + + for (d =3D migrate_disks; *d; d++) + if (virTypedParamsAddString(¶ms, &nparams, &maxparams, + VIR_MIGRATE_PARAM_MIGRATE_DISK= S, + *d) < 0) + goto cleanup; + } if (nbdPort && virTypedParamsAddInt(¶ms, &nparams, &maxparams, VIR_MIGRATE_PARAM_DISKS_PORT, @@ -6020,7 +6018,7 @@ qemuMigrationSrcPerformPeer2Peer(virQEMUDriver *drive= r, /* Only xmlin, dname, uri, and bandwidth parameters can be used with * old-style APIs. */ - if (!useParams && (graphicsuri || listenAddress || nmigrate_disks)) { + if (!useParams && (graphicsuri || listenAddress || migrate_disks)) { virReportError(VIR_ERR_ARGUMENT_UNSUPPORTED, "%s", _("Migration APIs with extensible parameters are no= t supported but extended parameters were passed")); goto cleanup; --=20 2.46.0 From nobody Sun Dec 22 06:30:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1727703214079795.7063810890994; Mon, 30 Sep 2024 06:33:34 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id D8705D55; Mon, 30 Sep 2024 09:33:32 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 719581528; Mon, 30 Sep 2024 09:30:11 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 69E681322; Mon, 30 Sep 2024 09:30:02 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 4F6881498 for ; Mon, 30 Sep 2024 09:29:52 -0400 (EDT) Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-270-_FnqW54BMdCEjqgrtl17FA-1; Mon, 30 Sep 2024 09:29:50 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (unknown [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id D0E3A19C9635 for ; Mon, 30 Sep 2024 13:29:49 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.12]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 14E7B19541A0 for ; Mon, 30 Sep 2024 13:29:48 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727702992; h=from:from: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; bh=TzsWd3LmJyyxiQbd0PxolxKtKQP65r24RQVoAbnCbQY=; b=fIT3u/Hny2rK8KY0iMC0j4JmarIYOUX3vXCeG86cOqTGUcP1uEqFtQvrTcIxF9kckUPf1d 7sgBQEUwBJYSy1rusAThJCiIGsuj/IGiTd8vr3FNn2IVEcWGVBUoIWWob09C+ttmXv1YoA +zQah9wesubEwPq4OtDk4X/Rdro0Eis= X-MC-Unique: _FnqW54BMdCEjqgrtl17FA-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 10/13] qemu: migration: Extract validation of disk target list Date: Mon, 30 Sep 2024 15:29:32 +0200 Message-ID: <0d7e2aa8a07eecfe467d0ca02d141a06ddc7506e.1727702835.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: RJO5MOM3QJQI4FDGESJMZHQIDT5EUQXZ X-Message-ID-Hash: RJO5MOM3QJQI4FDGESJMZHQIDT5EUQXZ X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1727703215581116600 Content-Type: text/plain; charset="utf-8" The migration code is checking the disk list provided via VIR_MIGRATE_PARAM_MIGRATE_DISKS against existing disks. Extract it to a helper function as we'll be passing another list of disk targets soon. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/qemu/qemu_migration.c | 52 +++++++++++++++++++++++++-------------- 1 file changed, 34 insertions(+), 18 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index bb466bf1ee..a4efd8bfa7 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -2576,6 +2576,37 @@ qemuMigrationSrcBeginXML(virDomainObj *vm, } +/** + * qemuMigrationSrcBeginPhaseValidateDiskTargetList: + * @vm: domain object + * @disks: NULL-terminated list of disk 'dst' strings to validate + * + * Validates that all members of the @disk list are valid disk targets. + */ +static int +qemuMigrationSrcBeginPhaseValidateDiskTargetList(virDomainObj *vm, + const char **disks) +{ + size_t i; + const char **d; + + for (d =3D disks; *d; d++) { + for (i =3D 0; i < vm->def->ndisks; i++) { + if (STREQ(vm->def->disks[i]->dst, *d)) + break; + } + + if (i =3D=3D vm->def->ndisks) { + virReportError(VIR_ERR_INVALID_ARG, + _("disk target %1$s not found"), *d); + return -1; + } + } + + return 0; +} + + /* The caller is supposed to lock the vm and start a migration job. */ static char * qemuMigrationSrcBeginPhase(virQEMUDriver *driver, @@ -2660,24 +2691,9 @@ qemuMigrationSrcBeginPhase(virQEMUDriver *driver, return NULL; } - if (migrate_disks) { - size_t j; - const char **d; - - /* Check user requested only known disk targets. */ - for (d =3D migrate_disks; *d; d++) { - for (j =3D 0; j < vm->def->ndisks; j++) { - if (STREQ(vm->def->disks[j]->dst, *d)) - break; - } - - if (j =3D=3D vm->def->ndisks) { - virReportError(VIR_ERR_INVALID_ARG, - _("disk target %1$s not found"), *d); - return NULL; - } - } - } + if (migrate_disks && + qemuMigrationSrcBeginPhaseValidateDiskTargetList(vm, migrate_d= isks) < 0) + return NULL; priv->nbdPort =3D 0; --=20 2.46.0 From nobody Sun Dec 22 06:30:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 172770329910870.5608083976773; Mon, 30 Sep 2024 06:34:59 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 0181F1376; Mon, 30 Sep 2024 09:34:57 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 8AE751444; Mon, 30 Sep 2024 09:30:15 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 7BC2513DA; Mon, 30 Sep 2024 09:30:09 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id E93531436 for ; Mon, 30 Sep 2024 09:29:53 -0400 (EDT) Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-111-gSbmsN6jMaiHjkTF9UhD5Q-1; Mon, 30 Sep 2024 09:29:52 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (unknown [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 5E9E518DB41A for ; Mon, 30 Sep 2024 13:29:51 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.12]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 50C1019541A0 for ; Mon, 30 Sep 2024 13:29:50 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727702993; h=from:from: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; bh=P+lLvYEUQ8oCw5oN/0b/m72uHGj7v/vmhR8LZ5IGykU=; b=frM2ILs+tPP3gTyxo2uGyYF4scoH8st0SXRd50YA7593js2Hi1abRYP/Z3Vfzcz1KKmW+J eG4cpIWZLJaIvQgrAhz7kBCpXfTirI8EpZcpigU2ByqDXTZB7CUKswLNNzf7KUqOyemPPg 65j2TKwiZu3aFEQznwbHcBMLjiT6tNk= X-MC-Unique: gSbmsN6jMaiHjkTF9UhD5Q-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 11/13] qemu: migration: Remove 'nmigration_disks' variable from all places Date: Mon, 30 Sep 2024 15:29:33 +0200 Message-ID: <1810ca09d89b121a9f77b3656f7d1700f181e509.1727702835.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: GX46C7LD4Z4VIPLR5GJEDR6PECLNCPZV X-Message-ID-Hash: GX46C7LD4Z4VIPLR5GJEDR6PECLNCPZV X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1727703299935116600 Content-Type: text/plain; charset="utf-8" Now that none of the functions need it we can drop it. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- src/qemu/qemu_driver.c | 47 ++++++----------- src/qemu/qemu_migration.c | 105 ++++++++++++++------------------------ src/qemu/qemu_migration.h | 3 -- 3 files changed, 53 insertions(+), 102 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 609263d026..cec700a36c 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -10732,7 +10732,7 @@ qemuDomainMigratePrepare2(virConnectPtr dconn, return qemuMigrationDstPrepareDirect(driver, dconn, NULL, 0, NULL, NULL, /* No cookie= s */ uri_in, uri_out, - &def, origname, NULL, 0, NULL, 0,= NULL, + &def, origname, NULL, NULL, 0, NU= LL, migParams, flags); } @@ -10782,7 +10782,7 @@ qemuDomainMigratePerform(virDomainPtr dom, * Consume any cookie we were able to decode though */ ret =3D qemuMigrationSrcPerform(driver, dom->conn, vm, NULL, - NULL, dconnuri, uri, NULL, NULL, 0, NULL= , 0, + NULL, dconnuri, uri, NULL, NULL, NULL, 0, NULL, migParams, cookie, cookielen, NULL, NULL, /* No output cookies in v2 */ @@ -10858,7 +10858,7 @@ qemuDomainMigrateBegin3(virDomainPtr domain, } return qemuMigrationSrcBegin(domain->conn, vm, xmlin, dname, - cookieout, cookieoutlen, 0, NULL, flags); + cookieout, cookieoutlen, NULL, flags); } static char * @@ -10872,7 +10872,6 @@ qemuDomainMigrateBegin3Params(virDomainPtr domain, const char *xmlin =3D NULL; const char *dname =3D NULL; g_autofree const char **migrate_disks =3D NULL; - int nmigrate_disks; virDomainObj *vm; virCheckFlags(QEMU_MIGRATION_FLAGS, NULL); @@ -10887,12 +10886,8 @@ qemuDomainMigrateBegin3Params(virDomainPtr domain, &dname) < 0) return NULL; - nmigrate_disks =3D virTypedParamsGetStringList(params, nparams, - VIR_MIGRATE_PARAM_MIGRATE= _DISKS, - &migrate_disks); - - if (nmigrate_disks < 0) - return NULL; + virTypedParamsGetStringList(params, nparams, VIR_MIGRATE_PARAM_MIGRATE= _DISKS, + &migrate_disks); if (!(vm =3D qemuDomainObjFromDomain(domain))) return NULL; @@ -10904,7 +10899,7 @@ qemuDomainMigrateBegin3Params(virDomainPtr domain, return qemuMigrationSrcBegin(domain->conn, vm, xmlin, dname, cookieout, cookieoutlen, - nmigrate_disks, migrate_disks, flags); + migrate_disks, flags); } @@ -10951,7 +10946,7 @@ qemuDomainMigratePrepare3(virConnectPtr dconn, cookiein, cookieinlen, cookieout, cookieoutlen, uri_in, uri_out, - &def, origname, NULL, 0, NULL, 0, + &def, origname, NULL, NULL, 0, NULL, migParams, flags); } @@ -10974,7 +10969,6 @@ qemuDomainMigratePrepare3Params(virConnectPtr dconn, const char *uri_in =3D NULL; const char *listenAddress =3D NULL; int nbdPort =3D 0; - int nmigrate_disks; g_autofree const char **migrate_disks =3D NULL; g_autofree char *origname =3D NULL; g_autoptr(qemuMigrationParams) migParams =3D NULL; @@ -11004,19 +10998,15 @@ qemuDomainMigratePrepare3Params(virConnectPtr dco= nn, &nbdPort) < 0) return -1; - nmigrate_disks =3D virTypedParamsGetStringList(params, nparams, - VIR_MIGRATE_PARAM_MIGRATE= _DISKS, - &migrate_disks); - - if (nmigrate_disks < 0) - return -1; + virTypedParamsGetStringList(params, nparams, VIR_MIGRATE_PARAM_MIGRATE= _DISKS, + &migrate_disks); if (!(migParams =3D qemuMigrationParamsFromFlags(params, nparams, flag= s, QEMU_MIGRATION_DESTINAT= ION))) return -1; if (flags & (VIR_MIGRATE_NON_SHARED_DISK | VIR_MIGRATE_NON_SHARED_INC)= || - nmigrate_disks > 0) { + migrate_disks) { if (uri_in && STRPREFIX(uri_in, "unix:") && !nbdURI) { virReportError(VIR_ERR_INVALID_ARG, "%s", _("NBD URI must be supplied when migration URI = uses UNIX transport method")); @@ -11060,7 +11050,7 @@ qemuDomainMigratePrepare3Params(virConnectPtr dconn, cookieout, cookieoutlen, uri_in, uri_out, &def, origname, listenAddress, - nmigrate_disks, migrate_disks, nb= dPort, + migrate_disks, nbdPort, nbdURI, migParams, flags); } @@ -11190,7 +11180,7 @@ qemuDomainMigratePerform3(virDomainPtr dom, goto cleanup; ret =3D qemuMigrationSrcPerform(driver, dom->conn, vm, xmlin, NULL, - dconnuri, uri, NULL, NULL, 0, NULL, 0, + dconnuri, uri, NULL, NULL, NULL, 0, NULL, migParams, cookiein, cookieinlen, cookieout, cookieoutlen, @@ -11220,7 +11210,6 @@ qemuDomainMigratePerform3Params(virDomainPtr dom, const char *uri =3D NULL; const char *graphicsuri =3D NULL; const char *listenAddress =3D NULL; - int nmigrate_disks; g_autofree const char **migrate_disks =3D NULL; unsigned long long bandwidth =3D 0; int nbdPort =3D 0; @@ -11276,15 +11265,11 @@ qemuDomainMigratePerform3Params(virDomainPtr dom, } } - nmigrate_disks =3D virTypedParamsGetStringList(params, nparams, - VIR_MIGRATE_PARAM_MIGRATE= _DISKS, - &migrate_disks); - - if (nmigrate_disks < 0) - goto cleanup; + virTypedParamsGetStringList(params, nparams, VIR_MIGRATE_PARAM_MIGRATE= _DISKS, + &migrate_disks); if (flags & (VIR_MIGRATE_NON_SHARED_DISK | VIR_MIGRATE_NON_SHARED_INC)= || - nmigrate_disks > 0) { + migrate_disks) { if (uri && STRPREFIX(uri, "unix:") && !nbdURI) { virReportError(VIR_ERR_INVALID_ARG, "%s", _("NBD URI must be supplied when migration URI = uses UNIX transport method")); @@ -11304,7 +11289,7 @@ qemuDomainMigratePerform3Params(virDomainPtr dom, ret =3D qemuMigrationSrcPerform(driver, dom->conn, vm, dom_xml, persis= t_xml, dconnuri, uri, graphicsuri, listenAddres= s, - nmigrate_disks, migrate_disks, nbdPort, + migrate_disks, nbdPort, nbdURI, migParams, cookiein, cookieinlen, cookieout, cookie= outlen, flags, dname, bandwidth, true); diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index a4efd8bfa7..94636e778d 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -382,7 +382,6 @@ qemuMigrationDstPrecreateDisk(virConnectPtr *conn, static bool qemuMigrationAnyCopyDisk(virDomainDiskDef const *disk, - size_t nmigrate_disks G_GNUC_UNUSED, const char **migrate_disks) { /* List of disks to migrate takes priority if present */ @@ -398,13 +397,12 @@ qemuMigrationAnyCopyDisk(virDomainDiskDef const *disk, static bool qemuMigrationHasAnyStorageMigrationDisks(virDomainDef *def, - const char **migrate_disks, - size_t nmigrate_disks) + const char **migrate_disks) { size_t i; for (i =3D 0; i < def->ndisks; i++) { - if (qemuMigrationAnyCopyDisk(def->disks[i], nmigrate_disks, migrat= e_disks)) + if (qemuMigrationAnyCopyDisk(def->disks[i], migrate_disks)) return true; } @@ -415,7 +413,6 @@ qemuMigrationHasAnyStorageMigrationDisks(virDomainDef *= def, static int qemuMigrationDstPrepareStorage(virDomainObj *vm, qemuMigrationCookieNBD *nbd, - size_t nmigrate_disks, const char **migrate_disks, bool incremental) { @@ -440,7 +437,7 @@ qemuMigrationDstPrepareStorage(virDomainObj *vm, } /* Skip disks we don't want to migrate. */ - if (!qemuMigrationAnyCopyDisk(disk, nmigrate_disks, migrate_disks)) + if (!qemuMigrationAnyCopyDisk(disk, migrate_disks)) continue; switch (virStorageSourceGetActualType(disk->src)) { @@ -547,7 +544,6 @@ static int qemuMigrationDstStartNBDServer(virQEMUDriver *driver, virDomainObj *vm, const char *listenAddr, - size_t nmigrate_disks, const char **migrate_disks, int nbdPort, const char *nbdURI, @@ -614,7 +610,7 @@ qemuMigrationDstStartNBDServer(virQEMUDriver *driver, g_autofree char *diskAlias =3D NULL; /* check whether disk should be migrated */ - if (!qemuMigrationAnyCopyDisk(disk, nmigrate_disks, migrate_disks)) + if (!qemuMigrationAnyCopyDisk(disk, migrate_disks)) continue; if (disk->src->readonly || virStorageSourceIsEmpty(disk->src)) { @@ -1186,7 +1182,6 @@ qemuMigrationSrcNBDStorageCopy(virQEMUDriver *driver, qemuMigrationCookie *mig, const char *host, unsigned long speed, - size_t nmigrate_disks, const char **migrate_disks, virConnectPtr dconn, const char *tlsAlias, @@ -1261,7 +1256,7 @@ qemuMigrationSrcNBDStorageCopy(virQEMUDriver *driver, virDomainDiskDef *disk =3D vm->def->disks[i]; /* check whether disk should be migrated */ - if (!qemuMigrationAnyCopyDisk(disk, nmigrate_disks, migrate_disks)) + if (!qemuMigrationAnyCopyDisk(disk, migrate_disks)) continue; if (qemuMigrationSrcNBDStorageCopyOne(vm, disk, host, port, @@ -1614,7 +1609,6 @@ qemuMigrationSrcIsAllowed(virDomainObj *vm, static bool qemuMigrationSrcIsSafe(virDomainDef *def, virQEMUCaps *qemuCaps, - size_t nmigrate_disks, const char **migrate_disks, unsigned int flags) @@ -1638,7 +1632,7 @@ qemuMigrationSrcIsSafe(virDomainDef *def, /* Disks which are migrated by qemu are safe too. */ if (storagemigration && - qemuMigrationAnyCopyDisk(disk, nmigrate_disks, migrate_disks)) + qemuMigrationAnyCopyDisk(disk, migrate_disks)) continue; /* However, disks on local FS (e.g. ext4) are not safe. */ @@ -2437,8 +2431,7 @@ qemuMigrationAnyConnectionClosed(virDomainObj *vm, static int qemuMigrationSrcBeginPhaseBlockDirtyBitmaps(qemuMigrationCookie *mig, virDomainObj *vm, - const char **migrate_disks, - size_t nmigrate_disks) + const char **migrate_disks) { GSList *disks =3D NULL; @@ -2460,7 +2453,7 @@ qemuMigrationSrcBeginPhaseBlockDirtyBitmaps(qemuMigra= tionCookie *mig, if (!nodedata) continue; - if (!qemuMigrationAnyCopyDisk(diskdef, nmigrate_disks, migrate_dis= ks)) + if (!qemuMigrationAnyCopyDisk(diskdef, migrate_disks)) continue; for (j =3D 0; j < nodedata->nbitmaps; j++) { @@ -2530,7 +2523,6 @@ qemuMigrationSrcBeginXML(virDomainObj *vm, int *cookieoutlen, unsigned int cookieFlags, const char **migrate_disks, - size_t nmigrate_disks, unsigned int flags) { qemuDomainObjPrivate *priv =3D vm->privateData; @@ -2548,8 +2540,7 @@ qemuMigrationSrcBeginXML(virDomainObj *vm, if (cookieFlags & QEMU_MIGRATION_COOKIE_NBD && virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_MIGRATION_PARAM_BLOCK_BIT= MAP_MAPPING) && - qemuMigrationSrcBeginPhaseBlockDirtyBitmaps(mig, vm, migrate_disks, - nmigrate_disks) < 0) + qemuMigrationSrcBeginPhaseBlockDirtyBitmaps(mig, vm, migrate_disks= ) < 0) return NULL; if (qemuMigrationCookieFormat(mig, driver, vm, @@ -2615,7 +2606,6 @@ qemuMigrationSrcBeginPhase(virQEMUDriver *driver, const char *dname, char **cookieout, int *cookieoutlen, - size_t nmigrate_disks, const char **migrate_disks, unsigned int flags) { @@ -2641,8 +2631,7 @@ qemuMigrationSrcBeginPhase(virQEMUDriver *driver, return NULL; if (!(flags & (VIR_MIGRATE_UNSAFE | VIR_MIGRATE_OFFLINE)) && - !qemuMigrationSrcIsSafe(vm->def, priv->qemuCaps, - nmigrate_disks, migrate_disks, flags)) + !qemuMigrationSrcIsSafe(vm->def, priv->qemuCaps, migrate_disks, fl= ags)) return NULL; if (flags & VIR_MIGRATE_POSTCOPY && @@ -2697,9 +2686,7 @@ qemuMigrationSrcBeginPhase(virQEMUDriver *driver, priv->nbdPort =3D 0; - if (qemuMigrationHasAnyStorageMigrationDisks(vm->def, - migrate_disks, - nmigrate_disks)) + if (qemuMigrationHasAnyStorageMigrationDisks(vm->def, migrate_disk= s)) cookieFlags |=3D QEMU_MIGRATION_COOKIE_NBD; } else { if (migrate_disks) { @@ -2721,8 +2708,7 @@ qemuMigrationSrcBeginPhase(virQEMUDriver *driver, return qemuMigrationSrcBeginXML(vm, xmlin, cookieout, cookieoutlen, cookieFlags, - migrate_disks, nmigrate_disks, - flags); + migrate_disks, flags); } @@ -2812,7 +2798,7 @@ qemuMigrationSrcBeginResume(virDomainObj *vm, } return qemuMigrationSrcBeginXML(vm, xmlin, - cookieout, cookieoutlen, 0, NULL, 0, f= lags); + cookieout, cookieoutlen, 0, NULL, flag= s); } @@ -2857,7 +2843,6 @@ qemuMigrationSrcBegin(virConnectPtr conn, const char *dname, char **cookieout, int *cookieoutlen, - size_t nmigrate_disks, const char **migrate_disks, unsigned int flags) { @@ -2908,7 +2893,7 @@ qemuMigrationSrcBegin(virConnectPtr conn, if (!(xml =3D qemuMigrationSrcBeginPhase(driver, vm, xmlin, dname, cookieout, cookieoutlen, - nmigrate_disks, migrate_disks, = flags))) + migrate_disks, flags))) goto endjob; if ((flags & VIR_MIGRATE_CHANGE_PROTECTION)) { @@ -3121,7 +3106,6 @@ qemuMigrationDstPrepareActive(virQEMUDriver *driver, const char *protocol, unsigned short port, const char *listenAddress, - size_t nmigrate_disks, const char **migrate_disks, int nbdPort, const char *nbdURI, @@ -3149,8 +3133,7 @@ qemuMigrationDstPrepareActive(virQEMUDriver *driver, goto error; } - if (qemuMigrationDstPrepareStorage(vm, mig->nbd, - nmigrate_disks, migrate_disks, + if (qemuMigrationDstPrepareStorage(vm, mig->nbd, migrate_disks, !!(flags & VIR_MIGRATE_NON_SHARED_I= NC)) < 0) goto error; @@ -3245,7 +3228,7 @@ qemuMigrationDstPrepareActive(virQEMUDriver *driver, } if (qemuMigrationDstStartNBDServer(driver, vm, incoming->address, - nmigrate_disks, migrate_disks, + migrate_disks, nbdPort, nbdURI, nbdTLSAlias) < 0) { goto error; @@ -3316,7 +3299,6 @@ qemuMigrationDstPrepareFresh(virQEMUDriver *driver, unsigned short port, bool autoPort, const char *listenAddress, - size_t nmigrate_disks, const char **migrate_disks, int nbdPort, const char *nbdURI, @@ -3426,7 +3408,7 @@ qemuMigrationDstPrepareFresh(virQEMUDriver *driver, if (!(flags & VIR_MIGRATE_OFFLINE)) { if (qemuMigrationDstPrepareActive(driver, vm, dconn, mig, st, protocol, port, listenAddress, - nmigrate_disks, migrate_disks, + migrate_disks, nbdPort, nbdURI, migParams, flags) < 0) { goto stopjob; @@ -3589,7 +3571,6 @@ qemuMigrationDstPrepareAny(virQEMUDriver *driver, unsigned short port, bool autoPort, const char *listenAddress, - size_t nmigrate_disks, const char **migrate_disks, int nbdPort, const char *nbdURI, @@ -3652,7 +3633,7 @@ qemuMigrationDstPrepareAny(virQEMUDriver *driver, cookieout, cookieoutlen, def, origname, st, protocol, port, autoPort, listenAddress, - nmigrate_disks, migrate_disks, + migrate_disks, nbdPort, nbdURI, migParams, flags); } @@ -3689,7 +3670,7 @@ qemuMigrationDstPrepareTunnel(virQEMUDriver *driver, return qemuMigrationDstPrepareAny(driver, dconn, cookiein, cookieinlen, cookieout, cookieoutlen, def, origna= me, - st, NULL, 0, false, NULL, 0, NULL, 0, + st, NULL, 0, false, NULL, NULL, 0, NULL, migParams, flags); } @@ -3728,7 +3709,6 @@ qemuMigrationDstPrepareDirect(virQEMUDriver *driver, virDomainDef **def, const char *origname, const char *listenAddress, - size_t nmigrate_disks, const char **migrate_disks, int nbdPort, const char *nbdURI, @@ -3859,7 +3839,7 @@ qemuMigrationDstPrepareDirect(virQEMUDriver *driver, cookieout, cookieoutlen, def, orignam= e, NULL, uri ? uri->scheme : "tcp", port, autoPort, listenAddress, - nmigrate_disks, migrate_disks, nbdPor= t, + migrate_disks, nbdPort, nbdURI, migParams, flags); cleanup: if (ret !=3D 0) { @@ -4759,7 +4739,6 @@ qemuMigrationSrcRun(virQEMUDriver *driver, qemuMigrationSpec *spec, virConnectPtr dconn, const char *graphicsuri, - size_t nmigrate_disks, const char **migrate_disks, qemuMigrationParams *migParams, const char *nbdURI) @@ -4794,8 +4773,7 @@ qemuMigrationSrcRun(virQEMUDriver *driver, if (storageMigration) storageMigration =3D qemuMigrationHasAnyStorageMigrationDisks(vm->= def, - migrat= e_disks, - nmigra= te_disks); + migrat= e_disks); if (storageMigration) { cookieFlags |=3D QEMU_MIGRATION_COOKIE_NBD; @@ -4928,7 +4906,6 @@ qemuMigrationSrcRun(virQEMUDriver *driver, if (qemuMigrationSrcNBDStorageCopy(driver, vm, mig, host, priv->migMaxBandwidth, - nmigrate_disks, migrate_disks, dconn, tlsAlias, tlsHostname, nbdURI, flags) < 0) { @@ -5198,7 +5175,6 @@ qemuMigrationSrcPerformNative(virQEMUDriver *driver, unsigned long resource, virConnectPtr dconn, const char *graphicsuri, - size_t nmigrate_disks, const char **migrate_disks, qemuMigrationParams *migParams, const char *nbdURI) @@ -5279,7 +5255,7 @@ qemuMigrationSrcPerformNative(virQEMUDriver *driver, ret =3D qemuMigrationSrcRun(driver, vm, xmlin, persist_xml, cookie= in, cookieinlen, cookieout, cookieoutlen, flags, resource, &spec, dconn, graphicsuri, - nmigrate_disks, migrate_disks, + migrate_disks, migParams, nbdURI); } @@ -5304,7 +5280,6 @@ qemuMigrationSrcPerformTunnel(virQEMUDriver *driver, unsigned long resource, virConnectPtr dconn, const char *graphicsuri, - size_t nmigrate_disks, const char **migrate_disks, qemuMigrationParams *migParams) { @@ -5343,7 +5318,7 @@ qemuMigrationSrcPerformTunnel(virQEMUDriver *driver, ret =3D qemuMigrationSrcRun(driver, vm, xmlin, persist_xml, cookiein, = cookieinlen, cookieout, cookieoutlen, flags, resource, &s= pec, - dconn, graphicsuri, nmigrate_disks, migrate_= disks, + dconn, graphicsuri, migrate_disks, migParams, NULL); cleanup: @@ -5383,7 +5358,7 @@ qemuMigrationSrcPerformResume(virQEMUDriver *driver, ret =3D qemuMigrationSrcPerformNative(driver, vm, NULL, NULL, uri, cookiein, cookieinlen, cookieout, cookieoutlen, flags, - 0, NULL, NULL, 0, NULL, migParams,= NULL); + 0, NULL, NULL, NULL, migParams, NU= LL); virCloseCallbacksDomainAdd(vm, conn, qemuMigrationAnyConnectionClosed); @@ -5485,12 +5460,12 @@ qemuMigrationSrcPerformPeer2Peer2(virQEMUDriver *dr= iver, ret =3D qemuMigrationSrcPerformTunnel(driver, vm, st, NULL, NULL, NULL, 0, NULL, NULL, flags, resource, dconn, - NULL, 0, NULL, migParams); + NULL, NULL, migParams); else ret =3D qemuMigrationSrcPerformNative(driver, vm, NULL, NULL, uri_= out, cookie, cookielen, NULL, NULL, /* No out cookie w= ith v2 migration */ - flags, resource, dconn, NULL, = 0, NULL, + flags, resource, dconn, NULL, = NULL, migParams, NULL); /* Perform failed. Make sure Finish doesn't overwrite the error */ @@ -5553,7 +5528,6 @@ qemuMigrationSrcPerformPeer2Peer3(virQEMUDriver *driv= er, const char *uri, const char *graphicsuri, const char *listenAddress, - size_t nmigrate_disks, const char **migrate_disks, int nbdPort, const char *nbdURI, @@ -5599,7 +5573,7 @@ qemuMigrationSrcPerformPeer2Peer3(virQEMUDriver *driv= er, } else { dom_xml =3D qemuMigrationSrcBeginPhase(driver, vm, xmlin, dname, &cookieout, &cookieoutlen, - nmigrate_disks, migrate_disks= , flags); + migrate_disks, flags); } if (!dom_xml) goto cleanup; @@ -5750,14 +5724,14 @@ qemuMigrationSrcPerformPeer2Peer3(virQEMUDriver *dr= iver, cookiein, cookieinlen, &cookieout, &cookieoutlen, flags, bandwidth, dconn, g= raphicsuri, - nmigrate_disks, migrate_di= sks, + migrate_disks, migParams); } else { ret =3D qemuMigrationSrcPerformNative(driver, vm, xmlin, persi= st_xml, uri, cookiein, cookieinlen, &cookieout, &cookieoutlen, flags, bandwidth, dconn, g= raphicsuri, - nmigrate_disks, migrate_di= sks, + migrate_disks, migParams, nbdURI); } @@ -5930,7 +5904,6 @@ qemuMigrationSrcPerformPeer2Peer(virQEMUDriver *drive= r, const char *uri, const char *graphicsuri, const char *listenAddress, - size_t nmigrate_disks, const char **migrate_disks, int nbdPort, const char *nbdURI, @@ -6056,7 +6029,7 @@ qemuMigrationSrcPerformPeer2Peer(virQEMUDriver *drive= r, if (*v3proto) { ret =3D qemuMigrationSrcPerformPeer2Peer3(driver, sconn, dconn, dc= onnuri, vm, xmlin, persist_xml, dname, uri, g= raphicsuri, - listenAddress, nmigrate_di= sks, migrate_disks, + listenAddress, migrate_dis= ks, nbdPort, nbdURI, migParams= , resource, !!useParams, flags); } else { @@ -6092,7 +6065,6 @@ qemuMigrationSrcPerformJob(virQEMUDriver *driver, const char *uri, const char *graphicsuri, const char *listenAddress, - size_t nmigrate_disks, const char **migrate_disks, int nbdPort, const char *nbdURI, @@ -6135,8 +6107,7 @@ qemuMigrationSrcPerformJob(virQEMUDriver *driver, goto endjob; if (!(flags & (VIR_MIGRATE_UNSAFE | VIR_MIGRATE_OFFLINE)) && - !qemuMigrationSrcIsSafe(vm->def, priv->qemuCaps, - nmigrate_disks, migrate_disks, flags)) + !qemuMigrationSrcIsSafe(vm->def, priv->qemuCaps, migrate_disks= , flags)) goto endjob; qemuMigrationSrcStoreDomainState(vm); @@ -6145,7 +6116,7 @@ qemuMigrationSrcPerformJob(virQEMUDriver *driver, if ((flags & (VIR_MIGRATE_TUNNELLED | VIR_MIGRATE_PEER2PEER))) { ret =3D qemuMigrationSrcPerformPeer2Peer(driver, conn, vm, xmlin, = persist_xml, dconnuri, uri, graphicsuri,= listenAddress, - nmigrate_disks, migrate_dis= ks, nbdPort, + migrate_disks, nbdPort, nbdURI, migParams, flags, dname, re= source, &v3proto); @@ -6155,7 +6126,7 @@ qemuMigrationSrcPerformJob(virQEMUDriver *driver, ret =3D qemuMigrationSrcPerformNative(driver, vm, xmlin, persist_x= ml, uri, cookiein, cookieinlen, cookieout, cookieoutlen, - flags, resource, NULL, NULL, 0= , NULL, + flags, resource, NULL, NULL, N= ULL, migParams, nbdURI); } if (ret < 0) @@ -6222,7 +6193,6 @@ qemuMigrationSrcPerformPhase(virQEMUDriver *driver, const char *persist_xml, const char *uri, const char *graphicsuri, - size_t nmigrate_disks, const char **migrate_disks, qemuMigrationParams *migParams, const char *cookiein, @@ -6259,7 +6229,7 @@ qemuMigrationSrcPerformPhase(virQEMUDriver *driver, if (qemuMigrationSrcPerformNative(driver, vm, xmlin, persist_xml, uri,= cookiein, cookieinlen, cookieout, cookieoutlen, flags, resource, NULL, graphicsuri, - nmigrate_disks, migrate_disks, migPa= rams, nbdURI) < 0) + migrate_disks, migParams, nbdURI) < = 0) goto cleanup; virCloseCallbacksDomainAdd(vm, conn, qemuMigrationAnyConnectionClosed); @@ -6300,7 +6270,6 @@ qemuMigrationSrcPerform(virQEMUDriver *driver, const char *uri, const char *graphicsuri, const char *listenAddress, - size_t nmigrate_disks, const char **migrate_disks, int nbdPort, const char *nbdURI, @@ -6345,7 +6314,7 @@ qemuMigrationSrcPerform(virQEMUDriver *driver, return qemuMigrationSrcPerformJob(driver, conn, vm, xmlin, persist= _xml, dconnuri, uri, graphicsuri, listenAddress, - nmigrate_disks, migrate_disks, n= bdPort, + migrate_disks, nbdPort, nbdURI, migParams, cookiein, cookieinlen, cookieout, cookieoutlen, @@ -6361,7 +6330,7 @@ qemuMigrationSrcPerform(virQEMUDriver *driver, if (v3proto) { return qemuMigrationSrcPerformPhase(driver, conn, vm, xmlin, persi= st_xml, uri, graphicsuri, - nmigrate_disks, migrate_disks, + migrate_disks, migParams, cookiein, cookieinlen, cookieout, cookieoutlen, @@ -6370,7 +6339,7 @@ qemuMigrationSrcPerform(virQEMUDriver *driver, return qemuMigrationSrcPerformJob(driver, conn, vm, xmlin, persist_xml= , NULL, uri, graphicsuri, listenAddress, - nmigrate_disks, migrate_disks, nbdPo= rt, + migrate_disks, nbdPort, nbdURI, migParams, cookiein, cookieinlen, cookieout, cookieoutlen, flags, diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h index ed62fd4a91..4dced4b166 100644 --- a/src/qemu/qemu_migration.h +++ b/src/qemu/qemu_migration.h @@ -122,7 +122,6 @@ qemuMigrationSrcBegin(virConnectPtr conn, const char *dname, char **cookieout, int *cookieoutlen, - size_t nmigrate_disks, const char **migrate_disks, unsigned int flags); @@ -158,7 +157,6 @@ qemuMigrationDstPrepareDirect(virQEMUDriver *driver, virDomainDef **def, const char *origname, const char *listenAddress, - size_t nmigrate_disks, const char **migrate_disks, int nbdPort, const char *nbdURI, @@ -175,7 +173,6 @@ qemuMigrationSrcPerform(virQEMUDriver *driver, const char *uri, const char *graphicsuri, const char *listenAddress, - size_t nmigrate_disks, const char **migrate_disks, int nbdPort, const char *nbdURI, --=20 2.46.0 From nobody Sun Dec 22 06:30:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1727703359866501.4302331515546; Mon, 30 Sep 2024 06:35:59 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id C26EACF8; Mon, 30 Sep 2024 09:35:58 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id EE0061296; Mon, 30 Sep 2024 09:30:18 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id A8424137D; Mon, 30 Sep 2024 09:30:10 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 9F5581430 for ; Mon, 30 Sep 2024 09:29:55 -0400 (EDT) Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-271-d8SJU5EkObG8q8xWyy9RAQ-1; Mon, 30 Sep 2024 09:29:53 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (unknown [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 00CE818DB432 for ; Mon, 30 Sep 2024 13:29:53 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.12]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id D73CA19541A0 for ; Mon, 30 Sep 2024 13:29:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727702995; h=from:from: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; bh=bM/VpjNGabcK2Lokcmy5wMTkwBHFKck0NtthknL86OI=; b=Lu3vuL0mRwgwuDMCABCmn75y/sDg6OdWkCHFrEmyKk05a6SRi0byOXQ6z2CKUrnK5CNsv7 z1DzzhVaKp1VVVeAP6LM3IEiwhhEQDDvEzQNgZ9E/VV22SexUbTzOsnlvg+eOq6ksKHXge fwKeO7b4i8UjGHeRFwINIK6m2i11XS4= X-MC-Unique: d8SJU5EkObG8q8xWyy9RAQ-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 12/13] qemu: Introduce and wire in 'VIR_MIGRATE_PARAM_MIGRATE_DISKS_DETECT_ZEROES' Date: Mon, 30 Sep 2024 15:29:34 +0200 Message-ID: <2ff4317b1a28705aafa58e7aa593b8a01b073186.1727702835.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 7JZ7YH6K7W2SVILPIL6TBYPMRZTWICR5 X-Message-ID-Hash: 7JZ7YH6K7W2SVILPIL6TBYPMRZTWICR5 X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1727703362257116600 Content-Type: text/plain; charset="utf-8" The new 'VIR_MIGRATE_PARAM_MIGRATE_DISKS_DETECT_ZEROES' migration parameter allows users of migration to pass in a list of disks where zero-detection (which avoids transferring the zeroed-blocks) should be enabled for the migration connection. This comes at the cost of extra CPU cycles needed to check each block if it's all-zero. This is useful for storage backends where information about the allocation state of a block is not available and thus without this the image would become fully allocated on the destination. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- include/libvirt/libvirt-domain.h | 13 ++++ src/qemu/qemu_driver.c | 20 ++++-- src/qemu/qemu_migration.c | 105 +++++++++++++++++++++++-------- src/qemu/qemu_migration.h | 4 ++ 4 files changed, 110 insertions(+), 32 deletions(-) diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-dom= ain.h index 4266237abe..6d4cc69c5d 100644 --- a/include/libvirt/libvirt-domain.h +++ b/include/libvirt/libvirt-domain.h @@ -1240,6 +1240,19 @@ typedef enum { */ # define VIR_MIGRATE_PARAM_MIGRATE_DISKS "migrate_disks" +/** + * VIR_MIGRATE_PARAM_MIGRATE_DISKS_DETECT_ZEROES: + * + * virDomainMigrate* params multiple field: The multiple values that list + * the block devices for which zero detection (to avoid transferring zero = blocks) + * is to be enabled. This may increase CPU overhead of the migration. At t= he + * moment this is only supported by the QEMU driver but not for the tunnel= led + * migration. + * + * Since: 10.9.0 + */ +# define VIR_MIGRATE_PARAM_MIGRATE_DISKS_DETECT_ZEROES "migrate_disks_d= etect_zeroes" + /** * VIR_MIGRATE_PARAM_DISKS_PORT: * diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index cec700a36c..472bcd1fd3 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -10782,7 +10782,7 @@ qemuDomainMigratePerform(virDomainPtr dom, * Consume any cookie we were able to decode though */ ret =3D qemuMigrationSrcPerform(driver, dom->conn, vm, NULL, - NULL, dconnuri, uri, NULL, NULL, NULL, 0, + NULL, dconnuri, uri, NULL, NULL, NULL, N= ULL, 0, NULL, migParams, cookie, cookielen, NULL, NULL, /* No output cookies in v2 */ @@ -10858,7 +10858,7 @@ qemuDomainMigrateBegin3(virDomainPtr domain, } return qemuMigrationSrcBegin(domain->conn, vm, xmlin, dname, - cookieout, cookieoutlen, NULL, flags); + cookieout, cookieoutlen, NULL, NULL, flag= s); } static char * @@ -10872,6 +10872,7 @@ qemuDomainMigrateBegin3Params(virDomainPtr domain, const char *xmlin =3D NULL; const char *dname =3D NULL; g_autofree const char **migrate_disks =3D NULL; + g_autofree const char **migrate_disks_detect_zeroes =3D NULL; virDomainObj *vm; virCheckFlags(QEMU_MIGRATION_FLAGS, NULL); @@ -10889,6 +10890,10 @@ qemuDomainMigrateBegin3Params(virDomainPtr domain, virTypedParamsGetStringList(params, nparams, VIR_MIGRATE_PARAM_MIGRATE= _DISKS, &migrate_disks); + virTypedParamsGetStringList(params, nparams, + VIR_MIGRATE_PARAM_MIGRATE_DISKS_DETECT_ZER= OES, + &migrate_disks_detect_zeroes); + if (!(vm =3D qemuDomainObjFromDomain(domain))) return NULL; @@ -10899,7 +10904,8 @@ qemuDomainMigrateBegin3Params(virDomainPtr domain, return qemuMigrationSrcBegin(domain->conn, vm, xmlin, dname, cookieout, cookieoutlen, - migrate_disks, flags); + migrate_disks, migrate_disks_detect_zeroe= s, + flags); } @@ -11180,7 +11186,7 @@ qemuDomainMigratePerform3(virDomainPtr dom, goto cleanup; ret =3D qemuMigrationSrcPerform(driver, dom->conn, vm, xmlin, NULL, - dconnuri, uri, NULL, NULL, NULL, 0, + dconnuri, uri, NULL, NULL, NULL, NULL, 0, NULL, migParams, cookiein, cookieinlen, cookieout, cookieoutlen, @@ -11211,6 +11217,7 @@ qemuDomainMigratePerform3Params(virDomainPtr dom, const char *graphicsuri =3D NULL; const char *listenAddress =3D NULL; g_autofree const char **migrate_disks =3D NULL; + g_autofree const char **migrate_disks_detect_zeroes =3D NULL; unsigned long long bandwidth =3D 0; int nbdPort =3D 0; g_autoptr(qemuMigrationParams) migParams =3D NULL; @@ -11267,6 +11274,9 @@ qemuDomainMigratePerform3Params(virDomainPtr dom, virTypedParamsGetStringList(params, nparams, VIR_MIGRATE_PARAM_MIGRATE= _DISKS, &migrate_disks); + virTypedParamsGetStringList(params, nparams, + VIR_MIGRATE_PARAM_MIGRATE_DISKS_DETECT_ZER= OES, + &migrate_disks_detect_zeroes); if (flags & (VIR_MIGRATE_NON_SHARED_DISK | VIR_MIGRATE_NON_SHARED_INC)= || migrate_disks) { @@ -11289,7 +11299,7 @@ qemuDomainMigratePerform3Params(virDomainPtr dom, ret =3D qemuMigrationSrcPerform(driver, dom->conn, vm, dom_xml, persis= t_xml, dconnuri, uri, graphicsuri, listenAddres= s, - migrate_disks, nbdPort, + migrate_disks, migrate_disks_detect_zero= es, nbdPort, nbdURI, migParams, cookiein, cookieinlen, cookieout, cookie= outlen, flags, dname, bandwidth, true); diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 94636e778d..7ae19dd0ce 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -1022,7 +1022,8 @@ qemuMigrationSrcNBDStorageCopyBlockdevPrepareSource(v= irDomainDiskDef *disk, int port, const char *socket, const char *tlsAlias, - const char *tlsHostnam= e) + const char *tlsHostnam= e, + bool detect_zeroes) { g_autoptr(virStorageSource) copysrc =3D NULL; @@ -1031,6 +1032,9 @@ qemuMigrationSrcNBDStorageCopyBlockdevPrepareSource(v= irDomainDiskDef *disk, copysrc->protocol =3D VIR_STORAGE_NET_PROTOCOL_NBD; copysrc->format =3D VIR_STORAGE_FILE_RAW; + if (detect_zeroes) + copysrc->detect_zeroes =3D VIR_DOMAIN_DISK_DETECT_ZEROES_ON; + copysrc->backingStore =3D virStorageSourceNew(); if (!(copysrc->path =3D qemuAliasDiskDriveFromDisk(disk))) @@ -1067,7 +1071,8 @@ qemuMigrationSrcNBDStorageCopyBlockdev(virDomainObj *= vm, unsigned int mirror_shallow, const char *tlsAlias, const char *tlsHostname, - bool syncWrites) + bool syncWrites, + bool detect_zeroes) { g_autoptr(qemuBlockStorageSourceAttachData) data =3D NULL; qemuDomainDiskPrivate *diskPriv =3D QEMU_DOMAIN_DISK_PRIVATE(disk); @@ -1081,7 +1086,8 @@ qemuMigrationSrcNBDStorageCopyBlockdev(virDomainObj *= vm, VIR_DEBUG("starting blockdev mirror for disk=3D%s to host=3D%s", disk-= >dst, host); if (!(copysrc =3D qemuMigrationSrcNBDStorageCopyBlockdevPrepareSource(= disk, host, port, socket, - tl= sAlias, tlsHostname))) + tl= sAlias, tlsHostname, + de= tect_zeroes))) return -1; if (!(data =3D qemuBlockStorageSourceAttachPrepareBlockdev(copysrc, @@ -1123,6 +1129,7 @@ qemuMigrationSrcNBDStorageCopyOne(virDomainObj *vm, bool mirror_shallow, const char *tlsAlias, const char *tlsHostname, + bool detect_zeroes, unsigned int flags) { qemuDomainDiskPrivate *diskPriv =3D QEMU_DOMAIN_DISK_PRIVATE(disk); @@ -1147,7 +1154,8 @@ qemuMigrationSrcNBDStorageCopyOne(virDomainObj *vm, mirror_shallow, tlsAlias, tlsHostname, - syncWrites); + syncWrites, + detect_zeroes); if (rc =3D=3D 0) { diskPriv->migrating =3D true; @@ -1183,6 +1191,7 @@ qemuMigrationSrcNBDStorageCopy(virQEMUDriver *driver, const char *host, unsigned long speed, const char **migrate_disks, + const char **migrate_disks_detect_zeroes, virConnectPtr dconn, const char *tlsAlias, const char *tlsHostname, @@ -1254,15 +1263,20 @@ qemuMigrationSrcNBDStorageCopy(virQEMUDriver *drive= r, for (i =3D 0; i < vm->def->ndisks; i++) { virDomainDiskDef *disk =3D vm->def->disks[i]; + bool detect_zeroes =3D false; /* check whether disk should be migrated */ if (!qemuMigrationAnyCopyDisk(disk, migrate_disks)) continue; + if (migrate_disks_detect_zeroes) + detect_zeroes =3D g_strv_contains(migrate_disks_detect_zeroes,= disk->dst); + if (qemuMigrationSrcNBDStorageCopyOne(vm, disk, host, port, socket, mirror_speed, mirror_shallow, - tlsAlias, tlsHostname, flags= ) < 0) + tlsAlias, tlsHostname, detec= t_zeroes, + flags) < 0) return -1; if (virDomainObjSave(vm, driver->xmlopt, cfg->stateDir) < 0) { @@ -2607,6 +2621,7 @@ qemuMigrationSrcBeginPhase(virQEMUDriver *driver, char **cookieout, int *cookieoutlen, const char **migrate_disks, + const char **migrate_disks_detect_zeroes, unsigned int flags) { qemuDomainObjPrivate *priv =3D vm->privateData; @@ -2614,10 +2629,10 @@ qemuMigrationSrcBeginPhase(virQEMUDriver *driver, VIR_DEBUG("driver=3D%p, vm=3D%p, xmlin=3D%s, dname=3D%s," " cookieout=3D%p, cookieoutlen=3D%p," - " migrate_disks=3D%p, flags=3D0x%x", + " migrate_disks=3D%p, migrate_disks_detect_zeroes=3D%p, flag= s=3D0x%x", driver, vm, NULLSTR(xmlin), NULLSTR(dname), cookieout, cookieoutlen, - migrate_disks, flags); + migrate_disks, migrate_disks_detect_zeroes, flags); /* Only set the phase if we are inside VIR_ASYNC_JOB_MIGRATION_OUT. * Otherwise we will start the async job later in the perform phase lo= sing @@ -2684,6 +2699,10 @@ qemuMigrationSrcBeginPhase(virQEMUDriver *driver, qemuMigrationSrcBeginPhaseValidateDiskTargetList(vm, migrate_d= isks) < 0) return NULL; + if (migrate_disks_detect_zeroes && + qemuMigrationSrcBeginPhaseValidateDiskTargetList(vm, migrate_d= isks_detect_zeroes) < 0) + return NULL; + priv->nbdPort =3D 0; if (qemuMigrationHasAnyStorageMigrationDisks(vm->def, migrate_disk= s)) @@ -2694,6 +2713,13 @@ qemuMigrationSrcBeginPhase(virQEMUDriver *driver, _("use of 'VIR_MIGRATE_PARAM_MIGRATE_DISKS' req= uires use of 'VIR_MIGRATE_NON_SHARED_DISK' or 'VIR_MIGRATE_NON_SHARED_INC' = flag")); return NULL; } + + if (migrate_disks_detect_zeroes) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("use of 'VIR_MIGRATE_PARAM_MIGRATE_DISKS_DETE= CT_ZEROES' requires use of 'VIR_MIGRATE_NON_SHARED_DISK' or 'VIR_MIGRATE_NO= N_SHARED_INC' flag")); + return NULL; + } + } if (virDomainDefHasMemoryHotplug(vm->def) || @@ -2844,6 +2870,7 @@ qemuMigrationSrcBegin(virConnectPtr conn, char **cookieout, int *cookieoutlen, const char **migrate_disks, + const char **migrate_disks_detect_zeroes, unsigned int flags) { virQEMUDriver *driver =3D conn->privateData; @@ -2893,7 +2920,9 @@ qemuMigrationSrcBegin(virConnectPtr conn, if (!(xml =3D qemuMigrationSrcBeginPhase(driver, vm, xmlin, dname, cookieout, cookieoutlen, - migrate_disks, flags))) + migrate_disks, + migrate_disks_detect_zeroes, + flags))) goto endjob; if ((flags & VIR_MIGRATE_CHANGE_PROTECTION)) { @@ -4740,6 +4769,7 @@ qemuMigrationSrcRun(virQEMUDriver *driver, virConnectPtr dconn, const char *graphicsuri, const char **migrate_disks, + const char **migrate_disks_detect_zeroes, qemuMigrationParams *migParams, const char *nbdURI) { @@ -4765,11 +4795,11 @@ qemuMigrationSrcRun(virQEMUDriver *driver, VIR_DEBUG("driver=3D%p, vm=3D%p, cookiein=3D%s, cookieinlen=3D%d, " "cookieout=3D%p, cookieoutlen=3D%p, flags=3D0x%x, resource= =3D%lu, " "spec=3D%p (dest=3D%d, fwd=3D%d), dconn=3D%p, graphicsuri=3D= %s, " - "migrate_disks=3D%p", + "migrate_disks=3D%p, migrate_disks_detect_zeroes=3D%p", driver, vm, NULLSTR(cookiein), cookieinlen, cookieout, cookieoutlen, flags, resource, spec, spec->destType, spec->fwdType, dconn, - NULLSTR(graphicsuri), migrate_disks); + NULLSTR(graphicsuri), migrate_disks, migrate_disks_detect_ze= roes); if (storageMigration) storageMigration =3D qemuMigrationHasAnyStorageMigrationDisks(vm->= def, @@ -4907,6 +4937,7 @@ qemuMigrationSrcRun(virQEMUDriver *driver, host, priv->migMaxBandwidth, migrate_disks, + migrate_disks_detect_zeroes, dconn, tlsAlias, tlsHostname, nbdURI, flags) < 0) { goto error; @@ -5176,6 +5207,7 @@ qemuMigrationSrcPerformNative(virQEMUDriver *driver, virConnectPtr dconn, const char *graphicsuri, const char **migrate_disks, + const char **migrate_disks_detect_zeroes, qemuMigrationParams *migParams, const char *nbdURI) { @@ -5186,10 +5218,10 @@ qemuMigrationSrcPerformNative(virQEMUDriver *driver, VIR_DEBUG("driver=3D%p, vm=3D%p, uri=3D%s, cookiein=3D%s, cookieinlen= =3D%d, " "cookieout=3D%p, cookieoutlen=3D%p, flags=3D0x%x, resource= =3D%lu, " - "graphicsuri=3D%s, migrate_disks=3D%p", + "graphicsuri=3D%s, migrate_disks=3D%p, migrate_disks_detect_= zeroes=3D%p", driver, vm, uri, NULLSTR(cookiein), cookieinlen, cookieout, cookieoutlen, flags, resource, - NULLSTR(graphicsuri), migrate_disks); + NULLSTR(graphicsuri), migrate_disks, migrate_disks_detect_ze= roes); if (!(uribits =3D qemuMigrationAnyParseURI(uri, NULL))) return -1; @@ -5255,7 +5287,7 @@ qemuMigrationSrcPerformNative(virQEMUDriver *driver, ret =3D qemuMigrationSrcRun(driver, vm, xmlin, persist_xml, cookie= in, cookieinlen, cookieout, cookieoutlen, flags, resource, &spec, dconn, graphicsuri, - migrate_disks, + migrate_disks, migrate_disks_detect_zero= es, migParams, nbdURI); } @@ -5316,9 +5348,11 @@ qemuMigrationSrcPerformTunnel(virQEMUDriver *driver, goto cleanup; } + /* Migration with NBD is not supported with _TUNNELED, thus + * 'migrate_disks_detect_zeroes' is NULL here */ ret =3D qemuMigrationSrcRun(driver, vm, xmlin, persist_xml, cookiein, = cookieinlen, cookieout, cookieoutlen, flags, resource, &s= pec, - dconn, graphicsuri, migrate_disks, + dconn, graphicsuri, migrate_disks, NULL, migParams, NULL); cleanup: @@ -5358,7 +5392,7 @@ qemuMigrationSrcPerformResume(virQEMUDriver *driver, ret =3D qemuMigrationSrcPerformNative(driver, vm, NULL, NULL, uri, cookiein, cookieinlen, cookieout, cookieoutlen, flags, - 0, NULL, NULL, NULL, migParams, NU= LL); + 0, NULL, NULL, NULL, NULL, migPara= ms, NULL); virCloseCallbacksDomainAdd(vm, conn, qemuMigrationAnyConnectionClosed); @@ -5466,7 +5500,7 @@ qemuMigrationSrcPerformPeer2Peer2(virQEMUDriver *driv= er, cookie, cookielen, NULL, NULL, /* No out cookie w= ith v2 migration */ flags, resource, dconn, NULL, = NULL, - migParams, NULL); + NULL, migParams, NULL); /* Perform failed. Make sure Finish doesn't overwrite the error */ if (ret < 0) @@ -5529,6 +5563,7 @@ qemuMigrationSrcPerformPeer2Peer3(virQEMUDriver *driv= er, const char *graphicsuri, const char *listenAddress, const char **migrate_disks, + const char **migrate_disks_detect_zeroes, int nbdPort, const char *nbdURI, qemuMigrationParams *migParams, @@ -5555,11 +5590,11 @@ qemuMigrationSrcPerformPeer2Peer3(virQEMUDriver *dr= iver, VIR_DEBUG("driver=3D%p, sconn=3D%p, dconn=3D%p, dconnuri=3D%s, vm=3D%p= , xmlin=3D%s, " "dname=3D%s, uri=3D%s, graphicsuri=3D%s, listenAddress=3D%s,= " - "migrate_disks=3D%p, nbdPort=3D%d, nbdURI=3D%s, " + "migrate_disks=3D%p, migrate_disks_detect_zeroes=3D%p, nbdPo= rt=3D%d, nbdURI=3D%s, " "bandwidth=3D%llu, useParams=3D%d, flags=3D0x%x", driver, sconn, dconn, NULLSTR(dconnuri), vm, NULLSTR(xmlin), NULLSTR(dname), NULLSTR(uri), NULLSTR(graphicsuri), - NULLSTR(listenAddress), migrate_disks, nbdPort, + NULLSTR(listenAddress), migrate_disks, migrate_disks_detect_= zeroes, nbdPort, NULLSTR(nbdURI), bandwidth, useParams, flags); /* Unlike the virDomainMigrateVersion3 counterpart, we don't need @@ -5573,7 +5608,9 @@ qemuMigrationSrcPerformPeer2Peer3(virQEMUDriver *driv= er, } else { dom_xml =3D qemuMigrationSrcBeginPhase(driver, vm, xmlin, dname, &cookieout, &cookieoutlen, - migrate_disks, flags); + migrate_disks, + migrate_disks_detect_zeroes, + flags); } if (!dom_xml) goto cleanup; @@ -5618,6 +5655,15 @@ qemuMigrationSrcPerformPeer2Peer3(virQEMUDriver *dri= ver, *d) < 0) goto cleanup; } + if (migrate_disks_detect_zeroes) { + const char **d; + + for (d =3D migrate_disks_detect_zeroes; *d; d++) + if (virTypedParamsAddString(¶ms, &nparams, &maxparams, + VIR_MIGRATE_PARAM_MIGRATE_DISK= S_DETECT_ZEROES, + *d) < 0) + goto cleanup; + } if (nbdPort && virTypedParamsAddInt(¶ms, &nparams, &maxparams, VIR_MIGRATE_PARAM_DISKS_PORT, @@ -5731,7 +5777,7 @@ qemuMigrationSrcPerformPeer2Peer3(virQEMUDriver *driv= er, cookiein, cookieinlen, &cookieout, &cookieoutlen, flags, bandwidth, dconn, g= raphicsuri, - migrate_disks, + migrate_disks, migrate_dis= ks_detect_zeroes, migParams, nbdURI); } @@ -5905,6 +5951,7 @@ qemuMigrationSrcPerformPeer2Peer(virQEMUDriver *drive= r, const char *graphicsuri, const char *listenAddress, const char **migrate_disks, + const char **migrate_disks_detect_zeroes, int nbdPort, const char *nbdURI, qemuMigrationParams *migParams, @@ -6029,7 +6076,7 @@ qemuMigrationSrcPerformPeer2Peer(virQEMUDriver *drive= r, if (*v3proto) { ret =3D qemuMigrationSrcPerformPeer2Peer3(driver, sconn, dconn, dc= onnuri, vm, xmlin, persist_xml, dname, uri, g= raphicsuri, - listenAddress, migrate_dis= ks, + listenAddress, migrate_dis= ks, migrate_disks_detect_zeroes, nbdPort, nbdURI, migParams= , resource, !!useParams, flags); } else { @@ -6066,6 +6113,7 @@ qemuMigrationSrcPerformJob(virQEMUDriver *driver, const char *graphicsuri, const char *listenAddress, const char **migrate_disks, + const char **migrate_disks_detect_zeroes, int nbdPort, const char *nbdURI, qemuMigrationParams *migParams, @@ -6116,7 +6164,7 @@ qemuMigrationSrcPerformJob(virQEMUDriver *driver, if ((flags & (VIR_MIGRATE_TUNNELLED | VIR_MIGRATE_PEER2PEER))) { ret =3D qemuMigrationSrcPerformPeer2Peer(driver, conn, vm, xmlin, = persist_xml, dconnuri, uri, graphicsuri,= listenAddress, - migrate_disks, nbdPort, + migrate_disks, migrate_disk= s_detect_zeroes, nbdPort, nbdURI, migParams, flags, dname, re= source, &v3proto); @@ -6126,7 +6174,7 @@ qemuMigrationSrcPerformJob(virQEMUDriver *driver, ret =3D qemuMigrationSrcPerformNative(driver, vm, xmlin, persist_x= ml, uri, cookiein, cookieinlen, cookieout, cookieoutlen, - flags, resource, NULL, NULL, N= ULL, + flags, resource, NULL, NULL, N= ULL, NULL, migParams, nbdURI); } if (ret < 0) @@ -6194,6 +6242,7 @@ qemuMigrationSrcPerformPhase(virQEMUDriver *driver, const char *uri, const char *graphicsuri, const char **migrate_disks, + const char **migrate_disks_detect_zeroes, qemuMigrationParams *migParams, const char *cookiein, int cookieinlen, @@ -6229,7 +6278,8 @@ qemuMigrationSrcPerformPhase(virQEMUDriver *driver, if (qemuMigrationSrcPerformNative(driver, vm, xmlin, persist_xml, uri,= cookiein, cookieinlen, cookieout, cookieoutlen, flags, resource, NULL, graphicsuri, - migrate_disks, migParams, nbdURI) < = 0) + migrate_disks, migrate_disks_detect_= zeroes, + migParams, nbdURI) < 0) goto cleanup; virCloseCallbacksDomainAdd(vm, conn, qemuMigrationAnyConnectionClosed); @@ -6271,6 +6321,7 @@ qemuMigrationSrcPerform(virQEMUDriver *driver, const char *graphicsuri, const char *listenAddress, const char **migrate_disks, + const char **migrate_disks_detect_zeroes, int nbdPort, const char *nbdURI, qemuMigrationParams *migParams, @@ -6314,7 +6365,7 @@ qemuMigrationSrcPerform(virQEMUDriver *driver, return qemuMigrationSrcPerformJob(driver, conn, vm, xmlin, persist= _xml, dconnuri, uri, graphicsuri, listenAddress, - migrate_disks, nbdPort, + migrate_disks, migrate_disks_det= ect_zeroes, nbdPort, nbdURI, migParams, cookiein, cookieinlen, cookieout, cookieoutlen, @@ -6330,7 +6381,7 @@ qemuMigrationSrcPerform(virQEMUDriver *driver, if (v3proto) { return qemuMigrationSrcPerformPhase(driver, conn, vm, xmlin, persi= st_xml, uri, graphicsuri, - migrate_disks, + migrate_disks, migrate_disks_d= etect_zeroes, migParams, cookiein, cookieinlen, cookieout, cookieoutlen, @@ -6339,7 +6390,7 @@ qemuMigrationSrcPerform(virQEMUDriver *driver, return qemuMigrationSrcPerformJob(driver, conn, vm, xmlin, persist_xml= , NULL, uri, graphicsuri, listenAddress, - migrate_disks, nbdPort, + migrate_disks, migrate_disks_detect_= zeroes, nbdPort, nbdURI, migParams, cookiein, cookieinlen, cookieout, cookieoutlen, flags, diff --git a/src/qemu/qemu_migration.h b/src/qemu/qemu_migration.h index 4dced4b166..4b7ef9688a 100644 --- a/src/qemu/qemu_migration.h +++ b/src/qemu/qemu_migration.h @@ -74,6 +74,8 @@ VIR_MIGRATE_PARAM_LISTEN_ADDRESS, VIR_TYPED_PARAM_STRING, \ VIR_MIGRATE_PARAM_MIGRATE_DISKS, VIR_TYPED_PARAM_STRING | \ VIR_TYPED_PARAM_MULTIPLE, \ + VIR_MIGRATE_PARAM_MIGRATE_DISKS_DETECT_ZEROES, VIR_TYPED_PARAM_STRING = | \ + VIR_TYPED_PARAM_MULTIPL= E, \ VIR_MIGRATE_PARAM_DISKS_PORT, VIR_TYPED_PARAM_INT, \ VIR_MIGRATE_PARAM_COMPRESSION, VIR_TYPED_PARAM_STRING | \ VIR_TYPED_PARAM_MULTIPLE, \ @@ -123,6 +125,7 @@ qemuMigrationSrcBegin(virConnectPtr conn, char **cookieout, int *cookieoutlen, const char **migrate_disks, + const char **migrate_disks_detect_zeroes, unsigned int flags); virDomainDef * @@ -174,6 +177,7 @@ qemuMigrationSrcPerform(virQEMUDriver *driver, const char *graphicsuri, const char *listenAddress, const char **migrate_disks, + const char **migrate_disks_detect_zeroes, int nbdPort, const char *nbdURI, qemuMigrationParams *migParams, --=20 2.46.0 From nobody Sun Dec 22 06:30:48 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1727703388760795.3799409735353; Mon, 30 Sep 2024 06:36:28 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id A0841C7C; Mon, 30 Sep 2024 09:36:27 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id C6D051276; Mon, 30 Sep 2024 09:30:20 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 670CE12F7; Mon, 30 Sep 2024 09:30:13 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 9F2EA14A9 for ; Mon, 30 Sep 2024 09:29:56 -0400 (EDT) Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-53-ZkKWa9BfOGGsAJVG8K8Ccg-1; Mon, 30 Sep 2024 09:29:55 -0400 Received: from mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (unknown [10.30.177.12]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 3E86919772F6 for ; Mon, 30 Sep 2024 13:29:54 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.45.242.12]) by mx-prod-int-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 5EDE819541A0 for ; Mon, 30 Sep 2024 13:29:53 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3,RCVD_IN_MSPIKE_WL,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1727702996; h=from:from: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; bh=In3hccEDK9QM8lAz2ZknTsO9sgS84POIB3CPfMbz7oc=; b=PXqSS1x/sLbV4YHUK5F9taQGpXysGPcnmHCcm5/M1HxjvYeBWLlORUT5YlgkfNl+y7cPR9 aShR7/QEq7ZQ1cJlwR6XLqCMZSlhnlUFYAtRM0wcODEQelfs7PUtOO3TnXFjmrmMopzvuy masCyMaH6Q1VQ7aqnamfU3+n5xtQCsY= X-MC-Unique: ZkKWa9BfOGGsAJVG8K8Ccg-1 From: Peter Krempa To: devel@lists.libvirt.org Subject: [PATCH 13/13] virsh: Add support for VIR_MIGRATE_PARAM_MIGRATE_DISKS_DETECT_ZEROES migration parameter Date: Mon, 30 Sep 2024 15:29:35 +0200 Message-ID: <89a495fabe2fabd2ce4cf0098bc17607e3014825.1727702835.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.12 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: DKWJX77QJOS2PX47E5TO3JEALEZPXNPO X-Message-ID-Hash: DKWJX77QJOS2PX47E5TO3JEALEZPXNPO X-MailFrom: pkrempa@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1727703390153116600 Content-Type: text/plain; charset="utf-8" Expose the new parameter as '--migrate-disks-detect-zeroes' option. Signed-off-by: Peter Krempa Reviewed-by: Pavel Hrdina --- docs/manpages/virsh.rst | 8 +++++++- tools/virsh-domain.c | 26 ++++++++++++++++++++++++++ 2 files changed, 33 insertions(+), 1 deletion(-) diff --git a/docs/manpages/virsh.rst b/docs/manpages/virsh.rst index f02a28156d..6665d46497 100644 --- a/docs/manpages/virsh.rst +++ b/docs/manpages/virsh.rst @@ -3389,7 +3389,9 @@ migrate [--postcopy-after-precopy] [--postcopy-resume] [--zerocopy] domain desturi [migrateuri] [graphicsuri] [listen-address] [dname] [--timeout seconds [--timeout-suspend | --timeout-postcopy]] - [--xml file] [--migrate-disks disk-list] [--disks-port port] + [--xml file] + [--migrate-disks disk-list] [--migrate-disks-detect-zeroes disk-list] + [--disks-port port] [--compressed] [--comp-methods method-list] [--comp-mt-level] [--comp-mt-threads] [--comp-mt-dthreads] [--comp-xbzrle-cache] [--comp-zlib-level] [--comp-zstd-level] @@ -3420,6 +3422,10 @@ images on source host to the images found at the sam= e place on the destination host. By default only non-shared non-readonly images are transferred. Use *--migrate-disks* to explicitly specify a list of disk targets to transfer via the comma separated ``disk-list`` argument. +The *--migrate-disks-detect-zeroes* option which takes a comma separated l= ist of +disk target names enables zeroed block detection for the listed migrated d= isks. +These blocks are not transferred or allocated on destination, effectively +sparsifying the disk at the cost of CPU overhead. With *--copy-storage-synchronous-writes* flag used the disk data migration= will synchronously handle guest disk writes to both the original source and the destination to ensure that the disk migration converges at the price of po= ssibly diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c index 50e80689a2..e4923284af 100644 --- a/tools/virsh-domain.c +++ b/tools/virsh-domain.c @@ -10691,6 +10691,11 @@ static const vshCmdOptDef opts_migrate[] =3D { .completer =3D virshDomainMigrateDisksCompleter, .help =3D N_("comma separated list of disks to be migrated") }, + {.name =3D "migrate-disks-detect-zeroes", + .type =3D VSH_OT_STRING, + .completer =3D virshDomainMigrateDisksCompleter, + .help =3D N_("comma separated list of disks to be migrated with zero = detection enabled") + }, {.name =3D "disks-port", .type =3D VSH_OT_INT, .unwanted_positional =3D true, @@ -10909,6 +10914,27 @@ doMigrate(void *opaque) } } + if (vshCommandOptString(ctl, cmd, "migrate-disks-detect-zeroes", &opt)= < 0) + goto out; + if (opt) { + g_autofree char **val =3D NULL; + + if (!(flags & (VIR_MIGRATE_NON_SHARED_DISK | VIR_MIGRATE_NON_SHARE= D_INC))) { + vshError(ctl, "'--migrate-disks-detect-zeroes' requires one of= '--copy-storage-all', '--copy-storage-inc'"); + goto out; + } + + val =3D g_strsplit(opt, ",", 0); + + if (virTypedParamsAddStringList(¶ms, + &nparams, + &maxparams, + VIR_MIGRATE_PARAM_MIGRATE_DISKS_DE= TECT_ZEROES, + (const char **)val) < 0) { + goto save_error; + } + } + if (vshCommandOptString(ctl, cmd, "comp-methods", &opt) < 0) goto out; if (opt) { --=20 2.46.0