From nobody Wed May 14 16:37:29 2025 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) client-ip=209.132.183.28; envelope-from=libvir-list-bounces@redhat.com; helo=mx1.redhat.com; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of redhat.com designates 209.132.183.28 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com Return-Path: Received: from mx1.redhat.com (mx1.redhat.com [209.132.183.28]) by mx.zohomail.com with SMTPS id 1524239325151584.2156231419751; Fri, 20 Apr 2018 08:48:45 -0700 (PDT) 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 mx1.redhat.com (Postfix) with ESMTPS id F2D0BC057F87; Fri, 20 Apr 2018 15:48:42 +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 A95268872F; Fri, 20 Apr 2018 15:48:42 +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 D01801805971; Fri, 20 Apr 2018 15:48:41 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.rdu2.redhat.com [10.11.54.3]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id w3KFicKg001421 for ; Fri, 20 Apr 2018 11:44:38 -0400 Received: by smtp.corp.redhat.com (Postfix) id 9174111701C2; Fri, 20 Apr 2018 15:44:38 +0000 (UTC) Received: from inaba.usersys.redhat.com (unknown [10.43.2.44]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 3467711701C3 for ; Fri, 20 Apr 2018 15:44:38 +0000 (UTC) From: Andrea Bolognani To: libvir-list@redhat.com Date: Fri, 20 Apr 2018 17:44:30 +0200 Message-Id: <20180420154431.31536-3-abologna@redhat.com> In-Reply-To: <20180420154431.31536-1-abologna@redhat.com> References: <20180420154431.31536-1-abologna@redhat.com> X-Scanned-By: MIMEDefang 2.78 on 10.11.54.3 X-loop: libvir-list@redhat.com Subject: [libvirt] [PATCH 2/3] qemu: Format rom.enabled attribute for PCI devices 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: , MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Sender: libvir-list-bounces@redhat.com Errors-To: libvir-list-bounces@redhat.com X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.32]); Fri, 20 Apr 2018 15:48:43 +0000 (UTC) X-ZohoMail: RSF_0 Z_629925259 SPT_0 Content-Type: text/plain; charset="utf-8" The attribute can be used to disable ROM loading completely for a device. Resolves: https://bugzilla.redhat.com/show_bug.cgi?id=3D1425058 Signed-off-by: Andrea Bolognani --- src/qemu/qemu_command.c | 13 ++++++++++-- tests/qemuxml2argvdata/pci-rom-disabled.args | 26 ++++++++++++++++++++++++ tests/qemuxml2argvdata/pci-rom-disabled.xml | 20 ++++++++++++++++++ tests/qemuxml2argvtest.c | 1 + tests/qemuxml2xmloutdata/pci-rom-disabled.xml | 29 +++++++++++++++++++++++= ++++ tests/qemuxml2xmltest.c | 1 + 6 files changed, 88 insertions(+), 2 deletions(-) create mode 100644 tests/qemuxml2argvdata/pci-rom-disabled.args create mode 100644 tests/qemuxml2argvdata/pci-rom-disabled.xml create mode 100644 tests/qemuxml2xmloutdata/pci-rom-disabled.xml diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index b666f3715f..84c4e1e350 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -442,13 +442,20 @@ static int qemuBuildRomStr(virBufferPtr buf, virDomainDeviceInfoPtr info) { - if (info->rombar || info->romfile) { + if (info->romenabled || info->rombar || info->romfile) { if (info->type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - "%s", _("rombar and romfile are supported only = for PCI devices")); + "%s", _("ROM tuning is only supported for PCI d= evices")); return -1; } =20 + /* Passing an empty romfile=3D tells QEMU to disable ROM entirely = for + * this device, and makes other settings irrelevant */ + if (info->romenabled =3D=3D VIR_TRISTATE_BOOL_NO) { + virBufferAddLit(buf, ",romfile=3D"); + goto done; + } + switch (info->rombar) { case VIR_TRISTATE_SWITCH_OFF: virBufferAddLit(buf, ",rombar=3D0"); @@ -464,6 +471,8 @@ qemuBuildRomStr(virBufferPtr buf, virQEMUBuildBufferEscapeComma(buf, info->romfile); } } + + done: return 0; } =20 diff --git a/tests/qemuxml2argvdata/pci-rom-disabled.args b/tests/qemuxml2a= rgvdata/pci-rom-disabled.args new file mode 100644 index 0000000000..8c9dc2fb80 --- /dev/null +++ b/tests/qemuxml2argvdata/pci-rom-disabled.args @@ -0,0 +1,26 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/home/test \ +USER=3Dtest \ +LOGNAME=3Dtest \ +QEMU_AUDIO_DRV=3Dnone \ +/usr/bin/qemu-system-x86_64 \ +-name guest \ +-S \ +-machine pc,accel=3Dtcg,usb=3Doff,dump-guest-core=3Doff \ +-m 214 \ +-smp 1,sockets=3D1,cores=3D1,threads=3D1 \ +-uuid c7a5fdbd-edaf-9466-926a-d65c16db1809 \ +-display none \ +-no-user-config \ +-nodefaults \ +-chardev socket,id=3Dcharmonitor,path=3D/tmp/lib/domain--1-guest/monitor.s= ock,\ +server,nowait \ +-mon chardev=3Dcharmonitor,id=3Dmonitor,mode=3Dcontrol \ +-rtc base=3Dutc \ +-no-shutdown \ +-no-acpi \ +-boot c \ +-netdev user,id=3Dhostnet0 \ +-device virtio-net-pci,netdev=3Dhostnet0,id=3Dnet0,mac=3D52:54:00:24:a5:9f= ,bus=3Dpci.0,\ +addr=3D0x3,romfile=3D diff --git a/tests/qemuxml2argvdata/pci-rom-disabled.xml b/tests/qemuxml2ar= gvdata/pci-rom-disabled.xml new file mode 100644 index 0000000000..1c12052382 --- /dev/null +++ b/tests/qemuxml2argvdata/pci-rom-disabled.xml @@ -0,0 +1,20 @@ + + guest + c7a5fdbd-edaf-9466-926a-d65c16db1809 + 219100 + 1 + + hvm + + + /usr/bin/qemu-system-x86_64 + + + + + + + + + + diff --git a/tests/qemuxml2argvtest.c b/tests/qemuxml2argvtest.c index 74d930ebe2..ae9893a84e 100644 --- a/tests/qemuxml2argvtest.c +++ b/tests/qemuxml2argvtest.c @@ -1554,6 +1554,7 @@ mymain(void) DO_TEST_PARSE_ERROR("hostdev-mdev-invalid-target-address", QEMU_CAPS_DEVICE_VFIO_PCI); DO_TEST("pci-rom", NONE); + DO_TEST("pci-rom-disabled", NONE); =20 DO_TEST_FULL("restore-v2", "exec:cat", 7, 0, 0, GIC_NONE, NONE); DO_TEST_FULL("restore-v2-fd", "stdio", 7, 0, 0, GIC_NONE, NONE); diff --git a/tests/qemuxml2xmloutdata/pci-rom-disabled.xml b/tests/qemuxml2= xmloutdata/pci-rom-disabled.xml new file mode 100644 index 0000000000..6a95064ebf --- /dev/null +++ b/tests/qemuxml2xmloutdata/pci-rom-disabled.xml @@ -0,0 +1,29 @@ + + guest + c7a5fdbd-edaf-9466-926a-d65c16db1809 + 219100 + 219100 + 1 + + hvm + + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + + + + + + +
+ + + + + + diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 9e77b9fb13..6c1f0b0fa6 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -474,6 +474,7 @@ mymain(void) DO_TEST("hostdev-vfio", NONE); DO_TEST("hostdev-mdev-precreated", NONE); DO_TEST("pci-rom", NONE); + DO_TEST("pci-rom-disabled", NONE); DO_TEST("pci-serial-dev-chardev", NONE); =20 DO_TEST("encrypted-disk", NONE); --=20 2.14.3 -- libvir-list mailing list libvir-list@redhat.com https://www.redhat.com/mailman/listinfo/libvir-list