From nobody Sun Feb 8 16:30:47 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) client-ip=205.139.110.120; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail(p=none dis=none) header.from=gmail.com ARC-Seal: i=1; a=rsa-sha256; t=1590009171; cv=none; d=zohomail.com; s=zohoarc; b=gmGxoOsBct5Tgl7ibyJ9vvzJsDQUnP/xXm4VRJXl7GAHGFmvLAEKXKbnyoRAZnTEIV8IlMj/dAHvGzWoGk6065wcxSyqAk1trFZqjNBqoafAi15H5OqLK85i0jGGjfsaKmZ0qafpIVFr+bQCOfaWy2aaAE/xtEIAqV6EHdRu0Z0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1590009171; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To; bh=/T17Avh4IKuJ83nvtjPNzDBaVIA8sZ8JCmRVqGjKq8s=; b=AHgn8nT+TG02l1PqL7A9bFh4lKjEwQfNn+Gp3/tzGYmA8flsYeJjg0oPyfMXhgO7q/yymEBv6V9WZhqh2T0uf1qVhMLpMmwAW9PUZTtuf+o24+6S3aXJRhZ9eVVAVsdMaBGf2oqplP2x1v5sWbIPq/dB9ih0KwXNa9Mi3O1FHOk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.120 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=fail header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.120]) by mx.zohomail.com with SMTPS id 1590009171216144.75711434512596; Wed, 20 May 2020 14:12:51 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-422-M4lasOqFNgmrPwwMvV-Trg-1; Wed, 20 May 2020 17:12:46 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.phx2.redhat.com [10.5.11.23]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id B1D228018A2; Wed, 20 May 2020 21:12:40 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 8EC3248D7E; Wed, 20 May 2020 21:12:40 +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 6043E180530E; Wed, 20 May 2020 21:12:40 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 04KLCb0P002198 for ; Wed, 20 May 2020 17:12:37 -0400 Received: by smtp.corp.redhat.com (Postfix) id 5E02B2166BA3; Wed, 20 May 2020 21:12:37 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast02.extmail.prod.ext.rdu2.redhat.com [10.11.55.18]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 5A1FC2156A2E for ; Wed, 20 May 2020 21:12:37 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [207.211.31.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-SHA384 (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 387818007D4 for ; Wed, 20 May 2020 21:12:37 +0000 (UTC) Received: from mail-qk1-f193.google.com (mail-qk1-f193.google.com [209.85.222.193]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-353-Gg0a--2EPxywKOTvLY4wyA-1; Wed, 20 May 2020 17:12:34 -0400 Received: by mail-qk1-f193.google.com with SMTP id 142so5159798qkl.6 for ; Wed, 20 May 2020 14:12:34 -0700 (PDT) Received: from rekt.ibmuc.com ([2804:431:c7c7:fbf2:bc5e:c314:af31:7070]) by smtp.gmail.com with ESMTPSA id z14sm2992031qki.83.2020.05.20.14.12.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 May 2020 14:12:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590009169; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=/T17Avh4IKuJ83nvtjPNzDBaVIA8sZ8JCmRVqGjKq8s=; b=YuCYDYszchL6TDr92Zt/i07uMokmoudq7cyW9E0/TQbALJXQEPuT2ksPWyqWJ+HwrAIFGk jrymdtZ6+9uLwDPz/5qUO6febZWTLxkc2zAdpcMFmtgcdTMTSBfuC/KyEb9SLtDZvl6aVy 9d2ft2wU7C2RYbj8r87ES5VFzQDldbg= X-MC-Unique: M4lasOqFNgmrPwwMvV-Trg-1 X-MC-Unique: Gg0a--2EPxywKOTvLY4wyA-1 X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/T17Avh4IKuJ83nvtjPNzDBaVIA8sZ8JCmRVqGjKq8s=; b=F9UWBWp6LmoGzPFigaW7aVnBxhM6oTyUtguqJwfM3i/QvIimq9odDQA/TxVy7g7AOo eS3Xq3B6xnwobXFPf8cRoxVrj9RcwM1O9guDYeZG1M5TKFpmy381sNCyU43m3aHC3UjZ zNRTCLT+L2Hx1tUll2tS3Heu+Upi4jwWEy2hyaNSqVl2gN1DeBUe9K7aQnKVIIsO0+T2 snc629T7qBUGWeTIKQO2vS85exe5zMtSeyzRVls/m/gKEzASz0y5rWeEcNGrsx+WzTnS 1SCZpVtTfjonn8x0DaXsPQuiWvledhORrwYnse4vFEDL1AfsuLq+PI+4OIznX5p9rdDj 8LzA== X-Gm-Message-State: AOAM531+m8D4TV1DczbrjRtbk2kC1yQphX3/+RrkYTmYUiE4rrKI2Zkc FBOtaS6XmQbHyhgnw9Ax1ucRgL3V X-Google-Smtp-Source: ABdhPJwWjft69W7OrHhlZRuyLD+Y1bi/W2Wzq1ZEfenyBQmlX6mQeNFfclwRjbPR/SLF0TE2NDzy/A== X-Received: by 2002:a05:620a:1524:: with SMTP id n4mr6949823qkk.490.1590009153988; Wed, 20 May 2020 14:12:33 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v3 14/21] qemu: hotplug: Queue and wait for multiple devices Date: Wed, 20 May 2020 18:11:36 -0300 Message-Id: <20200520211143.2980117-15-danielhb413@gmail.com> In-Reply-To: <20200520211143.2980117-1-danielhb413@gmail.com> References: <20200520211143.2980117-1-danielhb413@gmail.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Cc: Daniel Henrique Barboza , sbhat@linux.ibm.com 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" From: Shivaprasad G Bhat With multifunction devices, multiple delete requests are sent to qemu and all the requests should be queued up. Signed-off-by: Shivaprasad G Bhat Signed-off-by: Daniel Henrique Barboza --- src/qemu/qemu_domain.h | 3 ++- src/qemu/qemu_hotplug.c | 41 ++++++++++++++++++++++++++--------------- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 31c843de96..4fab1360f6 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -244,7 +244,8 @@ typedef enum { typedef struct _qemuDomainUnpluggingDevice qemuDomainUnpluggingDevice; typedef qemuDomainUnpluggingDevice *qemuDomainUnpluggingDevicePtr; struct _qemuDomainUnpluggingDevice { - const char *alias; + const char **aliases; + size_t naliases; qemuDomainUnpluggingDeviceStatus status; bool eventSeen; /* True if DEVICE_DELETED event arrived. */ }; diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 6991d7988c..b9946e8b8e 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -5134,13 +5134,19 @@ qemuDomainRemoveDevice(virQEMUDriverPtr driver, =20 static void qemuDomainMarkDeviceAliasForRemoval(virDomainObjPtr vm, - const char *alias) + const char *alias, + bool fresh) { qemuDomainObjPrivatePtr priv =3D vm->privateData; =20 - memset(&priv->unplug, 0, sizeof(priv->unplug)); + if (fresh) + memset(&priv->unplug, 0, sizeof(priv->unplug)); + + if (VIR_REALLOC_N(priv->unplug.aliases, priv->unplug.naliases + 1) < 0) + return; + + priv->unplug.aliases[priv->unplug.naliases++] =3D alias; =20 - priv->unplug.alias =3D alias; } =20 =20 @@ -5149,7 +5155,7 @@ qemuDomainMarkDeviceForRemoval(virDomainObjPtr vm, virDomainDeviceInfoPtr info) =20 { - qemuDomainMarkDeviceAliasForRemoval(vm, info->alias); + qemuDomainMarkDeviceAliasForRemoval(vm, info->alias, true); } =20 =20 @@ -5157,7 +5163,9 @@ static void qemuDomainResetDeviceRemoval(virDomainObjPtr vm) { qemuDomainObjPrivatePtr priv =3D vm->privateData; - priv->unplug.alias =3D NULL; + priv->unplug.aliases =3D NULL; + VIR_FREE(priv->unplug.aliases); + priv->unplug.naliases =3D 0; priv->unplug.eventSeen =3D false; } =20 @@ -5192,13 +5200,14 @@ qemuDomainWaitForDeviceRemoval(virDomainObjPtr vm) return 1; until +=3D qemuDomainGetUnplugTimeout(vm); =20 - while (priv->unplug.alias) { + /* All devices should get released around same time*/ + while (priv->unplug.naliases) { if ((rc =3D virDomainObjWaitUntil(vm, until)) =3D=3D 1) return 0; =20 if (rc < 0) { VIR_WARN("Failed to wait on unplug condition for domain '%s' " - "device '%s'", vm->def->name, priv->unplug.alias); + "device '%s'", vm->def->name, priv->unplug.aliases[0]= ); return 1; } } @@ -5224,14 +5233,16 @@ qemuDomainSignalDeviceRemoval(virDomainObjPtr vm, qemuDomainUnpluggingDeviceStatus status) { qemuDomainObjPrivatePtr priv =3D vm->privateData; + size_t i; =20 - if (STREQ_NULLABLE(priv->unplug.alias, devAlias)) { - VIR_DEBUG("Removal of device '%s' continues in waiting thread", de= vAlias); - qemuDomainResetDeviceRemoval(vm); - priv->unplug.status =3D status; - priv->unplug.eventSeen =3D true; - virDomainObjBroadcast(vm); - return true; + for (i =3D 0; i < priv->unplug.naliases; i++) { + if (STREQ_NULLABLE(priv->unplug.aliases[i], devAlias)) { + VIR_DEBUG("Removal of device '%s' continues in waiting thread"= , devAlias); + VIR_DELETE_ELEMENT(priv->unplug.aliases, i, priv->unplug.nalia= ses); + priv->unplug.status =3D status; + virDomainObjBroadcast(vm); + return true; + } } return false; } @@ -6075,7 +6086,7 @@ qemuDomainHotplugDelVcpu(virQEMUDriverPtr driver, return -1; } =20 - qemuDomainMarkDeviceAliasForRemoval(vm, vcpupriv->alias); + qemuDomainMarkDeviceAliasForRemoval(vm, vcpupriv->alias, true); =20 if (qemuDomainDeleteDevice(vm, vcpupriv->alias) < 0) { if (virDomainObjIsActive(vm)) --=20 2.26.2