From nobody Wed May 14 17:02:47 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; 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 1526918916932350.6560791913072; Mon, 21 May 2018 09:08:36 -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 2CC8E30C2869; Mon, 21 May 2018 16:08:35 +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 ED88B600CC; Mon, 21 May 2018 16:08:34 +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 A41394CA94; Mon, 21 May 2018 16:08:34 +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 w4LG8KIM030424 for ; Mon, 21 May 2018 12:08:20 -0400 Received: by smtp.corp.redhat.com (Postfix) id 90C5585778; Mon, 21 May 2018 16:08:20 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.192]) by smtp.corp.redhat.com (Postfix) with ESMTP id 36208AFD7F for ; Mon, 21 May 2018 16:08:20 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Mon, 21 May 2018 18:08:00 +0200 Message-Id: <5eea36e9f82a8a9ecd3ef6b385d492c18a0e5af0.1526918750.git.mprivozn@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 3/5] qemu: Split qemuDomainDetachDeviceLiveAndConfig 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.48]); Mon, 21 May 2018 16:08:35 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The aim is to have qemuDomainDetachDeviceLiveAndConfig() accept virDomainDeviceDefPtr. Therefore, new qemuDomainDetachDeviceXMLLiveAndConfig() which is a drop in replacement for the former. Signed-off-by: Michal Privoznik --- src/qemu/qemu_driver.c | 46 ++++++++++++++++++++++++++++++++++++---------- 1 file changed, 36 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 3a328e5d46..0e0c0ce53e 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -8661,15 +8661,16 @@ static int qemuDomainUpdateDeviceFlags(virDomainPtr= dom, return ret; } =20 + static int qemuDomainDetachDeviceLiveAndConfig(virQEMUDriverPtr driver, virDomainObjPtr vm, - const char *xml, + virDomainDeviceDefPtr dev, unsigned int flags) { virCapsPtr caps =3D NULL; virQEMUDriverConfigPtr cfg =3D NULL; - virDomainDeviceDefPtr dev =3D NULL, dev_copy =3D NULL; + virDomainDeviceDefPtr dev_copy =3D dev; unsigned int parse_flags =3D VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE; virDomainDefPtr vmdef =3D NULL; int ret =3D -1; @@ -8686,12 +8687,6 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriverPtr= driver, !(flags & VIR_DOMAIN_AFFECT_LIVE)) parse_flags |=3D VIR_DOMAIN_DEF_PARSE_INACTIVE; =20 - dev =3D dev_copy =3D virDomainDeviceDefParse(xml, vm->def, - caps, driver->xmlopt, - parse_flags); - if (dev =3D=3D NULL) - goto cleanup; - if (flags & VIR_DOMAIN_AFFECT_CONFIG && flags & VIR_DOMAIN_AFFECT_LIVE) { /* If we are affecting both CONFIG and LIVE @@ -8743,11 +8738,42 @@ qemuDomainDetachDeviceLiveAndConfig(virQEMUDriverPt= r driver, virObjectUnref(cfg); if (dev !=3D dev_copy) virDomainDeviceDefFree(dev_copy); - virDomainDeviceDefFree(dev); virDomainDefFree(vmdef); return ret; } =20 + +static int +qemuDomainDetachDeviceXMLLiveAndConfig(virQEMUDriverPtr driver, + virDomainObjPtr vm, + const char *xml, + unsigned int flags) +{ + virCapsPtr caps =3D NULL; + virDomainDeviceDefPtr dev =3D NULL; + unsigned int parse_flags =3D VIR_DOMAIN_DEF_PARSE_SKIP_VALIDATE; + int ret =3D -1; + + if (!(caps =3D virQEMUDriverGetCapabilities(driver, false))) + goto cleanup; + + if ((flags & VIR_DOMAIN_AFFECT_CONFIG) && + !(flags & VIR_DOMAIN_AFFECT_LIVE)) + parse_flags |=3D VIR_DOMAIN_DEF_PARSE_INACTIVE; + + if (!(dev =3D virDomainDeviceDefParse(xml, vm->def, + caps, driver->xmlopt, + parse_flags))) + goto cleanup; + + ret =3D qemuDomainDetachDeviceLiveAndConfig(driver, vm, dev, flags); + cleanup: + virDomainDeviceDefFree(dev); + virObjectUnref(caps); + return ret; +} + + static int qemuDomainDetachDeviceFlags(virDomainPtr dom, const char *xml, @@ -8769,7 +8795,7 @@ qemuDomainDetachDeviceFlags(virDomainPtr dom, if (virDomainObjUpdateModificationImpact(vm, &flags) < 0) goto endjob; =20 - if (qemuDomainDetachDeviceLiveAndConfig(driver, vm, xml, flags) < 0) + if (qemuDomainDetachDeviceXMLLiveAndConfig(driver, vm, xml, flags) < 0) goto endjob; =20 ret =3D 0; --=20 2.16.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list