From nobody Tue Dec 16 08:42:50 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1499864223723295.38717644947917; Wed, 12 Jul 2017 05:57:03 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 0F0FA4E909; Wed, 12 Jul 2017 12:57:01 +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 A6C165D6A6; Wed, 12 Jul 2017 12:57: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 ACB271800217; Wed, 12 Jul 2017 12:56:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v6CCuv6c022832 for ; Wed, 12 Jul 2017 08:56:57 -0400 Received: by smtp.corp.redhat.com (Postfix) id E93904D745; Wed, 12 Jul 2017 12:56:57 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.187]) by smtp.corp.redhat.com (Postfix) with ESMTPS id BAE884D748 for ; Wed, 12 Jul 2017 12:56:55 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id AF51510086B; Wed, 12 Jul 2017 14:56:54 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 0F0FA4E909 Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=libvir-list-bounces@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com 0F0FA4E909 From: Jiri Denemark To: libvir-list@redhat.com Date: Wed, 12 Jul 2017 14:56:50 +0200 Message-Id: <876f7287ace9fcec1283da71efcc2572f42529cf.1499864108.git.jdenemar@redhat.com> In-Reply-To: References: In-Reply-To: References: Mail-Followup-To: libvir-list@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 4/7] qemu: Add qemuProcessUpdateLiveGuestCPU 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.38]); Wed, 12 Jul 2017 12:57:01 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Separated from qemuProcessUpdateAndVerifyCPU to handle updating of an active guest CPU definition according to live data from QEMU. Signed-off-by: Jiri Denemark --- src/qemu/qemu_process.c | 70 +++++++++++++++++++++++++++++----------------= ---- 1 file changed, 42 insertions(+), 28 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index ebd13057b..926c64197 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4011,17 +4011,53 @@ qemuProcessVerifyCPU(virDomainObjPtr vm, =20 =20 static int +qemuProcessUpdateLiveGuestCPU(virDomainObjPtr vm, + virCPUDataPtr enabled, + virCPUDataPtr disabled) +{ + virDomainDefPtr def =3D vm->def; + qemuDomainObjPrivatePtr priv =3D vm->privateData; + virCPUDefPtr orig =3D NULL; + int rc; + int ret =3D -1; + + if (!enabled || + !def->cpu || + (def->cpu->mode =3D=3D VIR_CPU_MODE_CUSTOM && + !def->cpu->model)) + return 0; + + if (!(orig =3D virCPUDefCopy(def->cpu))) + goto cleanup; + + if ((rc =3D virCPUUpdateLive(def->os.arch, def->cpu, enabled, disabled= )) < 0) { + goto cleanup; + } else if (rc =3D=3D 0) { + /* Store the original CPU in priv if QEMU changed it and we didn't + * get the original CPU via migration, restore, or snapshot revert. + */ + if (!priv->origCPU && !virCPUDefIsEqual(def->cpu, orig, false)) + VIR_STEAL_PTR(priv->origCPU, orig); + + def->cpu->check =3D VIR_CPU_CHECK_FULL; + } + + ret =3D 0; + + cleanup: + virCPUDefFree(orig); + return ret; +} + + +static int qemuProcessUpdateAndVerifyCPU(virQEMUDriverPtr driver, virDomainObjPtr vm, qemuDomainAsyncJob asyncJob) { - virDomainDefPtr def =3D vm->def; virCPUDataPtr cpu =3D NULL; virCPUDataPtr disabled =3D NULL; - qemuDomainObjPrivatePtr priv =3D vm->privateData; - int rc; int ret =3D -1; - virCPUDefPtr orig =3D NULL; =20 if (qemuProcessFetchGuestCPU(driver, vm, asyncJob, &cpu, &disabled) < = 0) goto cleanup; @@ -4029,36 +4065,14 @@ qemuProcessUpdateAndVerifyCPU(virQEMUDriverPtr driv= er, if (qemuProcessVerifyCPU(vm, cpu) < 0) goto cleanup; =20 - if (cpu) { - if (!def->cpu || - (def->cpu->mode =3D=3D VIR_CPU_MODE_CUSTOM && - !def->cpu->model)) { - ret =3D 0; - goto cleanup; - } - - if (!(orig =3D virCPUDefCopy(def->cpu))) - goto cleanup; - - if ((rc =3D virCPUUpdateLive(def->os.arch, def->cpu, cpu, disabled= )) < 0) { - goto cleanup; - } else if (rc =3D=3D 0) { - /* Store the original CPU in priv if QEMU changed it and we di= dn't - * get the original CPU via migration, restore, or snapshot re= vert. - */ - if (!priv->origCPU && !virCPUDefIsEqual(def->cpu, orig, false)) - VIR_STEAL_PTR(priv->origCPU, orig); - - def->cpu->check =3D VIR_CPU_CHECK_FULL; - } - } + if (qemuProcessUpdateLiveGuestCPU(vm, cpu, disabled) < 0) + goto cleanup; =20 ret =3D 0; =20 cleanup: virCPUDataFree(cpu); virCPUDataFree(disabled); - virCPUDefFree(orig); return ret; } =20 --=20 2.13.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list