From nobody Mon Apr 29 11:22:13 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1568923520; cv=none; d=zoho.com; s=zohoarc; b=d2JJGifjg8/TVKpIHcJ8jTfHBOmIHxVeC8igibka1NhUhJbUACPRPTCX5unm7yvFxiSxdi7VnlkgYkjf5JWg6ynaxElxiFmOPYrl9tmrAUxyDpyCqpySLDbawt/SKwd1idDvT772TMQ4Tn6ojDvh8JRi2yPoMO0Axg/kxLZYK/4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568923520; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=2Pal3pc2bXvAWcMl2BrznHD3E879OP0dG8nrW2ixMxw=; b=cqJlQ7D+ZVVfskD7iJk2w9b9WpBagMH5TFrbEXkYMmDqzS0OFtfxVlYcakEHWskUFFifGUAohcUXhoaCU9SbRdEc8bAvirL527DaRFUtNgRv+fOBM5FvTGsE3ytxEV2n9DG/FDovVZNo6SX8Eo/6Z3xd1jwHtOTgkaNmPNT1Eb4= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1568923520596370.0787543483722; Thu, 19 Sep 2019 13:05:20 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 066CF18CB8F7; Thu, 19 Sep 2019 20:05:11 +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 ABB275D6C8; Thu, 19 Sep 2019 20:05:07 +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 463B04E58A; Thu, 19 Sep 2019 20:05:04 +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 x8JK52Mx016818 for ; Thu, 19 Sep 2019 16:05:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7700A60467; Thu, 19 Sep 2019 20:05:02 +0000 (UTC) Received: from mx1.redhat.com (ext-mx18.extmail.prod.ext.phx2.redhat.com [10.5.110.47]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 65DB36031F for ; Thu, 19 Sep 2019 20:04:59 +0000 (UTC) Received: from mail-qt1-f176.google.com (mail-qt1-f176.google.com [209.85.160.176]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EAB39308212D for ; Thu, 19 Sep 2019 20:04:58 +0000 (UTC) Received: by mail-qt1-f176.google.com with SMTP id u22so5808673qtq.13 for ; Thu, 19 Sep 2019 13:04:58 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c6:df05:2a1f:6ce3:83c3:51c0]) by smtp.gmail.com with ESMTPSA id a3sm5162462qtn.97.2019.09.19.13.04.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Sep 2019 13:04:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7HkhIZm54+tZdy/YYA03KOV8hL57fQ7mxQCQXDC7Vn0=; b=ka75uZ0CyftEerOwFS8MfM4k7RcK0J7P9u4C6gRtwhcvXChDztNjrSpO2o+gtdbOYU H0Wgruqqqc99hWRvWTWj1hdBB+xAftHA7AAPZ7WV2cjAYYb1d5ll27bmoyEJbsF14FtX u+m7Rcee3n3iAZhv5FrTYmmQa/impStnhXUI2xiCnAxAAjNj1dWkTS6m9ID7Es1hdg6j z4XTO/xi+igo3sV4YURYYaHWC+0+VjBI+Yh76ffdi8zh1txQOjGXd4U2ddwNG4iK/WXl jgTNJMUhSnUi1PjVWtXkuI1yFZlYbSySnxzcSgVLHh3LFq0PaehLGVhhSnVRzZIC9heg +kLw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7HkhIZm54+tZdy/YYA03KOV8hL57fQ7mxQCQXDC7Vn0=; b=UMGW9WEMuwLUwpH1SpfTzFw+AtHbJKu1isVCCcoCaQxI0WBHMvGSUEzjkr1tFxqlAB cjJT6DhMCs2RBUchBGYGdVzKOX4kyWoF03n5r1srEuuWXLhBAbv7ABV2iSnJ1rv47jxE w2lDgXXNhAvKTk8AJDSz6hQqwmFkxkvvT1xKLHd5Ph9mO6N3DvrpXcvosRbMHViojmQv 3snOyVKi3xgdLdh+a+1U83m9d/B19RWCKJOPofEOOow/EzosvkI3mFM5nYVwBzuK8keA yBlqEYE1p+41gCuJRhlrJGVTn3SE3A2gK5Sw4DdqRqavVhUn5hmEixmnoYZuMxXhtCiA hsCg== X-Gm-Message-State: APjAAAUd6rqNdY3JHjXRxx9skjlCvoCP7MpdMW0dG0IBGKvbWVdgmBWE mdst+8+d4aEvEsKkN9MW1B+5haSv X-Google-Smtp-Source: APXvYqx3iMUh+Igfn7Ji9zEb1NefXXN91H7E4FfUXbuebNSb5Qv71rwjxYANi3k0fnkpQKF9NcIDVQ== X-Received: by 2002:ad4:4469:: with SMTP id s9mr9676200qvt.109.1568923497952; Thu, 19 Sep 2019 13:04:57 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Date: Thu, 19 Sep 2019 17:04:46 -0300 Message-Id: <20190919200447.7653-2-danielhb413@gmail.com> In-Reply-To: <20190919200447.7653-1-danielhb413@gmail.com> References: <20190919200447.7653-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Thu, 19 Sep 2019 20:04:59 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.47]); Thu, 19 Sep 2019 20:04:59 +0000 (UTC) for IP:'209.85.160.176' DOMAIN:'mail-qt1-f176.google.com' HELO:'mail-qt1-f176.google.com' FROM:'danielhb413@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.15 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS) 209.85.160.176 mail-qt1-f176.google.com 209.85.160.176 mail-qt1-f176.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.47 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza Subject: [libvirt] [PATCH 1/2] qemu_domain_address.c: use VIR_AUTOFREE() in strings 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.63]); Thu, 19 Sep 2019 20:05:18 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" A few 'cleanup' labels gone after using VIR_AUTOFREE() in the strings. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Erik Skultety --- src/qemu/qemu_domain_address.c | 69 +++++++++++++++------------------- 1 file changed, 30 insertions(+), 39 deletions(-) diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index 216ba6235e..e20481607f 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -1524,12 +1524,11 @@ qemuDomainCollectPCIAddress(virDomainDefPtr def ATT= RIBUTE_UNUSED, * inappropriate address types. */ if (!info->pciConnectFlags) { - char *addrStr =3D virPCIDeviceAddressAsString(&info->addr.pci); + VIR_AUTOFREE(char *) addrStr =3D virPCIDeviceAddressAsString(&info= ->addr.pci); =20 VIR_WARN("qemuDomainDeviceCalculatePCIConnectFlags() thinks that t= he " "device with PCI address %s should not have a PCI address= ", addrStr ? addrStr : "(unknown)"); - VIR_FREE(addrStr); =20 info->pciConnectFlags =3D VIR_PCI_CONNECT_TYPE_PCI_DEVICE; } @@ -1720,11 +1719,10 @@ qemuDomainValidateDevicePCISlotsPIIX3(virDomainDefP= tr def, virQEMUCapsPtr qemuCaps, virDomainPCIAddressSetPtr addrs) { - int ret =3D -1; size_t i; virPCIDeviceAddress tmp_addr; bool qemuDeviceVideoUsable =3D virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVI= CE_VIDEO_PRIMARY); - char *addrStr =3D NULL; + VIR_AUTOFREE(char *) addrStr =3D NULL; virDomainPCIConnectFlags flags =3D (VIR_PCI_CONNECT_HOTPLUGGABLE | VIR_PCI_CONNECT_TYPE_PCI_DEVICE); =20 @@ -1742,7 +1740,7 @@ qemuDomainValidateDevicePCISlotsPIIX3(virDomainDefPtr= def, cont->info.addr.pci.function !=3D 1) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Primary IDE controller must have PCI= address 0:0:1.1")); - goto cleanup; + return -1; } } else { cont->info.type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; @@ -1762,7 +1760,7 @@ qemuDomainValidateDevicePCISlotsPIIX3(virDomainDefPtr= def, cont->info.addr.pci.function !=3D 2) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("PIIX3 USB controller at index 0 must= have PCI address 0:0:1.2")); - goto cleanup; + return -1; } } else { cont->info.type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; @@ -1777,7 +1775,7 @@ qemuDomainValidateDevicePCISlotsPIIX3(virDomainDefPtr= def, } if (addrs->nbuses && virDomainPCIAddressReserveAddr(addrs, &cont->info.addr.pci, fl= ags, 0) < 0) - goto cleanup; + return -1; } =20 /* Implicit PIIX3 devices living on slot 1 not handled above */ @@ -1786,11 +1784,11 @@ qemuDomainValidateDevicePCISlotsPIIX3(virDomainDefP= tr def, tmp_addr.slot =3D 1; /* ISA Bridge at 00:01.0 */ if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags, 0) < 0) - goto cleanup; + return -1; /* Bridge at 00:01.3 */ tmp_addr.function =3D 3; if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags, 0) < 0) - goto cleanup; + return -1; } =20 if (def->nvideos > 0 && @@ -1808,26 +1806,26 @@ qemuDomainValidateDevicePCISlotsPIIX3(virDomainDefP= tr def, tmp_addr.slot =3D 2; =20 if (!(addrStr =3D virPCIDeviceAddressAsString(&tmp_addr))) - goto cleanup; + return -1; if (!virDomainPCIAddressValidate(addrs, &tmp_addr, addrStr, flags, true)) - goto cleanup; + return -1; =20 if (virDomainPCIAddressSlotInUse(addrs, &tmp_addr)) { if (qemuDeviceVideoUsable) { if (qemuDomainPCIAddressReserveNextAddr(addrs, &primaryVideo-= >info) < 0) { - goto cleanup; + return -1; } } else { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("PCI address 0:0:2.0 is in use, " "QEMU needs it for primary video")); - goto cleanup; + return -1; } } else { if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags= , 0) < 0) - goto cleanup; + return -1; primaryVideo->info.addr.pci =3D tmp_addr; primaryVideo->info.type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE= _PCI; } @@ -1838,7 +1836,7 @@ qemuDomainValidateDevicePCISlotsPIIX3(virDomainDefPtr= def, primaryVideo->info.addr.pci.function !=3D 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Primary video card must have PCI address= 0:0:2.0")); - goto cleanup; + return -1; } /* If TYPE =3D=3D PCI, then qemuDomainCollectPCIAddress() func= tion * has already reserved the address, so we must skip */ @@ -1852,13 +1850,10 @@ qemuDomainValidateDevicePCISlotsPIIX3(virDomainDefP= tr def, " device will not be possible without manual" " intervention"); } else if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags,= 0) < 0) { - goto cleanup; + return -1; } } - ret =3D 0; - cleanup: - VIR_FREE(addrStr); - return ret; + return 0; } =20 =20 @@ -1867,11 +1862,10 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr= def, virQEMUCapsPtr qemuCaps, virDomainPCIAddressSetPtr addrs) { - int ret =3D -1; size_t i; virPCIDeviceAddress tmp_addr; bool qemuDeviceVideoUsable =3D virQEMUCapsGet(qemuCaps, QEMU_CAPS_DEVI= CE_VIDEO_PRIMARY); - char *addrStr =3D NULL; + VIR_AUTOFREE(char *) addrStr =3D NULL; virDomainPCIConnectFlags flags =3D VIR_PCI_CONNECT_TYPE_PCIE_DEVICE; =20 for (i =3D 0; i < def->ncontrollers; i++) { @@ -1891,7 +1885,7 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr d= ef, cont->info.addr.pci.function !=3D 2) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Primary SATA controller must hav= e PCI address 0:0:1f.2")); - goto cleanup; + return -1; } } else { cont->info.type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; @@ -1928,7 +1922,7 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr d= ef, } if (assign) { if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, f= lags, 0) < 0) - goto cleanup; + return -1; =20 cont->info.type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; cont->info.addr.pci.domain =3D 0; @@ -1951,7 +1945,7 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr d= ef, tmp_addr.slot =3D 0x1E; if (!virDomainPCIAddressSlotInUse(addrs, &tmp_addr)) { if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, f= lags, 0) < 0) - goto cleanup; + return -1; =20 cont->info.type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; cont->info.addr.pci.domain =3D 0; @@ -1975,12 +1969,12 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr= def, tmp_addr.function =3D 0; tmp_addr.multi =3D VIR_TRISTATE_SWITCH_ON; if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags, 0) < 0) - goto cleanup; + return -1; =20 tmp_addr.function =3D 3; tmp_addr.multi =3D VIR_TRISTATE_SWITCH_ABSENT; if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags, 0) < 0) - goto cleanup; + return -1; } =20 if (def->nvideos > 0 && @@ -1997,25 +1991,25 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr= def, tmp_addr.slot =3D 1; =20 if (!(addrStr =3D virPCIDeviceAddressAsString(&tmp_addr))) - goto cleanup; + return -1; if (!virDomainPCIAddressValidate(addrs, &tmp_addr, addrStr, flags, true)) - goto cleanup; + return -1; =20 if (virDomainPCIAddressSlotInUse(addrs, &tmp_addr)) { if (qemuDeviceVideoUsable) { if (qemuDomainPCIAddressReserveNextAddr(addrs, &primaryVideo-= >info) < 0) - goto cleanup; + return -1; } else { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("PCI address 0:0:1.0 is in use, " "QEMU needs it for primary video")); - goto cleanup; + return -1; } } else { if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags= , 0) < 0) - goto cleanup; + return -1; primaryVideo->info.type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE= _PCI; primaryVideo->info.addr.pci =3D tmp_addr; } @@ -2026,7 +2020,7 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr d= ef, primaryVideo->info.addr.pci.function !=3D 0) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Primary video card must have PCI address= 0:0:1.0")); - goto cleanup; + return -1; } /* If TYPE =3D=3D PCI, then qemuDomainCollectPCIAddress() func= tion * has already reserved the address, so we must skip */ @@ -2041,7 +2035,7 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr d= ef, " intervention"); virResetLastError(); } else if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags,= 0) < 0) { - goto cleanup; + return -1; } } =20 @@ -2062,7 +2056,7 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr d= ef, continue; } if (virDomainPCIAddressReserveAddr(addrs, &tmp_addr, flags, 0)= < 0) - goto cleanup; + return -1; =20 sound->info.type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; sound->info.addr.pci =3D tmp_addr; @@ -2070,10 +2064,7 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr = def, } } =20 - ret =3D 0; - cleanup: - VIR_FREE(addrStr); - return ret; + return 0; } =20 =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Mon Apr 29 11:22:14 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1568923532; cv=none; d=zoho.com; s=zohoarc; b=gvhbgWBKj97Tdcsnroozz+MSUJnL8hFLlmnLuGv2O7hYGAh2EqDDAmHIVzDD/cz0PVZRbe5AL/VWIAUhMODYPm06Aq+PAfoEaCpmxxjMK/2mVMUS5xGEJoGWHk/jgvGj9DsiddIHBr8iDijWjo5UA+EPB7ThKHH3Ait5n8P5nQk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1568923532; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=zffU3q62RoM16hz0U5Qd525Dw77wBPr/27Vcew6+M7s=; b=SAJnYZOXmGEVDDrNA5m4nyVDiH/QAEtH+hr4AGKmCX4dvvxbsgrYx3GdcCzhG5MJKjCcHPG66iCg01GaCJMaozG6Txkf4SUeDlDD1yinilOjnTsh7rht9LHZtfLJIsP/mwBJj5T7TSjUL800fZt9f3BvlNYCKZypIgQCsAglooU= ARC-Authentication-Results: i=1; mx.zoho.com; dkim=fail; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1568923532002645.0312136574912; Thu, 19 Sep 2019 13:05:32 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 5593010C0516; Thu, 19 Sep 2019 20:05:29 +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 1D0C65D6B2; Thu, 19 Sep 2019 20:05:29 +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 DA4724EDA5; Thu, 19 Sep 2019 20:05:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x8JK56KI016838 for ; Thu, 19 Sep 2019 16:05:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id AC77319C5B; Thu, 19 Sep 2019 20:05:06 +0000 (UTC) Received: from mx1.redhat.com (ext-mx16.extmail.prod.ext.phx2.redhat.com [10.5.110.45]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 9C5ED450F for ; Thu, 19 Sep 2019 20:05:03 +0000 (UTC) Received: from mail-qk1-f177.google.com (mail-qk1-f177.google.com [209.85.222.177]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0227F300BEA2 for ; Thu, 19 Sep 2019 20:05:01 +0000 (UTC) Received: by mail-qk1-f177.google.com with SMTP id u184so4777147qkd.4 for ; Thu, 19 Sep 2019 13:05:00 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c6:df05:2a1f:6ce3:83c3:51c0]) by smtp.gmail.com with ESMTPSA id a3sm5162462qtn.97.2019.09.19.13.04.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 19 Sep 2019 13:04:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=rrQ0SFJdKwlNLDLg19tbf9edSIN6V9pmtSplx1YE6CA=; b=CiCrh1S78uOJOlTrDI/OpMkEdCoj8vpFnk1rbVs+zcJOuaUjGQh8vmsNW9supmbwmx j8q/LejMb4zPQYv2WDh2haZpivfJN5Gxln7SF5vNsu8pDZaH1LxklaIS4dxPYyHh3MjH OsNZozG1hFqeqVTVyA94wtGT18Yrq0L/AGKhUrPLXeMANX9qpni6Jnz3gtoQDcBwOwaN S8AZcCebT8YmbVvVZXJoMwVM8RfPjreVf6vtmsSVTBV7SgEZuzclbmawS/X6oMerZ83f TZM3Oeh8jyVkmGoi8K0laTxtORrYaliBqQhiSM8CSMOCe14dZzQRNNEMSRcZOK8pwGBB N/ew== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=rrQ0SFJdKwlNLDLg19tbf9edSIN6V9pmtSplx1YE6CA=; b=AGPsdaBiw3oKzsomXcpd54msVEH4CcUw/kgZGOHGVrHsm0rdgfnHHQFknANPIHTlbU YTp6hW/212hThAliGSk48mDwW6wgbVhxumehedw89rXFoEDYuNs7IJIuD+ZCX7vfo/cM lG9i716tLSfdXoAFmaHt/s0J3Ej5px2GoLiMklmzbYtdjxNUhlnBjcmM8IP4WsRFc39T SSWAHCDcDa07gbUO65hqDZFSUvT7AzKuIOYk9I3RdhUzM14GT0toKiBf4SvBzEbqTztW ZcoOL58OUF1X95kiP3TQx6Bju4zi90PXQkf5LcibcwLnJvwTPvOwo1yPGfvTrbfUNQoJ 1Udg== X-Gm-Message-State: APjAAAVMxwQa0WK9bmMRAgFKUn9847vTnZy5tN4Ulj3Kkaj8J5FCAF9n XEM+yMYOP4BSXkkIvNNMjTEaRiJV X-Google-Smtp-Source: APXvYqyOqzBHtZRbpacy+ulBvCz5B9eSHq7M3UK5on5WCXEtuNAENKSUvHF/MZThbOo1nbthTiyXOg== X-Received: by 2002:a05:620a:5a8:: with SMTP id q8mr4763510qkq.453.1568923500082; Thu, 19 Sep 2019 13:05:00 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Date: Thu, 19 Sep 2019 17:04:47 -0300 Message-Id: <20190919200447.7653-3-danielhb413@gmail.com> In-Reply-To: <20190919200447.7653-1-danielhb413@gmail.com> References: <20190919200447.7653-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Thu, 19 Sep 2019 20:05:01 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.45]); Thu, 19 Sep 2019 20:05:01 +0000 (UTC) for IP:'209.85.222.177' DOMAIN:'mail-qk1-f177.google.com' HELO:'mail-qk1-f177.google.com' FROM:'danielhb413@gmail.com' RCPT:'' X-RedHat-Spam-Score: 0.15 (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS) 209.85.222.177 mail-qk1-f177.google.com 209.85.222.177 mail-qk1-f177.google.com X-Scanned-By: MIMEDefang 2.84 on 10.5.110.45 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza Subject: [libvirt] [PATCH 2/2] virpci, qemu_domain_address: adding virPCIDeviceSetAddress 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: , Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.6.2 (mx1.redhat.com [10.5.110.65]); Thu, 19 Sep 2019 20:05:30 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) Content-Type: text/plain; charset="utf-8" A common operation in qemu_domain_address is comparing a virPCIDeviceAddress and assigning domain, bus, slot and function to a specific value. The former can be done with the existing virPCIDeviceAddressEqual() helper. A new virpci helper called virPCIDeviceSetAddress() was created to make it easier to assign the same domain/bus/slot/function of an already existent virPCIDeviceAddress. Using both in qemu_domain_address made the code tidier, since the object was already created to use virPCIDeviceAddressEqual(). Signed-off-by: Daniel Henrique Barboza --- I wasn't sure if this change was worth contributing it back, since it feels more like a 'look and feel' change. But since it made the code inside qemu_domain_address tidier,=20 I decided to take a shot. src/libvirt_private.syms | 1 + src/qemu/qemu_domain_address.c | 57 ++++++++++++++++------------------ src/util/virpci.c | 10 ++++++ src/util/virpci.h | 3 ++ 4 files changed, 40 insertions(+), 31 deletions(-) diff --git a/src/libvirt_private.syms b/src/libvirt_private.syms index 39812227aa..e878494d3e 100644 --- a/src/libvirt_private.syms +++ b/src/libvirt_private.syms @@ -2697,6 +2697,7 @@ virPCIDeviceNew; virPCIDeviceReattach; virPCIDeviceRebind; virPCIDeviceReset; +virPCIDeviceSetAddress; virPCIDeviceSetManaged; virPCIDeviceSetRemoveSlot; virPCIDeviceSetReprobe; diff --git a/src/qemu/qemu_domain_address.c b/src/qemu/qemu_domain_address.c index e20481607f..8eb1f0656f 100644 --- a/src/qemu/qemu_domain_address.c +++ b/src/qemu/qemu_domain_address.c @@ -1729,45 +1729,41 @@ qemuDomainValidateDevicePCISlotsPIIX3(virDomainDefP= tr def, /* Verify that first IDE and USB controllers (if any) is on the PIIX3,= fn 1 */ for (i =3D 0; i < def->ncontrollers; i++) { virDomainControllerDefPtr cont =3D def->controllers[i]; + virPCIDeviceAddress primaryIDEAddr =3D {.domain =3D 0, .bus =3D 0, + .slot =3D 1, .function =3D 1= }; + virPCIDeviceAddress piix3USBAddr =3D {.domain =3D 0, .bus =3D 0, + .slot =3D 1, .function =3D 2}; =20 /* First IDE controller lives on the PIIX3 at slot=3D1, function= =3D1 */ if (cont->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_IDE && cont->idx =3D=3D 0) { if (virDeviceInfoPCIAddressIsPresent(&cont->info)) { - if (cont->info.addr.pci.domain !=3D 0 || - cont->info.addr.pci.bus !=3D 0 || - cont->info.addr.pci.slot !=3D 1 || - cont->info.addr.pci.function !=3D 1) { + if (!virPCIDeviceAddressEqual(&cont->info.addr.pci, + &primaryIDEAddr)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Primary IDE controller must have PCI= address 0:0:1.1")); + _("Primary IDE controller must have PCI= " + "address 0:0:1.1")); return -1; } } else { cont->info.type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; - cont->info.addr.pci.domain =3D 0; - cont->info.addr.pci.bus =3D 0; - cont->info.addr.pci.slot =3D 1; - cont->info.addr.pci.function =3D 1; + virPCIDeviceSetAddress(&cont->info.addr.pci, &primaryIDEAd= dr); } } else if (cont->type =3D=3D VIR_DOMAIN_CONTROLLER_TYPE_USB && cont->idx =3D=3D 0 && (cont->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_USB_PII= X3_UHCI || cont->model =3D=3D VIR_DOMAIN_CONTROLLER_MODEL_USB_DEF= AULT)) { if (virDeviceInfoPCIAddressIsPresent(&cont->info)) { - if (cont->info.addr.pci.domain !=3D 0 || - cont->info.addr.pci.bus !=3D 0 || - cont->info.addr.pci.slot !=3D 1 || - cont->info.addr.pci.function !=3D 2) { + if (!virPCIDeviceAddressEqual(&cont->info.addr.pci, + &piix3USBAddr)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("PIIX3 USB controller at index 0 must= have PCI address 0:0:1.2")); + _("PIIX3 USB controller at index 0 must= " + "have PCI address 0:0:1.2")); return -1; } } else { cont->info.type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; - cont->info.addr.pci.domain =3D 0; - cont->info.addr.pci.bus =3D 0; - cont->info.addr.pci.slot =3D 1; - cont->info.addr.pci.function =3D 2; + virPCIDeviceSetAddress(&cont->info.addr.pci, &piix3USBAddr= ); } } else { /* this controller is not skipped in qemuDomainCollectPCIAddre= ss */ @@ -1800,6 +1796,8 @@ qemuDomainValidateDevicePCISlotsPIIX3(virDomainDefPtr= def, * at slot 2. */ virDomainVideoDefPtr primaryVideo =3D def->videos[0]; + virPCIDeviceAddress primaryCardAddr =3D {.domain =3D 0, .bus =3D 0, + .slot =3D 2, .function =3D = 0}; =20 if (virDeviceInfoPCIAddressIsWanted(&primaryVideo->info)) { memset(&tmp_addr, 0, sizeof(tmp_addr)); @@ -1830,10 +1828,8 @@ qemuDomainValidateDevicePCISlotsPIIX3(virDomainDefPt= r def, primaryVideo->info.type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE= _PCI; } } else if (!qemuDeviceVideoUsable) { - if (primaryVideo->info.addr.pci.domain !=3D 0 || - primaryVideo->info.addr.pci.bus !=3D 0 || - primaryVideo->info.addr.pci.slot !=3D 2 || - primaryVideo->info.addr.pci.function !=3D 0) { + if (!virPCIDeviceAddressEqual(&primaryVideo->info.addr.pci, + &primaryCardAddr)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("Primary video card must have PCI address= 0:0:2.0")); return -1; @@ -1870,6 +1866,8 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr d= ef, =20 for (i =3D 0; i < def->ncontrollers; i++) { virDomainControllerDefPtr cont =3D def->controllers[i]; + virPCIDeviceAddress primarySATAAddr =3D {.domain =3D 0, .bus =3D 0, + .slot =3D 0x1F, .function = =3D 2}; =20 switch (cont->type) { case VIR_DOMAIN_CONTROLLER_TYPE_SATA: @@ -1879,20 +1877,17 @@ qemuDomainValidateDevicePCISlotsQ35(virDomainDefPtr= def, */ if (cont->idx =3D=3D 0) { if (virDeviceInfoPCIAddressIsPresent(&cont->info)) { - if (cont->info.addr.pci.domain !=3D 0 || - cont->info.addr.pci.bus !=3D 0 || - cont->info.addr.pci.slot !=3D 0x1F || - cont->info.addr.pci.function !=3D 2) { + if (!virPCIDeviceAddressEqual(&cont->info.addr.pci, + &primarySATAAddr)) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("Primary SATA controller must hav= e PCI address 0:0:1f.2")); + _("Primary SATA controller must hav= e " + "PCI address 0:0:1f.2")); return -1; } } else { cont->info.type =3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; - cont->info.addr.pci.domain =3D 0; - cont->info.addr.pci.bus =3D 0; - cont->info.addr.pci.slot =3D 0x1F; - cont->info.addr.pci.function =3D 2; + virPCIDeviceSetAddress(&cont->info.addr.pci, + &primarySATAAddr); } } break; diff --git a/src/util/virpci.c b/src/util/virpci.c index ee78151e74..12ec05ab9e 100644 --- a/src/util/virpci.c +++ b/src/util/virpci.c @@ -1483,6 +1483,16 @@ virPCIDeviceGetName(virPCIDevicePtr dev) return dev->name; } =20 +void +virPCIDeviceSetAddress(virPCIDeviceAddress *addr1, + const virPCIDeviceAddress *addr2) +{ + addr1->domain =3D addr2->domain; + addr1->bus =3D addr2->bus; + addr1->slot =3D addr2->slot; + addr1->function =3D addr2->function; +} + /** * virPCIDeviceGetConfigPath: * diff --git a/src/util/virpci.h b/src/util/virpci.h index dc20f91710..b192e1cf19 100644 --- a/src/util/virpci.h +++ b/src/util/virpci.h @@ -234,6 +234,9 @@ bool virPCIDeviceAddressIsEmpty(const virPCIDeviceAddre= ss *addr); bool virPCIDeviceAddressEqual(const virPCIDeviceAddress *addr1, const virPCIDeviceAddress *addr2); =20 +void virPCIDeviceSetAddress(virPCIDeviceAddress *addr1, + const virPCIDeviceAddress *addr2); + char *virPCIDeviceAddressAsString(const virPCIDeviceAddress *addr) ATTRIBUTE_NONNULL(1); =20 --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list