From nobody Sat May 4 09:04:57 2024 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; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1556635959; cv=none; d=zoho.com; s=zohoarc; b=P7xmFUlEJG97SGS7biLTFeW5I+ePzDhO0oVJJ9F7e4OjySr1g+L38mnyOSAhJ3IWbQx1a+heJRYdwuO8RsbEDyEG4NY+2345TSk6qPdnXr/asoCoUQgplyAR52ly56P8wQN+mWCQ9EfeIxXItAGrEtH8nIOzJ6HgtqyofclTf4Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1556635959; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To:ARC-Authentication-Results; bh=FRQBA8Zg6L7IDRtW/xPqM+6Izw4bwb5dRQTcmyXk20Q=; b=GUhtLkluOEp0XtwDYfO5xzIbUeIk3bnG2QuEchZyI7vSotRnW6w401ZJ+9IirbkeAKINMZ25afiR4oTmro1CZH8RKqDuWKK48mF1WtkOHrR3VvFeR6jY2TJBtD2Va2ODXvr7IbZlVeKKu0IhSyC/U2Qx9vvyllnkHdTnmqJBBOg= ARC-Authentication-Results: i=1; mx.zoho.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1556635959092570.9470747861485; Tue, 30 Apr 2019 07:52:39 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 4391981DF1; Tue, 30 Apr 2019 14:52:36 +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 95758171B0; Tue, 30 Apr 2019 14:52:35 +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 236AF3FB11; Tue, 30 Apr 2019 14:52:34 +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 x3UEpHtL016746 for ; Tue, 30 Apr 2019 10:51:17 -0400 Received: by smtp.corp.redhat.com (Postfix) id DE1B06D0A4; Tue, 30 Apr 2019 14:51:17 +0000 (UTC) Received: from moe.brq.redhat.com (unknown [10.43.2.30]) by smtp.corp.redhat.com (Postfix) with ESMTP id 64D4C6C511 for ; Tue, 30 Apr 2019 14:51:15 +0000 (UTC) From: Michal Privoznik To: libvir-list@redhat.com Date: Tue, 30 Apr 2019 16:51:12 +0200 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH] lib: Preserve error around virDomainNetReleaseActualDevice() 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: , 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.16 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Tue, 30 Apr 2019 14:52:37 +0000 (UTC) Content-Type: text/plain; charset="utf-8" This function is calling public API virNetworkLookupByName() which resets the error. Therefore, if virDomainNetReleaseActualDevice() is used in cleanup path it actually resets the original error that got us jump into 'cleanup' label. Signed-off-by: Michal Privoznik --- I've found this issue when trying to change QoS on an domain's and I've intentionally entered @floor bigger than corresponding network's average. Orders bigger. I mean, with this change the QoS is still kind of broken [1] but at least I'm getting some sensible error instead of "An error occurred, but the cause is unknown". 1: Thing is, when an is being updated (virsh update-device) then a new interface is actually created (virDomainNetAllocateActualDevice() is called), which is then set up and the old interface is then released. This works in theory, but for a fraction of a second we have two interfaces. Therefore the sum of their @floor-s might exceed the limit (which is MAX(network average, network peak)) and thus allocating new device will fail. Unfortunately, I don't have any bright idea around this. Maybe temporary setting newdev->bandwidth =3D NULL; then allocating new device and trying to set new bandwidth ourselves? That is still going to fail until the old interface is not released. Ideas are welcome. src/libxl/libxl_driver.c | 6 ++++++ src/lxc/lxc_driver.c | 3 +++ src/lxc/lxc_process.c | 3 +++ src/qemu/qemu_hotplug.c | 6 ++++++ 4 files changed, 18 insertions(+) diff --git a/src/libxl/libxl_driver.c b/src/libxl/libxl_driver.c index e7234c1479..2b9c6f1866 100644 --- a/src/libxl/libxl_driver.c +++ b/src/libxl/libxl_driver.c @@ -3380,6 +3380,7 @@ libxlDomainAttachNetDevice(libxlDriverPrivatePtr driv= er, int ret =3D -1; char mac[VIR_MAC_STRING_BUFLEN]; virConnectPtr conn =3D NULL; + virErrorPtr save_err =3D NULL; =20 libxl_device_nic_init(&nic); =20 @@ -3440,6 +3441,7 @@ libxlDomainAttachNetDevice(libxlDriverPrivatePtr driv= er, ret =3D 0; =20 cleanup: + virErrorPreserveLast(&save_err); libxl_device_nic_dispose(&nic); if (!ret) { vm->def->nets[vm->def->nnets++] =3D net; @@ -3450,6 +3452,7 @@ libxlDomainAttachNetDevice(libxlDriverPrivatePtr driv= er, } virObjectUnref(conn); virObjectUnref(cfg); + virErrorRestore(&save_err); return ret; } =20 @@ -3838,6 +3841,7 @@ libxlDomainDetachNetDevice(libxlDriverPrivatePtr driv= er, libxl_device_nic nic; char mac[VIR_MAC_STRING_BUFLEN]; int ret =3D -1; + virErrorPtr save_err =3D NULL; =20 libxl_device_nic_init(&nic); =20 @@ -3868,6 +3872,7 @@ libxlDomainDetachNetDevice(libxlDriverPrivatePtr driv= er, ret =3D 0; =20 cleanup: + virErrorPreserveLast(&save_err); libxl_device_nic_dispose(&nic); if (!ret) { if (detach->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK) { @@ -3882,6 +3887,7 @@ libxlDomainDetachNetDevice(libxlDriverPrivatePtr driv= er, virDomainNetRemove(vm->def, detachidx); } virObjectUnref(cfg); + virErrorRestore(&save_err); return ret; } =20 diff --git a/src/lxc/lxc_driver.c b/src/lxc/lxc_driver.c index 1980d0804e..9db2a02dee 100644 --- a/src/lxc/lxc_driver.c +++ b/src/lxc/lxc_driver.c @@ -4337,6 +4337,7 @@ lxcDomainDetachDeviceNetLive(virDomainObjPtr vm, virDomainNetType actualType; virDomainNetDefPtr detach =3D NULL; virNetDevVPortProfilePtr vport =3D NULL; + virErrorPtr save_err =3D NULL; =20 if ((detachidx =3D virDomainNetFindIdx(vm->def, dev->data.net)) < 0) goto cleanup; @@ -4396,6 +4397,7 @@ lxcDomainDetachDeviceNetLive(virDomainObjPtr vm, ret =3D 0; cleanup: if (!ret) { + virErrorPreserveLast(&save_err); if (detach->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK) { virConnectPtr conn =3D virGetConnectNetwork(); if (conn) { @@ -4407,6 +4409,7 @@ lxcDomainDetachDeviceNetLive(virDomainObjPtr vm, } virDomainNetRemove(vm->def, detachidx); virDomainNetDefFree(detach); + virErrorRestore(&save_err); } return ret; } diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index 3a33418aca..de4d7c73fb 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -550,6 +550,7 @@ static int virLXCProcessSetupInterfaces(virConnectPtr c= onn, virDomainNetDefPtr net; virDomainNetType type; virConnectPtr netconn =3D NULL; + virErrorPtr save_err =3D NULL; =20 if (VIR_ALLOC_N(*veths, def->nnets + 1) < 0) return -1; @@ -642,6 +643,7 @@ static int virLXCProcessSetupInterfaces(virConnectPtr c= onn, =20 cleanup: if (ret < 0) { + virErrorPreserveLast(&save_err); for (i =3D 0; i < def->nnets; i++) { virDomainNetDefPtr iface =3D def->nets[i]; virNetDevVPortProfilePtr vport =3D virDomainNetGetActualVirtPo= rtProfile(iface); @@ -652,6 +654,7 @@ static int virLXCProcessSetupInterfaces(virConnectPtr c= onn, if (iface->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK && netconn) virDomainNetReleaseActualDevice(netconn, def, iface); } + virErrorRestore(&save_err); } virObjectUnref(netconn); return ret; diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index e199368e8a..f3c5f44a23 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -1383,6 +1383,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, bool netdevPlugged =3D false; char *netdev_name; virConnectPtr conn =3D NULL; + virErrorPtr save_err =3D NULL; =20 /* preallocate new slot for device */ if (VIR_REALLOC_N(vm->def->nets, vm->def->nnets + 1) < 0) @@ -1678,6 +1679,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, if (!ret) { vm->def->nets[vm->def->nnets++] =3D net; } else { + virErrorPreserveLast(&save_err); if (releaseaddr) qemuDomainReleaseDeviceAddress(vm, &net->info); =20 @@ -1706,6 +1708,7 @@ qemuDomainAttachNetDevice(virQEMUDriverPtr driver, else VIR_WARN("Unable to release network device '%s'", NULLSTR(= net->ifname)); } + virErrorRestore(&save_err); } =20 VIR_FREE(nicstr); @@ -3756,6 +3759,7 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, int ret =3D -1; int changeidx =3D -1; virConnectPtr conn =3D NULL; + virErrorPtr save_err =3D NULL; =20 if ((changeidx =3D virDomainNetFindIdx(vm->def, newdev)) < 0) goto cleanup; @@ -4173,6 +4177,7 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, =20 ret =3D 0; cleanup: + virErrorPreserveLast(&save_err); /* When we get here, we will be in one of these two states: * * 1) newdev has been moved into the domain's list of nets and @@ -4194,6 +4199,7 @@ qemuDomainChangeNet(virQEMUDriverPtr driver, if (newdev && newdev->type =3D=3D VIR_DOMAIN_NET_TYPE_NETWORK && conn) virDomainNetReleaseActualDevice(conn, vm->def, newdev); virObjectUnref(conn); + virErrorRestore(&save_err); =20 return ret; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list