From nobody Sat Feb 7 07:31:41 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) client-ip=170.10.133.124; envelope-from=libvir-list-bounces@redhat.com; helo=us-smtp-delivery-124.mimecast.com; Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of redhat.com designates 170.10.133.124 as permitted sender) smtp.mailfrom=libvir-list-bounces@redhat.com; dmarc=pass(p=none dis=none) header.from=redhat.com ARC-Seal: i=1; a=rsa-sha256; t=1617812791; cv=none; d=zohomail.com; s=zohoarc; b=bq8/ZKGDf8xGtKywTNVgVTLPw0HmKWPewzH4yrtMjI5uyHOt1mujLg8bpfW2iJHCuQHtNWXHfmiiYNklQftEhF7s9BN7EUYorF2VnG75sVkin+pUm+BeiupTXqw1VMGP6NgvQL2UZw2KHEM5NadJIDuEEanjrXPY68tPCpBUm+0= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1617812791; h=Content-Type:Content-Transfer-Encoding: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=ArUpT9Y4AUM3sX8gCrP0GDp3aJm0aTtD8DQ5BHXYYDA=; b=RYa7qP5i6DANw9DYu1KJx+lXrwE2Tv2hwsKbSrtHBz9qtG6hhwmANInE5tiD2WJoImYHwhQn2fMYyx5GhlbPyGjfeCNnStCiRrGoh3Cv0zXGMQ6Mo7mrggGViyF5SFjytF5nDorWZiWnD3hKnq+oEhfzOWueH6L5yOIBs/3ocoQ= 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) header.from= 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 161781279155427.019778495525657; Wed, 7 Apr 2021 09:26:31 -0700 (PDT) Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-38-XgcbyIOaOR60FGvhFtOVgg-1; Wed, 07 Apr 2021 12:26:27 -0400 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.12]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 45861E99C1; Wed, 7 Apr 2021 16:26:23 +0000 (UTC) Received: from colo-mx.corp.redhat.com (colo-mx02.intmail.prod.int.phx2.redhat.com [10.5.11.21]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 1FF45610AF; Wed, 7 Apr 2021 16:26:23 +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 D6ACF55344; Wed, 7 Apr 2021 16:26:22 +0000 (UTC) Received: from smtp.corp.redhat.com (int-mx06.intmail.prod.int.phx2.redhat.com [10.5.11.16]) by lists01.pubmisc.prod.ext.phx2.redhat.com (8.13.8/8.13.8) with ESMTP id 137GOpws011030 for ; Wed, 7 Apr 2021 12:24:51 -0400 Received: by smtp.corp.redhat.com (Postfix) id 38DB11822A; Wed, 7 Apr 2021 16:24:51 +0000 (UTC) Received: from localhost.localdomain.com (ovpn-115-28.ams2.redhat.com [10.36.115.28]) by smtp.corp.redhat.com (Postfix) with ESMTP id 819001DB; Wed, 7 Apr 2021 16:24:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1617812790; 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: in-reply-to:in-reply-to:references:references:list-id:list-help: list-unsubscribe:list-subscribe:list-post; bh=ArUpT9Y4AUM3sX8gCrP0GDp3aJm0aTtD8DQ5BHXYYDA=; b=My0Kj/jPG6FV60sDLIAh+wojXVIcRf9YyeHz3tYP8z1H2i3Q5kRw+K5saetWtkIUydvaLn e88R1xq11sXFSCXGf3PAN+3XKjQL9XmIZr2XFWgImSYmtXVLzC1HVmqriRMXvzEw1CUlp/ 3ifAtlOj8/XAXmFxVfHtcrulTU+nrEA= X-MC-Unique: XgcbyIOaOR60FGvhFtOVgg-1 From: =?UTF-8?q?Daniel=20P=2E=20Berrang=C3=A9?= To: libvir-list@redhat.com Subject: [libvirt PATCH v2 5/5] qemu: wire up command line support for ACPI index Date: Wed, 7 Apr 2021 17:24:40 +0100 Message-Id: <20210407162440.421508-6-berrange@redhat.com> In-Reply-To: <20210407162440.421508-1-berrange@redhat.com> References: <20210407162440.421508-1-berrange@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.16 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.12 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) This makes it possible to enable stable NIC device names in most modern Linux distros. Signed-off-by: Daniel P. Berrang=C3=A9 --- src/qemu/qemu_command.c | 2 + src/qemu/qemu_validate.c | 35 +++++++++ .../devices-acpi-index.x86_64-latest.args | 57 +++++++++++++++ tests/qemuxml2argvdata/devices-acpi-index.xml | 62 ++++++++++++++++ tests/qemuxml2argvtest.c | 2 + .../devices-acpi-index.x86_64-latest.xml | 73 +++++++++++++++++++ tests/qemuxml2xmltest.c | 2 + 7 files changed, 233 insertions(+) create mode 100644 tests/qemuxml2argvdata/devices-acpi-index.x86_64-latest= .args create mode 100644 tests/qemuxml2argvdata/devices-acpi-index.xml create mode 100644 tests/qemuxml2xmloutdata/devices-acpi-index.x86_64-late= st.xml diff --git a/src/qemu/qemu_command.c b/src/qemu/qemu_command.c index 02f9d16f63..45eb0dc976 100644 --- a/src/qemu/qemu_command.c +++ b/src/qemu/qemu_command.c @@ -420,6 +420,8 @@ qemuBuildDeviceAddressStr(virBufferPtr buf, virBufferAsprintf(buf, ",addr=3D0x%x", info->addr.pci.slot); if (info->addr.pci.function !=3D 0) virBufferAsprintf(buf, ".0x%x", info->addr.pci.function); + if (info->acpiIndex !=3D 0) + virBufferAsprintf(buf, ",acpi-index=3D%u", info->acpiIndex); } break; =20 diff --git a/src/qemu/qemu_validate.c b/src/qemu/qemu_validate.c index 09778085a8..27afcab9aa 100644 --- a/src/qemu/qemu_validate.c +++ b/src/qemu/qemu_validate.c @@ -1069,6 +1069,32 @@ qemuValidateDomainDefPanic(const virDomainDef *def, } =20 =20 +static int +qemuValidateDomainDeviceInfo(virDomainDefPtr def G_GNUC_UNUSED, + virDomainDeviceDefPtr dev G_GNUC_UNUSED, + virDomainDeviceInfoPtr info, + void *opaque) +{ + virQEMUCapsPtr qemuCaps =3D opaque; + + if (info->acpiIndex) { + if (!virQEMUCapsGet(qemuCaps, QEMU_CAPS_ACPI_INDEX)) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("ACPI index is not supported with this QEMU")= ); + return -1; + } + + if (info->type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_NONE && + info->type !=3D VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, "%s", + _("ACPI index is only supported for PCI devices= ")); + return -1; + } + } + + return 0; +} + int qemuValidateDomainDef(const virDomainDef *def, void *opaque, @@ -1235,6 +1261,15 @@ qemuValidateDomainDef(const virDomainDef *def, return -1; } =20 + /* Explicitly discarding 'const' from 'def' is ok because + * we know our callback qemuValidateDomainDeviceInfo will + * not modify it + */ + if (virDomainDeviceInfoIterate((virDomainDefPtr)def, + qemuValidateDomainDeviceInfo, + qemuCaps) < 0) + return -1; + return 0; } =20 diff --git a/tests/qemuxml2argvdata/devices-acpi-index.x86_64-latest.args b= /tests/qemuxml2argvdata/devices-acpi-index.x86_64-latest.args new file mode 100644 index 0000000000..07a8b0d189 --- /dev/null +++ b/tests/qemuxml2argvdata/devices-acpi-index.x86_64-latest.args @@ -0,0 +1,57 @@ +LC_ALL=3DC \ +PATH=3D/bin \ +HOME=3D/tmp/lib/domain--1-fdr-br \ +USER=3Dtest \ +LOGNAME=3Dtest \ +XDG_DATA_HOME=3D/tmp/lib/domain--1-fdr-br/.local/share \ +XDG_CACHE_HOME=3D/tmp/lib/domain--1-fdr-br/.cache \ +XDG_CONFIG_HOME=3D/tmp/lib/domain--1-fdr-br/.config \ +/usr/bin/qemu-system-x86_64 \ +-name guest=3Dfdr-br,debug-threads=3Don \ +-S \ +-object '{"qom-type":"secret","id":"masterKey0","format":"raw",\ +"file":"/tmp/lib/domain--1-fdr-br/master-key.aes"}' \ +-machine pc-i440fx-5.0,accel=3Dtcg,usb=3Doff,dump-guest-core=3Doff,\ +memory-backend=3Dpc.ram \ +-cpu qemu64 \ +-m 2048 \ +-object '{"qom-type":"memory-backend-ram","id":"pc.ram","size":2147483648}= ' \ +-overcommit mem-lock=3Doff \ +-smp 2,sockets=3D2,cores=3D1,threads=3D1 \ +-uuid 3ec6cbe1-b5a2-4515-b800-31a61855df41 \ +-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 strict=3Don \ +-device piix3-usb-uhci,id=3Dusb,bus=3Dpci.0,addr=3D0x1.0x2 \ +-blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/test.img",\ +"node-name":"libvirt-2-storage","auto-read-only":true,"discard":"unmap"}' \ +-blockdev '{"node-name":"libvirt-2-format","read-only":false,"driver":"raw= ",\ +"file":"libvirt-2-storage"}' \ +-device virtio-blk-pci,bus=3Dpci.0,addr=3D0x3,acpi-index=3D1,drive=3Dlibvi= rt-2-format,\ +id=3Dvirtio-disk0,bootindex=3D1 \ +-blockdev '{"driver":"file","filename":"/var/lib/libvirt/images/test1.img"= ,\ +"node-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 virtio-blk-pci,bus=3Dpci.0,addr=3D0x4,acpi-index=3D42,drive=3Dlibv= irt-1-format,\ +id=3Dvirtio-disk1 \ +-netdev user,id=3Dhostnet0 \ +-device virtio-net-pci,netdev=3Dhostnet0,id=3Dnet0,mac=3D00:11:22:33:44:55= ,bus=3Dpci.0,\ +addr=3D0x5,acpi-index=3D100 \ +-netdev user,id=3Dhostnet1 \ +-device virtio-net-pci,netdev=3Dhostnet1,id=3Dnet1,mac=3D00:11:22:33:44:55= ,bus=3Dpci.0,\ +addr=3D0x7,acpi-index=3D200 \ +-netdev user,id=3Dhostnet2 \ +-device virtio-net-pci,netdev=3Dhostnet2,id=3Dnet2,mac=3D00:11:22:33:44:55= ,bus=3Dpci.0,\ +addr=3D0x8,acpi-index=3D300 \ +-audiodev id=3Daudio1,driver=3Dnone \ +-device cirrus-vga,id=3Dvideo0,bus=3Dpci.0,addr=3D0x2,acpi-index=3D1729 \ +-device virtio-balloon-pci,id=3Dballoon0,bus=3Dpci.0,addr=3D0x6 \ +-sandbox on,obsolete=3Ddeny,elevateprivileges=3Ddeny,spawn=3Ddeny,\ +resourcecontrol=3Ddeny \ +-msg timestamp=3Don diff --git a/tests/qemuxml2argvdata/devices-acpi-index.xml b/tests/qemuxml2= argvdata/devices-acpi-index.xml new file mode 100644 index 0000000000..5d0176e7fe --- /dev/null +++ b/tests/qemuxml2argvdata/devices-acpi-index.xml @@ -0,0 +1,62 @@ + + fdr-br + 3ec6cbe1-b5a2-4515-b800-31a61855df41 + 2097152 + 2097152 + 2 + + hvm + + + + + + + + + destroy + restart + restart + + /usr/bin/qemu-system-x86_64 + + + + + +
+ + + + + + +
+ + + + + + + + + + + + + + + + + + +