From nobody Wed May 8 23:13:12 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 1533119845626651.387306476385; Wed, 1 Aug 2018 03:37:25 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 40E4180F6B; Wed, 1 Aug 2018 10:37:22 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 69D28226F7; Wed, 1 Aug 2018 10:37:21 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id 6189F18052E9; Wed, 1 Aug 2018 10:37:19 +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 w71AbHcE029187 for ; Wed, 1 Aug 2018 06:37:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id B487E1C55D; Wed, 1 Aug 2018 10:37:17 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.43.2.5]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4ED481C55C for ; Wed, 1 Aug 2018 10:37:15 +0000 (UTC) From: Katerina Koukiou To: libvirt-list@redhat.com Date: Wed, 1 Aug 2018 12:37:13 +0200 Message-Id: <20180801103713.11698-1-kkoukiou@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] 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.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Wed, 01 Aug 2018 10:37:23 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" We need to first perform the checks for changed/missing elements and then we can overwrite the missing ones. Otherwise we might falsely report successfull update, because some elements 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 | 43 ++++++++++++++++++++++++++--------------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 1488f0a7c2..8d98c149e2 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 check for changes and + * then fill the missing newdev->info from olddev. */ - 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,51 @@ 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 all info struct */ + 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; + } /* (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