From nobody Thu Sep 19 01:12:52 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=fail(p=none dis=none) header.from=redhat.com Return-Path: Received: from lists.libvirt.org (lists.libvirt.org [8.43.85.245]) by mx.zohomail.com with SMTPS id 1721651117481411.33194631137235; Mon, 22 Jul 2024 05:25:17 -0700 (PDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 508D0C17; Mon, 22 Jul 2024 08:25:15 -0400 (EDT) Received: from lists.libvirt.org (localhost [IPv6:::1]) by lists.libvirt.org (Postfix) with ESMTP id 7B574D3B; Mon, 22 Jul 2024 08:23:48 -0400 (EDT) Received: by lists.libvirt.org (Postfix, from userid 996) id 608CDA3C; Mon, 22 Jul 2024 08:23:43 -0400 (EDT) Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 DA1CB9ED for ; Mon, 22 Jul 2024 08:23:42 -0400 (EDT) Received: from mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-172-mdM7qdnZPg6HuEyHQ7o_oQ-1; Mon, 22 Jul 2024 08:23:41 -0400 Received: from mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-05.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id 42D2E1955F49 for ; Mon, 22 Jul 2024 12:23:40 +0000 (UTC) Received: from maggie.brq.redhat.com (unknown [10.43.3.102]) by mx-prod-int-01.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 694283000188 for ; Mon, 22 Jul 2024 12:23:39 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on lists.libvirt.org X-Spam-Level: X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_INVALID,DKIM_SIGNED, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE autolearn=unavailable autolearn_force=no version=3.4.4 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1721651022; h=from:from: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; bh=YC8g+0aF8AHuR/NzfEg2Cz2EGRWDZko3K782v8n/BKg=; b=e2sniCqbw1yjd1AzVPQyWCQ6IIyLSIfFfuJd4Y0px8zSXCp+7j66M0cmZ6Ysyc1OlWJK0q E8ZqjnIaS9SaQFy/newB3SdkpvRAqgjb+0ev/ceLGGorYTScm4JaEtfwyoaCyH3CLhfw3/ IQxYIeYdxk5WJye16G+EylKQRMoKFoE= X-MC-Unique: mdM7qdnZPg6HuEyHQ7o_oQ-1 From: Michal Privoznik To: devel@lists.libvirt.org Subject: [PATCH 3/5] qemu: Build cmd line for pstore device Date: Mon, 22 Jul 2024 14:23:31 +0200 Message-ID: <3475463b3605ce61a988e9d1044985769144b9e6.1721650895.git.mprivozn@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.4.1 on 10.30.177.4 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Transfer-Encoding: quoted-printable Message-ID-Hash: 5CEXRRLRWBJEL5F6WBYCYJROESHEYAQL X-Message-ID-Hash: 5CEXRRLRWBJEL5F6WBYCYJROESHEYAQL X-MailFrom: mprivozn@redhat.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 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: X-ZohoMail-DKIM: fail (Header signature does not verify) X-ZM-MESSAGEID: 1721651119885116600 Content-Type: text/plain; charset="utf-8"; x-default="true" Nothing special going on here. Resolves: https://issues.redhat.com/browse/RHEL-24746 Signed-off-by: Michal Privoznik --- src/qemu/qemu_alias.c | 10 ++++ src/qemu/qemu_command.c | 51 +++++++++++++++++++ .../pstore-acpi-erst.x86_64-latest.args | 2 + 3 files changed, 63 insertions(+) diff --git a/src/qemu/qemu_alias.c b/src/qemu/qemu_alias.c index 872d940595..3e6bced4a8 100644 --- a/src/qemu/qemu_alias.c +++ b/src/qemu/qemu_alias.c @@ -658,6 +658,14 @@ qemuAssignDeviceCryptoAlias(virDomainDef *def, } =20 =20 +static void +qemuAssignDevicePstoreAlias(virDomainPstoreDef *pstore) +{ + if (!pstore->info.alias) + pstore->info.alias =3D g_strdup("pstore0"); +} + + int qemuAssignDeviceAliases(virDomainDef *def) { @@ -747,6 +755,8 @@ qemuAssignDeviceAliases(virDomainDef *def) for (i =3D 0; i < def->ncryptos; i++) { qemuAssignDeviceCryptoAlias(def, def->cryptos[i]); } + if (def->pstore) + qemuAssignDevicePstoreAlias(def->pstore); =20 return 0; } diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index def124cc27..f15e6bda1e 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -10341,6 +10341,53 @@ qemuBuildCryptoCommandLine(virCommand *cmd, } =20 =20 +static int +qemuBuildPstoreCommandLine(virCommand *cmd, + const virDomainDef *def, + virDomainPstoreDef *pstore, + virQEMUCaps *qemuCaps) +{ + g_autoptr(virJSONValue) devProps =3D NULL; + g_autoptr(virJSONValue) memProps =3D NULL; + g_autofree char *memAlias =3D NULL; + + if (!pstore->info.alias) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("pstore device is missing alias")); + return -1; + } + + memAlias =3D g_strdup_printf("mem%s", pstore->info.alias); + + if (qemuMonitorCreateObjectProps(&memProps, + "memory-backend-file", + memAlias, + "s:mem-path", pstore->path, + "U:size", pstore->size * 1024, + "b:share", true, + NULL) < 0) { + return -1; + } + + if (virJSONValueObjectAdd(&devProps, + "s:driver", "acpi-erst", + "s:id", pstore->info.alias, + "s:memdev", memAlias, + NULL) < 0) { + return -1; + } + + if (qemuBuildDeviceAddressProps(devProps, def, &pstore->info) < 0) + return -1; + + if (qemuBuildObjectCommandlineFromJSON(cmd, memProps, qemuCaps) < 0 || + qemuBuildDeviceCommandlineFromJSON(cmd, devProps, def, qemuCaps) <= 0) + return -1; + + return 0; +} + + static int qemuBuildAsyncTeardownCommandLine(virCommand *cmd, const virDomainDef *def, @@ -10699,6 +10746,10 @@ qemuBuildCommandLine(virDomainObj *vm, if (qemuBuildCryptoCommandLine(cmd, def, qemuCaps) < 0) return NULL; =20 + if (def->pstore && + qemuBuildPstoreCommandLine(cmd, def, def->pstore, qemuCaps) < 0) + return NULL; + if (qemuBuildAsyncTeardownCommandLine(cmd, def, qemuCaps) < 0) return NULL; =20 diff --git a/tests/qemuxmlconfdata/pstore-acpi-erst.x86_64-latest.args b/te= sts/qemuxmlconfdata/pstore-acpi-erst.x86_64-latest.args index d7c4708acb..2e217f6c83 100644 --- a/tests/qemuxmlconfdata/pstore-acpi-erst.x86_64-latest.args +++ b/tests/qemuxmlconfdata/pstore-acpi-erst.x86_64-latest.args @@ -33,4 +33,6 @@ XDG_CONFIG_HOME=3D/var/lib/libvirt/qemu/domain--1-guest/.= config \ -global ICH9-LPC.noreboot=3Doff \ -watchdog-action reset \ -sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ +-object '{"qom-type":"memory-backend-file","id":"mempstore0","mem-path":"/= tmp/guest_acpi_esrt","size":8192,"share":true}' \ +-device '{"driver":"acpi-erst","id":"pstore0","memdev":"mempstore0","bus":= "pci.2","addr":"0x1"}' \ -msg timestamp=3Don --=20 2.44.2