From nobody Sat May 4 17:35:23 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=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 From nobody Sat May 4 17:35:23 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=1561390878; cv=none; d=zoho.com; s=zohoarc; b=ogSqRjdlOvD9CN3Dtunn37ImN8SfgcbD/x7KWJt/oP7kOwOii0iP/r5CpqzlweXCnZI8skfDyNEzc6qUtP/AEcVSyPtjEQQo5LINV7u81b8bPH7fASFijowkmKE7QqmCxMx2BNjVCyZq67kBF3pRP2BR93Jy4DfxltE1gMF38kA= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561390878; 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=wGkuFTpkEJM4wNBG2TQD7NGsKs+AvMa47dKKyYmAYXU=; b=nDnCShG5IhY/MXCsopaQhoxPohdzKRzi4obG4tvyKE+3pjRbm/5hR5ib5Nj4eUlEAn5x1kgSmGtO6QY4DLegMv1GEM4ExEJlU0bIdAgABCBIngPYUscAwXFjzcFO9ayVfEXN7azw4XCfdNlCBwQNSOKIeaSb7355Gj8JAgKiOPY= 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 1561390878179439.7560583391239; Mon, 24 Jun 2019 08:41:18 -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 59C8430C31B4; Mon, 24 Jun 2019 15:40:58 +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 31BD9600D1; Mon, 24 Jun 2019 15:40:56 +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 E2E9219728; Mon, 24 Jun 2019 15:40:52 +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 x5OFd1lc020834 for ; Mon, 24 Jun 2019 11:39:01 -0400 Received: by smtp.corp.redhat.com (Postfix) id 543EE5D9D3; Mon, 24 Jun 2019 15:39:01 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id D2C4B5D9C5 for ; Mon, 24 Jun 2019 15:39:00 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 24 Jun 2019 17:38:47 +0200 Message-Id: <31178e03bced576cb1e7b71e689e41376cd907e3.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 02/10] qemu: hotplug: Handle copy-on-read filter separate from rest of backing chain 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:41:16 +0000 (UTC) Content-Type: text/plain; charset="utf-8" We use only one copy-on-read filter per disk, so we should handle it separately from the chain. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_hotplug.c | 46 ++++++++++++++++++++++------------------- 1 file changed, 25 insertions(+), 21 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index fe2f577d58..f96209a0bd 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -420,10 +420,6 @@ qemuHotplugRemoveManagedPR(virQEMUDriverPtr driver, struct _qemuHotplugDiskSourceData { qemuBlockStorageSourceAttachDataPtr *backends; size_t nbackends; - - /* disk copy-on-read object */ - virJSONValuePtr corProps; - char *corAlias; }; typedef struct _qemuHotplugDiskSourceData qemuHotplugDiskSourceData; typedef qemuHotplugDiskSourceData *qemuHotplugDiskSourceDataPtr; @@ -437,9 +433,6 @@ qemuHotplugDiskSourceDataFree(qemuHotplugDiskSourceData= Ptr data) if (!data) return; - virJSONValueFree(data->corProps); - VIR_FREE(data->corAlias); - for (i =3D 0; i < data->nbackends; i++) qemuBlockStorageSourceAttachDataFree(data->backends[i]); @@ -453,7 +446,6 @@ qemuHotplugDiskSourceRemovePrepare(virDomainDiskDefPtr = disk, virStorageSourcePtr src, virQEMUCapsPtr qemuCaps) { - qemuDomainDiskPrivatePtr diskPriv =3D QEMU_DOMAIN_DISK_PRIVATE(disk); VIR_AUTOPTR(qemuBlockStorageSourceAttachData) backend =3D NULL; qemuHotplugDiskSourceDataPtr data =3D NULL; qemuHotplugDiskSourceDataPtr ret =3D NULL; @@ -464,9 +456,6 @@ qemuHotplugDiskSourceRemovePrepare(virDomainDiskDefPtr = disk, return NULL; if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV)) { - if (VIR_STRDUP(data->corAlias, diskPriv->nodeCopyOnRead) < 0) - goto cleanup; - for (n =3D src; virStorageSourceIsBacking(n); n =3D n->backingStor= e) { if (!(backend =3D qemuBlockStorageSourceDetachPrepare(n, NULL)= )) goto cleanup; @@ -517,10 +506,6 @@ qemuHotplugDiskSourceAttachPrepare(virDomainDiskDefPtr= disk, return NULL; if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV)) { - if (disk->copy_on_read =3D=3D VIR_TRISTATE_SWITCH_ON && - !(data->corProps =3D qemuBlockStorageGetCopyOnReadProps(disk))) - goto cleanup; - for (n =3D src; virStorageSourceIsBacking(n); n =3D n->backingStor= e) { if (!(backend =3D qemuBlockStorageSourceAttachPrepareBlockdev(= n))) goto cleanup; @@ -577,9 +562,6 @@ qemuHotplugDiskSourceAttach(qemuMonitorPtr mon, return -1; } - if (data->corProps && - qemuMonitorAddObject(mon, &data->corProps, &data->corAlias) < 0) - return -1; return 0; } @@ -601,9 +583,6 @@ qemuHotplugDiskSourceRemove(qemuMonitorPtr mon, { size_t i; - if (data->corAlias) - ignore_value(qemuMonitorDelObject(mon, data->corAlias)); - for (i =3D 0; i < data->nbackends; i++) qemuBlockStorageSourceAttachRollback(mon, data->backends[i]); } @@ -812,6 +791,8 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver, qemuHotplugDiskSourceDataPtr diskdata =3D NULL; char *devstr =3D NULL; VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg =3D virQEMUDriverGetConfig(d= river); + VIR_AUTOPTR(virJSONValue) corProps =3D NULL; + VIR_AUTOFREE(char *)corAlias =3D NULL; if (qemuDomainStorageSourceChainAccessAllow(driver, vm, disk->src) < 0) goto cleanup; @@ -822,6 +803,12 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver, if (qemuDomainPrepareDiskSource(disk, priv, cfg) < 0) goto error; + if (virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV)) { + if (disk->copy_on_read =3D=3D VIR_TRISTATE_SWITCH_ON && + !(corProps =3D qemuBlockStorageGetCopyOnReadProps(disk))) + goto cleanup; + } + if (!(diskdata =3D qemuHotplugDiskSourceAttachPrepare(disk, disk->src, priv->qemuCaps))) goto error; @@ -840,6 +827,10 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver, if (qemuHotplugDiskSourceAttach(priv->mon, diskdata) < 0) goto exit_monitor; + if (corProps && + qemuMonitorAddObject(priv->mon, &corProps, &corAlias) < 0) + goto exit_monitor; + if (qemuDomainAttachExtensionDevice(priv->mon, &disk->info) < 0) goto exit_monitor; @@ -865,6 +856,8 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver, return ret; exit_monitor: + if (corAlias) + ignore_value(qemuMonitorDelObject(priv->mon, corAlias)); qemuHotplugDiskSourceRemove(priv->mon, diskdata); if (qemuDomainObjExitMonitor(driver, vm) < 0) @@ -4384,10 +4377,13 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainDiskDefPtr disk) { + qemuDomainDiskPrivatePtr diskPriv =3D QEMU_DOMAIN_DISK_PRIVATE(disk); qemuHotplugDiskSourceDataPtr diskbackend =3D NULL; virDomainDeviceDef dev; size_t i; qemuDomainObjPrivatePtr priv =3D vm->privateData; + VIR_AUTOFREE(char *) corAlias =3D NULL; + bool blockdev =3D virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV); int ret =3D -1; VIR_DEBUG("Removing disk %s from domain %p %s", @@ -4397,6 +4393,11 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver, priv->qemuCaps)= )) return -1; + if (blockdev) { + if (VIR_STRDUP(corAlias, diskPriv->nodeCopyOnRead) < 0) + goto cleanup; + } + for (i =3D 0; i < vm->def->ndisks; i++) { if (vm->def->disks[i] =3D=3D disk) { virDomainDiskRemove(vm->def, i); @@ -4406,6 +4407,9 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver, qemuDomainObjEnterMonitor(driver, vm); + if (corAlias) + ignore_value(qemuMonitorDelObject(priv->mon, corAlias)); + qemuHotplugDiskSourceRemove(priv->mon, diskbackend); if (qemuDomainObjExitMonitor(driver, vm) < 0) --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 17:35:24 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=1561391020; cv=none; d=zoho.com; s=zohoarc; b=m9G1lq90Md3dft/3+Odto/wCw9FQkbtJG1YkTIiZv2bAYVzhCmN9tHNYt4aZOonag9x/M9gxqGxN4V/maoSAFjb37SKFlb4DAZJcqxy6UzBKvUK7n6ajNDtr2jkupQtTh4pRSbhNUQdOsgoo8k4sfPdbmynk9Ek/gOVnZaOFGIw= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561391020; 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=1nXJCfV1m+TTnMb2bat/f9JCRDURMsYllD36Fq78PQA=; b=IKJvmANPrC7Jr9tO9TLZTB9Ymdud1Qc3nim+7WC4T8o6MIT1KaQ13G2BhP3TueH1+6HQYbIPNqRwUpMZGhO4K3gv5gbDvGBZyN5PStfM5h1EOJcyZDjCMPdywLBqFkLBGOp6wy0Vtx7D0yUmJTKiUwYFlAkTe9WsN1spajg0G7k= 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 156139102034471.20822285076304; Mon, 24 Jun 2019 08:43:40 -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 1733136809; Mon, 24 Jun 2019 15:43:27 +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 E15A5600D1; Mon, 24 Jun 2019 15:43:24 +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 9B2291806B1B; Mon, 24 Jun 2019 15:43:24 +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 x5OFd2nV020859 for ; Mon, 24 Jun 2019 11:39:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id 23AFF5D9D3; Mon, 24 Jun 2019 15:39:02 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 9FC4A5D9C5 for ; Mon, 24 Jun 2019 15:39:01 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 24 Jun 2019 17:38:48 +0200 Message-Id: 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 03/10] qemu: Introduce new set of helpers for attaching and detaching storage chains 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.30]); Mon, 24 Jun 2019 15:43:38 +0000 (UTC) Content-Type: text/plain; charset="utf-8" These are meant to replace the ad-hoc helpers qemuHotplugDiskSourceAtttach.= .. and the open-coded version in qemu_command.c for use in command line generation. The functions for preparing for attach of chains unfortunately need to be in qemu_command.c as they use function defined by that file and inclusion hierarchy. In this patch new functions are introduced and subsequent patches then refactor individual parts to use them. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_block.c | 117 ++++++++++++++++++++++++++++++++++++++++ src/qemu/qemu_block.h | 29 ++++++++++ src/qemu/qemu_command.c | 67 +++++++++++++++++++++++ src/qemu/qemu_command.h | 11 ++++ 4 files changed, 224 insertions(+) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 560488c852..4130a30e45 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -1622,6 +1622,123 @@ qemuBlockStorageSourceDetachPrepare(virStorageSourc= ePtr src, } +void +qemuBlockStorageSourceChainDataFree(qemuBlockStorageSourceChainDataPtr dat= a) +{ + size_t i; + + if (!data) + return; + + for (i =3D 0; i < data->nsrcdata; i++) + qemuBlockStorageSourceAttachDataFree(data->srcdata[i]); + + VIR_FREE(data->srcdata); + VIR_FREE(data); +} + + +/** + * qemuBlockStorageSourceChainDetachPrepareBlockdev + * @src: storage source chain to remove + * + * Prepares qemuBlockStorageSourceChainDataPtr for detaching @src and it's + * backingStore if -blockdev was used. + */ +qemuBlockStorageSourceChainDataPtr +qemuBlockStorageSourceChainDetachPrepareBlockdev(virStorageSourcePtr src) +{ + VIR_AUTOPTR(qemuBlockStorageSourceAttachData) backend =3D NULL; + VIR_AUTOPTR(qemuBlockStorageSourceChainData) data =3D NULL; + virStorageSourcePtr n; + + if (VIR_ALLOC(data) < 0) + return NULL; + + for (n =3D src; virStorageSourceIsBacking(n); n =3D n->backingStore) { + if (!(backend =3D qemuBlockStorageSourceDetachPrepare(n, NULL))) + return NULL; + + if (VIR_APPEND_ELEMENT(data->srcdata, data->nsrcdata, backend) < 0) + return NULL; + } + + VIR_RETURN_PTR(data); +} + + +/** + * qemuBlockStorageSourceChainDetachPrepareLegacy + * @src: storage source chain to remove + * @driveAlias: Alias of the 'drive' backend (always consumed) + * + * Prepares qemuBlockStorageSourceChainDataPtr for detaching @src and it's + * backingStore if -drive was used. + */ +qemuBlockStorageSourceChainDataPtr +qemuBlockStorageSourceChainDetachPrepareDrive(virStorageSourcePtr src, + char *driveAlias) +{ + VIR_AUTOPTR(qemuBlockStorageSourceAttachData) backend =3D NULL; + VIR_AUTOPTR(qemuBlockStorageSourceChainData) data =3D NULL; + + if (VIR_ALLOC(data) < 0) + return NULL; + + if (!(backend =3D qemuBlockStorageSourceDetachPrepare(src, driveAlias)= )) + return NULL; + + if (VIR_APPEND_ELEMENT(data->srcdata, data->nsrcdata, backend) < 0) + return NULL; + + VIR_RETURN_PTR(data); +} + + +/** + * qemuBlockStorageSourceChainAttach: + * @mon: monitor object + * @data: storage source chain data + * + * Attach a storage source including it's backing chain and supporting obj= ects. + * Caller must enter @mon prior calling this function. In case of error th= is + * function returns -1. @data is updated so that qemuBlockStorageSourceCha= inDetach + * can be used to roll-back the changes. + */ +int +qemuBlockStorageSourceChainAttach(qemuMonitorPtr mon, + qemuBlockStorageSourceChainDataPtr data) +{ + size_t i; + + for (i =3D data->nsrcdata; i > 0; i--) { + if (qemuBlockStorageSourceAttachApply(mon, data->srcdata[i - 1]) <= 0) + return -1; + } + + return 0; +} + + +/** + * qemuBlockStorageSourceChainDetach: + * @mon: monitor object + * @data: storage source chain data + * + * Detach a unused storage source including all it's backing chain and rel= ated + * objects described by @data. + */ +void +qemuBlockStorageSourceChainDetach(qemuMonitorPtr mon, + qemuBlockStorageSourceChainDataPtr data) +{ + size_t i; + + for (i =3D 0; i < data->nsrcdata; i++) + qemuBlockStorageSourceAttachRollback(mon, data->srcdata[i]); +} + + /** * qemuBlockStorageSourceDetachOneBlockdev: * @driver: qemu driver object diff --git a/src/qemu/qemu_block.h b/src/qemu/qemu_block.h index a49c73670b..934a1f125d 100644 --- a/src/qemu/qemu_block.h +++ b/src/qemu/qemu_block.h @@ -125,6 +125,35 @@ qemuBlockStorageSourceDetachOneBlockdev(virQEMUDriverP= tr driver, qemuDomainAsyncJob asyncJob, virStorageSourcePtr src); +struct _qemuBlockStorageSourceChainData { + qemuBlockStorageSourceAttachDataPtr *srcdata; + size_t nsrcdata; +}; + +typedef struct _qemuBlockStorageSourceChainData qemuBlockStorageSourceChai= nData; +typedef qemuBlockStorageSourceChainData *qemuBlockStorageSourceChainDataPt= r; + +void +qemuBlockStorageSourceChainDataFree(qemuBlockStorageSourceChainDataPtr dat= a); + +qemuBlockStorageSourceChainDataPtr +qemuBlockStorageSourceChainDetachPrepareBlockdev(virStorageSourcePtr src); +qemuBlockStorageSourceChainDataPtr +qemuBlockStorageSourceChainDetachPrepareDrive(virStorageSourcePtr src, + char *driveAlias); + +int +qemuBlockStorageSourceChainAttach(qemuMonitorPtr mon, + qemuBlockStorageSourceChainDataPtr data); + +void +qemuBlockStorageSourceChainDetach(qemuMonitorPtr mon, + qemuBlockStorageSourceChainDataPtr data); + + +VIR_DEFINE_AUTOPTR_FUNC(qemuBlockStorageSourceChainData, + qemuBlockStorageSourceChainDataFree); + int qemuBlockSnapshotAddLegacy(virJSONValuePtr actions, virDomainDiskDefPtr disk, diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index b767a1e15f..2a1d22eebf 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -11184,3 +11184,70 @@ qemuBuildStorageSourceAttachPrepareCommon(virStora= geSourcePtr src, return 0; } + + +/** + * qemuBuildStorageSourceChainAttachPrepareDrive: + * @disk: disk definition + * @qemuCaps: qemu capabilities object + * + * Prepares qemuBlockStorageSourceChainDataPtr for attaching @disk via -dr= ive. + */ +qemuBlockStorageSourceChainDataPtr +qemuBuildStorageSourceChainAttachPrepareDrive(virDomainDiskDefPtr disk, + virQEMUCapsPtr qemuCaps) +{ + VIR_AUTOPTR(qemuBlockStorageSourceAttachData) elem =3D NULL; + VIR_AUTOPTR(qemuBlockStorageSourceChainData) data =3D NULL; + qemuBlockStorageSourceChainDataPtr ret =3D NULL; + + if (VIR_ALLOC(data) < 0) + return NULL; + + if (!(elem =3D qemuBuildStorageSourceAttachPrepareDrive(disk, qemuCaps= ))) + return NULL; + + if (qemuBuildStorageSourceAttachPrepareCommon(disk->src, elem, qemuCap= s) < 0) + return NULL; + + if (VIR_APPEND_ELEMENT(data->srcdata, data->nsrcdata, elem) < 0) + return NULL; + + VIR_STEAL_PTR(ret, data); + return ret; +} + + +/** + * qemuBuildStorageSourceChainAttachPrepareDrive: + * @top: storage source chain + * @qemuCaps: qemu capabilities object + * + * Prepares qemuBlockStorageSourceChainDataPtr for attaching @top via -blo= ckdev. + */ +qemuBlockStorageSourceChainDataPtr +qemuBuildStorageSourceChainAttachPrepareBlockdev(virStorageSourcePtr top, + virQEMUCapsPtr qemuCaps) +{ + VIR_AUTOPTR(qemuBlockStorageSourceAttachData) elem =3D NULL; + VIR_AUTOPTR(qemuBlockStorageSourceChainData) data =3D NULL; + qemuBlockStorageSourceChainDataPtr ret =3D NULL; + virStorageSourcePtr n; + + if (VIR_ALLOC(data) < 0) + return NULL; + + for (n =3D top; virStorageSourceIsBacking(n); n =3D n->backingStore) { + if (!(elem =3D qemuBlockStorageSourceAttachPrepareBlockdev(n))) + return NULL; + + if (qemuBuildStorageSourceAttachPrepareCommon(n, elem, qemuCaps) <= 0) + return NULL; + + if (VIR_APPEND_ELEMENT(data->srcdata, data->nsrcdata, elem) < 0) + return NULL; + } + + VIR_STEAL_PTR(ret, data); + return ret; +} diff --git a/src/qemu/qemu_command.h b/src/qemu/qemu_command.h index c885d61578..8695832c16 100644 --- a/src/qemu/qemu_command.h +++ b/src/qemu/qemu_command.h @@ -107,6 +107,17 @@ qemuBuildStorageSourceAttachPrepareCommon(virStorageSo= urcePtr src, qemuBlockStorageSourceAttachData= Ptr data, virQEMUCapsPtr qemuCaps); + +qemuBlockStorageSourceChainDataPtr +qemuBuildStorageSourceChainAttachPrepareDrive(virDomainDiskDefPtr disk, + virQEMUCapsPtr qemuCaps); + + +qemuBlockStorageSourceChainDataPtr +qemuBuildStorageSourceChainAttachPrepareBlockdev(virStorageSourcePtr top, + virQEMUCapsPtr qemuCaps); + + char *qemuBuildDiskDeviceStr(const virDomainDef *def, virDomainDiskDefPtr disk, --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 17:35:24 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=1561390797; cv=none; d=zoho.com; s=zohoarc; b=as4/XjXL9zPKQv/MZNS34QsKPBuTrcl9ZXdB21a4MsaZzyubYP7JA7ENzDgVW+mrXfK7RtBafc0hs0YUBG6oycFYLA6ddn7m9pU5HSKhJY+uUHVv6rU3KqRGap0GyOzsCcIYe5BK/afk9rAuKNuGGe0M+fuQBWk+jjac7Fe1xoE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561390797; 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=vZnI2kpGHMx4oc3lxkrUizyVIm+z6kbIRJywynLxWz4=; b=YdBYaLENxzx5dm5pi8A0cJdLUH492ntj15V4HDlIaZS4UBMBbfrqM9ejZphaazlHslo7gVb5DB9v3uOi3cffyjRWErJKO/5x9Xl2A8Yjj+tyGKlssJCqfVZ2i7I0qwslRpNWzC/XwxoyM438rnV7jHXM9rg+Cifc6lmu9QZPyJE= 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 1561390797996746.8682505420918; Mon, 24 Jun 2019 08:39:57 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 56E3578EC1; Mon, 24 Jun 2019 15:39:26 +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 06DF75D9D3; Mon, 24 Jun 2019 15:39:19 +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 A03EE1806B1A; Mon, 24 Jun 2019 15:39:09 +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 x5OFd2ok020880 for ; Mon, 24 Jun 2019 11:39:02 -0400 Received: by smtp.corp.redhat.com (Postfix) id E07F35D961; Mon, 24 Jun 2019 15:39:02 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6BED25D9C5 for ; Mon, 24 Jun 2019 15:39:02 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 24 Jun 2019 17:38:49 +0200 Message-Id: <0a89bfe2ea43c5140f2bebb33b163b2419ddc5df.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 04/10] qemu: command: Use storage chain helpers in commandline generator 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.27]); Mon, 24 Jun 2019 15:39:56 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Replace the open-coded local implementation with qemuBuildStorageSourceChainAttachPrepare(Drive|Blockdev). Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 34 +++++++--------------------------- 1 file changed, 7 insertions(+), 27 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 2a1d22eebf..acfec8a1bb 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2559,11 +2559,8 @@ qemuBuildDiskSourceCommandLine(virCommandPtr cmd, virDomainDiskDefPtr disk, virQEMUCapsPtr qemuCaps) { - qemuBlockStorageSourceAttachDataPtr *data =3D NULL; - size_t ndata =3D 0; - VIR_AUTOPTR(qemuBlockStorageSourceAttachData) tmp =3D NULL; + VIR_AUTOPTR(qemuBlockStorageSourceChainData) data =3D NULL; virJSONValuePtr copyOnReadProps =3D NULL; - virStorageSourcePtr n; char *str =3D NULL; size_t i; int ret =3D -1; @@ -2574,35 +2571,21 @@ qemuBuildDiskSourceCommandLine(virCommandPtr cmd, goto cleanup; } - for (n =3D disk->src; virStorageSourceIsBacking(n); n =3D n->backi= ngStore) { - if (!(tmp =3D qemuBlockStorageSourceAttachPrepareBlockdev(n))) - goto cleanup; - - if (qemuBuildStorageSourceAttachPrepareCommon(n, tmp, qemuCaps= ) < 0) - goto cleanup; - - if (VIR_APPEND_ELEMENT(data, ndata, tmp) < 0) - goto cleanup; - } + if (!(data =3D qemuBuildStorageSourceChainAttachPrepareBlockdev(di= sk->src, + qemu= Caps))) + goto cleanup; if (disk->copy_on_read =3D=3D VIR_TRISTATE_SWITCH_ON && !(copyOnReadProps =3D qemuBlockStorageGetCopyOnReadProps(disk)= )) goto cleanup; } else { - if (!(tmp =3D qemuBuildStorageSourceAttachPrepareDrive(disk, qemuC= aps))) - goto cleanup; - - if (qemuBuildStorageSourceAttachPrepareCommon(disk->src, tmp, - qemuCaps) < 0) - goto cleanup; - - if (VIR_APPEND_ELEMENT(data, ndata, tmp) < 0) + if (!(data =3D qemuBuildStorageSourceChainAttachPrepareDrive(disk,= qemuCaps))) goto cleanup; } - for (i =3D ndata; i > 0; i--) { + for (i =3D data->nsrcdata; i > 0; i--) { if (qemuBuildBlockStorageSourceAttachDataCommandline(cmd, - data[i - 1]) = < 0) + data->srcdata= [i - 1]) < 0) goto cleanup; } @@ -2617,9 +2600,6 @@ qemuBuildDiskSourceCommandLine(virCommandPtr cmd, ret =3D 0; cleanup: - for (i =3D 0; i < ndata; i++) - qemuBlockStorageSourceAttachDataFree(data[i]); - VIR_FREE(data); virJSONValueFree(copyOnReadProps); VIR_FREE(str); return ret; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 17:35:24 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=1561390873; cv=none; d=zoho.com; s=zohoarc; b=drfos/BLj3+ftkZDf1K840cpZO+dnCZK2kZbMD1QqZauygJ4zYqCZnZe4bSqIcuAJicThGECnwwMCZl+uqaO+w1gR10LUm+HyECYK75wZuIjXWHaJnajwPPJpljw30QCdX2jx5HSA0Iubu8Pr3zXzEwerpZnouKLI0eaeF5MiRs= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561390873; 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=PF2fTh6DPpg6y389tXT4tS9jUPontmOMrGAd093cqaM=; b=Ez+w+cw/C/t8h/h5bpIeKkXj2rUl6SxNVXqq6e7pJi+7fQ3urYVzbON9edw+40osb0H7nLznPeWEZ6enQ29qFC8KYnWR5b2hW6he7BuZZqi0c0/wTIXaT2/u7qFTOHhDQNtJJhpUbAa7krr/wMbdSPN7vveSBaCxTt+0Q1xxxW0= 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 1561390873035207.58131113070692; Mon, 24 Jun 2019 08:41:13 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B5058C05A1D8; Mon, 24 Jun 2019 15:40:54 +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 8AD721001DEF; Mon, 24 Jun 2019 15:40:51 +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 3574B19725; Mon, 24 Jun 2019 15:40:48 +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 x5OFd3aU020908 for ; Mon, 24 Jun 2019 11:39:03 -0400 Received: by smtp.corp.redhat.com (Postfix) id AD6775DA34; Mon, 24 Jun 2019 15:39:03 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3711B5D9C5 for ; Mon, 24 Jun 2019 15:39:03 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 24 Jun 2019 17:38:50 +0200 Message-Id: <217a00832e8db67d867022c7e62fa4add51b7539.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 05/10] qemu: command: Use VIR_AUTO infrastructure in qemuBuildDiskSourceCommandLine 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.84 on 10.5.11.22 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 24 Jun 2019 15:41:11 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index acfec8a1bb..1ae8a00352 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2560,8 +2560,8 @@ qemuBuildDiskSourceCommandLine(virCommandPtr cmd, virQEMUCapsPtr qemuCaps) { VIR_AUTOPTR(qemuBlockStorageSourceChainData) data =3D NULL; - virJSONValuePtr copyOnReadProps =3D NULL; - char *str =3D NULL; + VIR_AUTOPTR(virJSONValue) copyOnReadProps =3D NULL; + VIR_AUTOFREE(char *) copyOnReadPropsStr =3D NULL; size_t i; int ret =3D -1; @@ -2590,18 +2590,15 @@ qemuBuildDiskSourceCommandLine(virCommandPtr cmd, } if (copyOnReadProps) { - if (!(str =3D virJSONValueToString(copyOnReadProps, false))) + if (!(copyOnReadPropsStr =3D virJSONValueToString(copyOnReadProps,= false))) goto cleanup; - virCommandAddArgList(cmd, "-blockdev", str, NULL); - VIR_FREE(str); + virCommandAddArgList(cmd, "-blockdev", copyOnReadPropsStr, NULL); } ret =3D 0; cleanup: - virJSONValueFree(copyOnReadProps); - VIR_FREE(str); return ret; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 17:35:24 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=1561391020; cv=none; d=zoho.com; s=zohoarc; b=lCUBMfIN94EFKD82KA9W1ZLDef8EzhTj6KsvCIJzZE57IZFxalPyY7/i9YBWq3HKPNNq3sDkIpUtBuBrCMgAL5+wfMdo/eiXSk+pelKsCQvpsv8mvLd+R0tRVpJkM3VLGnGQ5itG5FYUcT/CjZKtXeqpBDIdfMJSJ0CXkBPyVw4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561391020; 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=nr/DgiqGC9gaXMDyv5fXZD2JPCK8QIH+/RAO9ooW2AY=; b=nCZ6j9ONArvATBKCS/tAlDS2ZffoKr0W2wG4O+vh5RQyCFXaKr2wmV0x8rSUgEOKUJcxIoegTmuX6nQedMgkPvxjnowrQp+4kgFKz7ApBdQKsfx5j5zEdjeMpMI2YKQM3cW/BpJgG97Hopdmf2xLU6+sXcONqwGOU4hliZS3G7g= 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 1561391020151120.79247625576158; Mon, 24 Jun 2019 08:43:40 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id 7F710C066462; Mon, 24 Jun 2019 15:43:38 +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 582435D9D3; Mon, 24 Jun 2019 15:43:38 +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 09FBE1806B1B; Mon, 24 Jun 2019 15:43:38 +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 x5OFd4JO020931 for ; Mon, 24 Jun 2019 11:39:04 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7760C5D9DE; Mon, 24 Jun 2019 15:39:04 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 02D665D9C5 for ; Mon, 24 Jun 2019 15:39:03 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 24 Jun 2019 17:38:51 +0200 Message-Id: <96c68cc3f22992cc42c6a6e8aba91ff0bb3c115b.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 06/10] qemu: command: get rid of 'cleanup' in qemuBuildDiskSourceCommandLine 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.14 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.31]); Mon, 24 Jun 2019 15:43:39 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 1ae8a00352..7a7497686a 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -2563,43 +2563,37 @@ qemuBuildDiskSourceCommandLine(virCommandPtr cmd, VIR_AUTOPTR(virJSONValue) copyOnReadProps =3D NULL; VIR_AUTOFREE(char *) copyOnReadPropsStr =3D NULL; size_t i; - int ret =3D -1; if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV)) { - if (virStorageSourceIsEmpty(disk->src)) { - ret =3D 0; - goto cleanup; - } + if (virStorageSourceIsEmpty(disk->src)) + return 0; if (!(data =3D qemuBuildStorageSourceChainAttachPrepareBlockdev(di= sk->src, qemu= Caps))) - goto cleanup; + return -1; if (disk->copy_on_read =3D=3D VIR_TRISTATE_SWITCH_ON && !(copyOnReadProps =3D qemuBlockStorageGetCopyOnReadProps(disk)= )) - goto cleanup; + return -1; } else { if (!(data =3D qemuBuildStorageSourceChainAttachPrepareDrive(disk,= qemuCaps))) - goto cleanup; + return -1; } for (i =3D data->nsrcdata; i > 0; i--) { if (qemuBuildBlockStorageSourceAttachDataCommandline(cmd, data->srcdata= [i - 1]) < 0) - goto cleanup; + return -1; } if (copyOnReadProps) { if (!(copyOnReadPropsStr =3D virJSONValueToString(copyOnReadProps,= false))) - goto cleanup; + return -1; virCommandAddArgList(cmd, "-blockdev", copyOnReadPropsStr, NULL); } - ret =3D 0; - - cleanup: - return ret; + return 0; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 17:35:24 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=1561390883; cv=none; d=zoho.com; s=zohoarc; b=hs7tytwqEwnJhEC/9Ru5ChR1bOJ6ZkMBbUdLL7npHQkObEu3kZoeI94PJszgty921Bg2HmKwzP1idfbRQlYPc6/21Z5lxgH3T++XPHzDvWHtX2uM01Ka8sT+dhJC49lJMT/gkPNFr4WMqPTBrm5ObM/2pX10cPt4FGe50Lqexk0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561390883; 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=13kRLxFLhWeh373TSEyliLHrW7g3C8imtqnsW4xmC4o=; b=HFmXwNLFeJEWpux2dr63blIy7gmdfrqcRVo7FXK1kgzq6P3MdPB73pvRDrXyySN+lGrBX2hMeHl1SBgTsBPAGYpPGHxIDjIf2mHT4ccMWj4IHzooEZ8RMwj80rtDlWTFE3DNktO7ceq7sRaayMgOB/MO7aHYt7jZeVFg0vuhSrA= 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 1561390883473924.1170218236194; Mon, 24 Jun 2019 08:41:23 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id F021D81DF5; Mon, 24 Jun 2019 15:41:12 +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 BF55619C69; Mon, 24 Jun 2019 15:41:11 +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 5391B1806B19; Mon, 24 Jun 2019 15:41:07 +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 x5OFd5eD020959 for ; Mon, 24 Jun 2019 11:39:05 -0400 Received: by smtp.corp.redhat.com (Postfix) id 42B3E5D9D3; Mon, 24 Jun 2019 15:39:05 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id C30E75D9C5 for ; Mon, 24 Jun 2019 15:39:04 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 24 Jun 2019 17:38:52 +0200 Message-Id: <76faf87add80cd4be5ba2184414e9559fcb539e9.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 07/10] qemu: hotplug: Use storage chain helpers in qemuDomainAttachDiskGeneric 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.84 on 10.5.11.23 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Mon, 24 Jun 2019 15:41:22 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Replace the use of qemuHotplugDiskSourceAttach* helpers with qemuBuildStorageSourceChainAttachPrepare(Blockdev|Drive). Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_hotplug.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index f96209a0bd..413b81c0c7 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -786,9 +786,9 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver, virDomainObjPtr vm, virDomainDiskDefPtr disk) { + VIR_AUTOPTR(qemuBlockStorageSourceChainData) data =3D NULL; int ret =3D -1; qemuDomainObjPrivatePtr priv =3D vm->privateData; - qemuHotplugDiskSourceDataPtr diskdata =3D NULL; char *devstr =3D NULL; VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg =3D virQEMUDriverGetConfig(d= river); VIR_AUTOPTR(virJSONValue) corProps =3D NULL; @@ -807,11 +807,15 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver, if (disk->copy_on_read =3D=3D VIR_TRISTATE_SWITCH_ON && !(corProps =3D qemuBlockStorageGetCopyOnReadProps(disk))) goto cleanup; - } - if (!(diskdata =3D qemuHotplugDiskSourceAttachPrepare(disk, disk->src, - priv->qemuCaps))) - goto error; + if (!(data =3D qemuBuildStorageSourceChainAttachPrepareBlockdev(di= sk->src, + priv= ->qemuCaps))) + goto cleanup; + } else { + if (!(data =3D qemuBuildStorageSourceChainAttachPrepareDrive(disk, + priv->q= emuCaps))) + goto cleanup; + } if (!(devstr =3D qemuBuildDiskDeviceStr(vm->def, disk, 0, priv->qemuCa= ps))) goto error; @@ -824,7 +828,7 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver, qemuDomainObjEnterMonitor(driver, vm); - if (qemuHotplugDiskSourceAttach(priv->mon, diskdata) < 0) + if (qemuBlockStorageSourceChainAttach(priv->mon, data) < 0) goto exit_monitor; if (corProps && @@ -850,7 +854,6 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver, ret =3D 0; cleanup: - qemuHotplugDiskSourceDataFree(diskdata); qemuDomainSecretDiskDestroy(disk); VIR_FREE(devstr); return ret; @@ -858,7 +861,7 @@ qemuDomainAttachDiskGeneric(virQEMUDriverPtr driver, exit_monitor: if (corAlias) ignore_value(qemuMonitorDelObject(priv->mon, corAlias)); - qemuHotplugDiskSourceRemove(priv->mon, diskdata); + qemuBlockStorageSourceChainDetach(priv->mon, data); if (qemuDomainObjExitMonitor(driver, vm) < 0) ret =3D -2; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 17:35:24 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=1561391036; cv=none; d=zoho.com; s=zohoarc; b=DSL2527OtJ5pd+kmoMCZiLPG3svZJ8FhAQAcEwRIdvFWOblaFJ8GSxqFTNitsVkiaWFRWtb4WBCmP4sbu3mAtRbekNT/EXQ3Nm76xpNasmgMdJKNM9Qw9z9kP3/4Zx3oUIjlX3pqYvhu569xhMB5mIA59x5MgE/26AblyAYl0i4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561391036; 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=HtnONEpoqX2hx5sB8xnBYRhgV3OlAUHcOvedvAS2Rr4=; b=BsmrfjtKpWrlYJAlV2phnRk+tSItbfwSbuXAXJ9vx2JHaHabn3Zogtio+iddjpfsyO/seL/OZGNWtbcantSLPs6S2mpiLKrZMOol6udgDMYvSXAErV50AADStNS2ko46PwoMudtDKW0/Zswwvwb/jBH+0mvssnoq99mxkhscBA4= 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 156139103694166.78977989693522; Mon, 24 Jun 2019 08:43:56 -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 542F4295E; Mon, 24 Jun 2019 15:43:50 +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 2E6D75C23A; Mon, 24 Jun 2019 15:43:50 +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 D785DC57E; Mon, 24 Jun 2019 15:43:48 +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 x5OFd6lp020988 for ; Mon, 24 Jun 2019 11:39:06 -0400 Received: by smtp.corp.redhat.com (Postfix) id 170DC5D9DE; 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 8F5095D9C5 for ; Mon, 24 Jun 2019 15:39:05 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 24 Jun 2019 17:38:53 +0200 Message-Id: <3e3dd4f1a7c8c1589d8dbc19a3f85c2507964fdf.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 08/10] qemu: hotplug: Use storage chain helpers in qemuDomainRemoveDiskDevice 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.39]); Mon, 24 Jun 2019 15:43:55 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Use the new helpers for removing the backing chain in case when -blockdev is used. For -drive this function has a local implementation. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_hotplug.c | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 413b81c0c7..1b1d2ba5ce 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -4381,7 +4381,7 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver, virDomainDiskDefPtr disk) { qemuDomainDiskPrivatePtr diskPriv =3D QEMU_DOMAIN_DISK_PRIVATE(disk); - qemuHotplugDiskSourceDataPtr diskbackend =3D NULL; + VIR_AUTOPTR(qemuBlockStorageSourceChainData) diskBackend =3D NULL; virDomainDeviceDef dev; size_t i; qemuDomainObjPrivatePtr priv =3D vm->privateData; @@ -4392,13 +4392,21 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver, VIR_DEBUG("Removing disk %s from domain %p %s", disk->info.alias, vm, vm->def->name); - if (!(diskbackend =3D qemuHotplugDiskSourceRemovePrepare(disk, disk->s= rc, - priv->qemuCaps)= )) - return -1; if (blockdev) { if (VIR_STRDUP(corAlias, diskPriv->nodeCopyOnRead) < 0) goto cleanup; + + if (!(diskBackend =3D qemuBlockStorageSourceChainDetachPrepareBloc= kdev(disk->src))) + goto cleanup; + } else { + char *driveAlias; + + if (!(driveAlias =3D qemuAliasDiskDriveFromDisk(disk))) + goto cleanup; + + if (!(diskBackend =3D qemuBlockStorageSourceChainDetachPrepareDriv= e(disk->src, driveAlias))) + goto cleanup; } for (i =3D 0; i < vm->def->ndisks; i++) { @@ -4413,7 +4421,7 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver, if (corAlias) ignore_value(qemuMonitorDelObject(priv->mon, corAlias)); - qemuHotplugDiskSourceRemove(priv->mon, diskbackend); + qemuBlockStorageSourceChainDetach(priv->mon, diskBackend); if (qemuDomainObjExitMonitor(driver, vm) < 0) goto cleanup; @@ -4435,7 +4443,6 @@ qemuDomainRemoveDiskDevice(virQEMUDriverPtr driver, ret =3D 0; cleanup: - qemuHotplugDiskSourceDataFree(diskbackend); virDomainDiskDefFree(disk); return ret; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat May 4 17:35:24 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=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 From nobody Sat May 4 17:35:24 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=1561391020; cv=none; d=zoho.com; s=zohoarc; b=SQQQMB1qdsuwmmZ9oaS9HusO4SgzNC8dcYHklTJgyd4RWxPmeQf+IYtFLx397/fLJSD0lQbrLXO77PlpIxE1ZdrKUnFIkqwdeE2ynP/I6X9J+YeN+4zgJoTS6bX83NpkNsqKmit/mzUhFkDDxChAP27Ewdv0VRNXeA7Ft+H82Ts= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1561391020; 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=XySqUpqv11eC8XPsPru6/T9MhPgtDWP3Q8Em0fvayYs=; b=ZzoDOO/GkSRHNV6/y3HA7bQfxCKCv6L93+o+SreEni5HzE/4zGU3Av/1MmzNaUkcjmNPb7KyJJzSDE4C7sk4LazlVWQ0YU6lnQB3xChaql7musqabQ5i9oJhaxJXo9cFemWNNLS3juQ+uZn/VW0TX7P5X1NSzakT3fNsG9vMLfE= 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 1561391020410424.54348635401766; Mon, 24 Jun 2019 08:43:40 -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 71004307D983; Mon, 24 Jun 2019 15:43:33 +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 4469C5B68D; Mon, 24 Jun 2019 15:43:30 +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 F1D9BC57E; Mon, 24 Jun 2019 15:43:26 +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 x5OFd7Lf021038 for ; Mon, 24 Jun 2019 11:39:07 -0400 Received: by smtp.corp.redhat.com (Postfix) id AF2DF5D9D3; Mon, 24 Jun 2019 15:39:07 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 3A46F5D9C5 for ; Mon, 24 Jun 2019 15:39:07 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 24 Jun 2019 17:38:55 +0200 Message-Id: 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 10/10] qemu: hotplug: Remove rest of source backend if hotplug fails 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.48]); Mon, 24 Jun 2019 15:43:38 +0000 (UTC) Content-Type: text/plain; charset="utf-8" When changing media using blockdev-add we need to remove the leftovers if we didn't succeed plugging in the full chain or closing the tray. Otherwise the data structures will be freed and thus the backing chain members will never be unplugged. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_hotplug.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index a1296d55d4..29d703e514 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -491,6 +491,9 @@ qemuDomainChangeMediaBlockdev(virQEMUDriverPtr driver, if (rc =3D=3D 0) rc =3D qemuMonitorBlockdevTrayClose(priv->mon, diskPriv->qomName); + if (rc < 0 && newbackend) + qemuBlockStorageSourceChainDetach(priv->mon, newbackend); + if (qemuDomainObjExitMonitor(driver, vm) < 0 || rc < 0) goto cleanup; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list