From nobody Sat Nov 23 08:08:17 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1731337172899237.64540008910797; Mon, 11 Nov 2024 06:59:32 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id D7CFC1917; Mon, 11 Nov 2024 09:59:31 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 363A618F3; Mon, 11 Nov 2024 09:59:14 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 7439018DE; Mon, 11 Nov 2024 09:59:11 -0500 (EST) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id C950818DC for ; Mon, 11 Nov 2024 09:59:10 -0500 (EST) Received: from mail-wr1-f70.google.com (mail-wr1-f70.google.com [209.85.221.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-85-Zdxjx6uXPuG8YlvKCFZw4w-1; Mon, 11 Nov 2024 09:59:09 -0500 Received: by mail-wr1-f70.google.com with SMTP id ffacd0b85a97d-37d52ca258eso2385909f8f.3 for ; Mon, 11 Nov 2024 06:59:09 -0800 (PST) Received: from wheatley.localdomain (nat-pool-brq-t.redhat.com. [213.175.37.10]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-381ed9ea7c3sm13386746f8f.80.2024.11.11.06.59.07 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 11 Nov 2024 06:59:07 -0800 (PST) Received: from wheatley.brq.redhat.com (wheatley.k8r.cz [127.0.0.1]) by wheatley.localdomain (Postfix) with ESMTP id 29EE53A7BAB8; Mon, 11 Nov 2024 15:59:07 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-1.5 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1731337150; h=from:from: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; bh=4gY32BHd3nsA1lxT+XoLV0QFwzRF1UlT7FQqf1ge+QY=; b=HClwgW8tqso97ni5Kkpp2RJNHtKbNzL+wGhOfYlVPVFikiN57Luyf9kn4sfa9uvsHMQFLL Li+6A3GunUhJnO0r2V0z51eeOx4pasD10rq0sf+jg57aq1hSakNCmIc7WBaT3oy1wNKwiS 3WU4aGFcaApwpUKkFDRkFbnAokAFXuA= X-MC-Unique: Zdxjx6uXPuG8YlvKCFZw4w-1 X-Mimecast-MFC-AGG-ID: Zdxjx6uXPuG8YlvKCFZw4w X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1731337148; x=1731941948; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=4gY32BHd3nsA1lxT+XoLV0QFwzRF1UlT7FQqf1ge+QY=; b=OCRiVP/tVFdyFgVEkm7ahNYSwQL4NNMy6sH6MvOHNcC3MyDitEmB5ff+JtG2BKpPp9 1pAbK5Lxr44X9glHG8Tn9/qwcrq7thdvCGir6I4YqybljVtdAbmgYfz9Ga0MTyQTsTnY cXuhTNUbqF52vSutkFigN1hFQYQFCYM+qrSvPnic6QuGxygFJkZqf+rFshZcXCZgEJJw HICRG7QfaFi1LO5OdJRk6B9qaeEefPs3q6OKV0LVoXjORTte3jdEgdtv0/vL7tmOiAzK /3uFACpYF9+oknaRWL7mERzfyYRRHRf/nI/Ltg1Gu4PIYIBCUaZFy1Bd0sO4T2wvG9W6 povg== X-Gm-Message-State: AOJu0YxB6WGxp5Zbe5OK11WPrY9Q3OwSdLlgoJO9IqmdOnbaSeXJz2+7 IOrGFsMnWg/v3BjwoM6Ci8l9/x/VpL8/hogZXPSHyob2oLv0IuNtqtJhYtpFhLBBg4j7BD6HWsC CaE2dzofv0F5mkElAhcXYRv0ZjM45hTmqRVXWWMlOzSQxpcTw/8fe2FVuxR1LkT4Ymahl/WTKrs 600BOs36kWRXeGNSy5D90F9CmfEIMATF4EWDVnjoY= X-Received: by 2002:a5d:6c68:0:b0:37d:3939:ad98 with SMTP id ffacd0b85a97d-381f182714fmr10783253f8f.3.1731337148325; Mon, 11 Nov 2024 06:59:08 -0800 (PST) X-Google-Smtp-Source: AGHT+IF/f64MhNrdACah+CqNhd3zUcm6K+BEyLnpEMcGVcrzbSj5SnUsY7vk2JtHoQTv+xrp2kHj8g== X-Received: by 2002:a5d:6c68:0:b0:37d:3939:ad98 with SMTP id ffacd0b85a97d-381f182714fmr10783238f8f.3.1731337147894; Mon, 11 Nov 2024 06:59:07 -0800 (PST) From: Martin Kletzander To: devel@lists.libvirt.org Subject: [PATCH v2] qemu_hotplug: Do not report unknown error when hot-unplugging non-existing device Date: Mon, 11 Nov 2024 15:59:01 +0100 Message-ID: X-Mailer: git-send-email 2.47.0 MIME-Version: 1.0 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: nGPAUpgEGWncCVl2POEs1QDYizp8xqB5_EurhnC1j9U_1731337148 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: D6ATBLD4J25C5KQHXUS7565WVGZZPUHU X-Message-ID-Hash: D6ATBLD4J25C5KQHXUS7565WVGZZPUHU X-MailFrom: mkletzan@redhat.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: pkrempa@redhat.com X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1731337177687116600 Content-Type: text/plain; charset="utf-8"; x-default="true" When qemuDomainDeleteDevice() gets "DeviceNotFound" error it is a special case as we're trying to remove a device which does not exists any more. Such occasion is indicated by the return value -2. Callers of the aforementioned function ought to base their behaviour on the return value. However not all callers take as much care for the return value as one could realistically anticipate. Follow the usual direction of removing possible backend object (in case of character devices), remove the device from its XML without waiting for the device removal from QEMU (since it is already not there) and basically follow the same algorithm as there is when the device was removed, skipping over the wait for the device removal. The overall return value also needs to be adjusted since qemuDomainDeleteDevice() does not set an error on the -2 return value and would otherwise trigger an unknown error being reported to the user or management application. Signed-off-by: Martin Kletzander Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_hotplug.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 8361d3d9c1b7..1b6ecb1cd1f9 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -6090,8 +6090,12 @@ qemuDomainDetachDeviceChr(virQEMUDriver *driver, if (rc < 0) goto cleanup; } else { - if (qemuDomainDeleteDevice(vm, tmpChr->info.alias) < 0) + ret =3D qemuDomainDeleteDevice(vm, tmpChr->info.alias); + if (ret < 0) { + if (ret =3D=3D -2) + ret =3D qemuDomainRemoveChrDevice(driver, vm, tmpChr, true= ); goto cleanup; + } } =20 if (guestfwd) { @@ -6595,18 +6599,19 @@ qemuDomainHotplugDelVcpu(virQEMUDriver *driver, =20 qemuDomainMarkDeviceAliasForRemoval(vm, vcpupriv->alias); =20 - if (qemuDomainDeleteDevice(vm, vcpupriv->alias) < 0) { - if (virDomainObjIsActive(vm)) + rc =3D qemuDomainDeleteDevice(vm, vcpupriv->alias); + if (rc < 0) { + if (rc =3D=3D -1 && virDomainObjIsActive(vm)) virDomainAuditVcpu(vm, oldvcpus, oldvcpus - nvcpus, "update", = false); goto cleanup; - } - - if ((rc =3D qemuDomainWaitForDeviceRemoval(vm)) <=3D 0) { - if (rc =3D=3D 0) - virReportError(VIR_ERR_OPERATION_TIMEOUT, "%s", - _("vcpu unplug request timed out. Unplug result= must be manually inspected in the domain")); + } else { + if ((rc =3D qemuDomainWaitForDeviceRemoval(vm)) <=3D 0) { + if (rc =3D=3D 0) + virReportError(VIR_ERR_OPERATION_TIMEOUT, "%s", + _("vcpu unplug request timed out. Unplug re= sult must be manually inspected in the domain")); =20 - goto cleanup; + goto cleanup; + } } =20 if (qemuDomainRemoveVcpu(vm, vcpu) < 0) --=20 2.47.0