From nobody Sat May 4 16:40:17 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=1601967607; cv=none; d=zohomail.com; s=zohoarc; b=lwBDlRQniHWTR3vJCJDzINi+ZElVUZ8+nHuwGbR/QK/SqIcHx/fH+AV6SWajoCdf7KTtib+hx/Gz4Ci09wYnAtnsJV4fZu5hMaqUuKMDVEQuln6v5O8mjUdoYEhn4USuHg24MGLQNfZIxy4G76+vfHcWnPD13/E0LphrQeSRH5Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601967607; 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=NGpx388u81LvxueeO/3J4sw5nKbYE0DUEnQ2c9RQ7ao=; b=dUe60Cd8oAO5UuDX6dCNI/QP98YatqA23wWn+HtEbzEwhZiIu3jm++7WB03PlpJ2Q+yxg1CogedDdh8NvMDsmnu9Xxp8U2FVP4QU2G7If2miOXx1gnA7KIlNxCbnKX1/Qvp26H+5VWNUcLJuL03ZNKQ+R71U+Bny+ELppg+/33c= 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 1601967607021842.8638901532099; Tue, 6 Oct 2020 00: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-370-cP6mL-QkOrujonJ15lc-9w-1; Tue, 06 Oct 2020 02:59:19 -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 4A5AC8D9846; Tue, 6 Oct 2020 06:59:14 +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 2472555789; Tue, 6 Oct 2020 06:59:14 +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 E271F181A07D; Tue, 6 Oct 2020 06:59:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0966wvHd018560 for ; Tue, 6 Oct 2020 02:58:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id 20DAB5C1C4; Tue, 6 Oct 2020 06:58:57 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9D7825C1BD for ; Tue, 6 Oct 2020 06:58:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601967605; 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=NGpx388u81LvxueeO/3J4sw5nKbYE0DUEnQ2c9RQ7ao=; b=DaP01XE38YCmNo5z1nZu2vbBNVgk1vYXyBR8ZN5BcEuexhkBnRIZKZwPIu6rXLBeF3k+Gd o798cT6vGrTgbL6vIU/848pj7LKgwkVRJaTgb/4ZN7D2DHj0kvdtKj/gjeTILf8c/WWhO+ qqqrMH/E7PMLTP7Gc5JNwvK8AsoOjE0= X-MC-Unique: cP6mL-QkOrujonJ15lc-9w-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 01/14] qemu: agent: remove redundant checks Date: Tue, 6 Oct 2020 08:58:37 +0200 Message-Id: <2f0c1dbba27ef02a6ffd3c27a33c7c95a3533db9.1601967442.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) virJSONValueObjectGetArray returns NULL if the object with the supplied key is not an array. Calling virJSONValueIsArray right after is redundant. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Jonathon Jongsma --- src/qemu/qemu_agent.c | 12 ------------ 1 file changed, 12 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index 09116e749c..456f0b69e6 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -1444,12 +1444,6 @@ qemuAgentGetVCPUs(qemuAgentPtr agent, goto cleanup; } =20 - if (!virJSONValueIsArray(data)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Malformed guest-get-vcpus data array")); - goto cleanup; - } - ndata =3D virJSONValueArraySize(data); =20 *info =3D g_new0(qemuAgentCPUInfo, ndata); @@ -2314,12 +2308,6 @@ qemuAgentGetUsers(qemuAgentPtr agent, return -1; } =20 - if (!virJSONValueIsArray(data)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Malformed guest-get-users data array")); - return -1; - } - ndata =3D virJSONValueArraySize(data); =20 if (virTypedParamsAddUInt(params, nparams, maxparams, --=20 2.26.2 From nobody Sat May 4 16:40:17 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=1601967552; cv=none; d=zohomail.com; s=zohoarc; b=OHmzxvBdStyY0ih/8LwJfNcou2VxVMhVa1rmbUaoQ6m2MYVDagnZlY9VRyLb4HeidW1zIxwfUdNnmS7FGXfeC26FJGdzjj1RGW4KBgTxODk1TMNitpG9/D/bzrMSRqnXxyISrg46WoA19sbwM4QyxglmjR/+Ht1wRyweB5i+eFg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601967552; 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=new3y/tGX65S/8fzYLVyQ6sZoxt9K6AqcfR/THibqxs=; b=mLqhzjvL3fhmHnG2QO9+vBPEnDGxVSSSG1uFVGzVo3nmKbyct1KjocXgREJXSLWbG9RIfvln5xSnKS550/YEw6LjFOwnzzOQ2V8JR/lJafKCfgrywlvEr00k//xcWFUEa69JFN+WYTUtnZFI+KQsDJGr8U7cyh0Sem0SYaMjaXU= 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 1601967552086869.2141867719303; Mon, 5 Oct 2020 23:59: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-503-qOCl0EhBNPeRuSE38sZcLA-1; Tue, 06 Oct 2020 02:59:08 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id A2B731015C9C; Tue, 6 Oct 2020 06:59:02 +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 860E460BFA; Tue, 6 Oct 2020 06:59:01 +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 9D1EF181A06C; Tue, 6 Oct 2020 06:58:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0966wvEl018577 for ; Tue, 6 Oct 2020 02:58:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id E54365C1C4; Tue, 6 Oct 2020 06:58:57 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6DE745C1BD for ; Tue, 6 Oct 2020 06:58:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601967550; 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=new3y/tGX65S/8fzYLVyQ6sZoxt9K6AqcfR/THibqxs=; b=STCLyKo/U+Z9jadhjZI1xuKwQFjHoDD1J5Grvp4yTAJCDNKrd5tfe+rGLEy5OBhKlfgjf9 ciH1W4NgLO7d6zZIEwdAsTTVpNA2sHFotGjJvVhoVyQoNQ7wHmVPlDaoMvxCt9SYrog7Eh 66+y4vRJj7QJY3KoVBf4quzhTqUjGDo= X-MC-Unique: qOCl0EhBNPeRuSE38sZcLA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 02/14] qemu: agent: split out qemuAgentGetInterfaceOneAddress Date: Tue, 6 Oct 2020 08:58:38 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.12 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) A function that takes one entry from the "ip-addresses" array returned by "guest-network-get-interfaces" and converts it into virDomainIPAddress. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Jonathon Jongsma --- src/qemu/qemu_agent.c | 78 +++++++++++++++++++++++++------------------ 1 file changed, 46 insertions(+), 32 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index 456f0b69e6..fc7b65de2a 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -2059,6 +2059,51 @@ qemuAgentGetFSInfo(qemuAgentPtr agent, return ret; } =20 + +static int +qemuAgentGetInterfaceOneAddress(virDomainIPAddressPtr ip_addr, + virJSONValuePtr ip_addr_obj, + const char *name) +{ + const char *type, *addr; + + type =3D virJSONValueObjectGetString(ip_addr_obj, "ip-address-type"); + if (!type) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("qemu agent didn't provide 'ip-address-type'" + " field for interface '%s'"), name); + return -1; + } else if (STREQ(type, "ipv4")) { + ip_addr->type =3D VIR_IP_ADDR_TYPE_IPV4; + } else if (STREQ(type, "ipv6")) { + ip_addr->type =3D VIR_IP_ADDR_TYPE_IPV6; + } else { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("unknown ip address type '%s'"), + type); + return -1; + } + + addr =3D virJSONValueObjectGetString(ip_addr_obj, "ip-address"); + if (!addr) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("qemu agent didn't provide 'ip-address'" + " field for interface '%s'"), name); + return -1; + } + ip_addr->addr =3D g_strdup(addr); + + if (virJSONValueObjectGetNumberUint(ip_addr_obj, "prefix", + &ip_addr->prefix) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("malformed 'prefix' field")); + return -1; + } + + return 0; +} + + /* * qemuAgentGetInterfaces: * @agent: agent object @@ -2176,7 +2221,6 @@ qemuAgentGetInterfaces(qemuAgentPtr agent, addrs_count =3D iface->naddrs; =20 for (j =3D 0; j < virJSONValueArraySize(ip_addr_arr); j++) { - const char *type, *addr; virJSONValuePtr ip_addr_obj =3D virJSONValueArrayGet(ip_addr_a= rr, j); virDomainIPAddressPtr ip_addr; =20 @@ -2192,38 +2236,8 @@ qemuAgentGetInterfaces(qemuAgentPtr agent, goto error; } =20 - type =3D virJSONValueObjectGetString(ip_addr_obj, "ip-address-= type"); - if (!type) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("qemu agent didn't provide 'ip-address-ty= pe'" - " field for interface '%s'"), name); + if (qemuAgentGetInterfaceOneAddress(ip_addr, ip_addr_obj, name= ) < 0) goto error; - } else if (STREQ(type, "ipv4")) { - ip_addr->type =3D VIR_IP_ADDR_TYPE_IPV4; - } else if (STREQ(type, "ipv6")) { - ip_addr->type =3D VIR_IP_ADDR_TYPE_IPV6; - } else { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("unknown ip address type '%s'"), - type); - goto error; - } - - addr =3D virJSONValueObjectGetString(ip_addr_obj, "ip-address"= ); - if (!addr) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("qemu agent didn't provide 'ip-address'" - " field for interface '%s'"), name); - goto error; - } - ip_addr->addr =3D g_strdup(addr); - - if (virJSONValueObjectGetNumberUint(ip_addr_obj, "prefix", - &ip_addr->prefix) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("malformed 'prefix' field")); - goto error; - } } =20 iface->naddrs =3D addrs_count; --=20 2.26.2 From nobody Sat May 4 16:40:17 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=1601967551; cv=none; d=zohomail.com; s=zohoarc; b=J1PJKYlAy+vbAXP9UPswx9uGbnhbxxPvB9KiIKs86/UG6suGb8dlMYJmV462XJ2ScPspRZ+WSXbKHc8fJDZJVwn5mr4ahLLJfFNqYEslePnmwcxPJGD2IMpFU9QHCm+SYa0PPjp2qQhbkEVH5I7XF2dQefgL4lLnRvqc/3PL0+Q= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601967551; 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=/5KqnWMuEIJdenqFXf5a7pacKTB5n7rl9mmXnS9iGvo=; b=fI3FF9v3vHb1rr9lhWrWRiXtaasBK2ymdYSeUorsP2rn59gkSQYOCS10o4nK7QXbKL8Ud1v1C0lnAXPx+jYK9bzDdN5MgqpXrZJgdqYcHn4DWJTWhuWlpxWIUYHU0hDrKrUolLsLY591dplmOzuAvJ8hB+KSFZcg4BB21xX3Kac= 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 1601967551607108.32444381792925; Mon, 5 Oct 2020 23:59:11 -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-256-BxLO_8CFNGqe4O2JW9HXTA-1; Tue, 06 Oct 2020 02:59:07 -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 C184510866A7; Tue, 6 Oct 2020 06:59:02 +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 81DC55578C; Tue, 6 Oct 2020 06:59:01 +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 43E1744A6E; Tue, 6 Oct 2020 06:59:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0966wwni018585 for ; Tue, 6 Oct 2020 02:58:58 -0400 Received: by smtp.corp.redhat.com (Postfix) id B673A5C1BD; Tue, 6 Oct 2020 06:58:58 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3ED1B5C1C4 for ; Tue, 6 Oct 2020 06:58:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601967550; 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=/5KqnWMuEIJdenqFXf5a7pacKTB5n7rl9mmXnS9iGvo=; b=dhXvzHeMjGdcLqrfr6vu7uDH7yXQ6Vykg1iw6klNzH9EorsUvTsiS16eZZYTk/AERmk/VM gssXUBV6fOwrdNqJCAu3DuYzahsTj+vo+GYynEKDNs3WEpXC9ijBMl8CvjHnuM3rc1eO1k eHXhNfB96RkJXXXwL0FXG8qlBsyP/pc= X-MC-Unique: BxLO_8CFNGqe4O2JW9HXTA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 03/14] qemu: agent: remove impossible errors Date: Tue, 6 Oct 2020 08:58:39 +0200 Message-Id: <6c0ec867db7501d7d8894f9ece7b44d65b071272.1601967442.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) For both 'ip_addr_arr' and 'ret_array', we: 1) already checked that they are arrays 2) only iterate up to the array size Remove the duplicate checks. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Jonathon Jongsma --- src/qemu/qemu_agent.c | 14 -------------- 1 file changed, 14 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index fc7b65de2a..51c597f57e 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -2160,13 +2160,6 @@ qemuAgentGetInterfaces(qemuAgentPtr agent, const char *hwaddr, *ifname_s, *name =3D NULL; virDomainInterfacePtr iface =3D NULL; =20 - /* Shouldn't happen but doesn't hurt to check neither */ - if (!tmp_iface) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("qemu agent reply missing interface entry in = array")); - goto error; - } - /* interface name is required to be presented */ name =3D virJSONValueObjectGetString(tmp_iface, "name"); if (!name) { @@ -2229,13 +2222,6 @@ qemuAgentGetInterfaces(qemuAgentPtr agent, =20 ip_addr =3D &iface->addrs[addrs_count - 1]; =20 - /* Shouldn't happen but doesn't hurt to check neither */ - if (!ip_addr_obj) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("qemu agent reply missing IP addr in arra= y")); - goto error; - } - if (qemuAgentGetInterfaceOneAddress(ip_addr, ip_addr_obj, name= ) < 0) goto error; } --=20 2.26.2 From nobody Sat May 4 16:40:17 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=1601967563; cv=none; d=zohomail.com; s=zohoarc; b=cQBuWEv91t0HK3X2pYL1whiOg8JdVzPdvCFcIJvV0Q3UQp62hDjFZQr2TVktKCmmRV2ZSkUoHl7bjey0QHd/GbB0RTCE7tW7xfuwOWZPlgYUTGTjzBCTLN6o5wvjwSWbZenaTV59Vb88aV6waLmdnqYwBnXcB0ARjE9cI5srLOQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601967563; 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=fwnmcvtkx54KGnzvDob+QRH3fRtBkM+hkz5TkrZvvZY=; b=PeAPUG7buGSS5Ew8I5npfWBcya3scyFOQW3fbOm7EpSK7plblRnuYJeS2Snxqce7A+kusqkGzb5+mZPsFvV2RJhYgz5if8ZLvSs/Om0CiHkexueh9JOnb2g5zKITBEzGZiNHP5WlZwbHoWQMjdPQU/f/ewJ3dWYNb2y9tbDAB5A= 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 16019675634461008.2228357626245; Mon, 5 Oct 2020 23:59:23 -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-480-f6InH8aSNki91sB5Vr4sCg-1; Tue, 06 Oct 2020 02:59:19 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 7844B10866A9; Tue, 6 Oct 2020 06:59:14 +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 56DBD60BFA; Tue, 6 Oct 2020 06:59:14 +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 1FE88181A07E; Tue, 6 Oct 2020 06:59:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0966wx1O018598 for ; Tue, 6 Oct 2020 02:58:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8777D5C1C4; Tue, 6 Oct 2020 06:58:59 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0F7E75C1BD for ; Tue, 6 Oct 2020 06:58:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601967562; 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=fwnmcvtkx54KGnzvDob+QRH3fRtBkM+hkz5TkrZvvZY=; b=iTwUz5VEgBwsWvXhY9WmSEgwWhskO8sk/or4hgXUu5B8Bn2ER9UUT6VaYjvARa7x4Efopi tSNKCASKOoPTf3CcUOUO3Zy4Xtg7BlROAfWftDI8/hMms+ES1qjiVBkg8YlEEDHwxAZoSC aJvIE8daahc5qh0qVFbLsVd0ZWTFmL8= X-MC-Unique: f6InH8aSNki91sB5Vr4sCg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 04/14] qemu: agent: reduce scope of addrs_count Date: Tue, 6 Oct 2020 08:58:40 +0200 Message-Id: <8029a2c6d2f2c519462c70bdf737e5d7447ffa7c.1601967442.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.12 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Signed-off-by: J=C3=A1n Tomko Reviewed-by: Jonathon Jongsma --- src/qemu/qemu_agent.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index 51c597f57e..c6878c8590 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -2125,7 +2125,6 @@ qemuAgentGetInterfaces(qemuAgentPtr agent, virJSONValuePtr reply =3D NULL; virJSONValuePtr ret_array =3D NULL; size_t ifaces_count =3D 0; - size_t addrs_count =3D 0; virDomainInterfacePtr *ifaces_ret =3D NULL; virHashTablePtr ifaces_store =3D NULL; char **ifname =3D NULL; @@ -2159,6 +2158,7 @@ qemuAgentGetInterfaces(qemuAgentPtr agent, virJSONValuePtr ip_addr_arr =3D NULL; const char *hwaddr, *ifname_s, *name =3D NULL; virDomainInterfacePtr iface =3D NULL; + size_t addrs_count =3D 0; =20 /* interface name is required to be presented */ name =3D virJSONValueObjectGetString(tmp_iface, "name"); --=20 2.26.2 From nobody Sat May 4 16:40:17 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=1601967568; cv=none; d=zohomail.com; s=zohoarc; b=msknG5JJ7r8iIqJj+SsDhadBgEZ/7KWmWA7BMZpIMa4pNQkMHl3te9e16TcX4zppDpJR1ps0rbufkirAp4kpagLjkZU0Oss8IOnrAYScpa5Ub8Uo/CWSNW7d50c4TTss6PfcrqBZy2tUdpiKBURoAm4F7kzY0gPNZ+Eoccyf5bQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601967568; 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=CV/0iRUFPxpRDhZU4cHY+Pa2lQtvRBdtc8GQ8LqGFcc=; b=LPOAJsX854yJVc+GUrIwRfgI+b8YetX2O39hG+ZCPE3DBhJ1KaGtK0VhW35BoxwMUV+z6qT7NPcrGtVUis3YEvirzBZozm1mi2EFGaHu7mC6cgGPQamNBNAAD+YvdFuRdA/scs8HBkylYTg9hifpkO/bHEK/fIe7zRJ90Ci4NGE= 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 1601967568307440.7227807431616; Mon, 5 Oct 2020 23: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-337-uEIRDaWENMSso0AFMmTdcw-1; Tue, 06 Oct 2020 02: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 14BDE10866AE; Tue, 6 Oct 2020 06:59:17 +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 DF0233A40; Tue, 6 Oct 2020 06:59:16 +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 A86A644A77; Tue, 6 Oct 2020 06:59:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0966x09h018611 for ; Tue, 6 Oct 2020 02:59:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5AF235C22B; Tue, 6 Oct 2020 06:59:00 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id D51CA5C1BD for ; Tue, 6 Oct 2020 06:58:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601967566; 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=CV/0iRUFPxpRDhZU4cHY+Pa2lQtvRBdtc8GQ8LqGFcc=; b=D3QAmUCpP26VnLoVDFrDHJjexZWG/CTOktLOXsTMcguCqicN1KW62DzuXEYM0A7I8Tsqqq in5KenPKYDvehVQV3aBl4S/wc8X1sVHx9OxVwTuwAB7mWPHIMhDSFDrsPrMHuUtlhVRPB+ Fy7j3kKXMDDbmL8B6NTB+MRNQO94tgw= X-MC-Unique: uEIRDaWENMSso0AFMmTdcw-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 05/14] qemu: agent: expand addrs upfront Date: Tue, 6 Oct 2020 08:58:41 +0200 Message-Id: <43665cbf094727cf382d226e59a1b60894ec50a3.1601967442.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) qemuAgentGetInterfaceOneAddress returns exactly one address for every iteration of the loop (and we error out if not). Instead of expanding the addrs by one on every iteration, do it upfront since we know how many times the loop will execute. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Jonathon Jongsma --- src/qemu/qemu_agent.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index c6878c8590..dc989622b9 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -2213,20 +2213,17 @@ qemuAgentGetInterfaces(qemuAgentPtr agent, /* If current iface already exists, continue with the count */ addrs_count =3D iface->naddrs; =20 + if (VIR_EXPAND_N(iface->addrs, addrs_count, + virJSONValueArraySize(ip_addr_arr)) < 0) + goto error; + for (j =3D 0; j < virJSONValueArraySize(ip_addr_arr); j++) { virJSONValuePtr ip_addr_obj =3D virJSONValueArrayGet(ip_addr_a= rr, j); - virDomainIPAddressPtr ip_addr; - - if (VIR_EXPAND_N(iface->addrs, addrs_count, 1) < 0) - goto error; - - ip_addr =3D &iface->addrs[addrs_count - 1]; + virDomainIPAddressPtr ip_addr =3D iface->addrs + iface->naddrs= ++; =20 if (qemuAgentGetInterfaceOneAddress(ip_addr, ip_addr_obj, name= ) < 0) goto error; } - - iface->naddrs =3D addrs_count; } =20 *ifaces =3D g_steal_pointer(&ifaces_ret); --=20 2.26.2 From nobody Sat May 4 16:40:17 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=1601967613; cv=none; d=zohomail.com; s=zohoarc; b=XUqg1j/RdGyjR/M7Lb8iqZ0hk229L4anCfD1egbPyFzUhhUNjlvQEmQU9dyPkfOrlqcz6iNR6oepkPyhXRIOk0QqJcikvgizABJB3HQwYu5IjZFo56fy0hQt96VPHHTcpWjmBSwkmrlvDQ6B/U+jPZPQDBE9OalsVcEtK2HpswI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601967613; 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=oNkaM32k29d5h9Juh0sM5KbcGYxCQSvwIVmvYHG9B5U=; b=PS1RySvetWiJ5PynRMm2JC2uBPEGW54AyIeXHveFuZKDrUmR2Ob/4Vx386kCuP+1tvriefyIT/3iCCO6nnXI7kXz8zCm+aqjTK7GaDILwGy0JXxr9eRyTZZrYEPf6xvA37JHzCiRHf2aHr0W6ZTjSG5ZgTvRlxsQpxypCzCI3lk= 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 1601967613182296.65245192597047; Tue, 6 Oct 2020 00:00:13 -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-478-jEg46BvwNX6Dwaz_rBWSZw-1; Tue, 06 Oct 2020 02:59:19 -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 554B01015C9D; Tue, 6 Oct 2020 06:59:14 +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 311B95C1C4; Tue, 6 Oct 2020 06:59:14 +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 F0BA044A75; Tue, 6 Oct 2020 06:59:13 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0966x1KS018619 for ; Tue, 6 Oct 2020 02:59:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 28FF65C1C4; Tue, 6 Oct 2020 06:59:01 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id A5B1B5C1BD for ; Tue, 6 Oct 2020 06:59:00 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601967611; 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=oNkaM32k29d5h9Juh0sM5KbcGYxCQSvwIVmvYHG9B5U=; b=eUKCEnOz+2Wd5YGi/HZMK9MBvlv2wiXpondPaW8K2z75MWtQvaJMQSdOAEMNB9rxI4HpMP NQd+5eq3TAQiQoOcuTC+UbsBM51iaJuhV9THNUZX4DoHvs4JPik0DXQhN6a9oa0vZ1QA/4 UXdsMWMTYcVBLeFkahr7qeuLGoIlTXM= X-MC-Unique: jEg46BvwNX6Dwaz_rBWSZw-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 06/14] qemu: agent: use g_auto for ifname Date: Tue, 6 Oct 2020 08:58:42 +0200 Message-Id: <052236c1293cad4e34cb8bcf0ef072bba1abb7da.1601967442.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) This lets us conveniently reduce its scope to the outer loop. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Jonathon Jongsma --- src/qemu/qemu_agent.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index dc989622b9..3b92b2ec33 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -2127,7 +2127,6 @@ qemuAgentGetInterfaces(qemuAgentPtr agent, size_t ifaces_count =3D 0; virDomainInterfacePtr *ifaces_ret =3D NULL; virHashTablePtr ifaces_store =3D NULL; - char **ifname =3D NULL; =20 /* Hash table to handle the interface alias */ if (!(ifaces_store =3D virHashCreate(ifaces_count, NULL))) { @@ -2158,6 +2157,7 @@ qemuAgentGetInterfaces(qemuAgentPtr agent, virJSONValuePtr ip_addr_arr =3D NULL; const char *hwaddr, *ifname_s, *name =3D NULL; virDomainInterfacePtr iface =3D NULL; + g_auto(GStrv) ifname =3D NULL; size_t addrs_count =3D 0; =20 /* interface name is required to be presented */ @@ -2194,10 +2194,6 @@ qemuAgentGetInterfaces(qemuAgentPtr agent, iface->hwaddr =3D g_strdup(hwaddr); } =20 - /* Has to be freed for each interface. */ - g_strfreev(ifname); - ifname =3D NULL; - /* as well as IP address which - moreover - * can be presented multiple times */ ip_addr_arr =3D virJSONValueObjectGet(tmp_iface, "ip-addresses"); @@ -2241,8 +2237,6 @@ qemuAgentGetInterfaces(qemuAgentPtr agent, virDomainInterfaceFree(ifaces_ret[i]); } VIR_FREE(ifaces_ret); - g_strfreev(ifname); - goto cleanup; } =20 --=20 2.26.2 From nobody Sat May 4 16:40:17 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=1601967570; cv=none; d=zohomail.com; s=zohoarc; b=QDW27vRCHS8A/yV2RPN03tSlUyBdu26ReP15+hcB8rwebyEKTmqXZDsXQTtOg0gxCQptdtA+IGVJjGmxFRIMqPrJz+UPMZke2SCrhCzFB4VD0nfjwvumRAmdnVWzbpRhwQlj32I07i9OfQVtlhQ0UlW9yK6nEIyYkeNJwSyRAYc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601967570; 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=OrQrLLpD8XfNNPWaZ7v9yz/48oAtCok8wCORbDUz3FY=; b=HGt6+Sz31CiNGOvjWKvV9LZUrQ66XFH99yJfWkhOeqfFv6no28JfckoXaCHByfbM7WRbsRHM5B9o3Kw3/hWXgcf3RKLNQe9WNkAhujzcTZQkCuLXcl+s8F776tUQBm6tcsbrYC7oK+wFFKbGoB4iX5d/LnG/p9IioB+WIRXRFIw= 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 1601967570465881.596293300454; Mon, 5 Oct 2020 23: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-546-8d6oprodMkCB1HDMexcm_g-1; Tue, 06 Oct 2020 02:59:24 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1938210866AF; Tue, 6 Oct 2020 06:59:17 +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 EADC960BFA; Tue, 6 Oct 2020 06:59:16 +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 B5FA5181A55A; Tue, 6 Oct 2020 06:59:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0966x1LP018633 for ; Tue, 6 Oct 2020 02:59:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id EDD085C1BD; Tue, 6 Oct 2020 06:59:01 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 75B905C1C4 for ; Tue, 6 Oct 2020 06:59:01 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601967567; 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=OrQrLLpD8XfNNPWaZ7v9yz/48oAtCok8wCORbDUz3FY=; b=IO4yoHlJq9bQKSj5XeiCn9PNoTVrP95Z9mIMpwEOP/rJ2GjfbVvEceNu7zNwvTRdNqN9pw vzIs0PcG7zC2V6F34cdutVuXNC3qxOEdSxaQHmjtLdTVMOtmE5uOY9erXyd04zZD3swP5p l5/mgV6x4fJWW/AQMvH9aJAENCnEglA= X-MC-Unique: 8d6oprodMkCB1HDMexcm_g-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 07/14] qemu: agent: use virHashNew Date: Tue, 6 Oct 2020 08:58:43 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.12 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) We're passing 'ifaces_count' to virHashCreate as the initial hash table size just after we've initialized it to zero. This translates to a default of 256 inside virHashCreateFull. Instead of this obfuscation, use virHashNew (default of 32), to make it obvious we don't care about the initial hash size. Also remove the error handling, since neither of the functions return any errors after switching to g_new0. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Jonathon Jongsma --- src/qemu/qemu_agent.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index 3b92b2ec33..d0319cc0c7 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -2129,10 +2129,7 @@ qemuAgentGetInterfaces(qemuAgentPtr agent, virHashTablePtr ifaces_store =3D NULL; =20 /* Hash table to handle the interface alias */ - if (!(ifaces_store =3D virHashCreate(ifaces_count, NULL))) { - virHashFree(ifaces_store); - return -1; - } + ifaces_store =3D virHashNew(NULL); =20 if (!(cmd =3D qemuAgentMakeCommand("guest-network-get-interfaces", NUL= L))) goto cleanup; --=20 2.26.2 From nobody Sat May 4 16:40:17 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=1601967609; cv=none; d=zohomail.com; s=zohoarc; b=XJhQ62qwXjpEQ+O0mH3UReVZX6uLOkj8jdC+jdbof6Tj8cUYP+s95+uklJONk5kOwaM+Pfy9NI8ycvSZ0e44uxC5Ju0pdbxxU27WY2uBHir94a1uLv1CbaxSuiP31dzOV0Ix9MoTDnVoESe8B+Kkne5/pcZTP9vftG+olYZxvLU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601967609; 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=nsm2CHWpJ11z/KbF+8s6o8yIAkUAmOEc2GWNqpUyFkg=; b=h7Dl/JO9VY15o54GwyeszkygiPNagAH8ecDw53tvpwiUf0wsego0nwxMpOWbxd/Ch5MlN+ZxH8UG4+O0I7lNg31Q0QuLRDeyf9YmHIrwcdsOkWbgDYnwQ6wOmWzlSKPXa/oeyz1EM0kyDjG2coY9re0EQydoZMzEhha1QIipHHA= 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 1601967609222971.2939382488876; Tue, 6 Oct 2020 00:00:09 -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-576-XFhu2W6NNOO7n-ap9Pwqpg-1; Tue, 06 Oct 2020 02:59:29 -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 E7B0910866B7; Tue, 6 Oct 2020 06:59:19 +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 C356E19C4F; Tue, 6 Oct 2020 06:59:19 +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 8CEEB181A869; Tue, 6 Oct 2020 06:59:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0966x5tV018654 for ; Tue, 6 Oct 2020 02:59:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id 82F085C1BD; Tue, 6 Oct 2020 06:59:05 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 0AE145C22B for ; Tue, 6 Oct 2020 06:59:02 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601967607; 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=nsm2CHWpJ11z/KbF+8s6o8yIAkUAmOEc2GWNqpUyFkg=; b=BYhoJu9TpKo+knKZ+y2KHci86aySL1IyNFbIvUcv8K4BltBIfvJGHN5Or2+9RQIXoi5WCb 0XbOFf/8PfXcuOH1W30ZKbiXIzyBZ9s7q2Lr45xzkmES3LHp0u/9wMj8qAFhhegr3B3E/q Ndjbh+6BqgyKZ1EZhC0zyzFG0akj/XU= X-MC-Unique: XFhu2W6NNOO7n-ap9Pwqpg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 08/14] qemu: agent: simplify access to ifaces_ret Date: Tue, 6 Oct 2020 08:58:44 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) We have a local 'iface' variable that contains the same value eventually. Initialize it early instead of indexing two more times. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Jonathon Jongsma --- src/qemu/qemu_agent.c | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index d0319cc0c7..7a4f5cd6db 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -2176,15 +2176,13 @@ qemuAgentGetInterfaces(qemuAgentPtr agent, if (VIR_EXPAND_N(ifaces_ret, ifaces_count, 1) < 0) goto error; =20 - ifaces_ret[ifaces_count - 1] =3D g_new0(virDomainInterface, 1); + iface =3D g_new0(virDomainInterface, 1); + ifaces_ret[ifaces_count - 1] =3D iface; =20 - if (virHashAddEntry(ifaces_store, ifname_s, - ifaces_ret[ifaces_count - 1]) < 0) + if (virHashAddEntry(ifaces_store, ifname_s, iface) < 0) goto error; =20 - iface =3D ifaces_ret[ifaces_count - 1]; iface->naddrs =3D 0; - iface->name =3D g_strdup(ifname_s); =20 hwaddr =3D virJSONValueObjectGetString(tmp_iface, "hardware-ad= dress"); --=20 2.26.2 From nobody Sat May 4 16:40:17 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=1601967608; cv=none; d=zohomail.com; s=zohoarc; b=IOpm7YW8qfDHF1KKZs6d/lpNen9vXOHWn3RQXypaoHv9x6NiGMiCQS4DszjwwxzBHjfJCPoIb8TBYZtbr9+QLKc4WEwAgd0ORI0qrB0pC2xsTIpNu8RDHYkRcmFuhxxRSXmKwMHqqQVv3JqpBxAv40/v5lAd7L0K1k1ZQpw48pg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601967608; 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=O9ndmYDt9rcvTFJL+ZfWyEPmrCaQq/Ws5XANrj45jpk=; b=KFWOhbq/oozM8CBxAV2VDianAx5Oi9ZB7JjOnu4AuqyB8CH1GCZJpGPSiQnvwrrvaGsAgCaqH/7YMiQB/DCSqdB/UnBsO4DSd1lqCngNQLG6yGyyj4vAOq/thZaGjSdP5O4eQ9BlDvyPZGcnudPre2EnKc5VP40wKBdZ7UqGWBg= 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 1601967608939293.1998092823618; Tue, 6 Oct 2020 00:00:08 -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-204-x6B1iTqQMeS2-OucHWrIhA-1; Tue, 06 Oct 2020 02:59:25 -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 4D6A810866B0; Tue, 6 Oct 2020 06:59:17 +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 265F25578C; Tue, 6 Oct 2020 06:59:17 +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 E3F7244A79; Tue, 6 Oct 2020 06:59:16 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0966x96e018672 for ; Tue, 6 Oct 2020 02:59:09 -0400 Received: by smtp.corp.redhat.com (Postfix) id B8E7A5C221; Tue, 6 Oct 2020 06:59:09 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 401855C1C4 for ; Tue, 6 Oct 2020 06:59:05 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601967607; 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=O9ndmYDt9rcvTFJL+ZfWyEPmrCaQq/Ws5XANrj45jpk=; b=Ojbkigz3krWTWRSjtNdvbqZ4SVc6yoCYzdTD772jzsH356Wi0kPf9Ka4lkyi3vx9sCscpd nO+ejjpC2A04u/TyhG6H2tRM1afOB3MDgWMIIPUL9klPj9XBirdoPKDWnrHUw6SYFAd34l xBmQoaXnoVG95l0x+iNfTXqqC5E87Ws= X-MC-Unique: x6B1iTqQMeS2-OucHWrIhA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 09/14] qemu: agent: split out qemuAgentGetInterfaceAddresses Date: Tue, 6 Oct 2020 08:58:45 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Convert one interface from the "return" array returned by "guest-network-get-interfaces" to virDomainInterface. Due to the functionality of squashing interface aliases together, this is not a pure function - it either: * Adds the interface to ifaces_ret, incrementing ifaces_count and adds a pointer to it into the ifaces_store hash table. * Adds the additional IP addresses from the interface alias to the existing interface entry, found through the hash table. This does not increment ifaces_count or extend the array. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Jonathon Jongsma --- src/qemu/qemu_agent.c | 141 +++++++++++++++++++++++------------------- 1 file changed, 79 insertions(+), 62 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index 7a4f5cd6db..b314c610e7 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -2104,6 +2104,82 @@ qemuAgentGetInterfaceOneAddress(virDomainIPAddressPt= r ip_addr, } =20 =20 +static int +qemuAgentGetInterfaceAddresses(virDomainInterfacePtr **ifaces_ret, + size_t *ifaces_count, + virHashTablePtr ifaces_store, + virJSONValuePtr tmp_iface) +{ + virJSONValuePtr ip_addr_arr =3D NULL; + const char *hwaddr, *ifname_s, *name =3D NULL; + virDomainInterfacePtr iface =3D NULL; + g_auto(GStrv) ifname =3D NULL; + size_t addrs_count =3D 0; + size_t j; + + /* interface name is required to be presented */ + name =3D virJSONValueObjectGetString(tmp_iface, "name"); + if (!name) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("qemu agent didn't provide 'name' field")); + return -1; + } + + /* Handle interface alias (:) */ + ifname =3D virStringSplit(name, ":", 2); + ifname_s =3D ifname[0]; + + iface =3D virHashLookup(ifaces_store, ifname_s); + + /* If the hash table doesn't contain this iface, add it */ + if (!iface) { + if (VIR_EXPAND_N(*ifaces_ret, *ifaces_count, 1) < 0) + return -1; + + iface =3D g_new0(virDomainInterface, 1); + (*ifaces_ret)[*ifaces_count - 1] =3D iface; + + if (virHashAddEntry(ifaces_store, ifname_s, iface) < 0) + return -1; + + iface->naddrs =3D 0; + iface->name =3D g_strdup(ifname_s); + + hwaddr =3D virJSONValueObjectGetString(tmp_iface, "hardware-addres= s"); + iface->hwaddr =3D g_strdup(hwaddr); + } + + /* as well as IP address which - moreover - + * can be presented multiple times */ + ip_addr_arr =3D virJSONValueObjectGet(tmp_iface, "ip-addresses"); + if (!ip_addr_arr) + return 0; + + if (!virJSONValueIsArray(ip_addr_arr)) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("Malformed ip-addresses array")); + return -1; + } + + /* If current iface already exists, continue with the count */ + addrs_count =3D iface->naddrs; + + if (VIR_EXPAND_N(iface->addrs, addrs_count, + virJSONValueArraySize(ip_addr_arr)) < 0) + return -1; + + for (j =3D 0; j < virJSONValueArraySize(ip_addr_arr); j++) { + virJSONValuePtr ip_addr_obj =3D virJSONValueArrayGet(ip_addr_arr, = j); + virDomainIPAddressPtr ip_addr =3D iface->addrs + iface->naddrs++; + + if (qemuAgentGetInterfaceOneAddress(ip_addr, ip_addr_obj, name) < = 0) + return -1; + } + + return 0; +} + + /* * qemuAgentGetInterfaces: * @agent: agent object @@ -2120,7 +2196,7 @@ qemuAgentGetInterfaces(qemuAgentPtr agent, virDomainInterfacePtr **ifaces) { int ret =3D -1; - size_t i, j; + size_t i; virJSONValuePtr cmd =3D NULL; virJSONValuePtr reply =3D NULL; virJSONValuePtr ret_array =3D NULL; @@ -2151,70 +2227,11 @@ qemuAgentGetInterfaces(qemuAgentPtr agent, =20 for (i =3D 0; i < virJSONValueArraySize(ret_array); i++) { virJSONValuePtr tmp_iface =3D virJSONValueArrayGet(ret_array, i); - virJSONValuePtr ip_addr_arr =3D NULL; - const char *hwaddr, *ifname_s, *name =3D NULL; - virDomainInterfacePtr iface =3D NULL; - g_auto(GStrv) ifname =3D NULL; - size_t addrs_count =3D 0; =20 - /* interface name is required to be presented */ - name =3D virJSONValueObjectGetString(tmp_iface, "name"); - if (!name) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("qemu agent didn't provide 'name' field")); + if (qemuAgentGetInterfaceAddresses(&ifaces_ret, &ifaces_count, + ifaces_store, tmp_iface) < 0) goto error; - } =20 - /* Handle interface alias (:) */ - ifname =3D virStringSplit(name, ":", 2); - ifname_s =3D ifname[0]; - - iface =3D virHashLookup(ifaces_store, ifname_s); - - /* If the hash table doesn't contain this iface, add it */ - if (!iface) { - if (VIR_EXPAND_N(ifaces_ret, ifaces_count, 1) < 0) - goto error; - - iface =3D g_new0(virDomainInterface, 1); - ifaces_ret[ifaces_count - 1] =3D iface; - - if (virHashAddEntry(ifaces_store, ifname_s, iface) < 0) - goto error; - - iface->naddrs =3D 0; - iface->name =3D g_strdup(ifname_s); - - hwaddr =3D virJSONValueObjectGetString(tmp_iface, "hardware-ad= dress"); - iface->hwaddr =3D g_strdup(hwaddr); - } - - /* as well as IP address which - moreover - - * can be presented multiple times */ - ip_addr_arr =3D virJSONValueObjectGet(tmp_iface, "ip-addresses"); - if (!ip_addr_arr) - continue; - - if (!virJSONValueIsArray(ip_addr_arr)) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Malformed ip-addresses array")); - goto error; - } - - /* If current iface already exists, continue with the count */ - addrs_count =3D iface->naddrs; - - if (VIR_EXPAND_N(iface->addrs, addrs_count, - virJSONValueArraySize(ip_addr_arr)) < 0) - goto error; - - for (j =3D 0; j < virJSONValueArraySize(ip_addr_arr); j++) { - virJSONValuePtr ip_addr_obj =3D virJSONValueArrayGet(ip_addr_a= rr, j); - virDomainIPAddressPtr ip_addr =3D iface->addrs + iface->naddrs= ++; - - if (qemuAgentGetInterfaceOneAddress(ip_addr, ip_addr_obj, name= ) < 0) - goto error; - } } =20 *ifaces =3D g_steal_pointer(&ifaces_ret); --=20 2.26.2 From nobody Sat May 4 16:40:17 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=1601967666; cv=none; d=zohomail.com; s=zohoarc; b=Dg6gTXpk0iZCbvQdruMs5lDyCb7cmCnOOtGWh1Rgv0BCc9vKZMRAXUdz/kNgq+3Bo9jQuIUr/aLt92Dmv1exzsEMdt7K3yQdEJspOnJiC7h/+eXiDyEkKi1CRqzxuBYx/h4frPUvt9BomFlTh89b1O5SJzvamCY0O5CmhruY8z4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601967666; 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=H+z0gdwdOEiD83gVnbC+Y5qLhMgMnwPuogIJifU2pjw=; b=iVeRm6LvDgm7qLdG3e4o9k5c1w4HtutjDDok8W3k5iDwo8t9xnr1UcsfhAWtsd53+IZ6jZF3q7YkZd0NHZeU7q2aGtpxQ4Va8gwpzwFm0oLrQUhZzUpagueHwzPYFu/Oih121coe27c1HfBs8qunhbBmyiQU2G32VZQS7mjb6qo= 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 16019676660373.2444030261715398; Tue, 6 Oct 2020 00:01: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-493-YQSGRSSjOzOfLW5jI73SXA-1; Tue, 06 Oct 2020 02: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 7ACF18D9874; Tue, 6 Oct 2020 06:59:22 +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 563AB10001B3; Tue, 6 Oct 2020 06:59:22 +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 260CA5A0FF; Tue, 6 Oct 2020 06:59:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0966xAxC018677 for ; Tue, 6 Oct 2020 02:59:10 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8923F5C221; Tue, 6 Oct 2020 06:59:10 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 11A8A5C1C4 for ; Tue, 6 Oct 2020 06:59:09 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601967664; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=H+z0gdwdOEiD83gVnbC+Y5qLhMgMnwPuogIJifU2pjw=; b=XzmINydosy62o0oFgV/5VcB91xG/eoHeXJGpgzaSRK1VG+PxvP0xFh68tS1kI89T+UDSUO xPglA3OIJ3r//bKXQDLVcdj4EiBYAkxCuuO2WGmz1rvaUKw5ZiIQrKlWb2UlCRWCrybw57 vVEdognWioKJCA5NaIvFQ1kheDroblk= X-MC-Unique: YQSGRSSjOzOfLW5jI73SXA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 10/14] qemu: agent: use GetArray to remove a check Date: Tue, 6 Oct 2020 08:58:46 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) The error check for ValueObjectGet("return") is redundant, qemuAgentCommand already checked for us that the reply contains a "return" object. It does not guarantee, that it is an array. Use virJSONValueObjectGetArray that combines getting the object with checking for its type and return the more helpful of the two error messages. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Jonathon Jongsma --- src/qemu/qemu_agent.c | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index b314c610e7..8cd1aa6cb0 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -2213,13 +2213,7 @@ qemuAgentGetInterfaces(qemuAgentPtr agent, if (qemuAgentCommand(agent, cmd, &reply, agent->timeout) < 0) goto cleanup; =20 - if (!(ret_array =3D virJSONValueObjectGet(reply, "return"))) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("qemu agent didn't provide 'return' field")); - goto cleanup; - } - - if (!virJSONValueIsArray(ret_array)) { + if (!(ret_array =3D virJSONValueObjectGetArray(reply, "return"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("qemu agent didn't return an array of interfaces"= )); goto cleanup; --=20 2.26.2 From nobody Sat May 4 16:40:17 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=1601967676; cv=none; d=zohomail.com; s=zohoarc; b=MaWijXyvINzz1raS0oF0hX+scBo/9dohjZNOnzZY4Nn1o7KYW/4CYsznsjNkgHeD3QuYqJaJa5aWXIU4ukYs5GIX5hgvC7p7ujJKQS4bYyjPdlUidUV+zQwEeEkXA2a2Ma7PLofBvbY2XiM/0Lzrv+EH2OGxO2DfdaipHSAD3EM= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601967676; 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=lE8PmuC3MsTI2vgMaxOw/JVvbe2PJZTBcw3PbSo63GI=; b=Y+CejEAL24D3LuyUrcqO/blSgAnhYrBo6dwfg7PpClPJPlt+EOfFz0jNqdtrxrqqE1SaNKK6/ZxezsZE5Ovup8czdR5oXY/DQH22psAOzvtdyXbX16ib47k+Rc/HqdRih8CYURqgorFc7uIkhFN3YJ1gGlwhBOVFeLZOsE3xE3Y= 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 1601967676261824.8555628887223; Tue, 6 Oct 2020 00:01:16 -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-395-6EvjYw5wM7WQt6L2Pb2cBg-1; Tue, 06 Oct 2020 02:59:28 -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 0D3872FD0F; Tue, 6 Oct 2020 06:59:20 +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 DB1A01002C02; Tue, 6 Oct 2020 06:59:19 +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 A6C57181A870; Tue, 6 Oct 2020 06:59:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0966xBVr018684 for ; Tue, 6 Oct 2020 02:59:11 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5A03D5C221; Tue, 6 Oct 2020 06:59:11 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id D66935C1C4 for ; Tue, 6 Oct 2020 06:59:10 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601967675; 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=lE8PmuC3MsTI2vgMaxOw/JVvbe2PJZTBcw3PbSo63GI=; b=bdfI4cJqxJ314vAJj0DPDbEqIIGMpL5vCb9l9ab8Q+WN7LVjSdwz4Ouxo+bLXVN0E5mHpc TCxaXWb+otbRjJH61JeBAIDWczqVKrpxUWPeL0bhM4VRp9maNy1L+lTuZ7oJsckqq/yaUV ZrU9c6EkkNRITaXAe84EOC7u1s4BMq4= X-MC-Unique: 6EvjYw5wM7WQt6L2Pb2cBg-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 11/14] qemu: agent: use g_auto in qemuAgentGetInterfaces Date: Tue, 6 Oct 2020 08:58:47 +0200 Message-Id: <3b8dbe667909cd9eef6f8262b3efeb5a55ea55b8.1601967442.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Signed-off-by: J=C3=A1n Tomko Reviewed-by: Jonathon Jongsma --- src/qemu/qemu_agent.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index 8cd1aa6cb0..847300c86e 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -2197,12 +2197,12 @@ qemuAgentGetInterfaces(qemuAgentPtr agent, { int ret =3D -1; size_t i; - virJSONValuePtr cmd =3D NULL; - virJSONValuePtr reply =3D NULL; + g_autoptr(virJSONValue) cmd =3D NULL; + g_autoptr(virJSONValue) reply =3D NULL; virJSONValuePtr ret_array =3D NULL; size_t ifaces_count =3D 0; virDomainInterfacePtr *ifaces_ret =3D NULL; - virHashTablePtr ifaces_store =3D NULL; + g_autoptr(virHashTable) ifaces_store =3D NULL; =20 /* Hash table to handle the interface alias */ ifaces_store =3D virHashNew(NULL); @@ -2232,9 +2232,6 @@ qemuAgentGetInterfaces(qemuAgentPtr agent, ret =3D ifaces_count; =20 cleanup: - virJSONValueFree(cmd); - virJSONValueFree(reply); - virHashFree(ifaces_store); return ret; =20 error: --=20 2.26.2 From nobody Sat May 4 16:40:17 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=1601967571; cv=none; d=zohomail.com; s=zohoarc; b=SSQ7DVYzxPJu7ittsP2NGhD+hbTotjsyrqzWCTJsCnvjOFYWakjabNhpGtoOvyhWqK8QkbzfTF9HJA05FTqKQVRiQ2iHEcQJSL1UmHeacY31tIAM6NFNNll9dZ9jguQkDxH075WTGyx4KnR0SMXMyzhOxiIxrSOAI2eWoLg489A= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601967571; 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=qoON0JGNyK+wJJ3Cc20wF4y6OYldctS2pGLJnw4ccoI=; b=Sy0mpGVsAMvDvw8U30ZIm4BQhMeQdMBOA75kfo0PlUbbRn1QS5yE2Eo9D2P5FnsFPKt5x7V2P1w5lwfrW5Ib5bEZY63BgM3qDYb+G5j6aar1f3XrgZT8nxHurkZgz1ipuCsR6pHZ2Vx8DiCoUDa10Z0cq+id8C9pEkE+UYEWgeA= 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 1601967571710263.145012385581; Mon, 5 Oct 2020 23:59:31 -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-395-f4zVwfhrOOGFfoUoU_zurA-1; Tue, 06 Oct 2020 02:59:26 -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 5D916801AE5; Tue, 6 Oct 2020 06:59:21 +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 3CAD75D9D2; Tue, 6 Oct 2020 06:59:21 +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 0BCDD44A7F; Tue, 6 Oct 2020 06:59:21 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0966xFcc018709 for ; Tue, 6 Oct 2020 02:59:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id 112EE5C22B; Tue, 6 Oct 2020 06:59:15 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8CF545C1C4 for ; Tue, 6 Oct 2020 06:59:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601967569; 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=qoON0JGNyK+wJJ3Cc20wF4y6OYldctS2pGLJnw4ccoI=; b=IlDk5Logf8rKn8nF+Z87fx0tcAX0teXsMknVubh1/SPnhQkAy2w7JC6NFIHkuO6sdHBPM7 R8BnI8LIoygJ3dPXmtCs/DLYh/fFSGIeGZ79Ehy0bTVcVinbSRHQ6kjKKwbI9YsSVIQMRN 6/jHivbV1YQ+KwFj+FFNwyRRyyhIuSQ= X-MC-Unique: f4zVwfhrOOGFfoUoU_zurA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 12/14] qemu: agent: remove cleanup in qemuAgentGetInterfaces Date: Tue, 6 Oct 2020 08:58:48 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Signed-off-by: J=C3=A1n Tomko Reviewed-by: Jonathon Jongsma --- src/qemu/qemu_agent.c | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index 847300c86e..210b308610 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -2195,7 +2195,6 @@ int qemuAgentGetInterfaces(qemuAgentPtr agent, virDomainInterfacePtr **ifaces) { - int ret =3D -1; size_t i; g_autoptr(virJSONValue) cmd =3D NULL; g_autoptr(virJSONValue) reply =3D NULL; @@ -2208,15 +2207,15 @@ qemuAgentGetInterfaces(qemuAgentPtr agent, ifaces_store =3D virHashNew(NULL); =20 if (!(cmd =3D qemuAgentMakeCommand("guest-network-get-interfaces", NUL= L))) - goto cleanup; + return -1; =20 if (qemuAgentCommand(agent, cmd, &reply, agent->timeout) < 0) - goto cleanup; + return -1; =20 if (!(ret_array =3D virJSONValueObjectGetArray(reply, "return"))) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("qemu agent didn't return an array of interfaces"= )); - goto cleanup; + return -1; } =20 for (i =3D 0; i < virJSONValueArraySize(ret_array); i++) { @@ -2229,10 +2228,7 @@ qemuAgentGetInterfaces(qemuAgentPtr agent, } =20 *ifaces =3D g_steal_pointer(&ifaces_ret); - ret =3D ifaces_count; - - cleanup: - return ret; + return ifaces_count; =20 error: if (ifaces_ret) { @@ -2240,7 +2236,7 @@ qemuAgentGetInterfaces(qemuAgentPtr agent, virDomainInterfaceFree(ifaces_ret[i]); } VIR_FREE(ifaces_ret); - goto cleanup; + return -1; } =20 =20 --=20 2.26.2 From nobody Sat May 4 16:40:17 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=1601967616; cv=none; d=zohomail.com; s=zohoarc; b=TqonJTRQSECz4GELopAoYGu8IRfr07sBJc/qVqATtUdfxMRnChvMlOraaNT4ZSDY3f35BPB6gTggDuylmVlfOmFroyYphngjp5uIV1P8v+wym27vW+bQQHfthMcm/O0H7P0hQ8K1RRIQ1wUNp3sEjO9ER6uGeWWl+1dSJAOYLYk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601967616; 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=yWt58QzV/z4W+yCFqqSpu2uh8l0cn83gxnaNi2vWBE8=; b=Dq35KnFq3zOG9AyWU5bbm9072pEVA2UuzAzKPNzYlq3zKsnJq9bRCjeXEwcE9JkaE1bXQI9c8lZ18RREqoxs/UXcNx9E0l55ph9HfIpPlRgrC8XwGdHjmrZ/nglHHpsJL12dbo3et6NmatClC9xNIWgdkgitM1MC15TGHYAIfNM= 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 160196761637351.292005258876316; Tue, 6 Oct 2020 00:00:16 -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-13-PDJN2cWuOuSodXiDxEaXOA-1; Tue, 06 Oct 2020 02:59:31 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 93AE32FD0C; Tue, 6 Oct 2020 06:59:22 +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 72C8160BFA; Tue, 6 Oct 2020 06:59:22 +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 40E1C181A88C; Tue, 6 Oct 2020 06:59:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0966xFUK018715 for ; Tue, 6 Oct 2020 02:59:15 -0400 Received: by smtp.corp.redhat.com (Postfix) id D5EEB5C22B; Tue, 6 Oct 2020 06:59:15 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5DB765C1C4 for ; Tue, 6 Oct 2020 06:59:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601967615; 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=yWt58QzV/z4W+yCFqqSpu2uh8l0cn83gxnaNi2vWBE8=; b=dSwCNCZEB4oAppQjNm1z/YJnSfMlv21TWMPe4iLPgeT3bta0FK3Oe2Rr+10OCcmX2XdBjk kQHU0FMjSNUQNDwKVPPLZkcS5PbUQKnFSwKvaqMKdAMUu5v5ydaZL8C93V6hcD45zwwP3s 0L70eTDzQI0BrTFWAhI4GuN4Z7MtVLg= X-MC-Unique: PDJN2cWuOuSodXiDxEaXOA-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 13/14] qemuAgentGetInterfaceAddresses: turn ifname into char* Date: Tue, 6 Oct 2020 08:58:49 +0200 Message-Id: <367b390e3b452581aebf42702794ac02bc886484.1601967442.git.jtomko@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.12 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) We only care about the first part of the 'ifname' string, splitting it is overkill. Instead, just replace the ':' with a '\0' in a copy of the string. This reduces the count of the varaibles containing some form of the interface name to two. Signed-off-by: J=C3=A1n Tomko Reviewed-by: Jonathon Jongsma --- src/qemu/qemu_agent.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index 210b308610..b6c37b6b0d 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -2111,9 +2111,9 @@ qemuAgentGetInterfaceAddresses(virDomainInterfacePtr = **ifaces_ret, virJSONValuePtr tmp_iface) { virJSONValuePtr ip_addr_arr =3D NULL; - const char *hwaddr, *ifname_s, *name =3D NULL; + const char *hwaddr, *name =3D NULL; virDomainInterfacePtr iface =3D NULL; - g_auto(GStrv) ifname =3D NULL; + g_autofree char *ifname =3D NULL; size_t addrs_count =3D 0; size_t j; =20 @@ -2126,10 +2126,9 @@ qemuAgentGetInterfaceAddresses(virDomainInterfacePtr= **ifaces_ret, } =20 /* Handle interface alias (:) */ - ifname =3D virStringSplit(name, ":", 2); - ifname_s =3D ifname[0]; + ifname =3D g_strdelimit(g_strdup(name), ":", '\0'); =20 - iface =3D virHashLookup(ifaces_store, ifname_s); + iface =3D virHashLookup(ifaces_store, ifname); =20 /* If the hash table doesn't contain this iface, add it */ if (!iface) { @@ -2139,11 +2138,11 @@ qemuAgentGetInterfaceAddresses(virDomainInterfacePt= r **ifaces_ret, iface =3D g_new0(virDomainInterface, 1); (*ifaces_ret)[*ifaces_count - 1] =3D iface; =20 - if (virHashAddEntry(ifaces_store, ifname_s, iface) < 0) + if (virHashAddEntry(ifaces_store, ifname, iface) < 0) return -1; =20 iface->naddrs =3D 0; - iface->name =3D g_strdup(ifname_s); + iface->name =3D g_strdup(ifname); =20 hwaddr =3D virJSONValueObjectGetString(tmp_iface, "hardware-addres= s"); iface->hwaddr =3D g_strdup(hwaddr); --=20 2.26.2 From nobody Sat May 4 16:40:17 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=1601967613; cv=none; d=zohomail.com; s=zohoarc; b=b7Qei+UNNQ7kXX6I/eUwbR6Df2Eoiyjso99JXo+0c5LKs7f4p9CsyyFALP5EUU+D4+SvLgG3YaBiKHVCsrx0flhOnMZPKtbDAqNjRkAGnzWf2VKHMnZ/lbpyEDw5uBW6xRQNOR/mCZ09qI5KenlrKUT4sRf9BBhsE3uA78hJGe8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1601967613; 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=QnGsM51H6+0zl6fi052GQbP2ALEkTTmHsUAPYvzSJ44=; b=VkYT6x/H2X1a61oryZo8J4z0RC8nt/jZxQZcZ/iHgmj3xtykF3Z9PbfLJne1e78YgZ8GGq1f1kj04JZpSecapOXYQE7eN5eQ6P2cURWnJGNQglTVlwmK1pmbUyTzYCqcr8mVx7IK615r9gpdQ1pxZ4lnXrlyVn852qGPnBVzKlA= 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 1601967613042921.8054678228016; Tue, 6 Oct 2020 00:00:13 -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-578-kRl9FJhvMHOirHNzVNLiuQ-1; Tue, 06 Oct 2020 02:59:30 -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 6FB11805EE2; Tue, 6 Oct 2020 06:59:24 +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 423103782; Tue, 6 Oct 2020 06:59:24 +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 01FE4181A89E; Tue, 6 Oct 2020 06:59:24 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0966xGgj018725 for ; Tue, 6 Oct 2020 02:59:16 -0400 Received: by smtp.corp.redhat.com (Postfix) id A643C5C22B; Tue, 6 Oct 2020 06:59:16 +0000 (UTC) Received: from hjs.redhat.com (unknown [10.43.2.12]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2E3CB5C1C4 for ; Tue, 6 Oct 2020 06:59:16 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1601967611; 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=QnGsM51H6+0zl6fi052GQbP2ALEkTTmHsUAPYvzSJ44=; b=ibMsd/BAdrMmhb4i1acHalJlyC3CnlroTiAudxQK3a2vrBcVjFQ/vH1Z2Fuwens6hki1hl YEzTV0DoyO6d08/J2je6OxwodYzCzVfQffUma4XwPRvJGCOvjeApBXPUq1kiMRYyMRL2uP Hob71esoffhpwZIY2qvDdxuwf6Yn/Qw= X-MC-Unique: kRl9FJhvMHOirHNzVNLiuQ-1 From: =?UTF-8?q?J=C3=A1n=20Tomko?= To: libvir-list@redhat.com Subject: [libvirt PATCH 14/14] qemu: agent: rename tmp_iface to iface_obj Date: Tue, 6 Oct 2020 08:58:50 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Signed-off-by: J=C3=A1n Tomko Reviewed-by: Jonathon Jongsma --- src/qemu/qemu_agent.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_agent.c b/src/qemu/qemu_agent.c index b6c37b6b0d..3de951fc97 100644 --- a/src/qemu/qemu_agent.c +++ b/src/qemu/qemu_agent.c @@ -2108,7 +2108,7 @@ static int qemuAgentGetInterfaceAddresses(virDomainInterfacePtr **ifaces_ret, size_t *ifaces_count, virHashTablePtr ifaces_store, - virJSONValuePtr tmp_iface) + virJSONValuePtr iface_obj) { virJSONValuePtr ip_addr_arr =3D NULL; const char *hwaddr, *name =3D NULL; @@ -2118,7 +2118,7 @@ qemuAgentGetInterfaceAddresses(virDomainInterfacePtr = **ifaces_ret, size_t j; =20 /* interface name is required to be presented */ - name =3D virJSONValueObjectGetString(tmp_iface, "name"); + name =3D virJSONValueObjectGetString(iface_obj, "name"); if (!name) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("qemu agent didn't provide 'name' field")); @@ -2144,13 +2144,13 @@ qemuAgentGetInterfaceAddresses(virDomainInterfacePt= r **ifaces_ret, iface->naddrs =3D 0; iface->name =3D g_strdup(ifname); =20 - hwaddr =3D virJSONValueObjectGetString(tmp_iface, "hardware-addres= s"); + hwaddr =3D virJSONValueObjectGetString(iface_obj, "hardware-addres= s"); iface->hwaddr =3D g_strdup(hwaddr); } =20 /* as well as IP address which - moreover - * can be presented multiple times */ - ip_addr_arr =3D virJSONValueObjectGet(tmp_iface, "ip-addresses"); + ip_addr_arr =3D virJSONValueObjectGet(iface_obj, "ip-addresses"); if (!ip_addr_arr) return 0; =20 @@ -2218,10 +2218,10 @@ qemuAgentGetInterfaces(qemuAgentPtr agent, } =20 for (i =3D 0; i < virJSONValueArraySize(ret_array); i++) { - virJSONValuePtr tmp_iface =3D virJSONValueArrayGet(ret_array, i); + virJSONValuePtr iface_obj =3D virJSONValueArrayGet(ret_array, i); =20 if (qemuAgentGetInterfaceAddresses(&ifaces_ret, &ifaces_count, - ifaces_store, tmp_iface) < 0) + ifaces_store, iface_obj) < 0) goto error; =20 } --=20 2.26.2