From nobody Tue Feb 10 03:20:47 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.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 170.10.133.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=1678789257; cv=none; d=zohomail.com; s=zohoarc; b=AGRawFOcVUhXuO4CzGds+c9Q1lByOsV/hjIkqm2J35loTiSDuN0vAPmGaLiRCn4IFFYuOPW46Nt05AzzV+9ZhrvLKbI7ooiGqrcOnzS8HtkMh1AvcHk/O/biWn4ICMWoGg6jcBjyXHs8HY+0o96XhxztQ1zLfxOVE3tKvVYh+QI= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1678789257; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=I26MAsm8rzMJz1lHkjHc691fQx4tAx/gYZGJZoaOyto=; b=dWOzeemmMV9W77UG+Hu9q7PwfChtv+US7QssfwjVNEivhy0EFrzqSfr+X1fSKvijGIdQcg5qB4YVuqVD0cG/yANjZcRlMknRdJ7xGI8v736G7hUWMCMHsGW2TYLd/TpvmfGjn0rTCIkCD+ivM1x0sgBoM9u8csQxCa2Qh9aJraw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by mx.zohomail.com with SMTPS id 167878925747084.09157186357936; Tue, 14 Mar 2023 03:20:57 -0700 (PDT) Received: from mimecast-mx02.redhat.com (mimecast-mx02.redhat.com [66.187.233.88]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-120-b6vGrsMUPOW4Ey1ZwOpJpg-1; Tue, 14 Mar 2023 06:20:54 -0400 Received: from smtp.corp.redhat.com (int-mx04.intmail.prod.int.rdu2.redhat.com [10.11.54.4]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D94DC858F0E; Tue, 14 Mar 2023 10:20:52 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (unknown [10.30.29.100]) by smtp.corp.redhat.com (Postfix) with ESMTP id 82BD6202701E; Tue, 14 Mar 2023 10:20:52 +0000 (UTC) Received: from mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (localhost [IPv6:::1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 4EE6819465A2; Tue, 14 Mar 2023 10:20:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 8DFD51946594 for ; Tue, 14 Mar 2023 10:20:51 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 72881140E95F; Tue, 14 Mar 2023 10:20:51 +0000 (UTC) Received: from localhost.localdomain (unknown [10.43.2.39]) by smtp.corp.redhat.com (Postfix) with ESMTP id 18BC6140EBF4 for ; Tue, 14 Mar 2023 10:20:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1678789256; 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:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=I26MAsm8rzMJz1lHkjHc691fQx4tAx/gYZGJZoaOyto=; b=GIH0GaThfkD73A14Ar0LEdZ/6oZ0pxCRG6XMBlPiHj8XKSrdLTCGp6DA+fyu7MWBefLuT/ y/n1O7IYrMgXzxDh49riirvMwizYiWd82U+ZTfkvA9MfxtRaGPxcxokfKsrIgdKP50hOnQ rlfhgB7SC+hQGeSTvXLuIvjhSdpL2mQ= X-MC-Unique: b6vGrsMUPOW4Ey1ZwOpJpg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Michal Privoznik To: libvir-list@redhat.com Subject: [PATCH] qemu_alias: Fix backcompat console alias generation Date: Tue, 14 Mar 2023 11:20:49 +0100 Message-Id: <5f412e05f4dab43c913214272e91b7261b665822.1678789249.git.mprivozn@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.1 on 10.11.54.7 X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 3.1 on 10.11.54.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1678789257758100001 Content-Type: text/plain; charset="utf-8"; x-default="true" We have this crazy backwards compatibility when it comes to serial and console devices. Basically, in same cases the very first is just an alias to the very first device. This is to be seen at various places: 1) virDomainDefFormatInternalSetRootName() - when generating domain XML, the configuration is basically ignored and corresponding config is formatted, 2) virDomainDefAddConsoleCompat() - which adds a copy of or into virDomainDef in post parse. And when talking to QEMU we need a special handling too, because while is generated on the cmd line, the is not. And in a lot of place we get it right. Except for generating device aliases. On domain startup the 'expected' happens and devices get "serial0" and "console0" aliases, correspondingly. This ends up in the status XML too. But due to aforementioned trick when formatting domain XML, "serial0" ends up in both 'virsh dumpxml' and the status XML. But internally, both devices have different alias. Therefore, detaching the device using fails as qemuDomainDetachDeviceChr() tries to detach "console0". After the daemon is restarted and status XML is parsed, then everything works suddenly. This is because in the status XML both devices have the same alias. Let's generate correct alias from the beginning. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D2156300 Signed-off-by: Michal Privoznik Reviewed-by: Andrea Bolognani --- src/qemu/qemu_alias.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c index a9809797d5..05d25da93d 100644 --- a/src/qemu/qemu_alias.c +++ b/src/qemu/qemu_alias.c @@ -90,6 +90,18 @@ qemuAssignDeviceChrAlias(virDomainDef *def, if (chr->info.alias) return 0; =20 + /* Some crazy backcompat for consoles. Look into + * virDomainDefAddConsoleCompat() for more explanation. */ + if (chr->deviceType =3D=3D VIR_DOMAIN_CHR_DEVICE_TYPE_CONSOLE && + chr->targetType =3D=3D VIR_DOMAIN_CHR_CONSOLE_TARGET_TYPE_SERIAL && + def->os.type =3D=3D VIR_DOMAIN_OSTYPE_HVM && + def->consoles[0] =3D=3D chr && + def->nserials && + def->serials[0]->info.alias) { + chr->info.alias =3D g_strdup(def->serials[0]->info.alias); + return 0; + } + switch ((virDomainChrDeviceType)chr->deviceType) { case VIR_DOMAIN_CHR_DEVICE_TYPE_PARALLEL: prefix =3D "parallel"; --=20 2.39.2