From nobody Sat May 11 09:24:57 2024 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=1654256934; cv=none; d=zohomail.com; s=zohoarc; b=fOMFiSV8+oJeMWN6jM4dJB9unfdHGOXHkVkrU+7C5LVbdFQjxAX/Kkl23U5o6yCuof/EtgfCWPVp64KziFgS79A9jVsPA6s/WLOQndPlOwxZKs6gmCzKcCPcfWX91jLKRu7x4iwGD93qLZSwevcncfKAQkpbU9ISZp+Pa92wIV4= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654256934; h=Content-Type:Content-Transfer-Encoding:Cc: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=0nKSTeh/7MtatfCTCC6PfGin3rSya4yiNcA5+l8842E=; b=UQcxuGkIa4lGUyeWBIHFkD/Yq/i1Ll0Lz76MiuNRM2tQkrZRN+zfIc8Iqamexri9KLqsU96UrUsyVWzT0HY/cE35QYgS4neeDAfwL8pzmPOEL3GzNUGqk/BZpYgDIhxhR+GKc1QTMpTRJ0Udt6MKnyMGkNSxvKZOSiNSXtOaFR4= 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 1654256934160504.9346622257426; Fri, 3 Jun 2022 04:48:54 -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-190-RcUSYqaKPKSYZkQTQBnIFw-1; Fri, 03 Jun 2022 07:48:52 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 33D02811E76; Fri, 3 Jun 2022 11:48:50 +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 1ED943323E; Fri, 3 Jun 2022 11:48:50 +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 CD7D3194704A; Fri, 3 Jun 2022 11:48:49 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id AC790194704A for ; Fri, 3 Jun 2022 11:48:48 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id A29FC40CFD0B; Fri, 3 Jun 2022 11:48:48 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id F04B540CFD0A; Fri, 3 Jun 2022 11:48:47 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654256933; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=0nKSTeh/7MtatfCTCC6PfGin3rSya4yiNcA5+l8842E=; b=bcKxTzfejdelso/J5UkSTw/9+hKJ5MXrRCcp8Tnx01o0HBKkie4IsxryVaxbbXD7D/yRXS IgULQj92qbzntFnQ0nxgHe3W1vNzSdLcBPtjndg/z/7uStHYmQ66Q98q43wZ4xS7yxQRNO S3ZbGqO9veAuBJS1mU0aJmfE8mINbxk= X-MC-Unique: RcUSYqaKPKSYZkQTQBnIFw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v4 01/13] qemuDomainPrepareStorageSourceBlockdev: Add a variant for custom nodename Date: Fri, 3 Jun 2022 13:48:33 +0200 Message-Id: <8c44e2eddc816b300e05cdd04222970bb05a5e79.1654256672.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 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: , Cc: Rohit Kumar Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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: 1654256935343100001 Content-Type: text/plain; charset="utf-8" Extract the internals of qemuDomainPrepareStorageSourceBlockdev into qemuDomainPrepareStorageSourceBlockdevNodename so that we can reuse it when instantiating the virStorageSource for pflash backing. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_domain.c | 31 +++++++++++++++++++++++-------- src/qemu/qemu_domain.h | 5 +++++ 2 files changed, 28 insertions(+), 8 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 916f85e673..86dbf7cb01 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -10855,15 +10855,14 @@ qemuDomainPrepareDiskSourceLegacy(virDomainDiskDe= f *disk, int -qemuDomainPrepareStorageSourceBlockdev(virDomainDiskDef *disk, - virStorageSource *src, - qemuDomainObjPrivate *priv, - virQEMUDriverConfig *cfg) +qemuDomainPrepareStorageSourceBlockdevNodename(virDomainDiskDef *disk, + virStorageSource *src, + const char *nodenameprefix, + qemuDomainObjPrivate *priv, + virQEMUDriverConfig *cfg) { - src->id =3D qemuDomainStorageIDNew(priv); - - src->nodestorage =3D g_strdup_printf("libvirt-%u-storage", src->id); - src->nodeformat =3D g_strdup_printf("libvirt-%u-format", src->id); + src->nodestorage =3D g_strdup_printf("%s-storage", nodenameprefix); + src->nodeformat =3D g_strdup_printf("%s-format", nodenameprefix); if (qemuBlockStorageSourceNeedsStorageSliceLayer(src)) src->sliceStorage->nodename =3D g_strdup_printf("libvirt-%u-slice-= sto", src->id); @@ -10896,6 +10895,22 @@ qemuDomainPrepareStorageSourceBlockdev(virDomainDi= skDef *disk, } +int +qemuDomainPrepareStorageSourceBlockdev(virDomainDiskDef *disk, + virStorageSource *src, + qemuDomainObjPrivate *priv, + virQEMUDriverConfig *cfg) +{ + g_autofree char *nodenameprefix =3D NULL; + + src->id =3D qemuDomainStorageIDNew(priv); + + nodenameprefix =3D g_strdup_printf("libvirt-%u", src->id); + + return qemuDomainPrepareStorageSourceBlockdevNodename(disk, src, noden= ameprefix, priv, cfg); +} + + static int qemuDomainPrepareDiskSourceBlockdev(virDomainDiskDef *disk, qemuDomainObjPrivate *priv, diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 547d85b5f9..558037204c 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -757,6 +757,11 @@ int qemuDomainStorageSourceAccessAllow(virQEMUDriver *= driver, bool newSource, bool chainTop); +int qemuDomainPrepareStorageSourceBlockdevNodename(virDomainDiskDef *disk, + virStorageSource *src, + const char *nodenamepre= fix, + qemuDomainObjPrivate *p= riv, + virQEMUDriverConfig *cf= g); int qemuDomainPrepareStorageSourceBlockdev(virDomainDiskDef *disk, virStorageSource *src, qemuDomainObjPrivate *priv, --=20 2.35.3 From nobody Sat May 11 09:24:57 2024 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=1654256937; cv=none; d=zohomail.com; s=zohoarc; b=DxuHk9RoxrZUPYvGX+dQGgzYznVyGJR3vXuYiuf5rjbDJdlW4KTjQR0Uh0hWfoo34WLQSj23DSyB1z4gm5Ah658SPT1KggvQK1f0UIrjGuydHliLNO4Py6P+omgZayD8fwYY4rcPZsKMuzbgbPqrpjZNmnLl+o6euNotAbkZclU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654256937; h=Content-Type:Content-Transfer-Encoding:Cc: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=TShfI7HHHmMxi6VEoYoEr/cRpeNdZT5qHGvsy8K6cRs=; b=kGoWW8JhFfzpBViqzfHlgJtYJa4tz5/Fvw6wpbIAz/MqZLPl54e9Q/4at4hwN1LmgclcIDLygeqogmODYtMToI+QfA+CuQuan3DHRwyuf9LbK5p+srLRrexkn329ab34IfrkwUzJnT+QBfacnlAaMeKYS/2ugMqumeUOpKXew2Y= 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 1654256937768191.33418939045146; Fri, 3 Jun 2022 04:48: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-330-K5Huksr6Ot2Q0RGuhkh0dQ-1; Fri, 03 Jun 2022 07:48:52 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id AD048804194; Fri, 3 Jun 2022 11:48:50 +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 94F7E2166B26; Fri, 3 Jun 2022 11:48:50 +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 8137E1947041; Fri, 3 Jun 2022 11:48:50 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id DF2701947052 for ; Fri, 3 Jun 2022 11:48:49 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id B146E40CFD0B; Fri, 3 Jun 2022 11:48:49 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 01A4E40CFD0A; Fri, 3 Jun 2022 11:48:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654256936; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=TShfI7HHHmMxi6VEoYoEr/cRpeNdZT5qHGvsy8K6cRs=; b=bzX3vvH0koj4Ce8p0Jt0F1DPd7SYfLGUet6quZP6fbj/fHPMz8w1LWgXaWwRrDaQvKgMQ9 CbFtfiEHIrA1AxynsOgvo8PjFFA7b4TYUv7Vx3/Qf/wCflZow6LyFKa4l9rkq7OKiX7Eat T0iifmv0Jw4Lc8sHcOB9yeXnL3BWne4= X-MC-Unique: K5Huksr6Ot2Q0RGuhkh0dQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v4 02/13] qemuBuildPflashBlockdevCommandLine: Take virDomainObj instead of private data Date: Fri, 3 Jun 2022 13:48:34 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 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: , Cc: Rohit Kumar Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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: 1654256939345100001 Content-Type: text/plain; charset="utf-8" Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 52e4ef03cd..7dc09fc101 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -10122,8 +10122,10 @@ qemuBuildPflashBlockdevOne(virCommand *cmd, static int qemuBuildPflashBlockdevCommandLine(virCommand *cmd, - qemuDomainObjPrivate *priv) + virDomainObj *vm) { + qemuDomainObjPrivate *priv =3D vm->privateData; + if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV)) return 0; @@ -10504,7 +10506,7 @@ qemuBuildCommandLine(virDomainObj *vm, if (qemuBuildManagedPRCommandLine(cmd, def, priv) < 0) return NULL; - if (qemuBuildPflashBlockdevCommandLine(cmd, priv) < 0) + if (qemuBuildPflashBlockdevCommandLine(cmd, vm) < 0) return NULL; /* QEMU 1.2 and later have a binary flag -enable-fips that must be --=20 2.35.3 From nobody Sat May 11 09:24:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1654256939; cv=none; d=zohomail.com; s=zohoarc; b=JyCURJEz5rf5pxoVjR47/th3rfSfOAAZHPNR5RqYQKOTrBpDByNDlZXBYIaxNXFU78CHjLk22C8MTBLovovefQQZN2BNy4NwSVB+DnQxgYlXrUPL5gfRcPdzOgKUrGVlQs3rjq3WNy9fUutq6s0tT/OncnHnqudb87YqZNBCaqo= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654256939; h=Content-Type:Content-Transfer-Encoding:Cc: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=0vkUx9dwyGRwgKvw0nsoSAwuTXviUAqaPIuAfw1+1p8=; b=evC/cK8DaeAvupsLWIFvscUEgxc6MvROIIePkc3WiJLmXjGnCO32g92R1wED/6uD/CO9nR0O6XwoxajlUqJ4sQLdrGLOj/kAPpr6LMhYa3I+hYX51bdYBoGJ23OAd3ADE1FS5i7HxFUSFU11EbigU6A6J8gduVYhmHbcjElhq2o= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1654256939890224.3625960991492; Fri, 3 Jun 2022 04:48:59 -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-373-IQjRLF2zMIe3Cdo_LIaIiw-1; Fri, 03 Jun 2022 07:48:55 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0DC8480159B; Fri, 3 Jun 2022 11:48:53 +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 ED4201730C; Fri, 3 Jun 2022 11:48: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 D09E31947041; Fri, 3 Jun 2022 11:48:52 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D12411947052 for ; Fri, 3 Jun 2022 11:48:50 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C2D6C40CFD0D; Fri, 3 Jun 2022 11:48:50 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1603840CFD0A; Fri, 3 Jun 2022 11:48:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654256938; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=0vkUx9dwyGRwgKvw0nsoSAwuTXviUAqaPIuAfw1+1p8=; b=T1egfHdssE/JcwQQL9P5ZUWQcax6lQUCkLw3mgD4AJ6/rDqLH/0dFcq9dmOqQtw/UAu2Ak 9LIH67/xDY2sU/MLLyDmhgha7QZEYJw1eiFyDNlq6z9mk2WuMyp8KsY0K34jHZz0NhLUHq 2djCG/occ/HSFoIufhWzYT9YRpm56iU= X-MC-Unique: IQjRLF2zMIe3Cdo_LIaIiw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v4 03/13] conf: Convert def->os.loader->nvram a virStorageSource Date: Fri, 3 Jun 2022 13:48:35 +0200 Message-Id: <4cd687c19e702aad769b54374addd5e7e1d4bd56.1654256672.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 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: , Cc: Rohit Kumar Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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: 1654256941444100001 Content-Type: text/plain; charset="utf-8" From: Rohit Kumar Currently, libvirt allows only local filepaths to specify the location of the 'nvram' image. Changing it to virStorageSource type will allow to support remote storage for nvram. Signed-off-by: Prerna Saxena Signed-off-by: Florian Schmidt Signed-off-by: Rohit Kumar Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 16 +++++++++++++--- src/conf/domain_conf.h | 2 +- src/qemu/qemu_cgroup.c | 3 ++- src/qemu/qemu_command.c | 2 +- src/qemu/qemu_domain.c | 10 +++++++--- src/qemu/qemu_driver.c | 5 +++-- src/qemu/qemu_firmware.c | 18 +++++++++++++----- src/qemu/qemu_namespace.c | 5 +++-- src/qemu/qemu_process.c | 5 +++-- src/security/security_dac.c | 6 ++++-- src/security/security_selinux.c | 6 ++++-- src/security/virt-aa-helper.c | 5 +++-- src/vbox/vbox_common.c | 3 ++- 13 files changed, 59 insertions(+), 27 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5d0d436a40..252e34dd2a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -3576,7 +3576,7 @@ virDomainLoaderDefFree(virDomainLoaderDef *loader) return; g_free(loader->path); - g_free(loader->nvram); + virObjectUnref(loader->nvram); g_free(loader->nvramTemplate); g_free(loader); } @@ -18340,6 +18340,7 @@ virDomainDefParseBootLoaderOptions(virDomainDef *de= f, { xmlNodePtr loader_node =3D virXPathNode("./os/loader[1]", ctxt); const bool fwAutoSelect =3D def->os.firmware !=3D VIR_DOMAIN_OS_DEF_FI= RMWARE_NONE; + g_autofree char *nvramPath =3D NULL; if (!loader_node) return 0; @@ -18351,7 +18352,13 @@ virDomainDefParseBootLoaderOptions(virDomainDef *d= ef, fwAutoSelect) < 0) return -1; - def->os.loader->nvram =3D virXPathString("string(./os/nvram[1])", ctxt= ); + if ((nvramPath =3D virXPathString("string(./os/nvram[1])", ctxt))) { + def->os.loader->nvram =3D virStorageSourceNew(); + def->os.loader->nvram->path =3D g_steal_pointer(&nvramPath); + def->os.loader->nvram->type =3D VIR_STORAGE_TYPE_FILE; + def->os.loader->nvram->format =3D VIR_STORAGE_FILE_RAW; + } + if (!fwAutoSelect) def->os.loader->nvramTemplate =3D virXPathString("string(./os/nvra= m[1]/@template)", ctxt); @@ -27118,7 +27125,10 @@ virDomainLoaderDefFormat(virBuffer *buf, virXMLFormatElementInternal(buf, "loader", &loaderAttrBuf, &loaderChil= dBuf, false, false); virBufferEscapeString(&nvramAttrBuf, " template=3D'%s'", loader->nvram= Template); - virBufferEscapeString(&nvramChildBuf, "%s", loader->nvram); + if (loader->nvram) { + if (loader->nvram->type =3D=3D VIR_STORAGE_TYPE_FILE) + virBufferEscapeString(&nvramChildBuf, "%s", loader->nvram->pat= h); + } virXMLFormatElementInternal(buf, "nvram", &nvramAttrBuf, &nvramChildBu= f, false, false); } diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index e7e0f24443..9ec81067c6 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2253,7 +2253,7 @@ struct _virDomainLoaderDef { virTristateBool readonly; virDomainLoader type; virTristateBool secure; - char *nvram; /* path to non-volatile RAM */ + virStorageSource *nvram; char *nvramTemplate; /* user override of path to master nvram */ }; diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c index aa0c927578..64baed14e6 100644 --- a/src/qemu/qemu_cgroup.c +++ b/src/qemu/qemu_cgroup.c @@ -581,7 +581,8 @@ qemuSetupFirmwareCgroup(virDomainObj *vm) return -1; if (vm->def->os.loader->nvram && - qemuSetupImagePathCgroup(vm, vm->def->os.loader->nvram, false) < 0) + virStorageSourceIsLocalStorage(vm->def->os.loader->nvram) && + qemuSetupImagePathCgroup(vm, vm->def->os.loader->nvram->path, fals= e) < 0) return -1; return 0; diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 7dc09fc101..952336bafc 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -9668,7 +9668,7 @@ qemuBuildDomainLoaderPflashCommandLine(virCommand *cm= d, if (loader->nvram) { virBufferAddLit(&buf, "file=3D"); - virQEMUBuildBufferEscapeComma(&buf, loader->nvram); + virQEMUBuildBufferEscapeComma(&buf, loader->nvram->path); virBufferAsprintf(&buf, ",if=3Dpflash,format=3Draw,unit=3D%d", uni= t); virCommandAddArg(cmd, "-drive"); diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 86dbf7cb01..1ee3cc3922 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -4678,8 +4678,12 @@ qemuDomainDefPostParse(virDomainDef *def, } if (virDomainDefHasOldStyleROUEFI(def) && - !def->os.loader->nvram) - qemuDomainNVRAMPathFormat(cfg, def, &def->os.loader->nvram); + !def->os.loader->nvram) { + def->os.loader->nvram =3D virStorageSourceNew(); + def->os.loader->nvram->type =3D VIR_STORAGE_TYPE_FILE; + def->os.loader->nvram->format =3D VIR_STORAGE_FILE_RAW; + qemuDomainNVRAMPathFormat(cfg, def, &def->os.loader->nvram->path); + } if (qemuDomainDefAddDefaultDevices(driver, def, qemuCaps) < 0) return -1; @@ -11332,7 +11336,7 @@ qemuDomainInitializePflashStorageSource(virDomainOb= j *vm) pflash1 =3D virStorageSourceNew(); pflash1->type =3D VIR_STORAGE_TYPE_FILE; pflash1->format =3D VIR_STORAGE_FILE_RAW; - pflash1->path =3D g_strdup(def->os.loader->nvram); + pflash1->path =3D g_strdup(def->os.loader->nvram->path); pflash1->readonly =3D false; pflash1->nodeformat =3D g_strdup("libvirt-pflash1-format"); pflash1->nodestorage =3D g_strdup("libvirt-pflash1-storage"); diff --git a/src/qemu/qemu_driver.c b/src/qemu/qemu_driver.c index 0c6645ed89..c32e3cc8fe 100644 --- a/src/qemu/qemu_driver.c +++ b/src/qemu/qemu_driver.c @@ -6731,8 +6731,9 @@ qemuDomainUndefineFlags(virDomainPtr dom, } } - if (vm->def->os.loader && vm->def->os.loader->nvram) { - nvram_path =3D g_strdup(vm->def->os.loader->nvram); + if (vm->def->os.loader && vm->def->os.loader->nvram && + virStorageSourceIsLocalStorage(vm->def->os.loader->nvram)) { + nvram_path =3D g_strdup(vm->def->os.loader->nvram->path); } else if (vm->def->os.firmware =3D=3D VIR_DOMAIN_OS_DEF_FIRMWARE_EFI)= { qemuDomainNVRAMPathFormat(cfg, vm->def, &nvram_path); } diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c index 51223faadf..dd4273f73a 100644 --- a/src/qemu/qemu_firmware.c +++ b/src/qemu/qemu_firmware.c @@ -1192,13 +1192,17 @@ qemuFirmwareEnableFeatures(virQEMUDriver *driver, VIR_FREE(def->os.loader->nvramTemplate); def->os.loader->nvramTemplate =3D g_strdup(flash->nvram_template.f= ilename); - if (!def->os.loader->nvram) - qemuDomainNVRAMPathFormat(cfg, def, &def->os.loader->nvram); + if (!def->os.loader->nvram) { + def->os.loader->nvram =3D virStorageSourceNew(); + def->os.loader->nvram->type =3D VIR_STORAGE_TYPE_FILE; + def->os.loader->nvram->format =3D VIR_STORAGE_FILE_RAW; + qemuDomainNVRAMPathFormat(cfg, def, &def->os.loader->nvram->pa= th); + } VIR_DEBUG("decided on firmware '%s' template '%s' NVRAM '%s'", def->os.loader->path, def->os.loader->nvramTemplate, - def->os.loader->nvram); + def->os.loader->nvram->path); break; case QEMU_FIRMWARE_DEVICE_KERNEL: @@ -1364,8 +1368,12 @@ qemuFirmwareFillDomain(virQEMUDriver *driver, * its path in domain XML) but no template for NVRAM was * specified and the varstore doesn't exist ... */ if (!virDomainDefHasOldStyleROUEFI(def) || - def->os.loader->nvramTemplate || - (!reset_nvram && virFileExists(def->os.loader->nvram))) + def->os.loader->nvramTemplate) + return 0; + + if (!reset_nvram && def->os.loader->nvram && + virStorageSourceIsLocalStorage(def->os.loader->nvram) && + virFileExists(def->os.loader->nvram->path)) return 0; /* ... then we want to consult JSON FW descriptors first, diff --git a/src/qemu/qemu_namespace.c b/src/qemu/qemu_namespace.c index 23681b14a4..9e133587b7 100644 --- a/src/qemu/qemu_namespace.c +++ b/src/qemu/qemu_namespace.c @@ -572,8 +572,9 @@ qemuDomainSetupLoader(virDomainObj *vm, case VIR_DOMAIN_LOADER_TYPE_PFLASH: *paths =3D g_slist_prepend(*paths, g_strdup(loader->path)); - if (loader->nvram) - *paths =3D g_slist_prepend(*paths, g_strdup(loader->nvram)= ); + if (loader->nvram && + virStorageSourceIsLocalStorage(loader->nvram)) + *paths =3D g_slist_prepend(*paths, g_strdup(loader->nvram-= >path)); break; case VIR_DOMAIN_LOADER_TYPE_NONE: diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 1593ca7933..dab298085f 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -4400,7 +4400,8 @@ qemuPrepareNVRAM(virQEMUDriver *driver, struct qemuPrepareNVRAMHelperData data; if (!loader || !loader->nvram || - (virFileExists(loader->nvram) && !reset_nvram)) + !virStorageSourceIsLocalStorage(loader->nvram) || + (virFileExists(loader->nvram->path) && !reset_nvram)) return 0; master_nvram_path =3D loader->nvramTemplate; @@ -4432,7 +4433,7 @@ qemuPrepareNVRAM(virQEMUDriver *driver, data.srcFD =3D srcFD; data.srcPath =3D master_nvram_path; - if (virFileRewrite(loader->nvram, + if (virFileRewrite(loader->nvram->path, S_IRUSR | S_IWUSR, cfg->user, cfg->group, qemuPrepareNVRAMHelper, diff --git a/src/security/security_dac.c b/src/security/security_dac.c index 69c462de8b..03661efda1 100644 --- a/src/security/security_dac.c +++ b/src/security/security_dac.c @@ -1975,7 +1975,8 @@ virSecurityDACRestoreAllLabel(virSecurityManager *mgr, } if (def->os.loader && def->os.loader->nvram && - virSecurityDACRestoreFileLabel(mgr, def->os.loader->nvram) < 0) + virStorageSourceIsLocalStorage(def->os.loader->nvram) && + virSecurityDACRestoreFileLabel(mgr, def->os.loader->nvram->path) <= 0) rc =3D -1; if (def->os.kernel && @@ -2186,8 +2187,9 @@ virSecurityDACSetAllLabel(virSecurityManager *mgr, } if (def->os.loader && def->os.loader->nvram && + virStorageSourceIsLocalStorage(def->os.loader->nvram) && virSecurityDACSetOwnership(mgr, NULL, - def->os.loader->nvram, + def->os.loader->nvram->path, user, group, true) < 0) return -1; diff --git a/src/security/security_selinux.c b/src/security/security_selinu= x.c index 6f02baf2ce..e026212b13 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -2806,7 +2806,8 @@ virSecuritySELinuxRestoreAllLabel(virSecurityManager = *mgr, } if (def->os.loader && def->os.loader->nvram && - virSecuritySELinuxRestoreFileLabel(mgr, def->os.loader->nvram, tru= e) < 0) + virStorageSourceIsLocalStorage(def->os.loader->nvram) && + virSecuritySELinuxRestoreFileLabel(mgr, def->os.loader->nvram->pat= h, true) < 0) rc =3D -1; if (def->os.kernel && @@ -3212,8 +3213,9 @@ virSecuritySELinuxSetAllLabel(virSecurityManager *mgr, /* This is different than kernel or initrd. The nvram store * is really a disk, qemu can read and write to it. */ if (def->os.loader && def->os.loader->nvram && + virStorageSourceIsLocalStorage(def->os.loader->nvram) && secdef && secdef->imagelabel && - virSecuritySELinuxSetFilecon(mgr, def->os.loader->nvram, + virSecuritySELinuxSetFilecon(mgr, def->os.loader->nvram->path, secdef->imagelabel, true) < 0) return -1; diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 107f217246..2ddf293c2c 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -1006,8 +1006,9 @@ get_files(vahControl * ctl) if (vah_add_file(&buf, ctl->def->os.loader->path, "rk") !=3D 0) goto cleanup; - if (ctl->def->os.loader && ctl->def->os.loader->nvram) - if (vah_add_file(&buf, ctl->def->os.loader->nvram, "rwk") !=3D 0) + if (ctl->def->os.loader && ctl->def->os.loader->nvram && + virStorageSourceIsLocalStorage(ctl->def->os.loader->nvram)) + if (vah_add_file(&buf, ctl->def->os.loader->nvram->path, "rwk") != =3D 0) goto cleanup; for (i =3D 0; i < ctl->def->ngraphics; i++) { diff --git a/src/vbox/vbox_common.c b/src/vbox/vbox_common.c index 34e555644c..e249980195 100644 --- a/src/vbox/vbox_common.c +++ b/src/vbox/vbox_common.c @@ -992,7 +992,8 @@ vboxSetBootDeviceOrder(virDomainDef *def, struct _vboxD= river *data, VIR_DEBUG("def->os.loader->path %s", def->os.loader->path); VIR_DEBUG("def->os.loader->readonly %d", def->os.loader->readonly); VIR_DEBUG("def->os.loader->type %d", def->os.loader->type); - VIR_DEBUG("def->os.loader->nvram %s", def->os.loader->nvram); + if (def->os.loader->nvram) + VIR_DEBUG("def->os.loader->nvram->path %s", def->os.loader->nv= ram->path); } VIR_DEBUG("def->os.bootloader %s", def->os.bootloader); VIR_DEBUG("def->os.bootloaderArgs %s", def->os.bootloaderArgs); --=20 2.35.3 From nobody Sat May 11 09:24:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1654256943; cv=none; d=zohomail.com; s=zohoarc; b=RJwv4F9WfhBE1SLdztUE9e55TDjyZFOWjUrgRcq0ownJ4ez6FnltjhKJarmgNYkU+5cawwo66K7z5bkOQ9BO6gFCjf86H50di0liBw5Cm8ezWU5buswWSMtcmSq31Kotx7QPZje5WwQ7bcZseWl2spNFctvtg/Ip3QZmgWGArJc= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654256943; h=Content-Type:Content-Transfer-Encoding:Cc: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=GZdDhJMJK94a/8EsbJN0pNTfdb8T5EAx+jL6KjJG75Q=; b=jOGdJQvvroxOpMbN4XkXjG5fwX4SBuX5k1qtnJTyQPDVqh6qTb8L4LwBYVs0bfhLMsb2p6fe9nyA6HmYC/84kkGFBuv1W651E8WEO2hWP5Lm3hImQU31brW9amy3LyLGmQgolJzYwLnZwPD+Hb9y3DWIEz0n3vmOL3/Yso+hUDw= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 165425694349128.893348584580508; Fri, 3 Jun 2022 04:49:03 -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-543-zIvE9CfvNS-1gZOQOIzYuw-1; Fri, 03 Jun 2022 07:48:56 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9EE0D83397C; Fri, 3 Jun 2022 11:48:53 +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 80C6D141510D; Fri, 3 Jun 2022 11:48:53 +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 22B8C194705C; Fri, 3 Jun 2022 11:48:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id CA2AA1947041 for ; Fri, 3 Jun 2022 11:48:51 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id BF62D40CFD0A; Fri, 3 Jun 2022 11:48:51 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2915040CFD0B; Fri, 3 Jun 2022 11:48:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654256942; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=GZdDhJMJK94a/8EsbJN0pNTfdb8T5EAx+jL6KjJG75Q=; b=aHANHA2WR8ZYSqCgvbVXxl4KVktPVrokaNcGy6wCFyA5TPkj0UZDqSUNxQcFLSalbkAgZy /KlhmNgieqh/KgRymwXdgxsohhuTFA9bWYzfp3edRcidQ7psH0pCg9lRxAWNNBEUu/YDiB ktcd/AvsGG1gLw7sCUFgKmtwsPJ1scg= X-MC-Unique: zIvE9CfvNS-1gZOQOIzYuw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v4 04/13] qemu: Use 'def->os.loader->nvram' directly instead of 'priv->pflash1' Date: Fri, 3 Jun 2022 13:48:36 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 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: , Cc: Rohit Kumar Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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: 1654256945379100001 Content-Type: text/plain; charset="utf-8" Since we now have a full virStorageSource for storing the nvram path we don't need the extra dance of transfering the data into the 'pflash1' variable which was an intermediary solution to use -blockdev. For now we keep it functionally identical to the previous impl. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_command.c | 14 +++++++++----- src/qemu/qemu_domain.c | 12 ++---------- src/qemu/qemu_domain.h | 1 - 3 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 952336bafc..c57ff6d281 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -7138,11 +7138,12 @@ qemuBuildMachineCommandLine(virCommand *cmd, } } - if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV)) { + if (virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV) && + virDomainDefHasOldStyleUEFI(def)) { if (priv->pflash0) virBufferAsprintf(&buf, ",pflash0=3D%s", priv->pflash0->nodefo= rmat); - if (priv->pflash1) - virBufferAsprintf(&buf, ",pflash1=3D%s", priv->pflash1->nodefo= rmat); + if (def->os.loader->nvram) + virBufferAsprintf(&buf, ",pflash1=3D%s", def->os.loader->nvram= ->nodeformat); } if (virDomainNumaHasHMAT(def->numa)) @@ -10126,6 +10127,9 @@ qemuBuildPflashBlockdevCommandLine(virCommand *cmd, { qemuDomainObjPrivate *priv =3D vm->privateData; + if (!virDomainDefHasOldStyleUEFI(vm->def)) + return 0; + if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV)) return 0; @@ -10133,8 +10137,8 @@ qemuBuildPflashBlockdevCommandLine(virCommand *cmd, qemuBuildPflashBlockdevOne(cmd, priv->pflash0, priv->qemuCaps) < 0) return -1; - if (priv->pflash1 && - qemuBuildPflashBlockdevOne(cmd, priv->pflash1, priv->qemuCaps) < 0) + if (vm->def->os.loader->nvram && + qemuBuildPflashBlockdevOne(cmd, vm->def->os.loader->nvram, priv->q= emuCaps) < 0) return -1; return 0; diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 1ee3cc3922..9ed2d1fd86 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -1698,7 +1698,6 @@ qemuDomainObjPrivateDataClear(qemuDomainObjPrivate *p= riv) virHashRemoveAll(priv->blockjobs); g_clear_pointer(&priv->pflash0, virObjectUnref); - g_clear_pointer(&priv->pflash1, virObjectUnref); g_clear_pointer(&priv->backup, virDomainBackupDefFree); /* reset node name allocator */ @@ -11314,7 +11313,6 @@ qemuDomainInitializePflashStorageSource(virDomainOb= j *vm) qemuDomainObjPrivate *priv =3D vm->privateData; virDomainDef *def =3D vm->def; g_autoptr(virStorageSource) pflash0 =3D NULL; - g_autoptr(virStorageSource) pflash1 =3D NULL; if (!virQEMUCapsGet(priv->qemuCaps, QEMU_CAPS_BLOCKDEV)) return 0; @@ -11333,17 +11331,11 @@ qemuDomainInitializePflashStorageSource(virDomain= Obj *vm) if (def->os.loader->nvram) { - pflash1 =3D virStorageSourceNew(); - pflash1->type =3D VIR_STORAGE_TYPE_FILE; - pflash1->format =3D VIR_STORAGE_FILE_RAW; - pflash1->path =3D g_strdup(def->os.loader->nvram->path); - pflash1->readonly =3D false; - pflash1->nodeformat =3D g_strdup("libvirt-pflash1-format"); - pflash1->nodestorage =3D g_strdup("libvirt-pflash1-storage"); + def->os.loader->nvram->nodeformat =3D g_strdup("libvirt-pflash1-fo= rmat"); + def->os.loader->nvram->nodestorage =3D g_strdup("libvirt-pflash1-s= torage"); } priv->pflash0 =3D g_steal_pointer(&pflash0); - priv->pflash1 =3D g_steal_pointer(&pflash1); return 0; } diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 558037204c..0c6b3eeffa 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -231,7 +231,6 @@ struct _qemuDomainObjPrivate { * pointers hold the temporary virStorageSources for creating the -blo= ckdev * commandline for pflash drives. */ virStorageSource *pflash0; - virStorageSource *pflash1; /* running backup job */ virDomainBackupDef *backup; --=20 2.35.3 From nobody Sat May 11 09:24:57 2024 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=1654256943; cv=none; d=zohomail.com; s=zohoarc; b=hj5k+ROtFoF84E3Rdyb/xdiunO5RC48k9I2v3QKt3hc+jI7CwckdnMfFQ0kkt9ZuKQovcFy5Uc1YdE7aYFLDNAFf05/cULiao5iyzHRvbWXE3jRtfRimyh/EC3V/ZJfGNv5fND+jjIgaRq9MWu/wczVcBTUhIgb2wyfGHOt+MCU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654256943; h=Content-Type:Content-Transfer-Encoding:Cc: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=sIYqlahWOJ2FGtEEII/5+6vmAgmWRL/ZtQbxTVIQxos=; b=V5+35LyKTm1ibohuLEVhIldu4nBeD4YvKc8TW0C8xSHPxi5ym0fVeLK8dYVphWpIVKXP9wcnMas3TiVgoT1fnbf7ixIA8sDCu1svKFwuvjrdaJA9lV0v93F5aQGQTHlr/0ua9tG6Cs9muVFY90goKdUTGifHdABlupovdYiTuEQ= 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 165425694360830.39202248715742; Fri, 3 Jun 2022 04:49:03 -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-102-ZITRevjsPUO_FVaVC1K00Q-1; Fri, 03 Jun 2022 07:48:56 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 29BA480D3CD; Fri, 3 Jun 2022 11:48:54 +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 07EC81415108; Fri, 3 Jun 2022 11:48:54 +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 84A1F1947068; Fri, 3 Jun 2022 11:48:53 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D2CBF194704A for ; Fri, 3 Jun 2022 11:48:52 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C35FA40CFD0B; Fri, 3 Jun 2022 11:48:52 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 18BF140CFD0A; Fri, 3 Jun 2022 11:48:51 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654256942; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=sIYqlahWOJ2FGtEEII/5+6vmAgmWRL/ZtQbxTVIQxos=; b=FWWEwCZGC+P9JERuLgsO9k5RETJnmCOXFGmFLTb6L56VStz3R6j9/0UYJkW3Z/xu5WzXmC 2UcVMR2pj6I1rLhVrugtzzpU8gNt/JxSvIb8uACCpHpTuS0vbIaABoQ7H8ddYg7wwZVUDN epTjJj1FBYRnhGpQdCIJDIOZKup7QPc= X-MC-Unique: ZITRevjsPUO_FVaVC1K00Q-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v4 05/13] qemu: Properly setup the NVRAM virStorageSource Date: Fri, 3 Jun 2022 13:48:37 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 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: , Cc: Rohit Kumar Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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: 1654256945386100002 Content-Type: text/plain; charset="utf-8" Use the designated helpers for virStorageSource instead using the file-based ones with a check. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_cgroup.c | 3 +-- src/qemu/qemu_namespace.c | 5 +++-- src/security/security_dac.c | 21 +++++++++++---------- src/security/security_selinux.c | 23 +++++++++++------------ src/security/virt-aa-helper.c | 6 +++--- 5 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/qemu/qemu_cgroup.c b/src/qemu/qemu_cgroup.c index 64baed14e6..f189ca2bb6 100644 --- a/src/qemu/qemu_cgroup.c +++ b/src/qemu/qemu_cgroup.c @@ -581,8 +581,7 @@ qemuSetupFirmwareCgroup(virDomainObj *vm) return -1; if (vm->def->os.loader->nvram && - virStorageSourceIsLocalStorage(vm->def->os.loader->nvram) && - qemuSetupImagePathCgroup(vm, vm->def->os.loader->nvram->path, fals= e) < 0) + qemuSetupImageCgroup(vm, vm->def->os.loader->nvram) < 0) return -1; return 0; diff --git a/src/qemu/qemu_namespace.c b/src/qemu/qemu_namespace.c index 9e133587b7..59c6dc52ac 100644 --- a/src/qemu/qemu_namespace.c +++ b/src/qemu/qemu_namespace.c @@ -573,8 +573,9 @@ qemuDomainSetupLoader(virDomainObj *vm, *paths =3D g_slist_prepend(*paths, g_strdup(loader->path)); if (loader->nvram && - virStorageSourceIsLocalStorage(loader->nvram)) - *paths =3D g_slist_prepend(*paths, g_strdup(loader->nvram-= >path)); + qemuDomainSetupDisk(loader->nvram, paths) < 0) + return -1; + break; case VIR_DOMAIN_LOADER_TYPE_NONE: diff --git a/src/security/security_dac.c b/src/security/security_dac.c index 03661efda1..bb89e466e1 100644 --- a/src/security/security_dac.c +++ b/src/security/security_dac.c @@ -1974,10 +1974,11 @@ virSecurityDACRestoreAllLabel(virSecurityManager *m= gr, rc =3D -1; } - if (def->os.loader && def->os.loader->nvram && - virStorageSourceIsLocalStorage(def->os.loader->nvram) && - virSecurityDACRestoreFileLabel(mgr, def->os.loader->nvram->path) <= 0) - rc =3D -1; + if (def->os.loader && def->os.loader->nvram) { + if (virSecurityDACRestoreImageLabelInt(mgr, def, def->os.loader->n= vram, + migrated) < 0) + rc =3D -1; + } if (def->os.kernel && virSecurityDACRestoreFileLabel(mgr, def->os.kernel) < 0) @@ -2186,12 +2187,12 @@ virSecurityDACSetAllLabel(virSecurityManager *mgr, return -1; } - if (def->os.loader && def->os.loader->nvram && - virStorageSourceIsLocalStorage(def->os.loader->nvram) && - virSecurityDACSetOwnership(mgr, NULL, - def->os.loader->nvram->path, - user, group, true) < 0) - return -1; + if (def->os.loader && def->os.loader->nvram) { + if (virSecurityDACSetImageLabel(mgr, def, def->os.loader->nvram, + VIR_SECURITY_DOMAIN_IMAGE_LABEL_BA= CKING_CHAIN | + VIR_SECURITY_DOMAIN_IMAGE_PARENT_C= HAIN_TOP) < 0) + return -1; + } if (def->os.kernel && virSecurityDACSetOwnership(mgr, NULL, diff --git a/src/security/security_selinux.c b/src/security/security_selinu= x.c index e026212b13..6a9d8e7e59 100644 --- a/src/security/security_selinux.c +++ b/src/security/security_selinux.c @@ -2805,10 +2805,11 @@ virSecuritySELinuxRestoreAllLabel(virSecurityManage= r *mgr, rc =3D -1; } - if (def->os.loader && def->os.loader->nvram && - virStorageSourceIsLocalStorage(def->os.loader->nvram) && - virSecuritySELinuxRestoreFileLabel(mgr, def->os.loader->nvram->pat= h, true) < 0) - rc =3D -1; + if (def->os.loader && def->os.loader->nvram) { + if (virSecuritySELinuxRestoreImageLabelInt(mgr, def, def->os.loade= r->nvram, + migrated) < 0) + rc =3D -1; + } if (def->os.kernel && virSecuritySELinuxRestoreFileLabel(mgr, def->os.kernel, true) < 0) @@ -3210,14 +3211,12 @@ virSecuritySELinuxSetAllLabel(virSecurityManager *m= gr, return -1; } - /* This is different than kernel or initrd. The nvram store - * is really a disk, qemu can read and write to it. */ - if (def->os.loader && def->os.loader->nvram && - virStorageSourceIsLocalStorage(def->os.loader->nvram) && - secdef && secdef->imagelabel && - virSecuritySELinuxSetFilecon(mgr, def->os.loader->nvram->path, - secdef->imagelabel, true) < 0) - return -1; + if (def->os.loader && def->os.loader->nvram) { + if (virSecuritySELinuxSetImageLabel(mgr, def, def->os.loader->nvra= m, + VIR_SECURITY_DOMAIN_IMAGE_LABE= L_BACKING_CHAIN | + VIR_SECURITY_DOMAIN_IMAGE_PARE= NT_CHAIN_TOP) < 0) + return -1; + } if (def->os.kernel && virSecuritySELinuxSetFilecon(mgr, def->os.kernel, diff --git a/src/security/virt-aa-helper.c b/src/security/virt-aa-helper.c index 2ddf293c2c..d86b0f1cc2 100644 --- a/src/security/virt-aa-helper.c +++ b/src/security/virt-aa-helper.c @@ -1006,10 +1006,10 @@ get_files(vahControl * ctl) if (vah_add_file(&buf, ctl->def->os.loader->path, "rk") !=3D 0) goto cleanup; - if (ctl->def->os.loader && ctl->def->os.loader->nvram && - virStorageSourceIsLocalStorage(ctl->def->os.loader->nvram)) - if (vah_add_file(&buf, ctl->def->os.loader->nvram->path, "rwk") != =3D 0) + if (ctl->def->os.loader && ctl->def->os.loader->nvram) { + if (storage_source_add_files(disk->src, &buf, 0) < 0) goto cleanup; + } for (i =3D 0; i < ctl->def->ngraphics; i++) { virDomainGraphicsDef *graphics =3D ctl->def->graphics[i]; --=20 2.35.3 From nobody Sat May 11 09:24:57 2024 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=1654256947; cv=none; d=zohomail.com; s=zohoarc; b=MbVNDQ4UUIQEKw+Z+z6G/QwLML+ODrNLp9hTCCN7wJ2TRk4JxYoeEwdDFwnL+1dVtJ9PDKU1qYWuKzKBaCelUa8BC1hNqXW+AW24bEcgMHLT4jb5566Dm0K6B6uHTY8266+wXNPIJwYA+0BUIZrWli79o/+k+2OPBUIHjdFzpVY= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654256947; h=Content-Type:Content-Transfer-Encoding:Cc: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=r/y6PR73dG0vD2swXL1iV3WXN620YPspT7sImcfCbOA=; b=RnZ+MsgKGcMkjOi4GOrD07+FjDsiWEsQeg+N4rqW0LidbCcHgjRxdE6Esuj/z9NfQ8TvqUBFPB5hTebIQlz9wMVqTEWab1afQ/+K/gG9ineIFLNkJwCGfo4KwWAOUP16C7GToUHJbGRieiYAF2I+IwMj/1RSlhPxblLJYlGVpQo= 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 1654256947327749.6953538132017; Fri, 3 Jun 2022 04:49:07 -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-148-S0JGohNWOlmEcheafMMIHg-1; Fri, 03 Jun 2022 07:48:57 -0400 Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.rdu2.redhat.com [10.11.54.7]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id D0DE78041A8; Fri, 3 Jun 2022 11:48:54 +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 864FA1415102; Fri, 3 Jun 2022 11:48:54 +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 4E07F194704D; Fri, 3 Jun 2022 11:48:54 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D80AD1947062 for ; Fri, 3 Jun 2022 11:48:53 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id BD6CD40CFD0B; Fri, 3 Jun 2022 11:48:53 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1D31840CFD0A; Fri, 3 Jun 2022 11:48:52 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654256945; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=r/y6PR73dG0vD2swXL1iV3WXN620YPspT7sImcfCbOA=; b=GcKapWtffmnlIfdOPhMe6nVfMDHXomZtsQeHps3Hu2uCvsFWlqhYDinzYlleo2E/C9DMMq zizR5CupSg5v1U84UlVn2GFC2XAV8Xa1pqJkIfWprDLwqh3GVkgoQT9s1Ne51EGAf09bEV FOOIoXhpztuUm6A8XquTlWn8WrT0owA= X-MC-Unique: S0JGohNWOlmEcheafMMIHg-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v4 06/13] qemuProcessReconnect: Don't re-instantiate pflash storage source Date: Fri, 3 Jun 2022 13:48:38 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 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: , Cc: Rohit Kumar Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.7 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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: 1654256949378100001 Content-Type: text/plain; charset="utf-8" We don't really use it besides when starting up the VM so when reconnecting this step is totally pointless. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_process.c | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index dab298085f..3334c7d536 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -8730,10 +8730,6 @@ qemuProcessReconnect(void *opaque) if (qemuDomainPerfRestart(obj) < 0) goto error; - /* recreate the pflash storage sources */ - if (qemuDomainInitializePflashStorageSource(obj) < 0) - goto error; - for (i =3D 0; i < obj->def->ndisks; i++) { virDomainDiskDef *disk =3D obj->def->disks[i]; --=20 2.35.3 From nobody Sat May 11 09:24:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1654257063; cv=none; d=zohomail.com; s=zohoarc; b=HT7+qCBOq6UUE0u6NhfIqpckvQ+GhOEk8huqi1g+7BsuE73QHqH+juZtl5ymydNS+Xq74pbzg8wVF6R5Nf0Jg5zMJRzCbS2MEeKXibHkjYQF5PCDvXqDhF1t+bFUMiq5I0235FIjWa8D2kw8CWZe4YjODRW+jt2GcGnwwduKbUg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654257063; h=Content-Type:Content-Transfer-Encoding:Cc: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=xzyObvpZRKq0lVmDaBjCpMy7yHC/QwxtiwItiTBTS88=; b=BRfKI4V91B9brjTz9m6cSAnSsQQntdaZSeVgTAKiZLGd+nit/5pkiU/uO2XLtzeTuLcS8PLOfaZxPam7uy161nASYlglJyxz9Q2j8LBwGyGwCNmlUvdQDcAs5ndf2bLTzQfnswySA3OhS4+0zHxTquJQsCe3VfVmejSgYZQLGbI= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1654257063575307.145053513305; Fri, 3 Jun 2022 04:51:03 -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-65-shHXd6MRNc601UHcKDiKGQ-1; Fri, 03 Jun 2022 07:48:58 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 0457885A5BC; Fri, 3 Jun 2022 11:48:56 +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 E55CD492C3B; Fri, 3 Jun 2022 11:48:55 +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 9C1B61947041; Fri, 3 Jun 2022 11:48:55 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E7A491947040 for ; Fri, 3 Jun 2022 11:48:54 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C9F55404754C; Fri, 3 Jun 2022 11:48:54 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 226D440CFD0A; Fri, 3 Jun 2022 11:48:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654257062; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=xzyObvpZRKq0lVmDaBjCpMy7yHC/QwxtiwItiTBTS88=; b=PLmARxKKy/AzC0Ax8RmRVVTU5E6ZmmySse8IKl48yWAsUyhwRLYSNlz6OB2FkeHmT4hcnv hkSFKhIApc/kwz5thqrvKKLttrhIlEE8nlx9KR83WUiEbf2LgxdliFz7f+wmf2e0JLRtmB zysi5bxR2lfCTr0h9Ackq+dCgneuAxM= X-MC-Unique: shHXd6MRNc601UHcKDiKGQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v4 07/13] qemuDomainInitializePflashStorageSource: Properly and fully initialize nvram source Date: Fri, 3 Jun 2022 13:48:39 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 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: , Cc: Rohit Kumar Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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: 1654257064265100001 Content-Type: text/plain; charset="utf-8" Setup all fields for use with -blockdev. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_domain.c | 11 ++++++++--- src/qemu/qemu_domain.h | 3 ++- src/qemu/qemu_process.c | 2 +- 3 files changed, 11 insertions(+), 5 deletions(-) diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 9ed2d1fd86..2f91bdf316 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -11308,7 +11308,8 @@ qemuDomainSupportsCheckpointsBlockjobs(virDomainObj= *vm) * 'libvirt-pflash1-format' for pflash1. */ int -qemuDomainInitializePflashStorageSource(virDomainObj *vm) +qemuDomainInitializePflashStorageSource(virDomainObj *vm, + virQEMUDriverConfig *cfg) { qemuDomainObjPrivate *priv =3D vm->privateData; virDomainDef *def =3D vm->def; @@ -11331,8 +11332,12 @@ qemuDomainInitializePflashStorageSource(virDomainO= bj *vm) if (def->os.loader->nvram) { - def->os.loader->nvram->nodeformat =3D g_strdup("libvirt-pflash1-fo= rmat"); - def->os.loader->nvram->nodestorage =3D g_strdup("libvirt-pflash1-s= torage"); + if (qemuDomainPrepareStorageSourceBlockdevNodename(NULL, + def->os.loader-= >nvram, + "libvirt-pflash= 1", + priv, + cfg) < 0) + return -1; } priv->pflash0 =3D g_steal_pointer(&pflash0); diff --git a/src/qemu/qemu_domain.h b/src/qemu/qemu_domain.h index 0c6b3eeffa..36325259cc 100644 --- a/src/qemu/qemu_domain.h +++ b/src/qemu/qemu_domain.h @@ -1047,7 +1047,8 @@ int qemuDomainMakeCPUMigratable(virCPUDef *cpu); int -qemuDomainInitializePflashStorageSource(virDomainObj *vm); +qemuDomainInitializePflashStorageSource(virDomainObj *vm, + virQEMUDriverConfig *cfg); bool qemuDomainDiskBlockJobIsSupported(virDomainObj *vm, diff --git a/src/qemu/qemu_process.c b/src/qemu/qemu_process.c index 3334c7d536..09409b90b7 100644 --- a/src/qemu/qemu_process.c +++ b/src/qemu/qemu_process.c @@ -6493,7 +6493,7 @@ qemuProcessPrepareDomain(virQEMUDriver *driver, VIR_DEBUG("Prepare bios/uefi paths"); if (qemuFirmwareFillDomain(driver, vm->def, flags) < 0) return -1; - if (qemuDomainInitializePflashStorageSource(vm) < 0) + if (qemuDomainInitializePflashStorageSource(vm, cfg) < 0) return -1; VIR_DEBUG("Preparing external devices"); --=20 2.35.3 From nobody Sat May 11 09:24:57 2024 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=1654257015; cv=none; d=zohomail.com; s=zohoarc; b=M77ZtlNsnjgk8K+zCUkrjgoQI6uoRcpnR7nf1DreZzy1NXZ3oxClyizOs7VFyqq71fB0DDiXi1pe6UxJ+BlfJP3GFe8HW8sIdVESybAg1+8kWY/ROScVN4cdzjKHTtMTrBkhgAk9U0LhORw5x6w4Gv0NlmOWA6y9+DSVMWU8TUg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654257015; h=Content-Type:Content-Transfer-Encoding:Cc: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=UWtu+8Oy865czkD0j6BC9t6qJmiEQtiFZTQD5rsMCVI=; b=gJNMyMLxUDnK0WuexLhUTmmWvFfJHc0Fd1d7my6y8gMyHm/5rzXZrfsc7mmnjW/rq1MYWrsEZBh88iVqlzIloCyTG4nZp0CfDE9UP813a5PkPHC1MgNs0eZr6c7hB43RX3GWCVKPB6awk27TLMP3u/+yCEBPCYxRkiF6QiVr4Hs= 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 1654257015359960.7024509462185; Fri, 3 Jun 2022 04:50:15 -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-455-OQa3g8FdOROh8gudmhreYQ-1; Fri, 03 Jun 2022 07:48:59 -0400 Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.rdu2.redhat.com [10.11.54.6]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 6E24418A6637; Fri, 3 Jun 2022 11:48:57 +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 289DF2166B2D; Fri, 3 Jun 2022 11:48:57 +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 E8264194704A; Fri, 3 Jun 2022 11:48:56 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id D929F1947057 for ; Fri, 3 Jun 2022 11:48:55 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id C8121404754D; Fri, 3 Jun 2022 11:48:55 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 1F75740CF8E7; Fri, 3 Jun 2022 11:48:54 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654257014; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=UWtu+8Oy865czkD0j6BC9t6qJmiEQtiFZTQD5rsMCVI=; b=c1i2s6LpuxqEjKB3n+lHp2mYrLG5wg99SCz+eUXvaWfEQ7km5159dtNk+x6rtAdw+9OmLn xnvCRYJ87rhEi6O7h40UnKd0plF4WNXQ1F0BNK0ZhqOIRmuFsEs0nO3qqxrVJr6tEkMC79 Xu/LiBQEqhoXkiEKIjjewNoa3zpI4vE= X-MC-Unique: OQa3g8FdOROh8gudmhreYQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v4 08/13] qemu: validate: Reject virStorageSource features we don't want to support with nvram Date: Fri, 3 Jun 2022 13:48:40 +0200 Message-Id: <8a6139153507085f57cf50f74ab71b627170a756.1654256672.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 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: , Cc: Rohit Kumar Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.6 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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: 1654257015811100001 Content-Type: text/plain; charset="utf-8" From: Rohit Kumar Signed-off-by: Prerna Saxena Signed-off-by: Florian Schmidt Signed-off-by: Rohit Kumar Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_validate.c | 108 ++++++++++++++++++++++++++++++--------- 1 file changed, 84 insertions(+), 24 deletions(-) diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 9b6245e6d7..48b7d08684 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -568,35 +568,95 @@ qemuValidateDomainDefPM(const virDomainDef *def, static int -qemuValidateDomainDefBoot(const virDomainDef *def) +qemuValidateDomainDefNvram(const virDomainDef *def, + virQEMUCaps *qemuCaps) { - if (def->os.loader && - def->os.loader->secure =3D=3D VIR_TRISTATE_BOOL_YES) { - /* These are the QEMU implementation limitations. But we - * have to live with them for now. */ + virStorageSource *src =3D def->os.loader->nvram; - if (!qemuDomainIsQ35(def)) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Secure boot is supported with q35 machine ty= pes only")); - return -1; - } + if (!src) + return 0; - /* Now, technically it is possible to have secure boot on - * 32bits too, but that would require some -cpu xxx magic - * too. Not worth it unless we are explicitly asked. */ - if (def->os.arch !=3D VIR_ARCH_X86_64) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Secure boot is supported for x86_64 architec= ture only")); - return -1; + switch (src->type) { + case VIR_STORAGE_TYPE_FILE: + case VIR_STORAGE_TYPE_BLOCK: + case VIR_STORAGE_TYPE_NETWORK: + break; + + case VIR_STORAGE_TYPE_DIR: + case VIR_STORAGE_TYPE_VOLUME: + case VIR_STORAGE_TYPE_NVME: + case VIR_STORAGE_TYPE_VHOST_USER: + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unsupported nvram disk type '%s'"), + virStorageTypeToString(src->type)); + return -1; + + case VIR_STORAGE_TYPE_NONE: + case VIR_STORAGE_TYPE_LAST: + virReportEnumRangeError(virStorageType, src->type); + return -1; + } + + if (src->sliceStorage) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("slices are not supported with NVRAM")); + return -1; + } + + if (src->pr) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("persistent reservations are not supported with = NVRAM")); + return -1; + } + + if (src->backingStore) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("backingStore is not supported with NVRAM")); + return -1; + } + + if (qemuDomainValidateStorageSource(src, qemuCaps, false) < 0) + return -1; + + return 0; +} + + +static int +qemuValidateDomainDefBoot(const virDomainDef *def, + virQEMUCaps *qemuCaps) +{ + if (def->os.loader) { + if (def->os.loader->secure =3D=3D VIR_TRISTATE_BOOL_YES) { + /* These are the QEMU implementation limitations. But we + * have to live with them for now. */ + + if (!qemuDomainIsQ35(def)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Secure boot is supported with q35 machin= e types only")); + return -1; + } + + /* Now, technically it is possible to have secure boot on + * 32bits too, but that would require some -cpu xxx magic + * too. Not worth it unless we are explicitly asked. */ + if (def->os.arch !=3D VIR_ARCH_X86_64) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Secure boot is supported for x86_64 arch= itecture only")); + return -1; + } + + /* SMM will be enabled by qemuFirmwareFillDomain() if needed. = */ + if (def->os.firmware =3D=3D VIR_DOMAIN_OS_DEF_FIRMWARE_NONE && + def->features[VIR_DOMAIN_FEATURE_SMM] !=3D VIR_TRISTATE_SW= ITCH_ON) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("Secure boot requires SMM feature enabled= ")); + return -1; + } } - /* SMM will be enabled by qemuFirmwareFillDomain() if needed. */ - if (def->os.firmware =3D=3D VIR_DOMAIN_OS_DEF_FIRMWARE_NONE && - def->features[VIR_DOMAIN_FEATURE_SMM] !=3D VIR_TRISTATE_SWITCH= _ON) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", - _("Secure boot requires SMM feature enabled")); + if (qemuValidateDomainDefNvram(def, qemuCaps) < 0) return -1; - } } return 0; @@ -1174,7 +1234,7 @@ qemuValidateDomainDef(const virDomainDef *def, if (qemuValidateDomainDefPM(def, qemuCaps) < 0) return -1; - if (qemuValidateDomainDefBoot(def) < 0) + if (qemuValidateDomainDefBoot(def, qemuCaps) < 0) return -1; if (qemuValidateDomainVCpuTopology(def, qemuCaps) < 0) --=20 2.35.3 From nobody Sat May 11 09:24:57 2024 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=1654257006; cv=none; d=zohomail.com; s=zohoarc; b=WrNlMhh84FqdaujngUDJoqqgVZtE1p6me2iQCqORHNGTqgvQcCmZv0dm5VIDTdPaW427R/uILXUVIcY4xYmvUo7BjbIJaqqLakfUOrSXp+FSdWSBwzeX4IwKLx8+F4asqGUNZFct2Q+kmDxsGUUVVqVzRw0uHxjzn8IYJkrpphE= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654257006; h=Content-Type:Content-Transfer-Encoding:Cc: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=2w0HeCY56UTTFdJ4NwKcoDU6M3CT/ZImakR82muBFcI=; b=keTs2Wn7MCm+VIKLWmZE47rvcLWr5c5eH9f6IO5OhZelaDAffIHR1Gq9moC5nHnpafycdIFXckO0E4E8P+WOq7gNNHQtIAvFOkiEWhQBfqKTMpWkeVdUk9HVcnOWZEJ9pYh8WJny1yNg+C02qjG6+u3NiQ+O4X8FWgnIsnpqFTo= 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 1654257006922309.2248208833148; Fri, 3 Jun 2022 04:50:06 -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-466--B1odWgwO_yaHmj-ty8b0A-1; Fri, 03 Jun 2022 07:49:01 -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 14AD8101A54E; Fri, 3 Jun 2022 11:48:59 +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 017662026D64; Fri, 3 Jun 2022 11:48:59 +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 CAEAF1947041; Fri, 3 Jun 2022 11:48:58 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id E5AAB1947040 for ; Fri, 3 Jun 2022 11:48:56 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id CA32C404754C; Fri, 3 Jun 2022 11:48:56 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 21E6940CF8E7; Fri, 3 Jun 2022 11:48:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654257005; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=2w0HeCY56UTTFdJ4NwKcoDU6M3CT/ZImakR82muBFcI=; b=UNDTynOSYIkHth+WxyFz5ae4jJ/DCzfr//ULVk+61Zyl9TFhmxESk4gnxl80F6jX1DHFrL K8Uy0zVbC4FfWZVEKQXyt6wzU+pK4+jqUHFIMThL+ATVNNEoAfLYEU41b3mb+YXy+2HTFg +pxyWElu0KudznFXC6/aL0GZ94bXzLA= X-MC-Unique: -B1odWgwO_yaHmj-ty8b0A-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v4 09/13] qemuFirmwareFillDomain: Don't fill in firmware for network backed nvram Date: Fri, 3 Jun 2022 13:48:41 +0200 Message-Id: <97c6d4edadd83e7d8b38b6bea257b875a1de5b17.1654256672.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 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: , Cc: Rohit Kumar Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.78 on 10.11.54.4 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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: 1654257007773100001 Content-Type: text/plain; charset="utf-8" Prepare for network backed nvram by refusing the reset of nvram on boot and don't check whether it exists. We will not support filling it from a template. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_firmware.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/src/qemu/qemu_firmware.c b/src/qemu/qemu_firmware.c index dd4273f73a..a219978962 100644 --- a/src/qemu/qemu_firmware.c +++ b/src/qemu/qemu_firmware.c @@ -1371,10 +1371,22 @@ qemuFirmwareFillDomain(virQEMUDriver *driver, def->os.loader->nvramTemplate) return 0; - if (!reset_nvram && def->os.loader->nvram && - virStorageSourceIsLocalStorage(def->os.loader->nvram) && - virFileExists(def->os.loader->nvram->path)) - return 0; + if (def->os.loader->nvram) { + if (!virStorageSourceIsLocalStorage(def->os.loader->nvram)) { + if (reset_nvram) { + virReportError(VIR_ERR_OPERATION_UNSUPPORTED, "%s", + _("resetting of nvram is not supported = with network backed nvram")); + return -1; + } + + /* we don't scrutinize whether NVRAM image accessed via ne= twork + * is present */ + return 0; + } + + if (!reset_nvram && virFileExists(def->os.loader->nvram->path)) + return 0; + } /* ... then we want to consult JSON FW descriptors first, * but we don't want to fail if we haven't found a match. */ --=20 2.35.3 From nobody Sat May 11 09:24:57 2024 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=1654256947; cv=none; d=zohomail.com; s=zohoarc; b=aVQ4CzVHsNgVCxLIRSJD/I315BcndGxZaFc9YSZZ4F+JMDwpGOOuxLTC8iLqaDpdSQu9DphaFyCkVbTJxBzWm8UI9ofLvaDNW4UPlUk2BB/vdAyQTiaKLuAxf4SRkMsNb1TaQ7P/DekPXj1lvmiST3tdLRVL7Xgfm+t3UTNX7K8= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654256947; h=Content-Type:Content-Transfer-Encoding:Cc: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=KY/5ZMci/AV6BUScFtS3eEbB74q4JO6UR5o2itt7+/8=; b=ZI0QbfZgL7793Dq9QnrRoB2AdX7LRMkmNt/0LXClzezkoxrpvg1hg39TAN1EkOxYQ5UEtNr6H4rvTTBkLWMGlMmkygrzYX2zcoZ1L1SUGKy37QfJV651wliHEvGu2YUlOfHCYizN+Dn4ATYPQezZkwwEiO9xcEz/ol2muGBM2Jo= 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 165425694744245.84495950000132; Fri, 3 Jun 2022 04:49:07 -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-631-bDEF2adONnm_T8YHlxJfxQ-1; Fri, 03 Jun 2022 07:49:02 -0400 Received: from smtp.corp.redhat.com (int-mx09.intmail.prod.int.rdu2.redhat.com [10.11.54.9]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C16F6100BACB; Fri, 3 Jun 2022 11:48:59 +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 7B505492CA3; Fri, 3 Jun 2022 11:48:59 +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 27CF5194705E; Fri, 3 Jun 2022 11:48:59 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 0BFF81947040 for ; Fri, 3 Jun 2022 11:48:58 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id D9CB6404754D; Fri, 3 Jun 2022 11:48:57 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 2652A40CFD0A; Fri, 3 Jun 2022 11:48:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654256946; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=KY/5ZMci/AV6BUScFtS3eEbB74q4JO6UR5o2itt7+/8=; b=UqsS8UOe/6vdgcSJPKNq/+j8rsiLZJrdWy2KcYLZVpgH3lTz5DaEnLSEWlani/1gy9BDUU YIEl7JxwFJNA0I/sFhoUPGn2O+TRvvHPceGFGBqs5ft3+P6Yh2Lu2F4dyk5Wlqyt4f05tn P/8JOgvkUdq5oeNd/lZNqBYPD3ouXtM= X-MC-Unique: bDEF2adONnm_T8YHlxJfxQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v4 10/13] conf: Extract formatting of NVRAM out of virDomainLoaderDefFormat Date: Fri, 3 Jun 2022 13:48:42 +0200 Message-Id: <2cee9dcb9cb1a08ff413dd66d3cd8aa355eeea36.1654256672.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 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: , Cc: Rohit Kumar Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.9 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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: 1654256949384100002 Content-Type: text/plain; charset="utf-8" Introduce virDomainLoaderDefFormatNvram and extract the code to it so that it's self-contained in upcoming patches adding more complex logic. Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- src/conf/domain_conf.c | 27 +++++++++++++++++++-------- 1 file changed, 19 insertions(+), 8 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 252e34dd2a..05b2518a71 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -27099,14 +27099,30 @@ virDomainHugepagesFormat(virBuffer *buf, virBufferAddLit(buf, "\n"); } + +static void +virDomainLoaderDefFormatNvram(virBuffer *buf, + virDomainLoaderDef *loader) +{ + g_auto(virBuffer) attrBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) childBuf =3D VIR_BUFFER_INITIALIZER; + + virBufferEscapeString(&attrBuf, " template=3D'%s'", loader->nvramTempl= ate); + if (loader->nvram) { + if (loader->nvram->type =3D=3D VIR_STORAGE_TYPE_FILE) + virBufferEscapeString(&childBuf, "%s", loader->nvram->path); + } + + virXMLFormatElementInternal(buf, "nvram", &attrBuf, &childBuf, false, = false); +} + + static void virDomainLoaderDefFormat(virBuffer *buf, virDomainLoaderDef *loader) { g_auto(virBuffer) loaderAttrBuf =3D VIR_BUFFER_INITIALIZER; g_auto(virBuffer) loaderChildBuf =3D VIR_BUFFER_INITIALIZER; - g_auto(virBuffer) nvramAttrBuf =3D VIR_BUFFER_INITIALIZER; - g_auto(virBuffer) nvramChildBuf =3D VIR_BUFFER_INITIALIZER; if (loader->readonly !=3D VIR_TRISTATE_BOOL_ABSENT) virBufferAsprintf(&loaderAttrBuf, " readonly=3D'%s'", @@ -27124,12 +27140,7 @@ virDomainLoaderDefFormat(virBuffer *buf, virXMLFormatElementInternal(buf, "loader", &loaderAttrBuf, &loaderChil= dBuf, false, false); - virBufferEscapeString(&nvramAttrBuf, " template=3D'%s'", loader->nvram= Template); - if (loader->nvram) { - if (loader->nvram->type =3D=3D VIR_STORAGE_TYPE_FILE) - virBufferEscapeString(&nvramChildBuf, "%s", loader->nvram->pat= h); - } - virXMLFormatElementInternal(buf, "nvram", &nvramAttrBuf, &nvramChildBu= f, false, false); + virDomainLoaderDefFormatNvram(buf, loader); } static void --=20 2.35.3 From nobody Sat May 11 09:24:57 2024 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=1654257065; cv=none; d=zohomail.com; s=zohoarc; b=nOG+UXPg9yN5mrjRzvanlM3+S1DjeFEL0FiuzccU/PxL4Zg34f4Z/j2YcPdPjahUM8qFA0IpN4+JwWImFSOO0WefmOhoLFo22R64ciunZ87F0S39vbj/Na9LwxK0pAo7LWAH7r/Pbd5Vo7N6RHDhMUUBexkbQipggTh3VQ97nFU= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654257065; h=Content-Type:Content-Transfer-Encoding:Cc: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=a+mItVzfESBK6WNvb+pJjOTsfY3m4nhVp6heaKYPcDc=; b=LTWl4BETC3IY3v+aE8IYc7UQqr7jD2ugR5lQgGbbPJFSkrRekqUB7qinJ8C0lhzAQt6RGgFrWAi9cchZVt0TlXMQeKk7C4MgVu31z6hTQ67KKZx37J3Rf9dAjrh0gZ1lnMw5VNlPsQQBa9zY3DnvGH7XnSFYk9ZHJlWTx2DKuPo= 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 1654257065388371.10220901982564; Fri, 3 Jun 2022 04:51:05 -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-480-xwuPHC74PuGfwODyc_lHnQ-1; Fri, 03 Jun 2022 07:49:02 -0400 Received: from smtp.corp.redhat.com (int-mx08.intmail.prod.int.rdu2.redhat.com [10.11.54.8]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id B2674100BAB9; Fri, 3 Jun 2022 11:49:00 +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 9B053C27E97; Fri, 3 Jun 2022 11:49:00 +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 7752F1947041; Fri, 3 Jun 2022 11:49:00 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 19BFE194705B for ; Fri, 3 Jun 2022 11:48:59 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id EC05740CFD0A; Fri, 3 Jun 2022 11:48:58 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 408EB40CF8E7; Fri, 3 Jun 2022 11:48:58 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654257064; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=a+mItVzfESBK6WNvb+pJjOTsfY3m4nhVp6heaKYPcDc=; b=fbe2P3hqPSH7Bad7kkZ2x5abb4Fgh+VinEcGwSx/Cc0+N9YL3mcjwmz545+vgKAEfn/hKp HD33ovr7RT9SI0MLdJIUxBRFmBX2BauVRKkyP1fYaysZ/EFfKmp0ULMUGKjO+QK/VTb2hd jJbP4mLyrD/3c40VmYSp+NYrR7WL2AE= X-MC-Unique: xwuPHC74PuGfwODyc_lHnQ-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v4 11/13] conf: Add support to parse/format for NVRAM Date: Fri, 3 Jun 2022 13:48:43 +0200 Message-Id: <6fde8ee049a4ef618093829edb5fbe785a3947fa.1654256672.git.pkrempa@redhat.com> In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 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: , Cc: Rohit Kumar Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.85 on 10.11.54.8 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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: 1654257066336100003 Content-Type: text/plain; charset="utf-8" From: Rohit Kumar This patch introduces the logic to format and parse remote NVRAM. Update NVRAM element schema, and docs for supporting network backed NVRAM. NVRAM backed over network would give the flexibility to start the VM on any host without having to worry about where to get the latest nvram image. or In the qemu driver we will support the new definition only with qemu's supporting -blockdev. Signed-off-by: Prerna Saxena Signed-off-by: Florian Schmidt Signed-off-by: Rohit Kumar Signed-off-by: Peter Krempa Reviewed-by: J=C3=A1n Tomko --- docs/formatdomain.rst | 37 ++++++++++ src/conf/domain_conf.c | 116 ++++++++++++++++++++++++------ src/conf/domain_conf.h | 1 + src/conf/schemas/domaincommon.rng | 9 ++- src/qemu/qemu_validate.c | 7 ++ 5 files changed, 146 insertions(+), 24 deletions(-) diff --git a/docs/formatdomain.rst b/docs/formatdomain.rst index 312b605a8b..8a9da07612 100644 --- a/docs/formatdomain.rst +++ b/docs/formatdomain.rst @@ -135,6 +135,34 @@ harddisk, cdrom, network) determining where to obtain/= find the boot image. ... + + ... + + hvm + /usr/share/OV= MF/OVMF_CODE.fd + + + + + ... + + + ... + + hvm + /usr/share/OV= MF/OVMF_CODE.fd + + + + + + + + + + + ... + ... @@ -224,6 +252,15 @@ harddisk, cdrom, network) determining where to obtain/= find the boot image. if the NVRAM file has been created by libvirt it is left behind and it = is management application's responsibility to save and remove file (if nee= ded to be persistent). :since:`Since 1.2.8` + + :since:`Since 8.5.0`, it's possible for the element to have ``type`` a= ttribute + (accepts values ``file``, ``block`` and ``network``) in that case the N= VRAM + storage is described by a ```` sub-element with the same syntax= as + ``disk``'s source. See `Hard drives, floppy disks, CDROMs`_. + + **Note:** ``network`` backed NVRAM the variables are not instantiated f= rom + the ``template`` and it's user's responsibility to provide a valid NVRA= M image. + ``boot`` The ``dev`` attribute takes one of the values "fd", "hd", "cdrom" or "network" and is used to specify the next boot device to consider. The diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 05b2518a71..b34513f943 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -17951,6 +17951,51 @@ virDomainLoaderDefParseXML(xmlNodePtr node, } +static int +virDomainNvramDefParseXML(virDomainLoaderDef *loader, + xmlXPathContextPtr ctxt, + virDomainXMLOption *xmlopt, + unsigned int flags) +{ + g_autofree char *nvramType =3D virXPathString("string(./os/nvram/@type= )", ctxt); + g_autoptr(virStorageSource) src =3D virStorageSourceNew(); + + src->type =3D VIR_STORAGE_TYPE_FILE; + src->format =3D VIR_STORAGE_FILE_RAW; + + if (!nvramType) { + char *nvramPath =3D NULL; + + if (!(nvramPath =3D virXPathString("string(./os/nvram[1])", ctxt))) + return 0; /* no nvram */ + + src->path =3D nvramPath; + } else { + xmlNodePtr sourceNode; + + if ((src->type =3D virStorageTypeFromString(nvramType)) <=3D 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown disk type '%s'"), nvramType); + return -1; + } + + if (!(sourceNode =3D virXPathNode("./os/nvram/source[1]", ctxt))) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Missing source element for nvram")); + return -1; + } + + if (virDomainStorageSourceParse(sourceNode, ctxt, src, flags, xmlo= pt) < 0) + return -1; + + loader->newStyleNVRAM =3D true; + } + + loader->nvram =3D g_steal_pointer(&src); + return 0; +} + + static int virDomainSchedulerParseCommonAttrs(xmlNodePtr node, virProcessSchedPolicy *policy, @@ -18336,11 +18381,12 @@ virDomainDefParseBootFirmwareOptions(virDomainDef= *def, static int virDomainDefParseBootLoaderOptions(virDomainDef *def, - xmlXPathContextPtr ctxt) + xmlXPathContextPtr ctxt, + virDomainXMLOption *xmlopt, + unsigned int flags) { xmlNodePtr loader_node =3D virXPathNode("./os/loader[1]", ctxt); const bool fwAutoSelect =3D def->os.firmware !=3D VIR_DOMAIN_OS_DEF_FI= RMWARE_NONE; - g_autofree char *nvramPath =3D NULL; if (!loader_node) return 0; @@ -18352,12 +18398,8 @@ virDomainDefParseBootLoaderOptions(virDomainDef *d= ef, fwAutoSelect) < 0) return -1; - if ((nvramPath =3D virXPathString("string(./os/nvram[1])", ctxt))) { - def->os.loader->nvram =3D virStorageSourceNew(); - def->os.loader->nvram->path =3D g_steal_pointer(&nvramPath); - def->os.loader->nvram->type =3D VIR_STORAGE_TYPE_FILE; - def->os.loader->nvram->format =3D VIR_STORAGE_FILE_RAW; - } + if (virDomainNvramDefParseXML(def->os.loader, ctxt, xmlopt, flags) < 0) + return -1; if (!fwAutoSelect) def->os.loader->nvramTemplate =3D virXPathString("string(./os/nvra= m[1]/@template)", ctxt); @@ -18412,7 +18454,9 @@ virDomainDefParseBootAcpiOptions(virDomainDef *def, static int virDomainDefParseBootOptions(virDomainDef *def, - xmlXPathContextPtr ctxt) + xmlXPathContextPtr ctxt, + virDomainXMLOption *xmlopt, + unsigned int flags) { /* * Booting options for different OS types.... @@ -18430,7 +18474,7 @@ virDomainDefParseBootOptions(virDomainDef *def, if (virDomainDefParseBootFirmwareOptions(def, ctxt) < 0) return -1; - if (virDomainDefParseBootLoaderOptions(def, ctxt) < 0) + if (virDomainDefParseBootLoaderOptions(def, ctxt, xmlopt, flags) <= 0) return -1; if (virDomainDefParseBootAcpiOptions(def, ctxt) < 0) @@ -18446,7 +18490,7 @@ virDomainDefParseBootOptions(virDomainDef *def, case VIR_DOMAIN_OSTYPE_UML: virDomainDefParseBootKernelOptions(def, ctxt); - if (virDomainDefParseBootLoaderOptions(def, ctxt) < 0) + if (virDomainDefParseBootLoaderOptions(def, ctxt, xmlopt, flags) <= 0) return -1; break; @@ -19746,7 +19790,7 @@ virDomainDefParseXML(xmlXPathContextPtr ctxt, if (virDomainDefClockParse(def, ctxt) < 0) return NULL; - if (virDomainDefParseBootOptions(def, ctxt) < 0) + if (virDomainDefParseBootOptions(def, ctxt, xmlopt, flags) < 0) return NULL; /* analysis of the disk devices */ @@ -27100,26 +27144,48 @@ virDomainHugepagesFormat(virBuffer *buf, } -static void +static int virDomainLoaderDefFormatNvram(virBuffer *buf, - virDomainLoaderDef *loader) + virDomainLoaderDef *loader, + virDomainXMLOption *xmlopt, + unsigned int flags) { g_auto(virBuffer) attrBuf =3D VIR_BUFFER_INITIALIZER; - g_auto(virBuffer) childBuf =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) childBufDirect =3D VIR_BUFFER_INITIALIZER; + g_auto(virBuffer) childBufChild =3D VIR_BUFFER_INIT_CHILD(buf); + virBuffer *childBuf =3D &childBufDirect; + bool childNewline =3D false; virBufferEscapeString(&attrBuf, " template=3D'%s'", loader->nvramTempl= ate); + if (loader->nvram) { - if (loader->nvram->type =3D=3D VIR_STORAGE_TYPE_FILE) - virBufferEscapeString(&childBuf, "%s", loader->nvram->path); + virStorageSource *src =3D loader->nvram; + + if (!loader->newStyleNVRAM) { + virBufferEscapeString(&childBufDirect, "%s", src->path); + } else { + childNewline =3D true; + childBuf =3D &childBufChild; + + virBufferAsprintf(&attrBuf, " type=3D'%s'", virStorageTypeToSt= ring(src->type)); + + if (virDomainDiskSourceFormat(&childBufChild, src, "source", 0, + false, flags, false, false, xmlo= pt) < 0) + return -1; + } } - virXMLFormatElementInternal(buf, "nvram", &attrBuf, &childBuf, false, = false); + virXMLFormatElementInternal(buf, "nvram", &attrBuf, childBuf, false, c= hildNewline); + + return 0; } -static void +static int virDomainLoaderDefFormat(virBuffer *buf, - virDomainLoaderDef *loader) + virDomainLoaderDef *loader, + virDomainXMLOption *xmlopt, + unsigned int flags) { g_auto(virBuffer) loaderAttrBuf =3D VIR_BUFFER_INITIALIZER; g_auto(virBuffer) loaderChildBuf =3D VIR_BUFFER_INITIALIZER; @@ -27140,7 +27206,10 @@ virDomainLoaderDefFormat(virBuffer *buf, virXMLFormatElementInternal(buf, "loader", &loaderAttrBuf, &loaderChil= dBuf, false, false); - virDomainLoaderDefFormatNvram(buf, loader); + if (virDomainLoaderDefFormatNvram(buf, loader, xmlopt, flags) < 0) + return -1; + + return 0; } static void @@ -28341,8 +28410,9 @@ virDomainDefFormatInternalSetRootName(virDomainDef = *def, if (def->os.initgroup) virBufferAsprintf(buf, "%s\n", def->os.init= group); - if (def->os.loader) - virDomainLoaderDefFormat(buf, def->os.loader); + if (def->os.loader && + virDomainLoaderDefFormat(buf, def->os.loader, xmlopt, flags) < 0) + return -1; virBufferEscapeString(buf, "%s\n", def->os.kernel); virBufferEscapeString(buf, "%s\n", diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 9ec81067c6..1ce6e855b6 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -2254,6 +2254,7 @@ struct _virDomainLoaderDef { virDomainLoader type; virTristateBool secure; virStorageSource *nvram; + bool newStyleNVRAM; char *nvramTemplate; /* user override of path to master nvram */ }; diff --git a/src/conf/schemas/domaincommon.rng b/src/conf/schemas/domaincom= mon.rng index cc598212a8..bf829f3a65 100644 --- a/src/conf/schemas/domaincommon.rng +++ b/src/conf/schemas/domaincommon.rng @@ -333,7 +333,14 @@ - + + + + + + + + diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 48b7d08684..2bbe198a11 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -576,6 +576,13 @@ qemuValidateDomainDefNvram(const virDomainDef *def, if (!src) return 0; + if (def->os.loader->newStyleNVRAM && + !virQEMUCapsGet(qemuCaps, QEMU_CAPS_BLOCKDEV)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("modern nvram specification is not supported by t= his qemu")); + return -1; + } + switch (src->type) { case VIR_STORAGE_TYPE_FILE: case VIR_STORAGE_TYPE_BLOCK: --=20 2.35.3 From nobody Sat May 11 09:24:57 2024 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.129.124 as permitted sender) client-ip=170.10.129.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.129.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=1654257015; cv=none; d=zohomail.com; s=zohoarc; b=kmqK5y39qYjC2h6IjqAD5ipv4raRaALxktQJdu1NzxklA3QT8byCJlILba3xh+Bl5j38JA4KRkHQR/Y8QUgOYm1uBD/z9GyFVxLRgFTseD6w9WfODjmhf35dagEClrbae4Z5DwQljZoAXXIXpkH6QNKLEJdP1xKEtnHQOtANSPg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1654257015; h=Content-Type:Content-Transfer-Encoding:Cc: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=Ew1722IZEUklFdh8m7n7xEsbh1iQgrueYTpgZhS1JHw=; b=AeCH0xNHZVBuWwzlfqbZHi/N181WYGjNYNp9pH2StrjjOF1i1Z3waKQ/N8DHjihqvLBF6SSN0Pr3Z2h7Jy/SSB4p4A9mL48Q9vVAxM0OCfKKPyqTiWaW1RTURuYLJn3gbZK7M0TDOXowkzEj4EmxNTxtcZbPbT5v8sFVZ+kdBMY= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.129.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.129.124]) by mx.zohomail.com with SMTPS id 1654257015974748.7231895548158; Fri, 3 Jun 2022 04:50:15 -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-277-as61mYzyOXqeaotcxgXZqw-1; Fri, 03 Jun 2022 07:49:04 -0400 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id A6539811E7A; Fri, 3 Jun 2022 11:49:01 +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 8E97210725; Fri, 3 Jun 2022 11:49:01 +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 4B0C0194704A; Fri, 3 Jun 2022 11:49:01 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.rdu2.redhat.com [10.11.54.1]) by mm-prod-listman-01.mail-001.prod.us-east-1.aws.redhat.com (Postfix) with ESMTP id 373CB1947040 for ; Fri, 3 Jun 2022 11:49:00 +0000 (UTC) Received: by smtp.corp.redhat.com (Postfix) id 1CDC140CFD0B; Fri, 3 Jun 2022 11:49:00 +0000 (UTC) Received: from speedmetal.redhat.com (unknown [10.40.208.20]) by smtp.corp.redhat.com (Postfix) with ESMTP id 4974B40CFD0A; Fri, 3 Jun 2022 11:48:59 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1654257014; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc: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=Ew1722IZEUklFdh8m7n7xEsbh1iQgrueYTpgZhS1JHw=; b=LR+WE6XHS5fSWqmoyCafyRot7gY5klo1ojfWZQu/dOlrQ7fh3Y1374f1c+OzHIdzbgDIhJ USWXe2MuZJiXE7FjXm23OhzUwbxxd/i8B48eGuq7aXu5Wid0cbs6C5EZzHcMB9hvHvhsLY peZdGvJeL2LoIf8uSnOsX64eaFP5oOo= X-MC-Unique: as61mYzyOXqeaotcxgXZqw-1 X-Original-To: libvir-list@listman.corp.redhat.com From: Peter Krempa To: libvir-list@redhat.com Subject: [PATCH v4 12/13] Add unit tests for new specification of nvram. Date: Fri, 3 Jun 2022 13:48:44 +0200 Message-Id: In-Reply-To: References: MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.11.54.1 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: , Cc: Rohit Kumar Errors-To: libvir-list-bounces@redhat.com Sender: "libvir-list" X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 Authentication-Results: relay.mimecast.com; auth=pass smtp.auth=CUSA124A263 smtp.mailfrom=libvir-list-bounces@redhat.com 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: 1654257017893100001 Content-Type: text/plain; charset="utf-8" From: Rohit Kumar This patch adds unit tests for remote NVRAM. Examples: and and Signed-off-by: Prerna Saxena Signed-off-by: Florian Schmidt Signed-off-by: Rohit Kumar Reviewed-by: J=C3=A1n Tomko --- .../bios-nvram-file.x86_64-latest.args | 37 ++++++++++++++++ tests/qemuxml2argvdata/bios-nvram-file.xml | 23 ++++++++++ .../bios-nvram-network-iscsi.x86_64-4.1.0.err | 1 + ...ios-nvram-network-iscsi.x86_64-latest.args | 38 ++++++++++++++++ .../bios-nvram-network-iscsi.xml | 31 +++++++++++++ .../bios-nvram-network-nbd.x86_64-latest.args | 37 ++++++++++++++++ .../bios-nvram-network-nbd.xml | 28 ++++++++++++ tests/qemuxml2argvtest.c | 4 ++ .../bios-nvram-file.x86_64-latest.xml | 39 ++++++++++++++++ ...bios-nvram-network-iscsi.x86_64-latest.xml | 44 +++++++++++++++++++ .../bios-nvram-network-nbd.x86_64-latest.xml | 41 +++++++++++++++++ tests/qemuxml2xmltest.c | 3 ++ 12 files changed, 326 insertions(+) create mode 100644 tests/qemuxml2argvdata/bios-nvram-file.x86_64-latest.ar= gs create mode 100644 tests/qemuxml2argvdata/bios-nvram-file.xml create mode 100644 tests/qemuxml2argvdata/bios-nvram-network-iscsi.x86_64-= 4.1.0.err create mode 100644 tests/qemuxml2argvdata/bios-nvram-network-iscsi.x86_64-= latest.args create mode 100644 tests/qemuxml2argvdata/bios-nvram-network-iscsi.xml create mode 100644 tests/qemuxml2argvdata/bios-nvram-network-nbd.x86_64-la= test.args create mode 100644 tests/qemuxml2argvdata/bios-nvram-network-nbd.xml create mode 100644 tests/qemuxml2xmloutdata/bios-nvram-file.x86_64-latest.= xml create mode 100644 tests/qemuxml2xmloutdata/bios-nvram-network-iscsi.x86_6= 4-latest.xml create mode 100644 tests/qemuxml2xmloutdata/bios-nvram-network-nbd.x86_64-= latest.xml diff --git a/tests/qemuxml2argvdata/bios-nvram-file.x86_64-latest.args b/te= sts/qemuxml2argvdata/bios-nvram-file.x86_64-latest.args new file mode 100644 index 0000000000..4b0aec7539 --- /dev/null +++ b/tests/qemuxml2argvdata/bios-nvram-file.x86_64-latest.args @@ -0,0 +1,37 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/tmp/lib/domain--1-test-bios \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/tmp/lib/domain--1-test-bios/.local/share \ +XDG_CACHE_HOME=3D/tmp/lib/domain--1-test-bios/.cache \ +XDG_CONFIG_HOME=3D/tmp/lib/domain--1-test-bios/.config \ +/usr/bin/qemu-system-x86_64 \ +-name guest=3Dtest-bios,debug-threads=3Don \ +-S \ +-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tm= p/lib/domain--1-test-bios/master-key.aes"}' \ +-blockdev '{"driver":"file","filename":"/usr/share/OVMF/OVMF_CODE.fd","nod= e-name":"libvirt-pflash0-storage","auto-read-only":true,"discard":"unmap"}'= \ +-blockdev '{"node-name":"libvirt-pflash0-format","read-only":true,"driver"= :"raw","file":"libvirt-pflash0-storage"}' \ +-blockdev '{"driver":"file","filename":"/var/lib/libvirt/nvram/guest_VARS.= fd","node-name":"libvirt-pflash1-storage","auto-read-only":true,"discard":"= unmap"}' \ +-blockdev '{"node-name":"libvirt-pflash1-format","read-only":false,"driver= ":"raw","file":"libvirt-pflash1-storage"}' \ +-machine pc,usb=3Doff,dump-guest-core=3Doff,pflash0=3Dlibvirt-pflash0-form= at,pflash1=3Dlibvirt-pflash1-format,memory-backend=3Dpc.ram \ +-accel tcg \ +-cpu qemu64 \ +-m 1024 \ +-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":1073741824}= ' \ +-overcommit mem-lock=3Doff \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid 362d1fc1-df7d-193e-5c18-49a71bd1da66 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,fd=3D1729,server=3Don,wait=3Doff \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-boot menu=3Don,strict=3Don \ +-device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0= x2"}' \ +-audiodev '{"id":"audio1","driver":"none"}' \ +-device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","add= r":"0x2"}' \ +-sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ +-msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/bios-nvram-file.xml b/tests/qemuxml2arg= vdata/bios-nvram-file.xml new file mode 100644 index 0000000000..8df9412112 --- /dev/null +++ b/tests/qemuxml2argvdata/bios-nvram-file.xml @@ -0,0 +1,23 @@ + + test-bios + 362d1fc1-df7d-193e-5c18-49a71bd1da66 + 1048576 + 1048576 + 1 + + hvm + /usr/share/OVMF/OVMF_CODE.fd<= /loader> + + + + + + + + + + + + /usr/bin/qemu-system-x86_64 + + diff --git a/tests/qemuxml2argvdata/bios-nvram-network-iscsi.x86_64-4.1.0.e= rr b/tests/qemuxml2argvdata/bios-nvram-network-iscsi.x86_64-4.1.0.err new file mode 100644 index 0000000000..5251bbdbbf --- /dev/null +++ b/tests/qemuxml2argvdata/bios-nvram-network-iscsi.x86_64-4.1.0.err @@ -0,0 +1 @@ +unsupported configuration: modern nvram specification is not supported by = this qemu diff --git a/tests/qemuxml2argvdata/bios-nvram-network-iscsi.x86_64-latest.= args b/tests/qemuxml2argvdata/bios-nvram-network-iscsi.x86_64-latest.args new file mode 100644 index 0000000000..b8a323358d --- /dev/null +++ b/tests/qemuxml2argvdata/bios-nvram-network-iscsi.x86_64-latest.args @@ -0,0 +1,38 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/tmp/lib/domain--1-test-bios \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/tmp/lib/domain--1-test-bios/.local/share \ +XDG_CACHE_HOME=3D/tmp/lib/domain--1-test-bios/.cache \ +XDG_CONFIG_HOME=3D/tmp/lib/domain--1-test-bios/.config \ +/usr/bin/qemu-system-x86_64 \ +-name guest=3Dtest-bios,debug-threads=3Don \ +-S \ +-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tm= p/lib/domain--1-test-bios/master-key.aes"}' \ +-blockdev '{"driver":"file","filename":"/usr/share/OVMF/OVMF_CODE.fd","nod= e-name":"libvirt-pflash0-storage","auto-read-only":true,"discard":"unmap"}'= \ +-blockdev '{"node-name":"libvirt-pflash0-format","read-only":true,"driver"= :"raw","file":"libvirt-pflash0-storage"}' \ +-object '{"qom-type":"secret","id":"libvirt-pflash1-storage-auth-secret0",= "data":"9eao5F8qtkGt+seB1HYivWIxbtwUu6MQtg1zpj/oDtUsPr1q8wBYM91uEHCn6j/1","= keyid":"masterKey0","iv":"AAECAwQFBgcICQoLDA0ODw=3D=3D","format":"base64"}'= \ +-blockdev '{"driver":"iscsi","portal":"example.com:6000","target":"iqn.201= 3-07.com.example:iscsi-nopool","lun":0,"transport":"tcp","user":"myname","p= assword-secret":"libvirt-pflash1-storage-auth-secret0","node-name":"libvirt= -pflash1-storage","auto-read-only":true,"discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-pflash1-format","read-only":false,"driver= ":"raw","file":"libvirt-pflash1-storage"}' \ +-machine pc,usb=3Doff,dump-guest-core=3Doff,pflash0=3Dlibvirt-pflash0-form= at,pflash1=3Dlibvirt-pflash1-format,memory-backend=3Dpc.ram \ +-accel tcg \ +-cpu qemu64 \ +-m 1024 \ +-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":1073741824}= ' \ +-overcommit mem-lock=3Doff \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid 362d1fc1-df7d-193e-5c18-49a71bd1da66 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,fd=3D1729,server=3Don,wait=3Doff \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-boot menu=3Don,strict=3Don \ +-device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0= x2"}' \ +-audiodev '{"id":"audio1","driver":"none"}' \ +-device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","add= r":"0x2"}' \ +-sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ +-msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/bios-nvram-network-iscsi.xml b/tests/qe= muxml2argvdata/bios-nvram-network-iscsi.xml new file mode 100644 index 0000000000..d8a354126d --- /dev/null +++ b/tests/qemuxml2argvdata/bios-nvram-network-iscsi.xml @@ -0,0 +1,31 @@ + + test-bios + 362d1fc1-df7d-193e-5c18-49a71bd1da66 + 1048576 + 1048576 + 1 + + hvm + /usr/share/OVMF/OVMF_CODE.fd<= /loader> + + + + + + + + + + + + + + + + destroy + restart + restart + + /usr/bin/qemu-system-x86_64 + + diff --git a/tests/qemuxml2argvdata/bios-nvram-network-nbd.x86_64-latest.ar= gs b/tests/qemuxml2argvdata/bios-nvram-network-nbd.x86_64-latest.args new file mode 100644 index 0000000000..08dbd99335 --- /dev/null +++ b/tests/qemuxml2argvdata/bios-nvram-network-nbd.x86_64-latest.args @@ -0,0 +1,37 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/tmp/lib/domain--1-test-bios \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/tmp/lib/domain--1-test-bios/.local/share \ +XDG_CACHE_HOME=3D/tmp/lib/domain--1-test-bios/.cache \ +XDG_CONFIG_HOME=3D/tmp/lib/domain--1-test-bios/.config \ +/usr/bin/qemu-system-x86_64 \ +-name guest=3Dtest-bios,debug-threads=3Don \ +-S \ +-object '{"qom-type":"secret","id":"masterKey0","format":"raw","file":"/tm= p/lib/domain--1-test-bios/master-key.aes"}' \ +-blockdev '{"driver":"file","filename":"/usr/share/OVMF/OVMF_CODE.fd","nod= e-name":"libvirt-pflash0-storage","auto-read-only":true,"discard":"unmap"}'= \ +-blockdev '{"node-name":"libvirt-pflash0-format","read-only":true,"driver"= :"raw","file":"libvirt-pflash0-storage"}' \ +-blockdev '{"driver":"nbd","server":{"type":"inet","host":"example.org","p= ort":"6000"},"export":"bar","node-name":"libvirt-pflash1-storage","auto-rea= d-only":true,"discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-pflash1-format","read-only":false,"driver= ":"raw","file":"libvirt-pflash1-storage"}' \ +-machine pc,usb=3Doff,dump-guest-core=3Doff,pflash0=3Dlibvirt-pflash0-form= at,pflash1=3Dlibvirt-pflash1-format,memory-backend=3Dpc.ram \ +-accel tcg \ +-cpu qemu64 \ +-m 1024 \ +-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":1073741824}= ' \ +-overcommit mem-lock=3Doff \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid 362d1fc1-df7d-193e-5c18-49a71bd1da66 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,fd=3D1729,server=3Don,wait=3Doff \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-boot menu=3Don,strict=3Don \ +-device '{"driver":"piix3-usb-uhci","id":"usb","bus":"pci.0","addr":"0x1.0= x2"}' \ +-audiodev '{"id":"audio1","driver":"none"}' \ +-device '{"driver":"virtio-balloon-pci","id":"balloon0","bus":"pci.0","add= r":"0x2"}' \ +-sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,resource= control=3Ddeny \ +-msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/bios-nvram-network-nbd.xml b/tests/qemu= xml2argvdata/bios-nvram-network-nbd.xml new file mode 100644 index 0000000000..3350914607 --- /dev/null +++ b/tests/qemuxml2argvdata/bios-nvram-network-nbd.xml @@ -0,0 +1,28 @@ + + test-bios + 362d1fc1-df7d-193e-5c18-49a71bd1da66 + 1048576 + 1048576 + 1 + + hvm + /usr/share/OVMF/OVMF_CODE.fd<= /loader> + + + + + + + + + + + + + destroy + restart + restart + + /usr/bin/qemu-system-x86_64 + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index bffe7aef8a..fecd863820 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1209,6 +1209,10 @@ mymain(void) QEMU_CAPS_ICH9_AHCI, QEMU_CAPS_VIRTIO_SCSI); DO_TEST_CAPS_LATEST("bios-nvram-template"); + DO_TEST_CAPS_LATEST("bios-nvram-network-iscsi"); + DO_TEST_CAPS_VER_PARSE_ERROR("bios-nvram-network-iscsi", "4.1.0"); + DO_TEST_CAPS_LATEST("bios-nvram-network-nbd"); + DO_TEST_CAPS_LATEST("bios-nvram-file"); /* Make sure all combinations of ACPI and UEFI behave as expected */ DO_TEST_NOCAPS("q35-acpi-uefi"); diff --git a/tests/qemuxml2xmloutdata/bios-nvram-file.x86_64-latest.xml b/t= ests/qemuxml2xmloutdata/bios-nvram-file.x86_64-latest.xml new file mode 100644 index 0000000000..97e029f70b --- /dev/null +++ b/tests/qemuxml2xmloutdata/bios-nvram-file.x86_64-latest.xml @@ -0,0 +1,39 @@ + + test-bios + 362d1fc1-df7d-193e-5c18-49a71bd1da66 + 1048576 + 1048576 + 1 + + hvm + /usr/share/OVMF/OVMF_CODE.fd<= /loader> + + + + + + + + + + + qemu64 + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + +
+ + + + +