From nobody Mon May 6 23:23:40 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 ARC-Seal: i=1; a=rsa-sha256; t=1566994775; cv=none; d=zoho.com; s=zohoarc; b=IkU9EYyR1wn23gvyYYwK4cwMw82m3w8aZFFdR7mCmdRIVbyVgwRQKajwKQb4MSeeiL+Ag7+hkI1y1rOyr9gbJjc+U6O2HxyEI8hAYjRulfLhb3MmUwXLwadcOpWzRjO4VkvwLU30zytkZ0fEB0poqVq1tQmfi1v+GcH8B/3F4eQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1566994775; h=Content-Type:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=t3eiu+RR3eoQAnDM33ygO3NNhPKHv4Ave2mHgfUDalY=; b=X+nFhQD9zGwalaCjKWNMO5Bz39yB083YjmxSV+UPgQez45qq4M1zg7Wky3vAhqrIz3tUh47sSlIH0FtWIOXYdISQqN40hQlWzXwkR2LpFSSixomLwcmYU3K4I6gpPd5rcZ0FUb0WPX9qhSvT+0pjA3yXtX2PaiJpRRx8lA+6Q4g= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1566994775097102.13011408993395; Wed, 28 Aug 2019 05:19:35 -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 DC48E46; Wed, 28 Aug 2019 12:19:33 +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 B360F5D9C9; Wed, 28 Aug 2019 12:19:33 +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 6F1ED24F33; Wed, 28 Aug 2019 12:19:33 +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 x7QBWHD7031503 for ; Mon, 26 Aug 2019 07:32:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id B3855450E; Mon, 26 Aug 2019 11:32:17 +0000 (UTC) Received: from mx1.redhat.com (ext-mx08.extmail.prod.ext.phx2.redhat.com [10.5.110.32]) by smtp.corp.redhat.com (Postfix) with ESMTPS id ADEF619C70 for ; Mon, 26 Aug 2019 11:32:15 +0000 (UTC) Received: from huawei.com (szxga01-in.huawei.com [45.249.212.187]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id F2DC4C057F88 for ; Mon, 26 Aug 2019 11:32:12 +0000 (UTC) Received: from DGGEMM404-HUB.china.huawei.com (unknown [172.30.72.55]) by Forcepoint Email with ESMTP id 9361F3C997AAE6EE3F00 for ; Mon, 26 Aug 2019 19:32:06 +0800 (CST) Received: from DGGEMM501-MBX.china.huawei.com ([169.254.1.202]) by DGGEMM404-HUB.china.huawei.com ([10.3.20.212]) with mapi id 14.03.0439.000; Mon, 26 Aug 2019 19:31:56 +0800 From: "wujing (O)" To: "libvir-list@redhat.com" Thread-Topic: [libvirt] [PATCH] qemu: Use the same def when attaching device live and config Thread-Index: AdVcADVPd6xa5h+aT1eOOIcAKvR9Nw== Date: Mon, 26 Aug 2019 11:31:56 +0000 Message-ID: <321C97C684C0984AA2B0A18CD1A272110ABEF2B0@DGGEMM501-MBX.china.huawei.com> Accept-Language: zh-CN, en-US Content-Language: zh-CN X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [10.133.201.172] MIME-Version: 1.0 X-CFilter-Loop: Reflected X-Greylist: Sender passed SPF test, Sender IP whitelisted by DNSRBL, ACL 238 matched, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 26 Aug 2019 11:32:14 +0000 (UTC) X-Greylist: inspected by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Mon, 26 Aug 2019 11:32:14 +0000 (UTC) for IP:'45.249.212.187' DOMAIN:'szxga01-in.huawei.com' HELO:'huawei.com' FROM:'wujing42@huawei.com' RCPT:'' X-RedHat-Spam-Score: -2.301 (HTML_MESSAGE, RCVD_IN_DNSWL_MED, SPF_HELO_PASS, SPF_PASS) 45.249.212.187 szxga01-in.huawei.com 45.249.212.187 szxga01-in.huawei.com X-Scanned-By: MIMEDefang 2.78 on 10.5.110.32 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-loop: libvir-list@redhat.com X-Mailman-Approved-At: Wed, 28 Aug 2019 08:19:20 -0400 Cc: "Xuyandong \(Yandong Xu\)" Subject: [libvirt] [PATCH] qemu: Use the same def when attaching device live and config 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: multipart/mixed; boundary="===============2218799724938788617==" 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.6.2 (mx1.redhat.com [10.5.110.71]); Wed, 28 Aug 2019 12:19:34 +0000 (UTC) --===============2218799724938788617== Content-Language: zh-CN Content-Type: multipart/alternative; boundary="_000_321C97C684C0984AA2B0A18CD1A272110ABEF2B0DGGEMM501MBXchi_" --_000_321C97C684C0984AA2B0A18CD1A272110ABEF2B0DGGEMM501MBXchi_ Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable Patch 55ce6564634 caused a problem fixed in 1e0534a7702, described as below= : Some members are generated during XML parse (e.g. MAC address of an interface); However, with current implementation, if we are plugging a device both to persistent and live config, we parse given XML twice: first time for live, second for config. This is wrong then as the second time we are not guaranteed to generate same values as we did for the first time. To solve that, we should use the same def when attaching a device config and live. And leave the current process unchanged when using --config and --live separately. Signed-off-by: Wu Jing --- src/qemu/qemu_driver.c | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 617d7d5..eca54d0 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -8615,6 +8615,22 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObjPtr = vm, if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) goto cleanup; + if (flags & VIR_DOMAIN_AFFECT_CONFIG && + flags & VIR_DOMAIN_AFFECT_LIVE) { + /* If we are affecting both CONFIG and LIVE + * use the same xml of device preferentially + * to make the configuration consistent. + */ + devLive =3D virDomainDeviceDefParse(xml, vm->def, + caps, driver->xmlopt, + parse_flags); + if (!devLive) + goto cleanup; + devConf =3D virDomainDeviceDefCopy(devLive, vm->def, caps, driver-= >xmlopt); + if (!devConf) + goto cleanup; + } + /* The config and live post processing address auto-generation algorit= hms * rely on the correct vm->def or vm->newDef being passed, so call the * device parse based on which definition is in use */ @@ -8623,7 +8639,8 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObjPtr v= m, if (!vmdef) goto cleanup; - if (!(devConf =3D virDomainDeviceDefParse(xml, vmdef, caps, + if (!devConf && + !(devConf =3D virDomainDeviceDefParse(xml, vmdef, caps, driver->xmlopt, parse_flag= s))) goto cleanup; @@ -8643,7 +8660,8 @@ qemuDomainAttachDeviceLiveAndConfig(virDomainObjPtr v= m, } if (flags & VIR_DOMAIN_AFFECT_LIVE) { - if (!(devLive =3D virDomainDeviceDefParse(xml, vm->def, caps, + if (!devLive && + !(devLive =3D virDomainDeviceDefParse(xml, vm->def, caps, driver->xmlopt, parse_flag= s))) goto cleanup; -- 2.19.1 --_000_321C97C684C0984AA2B0A18CD1A272110ABEF2B0DGGEMM501MBXchi_ Content-Type: text/html; charset="us-ascii" Content-Transfer-Encoding: quoted-printable

Patch 55ce6564634 caused a prob= lem fixed in 1e0534a7702, described as below:

Some members are generated duri= ng XML parse (e.g. MAC address of

an interface); However, with cu= rrent implementation, if we

are plugging a device both to p= ersistent and live config,

we parse given XML twice: first= time for live, second for config.

This is wrong then as the secon= d time we are not guaranteed

to generate same values as we d= id for the first time.

 

To solve that, we should use th= e same def when attaching a device

config and live. And leave the = current process unchanged when

using --config and --live separ= ately.

 

Signed-off-by: Wu Jing <wuji= ng42@huawei.com>

---

src/qemu/qemu_driver.c | 22 = 3;++++++++++++++= 3;++++--

1 file changed, 20 insertions(&= #43;), 2 deletions(-)

 

diff --git a/src/qemu/qemu_driv= er.c b/src/qemu/qemu_driver.c

index 617d7d5..eca54d0 100644

--- a/src/qemu/qemu_driver.c

+++ b/src/qemu/qemu= _driver.c

@@ -8615,6 +8615,22 @@ qemu= DomainAttachDeviceLiveAndConfig(virDomainObjPtr vm,

     if (!(= caps =3D virQEMUDriverGetCapabilities(driver, false)))

     &= nbsp;   goto cleanup;

 

+    if (fla= gs & VIR_DOMAIN_AFFECT_CONFIG &&

+    &n= bsp;   flags & VIR_DOMAIN_AFFECT_LIVE) {

+    &n= bsp;   /* If we are affecting both CONFIG and LIVE

+    &n= bsp;    * use the same xml of device preferentially

+    &n= bsp;    * to make the configuration consistent.

+    &n= bsp;    */

+    &n= bsp;   devLive =3D virDomainDeviceDefParse(xml, vm->def,<= /o:p>

+    &n= bsp;            = ;            &n= bsp;            caps= , driver->xmlopt,

+    &n= bsp;            = ;            &n= bsp;            pars= e_flags);

+    &n= bsp;   if (!devLive)

+    &n= bsp;       goto cleanup;

+    &n= bsp;   devConf =3D virDomainDeviceDefCopy(devLive, vm->def, ca= ps, driver->xmlopt);

+    &n= bsp;   if (!devConf)

+    &n= bsp;       goto cleanup;

+    }<= /o:p>

+

     /* The= config and live post processing address auto-generation algorithms

      = * rely on the correct vm->def or vm->newDef being passed, so call the=

      = * device parse based on which definition is in use */

@@ -8623,7 +8639,8 @@ qemuD= omainAttachDeviceLiveAndConfig(virDomainObjPtr vm,

     &= nbsp;   if (!vmdef)

     &= nbsp;       goto cleanup;

 

-     =    if (!(devConf =3D virDomainDeviceDefParse(xml, vmdef, caps,

+     &= nbsp;  if (!devConf &&

+    &n= bsp;       !(devConf =3D virDomainDeviceDefPa= rse(xml, vmdef, caps,

     &= nbsp;           &nbs= p;            &= nbsp;           &nbs= p;      driver->xmlopt, parse_flags)))

     &= nbsp;       goto cleanup;

 

@@ -8643,7 +8660,8 @@ qemuD= omainAttachDeviceLiveAndConfig(virDomainObjPtr vm,

     }=

 

     if (fl= ags & VIR_DOMAIN_AFFECT_LIVE) {

-     =    if (!(devLive =3D virDomainDeviceDefParse(xml, vm->def, cap= s,

+    &n= bsp;   if (!devLive &&

+    &n= bsp;       !(devLive =3D virDomainDeviceDefPa= rse(xml, vm->def, caps,

     &= nbsp;           &nbs= p;             =             &nb= sp;     driver->xmlopt, parse_flags)))

     &= nbsp;       goto cleanup;

 

--

2.19.1

--_000_321C97C684C0984AA2B0A18CD1A272110ABEF2B0DGGEMM501MBXchi_-- --===============2218799724938788617== Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Content-Disposition: inline -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list --===============2218799724938788617==--