From nobody Mon Feb 9 16:53:47 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 207.211.31.81 as permitted sender) client-ip=207.211.31.81; 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 207.211.31.81 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=1599835099; cv=none; d=zohomail.com; s=zohoarc; b=i/NV11CxMj0cv4apAG4n8c8xMjjrMmjn1/4bQiRHNnJgDhXXRob7FK+yoztl56dacOKTFJ4xjRgsDs2Sy0zq5vqlqXq1Wepd+iGu96FlBi+Z5G+zhxALg0/Jusvc696DEZT6RdGZkOhpv2Kxm5VObzRqFg9WJZvglESG6nONa3w= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1599835099; 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=p3+FtCzDJ+iqmkVPowuzyonftenz0vd7jBuW8cORCbw=; b=M3AAxSDVibWI8zc9EmvofpT/Bj3xRRjdjjjJFiurabADd/tSI0+JCra0qIhN2ZLiDekoX0Tr5dXQzfqcT5Q/QDt6jI6OzrPHeriP6hMHh1tdPr6N/L75BOvG+oZEHKjeYt0bB+cibBCiT9rLn6Lk10R9gNAtz0zSIRJMtgFHqmk= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 207.211.31.81 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 [207.211.31.81]) by mx.zohomail.com with SMTPS id 1599835099780822.1628978179377; Fri, 11 Sep 2020 07:38:19 -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-395-zmeOrcHsOVGBiMTnA4x2jg-1; Fri, 11 Sep 2020 10:38:13 -0400 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 mimecast-mx01.redhat.com (Postfix) with ESMTPS id 2282F8030DD; Fri, 11 Sep 2020 14:38:08 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 0396C5C22B; Fri, 11 Sep 2020 14:38: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 C43F79230F; Fri, 11 Sep 2020 14:38:07 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.phx2.redhat.com [10.5.11.15]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 08BEbovf002390 for ; Fri, 11 Sep 2020 10:37:50 -0400 Received: by smtp.corp.redhat.com (Postfix) id E77768FCA1; Fri, 11 Sep 2020 14:37:50 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.92]) by smtp.corp.redhat.com (Postfix) with ESMTP id 5C2CF8FCA5 for ; Fri, 11 Sep 2020 14:37:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1599835097; 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=p3+FtCzDJ+iqmkVPowuzyonftenz0vd7jBuW8cORCbw=; b=R7prsciqQ2hyVq55zsA/9ItL8exjFk2NHZwZoPBWgxZ5fR80QDKA1i37CgCvyLHFdy8GlC b4GPiQwZbvYySO0ODGqKi/Q7nRjf0IZXX3oryG74GAROu9x+ZhTNck6bDuvzYUOH1QszPB cRwPX0VBa50KoXTHIh65sU3hYlKRhpc= X-MC-Unique: zmeOrcHsOVGBiMTnA4x2jg-1 From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH 09/17] qemu: domain: Fill in (i)SCSI backend nodename if it is not present in status XML Date: Fri, 11 Sep 2020 16:37:27 +0200 Message-Id: <3a1fa0ad6460449554b998431d4c96b967c7192c.1599834862.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.15 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.79 on 10.5.11.16 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com X-Mimecast-Spam-Score: 0.001 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) Content-Type: text/plain; charset="utf-8" For upgrade reasons so that we can modify the used nodename we must generate the old version for all status XMLs which don't have it stored explicitly. The change will be required as using the user-provided alias may result in too-long nodenames which will be rejected by qemu. Add code which fills in the appropriate old value and add test cases to validate that it's added and also that existing nodenames are not overwritten. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_domain.c | 55 +++++++++++++++++++++ tests/qemustatusxml2xmldata/modern-in.xml | 1 + tests/qemustatusxml2xmldata/upgrade-in.xml | 1 + tests/qemustatusxml2xmldata/upgrade-out.xml | 12 +++++ 4 files changed, 69 insertions(+) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 0ed132a829..89f2c2c09b 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -5301,6 +5301,57 @@ qemuDomainDeviceHostdevDefPostParseRestoreSecAlias(v= irDomainHostdevDefPtr hostde } +/** + * qemuDomainDeviceHostdevDefPostParseRestoreBackendAlias: + * + * Re-generate backend alias if it wasn't stored in the status XML by an o= lder + * libvirtd. + * + * Note that qemuCaps should be always present for a status XML. + */ +static int +qemuDomainDeviceHostdevDefPostParseRestoreBackendAlias(virDomainHostdevDef= Ptr hostdev, + virQEMUCapsPtr qemu= Caps, + unsigned int parseF= lags) +{ + virDomainHostdevSubsysSCSIPtr scsisrc =3D &hostdev->source.subsys.u.sc= si; + virStorageSourcePtr src; + + if (!(parseFlags & VIR_DOMAIN_DEF_PARSE_STATUS)) + return 0; + + if (!qemuCaps || + hostdev->mode !=3D VIR_DOMAIN_HOSTDEV_MODE_SUBSYS || + hostdev->source.subsys.type !=3D VIR_DOMAIN_HOSTDEV_SUBSYS_TYPE_SC= SI || + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV_HOSTDEV_SCSI)) + return 0; + + switch ((virDomainHostdevSCSIProtocolType) scsisrc->protocol) { + case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_NONE: + if (!scsisrc->u.host.src && + !(scsisrc->u.host.src =3D virStorageSourceNew())) + return -1; + + src =3D scsisrc->u.host.src; + break; + + case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_ISCSI: + src =3D scsisrc->u.iscsi.src; + break; + + case VIR_DOMAIN_HOSTDEV_SCSI_PROTOCOL_TYPE_LAST: + default: + virReportEnumRangeError(virDomainHostdevSCSIProtocolType, scsisrc-= >protocol); + return -1; + } + + if (!src->nodestorage) + src->nodestorage =3D g_strdup_printf("libvirt-%s-backend", hostdev= ->info->alias); + + return 0; +} + + static int qemuDomainHostdevDefMdevPostParse(virDomainHostdevSubsysMediatedDevPtr mde= vsrc, virQEMUCapsPtr qemuCaps) @@ -5327,6 +5378,10 @@ qemuDomainHostdevDefPostParse(virDomainHostdevDefPtr= hostdev, parseFlags) < 0) return -1; + if (qemuDomainDeviceHostdevDefPostParseRestoreBackendAlias(hostdev, qe= muCaps, + 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) diff --git a/tests/qemustatusxml2xmldata/modern-in.xml b/tests/qemustatusxm= l2xmldata/modern-in.xml index 0a3990bd3e..5a5d5b8983 100644 --- a/tests/qemustatusxml2xmldata/modern-in.xml +++ b/tests/qemustatusxml2xmldata/modern-in.xml @@ -234,6 +234,7 @@ + diff --git a/tests/qemustatusxml2xmldata/upgrade-in.xml b/tests/qemustatusx= ml2xmldata/upgrade-in.xml index 1942eacfa4..7fa56429f4 100644 --- a/tests/qemustatusxml2xmldata/upgrade-in.xml +++ b/tests/qemustatusxml2xmldata/upgrade-in.xml @@ -232,6 +232,7 @@ + diff --git a/tests/qemustatusxml2xmldata/upgrade-out.xml b/tests/qemustatus= xml2xmldata/upgrade-out.xml index ee3c1b49b0..962d25ce2e 100644 --- a/tests/qemustatusxml2xmldata/upgrade-out.xml +++ b/tests/qemustatusxml2xmldata/upgrade-out.xml @@ -232,6 +232,7 @@ + @@ -517,6 +518,9 @@ + + + @@ -532,6 +536,9 @@ + + + @@ -547,6 +554,11 @@
+ + + + +
--=20 2.26.2