From nobody Sat May 4 19:31:44 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; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 153380652514964.89273891217954; Thu, 9 Aug 2018 02:22:05 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 06F5C81DF3; Thu, 9 Aug 2018 09:22:02 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 51A17AD144; Thu, 9 Aug 2018 09:22: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 BD0644A460; Thu, 9 Aug 2018 09:21:56 +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 w799Lsuo004280 for ; Thu, 9 Aug 2018 05:21:54 -0400 Received: by smtp.corp.redhat.com (Postfix) id 1D00020180F4; Thu, 9 Aug 2018 09:21:54 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.43.2.196]) by smtp.corp.redhat.com (Postfix) with ESMTP id AFBEE2026D68 for ; Thu, 9 Aug 2018 09:21:53 +0000 (UTC) From: Katerina Koukiou To: libvir-list@redhat.com Date: Thu, 9 Aug 2018 11:21:52 +0200 Message-Id: <20180809092152.10128-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH v2] qemu: qemuDomainChangeNet: validity checks should be done before XML autocompletion 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: , MIME-Version: 1.0 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 09 Aug 2018 09:22:03 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" This patch ensures that changes in attributes of interfaces will be emit errors accept if they are missing from the XML. Previously we were falsely reporting successfull updates, because some changed attributes got overwritten before the validity checks. https://bugzilla.redhat.com/show_bug.cgi?id=3D1599513 Signed-off-by: Katerina Koukiou --- src/qemu/qemu_hotplug.c | 42 +++++++++++++++++++++++++---------------- 1 file changed, 26 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 1488f0a7c2..76ab56a479 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -3445,23 +3445,9 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, goto cleanup; } =20 - /* info: if newdev->info is empty, fill it in from olddev, - * otherwise verify that it matches - nothing is allowed to - * change. (There is no helper function to do this, so - * individually check the few feidls of virDomainDeviceInfo that - * are relevant in this case). + /* info: Nothing is allowed to change. First fill the missing newdev->= info + * from olddev and then check for changes. */ - if (!virDomainDeviceAddressIsValid(&newdev->info, - VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)= && - virDomainDeviceInfoCopy(&newdev->info, &olddev->info) < 0) { - goto cleanup; - } - if (!virPCIDeviceAddressEqual(&olddev->info.addr.pci, - &newdev->info.addr.pci)) { - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", - _("cannot modify network device guest PCI address")= ); - goto cleanup; - } /* grab alias from olddev if not set in newdev */ if (!newdev->info.alias && VIR_STRDUP(newdev->info.alias, olddev->info.alias) < 0) @@ -3469,26 +3455,50 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, =20 /* device alias is checked already in virDomainDefCompatibleDevice */ =20 + if (newdev->info.rombar =3D=3D VIR_TRISTATE_BOOL_ABSENT) + newdev->info.rombar =3D olddev->info.rombar; if (olddev->info.rombar !=3D newdev->info.rombar) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", _("cannot modify network device rom bar setting")); goto cleanup; } + + if (!newdev->info.romfile && + VIR_STRDUP(newdev->info.romfile, olddev->info.romfile) < 0) + goto cleanup; if (STRNEQ_NULLABLE(olddev->info.romfile, newdev->info.romfile)) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", _("cannot modify network rom file")); goto cleanup; } + + if (newdev->info.bootIndex =3D=3D 0) + newdev->info.bootIndex =3D olddev->info.bootIndex; if (olddev->info.bootIndex !=3D newdev->info.bootIndex) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", _("cannot modify network device boot index setting"= )); goto cleanup; } + + if (newdev->info.romenabled =3D=3D VIR_TRISTATE_BOOL_ABSENT) + newdev->info.romenabled =3D olddev->info.romenabled; if (olddev->info.romenabled !=3D newdev->info.romenabled) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", _("cannot modify network device rom enabled setting= ")); goto cleanup; } + + /* if pci addr is missing or is invalid we overwrite it from olddev */ + if (!virDomainDeviceAddressIsValid(&newdev->info, + VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI)= ) { + newdev->info.addr.pci =3D olddev->info.addr.pci; + } + if (!virPCIDeviceAddressEqual(&olddev->info.addr.pci, + &newdev->info.addr.pci)) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("cannot modify network device guest PCI address")= ); + goto cleanup; + } /* (end of device info checks) */ =20 if (STRNEQ_NULLABLE(olddev->filter, newdev->filter) || --=20 2.17.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list