From nobody Wed May 14 03:32:29 2025 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=126.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1530609630561789.404711750362; Tue, 3 Jul 2018 02:20:30 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 3BC4FFEBD; Tue, 3 Jul 2018 09:20: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 F24DC60175; Tue, 3 Jul 2018 09:20:28 +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 A76304A469; Tue, 3 Jul 2018 09:20:28 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.phx2.redhat.com [10.5.11.24]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w639KIfP015813 for ; Tue, 3 Jul 2018 05:20:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id AEBFD308BDB2; Tue, 3 Jul 2018 09:20:18 +0000 (UTC) Received: from mx1.redhat.com (ext-mx01.extmail.prod.ext.phx2.redhat.com [10.5.110.25]) by smtp.corp.redhat.com (Postfix) with ESMTPS id E5FC3308BDAC; Tue, 3 Jul 2018 09:20:15 +0000 (UTC) Received: from m50-110.126.com (m50-110.126.com [123.125.50.110]) by mx1.redhat.com (Postfix) with ESMTP id BA46981DEC; Tue, 3 Jul 2018 09:20:12 +0000 (UTC) Received: from localhost.localdomain (unknown [210.13.242.135]) by smtp4 (Coremail) with SMTP id jdKowAAHaferPztbAQ+EAQ--.1051S12; Tue, 03 Jul 2018 17:20:09 +0800 (CST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=126.com; s=s110527; h=From:Subject:Date:Message-Id:MIME-Version; bh=r9mXg o+MeisL2rL75LIJSnAjz24tZXCC803haYqRfwQ=; b=TQXZ7QfuQXw2aYt7vdNkt oEzyCz42Q59knKof6wlx3aCcrOnfFcu9vmxB+BGZcGS6JsyBi3ypF0OBn2gaEpmB ziQrETt2inK6tPSEGT1KtuICfKcjZk1xhW+QcdH/NrM5OFcFne1qRJ2JXrgDJ7+p SYhHjZxvC7kXPBr/hF7mXE= From: dubo163 To: libvir-list@redhat.com Date: Tue, 3 Jul 2018 05:19:21 -0400 Message-Id: <1530609577-9195-10-git-send-email-dubo163@126.com> In-Reply-To: <1530609577-9195-1-git-send-email-dubo163@126.com> References: <1530609577-9195-1-git-send-email-dubo163@126.com> MIME-Version: 1.0 X-CM-TRANSID: jdKowAAHaferPztbAQ+EAQ--.1051S12 X-Coremail-Antispam: 1Uf129KBjvJXoWxAr18Zr4DuFWDAw1kuFW7Jwb_yoWrGr48pF Z8AF1ayrWrJrsrX3ySqF48uF4Ut3ykW348Kr15Ww40q3sIk398Jw4aqFyFk343trZ7JFy2 yrWxXa4vga1SyFJanT9S1TB71UUUUUUqnTZGkaVYY2UrUUUUjbIjqfuFe4nvWSU5nxnvy2 9KBjDUYxBIdaVFxhVjvjDU0xZFpf9x07j-4SOUUUUU= X-Originating-IP: [210.13.242.135] X-CM-SenderInfo: 5gxe0iiwt6ij2wof0z/1tbiXwl4MFpD5kHJ5AAAsN X-Greylist: Sender passed SPF test, ACL 227 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 03 Jul 2018 09:20:15 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 03 Jul 2018 09:20:15 +0000 (UTC) for IP:'123.125.50.110' DOMAIN:'m50-110.126.com' HELO:'m50-110.126.com' FROM:'dubo163@126.com' RCPT:'' X-RedHat-Spam-Score: 5.305 ***** (DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, FREEMAIL_ENVFROM_END_DIGIT, FREEMAIL_FROM, RCVD_IN_ANBREP_L3, RCVD_IN_BL_SPAMCOP_NET, RCVD_IN_MSPIKE_BL, RCVD_IN_MSPIKE_L3, SPF_PASS) 123.125.50.110 m50-110.126.com 123.125.50.110 m50-110.126.com X-Scanned-By: MIMEDefang 2.83 on 10.5.110.25 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.24 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 09/25] lxc: Rearrange order in lxcDomainUpdateDeviceFlags 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-Type: text/plain; charset="utf-8" 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.29]); Tue, 03 Jul 2018 09:20:30 +0000 (UTC) X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZohoMail: RDKM_2 RSF_0 Z_629925259 SPT_0 From: John Ferlan Although commit e3497f3f noted that the LIVE option doesn't matter and removed the call to virDomainDefCompatibleDevice, it didn't go quite far enough and change the order of the checks and rework the code to just handle the config change causing a failure after virDomainObjUpdateModificationImpact updates the @flags. Since we only support config a lot of previously conditional code is now just inlined. Signed-off-by: John Ferlan ACKed-by: Michal Pr=C3=ADvozn=C3=ADk --- src/lxc/lxc_driver.c | 63 ++++++++++++++++++------------------------------= ---- 1 file changed, 21 insertions(+), 42 deletions(-) diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index aea48e5..1fc6c6a 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -4827,7 +4827,7 @@ static int lxcDomainUpdateDeviceFlags(virDomainPtr do= m, virCapsPtr caps =3D NULL; virDomainObjPtr vm =3D NULL; virDomainDefPtr vmdef =3D NULL; - virDomainDeviceDefPtr dev =3D NULL, dev_copy =3D NULL; + virDomainDeviceDefPtr dev =3D NULL; int ret =3D -1; virLXCDriverConfigPtr cfg =3D virLXCDriverGetConfig(driver); =20 @@ -4846,61 +4846,40 @@ static int lxcDomainUpdateDeviceFlags(virDomainPtr = dom, if (virDomainObjUpdateModificationImpact(vm, &flags) < 0) goto endjob; =20 - if (!(caps =3D virLXCDriverGetCapabilities(driver, false))) + if (flags & VIR_DOMAIN_AFFECT_LIVE) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("Unable to modify live devices")); goto endjob; + } =20 - dev =3D dev_copy =3D virDomainDeviceDefParse(xml, vm->def, - caps, driver->xmlopt, - VIR_DOMAIN_DEF_PARSE_INACTIVE= ); - if (dev =3D=3D NULL) + if (!(caps =3D virLXCDriverGetCapabilities(driver, false))) goto endjob; =20 - if (flags & VIR_DOMAIN_AFFECT_CONFIG && - flags & VIR_DOMAIN_AFFECT_LIVE) { - /* If we are affecting both CONFIG and LIVE - * create a deep copy of device as adding - * to CONFIG takes one instance. - */ - dev_copy =3D virDomainDeviceDefCopy(dev, vm->def, - caps, driver->xmlopt); - if (!dev_copy) - goto endjob; - } - - if (flags & VIR_DOMAIN_AFFECT_CONFIG) { - /* Make a copy for updated domain. */ - vmdef =3D virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt); - if (!vmdef) - goto endjob; + if (!(dev =3D virDomainDeviceDefParse(xml, vm->def, caps, driver->xmlo= pt, + VIR_DOMAIN_DEF_PARSE_INACTIVE))) + goto endjob; =20 - /* virDomainDefCompatibleDevice call is delayed until we know the - * device we're going to update. */ - if ((ret =3D lxcDomainUpdateDeviceConfig(vmdef, dev)) < 0) - goto endjob; - } + /* Make a copy for updated domain. */ + if (!(vmdef =3D virDomainObjCopyPersistentDef(vm, caps, driver->xmlopt= ))) + goto endjob; =20 - if (flags & VIR_DOMAIN_AFFECT_LIVE) { - virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", - _("Unable to modify live devices")); + /* virDomainDefCompatibleDevice call is delayed until we know the + * device we're going to update. */ + if (lxcDomainUpdateDeviceConfig(vmdef, dev) < 0) + goto endjob; =20 + if (virDomainSaveConfig(cfg->configDir, driver->caps, vmdef) < 0) goto endjob; - } =20 - /* Finally, if no error until here, we can save config. */ - if (flags & VIR_DOMAIN_AFFECT_CONFIG) { - ret =3D virDomainSaveConfig(cfg->configDir, driver->caps, vmdef); - if (!ret) { - virDomainObjAssignDef(vm, vmdef, false, NULL); - vmdef =3D NULL; - } - } + virDomainObjAssignDef(vm, vmdef, false, NULL); + vmdef =3D NULL; + ret =3D 0; + endjob: virLXCDomainObjEndJob(driver, vm); =20 cleanup: virDomainDefFree(vmdef); - if (dev !=3D dev_copy) - virDomainDeviceDefFree(dev_copy); virDomainDeviceDefFree(dev); virDomainObjEndAPI(&vm); virObjectUnref(caps); --=20 1.8.3.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list