From patchwork Sun Oct 11 23:44:36 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Cole Robinson X-Patchwork-Id: 317603 Delivered-To: patch@linaro.org Received: by 2002:a92:d603:0:0:0:0:0 with SMTP id w3csp4153633ilm; Sun, 11 Oct 2020 16:45:06 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzZnflXLvgpZPGid3EK0sFgwErInXhS0n/fKsvFCfGZysfn2ANBTZ+u37JaefoRGgJhXDPp X-Received: by 2002:a50:8fa3:: with SMTP id y32mr11548417edy.78.1602459906458; Sun, 11 Oct 2020 16:45:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1602459906; cv=none; d=google.com; s=arc-20160816; b=CE+ZsKX50uu6LbcERmr+t3ER6DGY3mXRtVc+pRJvkN1No6PM2wJY+kCeJDBWOIxXf/ IHeLd3QNLdhocPy6rq55ya716PWo3+3vNxdGIoUONaXUQwlAEnBlcobILPdg040pWWPl JuLFx897iMBT+Ivf+Cd2xqsjgcnx5pmukY8HrgxM1DTLVW8KNTK7GXeCt+52qqT5iFZH 4Rg0wLTZ+drtX9muZVfyPF2APaMtG8QKIWez1ggGf6nRkkyF5ptiab1xrHYEJQatvd6B sh1Y9LyDGRS3e6peLoQ9A+fvUt5YGCIRZLUb0swLsei6XsCmKd7dKBzaPZ4G+omAPCIC G3Yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:errors-to:sender:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence:cc :mime-version:message-id:date:subject:to:from:delivered-to :dkim-signature; bh=fGF7Gyq28AVTZ9ZAoqTPSs4mHx/2NvfX6ye7R6/b9vA=; b=qalTZ/2jhbg4FZimMTj2QkGbw9AJ09Ptj63bkKECI//pgQcyV7euikPU6UaqwVT/KJ Mhme/wI1iYA3FCXe1OGIwQS0FFJ9NUPFimr1FTtl06N7n+pPCJQjci2CxWlgLhJTZEcM igunmx++583sOVWMWFW6PD5nBU+Qgp5K16W/qBHbum3lq9NZuaws7ycHDGgmL+nlEU0e igViJBhC7u9J4ZZTJf+isbGxkKmdK8D/4gE9OsUOahtxcOaMLcF2m+y+9NEhpvfoL1Je 63IVrYDl88mpnCAVvGlZWucS5baI3EtuzlVtcHhNbui2FZWoD0ZkVzawo6Z+n+gq8KRI nFnQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EUkxGsFJ; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com. [216.205.24.124]) by mx.google.com with ESMTPS id cx21si11486654edb.82.2020.10.11.16.45.06 for (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Sun, 11 Oct 2020 16:45:06 -0700 (PDT) Received-SPF: pass (google.com: domain of libvir-list-bounces@redhat.com designates 216.205.24.124 as permitted sender) client-ip=216.205.24.124; Authentication-Results: mx.google.com; dkim=pass header.i=@redhat.com header.s=mimecast20190719 header.b=EUkxGsFJ; spf=pass (google.com: domain of libvir-list-bounces@redhat.com designates 216.205.24.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1602459905; 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=fGF7Gyq28AVTZ9ZAoqTPSs4mHx/2NvfX6ye7R6/b9vA=; b=EUkxGsFJJP1CesD85bzjJTW1qambxHqHwSgrtqBqSruJbgo7cq/CTJMygr+KZz2sXyBkMW ZMHv7iSPdxXxcHN0sx3UoQKrAlqhF//QLAyGoia8yUyJoqIs4xKhPTnNi5g0poRbKLUlv4 OtJqY0CbJS6RbjgSmCLjVxxDtWFGFko= 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-115-CQwjK5aoOcGr_Jx1t8TEhQ-1; Sun, 11 Oct 2020 19:45:03 -0400 X-MC-Unique: CQwjK5aoOcGr_Jx1t8TEhQ-1 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 6EC78107ACF5; Sun, 11 Oct 2020 23:44:56 +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 269B31964A; Sun, 11 Oct 2020 23:44: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 4B5FB18077BC; Sun, 11 Oct 2020 23:44:47 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 09BNiigJ001856 for ; Sun, 11 Oct 2020 19:44:44 -0400 Received: by smtp.corp.redhat.com (Postfix) id 8AC105C22D; Sun, 11 Oct 2020 23:44:44 +0000 (UTC) Delivered-To: libvirt-list@redhat.com Received: from colepc.home (ovpn-113-130.rdu2.redhat.com [10.10.113.130]) by smtp.corp.redhat.com (Postfix) with ESMTP id 337FF5C22B; Sun, 11 Oct 2020 23:44:41 +0000 (UTC) From: Cole Robinson To: libvirt-list@redhat.com Subject: [PATCH] qemu: migration: don't open storage driver too early Date: Sun, 11 Oct 2020 19:44:36 -0400 Message-Id: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 X-loop: libvir-list@redhat.com Cc: 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 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 --- src/qemu/qemu_migration.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) -- 2.28.0 Reviewed-by: Michal Privoznik diff --git a/src/qemu/qemu_migration.c b/src/qemu/qemu_migration.c index 2000c86640..99a6b41483 100644 --- a/src/qemu/qemu_migration.c +++ b/src/qemu/qemu_migration.c @@ -169,8 +169,7 @@ qemuMigrationSrcRestoreDomainState(virQEMUDriverPtr driver, virDomainObjPtr vm) static int -qemuMigrationDstPrecreateDisk(virConnectPtr conn, - virDomainDiskDefPtr disk, +qemuMigrationDstPrecreateDisk(virDomainDiskDefPtr disk, unsigned long long capacity) { int ret = -1; @@ -181,6 +180,7 @@ qemuMigrationDstPrecreateDisk(virConnectPtr conn, g_auto(virBuffer) buf = VIR_BUFFER_INITIALIZER; const char *format = NULL; unsigned int flags = 0; + virConnectPtr conn = NULL; VIR_DEBUG("Precreate disk type=%s", virStorageTypeToString(disk->src->type)); @@ -204,6 +204,9 @@ qemuMigrationDstPrecreateDisk(virConnectPtr conn, *volName = '\0'; volName++; + if (!(conn = virGetConnectStorage())) + goto cleanup; + if (!(pool = virStoragePoolLookupByTargetPath(conn, basePath))) goto cleanup; format = virStorageFileFormatTypeToString(disk->src->format); @@ -212,6 +215,9 @@ qemuMigrationDstPrecreateDisk(virConnectPtr conn, break; case VIR_STORAGE_TYPE_VOLUME: + if (!(conn = virGetConnectStorage())) + goto cleanup; + if (!(pool = virStoragePoolLookupByName(conn, disk->src->srcpool->pool))) goto cleanup; format = virStorageFileFormatTypeToString(disk->src->format); @@ -270,6 +276,7 @@ qemuMigrationDstPrecreateDisk(virConnectPtr conn, VIR_FREE(volStr); virObjectUnref(vol); virObjectUnref(pool); + virObjectUnref(conn); return ret; } @@ -304,13 +311,10 @@ qemuMigrationDstPrecreateStorage(virDomainObjPtr vm, { int ret = -1; size_t i = 0; - virConnectPtr conn; if (!nbd || !nbd->ndisks) return 0; - if (!(conn = virGetConnectStorage())) - return -1; for (i = 0; i < nbd->ndisks; i++) { virDomainDiskDefPtr disk; @@ -349,13 +353,12 @@ qemuMigrationDstPrecreateStorage(virDomainObjPtr vm, VIR_DEBUG("Proceeding with disk source %s", NULLSTR(diskSrcPath)); - if (qemuMigrationDstPrecreateDisk(conn, disk, nbd->disks[i].capacity) < 0) + if (qemuMigrationDstPrecreateDisk(disk, nbd->disks[i].capacity) < 0) goto cleanup; } ret = 0; cleanup: - virObjectUnref(conn); return ret; }