From nobody Fri Sep 20 22:16:26 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=1644346449; cv=none; d=zohomail.com; s=zohoarc; b=JKYms37tEIPJn6EALG6BLI3uNYmynUUkvm38r/tq2+JDwjQc6bQHKGUDurTBIFFEncUaq5vJLkcp3pAzshU1YTbPSvDxTMYG0GPnqAi2trnnm4QIN1Q7rK+W4l/Y3oQFMq/Nx7AWeqwybSBTVIU/mrzPoHnTHhnxwgv1euztC24= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1644346449; h=Content-Type:Content-Transfer-Encoding:Date:From:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:Sender:Subject:To; bh=FF8/ZErsg9X9EK6g5mU0EEIeOqw+NLpwWKOWrBbnusw=; b=Gh9K1YU3+pbHdYJTg2XfURbFqxlIbFKUL6BUWMse2AyHPlA4QHtrDBvx8a5hCCGJAqjhNSFovptrJBk7w2Zpe0EaGlijvU3hqlJbLNrDrkfvbvtU7J36+JgUT/HKd4+DI3dV28yUqgU/yrQ8pkzU9ngvonOUlC/ISVhbvGCfvbU= 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 1644346449034853.7626909611246; Tue, 8 Feb 2022 10:54:09 -0800 (PST) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-207-9sW2N8j_NI-hZGwnIaeaxA-1; Tue, 08 Feb 2022 13:53:27 -0500 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 5158B1091DBC; Tue, 8 Feb 2022 18:53:21 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.20]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 2DC52753E2; Tue, 8 Feb 2022 18:53:21 +0000 (UTC) Received: from lists01.pubmisc.prod.ext.phx2.redhat.com (lists01.pubmisc.prod.ext.phx2.redhat.com [10.5.19.33]) by colo-mx.corp.redhat.com (Postfix) with ESMTP id F0A151826D28; Tue, 8 Feb 2022 18:53:20 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx07.intmail.prod.int.phx2.redhat.com [10.5.11.22]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 217CgrSU003670 for ; Mon, 7 Feb 2022 07:42:53 -0500 Received: by smtp.corp.redhat.com (Postfix) id B0DEA106C0CB; Mon, 7 Feb 2022 12:42:53 +0000 (UTC) Received: from localhost.localdomain.com (unknown [10.33.36.143]) by smtp.corp.redhat.com (Postfix) with ESMTP id B5F51106C0C7; Mon, 7 Feb 2022 12:42:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1644346447; h=from:from:sender:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=FF8/ZErsg9X9EK6g5mU0EEIeOqw+NLpwWKOWrBbnusw=; b=He1JRwWvXqDbRbJ6ZiVla78Mqt6y3tUNN3KCn+iD4WFzkea5kNjOdGZMDFJA4iGlVCGTQ6 Sg5tj9kXxgUSu3nV47N5thrwsC7Aew0cKKzREKqhv06R7GsIDeN/jzZuJZkLZTW2JgIiCI IXwWSs+XhQfsxgehrnNwk/sc7V/6Lb4= X-MC-Unique: 9sW2N8j_NI-hZGwnIaeaxA-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [PATCH] qemu: fix formatting of pflash readonly attribute Date: Mon, 7 Feb 2022 12:42:42 +0000 Message-Id: <20220207124242.1044395-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.84 on 10.5.11.22 X-loop: libvir-list@redhat.com X-BeenThere: libvir-list@redhat.com X-Mailman-Version: 2.1.12 Precedence: junk List-Id: Development discussions about the libvirt library & tools List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 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-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable X-ZohoMail-DKIM: pass (identity @redhat.com) X-ZM-MESSAGEID: 1644346449902100001 When the had an explicit readonly=3D'no' attribute we accidentally still marked the plfash as readonly due to the bad conversion from virTristateBool to bool. Signed-off-by: Daniel P. Berrang=C3=A9 Reviewed-by: J=C3=A1n Tomko --- src/qemu/qemu_domain.c | 3 +- .../bios-nvram-implicit-rw.x86_64-latest.args | 39 +++++++++++++++++++ .../bios-nvram-implicit-rw.xml | 35 +++++++++++++++++ .../bios-nvram-rw.x86_64-latest.args | 39 +++++++++++++++++++ tests/qemuxml2argvdata/bios-nvram-rw.xml | 35 +++++++++++++++++ tests/qemuxml2argvtest.c | 2 + 6 files changed, 152 insertions(+), 1 deletion(-) create mode 100644 tests/qemuxml2argvdata/bios-nvram-implicit-rw.x86_64-la= test.args create mode 100644 tests/qemuxml2argvdata/bios-nvram-implicit-rw.xml create mode 100644 tests/qemuxml2argvdata/bios-nvram-rw.x86_64-latest.args create mode 100644 tests/qemuxml2argvdata/bios-nvram-rw.xml diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c index 9f9e969872..ec71144808 100644 --- a/src/qemu/qemu_domain.c +++ b/src/qemu/qemu_domain.c @@ -11120,7 +11120,8 @@ qemuDomainInitializePflashStorageSource(virDomainOb= j *vm) pflash0->type =3D VIR_STORAGE_TYPE_FILE; pflash0->format =3D VIR_STORAGE_FILE_RAW; pflash0->path =3D g_strdup(def->os.loader->path); - pflash0->readonly =3D def->os.loader->readonly; + pflash0->readonly =3D false; + virTristateBoolToBool(def->os.loader->readonly, &pflash0->readonly); pflash0->nodeformat =3D g_strdup("libvirt-pflash0-format"); pflash0->nodestorage =3D g_strdup("libvirt-pflash0-storage"); =20 diff --git a/tests/qemuxml2argvdata/bios-nvram-implicit-rw.x86_64-latest.ar= gs b/tests/qemuxml2argvdata/bios-nvram-implicit-rw.x86_64-latest.args new file mode 100644 index 0000000000..fde4c3f57f --- /dev/null +++ b/tests/qemuxml2argvdata/bios-nvram-implicit-rw.x86_64-latest.args @@ -0,0 +1,39 @@ +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":"/var/lib/libvirt/qemu/nvram/test-b= ios.fd","node-name":"libvirt-pflash0-storage","auto-read-only":true,"discar= d":"unmap"}' \ +-blockdev '{"node-name":"libvirt-pflash0-format","read-only":false,"driver= ":"raw","file":"libvirt-pflash0-storage"}' \ +-machine pc,usb=3Doff,dump-guest-core=3Doff,pflash0=3Dlibvirt-pflash0-form= at,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"}' \ +-blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1","no= de-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"raw= ","file":"libvirt-1-storage"}' \ +-device '{"driver":"ide-hd","bus":"ide.0","unit":0,"drive":"libvirt-1-form= at","id":"ide0-0-0","bootindex":1}' \ +-device '{"driver":"usb-tablet","id":"input0","bus":"usb.0","port":"1"}' \ +-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-implicit-rw.xml b/tests/qemu= xml2argvdata/bios-nvram-implicit-rw.xml new file mode 100644 index 0000000000..ebcd3e5300 --- /dev/null +++ b/tests/qemuxml2argvdata/bios-nvram-implicit-rw.xml @@ -0,0 +1,35 @@ + + test-bios + 362d1fc1-df7d-193e-5c18-49a71bd1da66 + 1048576 + 1048576 + 1 + + hvm + /var/lib/libvirt/qemu/nvram/test-bios.fd + + + + + + + + destroy + restart + restart + + /usr/bin/qemu-system-x86_64 + + + +
+ + + + + + + + + + diff --git a/tests/qemuxml2argvdata/bios-nvram-rw.x86_64-latest.args b/test= s/qemuxml2argvdata/bios-nvram-rw.x86_64-latest.args new file mode 100644 index 0000000000..fde4c3f57f --- /dev/null +++ b/tests/qemuxml2argvdata/bios-nvram-rw.x86_64-latest.args @@ -0,0 +1,39 @@ +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":"/var/lib/libvirt/qemu/nvram/test-b= ios.fd","node-name":"libvirt-pflash0-storage","auto-read-only":true,"discar= d":"unmap"}' \ +-blockdev '{"node-name":"libvirt-pflash0-format","read-only":false,"driver= ":"raw","file":"libvirt-pflash0-storage"}' \ +-machine pc,usb=3Doff,dump-guest-core=3Doff,pflash0=3Dlibvirt-pflash0-form= at,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"}' \ +-blockdev '{"driver":"host_device","filename":"/dev/HostVG/QEMUGuest1","no= de-name":"libvirt-1-storage","auto-read-only":true,"discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-1-format","read-only":false,"driver":"raw= ","file":"libvirt-1-storage"}' \ +-device '{"driver":"ide-hd","bus":"ide.0","unit":0,"drive":"libvirt-1-form= at","id":"ide0-0-0","bootindex":1}' \ +-device '{"driver":"usb-tablet","id":"input0","bus":"usb.0","port":"1"}' \ +-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-rw.xml b/tests/qemuxml2argvd= ata/bios-nvram-rw.xml new file mode 100644 index 0000000000..b03b4b5ecb --- /dev/null +++ b/tests/qemuxml2argvdata/bios-nvram-rw.xml @@ -0,0 +1,35 @@ + + test-bios + 362d1fc1-df7d-193e-5c18-49a71bd1da66 + 1048576 + 1048576 + 1 + + hvm + /var/lib/libvirt/qemu/nvram/te= st-bios.fd + + + + + + + + destroy + restart + restart + + /usr/bin/qemu-system-x86_64 + + + +
+ + + + + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index b9d8885912..b1592f3214 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1273,6 +1273,8 @@ mymain(void) QEMU_CAPS_DEVICE_IOH3420, QEMU_CAPS_ICH9_AHCI, QEMU_CAPS_VIRTIO_SCSI); + DO_TEST_CAPS_LATEST("bios-nvram-rw"); + DO_TEST_CAPS_LATEST("bios-nvram-implicit-rw"); =20 /* Make sure all combinations of ACPI and UEFI behave as expected */ DO_TEST_NOCAPS("q35-acpi-uefi"); --=20 2.34.1