From nobody Mon Apr 29 16:36:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1601629138; cv=none; d=zohomail.com; s=zohoarc; b=JjaF1exiAA6hdKH5gRYO6OYQmHbcGYBZokigUXioWHVxSYuY9IBCpt0WejsNms/rLAisuOS4I5O+XGfXj5zwMyvzIYUjXSRS7w+EHVp0nVIVuCZ9e6vOBsXJTc0RRqtAaURmtW2Kq3GhUSIYDq4DrsfWS7Z2HTS6J21Y37MbojA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601629138; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=wo4+AqIBatMk/uNAkunjD70v3TDD6AvTb+0QPlQX2mM=; b=K1LE6aeVr58kyMImRdrjYEEFW8uyOwwDToMsEY+wm1m8SHbToiGEYM2qElQ95bkmXQNo2R9W8dBxi3vDWGp9OYEzLMU8lACx86me/O4/EgW2IjUeNT69Iyox0c4vxn3ZjP86/8bVue9LVIZw9tNNWvRiTDCEv7kUkf1PCcguEco= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1601629138843685.7488207228841; Fri, 2 Oct 2020 01:58:58 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-258-4IHiAZ8MNQqGQmySp1d-yA-1; Fri, 02 Oct 2020 04:58:53 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9CBAF100A96A; Fri, 2 Oct 2020 08:58:37 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id EF3477D513; Fri, 2 Oct 2020 08:58:36 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id B216844A4C; Fri, 2 Oct 2020 08:58:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0928wVNj015039 for ; Fri, 2 Oct 2020 04:58:31 -0400 Received: by smtp.corp.redhat.com (Postfix) id 963FF78837; Fri, 2 Oct 2020 08:58:31 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id F36AC7B7C4 for ; Fri, 2 Oct 2020 08:58:30 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601629137; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=wo4+AqIBatMk/uNAkunjD70v3TDD6AvTb+0QPlQX2mM=; b=hSAbXq1e8tp7FblAMl7cVen8tXRrobHFjUCX/3IOblpELZaNMCYrLD21fCDsXM0zwUcR7A WKXwvNWBPVYftH43NpuqEUS8I1hld3uJ/esEJFSnrEvJwzSRyqm1YS7Js5Wqo/ryHCliZK S62DbhJ0N5VqvwZEgXhMWDgKglKIFsE= X-MC-Unique: 4IHiAZ8MNQqGQmySp1d-yA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 01/20] qemu: migration_cookie: Extract parsing/validation of mandatory features Date: Fri, 2 Oct 2020 10:57:35 +0200 Message-Id: <823f99895cc1bbcee338d3120aef086cc5212dcc.1601629017.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Move the code into 'qemuMigrationCookieXMLParseMandatoryFeatures' to simplify 'qemuMigrationCookieXMLParse'. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_migration_cookie.c | 77 +++++++++++++++++++------------- 1 file changed, 45 insertions(+), 32 deletions(-) diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_coo= kie.c index 4b73a98f7e..22705874e0 100644 --- a/src/qemu/qemu_migration_cookie.c +++ b/src/qemu/qemu_migration_cookie.c @@ -1159,6 +1159,49 @@ qemuMigrationCookieCapsXMLParse(xmlXPathContextPtr c= txt) } +/** + * qemuMigrationCookieXMLParseMandatoryFeatures: + * + * Check to ensure all mandatory features from XML are also present in 'fl= ags'. + */ +static int +qemuMigrationCookieXMLParseMandatoryFeatures(xmlXPathContextPtr ctxt, + unsigned int flags) +{ + g_autofree xmlNodePtr *nodes =3D NULL; + size_t i; + ssize_t n; + + if ((n =3D virXPathNodeSet("./feature", ctxt, &nodes)) < 0) + return -1; + + for (i =3D 0; i < n; i++) { + int val; + g_autofree char *str =3D virXMLPropString(nodes[i], "name"); + + if (!str) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("missing feature name")); + return -1; + } + + if ((val =3D qemuMigrationCookieFlagTypeFromString(str)) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unknown migration cookie feature %s"), str); + return -1; + } + + if ((flags & (1 << val)) =3D=3D 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("Unsupported migration cookie feature %s"), s= tr); + return -1; + } + } + + return 0; +} + + static int qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mig, virQEMUDriverPtr driver, @@ -1170,7 +1213,6 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mi= g, char uuidstr[VIR_UUID_STRING_BUFLEN]; char *tmp =3D NULL; xmlNodePtr *nodes =3D NULL; - size_t i; int n; /* We don't store the uuid, name, hostname, or hostuuid @@ -1237,38 +1279,9 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr m= ig, } VIR_FREE(tmp); - /* Check to ensure all mandatory features from XML are also - * present in 'flags' */ - if ((n =3D virXPathNodeSet("./feature", ctxt, &nodes)) < 0) - goto error; - - for (i =3D 0; i < n; i++) { - int val; - char *str =3D virXMLPropString(nodes[i], "name"); - if (!str) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("missing feature name")); - goto error; - } - - if ((val =3D qemuMigrationCookieFlagTypeFromString(str)) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unknown migration cookie feature %s"), - str); - VIR_FREE(str); - goto error; - } - if ((flags & (1 << val)) =3D=3D 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unsupported migration cookie feature %s"), - str); - VIR_FREE(str); - goto error; - } - VIR_FREE(str); - } - VIR_FREE(nodes); + if (qemuMigrationCookieXMLParseMandatoryFeatures(ctxt, flags) < 0) + return -1; if ((flags & QEMU_MIGRATION_COOKIE_GRAPHICS) && virXPathBoolean("count(./graphics) > 0", ctxt) && --=20 2.26.2 From nobody Mon Apr 29 16:36:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1601629143; cv=none; d=zohomail.com; s=zohoarc; b=Xsu4+9h5eg6POtHKqu9bvTWX+toIiYlBjZoKmy5ImERQffmqJFz321sKQDv58xAJXyumsW8z+eNK/eQNnp93FCsUchu08xrI+/MXWRRMlnZVCoHFVIFC4b5x4Vnq/WoleDcDG/r+jXtdwuUjVV7eNJq7n+sNzxzHJvkozOojtRM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601629143; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Ul9HaqUIV9FHUXmcPiiO2qJkWSCrGXK81tddahZfwaI=; b=hVLTRHbkfa/PRzWc86z5mDwV1ceol/sHUKIbomumCtJ+dBfI2JYp9oscqU4G7dbUlt5vJbZixLJskS9rSBPGIkWQXNed3DTHNyi4O+gZv7PP+7vCHMAv/jr7v0Y4LrSjluLQR7vRUoRKBMdNa2YrZ4rlY4Ia06r2fCOmEolFPok= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1601629143918462.44587337803466; Fri, 2 Oct 2020 01:59:03 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-479-bFi0_IB3PWWqQA9rLlcejA-1; Fri, 02 Oct 2020 04:59:00 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 4250FACF23; Fri, 2 Oct 2020 08:58:41 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BFE7A7C3F8; Fri, 2 Oct 2020 08:58:39 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 820A744A5E; Fri, 2 Oct 2020 08:58:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0928wWBx015049 for ; Fri, 2 Oct 2020 04:58:33 -0400 Received: by smtp.corp.redhat.com (Postfix) id DD8A27B7C0; Fri, 2 Oct 2020 08:58:32 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0A69378831 for ; Fri, 2 Oct 2020 08:58:31 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601629142; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Ul9HaqUIV9FHUXmcPiiO2qJkWSCrGXK81tddahZfwaI=; b=dXcqpdFiktN1x6V1j14lHbHMeATmuQVhs5MmeVSc8uXzepD9iuwWVCJt75aT/c1GQSxiIR bnZ1W05sUGhzYh647T3mGPzm5c+bDp5Gra7qmHR2KZ1rgXMYbTRVf+Py/rDHBLSTxjeAss XlD/6UNi2jaSNek75lGuMMxgcGlTZfM= X-MC-Unique: bFi0_IB3PWWqQA9rLlcejA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 02/20] qemuMigrationCookieXMLParse: Switch to single-purpose temporary variables Date: Fri, 2 Oct 2020 10:57:36 +0200 Message-Id: <4f1f5db4bf98fdb66e8c3db5d3c3e9387edd513d.1601629017.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Don't reuse 'tmp' over and over, but switch to single use automaticaly freed variables instead. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_migration_cookie.c | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_coo= kie.c index 22705874e0..f313b6d00e 100644 --- a/src/qemu/qemu_migration_cookie.c +++ b/src/qemu/qemu_migration_cookie.c @@ -1210,8 +1210,10 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr m= ig, xmlXPathContextPtr ctxt, unsigned int flags) { - char uuidstr[VIR_UUID_STRING_BUFLEN]; - char *tmp =3D NULL; + g_autofree char *name =3D NULL; + g_autofree char *uuid =3D NULL; + g_autofree char *hostuuid =3D NULL; + char localdomuuid[VIR_UUID_STRING_BUFLEN]; xmlNodePtr *nodes =3D NULL; int n; @@ -1221,34 +1223,31 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr = mig, */ /* Extract domain name */ - if (!(tmp =3D virXPathString("string(./name[1])", ctxt))) { + if (!(name =3D virXPathString("string(./name[1])", ctxt))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing name element in migration data")); goto error; } - if (STRNEQ(tmp, mig->name)) { + if (STRNEQ(name, mig->name)) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Incoming cookie data had unexpected name %s vs %= s"), - tmp, mig->name); + name, mig->name); goto error; } - VIR_FREE(tmp); /* Extract domain uuid */ - tmp =3D virXPathString("string(./uuid[1])", ctxt); - if (!tmp) { + if (!(uuid =3D virXPathString("string(./uuid[1])", ctxt))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing uuid element in migration data")); goto error; } - virUUIDFormat(mig->uuid, uuidstr); - if (STRNEQ(tmp, uuidstr)) { + virUUIDFormat(mig->uuid, localdomuuid); + if (STRNEQ(uuid, localdomuuid)) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Incoming cookie data had unexpected UUID %s vs %= s"), - tmp, uuidstr); + uuid, localdomuuid); goto error; } - VIR_FREE(tmp); if (!(mig->remoteHostname =3D virXPathString("string(./hostname[1])", = ctxt))) { virReportError(VIR_ERR_INTERNAL_ERROR, @@ -1261,12 +1260,12 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr = mig, * for sure. */ /* Check & forbid localhost migration */ - if (!(tmp =3D virXPathString("string(./hostuuid[1])", ctxt))) { + if (!(hostuuid =3D virXPathString("string(./hostuuid[1])", ctxt))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing hostuuid element in migration data= ")); goto error; } - if (virUUIDParse(tmp, mig->remoteHostuuid) < 0) { + if (virUUIDParse(hostuuid, mig->remoteHostuuid) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("malformed hostuuid element in migration da= ta")); goto error; @@ -1274,11 +1273,9 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr m= ig, if (memcmp(mig->remoteHostuuid, mig->localHostuuid, VIR_UUID_BUFLEN) = =3D=3D 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Attempt to migrate guest to the same host %s"), - tmp); + hostuuid); goto error; } - VIR_FREE(tmp); - if (qemuMigrationCookieXMLParseMandatoryFeatures(ctxt, flags) < 0) return -1; @@ -1353,7 +1350,6 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mi= g, return 0; error: - VIR_FREE(tmp); VIR_FREE(nodes); return -1; } --=20 2.26.2 From nobody Mon Apr 29 16:36:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1601629133; cv=none; d=zohomail.com; s=zohoarc; b=fEKSwe0JUMAMhrY8A5PRRjuQMhIQ7IHxz5iaoiRczxdURJAbJgGVbaHRmtxf6Xf+JyZk5c1ERMT6Sh4PJJYtJbS8oPV2rTWjnIaiOZkstpve3wEk7ddyvx1eW2Z1smxsVpzRjqiPsBMp2aMIj7ytcXgxoJirvUriL87y7UAqSkw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601629133; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=j+npQ/hRG1hrD0TybhwUhtm/Z70JOE/TZ35Bno+Ee/8=; b=hyEvpPwLw0IxYY8iFsH+Lmw07UOXzpVxr/93ZTHUi8W5mk6IBp0VNhCohUzF8HtUA1hxxecxuoifiOlXXmQTE9bXZKkTuR50fWpc+pQ29a5nUpndt5SAKFUDF8RBz2RtV21MUdAqahjAXSv4aAnoaok6YvRy/hvTApGkEdDhDmA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1601629133284293.8136810324128; Fri, 2 Oct 2020 01:58:53 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-557-GRcRajtNOM25Z_5nH_BVFQ-1; Fri, 02 Oct 2020 04:58:49 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 415A484E241; Fri, 2 Oct 2020 08:58:37 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7D9E75DE4F; Fri, 2 Oct 2020 08:58:36 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 05F0A181A06C; Fri, 2 Oct 2020 08:58:36 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0928wY6I015063 for ; Fri, 2 Oct 2020 04:58:34 -0400 Received: by smtp.corp.redhat.com (Postfix) id 29B947883B; Fri, 2 Oct 2020 08:58:34 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 35EDB79996 for ; Fri, 2 Oct 2020 08:58:32 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601629132; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=j+npQ/hRG1hrD0TybhwUhtm/Z70JOE/TZ35Bno+Ee/8=; b=BeyRIVji/MJo8iQ3aC9Ap3WuP4R5zsWNG0gzuuHpeXS5lDJ3rbNkXGeeTswUFTXZcBC+I2 jDoHM4CRhd+9EcPnnSRApMJ181Q8/TG4GR8Dofql1Yd/cBTXtB7v85ea/SOgbDawdgrmep aD3hjP7SuyeYcNLZL6BCoGouhPVzNf8= X-MC-Unique: GRcRajtNOM25Z_5nH_BVFQ-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 03/20] qemuMigrationCookieXMLParse: Check domain element count more defensively Date: Fri, 2 Oct 2020 10:57:37 +0200 Message-Id: <625dd42ddc23f5c48b0ba383b0f12a410714f48d.1601629017.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Make sure that 'virXPathNodeSet' returns '1' as the only expected value rather than relying on the fact that the previous check for the number of elements ensures success of the subsequent call. The error message no longer mentions the number of elements in the cookie, but this is a very unlikely internal error anyways. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_migration_cookie.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_coo= kie.c index f313b6d00e..9b1268833a 100644 --- a/src/qemu/qemu_migration_cookie.c +++ b/src/qemu/qemu_migration_cookie.c @@ -1215,7 +1215,6 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mi= g, g_autofree char *hostuuid =3D NULL; char localdomuuid[VIR_UUID_STRING_BUFLEN]; xmlNodePtr *nodes =3D NULL; - int n; /* We don't store the uuid, name, hostname, or hostuuid * values. We just compare them to local data to do some @@ -1300,11 +1299,9 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr m= ig, if ((flags & QEMU_MIGRATION_COOKIE_PERSISTENT) && virXPathBoolean("count(./domain) > 0", ctxt)) { - if ((n =3D virXPathNodeSet("./domain", ctxt, &nodes)) > 1) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Too many domain elements in " - "migration cookie: %d"), - n); + if ((virXPathNodeSet("./domain", ctxt, &nodes)) !=3D 1) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Too many domain elements in migration cookie= ")); goto error; } mig->persistent =3D virDomainDefParseNode(doc, nodes[0], --=20 2.26.2 From nobody Mon Apr 29 16:36:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1601629137; cv=none; d=zohomail.com; s=zohoarc; b=n67nUXcTaOmcsDGtegz0qf/EjqCsHrSVvtIFsa5xbXfQMGnLFcUu/DM8zTx+2hpiK4HhpR8i4CmV1cGEKdw9/qihWeE25qDjKznAWjYROzMVh9NgtuMU38U3O6okA0ozCcyI53JCVv+rcT840K1LPN8BryfcGP7o9iMtNXJzKIY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601629137; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=5zyIZEqJtf1O2380utrlOrg36UbiPWVNQkyriGCHyzM=; b=d7Fe2/TD4Hm2HL1XNq0SIOt7ElLK8Gr1MrTSLLlKIT0eDGOUABjFVAj5rFcmloHShHqtsQ2ZpMw7vUjXu1wifUtyt6XKEe+0uW6FnZCZaUfuzhOZgi7/M/JpoUy8WGLlVS4kykFpPLspICs5G0U6IkkPkgpKJk6nFclhc3FxVX4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1601629137158569.4720091925008; Fri, 2 Oct 2020 01:58:57 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-422-NHLKFHgROHyWalu1TDbF4w-1; Fri, 02 Oct 2020 04:58:53 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 70A32192CC78; Fri, 2 Oct 2020 08:58:38 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 93EB94F9A8; Fri, 2 Oct 2020 08:58:37 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 59F1344A5E; Fri, 2 Oct 2020 08:58:37 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0928wZqK015072 for ; Fri, 2 Oct 2020 04:58:35 -0400 Received: by smtp.corp.redhat.com (Postfix) id 408157ED6A; Fri, 2 Oct 2020 08:58:35 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 535FD7998B for ; Fri, 2 Oct 2020 08:58:34 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601629134; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=5zyIZEqJtf1O2380utrlOrg36UbiPWVNQkyriGCHyzM=; b=Q138CKHolmHSNYO3Oa2nhx/eMjzdL1FlMtNW2znu3dfvyue6iC3yuk/VOuDRc0XQ/PloQv hsQRIkFW81U0ezhS4Q2khXYS8iQoqnntz/VTOqZ5CaWkaW8Yhy0RHr1tWicmbf4e2fFoLm Z9AleEl0araofcey3bTpoVZNqCRQ1MU= X-MC-Unique: NHLKFHgROHyWalu1TDbF4w-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 04/20] qemuMigrationCookieXMLParse: Decrease scope of 'nodes' and use automatic freeing Date: Fri, 2 Oct 2020 10:57:38 +0200 Message-Id: <78224937ec6fd5b2f84bc2a82a3ebd2ed11fe42a.1601629017.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_migration_cookie.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_coo= kie.c index 9b1268833a..a9dd2b9323 100644 --- a/src/qemu/qemu_migration_cookie.c +++ b/src/qemu/qemu_migration_cookie.c @@ -1214,7 +1214,6 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mi= g, g_autofree char *uuid =3D NULL; g_autofree char *hostuuid =3D NULL; char localdomuuid[VIR_UUID_STRING_BUFLEN]; - xmlNodePtr *nodes =3D NULL; /* We don't store the uuid, name, hostname, or hostuuid * values. We just compare them to local data to do some @@ -1299,6 +1298,8 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mi= g, if ((flags & QEMU_MIGRATION_COOKIE_PERSISTENT) && virXPathBoolean("count(./domain) > 0", ctxt)) { + g_autofree xmlNodePtr *nodes =3D NULL; + if ((virXPathNodeSet("./domain", ctxt, &nodes)) !=3D 1) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Too many domain elements in migration cookie= ")); @@ -1314,7 +1315,6 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mi= g, * an error for us */ goto error; } - VIR_FREE(nodes); } if ((flags & QEMU_MIGRATION_COOKIE_NETWORK) && @@ -1347,7 +1347,6 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mi= g, return 0; error: - VIR_FREE(nodes); return -1; } --=20 2.26.2 From nobody Mon Apr 29 16:36:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1601629143; cv=none; d=zohomail.com; s=zohoarc; b=jnGWjgXaSACPeoQMNteYOU1bnXFjx7//YHgZuJY9qYwmbV8LAq/UQbSM8UShIozuBHC6BmC4IGT/oFH3v4MpgtI2or7UT4hpu1lBbr6buqyWh7wcb5vq5MyTM0wYF/sTgcidsZVPoKbd4kLb4/TKgrM1PbzL/fD0QOTG8G526FQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601629143; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=m5mqlKrJE5tUlXhQ6oes8Zufm/cXGBt/p8Dag+763u8=; b=AFtYBiOEa5MBe0W+/AR2+89twil3BHkdmB5+mcKZGy3/y0lmeiLglHEq1ddpYdJtnzG0aqlrVF3y4D1gOcHKQ91c4ggGW6HFA6Ys/I4nREbO7Y8x8AiH/NT1E/Lr7MLQVvgEhTHJ8Qj0mqwWKTkEoP9JtsNRQRfWWdsrPP0m2Us= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1601629143879781.2550687981213; Fri, 2 Oct 2020 01:59:03 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-127-dH0z_KtsNN6LXAy3ABeIgw-1; Fri, 02 Oct 2020 04:58:59 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B7DDA1DE0B; Fri, 2 Oct 2020 08:58:40 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 507C05DA71; Fri, 2 Oct 2020 08:58:40 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 11954181A050; Fri, 2 Oct 2020 08:58:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0928wa9V015082 for ; Fri, 2 Oct 2020 04:58:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2DCBD7E41C; Fri, 2 Oct 2020 08:58:36 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7820C88D5C for ; Fri, 2 Oct 2020 08:58:35 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601629142; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=m5mqlKrJE5tUlXhQ6oes8Zufm/cXGBt/p8Dag+763u8=; b=cKzRPQ+g+ZhSVhl1JwIF1t1fU51Vp9wnX0ed0nRJFa2+iWcNKst/rMVNWJw0xoxSkzlNzX L+9UVAOmJj0lrNPwudwdRPUfjCxjU2kFaPuW4v0FmpCIIb8GklGRomNmG/ycDl6F59Y6/E /t9YGcRDohX0m1ibKZU4IkMQdkpV1gU= X-MC-Unique: dH0z_KtsNN6LXAy3ABeIgw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 05/20] qemuMigrationCookieXMLParse: Remove comment mentioning that error was already set Date: Fri, 2 Oct 2020 10:57:39 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Most of our functions report errors so there's no need to mention it here again. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_migration_cookie.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_coo= kie.c index a9dd2b9323..f7625a7991 100644 --- a/src/qemu/qemu_migration_cookie.c +++ b/src/qemu/qemu_migration_cookie.c @@ -1310,11 +1310,8 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr m= ig, VIR_DOMAIN_DEF_PARSE_INACT= IVE | VIR_DOMAIN_DEF_PARSE_ABI_U= PDATE_MIGRATION | VIR_DOMAIN_DEF_PARSE_SKIP_= VALIDATE); - if (!mig->persistent) { - /* virDomainDefParseNode already reported - * an error for us */ + if (!mig->persistent) goto error; - } } if ((flags & QEMU_MIGRATION_COOKIE_NETWORK) && --=20 2.26.2 From nobody Mon Apr 29 16:36:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1601629206; cv=none; d=zohomail.com; s=zohoarc; b=i7OWEkOczmlLn9WUUrFzdctmlUU+WeqtQfKIgGD0b3ScrrbH8Yy85dgwru9mQm4mlwRbnMVRiaE9Kcrxtzqj0U8Nh+ltLHK7eIQsiCLdkKwX2BKvtbi4V10g6w6W6wnFRsrcyM27VFqL7zKiAWSx2hyAsnE541QOmptNNRpC8Uo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601629206; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=tL1rJeAuVa96haCnn4RXCQQJd3HiqEiCvEOQhHU1AEk=; b=NdZmTi+2Tf4y7rOzjCYxhAjChFdN3I8EJ+jeCMTKt8VzMJI5WzUz1JOf8s0iyRYQ94V6otdPGzqKvK3JxOthe55NMvGsYYgw09Hup17k9gTeB4M7wHhGXXVJ4l6wGXw7vUydUH+wduuHlegihK/y/oD+sv1f1Kj3sAvxlG2DgH8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1601629206787499.6392606229248; Fri, 2 Oct 2020 02:00:06 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-594-ggLpLTz4NBiGsLURR1iMvA-1; Fri, 02 Oct 2020 04:59:06 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8B962102C7D2; Fri, 2 Oct 2020 08:58:42 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 657135D9FC; Fri, 2 Oct 2020 08:58:42 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 2478044A56; Fri, 2 Oct 2020 08:58:42 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0928wcrh015093 for ; Fri, 2 Oct 2020 04:58:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5A107799B5; Fri, 2 Oct 2020 08:58:37 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9143A7E8D5 for ; Fri, 2 Oct 2020 08:58:36 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601629205; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=tL1rJeAuVa96haCnn4RXCQQJd3HiqEiCvEOQhHU1AEk=; b=hLjShi1RuQDUF98x+341bPkCz2fsTTcrKL/yLWVs2nGkNxPvn3PrgvHG7fgC6PjBXTcdUg YazvZlqJXRIfH2/pQTy2SveNF8QFkA8kT3LGrVIPkW0w8Awk5pUTXzMyVkrzr16TG5hj0J yeANr6iGxrXMcNySwkn51ihR2b30GWw= X-MC-Unique: ggLpLTz4NBiGsLURR1iMvA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 06/20] qemuMigrationCookieXMLParse: Remove 'error' label Date: Fri, 2 Oct 2020 10:57:40 +0200 Message-Id: <814ee53c68dc872a2edd32c069150925565d8162.1601629017.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Now it only returns -1 so we can do that directly. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_migration_cookie.c | 39 +++++++++++++++----------------- 1 file changed, 18 insertions(+), 21 deletions(-) diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_coo= kie.c index f7625a7991..052d8e311b 100644 --- a/src/qemu/qemu_migration_cookie.c +++ b/src/qemu/qemu_migration_cookie.c @@ -1224,33 +1224,33 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr = mig, if (!(name =3D virXPathString("string(./name[1])", ctxt))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing name element in migration data")); - goto error; + return -1; } if (STRNEQ(name, mig->name)) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Incoming cookie data had unexpected name %s vs %= s"), name, mig->name); - goto error; + return -1; } /* Extract domain uuid */ if (!(uuid =3D virXPathString("string(./uuid[1])", ctxt))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing uuid element in migration data")); - goto error; + return -1; } virUUIDFormat(mig->uuid, localdomuuid); if (STRNEQ(uuid, localdomuuid)) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Incoming cookie data had unexpected UUID %s vs %= s"), uuid, localdomuuid); - goto error; + return -1; } if (!(mig->remoteHostname =3D virXPathString("string(./hostname[1])", = ctxt))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing hostname element in migration data= ")); - goto error; + return -1; } /* Historically, this is the place where we checked whether remoteHost= name * and localHostname are the same. But even if they were, it doesn't m= ean @@ -1261,18 +1261,18 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr = mig, if (!(hostuuid =3D virXPathString("string(./hostuuid[1])", ctxt))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing hostuuid element in migration data= ")); - goto error; + return -1; } if (virUUIDParse(hostuuid, mig->remoteHostuuid) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("malformed hostuuid element in migration da= ta")); - goto error; + return -1; } if (memcmp(mig->remoteHostuuid, mig->localHostuuid, VIR_UUID_BUFLEN) = =3D=3D 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Attempt to migrate guest to the same host %s"), hostuuid); - goto error; + return -1; } if (qemuMigrationCookieXMLParseMandatoryFeatures(ctxt, flags) < 0) @@ -1281,7 +1281,7 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mi= g, if ((flags & QEMU_MIGRATION_COOKIE_GRAPHICS) && virXPathBoolean("count(./graphics) > 0", ctxt) && (!(mig->graphics =3D qemuMigrationCookieGraphicsXMLParse(ctxt)))) - goto error; + return -1; if ((flags & QEMU_MIGRATION_COOKIE_LOCKSTATE) && virXPathBoolean("count(./lockstate) > 0", ctxt)) { @@ -1289,7 +1289,7 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mi= g, if (!mig->lockDriver) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing lock driver name in migration cookie= ")); - goto error; + return -1; } mig->lockState =3D virXPathString("string(./lockstate[1]/leases[1]= )", ctxt); if (mig->lockState && STREQ(mig->lockState, "")) @@ -1303,7 +1303,7 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr mi= g, if ((virXPathNodeSet("./domain", ctxt, &nodes)) !=3D 1) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Too many domain elements in migration cookie= ")); - goto error; + return -1; } mig->persistent =3D virDomainDefParseNode(doc, nodes[0], driver->xmlopt, qemuCaps, @@ -1311,40 +1311,37 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr = mig, VIR_DOMAIN_DEF_PARSE_ABI_U= PDATE_MIGRATION | VIR_DOMAIN_DEF_PARSE_SKIP_= VALIDATE); if (!mig->persistent) - goto error; + return -1; } if ((flags & QEMU_MIGRATION_COOKIE_NETWORK) && virXPathBoolean("count(./network) > 0", ctxt) && (!(mig->network =3D qemuMigrationCookieNetworkXMLParse(ctxt)))) - goto error; + return -1; if (flags & QEMU_MIGRATION_COOKIE_NBD && virXPathBoolean("boolean(./nbd)", ctxt) && (!(mig->nbd =3D qemuMigrationCookieNBDXMLParse(ctxt)))) - goto error; + return -1; if (flags & QEMU_MIGRATION_COOKIE_STATS && virXPathBoolean("boolean(./statistics)", ctxt) && (!(mig->jobInfo =3D qemuMigrationCookieStatisticsXMLParse(ctxt)))) - goto error; + return -1; if (flags & QEMU_MIGRATION_COOKIE_CPU && virCPUDefParseXML(ctxt, "./cpu[1]", VIR_CPU_TYPE_GUEST, &mig->cpu)= < 0) - goto error; + return -1; if (flags & QEMU_MIGRATION_COOKIE_ALLOW_REBOOT && qemuDomainObjPrivateXMLParseAllowReboot(ctxt, &mig->allowReboot) <= 0) - goto error; + return -1; if (flags & QEMU_MIGRATION_COOKIE_CAPS && !(mig->caps =3D qemuMigrationCookieCapsXMLParse(ctxt))) - goto error; + return -1; return 0; - - error: - return -1; } --=20 2.26.2 From nobody Mon Apr 29 16:36:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1601629205; cv=none; d=zohomail.com; s=zohoarc; b=jJGEVO8yplYr79bFMWeor4ODzC2rKg5GIWvpmYizJ6e+wAnZ02pDUbZi9fj0bevFBgXK+GR8b7Ym/K6gubGPrNJHsh42/V7ZOn5cWt+o10+O0kkLLwzyOeVkWmEIQNtRVbM0I3eFHs3RyGs2HcZ77+9KMuf8NxdfNQbnITr9Das= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601629205; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=vXD+/rrj0vaGpCYCL1DQbe+DeT5eS7umuxnNSu7vL70=; b=CfMwCnkjjzTh+51tZIcJw/4XERf09iLRl+lMDMTLVg+6U/erfsY9zraRTxu28grfXyyMEKrKQUE/NQ4HNWHkCX+5LvdSmmdY57eN4h7KUOpcXUV+apQW+Ib3/WitQ2EyhF9bHdnueuuV5GZlA6i71AWYqQvNQIB09s1ZaksZBdY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 160162920540137.2791119758441; Fri, 2 Oct 2020 02:00:05 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-577-DY5SnftwP56CW107hiXj_Q-1; Fri, 02 Oct 2020 04:59:08 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2B90C8C4EF1; Fri, 2 Oct 2020 08:58:45 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 088995D9D5; Fri, 2 Oct 2020 08:58:45 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id CA032181A050; Fri, 2 Oct 2020 08:58:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0928wdXV015104 for ; Fri, 2 Oct 2020 04:58:39 -0400 Received: by smtp.corp.redhat.com (Postfix) id B0BE583458; Fri, 2 Oct 2020 08:58:38 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id B69E77ED66 for ; Fri, 2 Oct 2020 08:58:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601629204; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=vXD+/rrj0vaGpCYCL1DQbe+DeT5eS7umuxnNSu7vL70=; b=H3ZBAbd3l3n10VyPybfrP8zFJM5rsf9HI4AudmquyqW9TCXCSV4Y+TNudl+VgpukYgByCF L+x5xa7/CrDXCescp3SusQlFZw3h65mFctsh7TRTU9OhWXbbbk11FkM9e78bn0Gsn8KjVm BlDsErfEpe/CfT/2eKNo53+yY9YXpQU= X-MC-Unique: DY5SnftwP56CW107hiXj_Q-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 07/20] qemuMigrationCookieGraphicsXMLFormat: Use 'virXMLFormatElement' Date: Fri, 2 Oct 2020 10:57:41 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Switch to the two buffer approach to simplify the logic for terminating the element. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_migration_cookie.c | 21 ++++++++++----------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_coo= kie.c index 052d8e311b..accf3c5efb 100644 --- a/src/qemu/qemu_migration_cookie.c +++ b/src/qemu/qemu_migration_cookie.c @@ -581,20 +581,19 @@ static void qemuMigrationCookieGraphicsXMLFormat(virBufferPtr buf, qemuMigrationCookieGraphicsPtr grap) { - virBufferAsprintf(buf, "type), grap->port, grap->listen); + if (grap->type =3D=3D VIR_DOMAIN_GRAPHICS_TYPE_SPICE) - virBufferAsprintf(buf, " tlsPort=3D'%d'", grap->tlsPort); - if (grap->tlsSubject) { - virBufferAddLit(buf, ">\n"); - virBufferAdjustIndent(buf, 2); - virBufferEscapeString(buf, "\= n", grap->tlsSubject); - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); - } else { - virBufferAddLit(buf, "/>\n"); - } + virBufferAsprintf(&attrBuf, " tlsPort=3D'%d'", grap->tlsPort); + + virBufferEscapeString(&childBuf, "\n", grap->tlsSubject); + + virXMLFormatElement(buf, "graphics", &attrBuf, &childBuf); } --=20 2.26.2 From nobody Mon Apr 29 16:36:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1601629169; cv=none; d=zohomail.com; s=zohoarc; b=MtPh/ZAJK7orT2Xiyopyu552AJzrSKN/QLFIJYARl4e+j481ZzSADV9kHR/H+h/wuEtt1n/5ipmdzo+Udi5zoTdDaC/3U1ZR/fqoFF+w6ZR1AMu18saya2fyC9nz7RLppC5T4/wE+9paeSajmaxsXxllKXiM8C+TJZPgoqL+uCA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601629169; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=z56HRPZ/b/JyBS1TEmAVGDn9KvmCcljXucR7ot1h+Qg=; b=EsWDiYbYXMLDvDpU7v9Np5jyhh+EjOOmiusvySNCbQDcVc1qbuTZjAuh1NbwLAGg/nskMUcvCPWg1iqkl0SacIojMoore2UPP+heaLE2tabczURuqHtOav6/e7IUFKeOUscIesoLR0a8KuytvEOEE17OFc3LD+V3fGnmPPgjhRA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1601629168859255.58977770050888; Fri, 2 Oct 2020 01:59:28 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-496-q3dqByJPOJ2hQDdfMyLBZA-1; Fri, 02 Oct 2020 04:59:24 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 0477A108829E; Fri, 2 Oct 2020 08:58:48 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D18B1100238C; Fri, 2 Oct 2020 08:58:47 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 9B8D444A5C; Fri, 2 Oct 2020 08:58:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0928weFW015116 for ; Fri, 2 Oct 2020 04:58:40 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8599E83441; Fri, 2 Oct 2020 08:58:40 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id D69DA83467 for ; Fri, 2 Oct 2020 08:58:38 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601629167; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=z56HRPZ/b/JyBS1TEmAVGDn9KvmCcljXucR7ot1h+Qg=; b=Gph+FizuH9Tf3MbIFUiS8fDRQoH4VWRA7a3kAGg5NTDR4tepX+oCwaMMXsiV45OZNkydcC p57uNMLVlQH8IehdsHXbEJq1qfNkhah6Gwwlj9wTQgCQ/hTAKxrsev5Fy7BQ2NYAz47tTs S7/8eko7gqhWkWGBtCsf9zGC3wMcaos= X-MC-Unique: q3dqByJPOJ2hQDdfMyLBZA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 08/20] qemuMigrationCookieNetworkXMLFormat: Refactor XML formatting Date: Fri, 2 Oct 2020 10:57:42 +0200 Message-Id: <7fb721c51c28843d9001896330b07cf3a4e51aca.1601629017.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Use 'virXMLFormatElement' both for formating the whole element but also for formatting the subelements. This alows to remove the crazy logic which was determining which element was already formatted. Additional simplification is achieved by switching to skipping the loop using 'continue' rather than putting everything in a giant block. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_migration_cookie.c | 40 +++++++++++++------------------- 1 file changed, 16 insertions(+), 24 deletions(-) diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_coo= kie.c index accf3c5efb..a888c0074c 100644 --- a/src/qemu/qemu_migration_cookie.c +++ b/src/qemu/qemu_migration_cookie.c @@ -601,35 +601,27 @@ static void qemuMigrationCookieNetworkXMLFormat(virBufferPtr buf, qemuMigrationCookieNetworkPtr optr) { + g_auto(virBuffer) interfaceBuf =3D VIR_BUFFER_INIT_CHILD(buf); size_t i; - bool empty =3D true; for (i =3D 0; i < optr->nnets; i++) { + g_auto(virBuffer) attrBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) childBuf =3D VIR_BUFFER_INIT_CHILD(&interfaceBuf= ); + /* If optr->net[i].vporttype is not set, there is nothing to trans= fer */ - if (optr->net[i].vporttype !=3D VIR_NETDEV_VPORT_PROFILE_NONE) { - if (empty) { - virBufferAddLit(buf, "\n"); - virBufferAdjustIndent(buf, 2); - empty =3D false; - } - virBufferAsprintf(buf, "net[i].v= porttype)); - if (optr->net[i].portdata) { - virBufferAddLit(buf, ">\n"); - virBufferAdjustIndent(buf, 2); - virBufferEscapeString(buf, "%s\n", - optr->net[i].portdata); - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); - } else { - virBufferAddLit(buf, "/>\n"); - } - } - } - if (!empty) { - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); + if (optr->net[i].vporttype =3D=3D VIR_NETDEV_VPORT_PROFILE_NONE) + continue; + + virBufferAsprintf(&attrBuf, " index=3D'%zu' vporttype=3D'%s'", + i, virNetDevVPortTypeToString(optr->net[i].vport= type)); + + virBufferEscapeString(&childBuf, "%s\n", + optr->net[i].portdata); + + virXMLFormatElement(&interfaceBuf, "interface", &attrBuf, &childBu= f); } + + virXMLFormatElement(buf, "network", NULL, &interfaceBuf); } --=20 2.26.2 From nobody Mon Apr 29 16:36:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1601629207; cv=none; d=zohomail.com; s=zohoarc; b=R6k4PKq7W5g6jOhc5nilTmXamsHNkXevQqJH+VFeKdO5Wk0YbjKpAxHTeAtyEIh4/b7T4NFdeLMNT3MGfosFfbj8j6Xib2mX6aFrY6lMMQ/+DbJ7jjMOi8QhJvSURkNrOCxW+AKX1bb81YO7tMI1RZ5qo6cf2/mC+sGJLJ2mrsU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601629207; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=9i6MapETX81dy/INwchBwQPRwzMxcY0BpkZfD32xITc=; b=XsGD7YpE84zldK+GrWvGww4f9Hvoa1MATJFW6NWWFtjMqwq4+YRs3oaKRpi9hnZxIs7jCZmGHlkuVTmSYx/QODMqssTYVMiQKh1fpA5v/d6OOOiC1U1yRZ9XW4MEYdkOaaRgn9xASUyFcurOQRUUr6oxYEXn6WtQbZ0vSnEke+8= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1601629207636574.1856445765816; Fri, 2 Oct 2020 02:00:07 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-187-MFPpUaz4O_ype8wvdDitQA-1; Fri, 02 Oct 2020 04:59:09 -0400 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 6D9D4ADCFD; Fri, 2 Oct 2020 08:58:44 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4CD1B78820; Fri, 2 Oct 2020 08:58:44 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 19E73181A050; Fri, 2 Oct 2020 08:58:44 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0928wf6V015121 for ; Fri, 2 Oct 2020 04:58:41 -0400 Received: by smtp.corp.redhat.com (Postfix) id 95F9778820; Fri, 2 Oct 2020 08:58:41 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 013C27881E for ; Fri, 2 Oct 2020 08:58:40 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601629206; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=9i6MapETX81dy/INwchBwQPRwzMxcY0BpkZfD32xITc=; b=NCGwjnvLUP/ahzmLkKbcCUaBqK2iatLbsIPLgF34LMpt318b2eR81c+ZCyNey0Toqw152r ybgPBqx6YL65jFXPD8cpD7qdeKRXKZvZ1voNbpUygPcxh8mYJ9cLg/VRM9DVC2qXgcWCxy 5DG56ISYqr4vHtn5qiUk7w1dQJ1qaxc= X-MC-Unique: MFPpUaz4O_ype8wvdDitQA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 09/20] qemuMigrationCookieXMLFormat: Extract formatting of NBD Date: Fri, 2 Oct 2020 10:57:43 +0200 Message-Id: <39864d0d5032e9b894e6abb13784d4e4c8167092.1601629017.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Move the code into 'qemuMigrationCookieNBDXMLFormat' and use modern XML formatting code patterns. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_migration_cookie.c | 41 +++++++++++++++++--------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_coo= kie.c index a888c0074c..b7d8ba58bf 100644 --- a/src/qemu/qemu_migration_cookie.c +++ b/src/qemu/qemu_migration_cookie.c @@ -758,6 +758,26 @@ qemuMigrationCookieCapsXMLFormat(virBufferPtr buf, } +static void +qemuMigrationCookieNBDXMLFormat(qemuMigrationCookieNBDPtr nbd, + virBufferPtr buf) +{ + g_auto(virBuffer) attrBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) childBuf =3D VIR_BUFFER_INIT_CHILD(buf); + size_t i; + + if (nbd->port) + virBufferAsprintf(buf, " port=3D'%d'", nbd->port); + + for (i =3D 0; i < nbd->ndisks; i++) { + virBufferEscapeString(&childBuf, "disks= [i].target); + virBufferAsprintf(&childBuf, " capacity=3D'%llu'/>\n", nbd->disks[= i].capacity); + } + + virXMLFormatElement(buf, "nbd", &attrBuf, &childBuf); +} + + static int qemuMigrationCookieXMLFormat(virQEMUDriverPtr driver, virQEMUCapsPtr qemuCaps, @@ -814,25 +834,8 @@ qemuMigrationCookieXMLFormat(virQEMUDriverPtr driver, if ((mig->flags & QEMU_MIGRATION_COOKIE_NETWORK) && mig->network) qemuMigrationCookieNetworkXMLFormat(buf, mig->network); - if ((mig->flags & QEMU_MIGRATION_COOKIE_NBD) && mig->nbd) { - virBufferAddLit(buf, "nbd->port) - virBufferAsprintf(buf, " port=3D'%d'", mig->nbd->port); - if (mig->nbd->ndisks) { - virBufferAddLit(buf, ">\n"); - virBufferAdjustIndent(buf, 2); - for (i =3D 0; i < mig->nbd->ndisks; i++) { - virBufferEscapeString(buf, "nbd->disks[i].target); - virBufferAsprintf(buf, " capacity=3D'%llu'/>\n", - mig->nbd->disks[i].capacity); - } - virBufferAdjustIndent(buf, -2); - virBufferAddLit(buf, "\n"); - } else { - virBufferAddLit(buf, "/>\n"); - } - } + if ((mig->flags & QEMU_MIGRATION_COOKIE_NBD) && mig->nbd) + qemuMigrationCookieNBDXMLFormat(mig->nbd, buf); if (mig->flags & QEMU_MIGRATION_COOKIE_STATS && mig->jobInfo) qemuMigrationCookieStatisticsXMLFormat(buf, mig->jobInfo); --=20 2.26.2 From nobody Mon Apr 29 16:36:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1601629212; cv=none; d=zohomail.com; s=zohoarc; b=LhOgPSO44fR1yWdHOIdvUYLFk2fcDGkWaCH/l1frAW/Sf3V1KuW7IhE2Pj2GKTK4ZoE2xX01pSnDkUaZm/JMGsh/b7oVx72DZFUobw476VmssiA2nZe/666cdYuaFJGGZDDOiWIM3ddp87ccr9tPg4ZOYSH1cV2zgP7472cx17Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601629212; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=+mq3PELwOfs66trBj2ev9WTNpu6gybgyrrMdCSSMXWw=; b=hA6divgpQJarx1umBc0rKAGzKjtpFadX35K4+ljOa7skdRrOW4u6K91qtZ/4IkC9mxXMU+HdLTXthYliCvSXAVgqYeFowMTVsFh84jVdj0aPQticTu5Ax10dxhA858E+9NVFKWf6iJjPu+ecD4j6hcZWGFFZnKFdo+dvvVRkzDA= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1601629212747833.7565434257251; Fri, 2 Oct 2020 02:00:12 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-89-GXbqMeyoN7Gxk7aKYUueGA-1; Fri, 02 Oct 2020 04:59:29 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id BF382100A44C; Fri, 2 Oct 2020 08:58:50 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 942747512C; Fri, 2 Oct 2020 08:58:50 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 57B8818095FF; Fri, 2 Oct 2020 08:58:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0928wgdg015136 for ; Fri, 2 Oct 2020 04:58:42 -0400 Received: by smtp.corp.redhat.com (Postfix) id AC5777882A; Fri, 2 Oct 2020 08:58:42 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 067467881E for ; Fri, 2 Oct 2020 08:58:41 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601629211; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=+mq3PELwOfs66trBj2ev9WTNpu6gybgyrrMdCSSMXWw=; b=QtvNMOKrh1rIuANJhPrvGi1r/9hJNEKF6vH+A2W9SYLdQPoOSyfBRwMz3+cFeYj7RfDPQf UqH85lEzsU4HGHw4d3xOY74ZrXojM/yq8bHYcNXdwbtFiOnuO4ZshQkwn4TeWsro55NHG6 pveVrkhHPL9ONLYX4LEkHDSizAK4MkE= X-MC-Unique: GXbqMeyoN7Gxk7aKYUueGA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 10/20] qemuDomainExtractTLSSubject: Refactor memory handling Date: Fri, 2 Oct 2020 10:57:44 +0200 Message-Id: <6e8526781642eb0c4bd39a8c7c8c0bca44538df7.1601629017.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Switch to automatic memory cleaning, use g_new0 for allocation and get rid of the 'error' label. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_migration_cookie.c | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_coo= kie.c index b7d8ba58bf..006869a618 100644 --- a/src/qemu/qemu_migration_cookie.c +++ b/src/qemu/qemu_migration_cookie.c @@ -133,9 +133,9 @@ qemuMigrationCookieFree(qemuMigrationCookiePtr mig) static char * qemuDomainExtractTLSSubject(const char *certdir) { - char *certfile =3D NULL; + g_autofree char *certfile =3D NULL; char *subject =3D NULL; - char *pemdata =3D NULL; + g_autofree char *pemdata =3D NULL; gnutls_datum_t pemdatum; gnutls_x509_crt_t cert; int ret; @@ -146,7 +146,7 @@ qemuDomainExtractTLSSubject(const char *certdir) if (virFileReadAll(certfile, 8192, &pemdata) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("unable to read server cert %s"), certfile); - goto error; + return NULL; } ret =3D gnutls_x509_crt_init(&cert); @@ -154,7 +154,7 @@ qemuDomainExtractTLSSubject(const char *certdir) virReportError(VIR_ERR_INTERNAL_ERROR, _("cannot initialize cert object: %s"), gnutls_strerror(ret)); - goto error; + return NULL; } pemdatum.data =3D (unsigned char *)pemdata; @@ -165,25 +165,16 @@ qemuDomainExtractTLSSubject(const char *certdir) virReportError(VIR_ERR_INTERNAL_ERROR, _("cannot load cert data from %s: %s"), certfile, gnutls_strerror(ret)); - goto error; + return NULL; } subjectlen =3D 1024; - if (VIR_ALLOC_N(subject, subjectlen+1) < 0) - goto error; + subject =3D g_new0(char, subjectlen + 1); gnutls_x509_crt_get_dn(cert, subject, &subjectlen); subject[subjectlen] =3D '\0'; - VIR_FREE(certfile); - VIR_FREE(pemdata); - return subject; - - error: - VIR_FREE(certfile); - VIR_FREE(pemdata); - return NULL; } --=20 2.26.2 From nobody Mon Apr 29 16:36:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1601629172; cv=none; d=zohomail.com; s=zohoarc; b=nSFvtZVZksi6tUy6iHJ0GM3hqG4ow8RR+djZ5z7d3mjztbtGr53d3s/iHrjuL08JMHmB7KxHWIceMtGqaIthSOkbmch6pn1DFWNeNGil5OblGOosZ1JNEuEtESzHZPA8VVEwwXl2V4tRbHyWwPomkWNevQtZsPdQHV8tf8964CQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601629172; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=MbtskZQ4OaepdPBqfQepf9qunMRSQ5e9whUqqqLShD4=; b=bKUuavJkWOko3YQaCS35uB78PD7Q0r62s7H45KGdiusKmTzaXxb/fRmc0CH+xNsVRKRTVfjbOjbrGkjBV1J8I0eXdBPxNJ0vIQf9EOr0Mb+OL2oAVGOCexPIUw4J+5y8QI0BD03wM+gK/OvSxLyJTeOcurNmyiYNi3HjRrK3Tfo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1601629172375139.3058067119025; Fri, 2 Oct 2020 01:59:32 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-410-tRY0h7K1OSSpUSoucIPfMw-1; Fri, 02 Oct 2020 04:59:29 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5B70A1017DC0; Fri, 2 Oct 2020 08:58:53 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 371661002382; Fri, 2 Oct 2020 08:58:53 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 02F7A181A06D; Fri, 2 Oct 2020 08:58:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0928whjt015146 for ; Fri, 2 Oct 2020 04:58:43 -0400 Received: by smtp.corp.redhat.com (Postfix) id C70987881E; Fri, 2 Oct 2020 08:58:43 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2F56078830 for ; Fri, 2 Oct 2020 08:58:42 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601629171; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=MbtskZQ4OaepdPBqfQepf9qunMRSQ5e9whUqqqLShD4=; b=ZyfqmtvEzpaOkqyaVb8V4ik+hWz2Mzaj64YugRefKeL+m1DalmbZqcN/0BG208WCMruktb ljMZUXnh0bv5SvzLR0QINjF4KUdv5M/z4nbE3tg+qY9ZrECMC9kJrCxhg+5XyNOKIRc+S7 yw+lVDgwXNnjYWg8PAO9DVj0eZDZvFA= X-MC-Unique: tRY0h7K1OSSpUSoucIPfMw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 11/20] qemu: migration_cookie: Register 'autoptr' functions for internal types Date: Fri, 2 Oct 2020 10:57:45 +0200 Message-Id: <5a63952d1d48c0095d60a379d3c4a200d3f65dc5.1601629017.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Register the the cleanup functions for 'qemuMigrationCookieGraphics', 'qemuMigrationCookieNetwork', 'qemuMigrationCookieNBD', and 'qemuMigrationCookieCaps'. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_migration_cookie.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_coo= kie.c index 006869a618..b71ff7bf9d 100644 --- a/src/qemu/qemu_migration_cookie.c +++ b/src/qemu/qemu_migration_cookie.c @@ -64,6 +64,9 @@ qemuMigrationCookieGraphicsFree(qemuMigrationCookieGraphi= csPtr grap) VIR_FREE(grap); } +G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuMigrationCookieGraphics, + qemuMigrationCookieGraphicsFree); + static void qemuMigrationCookieNetworkFree(qemuMigrationCookieNetworkPtr network) @@ -81,6 +84,8 @@ qemuMigrationCookieNetworkFree(qemuMigrationCookieNetwork= Ptr network) VIR_FREE(network); } +G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuMigrationCookieNetwork, + qemuMigrationCookieNetworkFree); static void qemuMigrationCookieNBDFree(qemuMigrationCookieNBDPtr nbd) @@ -94,6 +99,8 @@ qemuMigrationCookieNBDFree(qemuMigrationCookieNBDPtr nbd) VIR_FREE(nbd); } +G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuMigrationCookieNBD, + qemuMigrationCookieNBDFree); static void qemuMigrationCookieCapsFree(qemuMigrationCookieCapsPtr caps) @@ -106,6 +113,8 @@ qemuMigrationCookieCapsFree(qemuMigrationCookieCapsPtr = caps) VIR_FREE(caps); } +G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuMigrationCookieCaps, + qemuMigrationCookieCapsFree); void qemuMigrationCookieFree(qemuMigrationCookiePtr mig) --=20 2.26.2 From nobody Mon Apr 29 16:36:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1601629161; cv=none; d=zohomail.com; s=zohoarc; b=NfvDwJPOMDDojqy+Eg3emeVoyVBjg4oX+0cbq3nlSGcWBuY6iJexuXTpeCQi/jVcXmT5vkfuCFVQ5Q3LmKzUH+AAZkb5WC666INsIvEL1HX0xeTtUvdi+zKNu/4vnZJ6yrYQq2pZucdTYR9wWnvchKbIfKg/aPF2cPvkJizRdGY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601629161; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Pn14cAmdYcZxv4n0j7CNXEClOSeX3aZ2LgjgSU0sDX4=; b=KBn3hSPpP4qlYUX8XLmQr6+/fsqsI60wGR777ZfVBM8iSXn7s1PLNvTTpZmV4FDXw28yxRXjIGi4aKW3Woy+zkS0RnhnNV4jav758mou86vzLyL9zxvk7H2Oux1lbpLCWgw6BW+k5lbuAQB8EVtx5zhdkB2k7WYU2ERj3Yhh5iE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1601629161864250.77901026140978; Fri, 2 Oct 2020 01:59:21 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-364-BHpfKMpIPtKgIF37hMIkTw-1; Fri, 02 Oct 2020 04:59:18 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 8229DA4C6A; Fri, 2 Oct 2020 08:58:47 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 310EB75124; Fri, 2 Oct 2020 08:58:47 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id E979844A4C; Fri, 2 Oct 2020 08:58:46 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0928wi5q015158 for ; Fri, 2 Oct 2020 04:58:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id E744578839; Fri, 2 Oct 2020 08:58:44 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 356297881E for ; Fri, 2 Oct 2020 08:58:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601629160; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Pn14cAmdYcZxv4n0j7CNXEClOSeX3aZ2LgjgSU0sDX4=; b=MXj4udh+oEzywP+/8oc/nT29p19zvSq9qzgPQKwYUEDOT9SG1qfx8GblLUz0YYIRT3MWal vorJGMM7XoCxtP6Sg1X++0s7Cu/Kl8fCMQRO3gpdIowzvyyWITpl1ph5M8NGNiygCFNKuz bQZcNFibN1Lsda7dGpjZC0fVHlPW5l8= X-MC-Unique: BHpfKMpIPtKgIF37hMIkTw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 12/20] qemuMigrationCookieGraphicsSpiceAlloc: Refactor memory handling Date: Fri, 2 Oct 2020 10:57:46 +0200 Message-Id: <2f76b8a5cfc864029a7b3045301b68ad6c0bfa61.1601629017.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Use modern memory handling approach to simplify the code. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_migration_cookie.c | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_coo= kie.c index b71ff7bf9d..f63e3d7e12 100644 --- a/src/qemu/qemu_migration_cookie.c +++ b/src/qemu/qemu_migration_cookie.c @@ -192,13 +192,10 @@ qemuMigrationCookieGraphicsSpiceAlloc(virQEMUDriverPt= r driver, virDomainGraphicsDefPtr def, virDomainGraphicsListenDefPtr gliste= n) { - qemuMigrationCookieGraphicsPtr mig =3D NULL; + g_autoptr(qemuMigrationCookieGraphics) mig =3D g_new0(qemuMigrationCoo= kieGraphics, 1); const char *listenAddr; g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); - if (VIR_ALLOC(mig) < 0) - goto error; - mig->type =3D VIR_DOMAIN_GRAPHICS_TYPE_SPICE; mig->port =3D def->data.spice.port; if (cfg->spiceTLS) @@ -211,15 +208,11 @@ qemuMigrationCookieGraphicsSpiceAlloc(virQEMUDriverPt= r driver, if (cfg->spiceTLS && !(mig->tlsSubject =3D qemuDomainExtractTLSSubject(cfg->spiceTLSx50= 9certdir))) - goto error; + return NULL; mig->listen =3D g_strdup(listenAddr); - return mig; - - error: - qemuMigrationCookieGraphicsFree(mig); - return NULL; + return g_steal_pointer(&mig); } --=20 2.26.2 From nobody Mon Apr 29 16:36:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1601629175; cv=none; d=zohomail.com; s=zohoarc; b=cd9r5pxbW9fWNtYnAK5kBACtX5nlM5ltsb+qmx11Au4Hb+azyA1Cdqp+8+E8fhkcn1h9vMGYU2qEvzO4Clpx8ZdDX8IsH8YDo8bRa0qzJ+ezwVh7aKusF0eR/NpvteGiVczSBFNxF4DFoTuLsncGDMzwHovDA4P7eLrshCpoc9M= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601629175; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2Y3Dhr748IiA1+Wq/RYqNIhpV71RM/Dx99wtYlHPQPs=; b=H/LOBm+Bkz5HI6kd+BOvFR5exflPuCXikQUZGVGo4qLd/r7Qv1JRfIb9r2PPbuDnUD7MVbmxOvkN07aZ8uXBnbGnuDXezxBseqdvpg4sfZwvEeDN34Q48AofOGw3iyK1wQMj0IfKQezF8GkpmhpEwxK/X+CtsotCK31oDytLILo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1601629175800593.1543594998035; Fri, 2 Oct 2020 01:59:35 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-495-itcs8CKhNQ-l5XTrXH005A-1; Fri, 02 Oct 2020 04:59:32 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id DDD581074666; Fri, 2 Oct 2020 08:58:55 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BB7B055784; Fri, 2 Oct 2020 08:58:55 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 8A56E181A06C; Fri, 2 Oct 2020 08:58:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0928wjse015168 for ; Fri, 2 Oct 2020 04:58:46 -0400 Received: by smtp.corp.redhat.com (Postfix) id EF71778820; Fri, 2 Oct 2020 08:58:45 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 587C87881E for ; Fri, 2 Oct 2020 08:58:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601629174; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=2Y3Dhr748IiA1+Wq/RYqNIhpV71RM/Dx99wtYlHPQPs=; b=OwTfdaGpr4pVjjqMOzjL83VMXsLV2Szy29YvUHEhXV5w3BfwL11FT55OfqI5bKOTPcGy/u HgWJ0L+ErEXeQERGgNXue86UtVgOW7hGikUriGAhWx6Xp5SfE+GsmXMCLJjtAyBvS52Eln gVtTaEBcEMAGIb5biY+FVrAyMOLZHB4= X-MC-Unique: itcs8CKhNQ-l5XTrXH005A-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 13/20] qemuMigrationCookieNetworkAlloc: Refactor memory handling Date: Fri, 2 Oct 2020 10:57:47 +0200 Message-Id: <6801f5f846eac212e3c3a099bec8257b4f3f24a1.1601629017.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Use modern memory handling approach to simplify the code. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_migration_cookie.c | 17 ++++------------- 1 file changed, 4 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_coo= kie.c index f63e3d7e12..7a1d115ae5 100644 --- a/src/qemu/qemu_migration_cookie.c +++ b/src/qemu/qemu_migration_cookie.c @@ -220,16 +220,11 @@ static qemuMigrationCookieNetworkPtr qemuMigrationCookieNetworkAlloc(virQEMUDriverPtr driver G_GNUC_UNUSED, virDomainDefPtr def) { - qemuMigrationCookieNetworkPtr mig; + g_autoptr(qemuMigrationCookieNetwork) mig =3D g_new0(qemuMigrationCook= ieNetwork, 1); size_t i; - if (VIR_ALLOC(mig) < 0) - goto error; - mig->nnets =3D def->nnets; - - if (VIR_ALLOC_N(mig->net, def->nnets) <0) - goto error; + mig->net =3D g_new0(qemuMigrationCookieNetData, def->nnets); for (i =3D 0; i < def->nnets; i++) { virDomainNetDefPtr netptr; @@ -252,7 +247,7 @@ qemuMigrationCookieNetworkAlloc(virQEMUDriverPtr driver= G_GNUC_UNUSED, virReportError(VIR_ERR_INTERNAL_ERROR, _("Unable to run command to get OVS= port data for " "interface %s"), netptr->ifname); - goto error; + return NULL; } break; default: @@ -260,11 +255,7 @@ qemuMigrationCookieNetworkAlloc(virQEMUDriverPtr drive= r G_GNUC_UNUSED, } } } - return mig; - - error: - qemuMigrationCookieNetworkFree(mig); - return NULL; + return g_steal_pointer(&mig); } --=20 2.26.2 From nobody Mon Apr 29 16:36:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1601629174; cv=none; d=zohomail.com; s=zohoarc; b=iAPuOswoXZdl83KVc8b1IBK2bFlpKikJONH4mJu84b/4WvUJDCIGSEJdfZT5Xtc1ObU21+SrWGXMrlg4AXN89B63UBNZM08/LB0SChlZnsPGuYtRjP5n7Npj1cTvK2OFuvj/HZh3vB68vIHRWGHBb9Ak5KiJfpoFCAhCiqnd8vM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601629174; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=eFlBzhCflnZacB4Kar88OXS6dBYRSpQZ4w5XQwhu4Ss=; b=gcky/EGYPfhq/zVJFQFEW75s1wwnKDfNSKAAOvoLhIYSojvjKgHuslSxXzNmM+waWMvu3JGn++J0CEuJ97BMO5Mdb8A6lcEccfZk6xpuMReIgqZWBExlUW0nSJGWYrWhEW/HaJWRTjY4XRv3W0leECk/VottiAVPWnNB8kBbtxI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1601629174763286.8986388648883; Fri, 2 Oct 2020 01:59:34 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-170-gyiBHiD1O0yuSxoCMjPt3A-1; Fri, 02 Oct 2020 04:59:31 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 918291084CA7; Fri, 2 Oct 2020 08:58:58 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6F2F910013BD; Fri, 2 Oct 2020 08:58:58 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 3F89244A4C; Fri, 2 Oct 2020 08:58:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0928wl3Y015175 for ; Fri, 2 Oct 2020 04:58:47 -0400 Received: by smtp.corp.redhat.com (Postfix) id 2497278830; Fri, 2 Oct 2020 08:58:47 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7AECE7881E for ; Fri, 2 Oct 2020 08:58:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601629173; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=eFlBzhCflnZacB4Kar88OXS6dBYRSpQZ4w5XQwhu4Ss=; b=AfT2Wj72J7sTUvS/3F23vVpHVbL00CbR3k8h43Pu2djDAEt/d+Ni8aVQoYdER7YqJDUvhX EXTJG/ZuNucnRwLnXvZScD14dS58qU7lCtHSY6F5IOia1SjvR/1LZecz8/cBDUuMRykX8i hYytR973J6f/TrMFDoIIVKiXPFjxN0c= X-MC-Unique: gyiBHiD1O0yuSxoCMjPt3A-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 14/20] qemuMigrationCookieXMLFormat: Refactor memory handling Date: Fri, 2 Oct 2020 10:57:48 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Use automatic memory freeing to get rid of the 'error' label. Since the 'tmp' variable was used only in one instance, rename it appropriately. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_migration_cookie.c | 31 +++++++++++-------------------- 1 file changed, 11 insertions(+), 20 deletions(-) diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_coo= kie.c index 7a1d115ae5..8b5491e388 100644 --- a/src/qemu/qemu_migration_cookie.c +++ b/src/qemu/qemu_migration_cookie.c @@ -842,49 +842,40 @@ qemuMigrationCookieXMLFormat(virQEMUDriverPtr driver, static qemuMigrationCookieGraphicsPtr qemuMigrationCookieGraphicsXMLParse(xmlXPathContextPtr ctxt) { - qemuMigrationCookieGraphicsPtr grap; - char *tmp; + g_autoptr(qemuMigrationCookieGraphics) grap =3D g_new0(qemuMigrationCo= okieGraphics, 1); + g_autofree char *graphicstype =3D NULL; - if (VIR_ALLOC(grap) < 0) - goto error; - - if (!(tmp =3D virXPathString("string(./graphics/@type)", ctxt))) { + if (!(graphicstype =3D virXPathString("string(./graphics/@type)", ctxt= ))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing type attribute in migration data")= ); - goto error; + return NULL; } - if ((grap->type =3D virDomainGraphicsTypeFromString(tmp)) < 0) { + if ((grap->type =3D virDomainGraphicsTypeFromString(graphicstype)) < 0= ) { virReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown graphics type %s"), tmp); - VIR_FREE(tmp); - goto error; + _("unknown graphics type %s"), graphicstype); + return NULL; } - VIR_FREE(tmp); if (virXPathInt("string(./graphics/@port)", ctxt, &grap->port) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing port attribute in migration data")= ); - goto error; + return NULL; } if (grap->type =3D=3D VIR_DOMAIN_GRAPHICS_TYPE_SPICE) { if (virXPathInt("string(./graphics/@tlsPort)", ctxt, &grap->tlsPor= t) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing tlsPort attribute in migration= data")); - goto error; + return NULL; } } if (!(grap->listen =3D virXPathString("string(./graphics/@listen)", ct= xt))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing listen attribute in migration data= ")); - goto error; + return NULL; } /* Optional */ grap->tlsSubject =3D virXPathString("string(./graphics/cert[@info=3D's= ubject']/@value)", ctxt); - return grap; - - error: - qemuMigrationCookieGraphicsFree(grap); - return NULL; + return g_steal_pointer(&grap); } --=20 2.26.2 From nobody Mon Apr 29 16:36:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1601629525; cv=none; d=zohomail.com; s=zohoarc; b=eqanPWixR4tmT659VLaI/tUCpmJBKr2XTrsEv9DaW/Ev4eLoX1Pw79EgAHoU8PtF3Ja3f7f2pA2t4fhvyykeJlpCKZqOen3O/Y8SgecGy/wNPkC9BUfnns6oyHbTdUvBwdFN+7J7hA2c+/XrQ7zV7dmjVL52LBFWwtvkG0XwGHc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601629525; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=3GXOwtBrQGDk4WpqqnABUiGIr0p65JiAbQfOSX4pmno=; b=bBfkmyKJ8S9YmlKFAGXO4DZ0IO+TBrFvxCftFESosgLkDR7Vlg7vsU0GCNPRi9JHw7Llk4yINLjJk6T/4oLZj2SiWbighnnXkrNkOj1t7rdOJGMHMKw26MdUdqyTYyRNdOa5l2aUrbyhKtRQu//N/U56v6+sssplW4VICpC0TbU= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1601629525594619.1048737037768; Fri, 2 Oct 2020 02:05:25 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-27-gjSM5Fw9OQWjgdPbKwS8Xw-1; Fri, 02 Oct 2020 05:05:22 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 11A8C80EDA3; Fri, 2 Oct 2020 09:05:16 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id D841119931; Fri, 2 Oct 2020 09:05:15 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 9D77144A4C; Fri, 2 Oct 2020 09:05:15 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0928wmPR015190 for ; Fri, 2 Oct 2020 04:58:48 -0400 Received: by smtp.corp.redhat.com (Postfix) id 4D6FA7881E; Fri, 2 Oct 2020 08:58:48 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9CC697998A for ; Fri, 2 Oct 2020 08:58:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601629524; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=3GXOwtBrQGDk4WpqqnABUiGIr0p65JiAbQfOSX4pmno=; b=eqZUNggjV6uqBbflVSdv/fxNPDm6h75nkNENwneWRZT+McH9/nmxdHR9wD5F45VHOeJI9m sqNeznFlF0EpRyNLw5BHfF8AjNkjzVoBc/ROHPvagE7Iy7G1g/xvVk7pCsg+grMXPwEUP7 4LXJQUxmbmRj3b6/MrWY+V/CGYYr7UQ= X-MC-Unique: gjSM5Fw9OQWjgdPbKwS8Xw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 15/20] qemuMigrationCookieNetworkXMLParse: Refactor memory handling Date: Fri, 2 Oct 2020 10:57:49 +0200 Message-Id: <02d020d6bda8220e7a8f3b3928ef8b3f54028ff6.1601629017.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Use modern allocators, automatic memory feeing, and decrease the scope of some variables to remove the 'error' label. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_migration_cookie.c | 27 ++++++++------------------- 1 file changed, 8 insertions(+), 19 deletions(-) diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_coo= kie.c index 8b5491e388..c2ae3ab6a7 100644 --- a/src/qemu/qemu_migration_cookie.c +++ b/src/qemu/qemu_migration_cookie.c @@ -882,27 +882,24 @@ qemuMigrationCookieGraphicsXMLParse(xmlXPathContextPt= r ctxt) static qemuMigrationCookieNetworkPtr qemuMigrationCookieNetworkXMLParse(xmlXPathContextPtr ctxt) { - qemuMigrationCookieNetworkPtr optr; + g_autoptr(qemuMigrationCookieNetwork) optr =3D g_new0(qemuMigrationCoo= kieNetwork, 1); size_t i; int n; - xmlNodePtr *interfaces =3D NULL; - char *vporttype; + g_autofree xmlNodePtr *interfaces =3D NULL; VIR_XPATH_NODE_AUTORESTORE(ctxt) - if (VIR_ALLOC(optr) < 0) - goto error; - if ((n =3D virXPathNodeSet("./network/interface", ctxt, &interfaces)) = < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing interface information")); - goto error; + return NULL; } optr->nnets =3D n; - if (VIR_ALLOC_N(optr->net, optr->nnets) < 0) - goto error; + optr->net =3D g_new0(qemuMigrationCookieNetData, optr->nnets); for (i =3D 0; i < n; i++) { + g_autofree char *vporttype =3D NULL; + /* portdata is optional, and may not exist */ ctxt->node =3D interfaces[i]; optr->net[i].portdata =3D virXPathString("string(./portdata[1])", = ctxt); @@ -910,20 +907,12 @@ qemuMigrationCookieNetworkXMLParse(xmlXPathContextPtr= ctxt) if (!(vporttype =3D virXMLPropString(interfaces[i], "vporttype")))= { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing vporttype attribute in migrati= on data")); - goto error; + return NULL; } optr->net[i].vporttype =3D virNetDevVPortTypeFromString(vporttype); - VIR_FREE(vporttype); } - VIR_FREE(interfaces); - - return optr; - - error: - VIR_FREE(interfaces); - qemuMigrationCookieNetworkFree(optr); - return NULL; + return g_steal_pointer(&optr); } --=20 2.26.2 From nobody Mon Apr 29 16:36:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1601629165; cv=none; d=zohomail.com; s=zohoarc; b=EyF5RnCr3oAjlYNuhcpsmeIkSTo6Pyhvy0Q4nsRNbD1dgLhVEn11fRaP8TC9RWg3zGXbHP4fFFeJOIfFKS1ni7KssnsIrQ2zoSdbneSkaNCMYavYX0TVevMFtPjI0XEBFl43AUQILCrI21P4vOhQsrGUthLbhuLWxz4OQFH5EGk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601629165; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=BAaVwvzAVWuVltmgv9vWvMGffRRDghuWxP/Cs/Pm8Dw=; b=ONd82j/zPNvsTsG2AWuj8rpa7Jr4EJG7tHC+Le8ITevKDoBNh86Pskg3lUwvZ/rtZuvxHRayRi7/uufHo+aTJUZu7vapxrZEyUV9thnJ3M2h2WHKfjNvTNORmnxVd4ZQR07q3Cl7+8yNKfD96UL+DNAfy/20Aec/0HCQvm7DtQs= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1601629165714298.2344145401149; Fri, 2 Oct 2020 01:59:25 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-571-l04VZ3AlNUuCXk9o4Mvn8Q-1; Fri, 02 Oct 2020 04:59:22 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5E3B9884DFF; Fri, 2 Oct 2020 08:58:52 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 232B45578D; Fri, 2 Oct 2020 08:58:52 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id DF0AE44A4C; Fri, 2 Oct 2020 08:58:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0928wnjq015201 for ; Fri, 2 Oct 2020 04:58:49 -0400 Received: by smtp.corp.redhat.com (Postfix) id 6151978820; Fri, 2 Oct 2020 08:58:49 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id C3AF07881E for ; Fri, 2 Oct 2020 08:58:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601629164; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=BAaVwvzAVWuVltmgv9vWvMGffRRDghuWxP/Cs/Pm8Dw=; b=HwCoXmSlpzl8mqKvwYVeZsgsfG0k0xntS9Jl3sIPmUcalgvnYllSkOodmaetPZxFsJ2o7f E3cXVMYqOAkdtl05ZE2v6tBGsiOpjfj4aGiHsQ7Yt3q2PYuTU684B5TeVKv0Q12YoYnExA 6Xp6YaValoqCcnP4w9W2lON4em6+Ys8= X-MC-Unique: l04VZ3AlNUuCXk9o4Mvn8Q-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 16/20] qemuMigrationCookieNBDXMLParse: Refactor memory handling Date: Fri, 2 Oct 2020 10:57:50 +0200 Message-Id: <2e38283567132c4c2329db6f31f3a99086760dbf.1601629017.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Use modern allocators, automatic memory feeing, and decrease the scope of some variables to remove the 'error' and 'cleanup' labels. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_migration_cookie.c | 31 ++++++++++--------------------- 1 file changed, 10 insertions(+), 21 deletions(-) diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_coo= kie.c index c2ae3ab6a7..1e0a1c3d7f 100644 --- a/src/qemu/qemu_migration_cookie.c +++ b/src/qemu/qemu_migration_cookie.c @@ -919,40 +919,37 @@ qemuMigrationCookieNetworkXMLParse(xmlXPathContextPtr= ctxt) static qemuMigrationCookieNBDPtr qemuMigrationCookieNBDXMLParse(xmlXPathContextPtr ctxt) { - qemuMigrationCookieNBDPtr ret =3D NULL; - char *port =3D NULL, *capacity =3D NULL; + g_autoptr(qemuMigrationCookieNBD) ret =3D g_new0(qemuMigrationCookieNB= D, 1); + g_autofree char *port =3D NULL; size_t i; int n; - xmlNodePtr *disks =3D NULL; + g_autofree xmlNodePtr *disks =3D NULL; VIR_XPATH_NODE_AUTORESTORE(ctxt) - if (VIR_ALLOC(ret) < 0) - goto error; - port =3D virXPathString("string(./nbd/@port)", ctxt); if (port && virStrToLong_i(port, NULL, 10, &ret->port) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("Malformed nbd port '%s'"), port); - goto error; + return NULL; } /* Now check if source sent a list of disks to prealloc. We might be * talking to an older server, so it's not an error if the list is * missing. */ if ((n =3D virXPathNodeSet("./nbd/disk", ctxt, &disks)) > 0) { - if (VIR_ALLOC_N(ret->disks, n) < 0) - goto error; + ret->disks =3D g_new0(struct qemuMigrationCookieNBDDisk, n); ret->ndisks =3D n; for (i =3D 0; i < n; i++) { + g_autofree char *capacity =3D NULL; + ctxt->node =3D disks[i]; - VIR_FREE(capacity); if (!(ret->disks[i].target =3D virXPathString("string(./@targe= t)", ctxt))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Malformed disk target")); - goto error; + return NULL; } capacity =3D virXPathString("string(./@capacity)", ctxt); @@ -962,20 +959,12 @@ qemuMigrationCookieNBDXMLParse(xmlXPathContextPtr ctx= t) virReportError(VIR_ERR_INTERNAL_ERROR, _("Malformed disk capacity: '%s'"), NULLSTR(capacity)); - goto error; + return NULL; } } } - cleanup: - VIR_FREE(port); - VIR_FREE(capacity); - VIR_FREE(disks); - return ret; - error: - qemuMigrationCookieNBDFree(ret); - ret =3D NULL; - goto cleanup; + return g_steal_pointer(&ret); } --=20 2.26.2 From nobody Mon Apr 29 16:36:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1601629170; cv=none; d=zohomail.com; s=zohoarc; b=iL5R8bG70l8FfKK8Gpu3VQUTET4YdBiS1MW+EAtC/2BLgNsm5wW0JRKx8zcStaSYV1Xpsva+8h7w5oPH8MyxYmWmtWv9iXO0h2r0E3L+FnsM4hHHPD/n5FTpqR3x+kbI+9jCSZwl2tfO3YnYTkbgc8PvI4fBwCKTpCQ/m88wPOE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601629170; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=Y3j0KXxf8npXcpsg/bsa6X6+s/58IjOkP4DFExnDuDQ=; b=VNi/r0LZMw/LDAq9ipWc1N3mD6i9rlpZKeUDluegoDh5xTl459rvNgEHZzYDetSgnsLGR/0gTJRT6pvUUZk2+BRnKeJnZ13adDC7pqYh65sWut9xtVs5LWO8e8+J80tnHys8cl4rMfhvR8dahMb5E4C1yUBL6VRDVrZQeGgRSD0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1601629170257421.01251347687014; Fri, 2 Oct 2020 01:59:30 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-594-A34UNRo9Mpae59rDMZJmiw-1; Fri, 02 Oct 2020 04:59:25 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E5D8519611A1; Fri, 2 Oct 2020 08:58:51 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C67385D9D3; Fri, 2 Oct 2020 08:58:51 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 91B9B181A06B; Fri, 2 Oct 2020 08:58:51 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0928woDk015206 for ; Fri, 2 Oct 2020 04:58:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id 825D878820; Fri, 2 Oct 2020 08:58:50 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id DB5B87881E for ; Fri, 2 Oct 2020 08:58:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601629166; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=Y3j0KXxf8npXcpsg/bsa6X6+s/58IjOkP4DFExnDuDQ=; b=ik4tNEAgfLc+o12TVu0HLEgQhdNforSMKzlVxY3/HX5d5Cyi+4ZsO6zQLKUPup3MjYcTHM GPoVC3Ig/P6j+Xj9GCRKixgTivpSmCTA//Wgw3hSv7HqUYIERLgJQRwZBFyoEHlSyvXtRJ 68ubLz+sMPU0wsVjkNoGJ6kpNFsXKvo= X-MC-Unique: A34UNRo9Mpae59rDMZJmiw-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 17/20] qemuMigrationCookieCapsXMLParse: Refactor memory handling Date: Fri, 2 Oct 2020 10:57:51 +0200 Message-Id: <3ba3c981b44354891a956e56de514303187d4a07.1601629017.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Use modern allocators, automatic memory feeing, and decrease the scope of some variables to remove the 'cleanup' label. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_migration_cookie.c | 31 +++++++++---------------------- 1 file changed, 9 insertions(+), 22 deletions(-) diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_coo= kie.c index 1e0a1c3d7f..a1ef3d2b12 100644 --- a/src/qemu/qemu_migration_cookie.c +++ b/src/qemu/qemu_migration_cookie.c @@ -1057,29 +1057,26 @@ qemuMigrationCookieStatisticsXMLParse(xmlXPathConte= xtPtr ctxt) static qemuMigrationCookieCapsPtr qemuMigrationCookieCapsXMLParse(xmlXPathContextPtr ctxt) { - qemuMigrationCookieCapsPtr caps =3D NULL; - xmlNodePtr *nodes =3D NULL; - qemuMigrationCookieCapsPtr ret =3D NULL; - char *name =3D NULL; - char *automatic =3D NULL; - int cap; + g_autoptr(qemuMigrationCookieCaps) caps =3D g_new0(qemuMigrationCookie= Caps, 1); + g_autofree xmlNodePtr *nodes =3D NULL; size_t i; int n; - if (VIR_ALLOC(caps) < 0) - return NULL; - caps->supported =3D virBitmapNew(QEMU_MIGRATION_CAP_LAST); caps->automatic =3D virBitmapNew(QEMU_MIGRATION_CAP_LAST); if ((n =3D virXPathNodeSet("./capabilities[1]/cap", ctxt, &nodes)) < 0) - goto cleanup; + return NULL; for (i =3D 0; i < n; i++) { + g_autofree char *name =3D NULL; + g_autofree char *automatic =3D NULL; + int cap; + if (!(name =3D virXMLPropString(nodes[i], "name"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing migration capability name")); - goto cleanup; + return NULL; } if ((cap =3D qemuMigrationCapabilityTypeFromString(name)) < 0) @@ -1090,19 +1087,9 @@ qemuMigrationCookieCapsXMLParse(xmlXPathContextPtr c= txt) if ((automatic =3D virXMLPropString(nodes[i], "auto")) && STREQ(automatic, "yes")) ignore_value(virBitmapSetBit(caps->automatic, cap)); - - VIR_FREE(name); - VIR_FREE(automatic); } - ret =3D g_steal_pointer(&caps); - - cleanup: - qemuMigrationCookieCapsFree(caps); - VIR_FREE(nodes); - VIR_FREE(name); - VIR_FREE(automatic); - return ret; + return g_steal_pointer(&caps); } --=20 2.26.2 From nobody Mon Apr 29 16:36:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1601629724; cv=none; d=zohomail.com; s=zohoarc; b=AqOHKlzXY8AafYWPWpwW/Mh8P6vaPvfxadZmV/yCp5gwiT+pJ3JIyKX1L/DYOXVJzdcCobsxob/QGw0A9poEG46NbZ88cxtIJ98qeWqxhT1rheD/1jLxRYR9QGObr8cKs1FHTzYes+hijuEGWUcZ2Iu7/cAJeSiPHUfvfs092rQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601629724; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=nyBG2VXO1//iZrGj8o0/LtaKdYITCS9nEAl+BgRbX7g=; b=lO4MZPKIoOqkYfKdt6aQe/CxGevRbKzF7HdG22sGbLyca7jW8eWKlzMs+l8SDm63e86YthlZX+VWQQAqFec9RjM1XeGGqpGXNo0+IK6/S7PsLNR8EzsVKD0vx5nZs3rGsrgxzeSUu6uJRb6mQX9iMdyj9Ki2uw24jc3WL3dnZMo= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1601629724875148.09485686976302; Fri, 2 Oct 2020 02:08:44 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-594-jHF6JXM7OZ-Eaa6CSjaoxg-1; Fri, 02 Oct 2020 05:08:42 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B1481801AC2; Fri, 2 Oct 2020 09:08:36 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 6B8D073677; Fri, 2 Oct 2020 09:08:36 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 2E82E44A4C; Fri, 2 Oct 2020 09:08:35 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0928wpI2015214 for ; Fri, 2 Oct 2020 04:58:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9FF617881E; Fri, 2 Oct 2020 08:58:51 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 00EEF78830 for ; Fri, 2 Oct 2020 08:58:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601629723; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=nyBG2VXO1//iZrGj8o0/LtaKdYITCS9nEAl+BgRbX7g=; b=PT7Bhce4cBTCnETimA82w8AMIEcU/jfdjsSwloGpu8DHOqlEddB2HGbp7mg7ECZaoLppgo 3IjFkD+tI1o0LzXXMpZQxAI9ajxxTIASqTk/2VL79sYrCtqLFmyWPaTLy+DqAHiDTZ0y9i BYgY5OeqJaLvPodiFwovUiSxES+Aeh0= X-MC-Unique: jHF6JXM7OZ-Eaa6CSjaoxg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 18/20] qemuMigrationCookieAddCaps: Use 'g_new0' instead of VIR_ALLOC Date: Fri, 2 Oct 2020 10:57:52 +0200 Message-Id: <382f1c21d52655eb63196abbaca921b297238562.1601629017.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_migration_cookie.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_coo= kie.c index a1ef3d2b12..93d91b8a1c 100644 --- a/src/qemu/qemu_migration_cookie.c +++ b/src/qemu/qemu_migration_cookie.c @@ -542,8 +542,7 @@ qemuMigrationCookieAddCaps(qemuMigrationCookiePtr mig, qemuDomainObjPrivatePtr priv =3D vm->privateData; qemuMigrationCookieCapsFree(mig->caps); - if (VIR_ALLOC(mig->caps) < 0) - return -1; + mig->caps =3D g_new0(qemuMigrationCookieCaps, 1); if (priv->migrationCaps) mig->caps->supported =3D virBitmapNewCopy(priv->migrationCaps); --=20 2.26.2 From nobody Mon Apr 29 16:36:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1601629527; cv=none; d=zohomail.com; s=zohoarc; b=ihS2VoqQNhj5lMbZiB68+wfKLF+sZr+sAzBPfFsqcvIYamlTbH/QdtmYzo/yHXvLo62rseYs9o+CYY/APGfwBneXAj0mvJ3ginv7SJCU4SavpA30bsVK8wm6uWbBWTqUDpgDAErZzWtIKy9O9zxNbEywklg40QlEIwwaG0g9Opk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601629527; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=yFTh+5xUG+eq7LKy+/xUNMKai5O3CHxAwkSGffA9caU=; b=X4R/EbLTAPb1niZ29dq/3a3Fku6vZS+kNxFqqIBwOp7UTqxNKkWxRe5kolyNSz+A5s6GXdx+vPSZezsPUxl17eg4ZXMS11WT9wrCCAMJb7o3WYNHc8TJhZtOt3Kx93SfvfBfAqViR8XVLVw0vSARc8v9tQHZl28nELEC9IZtzy4= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1601629527422425.97728558317783; Fri, 2 Oct 2020 02:05:27 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-342-2Ql5ccjyMgOfXYRbsFfoKA-1; Fri, 02 Oct 2020 05:05:24 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E864F80EDA4; Fri, 2 Oct 2020 09:05:18 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C7C3D5C1D7; Fri, 2 Oct 2020 09:05:18 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 9518E44A5E; Fri, 2 Oct 2020 09:05:18 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0928wqXx015232 for ; Fri, 2 Oct 2020 04:58:52 -0400 Received: by smtp.corp.redhat.com (Postfix) id A959478820; Fri, 2 Oct 2020 08:58:52 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 13E327881E for ; Fri, 2 Oct 2020 08:58:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601629526; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=yFTh+5xUG+eq7LKy+/xUNMKai5O3CHxAwkSGffA9caU=; b=fZqaRKd0ualfW8GxsncT9mn1qhWDLiBHXU6+CjdD71xW3KSC9/Z0JlbRVc3zM/5YVOHQOm x07LulS3fbQtYYd1DZc+4IXefUpGQoq8KSHicIqk3rNrmMrTxVtFdjnOqeZf4UnenJeNd7 V9uMKaeTeer8UwWUrnaFcR1bBBLs1kA= X-MC-Unique: 2Ql5ccjyMgOfXYRbsFfoKA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 19/20] qemuMigrationCookieXMLParse: Avoid VIR_FREE when parsing lockstate Date: Fri, 2 Oct 2020 10:57:53 +0200 Message-Id: <1021846a6def5e78183c9664e28ef477caf5ea99.1601629017.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Restructure the control-flow a bit using an temporary variable to avoid the need to use VIR_FREE. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_migration_cookie.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_coo= kie.c index 93d91b8a1c..84274301dc 100644 --- a/src/qemu/qemu_migration_cookie.c +++ b/src/qemu/qemu_migration_cookie.c @@ -1218,15 +1218,18 @@ qemuMigrationCookieXMLParse(qemuMigrationCookiePtr = mig, if ((flags & QEMU_MIGRATION_COOKIE_LOCKSTATE) && virXPathBoolean("count(./lockstate) > 0", ctxt)) { + g_autofree char *lockState =3D NULL; + mig->lockDriver =3D virXPathString("string(./lockstate[1]/@driver)= ", ctxt); if (!mig->lockDriver) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Missing lock driver name in migration cookie= ")); return -1; } - mig->lockState =3D virXPathString("string(./lockstate[1]/leases[1]= )", ctxt); - if (mig->lockState && STREQ(mig->lockState, "")) - VIR_FREE(mig->lockState); + + lockState =3D virXPathString("string(./lockstate[1]/leases[1])", c= txt); + if (STRNEQ_NULLABLE(lockState, "")) + mig->lockState =3D g_steal_pointer(&lockState); } if ((flags & QEMU_MIGRATION_COOKIE_PERSISTENT) && --=20 2.26.2 From nobody Mon Apr 29 16:36:35 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) client-ip=63.128.21.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1601629494; cv=none; d=zohomail.com; s=zohoarc; b=bhYI91PJuyDjOuzd2ucKRemsxdM+DLYDQwY1aeUd9sUO3KkRY78t9Hwka5d8KtNrfCk2y4fEnhpDUJxKPHMpedoRPar4uV14g61VelTyui0jVpTXDbWZsSEXN0gvmwXjcZkUmYoJS0GeMw6q+dP5RhVrQ1XgD6ApBe7zIa8ngZE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601629494; h=Content-Type:Content-Transfer-Encoding:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=2E7yAiX6wYHesJSPWzmXssvnWBzRxIQvP8gVbkplPak=; b=eqdKZYbksljn365ruicopYyon4xgzq8pRSp8sR69M7zi6RbSY5cnjSUGv1a8XIt8N6sRtNDk/Y/+fwtW12wMCuaWrCIjuOCBZmp/gUNukqnIBug3Ut9Ye2eNZLUVQ3lW6PbUNXFvmEjxNjP5wnK7QModdXJHE+EIWovpdFr40xc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [63.128.21.124]) by mx.zohomail.com with SMTPS id 1601629494635197.9211156267611; Fri, 2 Oct 2020 02:04:54 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-400-FbJ0DL_aPhSTzcrJ-uFfLA-1; Fri, 02 Oct 2020 05:04:51 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id E845664142; Fri, 2 Oct 2020 09:04:45 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 70EFD5C1D0; Fri, 2 Oct 2020 09:04:45 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id BDD4E181A050; Fri, 2 Oct 2020 09:04:43 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0928wr9F015243 for ; Fri, 2 Oct 2020 04:58:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id BF2EE78820; Fri, 2 Oct 2020 08:58:53 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.55]) by smtp.corp.redhat.com (Postfix) with ESMTP id 25DD37881E for ; Fri, 2 Oct 2020 08:58:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601629493; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=2E7yAiX6wYHesJSPWzmXssvnWBzRxIQvP8gVbkplPak=; b=H1ZOGzshMkZdXZPfbyTlHFgi77MjIuvhmWd/RjvvwG+Pg1SgBtVrPPRlXbUK1fj7GC5kTR lj/95/U/Lasb3xW01GrLwtubwiTOTwE1bS3casPBIg3/I8jQRN9XXxI5AevRiaYsxCp4Pr y1tjfJpWIKhJDJHkX5CdeI59AeuGR84= X-MC-Unique: FbJ0DL_aPhSTzcrJ-uFfLA-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 20/20] qemu: migration_cookie: s/VIR_FREE/g_free/ Date: Fri, 2 Oct 2020 10:57:54 +0200 Message-Id: <5af9c673b580ea595d67d1d3268ba1aad8754fa0.1601629017.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" Previous refactors allow us to plainly replace all VIR_FREE by g_free to finish the modernization of the file. Signed-off-by: Peter Krempa Reviewed-by: Michal Privoznik --- src/qemu/qemu_migration_cookie.c | 34 ++++++++++++++++---------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_coo= kie.c index 84274301dc..1c792f15bc 100644 --- a/src/qemu/qemu_migration_cookie.c +++ b/src/qemu/qemu_migration_cookie.c @@ -59,9 +59,9 @@ qemuMigrationCookieGraphicsFree(qemuMigrationCookieGraphi= csPtr grap) { if (!grap) return; - VIR_FREE(grap->listen); - VIR_FREE(grap->tlsSubject); - VIR_FREE(grap); + g_free(grap->listen); + g_free(grap->tlsSubject); + g_free(grap); } G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuMigrationCookieGraphics, @@ -78,10 +78,10 @@ qemuMigrationCookieNetworkFree(qemuMigrationCookieNetwo= rkPtr network) if (network->net) { for (i =3D 0; i < network->nnets; i++) - VIR_FREE(network->net[i].portdata); + g_free(network->net[i].portdata); } - VIR_FREE(network->net); - VIR_FREE(network); + g_free(network->net); + g_free(network); } G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuMigrationCookieNetwork, @@ -94,9 +94,9 @@ qemuMigrationCookieNBDFree(qemuMigrationCookieNBDPtr nbd) return; while (nbd->ndisks) - VIR_FREE(nbd->disks[--nbd->ndisks].target); - VIR_FREE(nbd->disks); - VIR_FREE(nbd); + g_free(nbd->disks[--nbd->ndisks].target); + g_free(nbd->disks); + g_free(nbd); } G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuMigrationCookieNBD, @@ -110,7 +110,7 @@ qemuMigrationCookieCapsFree(qemuMigrationCookieCapsPtr = caps) virBitmapFree(caps->supported); virBitmapFree(caps->automatic); - VIR_FREE(caps); + g_free(caps); } G_DEFINE_AUTOPTR_CLEANUP_FUNC(qemuMigrationCookieCaps, @@ -127,15 +127,15 @@ qemuMigrationCookieFree(qemuMigrationCookiePtr mig) qemuMigrationCookieNetworkFree(mig->network); qemuMigrationCookieNBDFree(mig->nbd); - VIR_FREE(mig->localHostname); - VIR_FREE(mig->remoteHostname); - VIR_FREE(mig->name); - VIR_FREE(mig->lockState); - VIR_FREE(mig->lockDriver); + g_free(mig->localHostname); + g_free(mig->remoteHostname); + g_free(mig->name); + g_free(mig->lockState); + g_free(mig->lockDriver); g_clear_pointer(&mig->jobInfo, qemuDomainJobInfoFree); virCPUDefFree(mig->cpu); qemuMigrationCookieCapsFree(mig->caps); - VIR_FREE(mig); + g_free(mig); } @@ -1409,7 +1409,7 @@ qemuMigrationCookieParse(virQEMUDriverPtr driver, if (flags & QEMU_MIGRATION_COOKIE_PERSISTENT && mig->persistent && STRNEQ(def->name, mig->persistent->name)) { - VIR_FREE(mig->persistent->name); + g_free(mig->persistent->name); mig->persistent->name =3D g_strdup(def->name); } --=20 2.26.2