From nobody Tue Dec 16 08:53:01 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 1499864235484963.3415417860775; Wed, 12 Jul 2017 05:57:15 -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 72AE7C057FAB; Wed, 12 Jul 2017 12:57:10 +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 4E5A26E501; Wed, 12 Jul 2017 12:57:10 +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 EEB1C3FAE4; Wed, 12 Jul 2017 12:57:09 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v6CCuxP5022858 for ; Wed, 12 Jul 2017 08:56:59 -0400 Received: by smtp.corp.redhat.com (Postfix) id 786EB6BF63; Wed, 12 Jul 2017 12:56:59 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.187]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 4BCD360841 for ; Wed, 12 Jul 2017 12:56:59 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id B586B10086E; Wed, 12 Jul 2017 14:56:54 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 72AE7C057FAB Authentication-Results: ext-mx08.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx08.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 72AE7C057FAB From: Jiri Denemark To: libvir-list@redhat.com Date: Wed, 12 Jul 2017 14:56:53 +0200 Message-Id: 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.13 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 7/7] qemu: Update host-model CPUs on reconnect 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.32]); Wed, 12 Jul 2017 12:57:11 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" When libvirt starts a new QEMU domain, it replaces host-model CPUs with the appropriate custom CPU definition. However, when reconnecting to a domain started by older libvirt (< 2.3), the domain would still have a host-model CPU in its active definition. https://bugzilla.redhat.com/show_bug.cgi?id=3D1463957 Signed-off-by: Jiri Denemark --- src/qemu/qemu_process.c | 48 +++++++++++++++++++++++++++++++++++++++++++++= +++ 1 file changed, 48 insertions(+) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 2339de41c..0193c3591 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -3756,6 +3756,30 @@ qemuProcessUpdateAndVerifyCPU(virQEMUDriverPtr drive= r, =20 =20 static int +qemuProcessUpdateCPU(virQEMUDriverPtr driver, + virDomainObjPtr vm, + qemuDomainAsyncJob asyncJob) +{ + virCPUDataPtr cpu =3D NULL; + virCPUDataPtr disabled =3D NULL; + int ret =3D -1; + + if (qemuProcessFetchGuestCPU(driver, vm, asyncJob, &cpu, &disabled) < = 0) + goto cleanup; + + if (qemuProcessUpdateLiveGuestCPU(vm, cpu, disabled) < 0) + goto cleanup; + + ret =3D 0; + + cleanup: + virCPUDataFree(cpu); + virCPUDataFree(disabled); + return ret; +} + + +static int qemuPrepareNVRAM(virQEMUDriverConfigPtr cfg, virDomainObjPtr vm) { @@ -6850,6 +6874,30 @@ qemuProcessReconnect(void *opaque) ignore_value(qemuSecurityCheckAllLabel(driver->securityManager, obj->def)); =20 + /* If the domain with a host-model CPU was started by an old libvirt + * (< 2.3) which didn't replace the CPU with a custom one, let's do it= now + * since the rest of our code does not really expect a host-model CPU = in a + * running domain. + */ + if (virQEMUCapsGuestIsNative(caps->host.arch, obj->def->os.arch) && + caps->host.cpu && + obj->def->cpu && + obj->def->cpu->mode =3D=3D VIR_CPU_MODE_HOST_MODEL) { + virCPUDefPtr host; + + if (!(host =3D virCPUCopyMigratable(caps->host.cpu->arch, caps->ho= st.cpu))) + goto error; + + if (virCPUUpdate(obj->def->os.arch, obj->def->cpu, host) < 0) { + virCPUDefFree(host); + goto error; + } + virCPUDefFree(host); + + if (qemuProcessUpdateCPU(driver, obj, QEMU_ASYNC_JOB_NONE) < 0) + goto error; + } + if (qemuDomainRefreshVcpuInfo(driver, obj, QEMU_ASYNC_JOB_NONE, true) = < 0) goto error; =20 --=20 2.13.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list