From nobody Mon Feb 9 10:32:32 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=1561391046; cv=none; d=zoho.com; s=zohoarc; b=bsD06kQLG6IaFDiFFz4nx4AdIryu6KKU/uz7HKu9W/dKgY0UxlKoGIeqVTPNUCNQGgNrpU2240uc7bj6BXJzpBidd7bYgtn+XhXh2VwB2fdL5m9R50DwuA6xYmyma87/vpn0hRIlBIwy+TAZ5mIKxc43njrHA6UeLtJbTXnCs9U= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561391046; 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=vXDJcFWQK+sOLuh8foc6cJQr+GNHT3vn2F9JXAaJr8g=; b=Y7wlKmA51ZIoYtCp8iL9Ivi7om72aC5oUKXBKI4B8w0HRnIOSZ93ATu8nhR74CJZ0QgvjECE+qxzMAqDK5jiWaxidnSAA8G9PkyhYwFnxdwHYeYzm8IyuGoPVWvUS7gD6afMJTo26963UPmvM0Z7Mq095Pz7Z/2R1EoxISidzTc= 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 1561391046904163.96626831145124; Mon, 24 Jun 2019 08:44:06 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 35D493001809; Mon, 24 Jun 2019 15:43:59 +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 E89C960143; Mon, 24 Jun 2019 15:43:58 +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 AF19A206D1; Mon, 24 Jun 2019 15:43:57 +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 x5OFd6VJ021016 for ; Mon, 24 Jun 2019 11:39:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id E3C4D5D9D3; Mon, 24 Jun 2019 15:39:06 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6D4425D9C5 for ; Mon, 24 Jun 2019 15:39:06 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 24 Jun 2019 17:38:54 +0200 Message-Id: <1969277e0534f23e5301ebc2a1ba2ef12bae0fe0.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 09/10] qemu: hotplug: qemu: hotplug: Use storage chain helpers in qemuDomainChangeMediaBlockdev 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.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.40]); Mon, 24 Jun 2019 15:44:05 +0000 (UTC) Content-Type: text/plain; charset="utf-8" As this conversion removes the last use of qemuHotplugDiskSource* functions we can remove all of them now. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_hotplug.c | 188 ++-------------------------------------- 1 file changed, 7 insertions(+), 181 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 1b1d2ba5ce..a1296d55d4 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -417,177 +417,6 @@ qemuHotplugRemoveManagedPR(virQEMUDriverPtr driver, } -struct _qemuHotplugDiskSourceData { - qemuBlockStorageSourceAttachDataPtr *backends; - size_t nbackends; -}; -typedef struct _qemuHotplugDiskSourceData qemuHotplugDiskSourceData; -typedef qemuHotplugDiskSourceData *qemuHotplugDiskSourceDataPtr; - - -static void -qemuHotplugDiskSourceDataFree(qemuHotplugDiskSourceDataPtr data) -{ - size_t i; - - if (!data) - return; - - for (i =3D 0; i < data->nbackends; i++) - qemuBlockStorageSourceAttachDataFree(data->backends[i]); - - VIR_FREE(data->backends); - VIR_FREE(data); -} - - -static qemuHotplugDiskSourceDataPtr -qemuHotplugDiskSourceRemovePrepare(virDomainDiskDefPtr disk, - virStorageSourcePtr src, - virQEMUCapsPtr qemuCaps) -{ - VIR_AUTOPTR(qemuBlockStorageSourceAttachData) backend =3D NULL; - qemuHotplugDiskSourceDataPtr data =3D NULL; - qemuHotplugDiskSourceDataPtr ret =3D NULL; - char *drivealias =3D NULL; - virStorageSourcePtr n; - - if (VIR_ALLOC(data) < 0) - return NULL; - - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV)) { - for (n =3D src; virStorageSourceIsBacking(n); n =3D n->backingStor= e) { - if (!(backend =3D qemuBlockStorageSourceDetachPrepare(n, NULL)= )) - goto cleanup; - - if (VIR_APPEND_ELEMENT(data->backends, data->nbackends, backen= d) < 0) - goto cleanup; - } - } else { - if (!(drivealias =3D qemuAliasDiskDriveFromDisk(disk))) - goto cleanup; - - if (!(backend =3D qemuBlockStorageSourceDetachPrepare(src, driveal= ias))) - goto cleanup; - - if (VIR_APPEND_ELEMENT(data->backends, data->nbackends, backend) <= 0) - goto cleanup; - } - - VIR_STEAL_PTR(ret, data); - - cleanup: - qemuHotplugDiskSourceDataFree(data); - return ret; -} - - -/** - * qemuHotplugDiskSourceAttachPrepare: - * @disk: disk to generate attachment data for - * @src: disk source to prepare attachment - * @qemuCaps: capabilities of the qemu process - * - * Prepares and returns qemuHotplugDiskSourceData structure filled with al= l data - * which will fully attach the source backend of the disk to a given VM. - */ -static qemuHotplugDiskSourceDataPtr -qemuHotplugDiskSourceAttachPrepare(virDomainDiskDefPtr disk, - virStorageSourcePtr src, - virQEMUCapsPtr qemuCaps) -{ - VIR_AUTOPTR(qemuBlockStorageSourceAttachData) backend =3D NULL; - qemuHotplugDiskSourceDataPtr data; - qemuHotplugDiskSourceDataPtr ret =3D NULL; - virStorageSourcePtr savesrc =3D NULL; - virStorageSourcePtr n; - - if (VIR_ALLOC(data) < 0) - return NULL; - - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV)) { - for (n =3D src; virStorageSourceIsBacking(n); n =3D n->backingStor= e) { - if (!(backend =3D qemuBlockStorageSourceAttachPrepareBlockdev(= n))) - goto cleanup; - - if (qemuBuildStorageSourceAttachPrepareCommon(n, backend, qemu= Caps) < 0) - goto cleanup; - - if (VIR_APPEND_ELEMENT(data->backends, data->nbackends, backen= d) < 0) - goto cleanup; - } - } else { - VIR_STEAL_PTR(savesrc, disk->src); - disk->src =3D src; - - if (!(backend =3D qemuBuildStorageSourceAttachPrepareDrive(disk, q= emuCaps))) - goto cleanup; - - VIR_STEAL_PTR(disk->src, savesrc); - - if (qemuBuildStorageSourceAttachPrepareCommon(src, backend, qemuCa= ps) < 0) - goto cleanup; - - if (VIR_APPEND_ELEMENT(data->backends, data->nbackends, backend) <= 0) - goto cleanup; - } - - VIR_STEAL_PTR(ret, data); - - cleanup: - if (savesrc) - VIR_STEAL_PTR(disk->src, savesrc); - - qemuHotplugDiskSourceDataFree(data); - return ret; -} - - -/** - * qemuHotplugDiskSourceAttach: - * @mon: monitor object - * @data: disk backend data object describing what to remove - * - * Attach a disk source backend with all relevant pieces. Caller must ente= r the - * monitor context for @mon. - */ -static int -qemuHotplugDiskSourceAttach(qemuMonitorPtr mon, - qemuHotplugDiskSourceDataPtr data) -{ - size_t i; - - for (i =3D data->nbackends; i > 0; i--) { - if (qemuBlockStorageSourceAttachApply(mon, data->backends[i - 1]) = < 0) - return -1; - } - - - return 0; -} - - -/** - * qemuHotplugDiskSourceRemove: - * @mon: monitor object - * @data: disk backend data object describing what to remove - * - * Remove a disk source backend with all relevant pieces. This function - * preserves the error which was set prior to calling it. Caller must ente= r the - * monitor context for @mon. - */ -static void -qemuHotplugDiskSourceRemove(qemuMonitorPtr mon, - qemuHotplugDiskSourceDataPtr data) - -{ - size_t i; - - for (i =3D 0; i < data->nbackends; i++) - qemuBlockStorageSourceAttachRollback(mon, data->backends[i]); -} - - /** * qemuDomainChangeMediaBlockdev: * @driver: qemu driver structure @@ -614,20 +443,19 @@ qemuDomainChangeMediaBlockdev(virQEMUDriverPtr driver, { qemuDomainObjPrivatePtr priv =3D vm->privateData; qemuDomainDiskPrivatePtr diskPriv =3D QEMU_DOMAIN_DISK_PRIVATE(disk); - qemuHotplugDiskSourceDataPtr newbackend =3D NULL; - qemuHotplugDiskSourceDataPtr oldbackend =3D NULL; + VIR_AUTOPTR(qemuBlockStorageSourceChainData) newbackend =3D NULL; + VIR_AUTOPTR(qemuBlockStorageSourceChainData) oldbackend =3D NULL; char *nodename =3D NULL; int rc; int ret =3D -1; if (!virStorageSourceIsEmpty(oldsrc) && - !(oldbackend =3D qemuHotplugDiskSourceRemovePrepare(disk, oldsrc, - priv->qemuCaps))) + !(oldbackend =3D qemuBlockStorageSourceChainDetachPrepareBlockdev(= oldsrc))) goto cleanup; if (!virStorageSourceIsEmpty(newsrc)) { - if (!(newbackend =3D qemuHotplugDiskSourceAttachPrepare(disk, news= rc, - priv->qemuCa= ps))) + if (!(newbackend =3D qemuBuildStorageSourceChainAttachPrepareBlock= dev(newsrc, + = priv->qemuCaps))) goto cleanup; if (qemuDomainDiskGetBackendAlias(disk, priv->qemuCaps, &nodename)= < 0) @@ -649,11 +477,11 @@ qemuDomainChangeMediaBlockdev(virQEMUDriverPtr driver, rc =3D qemuMonitorBlockdevMediumRemove(priv->mon, diskPriv->qomName); if (rc =3D=3D 0 && oldbackend) - qemuHotplugDiskSourceRemove(priv->mon, oldbackend); + qemuBlockStorageSourceChainDetach(priv->mon, oldbackend); if (newbackend && nodename) { if (rc =3D=3D 0) - rc =3D qemuHotplugDiskSourceAttach(priv->mon, newbackend); + rc =3D qemuBlockStorageSourceChainAttach(priv->mon, newbackend= ); if (rc =3D=3D 0) rc =3D qemuMonitorBlockdevMediumInsert(priv->mon, diskPriv->qo= mName, @@ -669,8 +497,6 @@ qemuDomainChangeMediaBlockdev(virQEMUDriverPtr driver, ret =3D 0; cleanup: - qemuHotplugDiskSourceDataFree(newbackend); - qemuHotplugDiskSourceDataFree(oldbackend); VIR_FREE(nodename); return ret; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list