From nobody Sat Apr 20 12:28:13 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=1562857017; cv=none; d=zoho.com; s=zohoarc; b=QckSTanz9TNYpjQiJ9jmQ4UrW5+z3jyUa6QoOeNS4eqyJKNFihtCOeOHwgKUpfGxAfObFE1UXn+nS1hIktLGwutg+xoO/7RcuGqx3CzG5hXoccfQYInmvCDERBr2fw3bcGP5YhthY7+l2d2HbhyfqRiCxkE2i4yu2olziksAJqE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562857017; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=HaDrl1s1p00XfLc3OvmZjxiAkzdXCBKHCYK8c6ZeAVY=; b=L67XuZ84p/DEuHnUpz8RCNgaBONAtJC4ZWEQwMexbb2j98DRiV5Rty0zaCWU3WKUgLOUqcrLfea5POa1n7ZfzwV2oL8QnjEX9AGooP+ykEIIH+bz8v/5Yz1lLhTsUVzQAxtmkja3n3mgzL6vahV2WhccY98baZyT6Ao9nWi9aZ0= 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 1562857017684890.6857700020631; Thu, 11 Jul 2019 07:56:57 -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 EA16A3082E8E; Thu, 11 Jul 2019 14:56:55 +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 C61FC10190B6; Thu, 11 Jul 2019 14:56:55 +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 75CA219729; Thu, 11 Jul 2019 14:56:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6BEuC0C004762 for ; Thu, 11 Jul 2019 10:56:12 -0400 Received: by smtp.corp.redhat.com (Postfix) id 12B041001B17; Thu, 11 Jul 2019 14:56:12 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 6CD1D1001281; Thu, 11 Jul 2019 14:56:11 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 11 Jul 2019 16:56:02 +0200 Message-Id: <5957dac55aa7a36a2b412a771bd9d1a9d76365dc.1562856896.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 1/4] qemu: blockjob: Don't reset state when entering sync blockjob 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.46]); Thu, 11 Jul 2019 14:56:56 +0000 (UTC) Content-Type: text/plain; charset="utf-8" job->newstate is now used internally all the time so there's no need to clear it as it already has correct value. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_blockjob.c | 1 - 1 file changed, 1 deletion(-) diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index 34a4047210..a4662342a7 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -428,7 +428,6 @@ qemuBlockJobSyncBegin(qemuBlockJobDataPtr job) VIR_DEBUG("disk=3D%s", NULLSTR(diskdst)); job->synchronous =3D true; - job->newstate =3D -1; } --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 20 12:28:13 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=1562857021; cv=none; d=zoho.com; s=zohoarc; b=CHiit+w38OYg5wpscc6eyUbDaDeNdUBfN/HLFqhC4OjaIcZNL+fD9CSYBmUriGcJNX/cYMOpEVOexDxGN6H/NYV9mP1vxAVpueoCz0tBLabN2OOPqtD22jettAhGtK7UWQl3EeBJqFk8m8X3zPJN0E66BZI9n6pXj9wds4Vt9RQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562857021; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=495FhsmIvlxtFL7GW9PkHa7YeI6EGcVlvmgfjnG/yj0=; b=dsFrTISXhImD1SO4PGfqQdbyURHldIS8CWkgxexw+pSMhAVDam1IZt87y3nCA8wKhMSysHpKRHmpiLBsuJSkNgw52onbgJStI8IGln88zcVktSKrgAWagSlf8qsYf0N6eSvyOZanii1VsJN363CKuoBK/fCWY4ufzmjermdY1vA= 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 1562857021626592.122250122382; Thu, 11 Jul 2019 07:57:01 -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 CB5622EED07; Thu, 11 Jul 2019 14:56:59 +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 9F09F5FC02; Thu, 11 Jul 2019 14:56:59 +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 58CAD1833005; Thu, 11 Jul 2019 14:56:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6BEuDGD004772 for ; Thu, 11 Jul 2019 10:56:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id 03E2D1001B17; Thu, 11 Jul 2019 14:56:13 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5E3931001B16; Thu, 11 Jul 2019 14:56:12 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 11 Jul 2019 16:56:03 +0200 Message-Id: <2c772f1328b64bebe69e5fccefae75dcb7d4d863.1562856896.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 2/4] qemu: blockjob: Don't emit traditional disk events for jobs without disk 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.29]); Thu, 11 Jul 2019 14:57:00 +0000 (UTC) Content-Type: text/plain; charset="utf-8" With -blockdev it will be possible that a block job loses the disk that was used to start it to a guest-initiated hot-unplug. Don't emit the block job events in that case as we can't report the top level source or disk target for an unplugged (and potentially replugged with different source) disk. Eventually when we add machinery for tracking jobs globally for a VM the event will be reinstated via the domain job event. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_blockjob.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/qemu/qemu_blockjob.c b/src/qemu/qemu_blockjob.c index a4662342a7..b3bdbeb990 100644 --- a/src/qemu/qemu_blockjob.c +++ b/src/qemu/qemu_blockjob.c @@ -216,6 +216,10 @@ qemuBlockJobEmitEvents(virQEMUDriverPtr driver, virObjectEventPtr event =3D NULL; virObjectEventPtr event2 =3D NULL; + /* don't emit events for jobs without disk */ + if (!disk) + return; + /* don't emit events for internal jobs and states */ if (type >=3D VIR_DOMAIN_BLOCK_JOB_TYPE_LAST || status >=3D VIR_DOMAIN_BLOCK_JOB_LAST) --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 20 12:28:13 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=1562856980; cv=none; d=zoho.com; s=zohoarc; b=b0/Nb3PH76FvaG0IM5Cna+FwnbUW3E9pcYYnm9MOpeZE55cZ2tfG7jkC5Ark9wcnd3Q2LGo22/d17pqr2KCcyZtufb2fIylom5gvr2IZxzgg6o6h4Xrubzhe24SQ/FnyW/htLXnlbruSBP3j2kGRKEuwgULTgvRJ4eSJfWWu12Y= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562856980; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=jia9sD/HRzru4qQiLc4xSgO8YIf+utzUNaQ5FbU2P6Q=; b=nYGD+XQoJbFVY/FEjd5xsOHjG91/U+ZcOW5clmC/cqsYjMd5OjjXudxiN4bvxUJlKOvuTnKgRs6wg+1UxUyg5Ii+YyJc8czECsPw5N4WU5C/aXpuESDExr0BNyhSW77kmL1Dzq7j511ZtaL7uHeTcjbKvgcKYXira+wlBMfP+LM= 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 156285698081056.98781046314548; Thu, 11 Jul 2019 07:56:20 -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 C97788552E; Thu, 11 Jul 2019 14:56:18 +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 7696519C69; Thu, 11 Jul 2019 14:56:18 +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 3AB3D19727; Thu, 11 Jul 2019 14:56:17 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6BEuDu3004780 for ; Thu, 11 Jul 2019 10:56:13 -0400 Received: by smtp.corp.redhat.com (Postfix) id EA32E1001B02; Thu, 11 Jul 2019 14:56:13 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 509251001B16; Thu, 11 Jul 2019 14:56:13 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 11 Jul 2019 16:56:04 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 3/4] qemu: Refactor variables for extracting flags in qemuDomainBlockCopyCommon 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.28]); Thu, 11 Jul 2019 14:56:19 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Add separate booleans for extracting VIR_DOMAIN_BLOCK_COPY_REUSE_EXT and VIR_DOMAIN_BLOCK_COPY_SHALLOW from '@flags' and also change 'reuse' into 'existing'. qemuMonitorDriveMirror requires the unmodified state of the flags to pass to qemu and also we use the value a few times internally. Extract it separately now. The 'reuse' flag did not indicate reusing of the file as much as the fact that the storage is existing and thus should not be created, so modify the name to reflect this. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_driver.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 140896f329..1955e871ec 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -17507,7 +17507,9 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, bool need_unlink =3D false; VIR_AUTOUNREF(virQEMUDriverConfigPtr) cfg =3D virQEMUDriverGetConfig(d= river); const char *format =3D NULL; - bool reuse =3D !!(flags & VIR_DOMAIN_BLOCK_COPY_REUSE_EXT); + bool mirror_reuse =3D !!(flags & VIR_DOMAIN_BLOCK_COPY_REUSE_EXT); + bool mirror_shallow =3D !!(flags & VIR_DOMAIN_BLOCK_COPY_SHALLOW); + bool existing =3D mirror_reuse; qemuBlockJobDataPtr job =3D NULL; VIR_AUTOUNREF(virStorageSourcePtr) mirror =3D mirrorsrc; bool blockdev =3D virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV); @@ -17571,8 +17573,7 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, /* unless the user provides a pre-created file, shallow copy into a raw * file is not possible */ - if ((flags & VIR_DOMAIN_BLOCK_COPY_SHALLOW) && !reuse && - mirror->format =3D=3D VIR_STORAGE_FILE_RAW) { + if (mirror_shallow && !existing && mirror->format =3D=3D VIR_STORAGE_F= ILE_RAW) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, _("shallow copy of disk '%s' into a raw file " "is not possible"), @@ -17591,11 +17592,11 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, if (qemuDomainStorageFileInit(driver, vm, mirror, NULL) < 0) goto endjob; - if (qemuDomainBlockCopyValidateMirror(mirror, disk->dst, &reuse) < 0) + if (qemuDomainBlockCopyValidateMirror(mirror, disk->dst, &existing) < = 0) goto endjob; if (!mirror->format) { - if (!(flags & VIR_DOMAIN_BLOCK_COPY_REUSE_EXT)) { + if (!mirror_reuse) { mirror->format =3D disk->src->format; } else { /* If the user passed the REUSE_EXT flag, then either they @@ -17618,7 +17619,7 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, } /* pre-create the image file */ - if (!reuse) { + if (!existing) { if (virStorageFileCreate(mirror) < 0) { virReportSystemError(errno, "%s", _("failed to create copy tar= get")); goto endjob; @@ -17636,7 +17637,7 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, /* If reusing an external image that includes a backing file but the u= ser * did not enumerate the chain in the XML we need to detect the chain = */ - if (flags & VIR_DOMAIN_BLOCK_COPY_REUSE_EXT && + if (mirror_reuse && mirror->format >=3D VIR_STORAGE_FILE_BACKING && mirror->backingStore =3D=3D NULL && qemuDomainDetermineDiskChain(driver, vm, disk, mirror, true) < 0) @@ -17653,11 +17654,10 @@ qemuDomainBlockCopyCommon(virDomainObjPtr vm, /* Actually start the mirroring */ qemuDomainObjEnterMonitor(driver, vm); /* qemuMonitorDriveMirror needs to honor the REUSE_EXT flag as specifi= ed - * by the user regardless of how @reuse was modified */ + * by the user */ ret =3D qemuMonitorDriveMirror(priv->mon, device, mirror->path, format, bandwidth, granularity, buf_size, - flags & VIR_DOMAIN_BLOCK_COPY_SHALLOW, - flags & VIR_DOMAIN_BLOCK_COPY_REUSE_EXT); + mirror_shallow, mirror_reuse); virDomainAuditDisk(vm, NULL, mirror, "mirror", ret >=3D 0); if (qemuDomainObjExitMonitor(driver, vm) < 0) ret =3D -1; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list From nobody Sat Apr 20 12:28:13 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=1562856992; cv=none; d=zoho.com; s=zohoarc; b=eQ/zhejU+fRJwZkAtVn/WP7x/8Ljd5jBpZCzFmU5lBb2cbXRSDHlqlba0l8wZN27t7iEZlxhpkajGrVJXWid3T+8Jv1p3OXCYKdC2W8E0vhBMuQI+0s+hzJPvjbA9ZpD1tJASw0w2gYzAQhrT9H3QvDlWADzSWJqrrlOSMHuXQ4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zoho.com; s=zohoarc; t=1562856992; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:To:ARC-Authentication-Results; bh=r21ciKc5m8/vMIEmtXjk9EthRcwDXlHCV0Jm3pkwKqc=; b=SmCcz8jvKoDa63Op1kj8z/bGlsWWiX4skjYdIOckN4YVEg4HoZ0TWGhhYLHWAw3bZiSuz2mm+oTg2f0rTTQR/mKBbhdtpXpXBgg3Vw9opyxCZF63je3pCnkVlu4V1Rz+HVb60CQcIHMVInmb4nQEH2HMo8GMNL0TE+m26UUUwyk= 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 1562856992045991.0416620305152; Thu, 11 Jul 2019 07:56:32 -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 23653300183C; Thu, 11 Jul 2019 14:56:30 +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 E9BC85C559; Thu, 11 Jul 2019 14:56:29 +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 ADD561833002; Thu, 11 Jul 2019 14:56:29 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id x6BEuELk004795 for ; Thu, 11 Jul 2019 10:56:14 -0400 Received: by smtp.corp.redhat.com (Postfix) id DE5571001B02; Thu, 11 Jul 2019 14:56:14 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.229]) by smtp.corp.redhat.com (Postfix) with ESMTP id 442701001B10; Thu, 11 Jul 2019 14:56:14 +0000 (UTC) From: Peter Krempa To: libvir-list@redhat.com Date: Thu, 11 Jul 2019 16:56:05 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 4/4] qemu: block: Split up qemuBlockStorageSourceAttachApply 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.40]); Thu, 11 Jul 2019 14:56:30 +0000 (UTC) Content-Type: text/plain; charset="utf-8" Split up the addition of a storage source into the following sub-steps: 1) storage access dependancies (TLS transport, persistent reservation) 2) storage acccess node (file/gluster/nbd...) 3) format driver dependancies (encryption secret) 4) format driver node (qcow2, raw, ...) The functions split out will be later reused when implementing support for 'blockdev-create' as we'll need the dependancies plugged in first, then blockdev-create will be called and after that successfully finishes blockdev-add will be added. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_block.c | 86 +++++++++++++++++++++++++++++++------------ 1 file changed, 63 insertions(+), 23 deletions(-) diff --git a/src/qemu/qemu_block.c b/src/qemu/qemu_block.c index 0a6522577d..8641e2011c 100644 --- a/src/qemu/qemu_block.c +++ b/src/qemu/qemu_block.c @@ -1450,25 +1450,10 @@ qemuBlockStorageSourceAttachPrepareBlockdev(virStor= ageSourcePtr src) } -/** - * qemuBlockStorageSourceAttachApply: - * @mon: monitor object - * @data: structure holding data of block device to apply - * - * Attaches a virStorageSource definition converted to - * qemuBlockStorageSourceAttachData to a running VM. This function expects= being - * called after the monitor was entered. - * - * Returns 0 on success and -1 on error with a libvirt error reported. If = an - * error occurred, changes which were already applied need to be rolled ba= ck by - * calling qemuBlockStorageSourceAttachRollback. - */ -int -qemuBlockStorageSourceAttachApply(qemuMonitorPtr mon, - qemuBlockStorageSourceAttachDataPtr data) +static int +qemuBlockStorageSourceAttachApplyStorageDeps(qemuMonitorPtr mon, + qemuBlockStorageSourceAttachD= ataPtr data) { - int rv; - if (data->prmgrProps && qemuMonitorAddObject(mon, &data->prmgrProps, &data->prmgrAlias) < = 0) return -1; @@ -1478,15 +1463,20 @@ qemuBlockStorageSourceAttachApply(qemuMonitorPtr mo= n, &data->authsecretAlias) < 0) return -1; - if (data->encryptsecretProps && - qemuMonitorAddObject(mon, &data->encryptsecretProps, - &data->encryptsecretAlias) < 0) - return -1; - if (data->tlsProps && qemuMonitorAddObject(mon, &data->tlsProps, &data->tlsAlias) < 0) return -1; + return 0; +} + + +static int +qemuBlockStorageSourceAttachApplyStorage(qemuMonitorPtr mon, + qemuBlockStorageSourceAttachDataP= tr data) +{ + int rv; + if (data->storageProps) { rv =3D qemuMonitorBlockdevAdd(mon, data->storageProps); data->storageProps =3D NULL; @@ -1497,6 +1487,29 @@ qemuBlockStorageSourceAttachApply(qemuMonitorPtr mon, data->storageAttached =3D true; } + return 0; +} + + +static int +qemuBlockStorageSourceAttachApplyFormatDeps(qemuMonitorPtr mon, + qemuBlockStorageSourceAttachDa= taPtr data) +{ + if (data->encryptsecretProps && + qemuMonitorAddObject(mon, &data->encryptsecretProps, + &data->encryptsecretAlias) < 0) + return -1; + + return 0; +} + + +static int +qemuBlockStorageSourceAttachApplyFormat(qemuMonitorPtr mon, + qemuBlockStorageSourceAttachDataPt= r data) +{ + int rv; + if (data->formatProps) { rv =3D qemuMonitorBlockdevAdd(mon, data->formatProps); data->formatProps =3D NULL; @@ -1507,6 +1520,33 @@ qemuBlockStorageSourceAttachApply(qemuMonitorPtr mon, data->formatAttached =3D true; } + return 0; +} + + +/** + * qemuBlockStorageSourceAttachApply: + * @mon: monitor object + * @data: structure holding data of block device to apply + * + * Attaches a virStorageSource definition converted to + * qemuBlockStorageSourceAttachData to a running VM. This function expects= being + * called after the monitor was entered. + * + * Returns 0 on success and -1 on error with a libvirt error reported. If = an + * error occurred, changes which were already applied need to be rolled ba= ck by + * calling qemuBlockStorageSourceAttachRollback. + */ +int +qemuBlockStorageSourceAttachApply(qemuMonitorPtr mon, + qemuBlockStorageSourceAttachDataPtr data) +{ + if (qemuBlockStorageSourceAttachApplyStorageDeps(mon, data) < 0 || + qemuBlockStorageSourceAttachApplyStorage(mon, data) < 0 || + qemuBlockStorageSourceAttachApplyFormatDeps(mon, data) < 0 || + qemuBlockStorageSourceAttachApplyFormat(mon, data) < 0) + return -1; + if (data->driveCmd) { if (qemuMonitorAddDrive(mon, data->driveCmd) < 0) return -1; --=20 2.21.0 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list