From nobody Mon Feb 9 02:36:34 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1669126148; cv=none; d=zohomail.com; s=zohoarc; b=Kmqgms43uqVForCEQx7EWwTYV1yvueNHVgvECYYfzWe6tV72VQf5gHEDTsZcqGEzIoyrAFToc6eo2wYKtPWOLrrzDF41bqCD0ouzkBL5lLJWb1oafejpPvVeljmCqwYxBwO3m+t8QOykl+KA2C/o31Jm4QgwO15FxjCkZT/wJPo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1669126148; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=5VHUp+dJjOHibZjC4YtJSoKnELBBvaNeToyOrLBd1dg=; b=PxCxfBUl0PZQ5GidJryfqOIj4ghQxwVnFrtm7l6l+wikD7hjAsld0qPGeUciOQrD9ZWlynOMHyRcbChkoIS1bMEwTc96ePqsoYpDoxnrHymC6UqUaI/DGZJp+bqWo6WjUxmyG+PGiKa0KDSOmsbgbDRrKQ9kVnofts6b3ayyvjE= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by mx.zohomail.com with SMTPS id 1669126148582372.0597261216392; Tue, 22 Nov 2022 06:09:08 -0800 (PST) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-199-tZxsejbTOcaXPKH8PVBufw-1; Tue, 22 Nov 2022 09:09:04 -0500 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id EE28B85A588; Tue, 22 Nov 2022 14:09:00 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id D9689112132D; Tue, 22 Nov 2022 14:09:00 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 90B231946589; Tue, 22 Nov 2022 14:08:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 6760A1946587 for ; Tue, 22 Nov 2022 14:08:54 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 57CB41415114; Tue, 22 Nov 2022 14:08:54 +0000 (UTC) Received: from speedmetal.redhat.com (ovpn-208-20.brq.redhat.com [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 27AE7140EBF3; Tue, 22 Nov 2022 14:08:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1669126147; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=5VHUp+dJjOHibZjC4YtJSoKnELBBvaNeToyOrLBd1dg=; b=DnrtmswqXE1zBnVh/18dCsH0KhJNFNag2ALDMhzUw5EALoDRF/lvLCRhEgBDMwz5wWqChU 270+dpq+7toXM3LZbbygD8pGOkjzgZizACL2CUImgPkNwPAZDWFtB628F3OK9B4KHs5xqA 9AH3czyCE5yfyxZfg/bdkmPH62Ds5n4= X-MC-Unique: tZxsejbTOcaXPKH8PVBufw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v3] qemu: Don't report spurious errors from vCPU tid validation on hotunplug timeout Date: Tue, 22 Nov 2022 15:08:43 +0100 Message-Id: <82ff159672c83e737b044d28398a12019fffbf9d.1669126039.git.pkrempa@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Partha Satapathy , Shaleen Bathla , Peter Krempa Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.3 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1669126149047100001 Content-Type: text/plain; charset="utf-8" From: Shaleen Bathla Use of qemuDomainValidateVcpuInfo in the helpers for hotplug and unplug of vCPUs can lead to spurious errors reported such as: internal error: qemu didn't report thread id for vcpu 'XX'" The reason for this is that qemuDomainValidateVcpuInfo validates the state of all vCPUs against the expected state of vCPUs. If an unplug operation completed before libvirt was unable to process it yet the expected state could not reflect the current state. To avoid spurious errors the qemuDomainHotplugAddVcpu and qemuDomainRemoveVcpu functions are modified to do localized validation only for the vCPUs they actually modify. We also now ensure that the cgroups are modified before bailing out on error for any vCPUs which passed validation. Additionally in order for qemuDomainRemoveVcpuAlias to be able to find the unplugged vCPU we must ensure that qemuDomainRefreshVcpuInfo does not clear out the alias in case when the vCPU is no longer reported by qemu. Co-authored-by: Partha Satapathy Signed-off-by: Shaleen Bathla Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- v3 addresses my review feedback of the original patch, as well as rewrites the commit message for more clarity. src/qemu/qemu_domain.c | 6 +++-- src/qemu/qemu_hotplug.c | 53 ++++++++++++++++++++++++----------------- 2 files changed, 35 insertions(+), 24 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index ef1a9c8c74..64ebec626c 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -9795,8 +9795,10 @@ qemuDomainRefreshVcpuInfo(virDomainObj *vm, vcpupriv->vcpus =3D info[i].vcpus; VIR_FREE(vcpupriv->type); vcpupriv->type =3D g_steal_pointer(&info[i].type); - VIR_FREE(vcpupriv->alias); - vcpupriv->alias =3D g_steal_pointer(&info[i].alias); + if (info[i].alias) { + VIR_FREE(vcpupriv->alias); + vcpupriv->alias =3D g_steal_pointer(&info[i].alias); + } virJSONValueFree(vcpupriv->props); vcpupriv->props =3D g_steal_pointer(&info[i].props); vcpupriv->enable_id =3D info[i].id; diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index da92ced2f4..6e300f547c 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -6088,38 +6088,37 @@ qemuDomainRemoveVcpu(virDomainObj *vm, qemuDomainVcpuPrivate *vcpupriv =3D QEMU_DOMAIN_VCPU_PRIVATE(vcpuinfo); int oldvcpus =3D virDomainDefGetVcpus(vm->def); unsigned int nvcpus =3D vcpupriv->vcpus; - virErrorPtr save_error =3D NULL; size_t i; + ssize_t offlineVcpuWithTid =3D -1; if (qemuDomainRefreshVcpuInfo(vm, VIR_ASYNC_JOB_NONE, false) < 0) return -1; - /* validation requires us to set the expected state prior to calling i= t */ for (i =3D vcpu; i < vcpu + nvcpus; i++) { vcpuinfo =3D virDomainDefGetVcpu(vm->def, i); - vcpuinfo->online =3D false; + vcpupriv =3D QEMU_DOMAIN_VCPU_PRIVATE(vcpuinfo); + + if (vcpupriv->tid =3D=3D 0) { + vcpuinfo->online =3D false; + /* Clear the alias as VCPU is now unplugged */ + VIR_FREE(vcpupriv->alias); + ignore_value(virCgroupDelThread(priv->cgroup, VIR_CGROUP_THREA= D_VCPU, i)); + } else { + if (offlineVcpuWithTid =3D=3D -1) + offlineVcpuWithTid =3D i; + } } - if (qemuDomainValidateVcpuInfo(vm) < 0) { - /* rollback vcpu count if the setting has failed */ + if (offlineVcpuWithTid !=3D -1) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("qemu reported thread id for inactive vcpu '%zu'"= ), + offlineVcpuWithTid); virDomainAuditVcpu(vm, oldvcpus, oldvcpus - nvcpus, "update", fals= e); - - for (i =3D vcpu; i < vcpu + nvcpus; i++) { - vcpuinfo =3D virDomainDefGetVcpu(vm->def, i); - vcpuinfo->online =3D true; - } return -1; } virDomainAuditVcpu(vm, oldvcpus, oldvcpus - nvcpus, "update", true); - virErrorPreserveLast(&save_error); - - for (i =3D vcpu; i < vcpu + nvcpus; i++) - ignore_value(virCgroupDelThread(priv->cgroup, VIR_CGROUP_THREAD_VC= PU, i)); - - virErrorRestore(&save_error); - return 0; } @@ -6141,6 +6140,9 @@ qemuDomainRemoveVcpuAlias(virDomainObj *vm, return; } } + + VIR_DEBUG("vcpu '%s' not found in vcpulist of domain '%s'", + alias, vm->def->name); } @@ -6209,6 +6211,7 @@ qemuDomainHotplugAddVcpu(virQEMUDriver *driver, int rc; int oldvcpus =3D virDomainDefGetVcpus(vm->def); size_t i; + bool vcpuTidMissing =3D false; if (!qemuDomainSupportsNewVcpuHotplug(vm)) { virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", @@ -6238,20 +6241,26 @@ qemuDomainHotplugAddVcpu(virQEMUDriver *driver, if (qemuDomainRefreshVcpuInfo(vm, VIR_ASYNC_JOB_NONE, false) < 0) return -1; - /* validation requires us to set the expected state prior to calling i= t */ for (i =3D vcpu; i < vcpu + nvcpus; i++) { vcpuinfo =3D virDomainDefGetVcpu(vm->def, i); vcpupriv =3D QEMU_DOMAIN_VCPU_PRIVATE(vcpuinfo); vcpuinfo->online =3D true; - if (vcpupriv->tid > 0 && - qemuProcessSetupVcpu(vm, i, true) < 0) - return -1; + if (vcpupriv->tid > 0) { + if (qemuProcessSetupVcpu(vm, i, true) < 0) { + return -1; + } + } else { + vcpuTidMissing =3D true; + } } - if (qemuDomainValidateVcpuInfo(vm) < 0) + if (vcpuTidMissing && qemuDomainHasVcpuPids(vm)) { + virReportError(VIR_ERR_INTERNAL_ERROR, + _("qemu didn't report thread id for vcpu '%zu'"), i= ); return -1; + } qemuDomainVcpuPersistOrder(vm->def); --=20 2.37.3