From nobody Tue Feb 10 01:38:17 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1534176153836277.8782444201777; Mon, 13 Aug 2018 09:02:33 -0700 (PDT) Received: from smtp.corp.redhat.com (int-mx11.intmail.prod.int.phx2.redhat.com [10.5.11.26]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id AFDA230A3AD1; Mon, 13 Aug 2018 16:02:31 +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 6D5003083322; Mon, 13 Aug 2018 16:02:31 +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 11CEE3FC9D; Mon, 13 Aug 2018 16:02:31 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w7DG1C81001622 for ; Mon, 13 Aug 2018 12:01:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id E2C222166BA5; Mon, 13 Aug 2018 16:01:11 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 809EB2166BA0 for ; Mon, 13 Aug 2018 16:01:11 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Mon, 13 Aug 2018 18:00:17 +0200 Message-Id: <22b57b1b4aff802389ae5b0e2469d3a7c0977b54.1534173735.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCHv2 43/62] qemu: hotplug: Prepare for blockdev-add/blockdev-del with backing 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: , MIME-Version: 1.0 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.26 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.43]); Mon, 13 Aug 2018 16:02:32 +0000 (UTC) X-ZohoMail: RDMRC_0 RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Initialize data for the whole backing chain when plugging in or removing disks when a machine supports -blockdev. Similarly to startup we need to prepare the structures for the whole backing chain and take care of the copy-on-read feature. Signed-off-by: Peter Krempa --- src/qemu/qemu_hotplug.c | 77 +++++++++++++++++++++++++++++++++++++++------= ---- 1 file changed, 62 insertions(+), 15 deletions(-) diff --git a/src/qemu/qemu_hotplug.c b/src/qemu/qemu_hotplug.c index 32d0c3862e..6fde7308f7 100644 --- a/src/qemu/qemu_hotplug.c +++ b/src/qemu/qemu_hotplug.c @@ -380,6 +380,10 @@ 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; @@ -393,6 +397,9 @@ 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]); @@ -461,25 +468,40 @@ qemuHotplugRemoveStorageSourcePrepareData(virStorageS= ourcePtr src, static qemuHotplugDiskSourceDataPtr qemuHotplugDiskSourceRemovePrepare(virDomainDiskDefPtr disk, - virQEMUCapsPtr qemuCaps ATTRIBUTE_UNUSE= D) + virQEMUCapsPtr qemuCaps) { + qemuDomainDiskPrivatePtr diskPriv =3D QEMU_DOMAIN_DISK_PRIVATE(disk); qemuBlockStorageSourceAttachDataPtr 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 (!(drivealias =3D qemuAliasDiskDriveFromDisk(disk))) - goto cleanup; + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV)) { + if (VIR_STRDUP(data->corAlias, diskPriv->nodeCopyOnRead) < 0) + goto cleanup; - if (!(backend =3D qemuHotplugRemoveStorageSourcePrepareData(disk->src, - drivealias))) - goto cleanup; + for (n =3D disk->src; virStorageSourceIsBacking(n); n =3D n->backi= ngStore) { + if (!(backend =3D qemuHotplugRemoveStorageSourcePrepareData(n,= NULL))) + goto cleanup; - if (VIR_APPEND_ELEMENT(data->backends, data->nbackends, backend) < 0) - 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 qemuHotplugRemoveStorageSourcePrepareData(disk->= src, + driveali= as))) + goto cleanup; + + if (VIR_APPEND_ELEMENT(data->backends, data->nbackends, backend) <= 0) + goto cleanup; + } VIR_STEAL_PTR(ret, data); @@ -502,21 +524,39 @@ static qemuHotplugDiskSourceDataPtr qemuHotplugDiskSourceAttachPrepare(virDomainDiskDefPtr disk, virQEMUCapsPtr qemuCaps) { - qemuBlockStorageSourceAttachDataPtr backend; + qemuBlockStorageSourceAttachDataPtr backend =3D NULL; qemuHotplugDiskSourceDataPtr data; qemuHotplugDiskSourceDataPtr ret =3D NULL; + virStorageSourcePtr n; if (VIR_ALLOC(data) < 0) return NULL; - if (!(backend =3D qemuBuildStorageSourceAttachPrepareDrive(disk, qemuC= aps))) - goto cleanup; + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV)) { + if (disk->copy_on_read =3D=3D VIR_TRISTATE_SWITCH_ON && + !(data->corProps =3D qemuBlockStorageGetCopyOnReadProps(disk))) + goto cleanup; - if (qemuBuildStorageSourceAttachPrepareCommon(disk->src, backend, qemu= Caps) < 0) - goto cleanup; + for (n =3D disk->src; virStorageSourceIsBacking(n); n =3D n->backi= ngStore) { + if (!(backend =3D qemuBlockStorageSourceAttachPrepareBlockdev(= n))) + goto cleanup; - if (VIR_APPEND_ELEMENT(data->backends, data->nbackends, backend) < 0) - 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 { + if (!(backend =3D qemuBuildStorageSourceAttachPrepareDrive(disk, q= emuCaps))) + goto cleanup; + + if (qemuBuildStorageSourceAttachPrepareCommon(disk->src, backend, = qemuCaps) < 0) + goto cleanup; + + if (VIR_APPEND_ELEMENT(data->backends, data->nbackends, backend) <= 0) + goto cleanup; + } VIR_STEAL_PTR(ret, data); @@ -546,6 +586,10 @@ qemuHotplugDiskSourceAttach(qemuMonitorPtr mon, return -1; } + if (data->corProps && + qemuMonitorAddObject(mon, &data->corProps, &data->corAlias) < 0) + return -1; + return 0; } @@ -566,6 +610,9 @@ 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]); } --=20 2.16.2 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list