From nobody Thu May 15 12:43:30 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 1507717640943841.5936762973591; Wed, 11 Oct 2017 03:27:20 -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 7D1A55114F; Wed, 11 Oct 2017 10:27:19 +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 5AFE718EF6; Wed, 11 Oct 2017 10:27:19 +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 0FD4B410B2; Wed, 11 Oct 2017 10:27:19 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v9BABLfw029564 for ; Wed, 11 Oct 2017 06:11:21 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7F6FB68B2B; Wed, 11 Oct 2017 10:11:21 +0000 (UTC) Received: from virval.usersys.redhat.com (unknown [10.43.2.105]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 544B168B39 for ; Wed, 11 Oct 2017 10:11:19 +0000 (UTC) Received: by virval.usersys.redhat.com (Postfix, from userid 500) id 4E60D10050D; Wed, 11 Oct 2017 12:11:18 +0200 (CEST) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 7D1A55114F Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx10.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Jiri Denemark To: libvir-list@redhat.com Date: Wed, 11 Oct 2017 12:11:14 +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.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 1/4] qemu: Separate CPU updating code from qemuProcessReconnect 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.39]); Wed, 11 Oct 2017 10:27:20 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The new function is called qemuProcessRefreshCPU. Signed-off-by: Jiri Denemark Reviewed-by: Pavel Hrdina --- src/qemu/qemu_process.c | 66 ++++++++++++++++++++++++++++++++-------------= ---- 1 file changed, 43 insertions(+), 23 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 0cb023095b..5ed6b68eb8 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6876,6 +6876,47 @@ qemuProcessRefreshDisks(virQEMUDriverPtr driver, } =20 =20 +static int +qemuProcessRefreshCPU(virQEMUDriverPtr driver, + virDomainObjPtr vm) +{ + virCapsPtr caps =3D virQEMUDriverGetCapabilities(driver, false); + virCPUDefPtr host =3D NULL; + int ret =3D -1; + + if (!virQEMUCapsGuestIsNative(caps->host.arch, vm->def->os.arch) || + !caps->host.cpu || + !vm->def->cpu) + return 0; + + if (!caps) + goto cleanup; + + /* 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 (vm->def->cpu->mode =3D=3D VIR_CPU_MODE_HOST_MODEL) { + if (!(host =3D virCPUCopyMigratable(caps->host.cpu->arch, caps->ho= st.cpu))) + goto cleanup; + + if (virCPUUpdate(vm->def->os.arch, vm->def->cpu, host) < 0) + goto cleanup; + + if (qemuProcessUpdateCPU(driver, vm, QEMU_ASYNC_JOB_NONE) < 0) + goto cleanup; + } + + ret =3D 0; + + cleanup: + virCPUDefFree(host); + virObjectUnref(caps); + return ret; +} + + struct qemuProcessReconnectData { virConnectPtr conn; virQEMUDriverPtr driver; @@ -7042,29 +7083,8 @@ 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 (qemuProcessRefreshCPU(driver, obj) < 0) + goto error; =20 if (qemuDomainRefreshVcpuInfo(driver, obj, QEMU_ASYNC_JOB_NONE, true) = < 0) goto error; --=20 2.14.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list