From nobody Mon Feb 9 04:15:20 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 205.139.110.61 as permitted sender) client-ip=205.139.110.61; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-1.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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=1594391662; cv=none; d=zohomail.com; s=zohoarc; b=eoWrcUT1YigkEUeu1FdIAFfb7tbwHt+qij++5dXzNuRwIbDpCv+h8OEwcuIKMyE8/09O5Ajujhxx9/IEuiQBDwABiOiE5+lpFeq0/RRCjH6jU1Q+CZg74RhCuhoct5xJaArfpVD0yay8FoiaoFYSUbU2m4R9PuA4iGAEkDwkYtg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1594391662; h=Content-Type:Content-Transfer-Encoding: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; bh=8sHspuyKAoFpfYi1Ekken9iSPzqXko5wufoHjuHFCC4=; b=l8QUYhDvbvRAH9Kja6dkyXFMdvqbnFzqS6cOkt3iZm3A6nnsLoYza0Gx5Iw2bMz5WMMIw8f8916V49mIOVMbIAkRiCn2IF7X7qMHE4CzhzsWX5bvSM2Ry7iUPC7aCRyzjHR/p9CFn1RkVPtDtUvWhIts6EkdYftGxXpjRitjt+g= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 205.139.110.61 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-1.mimecast.com (us-smtp-2.mimecast.com [205.139.110.61]) by mx.zohomail.com with SMTPS id 1594391662914245.34159948986587; Fri, 10 Jul 2020 07:34:22 -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-196-UNkbpBZPMQu_jKs0fPmA-Q-1; Fri, 10 Jul 2020 10:34:18 -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 BA086102C7F7; Fri, 10 Jul 2020 14:34:08 +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 9713B1A7D9; Fri, 10 Jul 2020 14:34:08 +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 660E71809563; Fri, 10 Jul 2020 14:34:08 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.phx2.redhat.com [10.5.11.14]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 06AEXr9s007044 for ; Fri, 10 Jul 2020 10:33:53 -0400 Received: by smtp.corp.redhat.com (Postfix) id 223817880F; Fri, 10 Jul 2020 14:33:53 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.29]) by smtp.corp.redhat.com (Postfix) with ESMTP id 7FB6717D82 for ; Fri, 10 Jul 2020 14:33:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1594391661; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=8sHspuyKAoFpfYi1Ekken9iSPzqXko5wufoHjuHFCC4=; b=XF0rktJR6STVbrp3Oggw2HGYidTyOiJUCyLTtXJLhhGo2Cl5s4uOalGSVnW7Haa9FRQfzI Uc1YVkG+IGqwL226SbGKzZ63wdU7FIfnG2scnZScPyxN0LyzRp9ilfeuijubsxkmoKlWcS JhUKpSzQ1diEfoOWoNRwX7u5GnPCI9o= X-MC-Unique: UNkbpBZPMQu_jKs0fPmA-Q-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 08/18] qemu: domain: Regenerate hostdev source private data Date: Fri, 10 Jul 2020 16:33:29 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.14 X-loop: libvir-list@redhat.com 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 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" When upgrading from a libvirt which didn't format private data of a virStorageSource representing an iSCSI hostdev source, we might need to generate some internal data so that the code still works as if it was present in the status XML. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_domain.c | 54 ++++++++++++++++++- .../disk-secinfo-upgrade-in.xml | 20 +++++++ .../disk-secinfo-upgrade-out.xml | 30 +++++++++++ 3 files changed, 102 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 3141a94136..41e4d5dd0b 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5319,6 +5319,51 @@ qemuDomainVsockDefPostParse(virDomainVsockDefPtr vso= ck) } +/** + * qemuDomainDeviceHostdevDefPostParseRestoreSecAlias: + * + * Re-generate aliases for objects related to the storage source if they + * were not stored in the status XML by an older libvirt. + * + * Note that qemuCaps should be always present for a status XML. + */ +static int +qemuDomainDeviceHostdevDefPostParseRestoreSecAlias(virDomainHostdevDefPtr = hostdev, + virQEMUCapsPtr qemuCaps, + unsigned int parseFlags) +{ + qemuDomainStorageSourcePrivatePtr priv; + virDomainHostdevSubsysSCSIPtr scsisrc =3D &hostdev->source.subsys.u.sc= si; + virDomainHostdevSubsysSCSIiSCSIPtr iscsisrc =3D &scsisrc->u.iscsi; + g_autofree char *authalias =3D NULL; + + if (!(parseFlags & VIR_DOMAIN_DEF_PARSE_STATUS) || + !qemuCaps || + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_OBJECT_SECRET)) + return 0; + + if (hostdev->mode !=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS || + hostdev->source.subsys.type !=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SC= SI || + scsisrc->protocol !=3D VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI= || + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_ISCSI_PASSWORD_SECRET) || + !qemuDomainStorageSourceHasAuth(iscsisrc->src)) + return 0; + + if (!(priv =3D qemuDomainStorageSourcePrivateFetch(iscsisrc->src))) + return -1; + + if (priv->secinfo) + return 0; + + authalias =3D g_strdup_printf("%s-secret0", hostdev->info->alias); + + if (qemuStorageSourcePrivateDataAssignSecinfo(&priv->secinfo, &authali= as) < 0) + return -1; + + return 0; +} + + static int qemuDomainHostdevDefMdevPostParse(virDomainHostdevSubsysMediatedDevPtr mde= vsrc, virQEMUCapsPtr qemuCaps) @@ -5336,10 +5381,15 @@ qemuDomainHostdevDefMdevPostParse(virDomainHostdevS= ubsysMediatedDevPtr mdevsrc, static int qemuDomainHostdevDefPostParse(virDomainHostdevDefPtr hostdev, - virQEMUCapsPtr qemuCaps) + virQEMUCapsPtr qemuCaps, + unsigned int parseFlags) { virDomainHostdevSubsysPtr subsys =3D &hostdev->source.subsys; + if (qemuDomainDeviceHostdevDefPostParseRestoreSecAlias(hostdev, qemuCa= ps, + parseFlags) < 0) + return -1; + if (hostdev->mode =3D=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS && hostdev->source.subsys.type =3D=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_= MDEV && qemuDomainHostdevDefMdevPostParse(&subsys->u.mdev, qemuCaps) < 0) @@ -5414,7 +5464,7 @@ qemuDomainDeviceDefPostParse(virDomainDeviceDefPtr de= v, break; case VIR_DOMAIN_DEVICE_HOSTDEV: - ret =3D qemuDomainHostdevDefPostParse(dev->data.hostdev, qemuCaps); + ret =3D qemuDomainHostdevDefPostParse(dev->data.hostdev, qemuCaps,= parseFlags); break; case VIR_DOMAIN_DEVICE_TPM: diff --git a/tests/qemustatusxml2xmldata/disk-secinfo-upgrade-in.xml b/test= s/qemustatusxml2xmldata/disk-secinfo-upgrade-in.xml index ce55a70637..8023857ffe 100644 --- a/tests/qemustatusxml2xmldata/disk-secinfo-upgrade-in.xml +++ b/tests/qemustatusxml2xmldata/disk-secinfo-upgrade-in.xml @@ -491,6 +491,26 @@
+ + + + + + + + +
+ + + + + + + + + +
+
diff --git a/tests/qemustatusxml2xmldata/disk-secinfo-upgrade-out.xml b/tes= ts/qemustatusxml2xmldata/disk-secinfo-upgrade-out.xml index 5d3287606f..d5534fb0f5 100644 --- a/tests/qemustatusxml2xmldata/disk-secinfo-upgrade-out.xml +++ b/tests/qemustatusxml2xmldata/disk-secinfo-upgrade-out.xml @@ -513,6 +513,36 @@
+ + + + + + + + + + + + + +
+ + + + + + + + + + + + + + +
+
--=20 2.26.2