From nobody Sun Feb 8 14:53:22 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=1590009169; cv=none; d=zohomail.com; s=zohoarc; b=QLVE6HTUC0+JFhOnVAJd7B1XMbLoKtp1SRIZql3Sk4zGhiF6BNbth0MjrjxIeDO6G+AQDfRjql4ymyV72CG+0w/LmBR3IBnEbz5etek4lTikojiwNQkRNx3pKteMvr0POsX+x7WHr3DJ/pPvHHwvPQrBZNYi/u5fOPfVeAh5GyE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1590009169; 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=tqUDLt0jIR+ntZF41ECOCut3Tk6wzy+MM1ncEHVB0hs=; b=n9Wawfm6sYi+2opF5BgrXiuqGEVPNHFwersrzj/MHnQtpV/aNplUElXUd6Xr53Ruuf4RqN8SsD0aCqh5+XBHWMX7fOxfwVjisKZ8PbaSjorMDKBiV9/aB8lQOTwt40Cm6TufxgmOvV8CE/Xyho3UYaTi/qMZJwwln+zTU11aRmw= 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 1590009169483474.31368970416906; Wed, 20 May 2020 14:12:49 -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-234-e0lJ_VUNNQGn9coGUBa8IA-1; Wed, 20 May 2020 17:12:45 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id EC9C8800688; Wed, 20 May 2020 21:12:39 +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 CC43C2C7B9; Wed, 20 May 2020 21:12:39 +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 9F98B54D0B; Wed, 20 May 2020 21:12:39 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 04KLCaJL002182 for ; Wed, 20 May 2020 17:12:36 -0400 Received: by smtp.corp.redhat.com (Postfix) id 677D35AB85; Wed, 20 May 2020 21:12:36 +0000 (UTC) Received: from mimecast-mx02.redhat.com (mimecast01.extmail.prod.ext.rdu2.redhat.com [10.11.55.17]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 63AAE11317 for ; Wed, 20 May 2020 21:12:34 +0000 (UTC) Received: from us-smtp-1.mimecast.com (us-smtp-delivery-1.mimecast.com [205.139.110.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 5F27B8ECB0C for ; Wed, 20 May 2020 21:12:34 +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-352-LL4GtTToMpeVeG2VhDbFLw-1; Wed, 20 May 2020 17:12:30 -0400 Received: by mail-qk1-f193.google.com with SMTP id i5so5090653qkl.12 for ; Wed, 20 May 2020 14:12:30 -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.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 May 2020 14:12:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1590009168; 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=tqUDLt0jIR+ntZF41ECOCut3Tk6wzy+MM1ncEHVB0hs=; b=Pwr+VC/8EAcj+8R60rVU/l8AtNc9g7YfE8NaYWCElSiAlFLqyfR6pvNFnvFLdnneCaW6lY fZPmgyVSwLkLtiZpj9et+QTOaZwwFLOINMS/SWpzpWpWBmT8FKktTIZzIiVgfOdCxqzzuN lpKpSHXA0mxY6ZdaMt7zd4O1QLv0+dY= X-MC-Unique: e0lJ_VUNNQGn9coGUBa8IA-1 X-MC-Unique: LL4GtTToMpeVeG2VhDbFLw-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=tqUDLt0jIR+ntZF41ECOCut3Tk6wzy+MM1ncEHVB0hs=; b=GUlut+QHOuMpatBUA8LiuH18G6Q4idGec+nQv22VJ5eputjVVQEguZMwLiPXnEwB6h rNkUX4Y/CTe4sKseqWL6/DUTYDtwNePYlpAOBf9evNs0W/nE6q/3oCxK+zisLycM46fy qzg/SvOqcyh0MSwOSVDiVPX+BelIgq0iGSA+3p8jiZQ1rhGGq2mLth0E5QdDdPaD6/di PzeJPVhnpJjVzRCvafRjMYeAqU3t09C8hFzWbrumZ/8FqkllzowBecZzdAWfje0e9ocr 43NlrK+xoJv3DlZgSF5GlQRy/JrezkBh1KPT3bP+GY+sDp11KlPyJXlt/EG2V+YiQ4qm hssQ== X-Gm-Message-State: AOAM531L3UnD8jZWbA/GjZmmwr8izPkj4J70XkmyUGPcl8MUYiU8hb74 6ySECF7S/3g8D053han909LD5PWW X-Google-Smtp-Source: ABdhPJxXqtAjMqLg6LORuz/WAnRQi+LwSQQyhVpZNZcLT8jnRLef8wBv46wekfZrPfshhwff94IEgQ== X-Received: by 2002:a37:9e06:: with SMTP id h6mr6680553qke.400.1590009149962; Wed, 20 May 2020 14:12:29 -0700 (PDT) From: Daniel Henrique Barboza To: libvir-list@redhat.com Subject: [PATCH v3 12/21] qemu: refactor qemuDomain[Attach|Detach]DeviceConfig Date: Wed, 20 May 2020 18:11:34 -0300 Message-Id: <20200520211143.2980117-13-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.79 on 10.11.54.5 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.79 on 10.5.11.15 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 This helps calling the routines with a list of devices. Signed-off-by: Shivaprasad G Bhat Signed-off-by: Daniel Henrique Barboza --- src/qemu/qemu_driver.c | 45 +++++++++++++++++++++++++++++++++--------- 1 file changed, 36 insertions(+), 9 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index dd9ae30bb5..43a3ffea99 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -8117,11 +8117,8 @@ qemuCheckDiskConfigAgainstDomain(const virDomainDef = *def, =20 =20 static int -qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef, - virDomainDeviceDefPtr dev, - virQEMUCapsPtr qemuCaps, - unsigned int parse_flags, - virDomainXMLOptionPtr xmlopt) +qemuDomainAttachDeviceConfigInternal(virDomainDefPtr vmdef, + virDomainDeviceDefPtr dev) { virDomainDiskDefPtr disk; virDomainNetDefPtr net; @@ -8316,19 +8313,35 @@ qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef, return -1; } =20 - if (virDomainDefPostParse(vmdef, parse_flags, xmlopt, qemuCaps) < 0) - return -1; - return 0; } =20 =20 static int -qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef, +qemuDomainAttachDeviceConfig(virDomainDefPtr vmdef, virDomainDeviceDefPtr dev, virQEMUCapsPtr qemuCaps, unsigned int parse_flags, virDomainXMLOptionPtr xmlopt) +{ + if (virDomainDefCompatibleDevice(vmdef, dev, NULL, + VIR_DOMAIN_DEVICE_ACTION_ATTACH, + false) < 0) + return -1; + + if (qemuDomainAttachDeviceConfigInternal(vmdef, dev)) + return -1; + + if (virDomainDefPostParse(vmdef, parse_flags, xmlopt, qemuCaps) < 0) + return -1; + + return 0; +} + + +static int +qemuDomainDetachDeviceConfigInternal(virDomainDefPtr vmdef, + virDomainDeviceDefPtr dev) { virDomainDiskDefPtr disk, det_disk; virDomainNetDefPtr net; @@ -8518,6 +8531,20 @@ qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef, return -1; } =20 + return 0; +} + + +static int +qemuDomainDetachDeviceConfig(virDomainDefPtr vmdef, + virDomainDeviceDefPtr dev, + virQEMUCapsPtr qemuCaps, + unsigned int parse_flags, + virDomainXMLOptionPtr xmlopt) +{ + if (qemuDomainDetachDeviceConfigInternal(vmdef, dev)) + return -1; + if (virDomainDefPostParse(vmdef, parse_flags, xmlopt, qemuCaps) < 0) return -1; =20 --=20 2.26.2