From nobody Wed May 8 03:11:30 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 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=1602522606; cv=none; d=zohomail.com; s=zohoarc; b=M6Z8sdIVLavixLs2t90wLMJHDOHeT8IoyPx7DU+BIPe3mnMbWEIVxY/f34f6BxVUvUvo9Xf0MvoRcMWBnBK+u697/92q6/OGqtQGLMZZ5j9JhyZYBIZQhJzBXrM4R3jYLgdWA+pOSF6jbEDYyfvVtIZgdkuYaA3FGSSs/lpACXY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1602522606; h=Content-Type:Content-Transfer-Encoding:Cc:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=dm+ddmH3OyuqoBp2p3EkWLZir1x4gcpyNeToBfmge5U=; b=Eka9962x3erTVCX1md/3SoPmoZe4yCY+74ldo6RHiBd990fLu31ArmQSs25SFk4y48jnQSn4lwvBv3EG7BeDIoDH85m3qDZstOHtXLhdu+Rfmu7czmGtvWITUXf3BQG0TjUcd+APd2+yzT5RaRf5eHWjk5oNahcoF0OUBIABICw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) header.from= Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by mx.zohomail.com with SMTPS id 1602522606868511.1633800273596; Mon, 12 Oct 2020 10:10:06 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-485-oko1HYruM7CQUK3CX9AydA-1; Mon, 12 Oct 2020 13:10:02 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 058D710A0821; Mon, 12 Oct 2020 17:09:29 +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 51ED027BB1; Mon, 12 Oct 2020 17:09:28 +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 66C21183D021; Mon, 12 Oct 2020 17:09:27 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09CH9QnY027803 for ; Mon, 12 Oct 2020 13:09:26 -0400 Received: by smtp.corp.redhat.com (Postfix) id 7C17C73676; Mon, 12 Oct 2020 17:09:26 +0000 (UTC) Received: from colepc.home (ovpn-113-130.rdu2.redhat.com [10.10.113.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id AF70173667; Mon, 12 Oct 2020 17:09:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602522605; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=dm+ddmH3OyuqoBp2p3EkWLZir1x4gcpyNeToBfmge5U=; b=IYORB0ATeePqpAgP0VwV0JFOaCLGm26tfbUcoy2nGGrkb80x26+RlXb6ip77detA3uH4wr Eb5vHnFtp6LIwZjirb380uhgveHsroxXDaL7HhPSIG+O1Qdg95F6jJISL0fZA3lElvSR2f ulvDdO9g4xV9eE+ViDMSWVKBi2qYhGg= X-MC-Unique: oko1HYruM7CQUK3CX9AydA-1 From: Cole Robinson To: libvirt-list@redhat.com Subject: [PATCH v2] qemu: migration: don't open storage driver too early Date: Mon, 12 Oct 2020 13:08:58 -0400 Message-Id: <626e6103f22c78262f5cf0c1bd421c252a6bffca.1602522367.git.crobinso@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-loop: libvir-list@redhat.com Cc: Michal Privoznik , Cole Robinson 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: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.84 on 10.5.11.23 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" If storage migration is requested, and the destination storage does not exist on the remote host, qemu's migration support will call into the libvirt storage driver to precreate the destination storage. The storage driver virConnectPtr is opened too early though, adding an unnecessary dependency on the storage driver for several cases that don't require it. This currently requires kubevirt to install the storage driver even though they aren't actually using it. Push the virGetConnectStorage calls to right before the cases they are actually needed. Signed-off-by: Cole Robinson Reviewed-by: Daniel P. Berrang=C3=A9 --- v2: Only open the connection once per VM via qemuMigrationDstPrecreateStorage src/qemu/qemu_migration.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 2000c86640..4e959abebf 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -169,7 +169,7 @@ qemuMigrationSrcRestoreDomainState(virQEMUDriverPtr dri= ver, virDomainObjPtr vm) =20 =20 static int -qemuMigrationDstPrecreateDisk(virConnectPtr conn, +qemuMigrationDstPrecreateDisk(virConnectPtr *conn, virDomainDiskDefPtr disk, unsigned long long capacity) { @@ -204,7 +204,12 @@ qemuMigrationDstPrecreateDisk(virConnectPtr conn, *volName =3D '\0'; volName++; =20 - if (!(pool =3D virStoragePoolLookupByTargetPath(conn, basePath))) + if (!*conn) { + if (!(*conn =3D virGetConnectStorage())) + goto cleanup; + } + + if (!(pool =3D virStoragePoolLookupByTargetPath(*conn, basePath))) goto cleanup; format =3D virStorageFileFormatTypeToString(disk->src->format); if (disk->src->format =3D=3D VIR_STORAGE_FILE_QCOW2) @@ -212,7 +217,12 @@ qemuMigrationDstPrecreateDisk(virConnectPtr conn, break; =20 case VIR_STORAGE_TYPE_VOLUME: - if (!(pool =3D virStoragePoolLookupByName(conn, disk->src->srcpool= ->pool))) + if (!*conn) { + if (!(*conn =3D virGetConnectStorage())) + goto cleanup; + } + + if (!(pool =3D virStoragePoolLookupByName(*conn, disk->src->srcpoo= l->pool))) goto cleanup; format =3D virStorageFileFormatTypeToString(disk->src->format); volName =3D disk->src->srcpool->volume; @@ -304,14 +314,11 @@ qemuMigrationDstPrecreateStorage(virDomainObjPtr vm, { int ret =3D -1; size_t i =3D 0; - virConnectPtr conn; + virConnectPtr conn =3D NULL; =20 if (!nbd || !nbd->ndisks) return 0; =20 - if (!(conn =3D virGetConnectStorage())) - return -1; - for (i =3D 0; i < nbd->ndisks; i++) { virDomainDiskDefPtr disk; const char *diskSrcPath; @@ -349,7 +356,8 @@ qemuMigrationDstPrecreateStorage(virDomainObjPtr vm, =20 VIR_DEBUG("Proceeding with disk source %s", NULLSTR(diskSrcPath)); =20 - if (qemuMigrationDstPrecreateDisk(conn, disk, nbd->disks[i].capaci= ty) < 0) + if (qemuMigrationDstPrecreateDisk(&conn, + disk, nbd->disks[i].capacity) < = 0) goto cleanup; } =20 --=20 2.28.0