From nobody Mon Feb 9 12:29:39 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 Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1507118323221266.0171237183873; Wed, 4 Oct 2017 04:58:43 -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 4CDA55F297D; Wed, 4 Oct 2017 11:58:42 +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 2E6B55C542; Wed, 4 Oct 2017 11:58:42 +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 E5D8A18355C3; Wed, 4 Oct 2017 11:58:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id v94BhIdf008619 for ; Wed, 4 Oct 2017 07:43:18 -0400 Received: by smtp.corp.redhat.com (Postfix) id 36B8060F89; Wed, 4 Oct 2017 11:43:18 +0000 (UTC) Received: from angien.brq.redhat.com (unknown [10.43.2.136]) by smtp.corp.redhat.com (Postfix) with ESMTP id 8AABD60F81; Wed, 4 Oct 2017 11:43:17 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com 4CDA55F297D Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx09.extmail.prod.ext.phx2.redhat.com; spf=fail smtp.mailfrom=libvir-list-bounces@redhat.com From: Peter Krempa To: libvir-list@redhat.com Date: Wed, 4 Oct 2017 13:42:56 +0200 Message-Id: <7ba914ce36ec1d342037f81ecd544b24790b002b.1507117236.git.pkrempa@redhat.com> In-Reply-To: References: In-Reply-To: References: X-Scanned-By: MIMEDefang 2.79 on 10.5.11.12 X-loop: libvir-list@redhat.com Cc: Peter Krempa Subject: [libvirt] [PATCH 7/7] qemu: process: move disk presence checking to host setup function 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.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.38]); Wed, 04 Oct 2017 11:58:42 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" Checking of disk presence accesses storage on the host so it should be done from the host setup function. Move the code to new function called qemuProcessPrepareHostStorage and remove qemuDomainCheckDiskPresence. Reviewed-by: John Ferlan --- src/qemu/qemu_domain.c | 41 ----------------------------------------- src/qemu/qemu_process.c | 46 ++++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 42 insertions(+), 45 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index d3d5dbac6..a8c718f62 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5681,47 +5681,6 @@ qemuDomainCheckDiskStartupPolicy(virQEMUDriverPtr dr= iver, } -int -qemuDomainCheckDiskPresence(virQEMUDriverPtr driver, - virDomainObjPtr vm, - unsigned int flags) -{ - size_t i; - bool pretend =3D flags & VIR_QEMU_PROCESS_START_PRETEND; - bool cold_boot =3D flags & VIR_QEMU_PROCESS_START_COLD; - - VIR_DEBUG("Checking for disk presence"); - for (i =3D vm->def->ndisks; i > 0; i--) { - size_t idx =3D i - 1; - virDomainDiskDefPtr disk =3D vm->def->disks[idx]; - virStorageFileFormat format =3D virDomainDiskGetFormat(disk); - - if (pretend) - continue; - - if (virStorageSourceIsEmpty(disk->src)) - continue; - - /* There is no need to check the backing chain for disks - * without backing support, the fact that the file exists is - * more than enough */ - if (virStorageSourceIsLocalStorage(disk->src) && - format > VIR_STORAGE_FILE_NONE && - format < VIR_STORAGE_FILE_BACKING && - virFileExists(virDomainDiskGetSource(disk))) - continue; - - if (qemuDomainDetermineDiskChain(driver, vm, disk, true, true) >= =3D 0) - continue; - - if (qemuDomainCheckDiskStartupPolicy(driver, vm, idx, cold_boot) >= =3D 0) - continue; - - return -1; - } - - return 0; -} /* * The vm must be locked when any of the following cleanup functions is diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 84792c2a7..6bebfe4f4 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -5385,10 +5385,6 @@ qemuProcessPrepareDomain(virConnectPtr conn, if (qemuProcessPrepareDomainStorage(conn, driver, vm, cfg, flags) < 0) goto cleanup; - /* Drop possibly missing disks from the definition. */ - if (qemuDomainCheckDiskPresence(driver, vm, flags) < 0) - goto cleanup; - VIR_DEBUG("Create domain masterKey"); if (qemuDomainMasterKeyCreate(vm) < 0) goto cleanup; @@ -5435,6 +5431,44 @@ qemuProcessPrepareDomain(virConnectPtr conn, } +static int +qemuProcessPrepareHostStorage(virQEMUDriverPtr driver, + virDomainObjPtr vm, + unsigned int flags) +{ + size_t i; + bool cold_boot =3D flags & VIR_QEMU_PROCESS_START_COLD; + + for (i =3D vm->def->ndisks; i > 0; i--) { + size_t idx =3D i - 1; + virDomainDiskDefPtr disk =3D vm->def->disks[idx]; + virStorageFileFormat format =3D virDomainDiskGetFormat(disk); + + if (virStorageSourceIsEmpty(disk->src)) + continue; + + /* There is no need to check the backing chain for disks + * without backing support, the fact that the file exists is + * more than enough */ + if (virStorageSourceIsLocalStorage(disk->src) && + format > VIR_STORAGE_FILE_NONE && + format < VIR_STORAGE_FILE_BACKING && + virFileExists(virDomainDiskGetSource(disk))) + continue; + + if (qemuDomainDetermineDiskChain(driver, vm, disk, true, true) >= =3D 0) + continue; + + if (qemuDomainCheckDiskStartupPolicy(driver, vm, idx, cold_boot) >= =3D 0) + continue; + + return -1; + } + + return 0; +} + + /** * qemuProcessPrepareHost: * @driver: qemu driver @@ -5527,6 +5561,10 @@ qemuProcessPrepareHost(virQEMUDriverPtr driver, if (qemuDomainWriteMasterKeyFile(driver, vm) < 0) goto cleanup; + VIR_DEBUG("Preparing disks (host)"); + if (qemuProcessPrepareHostStorage(driver, vm, flags) < 0) + goto cleanup; + ret =3D 0; cleanup: virObjectUnref(cfg); --=20 2.14.1 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list