From nobody Thu Nov 21 17:48:02 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) client-ip=8.43.85.245; envelope-from=devel-bounces@lists.libvirt.org; helo=lists.libvirt.org; Authentication-Results: mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass(p=reject dis=none) header.from=lists.libvirt.org ARC-Seal: i=1; a=rsa-sha256; t=1732119262; cv=none; d=zohomail.com; s=zohoarc; b=P5F9wl5tnvQqOTW8Inz77AodND2eTFUgJ9k2on/YeVtUsbCkW9wKnM+wd58ZzufmqbPlrEEZ1piczmBL2dYc4NNN8do5B7ZOkpWzVj00dTctwTUexO91Y11CSyTC9ilmszGdqBMkXY2q99CLXSLV97mrOWki8NvIiMDiBuUQSzQ= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1732119262; h=Content-Transfer-Encoding:Cc:Cc:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Reply-To:Reply-To:References:Subject:Subject:To:To:Message-Id; bh=shtJReE7VZf9ETPkU7zPs2vC0VvaRDji5HnM6cFUrv8=; b=YJaSTo47EGAOwgsiXjx92tVgUi5MwQZLW/5EcTe5eB0QPeMrUDWS4Qipj/2d5h5ZscsOeCWNVjduoXBhX0o7+CnN66dMibzUSzCzZhrSR8m7Eon9h+CM+4nOvvVL11Y1+9sqqKlq/i6rCd3FhU3pZDF5wm36qzNa9yEPOW0auKk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=fail; spf=pass (zohomail.com: domain of lists.libvirt.org designates 8.43.85.245 as permitted sender) smtp.mailfrom=devel-bounces@lists.libvirt.org; dmarc=pass header.from= (p=reject dis=none) Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1732119261997346.27524460726033; Wed, 20 Nov 2024 08:14:21 -0800 (PST) Received: by lists.libvirt.org (Postfix, from userid 996) id D0A2D15C6; Wed, 20 Nov 2024 11:14:20 -0500 (EST) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 3204615F2; Wed, 20 Nov 2024 11:10:05 -0500 (EST) Received: by lists.libvirt.org (Postfix, from userid 996) id 66F161503; Wed, 20 Nov 2024 11:09:57 -0500 (EST) Received: from relay.virtuozzo.com (relay.virtuozzo.com [130.117.225.111]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.libvirt.org (Postfix) with ESMTPS id 7046E1516 for ; Wed, 20 Nov 2024 11:09:44 -0500 (EST) Received: from [130.117.225.1] (helo=vz9-barybin-2.ch-qa.vzint.dev) by relay.virtuozzo.com with esmtp (Exim 4.96) (envelope-from ) id 1tDn0x-0005yc-39; Wed, 20 Nov 2024 16:53:12 +0100 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-3.1 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, MAILING_LIST_MULTI,RCVD_IN_DNSWL_MED,RCVD_IN_VALIDITY_RPBL_BLOCKED, RCVD_IN_VALIDITY_SAFE_BLOCKED,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=virtuozzo.com; s=relay; h=MIME-Version:Message-ID:Date:Subject:From: Content-Type; bh=Gx0t3INsyuvu2soodaLtTieLrxV6i0BbKjgWBnBnOV0=; b=mfQm4t5jyIrk 1BgUZMKBXwZaLZ55ewb+l422ZRkqiidysUNZIYBFPztw6cflFtHeTpPyRIqNUARPxh2f+GjHUeZle niqoVTvol+yRhIptPgnSwCISk/Od9WEf9W1qDvfdF30lPQyyaUOTgV6OORI+q8o/MSmakrm/JVVT+ R4cna6EiMBHScULayjLWyak8eY5c9nSK7EbvRy49kC7xlT21r5bVFWshoHL9LyYl1tVR9kna+ioxe Exh6A7l7XtJldTUekJZ1V40IaxJVhvBJQKfbVIRN0ihviIYgcu6zYyEAIsh0scfqX91Ut6ZAFB4+y fD69Ynu5fEloI7UaKLd+hg==; To: devel@lists.libvirt.org Subject: [PATCH 12/15] qemu: factor out qemuDomainPrepareStorageSource() Date: Wed, 20 Nov 2024 18:48:47 +0300 Message-ID: <20241120155229.1259-13-nikolai.barybin@virtuozzo.com> X-Mailer: git-send-email 2.43.5 In-Reply-To: <20241120155229.1259-1-nikolai.barybin@virtuozzo.com> References: <20241120155229.1259-1-nikolai.barybin@virtuozzo.com> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-ID-Hash: W4BJUUQ34KKMJVN62YTA7IZOKMIZPBAZ X-Message-ID-Hash: W4BJUUQ34KKMJVN62YTA7IZOKMIZPBAZ X-MailFrom: nikolai.barybin@virtuozzo.com X-Mailman-Rule-Misses: dmarc-mitigation; no-senders; approved; emergency; loop; banned-address; member-moderation; header-match-config-1; header-match-config-2; header-match-config-3; header-match-devel.lists.libvirt.org-0; nonmember-moderation; administrivia; implicit-dest; max-recipients; max-size; news-moderation; no-subject; suspicious-header CC: den@openvz.org, Nikolai Barybin X-Mailman-Version: 3.2.2 Precedence: list List-Id: Development discussions about the libvirt library & tools Archived-At: List-Archive: List-Help: List-Post: List-Subscribe: List-Unsubscribe: From: Nikolai Barybin via Devel Reply-To: Nikolai Barybin X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1732119262959116600 Content-Type: text/plain; charset="utf-8" This refactoring will simplify next changes. Signed-off-by: Nikolai Barybin --- src/qemu/qemu_domain.c | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 66ab4baa8b..393c7dcac1 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -6114,6 +6114,32 @@ qemuDomainPrepareStorageSourceConfig(virStorageSourc= e *src, } =20 =20 +static int +qemuDomainPrepareStorageSource(virStorageSource *src, + virDomainObj *vm, + virDomainDiskDef *disk, + virQEMUDriverConfig *cfg) +{ + qemuDomainObjPrivate *priv =3D vm->privateData; + + /* convert detected ISO format to 'raw' as qemu would not understand i= t */ + if (src->format =3D=3D VIR_STORAGE_FILE_ISO) + src->format =3D VIR_STORAGE_FILE_RAW; + + if (qemuDomainValidateStorageSource(src, priv->qemuCaps) < 0) + return -1; + + qemuDomainPrepareStorageSourceConfig(src, cfg); + qemuDomainPrepareDiskSourceData(disk, src); + + if (!qemuDiskBusIsSD(disk->bus) && + qemuDomainPrepareStorageSourceBlockdev(disk, src, priv, cfg) < 0) + return -1; + + return 0; +} + + /** * qemuDomainDetermineDiskChain: * @driver: qemu driver object @@ -6134,7 +6160,6 @@ qemuDomainDetermineDiskChain(virQEMUDriver *driver, g_autoptr(virQEMUDriverConfig) cfg =3D virQEMUDriverGetConfig(driver); virStorageSource *src; /* iterator for the backing chain declared in X= ML */ virStorageSource *n; /* iterator for the backing chain detected from d= isk */ - qemuDomainObjPrivate *priv =3D vm->privateData; uid_t uid; gid_t gid; =20 @@ -6218,18 +6243,7 @@ qemuDomainDetermineDiskChain(virQEMUDriver *driver, return -1; =20 for (n =3D src->backingStore; virStorageSourceIsBacking(n); n =3D n->b= ackingStore) { - /* convert detected ISO format to 'raw' as qemu would not understa= nd it */ - if (n->format =3D=3D VIR_STORAGE_FILE_ISO) - n->format =3D VIR_STORAGE_FILE_RAW; - - if (qemuDomainValidateStorageSource(n, priv->qemuCaps) < 0) - return -1; - - qemuDomainPrepareStorageSourceConfig(n, cfg); - qemuDomainPrepareDiskSourceData(disk, n); - - if (!qemuDiskBusIsSD(disk->bus) && - qemuDomainPrepareStorageSourceBlockdev(disk, n, priv, cfg) < 0) + if (qemuDomainPrepareStorageSource(n, vm, disk, cfg) < 0) return -1; } =20 --=20 2.43.5