From nobody Sat May 4 09:27:58 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; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1606245670; cv=none; d=zohomail.com; s=zohoarc; b=aPFm6M5okOegkyNcNGd6eBLkevYmMx57RuPzYdgJciMdRKQlNhp2fiYDyUBM/P5qe+I42ZSBVASKnRdP7SwWINq+Cm1nz4rqf8DrZupKpzdVkJmhFPUURpgBLMvj/NgkvRQF4fx/4sHV8r53v1vJYh6yZqUdFjRJJqA7Pne+HMw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606245670; 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; bh=AkBDY1uDSrzxHgiVEiOXT6wK6R+s5GXidoxwjr/aX70=; b=AKQF40wteT30Fo7mfADJe4mO309xpkIC/cGmomhEVlJ+1LJkaq8mRrMcyrvtwmJrG32ibVZ7vWrQKUFa3+iBmjkcOE7TOkb+SR5VEXSe6Vu8XHI4h3nqno4i5jEyQVhUUVqOR2U2+73SRo3pXqnHqH247AOtyTVfnDrx42tGfqw= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail 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 1606245670209184.0993371894774; Tue, 24 Nov 2020 11:21:10 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-395-z0QgPgmTPI-6rcLwYMTmAg-1; Tue, 24 Nov 2020 14:21:06 -0500 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 9CCCE1009446; Tue, 24 Nov 2020 19:21:00 +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 47A875C1BD; Tue, 24 Nov 2020 19:21:00 +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 9CD12180954D; Tue, 24 Nov 2020 19:20:57 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0AOJKua9004045 for ; Tue, 24 Nov 2020 14:20:56 -0500 Received: by smtp.corp.redhat.com (Postfix) id 81B85110F0D4; Tue, 24 Nov 2020 19:20:56 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 7D311110F0D2 for ; Tue, 24 Nov 2020 19:20:55 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id CB57D800883 for ; Tue, 24 Nov 2020 19:20:55 +0000 (UTC) Received: from mail-qk1-f195.google.com (mail-qk1-f195.google.com [209.85.222.195]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-384-4yZoHmOXOa-4-WFnrjy9wA-1; Tue, 24 Nov 2020 14:20:53 -0500 Received: by mail-qk1-f195.google.com with SMTP id n132so22178241qke.1 for ; Tue, 24 Nov 2020 11:20:53 -0800 (PST) Received: from rekt.redhat.com ([2804:431:c7c7:d88a:482:7c39:5cca:96f6]) by smtp.gmail.com with ESMTPSA id l79sm88837qke.1.2020.11.24.11.20.50 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Nov 2020 11:20:51 -0800 (PST) X-MC-Unique: z0QgPgmTPI-6rcLwYMTmAg-1 X-MC-Unique: 4yZoHmOXOa-4-WFnrjy9wA-1 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=AkBDY1uDSrzxHgiVEiOXT6wK6R+s5GXidoxwjr/aX70=; b=dfxxAavNH4VLU5tUYQRITyoJxyrRnoinRNAVmb8HbQIXU+OAZeEfnCvPklo/rYNJGd 5OaKjkeP4N3VMR5gKzfGZLAQJLAXteEmhq7KLk44WuS6/aIxGmKpwypsfQATn0nl3Wbl oQV+/dniWtpHCTlBm/pHrjllCHTpE6VI4UcLVhWXIoq7J1AbX0oli1qJ4fA6kmbFFSBT VrjpPSyxkkbV8kebLXRkCcu2aHst6OpC2HdITEfXgl6GdqlGyS9VN8jrP9pI7grAZ24O box1+PbytkeYmFg0gNYTuz9w+bLI+q0jU9s+E40k2p0J2TUHSBoLHCUSIuvwBHZmiFHR ulrw== X-Gm-Message-State: AOAM5332P6BdRqvRhGqdWb1XGnEZpSH6gMJ7HDNf1BMHoPjsInJSsz5h KedZPLV6S9qT1QJFghTDGfLPqsrGJsg= X-Google-Smtp-Source: ABdhPJytmxdZeAN+sVBRBZsrw/XCq4alNNBOR3FUr5QrdagwJeqO7uaDUWa5dfJGklGEzmXYTU/rbA== X-Received: by 2002:a37:ac11:: with SMTP id e17mr6278624qkm.238.1606245652419; Tue, 24 Nov 2020 11:20:52 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH 01/21] domain_conf.c: move NVDIMM 'labelsize' check to post parse Date: Tue, 24 Nov 2020 16:20:15 -0300 Message-Id: <20201124192035.2343063-2-danielhb413@gmail.com> In-Reply-To: <20201124192035.2343063-1-danielhb413@gmail.com> References: <20201124192035.2343063-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Move 'labelsize' validation to virDomainMemoryDefPostParse(). Signed-off-by: Daniel Henrique Barboza reviewed-by. --- src/conf/domain_conf.c | 43 +++++++++++++++++++++--------------------- 1 file changed, 22 insertions(+), 21 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b1534dcc1e..5e5905f483 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5363,15 +5363,28 @@ static int virDomainMemoryDefPostParse(virDomainMemoryDefPtr mem, const virDomainDef *def) { - /* Although only the QEMU driver implements PPC64 support, this - * code is related to the platform specification (PAPR), i.e. it - * is hypervisor agnostic, and any future PPC64 hypervisor driver - * will have the same restriction. - */ - if (ARCH_IS_PPC64(def->os.arch) && - mem->model =3D=3D VIR_DOMAIN_MEMORY_MODEL_NVDIMM && - virDomainNVDimmAlignSizePseries(mem) < 0) - return -1; + if (mem->model =3D=3D VIR_DOMAIN_MEMORY_MODEL_NVDIMM) { + if (mem->labelsize && mem->labelsize < 128) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("nvdimm label must be at least 128KiB")); + return -1; + } + + if (mem->labelsize >=3D mem->size) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("label size must be smaller than NVDIMM size"= )); + return -1; + } + + /* Although only the QEMU driver implements PPC64 support, this + * code is related to the platform specification (PAPR), i.e. it + * is hypervisor agnostic, and any future PPC64 hypervisor driver + * will have the same restriction. + */ + if (ARCH_IS_PPC64(def->os.arch) && + virDomainNVDimmAlignSizePseries(mem) < 0) + return -1; + } =20 return 0; } @@ -16766,18 +16779,6 @@ virDomainMemoryTargetDefParseXML(xmlNodePtr node, &def->labelsize, false, false) < 0) return -1; =20 - if (def->labelsize && def->labelsize < 128) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("nvdimm label must be at least 128KiB")); - return -1; - } - - if (def->labelsize >=3D def->size) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("label size must be smaller than NVDIMM size"= )); - return -1; - } - if (virXPathBoolean("boolean(./readonly)", ctxt)) def->readonly =3D true; } --=20 2.26.2 From nobody Sat May 4 09:27:58 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; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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=1606245672; cv=none; d=zohomail.com; s=zohoarc; b=VBdVXzFHZY5rpDeCmnRh0HwJ94lsPndmryJkyV50ubF1TSO3aPtDTPnoMPq0E+F3W9yQ2kSJgEQvhYWQpQ42KcTqkhs/Q7kAzViAt8uBSrq4cd7S2e+2+0ApDVU7EoIPvky4AsfgmNtq9bnk1OSzEg1DFlwZPwt7Ft1/ID60xsw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606245672; 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; bh=DrhMy5JWXNMzPGLhHMvxaBYM3MLaXyJEFg5KNzfg6BY=; b=MuAfbEXiNBUM7A53wK5ySNbrQniOWPMVYMZGJvfbI8xShaK4XDhaN+e+3bNowQssrTfF6k3SGNnMB7knesiqdBKLD3+iAx5izuUjRxLIWGo1Qs/fSyFl289y4scjWFhkooBbvwBsyrF5HyWnSpttF6VkNUYzBNzPWRDMtMDkUR4= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail 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 1606245672990754.5587094240877; Tue, 24 Nov 2020 11:21:12 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-290-laf61vQBNSutgRt89Viwnw-1; Tue, 24 Nov 2020 14:21:09 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1ABE81084C84; Tue, 24 Nov 2020 19:21:04 +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 EC312189A4; Tue, 24 Nov 2020 19:21:03 +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 B4F621809CA1; Tue, 24 Nov 2020 19:21:03 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0AOJL27u004077 for ; Tue, 24 Nov 2020 14:21:02 -0500 Received: by smtp.corp.redhat.com (Postfix) id 5373A2026D38; Tue, 24 Nov 2020 19:21:02 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4C3B02026D35 for ; Tue, 24 Nov 2020 19:20:57 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 8C14E185A794 for ; Tue, 24 Nov 2020 19:20:57 +0000 (UTC) Received: from mail-qk1-f182.google.com (mail-qk1-f182.google.com [209.85.222.182]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-489-05uEF8iYMomftdcgWsvP6Q-1; Tue, 24 Nov 2020 14:20:55 -0500 Received: by mail-qk1-f182.google.com with SMTP id u184so7543170qkf.3 for ; Tue, 24 Nov 2020 11:20:55 -0800 (PST) Received: from rekt.redhat.com ([2804:431:c7c7:d88a:482:7c39:5cca:96f6]) by smtp.gmail.com with ESMTPSA id l79sm88837qke.1.2020.11.24.11.20.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Nov 2020 11:20:53 -0800 (PST) X-MC-Unique: laf61vQBNSutgRt89Viwnw-1 X-MC-Unique: 05uEF8iYMomftdcgWsvP6Q-1 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=DrhMy5JWXNMzPGLhHMvxaBYM3MLaXyJEFg5KNzfg6BY=; b=XczX33WuiEqd1juw01QzPVuRBh6292J5QueUCVJx46vYp1TgvDex6Gdvqyx7PbDIZP iRYxrENF9zkVHQNgpfLTu73z8phXKDuz8+V/MwegUtd3i9v+wGcwrU1/BkiZu/fHDDaj uBF6RpAuQzdXYu1CxEoM2G6kK9oxEndfUWTHV2apg3wvagFa2YbKLYXfrHkmguIQG/5B pdXB+C2d+p+Ynfm/pGhmE7YUP8XvKH+rHs1RWRSvoiMBVtP99VyOr6Go4LBUmGKwUZFa PMZtfE2V5ZPZ8unA2JGOqua4EEUlE16YwPesVA6x5f8MxA8sQ43aPlRQtvrrnFB0tAg/ I8dg== X-Gm-Message-State: AOAM532Soa8FtZN8kReNqhuvS9u5edOrYG0s9Z/CrSUwZU9pLyY12etW rE8YCx4a8g6j6+Cj0ztD3a93/OongRE= X-Google-Smtp-Source: ABdhPJyklhXhprdMutxauRD0OX0p9+KbiW7pJAhbRu0MwGCKTulOx1dQy/hcG6ki8I0Acmdh1PsNmA== X-Received: by 2002:a37:a694:: with SMTP id p142mr6190056qke.467.1606245654488; Tue, 24 Nov 2020 11:20:54 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH 02/21] domain_conf.c: use g_autofree in 'dev' in virDomainDefParseBootXML() Date: Tue, 24 Nov 2020 16:20:16 -0300 Message-Id: <20201124192035.2343063-3-danielhb413@gmail.com> In-Reply-To: <20201124192035.2343063-1-danielhb413@gmail.com> References: <20201124192035.2343063-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This spares us of 2 explicit VIR_FREE() calls. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5e5905f483..4229add26d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -18908,7 +18908,7 @@ virDomainDefParseBootXML(xmlXPathContextPtr ctxt, =20 for (i =3D 0; i < n && i < VIR_DOMAIN_BOOT_LAST; i++) { int val; - char *dev =3D virXMLPropString(nodes[i], "dev"); + g_autofree char *dev =3D virXMLPropString(nodes[i], "dev"); if (!dev) { virReportError(VIR_ERR_INTERNAL_ERROR, "%s", _("missing boot device")); @@ -18918,10 +18918,8 @@ virDomainDefParseBootXML(xmlXPathContextPtr ctxt, virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown boot device '%s'"), dev); - VIR_FREE(dev); return -1; } - VIR_FREE(dev); def->os.bootDevs[def->os.nBootDevs++] =3D val; } =20 --=20 2.26.2 From nobody Sat May 4 09:27:58 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; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1606245677; cv=none; d=zohomail.com; s=zohoarc; b=R9mE0zwZCyA9fftgSgf4gMdiNkeDcGnweZMIbn5hadfwdjPXoA/g31j/VPoqAFpwTzNbnOS7cZtjxWWeYMAixAkAMtS/GJGN0me7TMSKs/7QAsbjGhGEN0n3JR5JOwUU5F/8iwP5zBsCR1LnImDNwhvht1OnHA3BZy65/TDjcq4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606245677; 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; bh=e7RJWnSU0OAvWTQVD4l+SjXSDfpp4e19ND5oF6equCU=; b=EalaH0UXdzEYA6QcaPFWCPba3J0LzWe9a31VDAKQ4ckkYnwTC4ZedUGhHU7I8Cr7CZLb+csrHVdfI+1BezQ5oF3NASLS3czrYq4+W4u9xlHw5qX/bmOJ8cE0pU7orBT+ne7WPx3fpOxrJDoAL4vef95KbVRWpoNrHziOH4NNTAs= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail 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 1606245677632101.27240762636347; Tue, 24 Nov 2020 11:21:17 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-535-npB26oLMMKONnIE_rD5NqA-1; Tue, 24 Nov 2020 14:21:14 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 1A70C800FFF; Tue, 24 Nov 2020 19:21:07 +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 EB9BA6087C; Tue, 24 Nov 2020 19:21:06 +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 AFAB81809CA4; Tue, 24 Nov 2020 19:21:06 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0AOJL2Mf004078 for ; Tue, 24 Nov 2020 14:21:02 -0500 Received: by smtp.corp.redhat.com (Postfix) id 567FD2026D35; Tue, 24 Nov 2020 19:21:02 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4FDF12026D37 for ; Tue, 24 Nov 2020 19:20:59 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 5A81F811E87 for ; Tue, 24 Nov 2020 19:20:59 +0000 (UTC) Received: from mail-qv1-f67.google.com (mail-qv1-f67.google.com [209.85.219.67]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-35-So_wHZZHPGq8AG96xpAbeg-1; Tue, 24 Nov 2020 14:20:56 -0500 Received: by mail-qv1-f67.google.com with SMTP id q7so11145121qvt.12 for ; Tue, 24 Nov 2020 11:20:56 -0800 (PST) Received: from rekt.redhat.com ([2804:431:c7c7:d88a:482:7c39:5cca:96f6]) by smtp.gmail.com with ESMTPSA id l79sm88837qke.1.2020.11.24.11.20.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Nov 2020 11:20:55 -0800 (PST) X-MC-Unique: npB26oLMMKONnIE_rD5NqA-1 X-MC-Unique: So_wHZZHPGq8AG96xpAbeg-1 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=e7RJWnSU0OAvWTQVD4l+SjXSDfpp4e19ND5oF6equCU=; b=noziQ6NE5pXmRhjDpBZIj/kzSXFSAFFQ2AqbGlrw1KBO4RLm03tVfRiM9q6a64bkTe /lCbrHcB9HYlvX53PpHPfgVpYKbkcI27w+4MzzclQrbAKA4QGUwfgTXojHOXhRpJ9GWg 4KtSMGuZjJ0dyH5wcyWi+mfOGMVUKgKJfjrKZcVCz7mpTToreUHZS1pSAovaMHuKj+NQ 1Nn/HLxYuEA8MS27BlMjSMW8XO6YGzVuTsFpudnPFYkUXz/q2778kuTOOS/3F8J0ncaG U0U6JEkpJftFjwrpGZyXENX11fMdc/ChNPj7opu2MIaAQakBUotOda8kjcqPNpFxOhLw FCjQ== X-Gm-Message-State: AOAM531I+fwKIvBB9IGv3gdrBnTHwjfwMlJHoa4Ki7bdHSnaegEA765R 5mfN6mvPKJ9gVS/yoVM4jmExTSUm1h8= X-Google-Smtp-Source: ABdhPJzLwT5RBnJM1kqR/S3doHbAftb0Pj1FevNnR3l+jfAmpE6n91vf4VnMRbU9e7tXPff/sQIJmA== X-Received: by 2002:a05:6214:3a9:: with SMTP id m9mr6271548qvy.1.1606245656267; Tue, 24 Nov 2020 11:20:56 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH 03/21] domain_conf.c: modernize virDomainDefBootOrderPostParse() Date: Tue, 24 Nov 2020 16:20:17 -0300 Message-Id: <20201124192035.2343063-4-danielhb413@gmail.com> In-Reply-To: <20201124192035.2343063-1-danielhb413@gmail.com> References: <20201124192035.2343063-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Use g_autoptr() with the hash and remove the 'cleanup' label. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 4229add26d..f0300b870d 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5823,20 +5823,19 @@ virDomainDefCollectBootOrder(virDomainDefPtr def G_= GNUC_UNUSED, static int virDomainDefBootOrderPostParse(virDomainDefPtr def) { - GHashTable *bootHash =3D NULL; - int ret =3D -1; + g_autoptr(GHashTable) bootHash =3D NULL; =20 if (!(bootHash =3D virHashNew(NULL))) - goto cleanup; + return -1; =20 if (virDomainDeviceInfoIterate(def, virDomainDefCollectBootOrder, boot= Hash) < 0) - goto cleanup; + return -1; =20 if (def->os.nBootDevs > 0 && virHashSize(bootHash) > 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("per-device boot elements cannot be used" " together with os/boot elements")); - goto cleanup; + return -1; } =20 if (def->os.nBootDevs =3D=3D 0 && virHashSize(bootHash) =3D=3D 0) { @@ -5844,11 +5843,7 @@ virDomainDefBootOrderPostParse(virDomainDefPtr def) def->os.bootDevs[0] =3D VIR_DOMAIN_BOOT_DISK; } =20 - ret =3D 0; - - cleanup: - virHashFree(bootHash); - return ret; + return 0; } =20 =20 --=20 2.26.2 From nobody Sat May 4 09:27:58 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; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1606245683; cv=none; d=zohomail.com; s=zohoarc; b=eL5MsxqQYUxxWUgn1heCt1kuYhEomfxPi8UIyYKIyqfjJiiKBQIzCpFjJGATGw5iOLW9EF0ef3q2iv20B1FKL1naNQ2TG5gS4qHPkEmZLQHxKkloibDtRagBQZ4ST2AwCUa9kQC+YmfWnopabuVy+9Fs1qmBDLvbAY08nCGgQrY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606245683; 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; bh=GlNd2uEebkxsCFiHjwL97uhR79JLwnPdY/2vt5LQPvQ=; b=nylVvSsv+XD/wxRDGOWGWZyUqFgAPBb8RCDXMGy9WhiBmVEJ+V3PlswBpcNFkBCqDY64pL6A5FnScCJHZApDpLoxir5AgC+QLfd2zkWRSzt/8ueGrukVlsHSaZiCIRNLaWZZJqL3zTQMweSisKWghJgGKTYrfJJEaE5dDB6VDBo= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail 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 1606245683174128.86021792539793; Tue, 24 Nov 2020 11:21:23 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-357-1VC_u2cdMBCP89TEHo4A9w-1; Tue, 24 Nov 2020 14:21:18 -0500 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 2408F81C478; Tue, 24 Nov 2020 19:21:09 +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 F19655D71B; Tue, 24 Nov 2020 19:21:08 +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 B934B1809CA6; Tue, 24 Nov 2020 19:21:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0AOJL6dx004102 for ; Tue, 24 Nov 2020 14:21:06 -0500 Received: by smtp.corp.redhat.com (Postfix) id E8B3E2166B2C; Tue, 24 Nov 2020 19:21:05 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast06.extmail.prod.ext.rdu2.redhat.com [10.11.55.22]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E345D2166B2A for ; Tue, 24 Nov 2020 19:21:03 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id BAFDE186E128 for ; Tue, 24 Nov 2020 19:21:03 +0000 (UTC) Received: from mail-qt1-f170.google.com (mail-qt1-f170.google.com [209.85.160.170]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-273-X-CJqYCkOE6XQDVai4LKAA-1; Tue, 24 Nov 2020 14:20:59 -0500 Received: by mail-qt1-f170.google.com with SMTP id e60so7723912qtd.3 for ; Tue, 24 Nov 2020 11:20:58 -0800 (PST) Received: from rekt.redhat.com ([2804:431:c7c7:d88a:482:7c39:5cca:96f6]) by smtp.gmail.com with ESMTPSA id l79sm88837qke.1.2020.11.24.11.20.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Nov 2020 11:20:57 -0800 (PST) X-MC-Unique: 1VC_u2cdMBCP89TEHo4A9w-1 X-MC-Unique: X-CJqYCkOE6XQDVai4LKAA-1 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=GlNd2uEebkxsCFiHjwL97uhR79JLwnPdY/2vt5LQPvQ=; b=oyEI9PZ14b7eW7l9h25wMRpSvw/PqVjlCJURVI2okFkm0mzqNnbxwCcoWVR0QwNyZu EAkd/cHHkoSq7ZlaKgx0DB4x3qjU6nhUolnO/dnJjfdJs8mMaWNjZXh6tvQqTP5xqZlq nSSHBix+TfIcsnpLW8QfSjtqDUAFs5uJbApEJmxVteoPLBN9S+wnvD94G70EoTGvcXp2 7mBb8rIR07rB1/9gjl9Kfmc8nFHgaaGQnvfRxGLjwEdcJs30k1rXpPwe1FcJQORnd+2K yXtyvJ5Tm4v7ChdN7IRAEMpjttUuq6TvZhbrDmUvdztWX6iXSBrFMBHsE0G6vCTHbUH8 qvQQ== X-Gm-Message-State: AOAM531tGuMxkqQQNiYm8G8hpW2p0JSJlEhnF1PBthAsDUnf4HafHzIP tz8rvjn+uqfrqPHvGPVxyJcWrdciyBo= X-Google-Smtp-Source: ABdhPJxj/icFlL+rZvxMFWLwnRrlMcBbyf0MUuu1Abd+dnuHt8pRI0IT+EwHfnofUEZpjBjLs4sxfg== X-Received: by 2002:ac8:548e:: with SMTP id h14mr5955577qtq.326.1606245658167; Tue, 24 Nov 2020 11:20:58 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH 04/21] domain_conf.c: move boot related timeouts check to post parse Date: Tue, 24 Nov 2020 16:20:18 -0300 Message-Id: <20201124192035.2343063-5-danielhb413@gmail.com> In-Reply-To: <20201124192035.2343063-1-danielhb413@gmail.com> References: <20201124192035.2343063-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This patch creates a new function, virDomainDefBootPostParse(), to host the validation of boot menu timeout and rebootTimeout to post parse time. The checks in virDomainDefParseBootXML() were changed to throw VIR_ERR_XML_ERROR in case of parse error of those values. Signed-off-by: Daniel Henrique Barboza --- src/conf/domain_conf.c | 41 +++++++++++++++++++++++++++++++---------- 1 file changed, 31 insertions(+), 10 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index f0300b870d..c2e5ed5680 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5847,6 +5847,28 @@ virDomainDefBootOrderPostParse(virDomainDefPtr def) } =20 =20 +static int +virDomainDefBootPostParse(virDomainDefPtr def) +{ + if (def->os.bm_timeout_set && def->os.bm_timeout > 65535) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("invalid value for boot menu timeout, " + "must be in range [0,65535]")); + return -1; + } + + if (def->os.bios.rt_set && + (def->os.bios.rt_delay < -1 || def->os.bios.rt_delay > 65535)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("invalid value for rebootTimeout, " + "must be in range [-1,65535]")); + return -1; + } + + return 0; +} + + static int virDomainDefPostParseVideo(virDomainDefPtr def, void *opaque) @@ -5917,6 +5939,9 @@ virDomainDefPostParseCommon(virDomainDefPtr def, if (virDomainDefRejectDuplicatePanics(def) < 0) return -1; =20 + if (virDomainDefBootPostParse(def) < 0) + return -1; + if (def->os.type =3D=3D VIR_DOMAIN_OSTYPE_HVM && !(data->xmlopt->config.features & VIR_DOMAIN_DEF_FEATURE_NO_BOOT_O= RDER) && virDomainDefBootOrderPostParse(def) < 0) @@ -18935,11 +18960,9 @@ virDomainDefParseBootXML(xmlXPathContextPtr ctxt, =20 tmp =3D virXMLPropString(node, "timeout"); if (tmp && def->os.bootmenu =3D=3D VIR_TRISTATE_BOOL_YES) { - if (virStrToLong_uip(tmp, NULL, 0, &def->os.bm_timeout) < 0 || - def->os.bm_timeout > 65535) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("invalid value for boot menu timeout, " - "must be in range [0,65535]")); + if (virStrToLong_uip(tmp, NULL, 0, &def->os.bm_timeout) < 0) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("invalid value for boot menu timeout")); return -1; } def->os.bm_timeout_set =3D true; @@ -18960,11 +18983,9 @@ virDomainDefParseBootXML(xmlXPathContextPtr ctxt, if (tmp) { /* that was really just for the check if it is there */ =20 - if (virStrToLong_i(tmp, NULL, 0, &def->os.bios.rt_delay) < 0 || - def->os.bios.rt_delay < -1 || def->os.bios.rt_delay > 6553= 5) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("invalid value for rebootTimeout, " - "must be in range [-1,65535]")); + if (virStrToLong_i(tmp, NULL, 0, &def->os.bios.rt_delay) < 0) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("invalid value for rebootTimeout")); return -1; } def->os.bios.rt_set =3D true; --=20 2.26.2 From nobody Sat May 4 09:27:58 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; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1606245685; cv=none; d=zohomail.com; s=zohoarc; b=KgkOv7LK+y2b4fo3B3xErrHafjn1R9H8zv4mpOlLQAMek5xopPnY97+i+ctSK3aFTSZMA0O+EvFt+flk+kFDCsRpTH4WQi8nVbwW/+7ynWOB+61gQbUxP4kJB6SlMRMj95bHohdub3T93cfS3dyXIWS1Ctdf6qaPVG3CDgXKCxA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606245685; 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; bh=nKKYuapGPCFdQhmkouPYdBlztwppnkqoOSs4G1fYdvM=; b=P+LyDk4R0c7obN83YUHVBBDzibxKBzSukgQC+ST1x2fxmjStCZCF0neOryG89FtQ2I1fOWyrhr3I9sXSjihxe3ILlbhWVhjHp91k66ZqYLhZ1pL4ivIuoPzfWkVMKdettbpzwuzww7GG7O2B//J/60YL1qNeV2TxCrEIl3xaliE= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail 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 1606245685397680.7750006693789; Tue, 24 Nov 2020 11:21:25 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-373-RbE4_Z4JMU-qsJN4QGqoAA-1; Tue, 24 Nov 2020 14:21:20 -0500 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 67927801AE8; Tue, 24 Nov 2020 19:21:12 +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 3F7805D71B; Tue, 24 Nov 2020 19:21:12 +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 0B32A1809CA8; Tue, 24 Nov 2020 19:21:12 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0AOJL3qv004089 for ; Tue, 24 Nov 2020 14:21:03 -0500 Received: by smtp.corp.redhat.com (Postfix) id 2A84D2026D35; Tue, 24 Nov 2020 19:21:03 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast03.extmail.prod.ext.rdu2.redhat.com [10.11.55.19]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 25FDB2026D25 for ; Tue, 24 Nov 2020 19:21:03 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 11EF9811E78 for ; Tue, 24 Nov 2020 19:21:03 +0000 (UTC) Received: from mail-qv1-f42.google.com (mail-qv1-f42.google.com [209.85.219.42]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-412-LwLChbOGO_i8oTMzvMI6hA-1; Tue, 24 Nov 2020 14:21:00 -0500 Received: by mail-qv1-f42.google.com with SMTP id es6so2416263qvb.7 for ; Tue, 24 Nov 2020 11:21:00 -0800 (PST) Received: from rekt.redhat.com ([2804:431:c7c7:d88a:482:7c39:5cca:96f6]) by smtp.gmail.com with ESMTPSA id l79sm88837qke.1.2020.11.24.11.20.58 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Nov 2020 11:20:59 -0800 (PST) X-MC-Unique: RbE4_Z4JMU-qsJN4QGqoAA-1 X-MC-Unique: LwLChbOGO_i8oTMzvMI6hA-1 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=nKKYuapGPCFdQhmkouPYdBlztwppnkqoOSs4G1fYdvM=; b=GXVs8r4ak3nJzl4XtdVWCPEKHJTOxgNfZq1xKeNEUEF0z/xUzLUPXSN/wY7cWIq/px UM6jDLNomlOoP71/sqr4OsMg7WnYrNwcKb+wTTw8WjFJliCPl4yIid94rXKTBysEw6SF 0ujmS2IpyDzVUvecsbqJ5NOZEO9JCX3BY+dLaxm+EGAYu5S4p2aDf6OVl+nBlae47Cok sIiCbY5fifRlLujqsMES0TjQxaswMyC3zCHrmxMERqRgRyHOHJkHTQVWfKRL7Tmsq669 tqWO3UlMpayv+P7XLaYhzDhR9rqdDJRMqWJUxG6afQFGOXXjj9Cp8An4tWAZzWLdy/Hf XVSg== X-Gm-Message-State: AOAM531vIpG/l1KaDoBo3XyFrBdt9bYwcmh7n+QdvHlsJx9HXVSFna3+ /bQR2gPdXE0+DdGgOygplBafYw5xSC0= X-Google-Smtp-Source: ABdhPJzkc0wIQK/kuXMvodDS4DXAl7aBjPyje/0lEiH2bZBRFhB7LtlyvbfoboVG4WuWDX72laVgRw== X-Received: by 2002:a0c:9ad8:: with SMTP id k24mr6601496qvf.28.1606245659903; Tue, 24 Nov 2020 11:20:59 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH 05/21] domain_conf.c: do not leak 'video' in virDomainDefParseXML() Date: Tue, 24 Nov 2020 16:20:19 -0300 Message-Id: <20201124192035.2343063-6-danielhb413@gmail.com> In-Reply-To: <20201124192035.2343063-1-danielhb413@gmail.com> References: <20201124192035.2343063-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" The 'video' pointer is only being freed on error path, meaning that we're leaking it after each loop restart. There are more opportunities for auto cleanups of virDomainVideoDef pointers, so let's register AUTOPTR_CLEANUP_FUNC for it to use g_autoptr() later on. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 4 +--- src/conf/domain_conf.h | 1 + 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index c2e5ed5680..88c647f943 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -22233,7 +22233,7 @@ virDomainDefParseXML(xmlDocPtr xml, if (n) def->videos =3D g_new0(virDomainVideoDefPtr, n); for (i =3D 0; i < n; i++) { - virDomainVideoDefPtr video; + g_autoptr(virDomainVideoDef) video =3D NULL; ssize_t insertAt =3D -1; =20 if (!(video =3D virDomainVideoDefParseXML(xmlopt, nodes[i], @@ -22242,7 +22242,6 @@ virDomainDefParseXML(xmlDocPtr xml, =20 if (video->primary) { if (def->nvideos !=3D 0 && def->videos[0]->primary) { - virDomainVideoDefFree(video); virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", _("Only one primary video device is support= ed")); goto error; @@ -22254,7 +22253,6 @@ virDomainDefParseXML(xmlDocPtr xml, insertAt, def->nvideos, video) < 0) { - virDomainVideoDefFree(video); goto error; } } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 96e6c34553..ff82da7f7e 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -3083,6 +3083,7 @@ void virDomainNVRAMDefFree(virDomainNVRAMDefPtr def); void virDomainWatchdogDefFree(virDomainWatchdogDefPtr def); virDomainVideoDefPtr virDomainVideoDefNew(virDomainXMLOptionPtr xmlopt); void virDomainVideoDefFree(virDomainVideoDefPtr def); +G_DEFINE_AUTOPTR_CLEANUP_FUNC(virDomainVideoDef, virDomainVideoDefFree); void virDomainVideoDefClear(virDomainVideoDefPtr def); virDomainHostdevDefPtr virDomainHostdevDefNew(void); void virDomainHostdevDefClear(virDomainHostdevDefPtr def); --=20 2.26.2 From nobody Sat May 4 09:27:58 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; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 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=1606245723; cv=none; d=zohomail.com; s=zohoarc; b=fzyHXpQnyLJxDrMUDB8gCqAsUpOQfU5XCiIHCresT3w9t1jxUXeVWrZgqEl9kkITsKowFJJ+y1GuNmfgisuH9wX2Z+mYJX/V/2PptsPB4yKJ9Zq2fYCPVOe5ZuqMwf+F1VtEcRzprj/+adAmSv3vKzce9AoepCISndK3gBDa8v4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606245723; 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; bh=iPUmeq89MlDmlXhkR+tsHL0CzQxhUYzgs1qllIQ3CyY=; b=emI9XSKh1JHNKVylj1qo9gf7jMV3MIvitHOf+ZYJtKljaGNUrZogo0HqBvXdLd+171UhYnTtMbfYNXsg/PkopTJi79vXMtdsw7mVeXF9lWtkCV1nvv5apmyReYIzYdJZvZ+PhBwESLW+TgOgXx3ZPfoM4GjLBWZPYdVc1SGyIqs= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 63.128.21.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail 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 1606245723985478.1836370428298; Tue, 24 Nov 2020 11:22:03 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-206-aYp9pvU3NP-JRscFqEKuCg-1; Tue, 24 Nov 2020 14:21:17 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 90DC21084C89; Tue, 24 Nov 2020 19:21: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 71E05608DB; Tue, 24 Nov 2020 19:21:11 +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 3FCE95002C; Tue, 24 Nov 2020 19:21:11 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0AOJL9WF004126 for ; Tue, 24 Nov 2020 14:21:09 -0500 Received: by smtp.corp.redhat.com (Postfix) id 3D55116794; Tue, 24 Nov 2020 19:21:09 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 37BCE9458A for ; Tue, 24 Nov 2020 19:21:06 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [205.139.110.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 27AAA803C9F for ; Tue, 24 Nov 2020 19:21:06 +0000 (UTC) Received: from mail-qv1-f43.google.com (mail-qv1-f43.google.com [209.85.219.43]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-254-OFirzyz8POWMxfnQukuyzg-1; Tue, 24 Nov 2020 14:21:02 -0500 Received: by mail-qv1-f43.google.com with SMTP id 62so959851qva.11 for ; Tue, 24 Nov 2020 11:21:02 -0800 (PST) Received: from rekt.redhat.com ([2804:431:c7c7:d88a:482:7c39:5cca:96f6]) by smtp.gmail.com with ESMTPSA id l79sm88837qke.1.2020.11.24.11.21.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Nov 2020 11:21:01 -0800 (PST) X-MC-Unique: aYp9pvU3NP-JRscFqEKuCg-1 X-MC-Unique: OFirzyz8POWMxfnQukuyzg-1 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=iPUmeq89MlDmlXhkR+tsHL0CzQxhUYzgs1qllIQ3CyY=; b=gdLk/a3jDBt7nvtcYHG/Y4PUXGJUjo6iQpU1743/h+JacBxLiRNkm5JuC+J5rX5g1F a9xXCY2Z+yqjU94XtlN9xhSeZhDw3w4+jNyliNs49UUcxp21Tx7AVFCeSFvL5oX9v4Fi 7w86zAti9z06N9w3xHYqleldbf8fuluper9VcIy/FWovxVlhe9fDb7MZIOytSOncwXKj ZmPtW6b4S3ksBtL8Ho0Z/UF8AyVVypEkhM/VUwF6LpfFKO2HBpvFRlbvql97h+EOlfAm JUJeH4c1V1/n4X1WAtIBDj3iYTYkbd+JhNxM7y6r544Ie+MOrnVjJ79uus+whqI5IkWF loMA== X-Gm-Message-State: AOAM530bB+0MHM6Gv6LSmCwGXcLLJfyNnxRibMZ+N0I5xa6rO54vTcYX YggsQ6jgnpFWm6iFg92IHqVgrMTR+DY= X-Google-Smtp-Source: ABdhPJzYTSqhCaLV/uLbiZcDeD2AJ3VpZAlOBAq+zsPHIsFqdBLTTO9XSQUyIzHM3/YnS81nO2fCAw== X-Received: by 2002:a0c:8d4a:: with SMTP id s10mr6691468qvb.30.1606245661924; Tue, 24 Nov 2020 11:21:01 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH 06/21] domain_conf.c: move primary video check to virDomainDefPostParseVideo() Date: Tue, 24 Nov 2020 16:20:20 -0300 Message-Id: <20201124192035.2343063-7-danielhb413@gmail.com> In-Reply-To: <20201124192035.2343063-1-danielhb413@gmail.com> References: <20201124192035.2343063-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" Move it to post parse since it's not related to XML parsing. Since we don't have a failure test for this scenario, a new 'video-multiple-primaries' test was added to test this failure case. Signed-off-by: Daniel Henrique Barboza --- src/conf/domain_conf.c | 24 +++++++++----- .../video-multiple-primaries.err | 1 + .../video-multiple-primaries.xml | 32 +++++++++++++++++++ tests/qemuxml2argvtest.c | 5 +++ 4 files changed, 54 insertions(+), 8 deletions(-) create mode 100644 tests/qemuxml2argvdata/video-multiple-primaries.err create mode 100644 tests/qemuxml2argvdata/video-multiple-primaries.xml diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 88c647f943..521a7cee3a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -5873,9 +5873,23 @@ static int virDomainDefPostParseVideo(virDomainDefPtr def, void *opaque) { + size_t i; + if (def->nvideos =3D=3D 0) return 0; =20 + /* Any video marked as primary will be put in index 0 by the + * parser. Ensure that we have only one primary set by the user. */ + if (def->videos[0]->primary) { + for (i =3D 1; i < def->nvideos; i++) { + if (def->videos[i]->primary) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Only one primary video device is support= ed")); + return -1; + } + } + } + if (def->videos[0]->type =3D=3D VIR_DOMAIN_VIDEO_TYPE_NONE) { char *alias; =20 @@ -22240,15 +22254,9 @@ virDomainDefParseXML(xmlDocPtr xml, ctxt, flags))) goto error; =20 - if (video->primary) { - if (def->nvideos !=3D 0 && def->videos[0]->primary) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Only one primary video device is support= ed")); - goto error; - } - + if (video->primary) insertAt =3D 0; - } + if (VIR_INSERT_ELEMENT_INPLACE(def->videos, insertAt, def->nvideos, diff --git a/tests/qemuxml2argvdata/video-multiple-primaries.err b/tests/qe= muxml2argvdata/video-multiple-primaries.err new file mode 100644 index 0000000000..f81b7275e4 --- /dev/null +++ b/tests/qemuxml2argvdata/video-multiple-primaries.err @@ -0,0 +1 @@ +unsupported configuration: Only one primary video device is supported diff --git a/tests/qemuxml2argvdata/video-multiple-primaries.xml b/tests/qe= muxml2argvdata/video-multiple-primaries.xml new file mode 100644 index 0000000000..977227c5ff --- /dev/null +++ b/tests/qemuxml2argvdata/video-multiple-primaries.xml @@ -0,0 +1,32 @@ + + QEMUGuest1 + c7a5fdbd-edaf-9455-926a-d65c16db1809 + 1048576 + 1048576 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-i386 + + + + +
+ + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 42d147243e..9043c9bdbe 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -2378,6 +2378,11 @@ mymain(void) DO_TEST_CAPS_ARCH_LATEST("default-video-type-riscv64", "riscv64"); DO_TEST_CAPS_ARCH_LATEST("default-video-type-s390x", "s390x"); =20 + DO_TEST_PARSE_ERROR("video-multiple-primaries", + QEMU_CAPS_DEVICE_QXL, + QEMU_CAPS_DEVICE_VGA, + QEMU_CAPS_DEVICE_VIDEO_PRIMARY); + DO_TEST("virtio-rng-default", QEMU_CAPS_DEVICE_VIRTIO_RNG, QEMU_CAPS_OBJECT_RNG_RANDOM); --=20 2.26.2 From nobody Sat May 4 09:27:58 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; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1606245688; cv=none; d=zohomail.com; s=zohoarc; b=Dj66J4weMRHPCmEAmiklGcqYXvXq9WI2mCO/M88n0+AHLGx2SWEQaNN1hhKijtGPY+QKUHLmXzYftQjTkMyzPuXegyFin8LJez5qrsnUYIkKyN31D3MEEjXjnqK4vt22BIu7HA52Nss8QlD9l0BpDH6hoQWw3tN6/xlQ0fUQkXQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1606245688; 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; bh=pOVDvazIKQtbReykeE2b2Gks0rAqDdBzB1eK5wgaRGg=; b=NWdoSB+E5Khs/Nwqb13KgGr1K1WNMFAWV6k6moT4IfDjMBHAF6Xt4l6r5Y2kFI771lEaQdMfIhpeSyVyNGsJU6vP8oMffhbZ8FNjol5drEqew0DNyrYDUFzno0JVO+OdA+4C6ji0kVr9SNcqKQWpy1tsco8EO+3AJTQPK9HNjCA= ARC-Authentication-Results: i=1; mx.zohomail.com; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail 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 1606245688434175.85916899401377; Tue, 24 Nov 2020 11:21:28 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-7-056f3CduMXG5nfg8K96raw-1; Tue, 24 Nov 2020 14:21:23 -0500 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 13C309A228; Tue, 24 Nov 2020 19:21:15 +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 E16B319C45; Tue, 24 Nov 2020 19:21: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 AE9FB50030; Tue, 24 Nov 2020 19:21:14 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 0AOJL7bp004111 for ; Tue, 24 Nov 2020 14:21:07 -0500 Received: by smtp.corp.redhat.com (Postfix) id 886F52166B2A; Tue, 24 Nov 2020 19:21:07 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast05.extmail.prod.ext.rdu2.redhat.com [10.11.55.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 83A072166B27 for ; Tue, 24 Nov 2020 19:21:07 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-1.mimecast.com [207.211.31.81]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6E889800296 for ; Tue, 24 Nov 2020 19:21:07 +0000 (UTC) Received: from mail-qt1-f171.google.com (mail-qt1-f171.google.com [209.85.160.171]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-295-6anK6IHQPMmUeBL44UsDIQ-1; Tue, 24 Nov 2020 14:21:04 -0500 Received: by mail-qt1-f171.google.com with SMTP id v11so16889444qtq.12 for ; Tue, 24 Nov 2020 11:21:04 -0800 (PST) Received: from rekt.redhat.com ([2804:431:c7c7:d88a:482:7c39:5cca:96f6]) by smtp.gmail.com with ESMTPSA id l79sm88837qke.1.2020.11.24.11.21.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 24 Nov 2020 11:21:03 -0800 (PST) X-MC-Unique: 056f3CduMXG5nfg8K96raw-1 X-MC-Unique: 6anK6IHQPMmUeBL44UsDIQ-1 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=pOVDvazIKQtbReykeE2b2Gks0rAqDdBzB1eK5wgaRGg=; b=F4hawx78/q9rEkxqP7jhvNRrE3MRakfRwVeQhSVZsiLDKc+rFSd5U9HWUqeajTt0GW lQMylWI4FrTAEInV0Vnqp7IcCkexjnAWlmkUFyaJPuoQJi8FU8QkozdvFcq2fkdM22PY yRjznL3JWWUWypeTPvI/Jjsbh5uI0SPto7UwXWT3cQDD1UfsYCcB7NiLAi3zVkW7Z1fz 9RrKZlwwMm31sCeXzX9sxFaIgUBQbUEV2aizR6EXwYFzyIoYuHrSJWoesQbi6galSmtq BiqFk3qIzVhFTc3WlBdA8UcA/v+wpIaE5wlm9DFOsGyggsl74N19G5F1jzC3m+UAptbq 2/tA== X-Gm-Message-State: AOAM5300h9vw1npQWbN57tXmnh44OObuLvL6Ysyf0jArCrABLPgxP2zB 6KZRByuBfjr+e4pBN23khgxGf03201k= X-Google-Smtp-Source: ABdhPJzsHrqxzHLknIrTwm57JulSayAc6aWJ+k+Hb/PTosx2TjsYC7ePXEQCXMSJw6u0wUglZUZSsQ== X-Received: by 2002:ac8:2a2a:: with SMTP id k39mr5845372qtk.232.1606245663973; Tue, 24 Nov 2020 11:21:03 -0800 (PST) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH 07/21] domain_conf.c: use g_autoptr() with virDomainVideoDefPtr Date: Tue, 24 Nov 2020 16:20:21 -0300 Message-Id: <20201124192035.2343063-8-danielhb413@gmail.com> In-Reply-To: <20201124192035.2343063-1-danielhb413@gmail.com> References: <20201124192035.2343063-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Mimecast-Impersonation-Protect: Policy=CLT - Impersonation Protection Definition; Similar Internal Domain=false; Similar Monitored External Domain=false; Custom External Domain=false; Mimecast External Domain=false; Newly Observed Domain=false; Internal User Name=false; Custom Display Name List=false; Reply-to Address Mismatch=false; Targeted Threat Dictionary=false; Mimecast Threat Dictionary=false; Custom Threat Dictionary=false X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This will modernize virDomainVideoDefParseXML() and virDomainDefAddImplicitVideo() by removing unneeded cleanup labels. Signed-off-by: Daniel Henrique Barboza Reviewed-by: Michal Privoznik --- src/conf/domain_conf.c | 48 ++++++++++++++++++------------------------ 1 file changed, 20 insertions(+), 28 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 521a7cee3a..8352c60473 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -16179,7 +16179,7 @@ virDomainVideoDefParseXML(virDomainXMLOptionPtr xml= opt, xmlXPathContextPtr ctxt, unsigned int flags) { - virDomainVideoDefPtr def; + g_autoptr(virDomainVideoDef) def =3D NULL; xmlNodePtr cur; VIR_XPATH_NODE_AUTORESTORE(ctxt) g_autofree char *type =3D NULL; @@ -16220,12 +16220,12 @@ virDomainVideoDefParseXML(virDomainXMLOptionPtr x= mlopt, if (def->accel =3D=3D NULL && virXMLNodeNameEqual(child, "acceleration")) { if ((def->accel =3D virDomainVideoAccelDefPars= eXML(child)) =3D=3D NULL) - goto error; + return NULL; } if (def->res =3D=3D NULL && virXMLNodeNameEqual(child, "resolution")) { if ((def->res =3D virDomainVideoResolutionDefP= arseXML(child)) =3D=3D NULL) - goto error; + return NULL; } } child =3D child->next; @@ -16233,7 +16233,7 @@ virDomainVideoDefParseXML(virDomainXMLOptionPtr xml= opt, } if (virXMLNodeNameEqual(cur, "driver")) { if (virDomainVirtioOptionsParseXML(cur, &def->virtio) < 0) - goto error; + return NULL; driver_name =3D virXMLPropString(cur, "name"); } } @@ -16244,7 +16244,7 @@ virDomainVideoDefParseXML(virDomainXMLOptionPtr xml= opt, if ((def->type =3D virDomainVideoTypeFromString(type)) < 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown video model '%s'"), type); - goto error; + return NULL; } } else { def->type =3D VIR_DOMAIN_VIDEO_TYPE_DEFAULT; @@ -16255,7 +16255,7 @@ virDomainVideoDefParseXML(virDomainXMLOptionPtr xml= opt, if ((backend =3D virDomainVideoBackendTypeFromString(driver_name))= <=3D 0) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("unknown video driver '%s'"), driver_name); - goto error; + return NULL; } def->backend =3D backend; } else { @@ -16266,12 +16266,12 @@ virDomainVideoDefParseXML(virDomainXMLOptionPtr x= mlopt, if (def->type !=3D VIR_DOMAIN_VIDEO_TYPE_QXL) { virReportError(VIR_ERR_XML_ERROR, "%s", _("ram attribute only supported for type of qxl= ")); - goto error; + return NULL; } if (virStrToLong_uip(ram, NULL, 10, &def->ram) < 0) { virReportError(VIR_ERR_XML_ERROR, _("cannot parse video ram '%s'"), ram); - goto error; + return NULL; } } =20 @@ -16279,7 +16279,7 @@ virDomainVideoDefParseXML(virDomainXMLOptionPtr xml= opt, if (virStrToLong_uip(vram, NULL, 10, &def->vram) < 0) { virReportError(VIR_ERR_XML_ERROR, _("cannot parse video vram '%s'"), vram); - goto error; + return NULL; } } =20 @@ -16287,12 +16287,12 @@ virDomainVideoDefParseXML(virDomainXMLOptionPtr x= mlopt, if (def->type !=3D VIR_DOMAIN_VIDEO_TYPE_QXL) { virReportError(VIR_ERR_XML_ERROR, "%s", _("vram64 attribute only supported for type of = qxl")); - goto error; + return NULL; } if (virStrToLong_uip(vram64, NULL, 10, &def->vram64) < 0) { virReportError(VIR_ERR_XML_ERROR, _("cannot parse video vram64 '%s'"), vram64); - goto error; + return NULL; } } =20 @@ -16300,12 +16300,12 @@ virDomainVideoDefParseXML(virDomainXMLOptionPtr x= mlopt, if (def->type !=3D VIR_DOMAIN_VIDEO_TYPE_QXL) { virReportError(VIR_ERR_XML_ERROR, "%s", _("vgamem attribute only supported for type of = qxl")); - goto error; + return NULL; } if (virStrToLong_uip(vgamem, NULL, 10, &def->vgamem) < 0) { virReportError(VIR_ERR_XML_ERROR, _("cannot parse video vgamem '%s'"), vgamem); - goto error; + return NULL; } } =20 @@ -16313,20 +16313,16 @@ virDomainVideoDefParseXML(virDomainXMLOptionPtr x= mlopt, if (virStrToLong_uip(heads, NULL, 10, &def->heads) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("cannot parse video heads '%s'"), heads); - goto error; + return NULL; } } =20 if (virDomainDeviceInfoParseXML(xmlopt, node, &def->info, flags) < 0) - goto error; + return NULL; =20 def->driver =3D virDomainVideoDriverDefParseXML(node); =20 - return def; - - error: - virDomainVideoDefFree(def); - return NULL; + return g_steal_pointer(&def); } =20 static virDomainHostdevDefPtr @@ -25038,8 +25034,7 @@ virDomainDefAddImplicitControllers(virDomainDefPtr = def) static int virDomainDefAddImplicitVideo(virDomainDefPtr def, virDomainXMLOptionPtr xm= lopt) { - int ret =3D -1; - virDomainVideoDefPtr video =3D NULL; + g_autoptr(virDomainVideoDef) video =3D NULL; =20 /* For backwards compatibility, if no