From nobody Mon Feb 9 07:26:58 2026 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=1561390793; cv=none; d=zoho.com; s=zohoarc; b=RC+TyXkxQm/Pqz3tKIuTMzxpNCcEMCLZd6Z32rR9HDAjVoduPTU433PZhyVycRJ2YSZvcs4NJE7RIGXfM2Yue2y4Vk4WqIqcYPSO2CVA8MNcooLuDWK3SWChS47VEyEeLVHwnC/TtRjeX0jTmBcscWp6EcB7r235FP/xQd6DJjk= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561390793; h=Content-Type:Content-Transfer-Encoding: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:ARC-Authentication-Results; bh=6VMiDyw/XsqOqpBN+0MnHXWcmnm0R5JHUHynEdqY/XI=; b=hZa2gQI95w1DCt4c3mX/RN/zedevW0vUL+HgcgawNV2W1oztPjTYYcQwwWSAvuEYGYIsuhFccDROjQoYZcVkOHeiq0d48KNXk6b8t8ReH5FNiiWaRr+KEZNsq/9uD2Tf2YqRcAe1zdCdLiWjITtJ0N8YgEPM/TEhJz+Wl9/ZFIA= 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 1561390793512392.18471241175257; Mon, 24 Jun 2019 08:39:53 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id 26A2844FB1; Mon, 24 Jun 2019 15:39:24 +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 DF07C5B687; Mon, 24 Jun 2019 15:39:17 +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 99D301806B16; Mon, 24 Jun 2019 15:39:04 +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 x5OFd0gl020808 for ; Mon, 24 Jun 2019 11:39:00 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8643E5D9D3; Mon, 24 Jun 2019 15:39:00 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 11DDA5D9C5 for ; Mon, 24 Jun 2019 15:38:59 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 24 Jun 2019 17:38:46 +0200 Message-Id: <0a950054bc3c31fc45539eabfa234278e0d01a02.1561390513.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 01/10] qemu: block: Move and rename qemuHotplugRemoveStorageSourcePrepareData 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.15 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.30]); Mon, 24 Jun 2019 15:39:46 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Move it to qemu_block.c and call it qemuBlockStorageSourceDetachPrepare. It will be reused in other parts as well. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_block.c | 57 +++++++++++++++++++++++++++++++++++++ src/qemu/qemu_block.h | 4 +++ src/qemu/qemu_hotplug.c | 63 ++--------------------------------------- 3 files changed, 63 insertions(+), 61 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 7d9f7ec3ab..560488c852 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -1565,6 +1565,63 @@ qemuBlockStorageSourceAttachRollback(qemuMonitorPtr = mon, } +/** + * qemuBlockStorageSourceDetachPrepare: + * @src: disk source structure + * @driveAlias: Alias of the -drive backend, the pointer is always consumed + * + * Prepare qemuBlockStorageSourceAttachDataPtr for detaching a single sour= ce + * from a VM. If @driveAlias is NULL -blockdev is assumed. + */ +qemuBlockStorageSourceAttachDataPtr +qemuBlockStorageSourceDetachPrepare(virStorageSourcePtr src, + char *driveAlias) +{ + qemuDomainStorageSourcePrivatePtr srcpriv =3D QEMU_DOMAIN_STORAGE_SOUR= CE_PRIVATE(src); + VIR_AUTOPTR(qemuBlockStorageSourceAttachData) data =3D NULL; + qemuBlockStorageSourceAttachDataPtr ret =3D NULL; + + if (VIR_ALLOC(data) < 0) + goto cleanup; + + if (driveAlias) { + VIR_STEAL_PTR(data->driveAlias, driveAlias); + data->driveAdded =3D true; + } else { + data->formatNodeName =3D src->nodeformat; + data->formatAttached =3D true; + data->storageNodeName =3D src->nodestorage; + data->storageAttached =3D true; + } + + if (src->pr && + !virStoragePRDefIsManaged(src->pr) && + VIR_STRDUP(data->prmgrAlias, src->pr->mgralias) < 0) + goto cleanup; + + if (VIR_STRDUP(data->tlsAlias, src->tlsAlias) < 0) + goto cleanup; + + if (srcpriv) { + if (srcpriv->secinfo && + srcpriv->secinfo->type =3D=3D VIR_DOMAIN_SECRET_INFO_TYPE_AES = && + VIR_STRDUP(data->authsecretAlias, srcpriv->secinfo->s.aes.alia= s) < 0) + goto cleanup; + + if (srcpriv->encinfo && + srcpriv->encinfo->type =3D=3D VIR_DOMAIN_SECRET_INFO_TYPE_AES = && + VIR_STRDUP(data->encryptsecretAlias, srcpriv->encinfo->s.aes.a= lias) < 0) + goto cleanup; + } + + VIR_STEAL_PTR(ret, data); + + cleanup: + VIR_FREE(driveAlias); + return ret; +} + + /** * qemuBlockStorageSourceDetachOneBlockdev: * @driver: qemu driver object diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h index e41b9a1df2..a49c73670b 100644 --- a/src/qemu/qemu_block.h +++ b/src/qemu/qemu_block.h @@ -107,6 +107,10 @@ VIR_DEFINE_AUTOPTR_FUNC(qemuBlockStorageSourceAttachDa= ta, qemuBlockStorageSourceAttachDataPtr qemuBlockStorageSourceAttachPrepareBlockdev(virStorageSourcePtr src); +qemuBlockStorageSourceAttachDataPtr +qemuBlockStorageSourceDetachPrepare(virStorageSourcePtr src, + char *driveAlias); + int qemuBlockStorageSourceAttachApply(qemuMonitorPtr mon, qemuBlockStorageSourceAttachDataPtr data= ); diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index efda539208..fe2f577d58 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -448,64 +448,6 @@ qemuHotplugDiskSourceDataFree(qemuHotplugDiskSourceDat= aPtr data) } -/** - * qemuDomainRemoveDiskStorageSourcePrepareData: - * @src: disk source structure - * @driveAlias: Alias of the -drive backend, the pointer is always consumed - * - * Prepare qemuBlockStorageSourceAttachDataPtr for detaching a single sour= ce - * from a VM. If @driveAlias is NULL -blockdev is assumed. - */ -static qemuBlockStorageSourceAttachDataPtr -qemuHotplugRemoveStorageSourcePrepareData(virStorageSourcePtr src, - char *driveAlias) - -{ - qemuDomainStorageSourcePrivatePtr srcpriv =3D QEMU_DOMAIN_STORAGE_SOUR= CE_PRIVATE(src); - VIR_AUTOPTR(qemuBlockStorageSourceAttachData) data =3D NULL; - qemuBlockStorageSourceAttachDataPtr ret =3D NULL; - - if (VIR_ALLOC(data) < 0) - goto cleanup; - - if (driveAlias) { - VIR_STEAL_PTR(data->driveAlias, driveAlias); - data->driveAdded =3D true; - } else { - data->formatNodeName =3D src->nodeformat; - data->formatAttached =3D true; - data->storageNodeName =3D src->nodestorage; - data->storageAttached =3D true; - } - - if (src->pr && - !virStoragePRDefIsManaged(src->pr) && - VIR_STRDUP(data->prmgrAlias, src->pr->mgralias) < 0) - goto cleanup; - - if (VIR_STRDUP(data->tlsAlias, src->tlsAlias) < 0) - goto cleanup; - - if (srcpriv) { - if (srcpriv->secinfo && - srcpriv->secinfo->type =3D=3D VIR_DOMAIN_SECRET_INFO_TYPE_AES = && - VIR_STRDUP(data->authsecretAlias, srcpriv->secinfo->s.aes.alia= s) < 0) - goto cleanup; - - if (srcpriv->encinfo && - srcpriv->encinfo->type =3D=3D VIR_DOMAIN_SECRET_INFO_TYPE_AES = && - VIR_STRDUP(data->encryptsecretAlias, srcpriv->encinfo->s.aes.a= lias) < 0) - goto cleanup; - } - - VIR_STEAL_PTR(ret, data); - - cleanup: - VIR_FREE(driveAlias); - return ret; -} - - static qemuHotplugDiskSourceDataPtr qemuHotplugDiskSourceRemovePrepare(virDomainDiskDefPtr disk, virStorageSourcePtr src, @@ -526,7 +468,7 @@ qemuHotplugDiskSourceRemovePrepare(virDomainDiskDefPtr = disk, goto cleanup; for (n =3D src; virStorageSourceIsBacking(n); n =3D n->backingStor= e) { - if (!(backend =3D qemuHotplugRemoveStorageSourcePrepareData(n,= NULL))) + if (!(backend =3D qemuBlockStorageSourceDetachPrepare(n, NULL)= )) goto cleanup; if (VIR_APPEND_ELEMENT(data->backends, data->nbackends, backen= d) < 0) @@ -536,8 +478,7 @@ qemuHotplugDiskSourceRemovePrepare(virDomainDiskDefPtr = disk, if (!(drivealias =3D qemuAliasDiskDriveFromDisk(disk))) goto cleanup; - if (!(backend =3D qemuHotplugRemoveStorageSourcePrepareData(src, - driveali= as))) + if (!(backend =3D qemuBlockStorageSourceDetachPrepare(src, driveal= ias))) goto cleanup; if (VIR_APPEND_ELEMENT(data->backends, data->nbackends, backend) <= 0) --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list