public inbox for pve-devel@lists.proxmox.com
 help / color / mirror / Atom feed
From: Thomas Lamprecht <t.lamprecht@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH v2 4/4] cfg2cmd: switch off ACPI hotplug on bridges for q35 VMs
Date: Wed,  3 Nov 2021 16:58:12 +0100	[thread overview]
Message-ID: <20211103155812.1461208-5-t.lamprecht@proxmox.com> (raw)
In-Reply-To: <20211103155812.1461208-1-t.lamprecht@proxmox.com>

See commit 17858a1695 (hw/acpi/ich9: Set ACPI PCI hot-plug as default
on Q35)[0] in upstream QEMU repository for details about why the change
was made.

As that change affects systemds predictable interface naming[1],
e.g., by going from a previously `ens18` name to `enp6s18`, it may
have rather bad effects for users that did not setup some .link files
to enforce a specific naming by an more stable information like the
NIC's MAC-Address

The alternative would be making the preferred mode of hotplug an
option like `hotplug-mode=<acpi|pcie>`, but it does not seems like
one would like to change that much in the first place...

Note the changes to the tests and especially the tests with q35
machines that did not change.

[0]: https://gitlab.com/qemu-project/qemu/-/commit/17858a1695
[1]: https://www.freedesktop.org/software/systemd/man/systemd.net-naming-scheme.html#Naming

Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
---

changes v1 -> v2:
* move checks into own method to avoid crowding cfg2cmd further
* ensure forced machine is parsed so that min_version can work
* only apply on `l26` ostype as non-linux machines normally are not
  affected by this change on fresh start

 PVE/QemuServer.pm                             | 29 +++++++++++++++++++
 .../q35-linux-hostpci-multifunction.conf.cmd  |  1 +
 test/cfg2cmd/q35-linux-hostpci.conf.cmd       |  1 +
 test/cfg2cmd/q35-simple.conf.cmd              |  1 +
 4 files changed, 32 insertions(+)

diff --git a/PVE/QemuServer.pm b/PVE/QemuServer.pm
index dc06171..091d103 100644
--- a/PVE/QemuServer.pm
+++ b/PVE/QemuServer.pm
@@ -2150,6 +2150,31 @@ sub new_meta_info_string {
     );
 }
 
+sub qemu_created_version_fixups {
+    my ($conf, $forcemachine, $kvmver) = @_;
+
+    my $meta = parse_meta_info($conf->{meta}) // {};
+    my $forced_vers = PVE::QemuServer::Machine::extract_version($forcemachine);
+
+    # check if we need to apply some handling for VMs that always use the latest machine version but
+    # had a machine version transition happen that affected HW such that, e.g., an OS config change
+    # would be required (we do not want to pin machine version for non-windows OS type)
+    if (
+	(!defined($conf->{machine}) || $conf->{machine} =~ m/^(?:pc|q35|virt)$/) # non-versioned machine
+	&& (!defined($meta->{'creation-qemu'}) || !min_version($meta->{'creation-qemu'}, 6, 1)) # created before 6.1
+	&& (!$forced_vers || min_version($forced_vers, 6, 1)) # handle snapshot-rollback/migrations
+	&& min_version($kvmver, 6, 1) # only need to apply the change since 6.1
+    ) {
+	my $q35 = PVE::QemuServer::Machine::machine_type_is_q35($conf);
+	if ($q35 && $conf->{ostype} && $conf->{ostype} eq 'l26') {
+	    # this changed to default-on in Q 6.1 for q35 machines, it will mess with PCI slot view
+	    # and thus with the predictable interface naming of systemd
+	    return ['-global', 'ICH9-LPC.acpi-pci-hotplug-with-bridge-support=off'];
+	}
+    }
+    return;
+}
+
 PVE::JSONSchema::register_format('pve-qm-usb-device', \&verify_usb_device);
 sub verify_usb_device {
     my ($value, $noerr) = @_;
@@ -3546,6 +3571,10 @@ sub config_to_command {
 	}
     }
 
+    if (defined(my $fixups = qemu_created_version_fixups($conf, $forcemachine, $kvmver))) {
+	push @$cmd, $fixups->@*;
+    }
+
     if ($conf->{vmgenid}) {
 	push @$devices, '-device', 'vmgenid,guid='.$conf->{vmgenid};
     }
diff --git a/test/cfg2cmd/q35-linux-hostpci-multifunction.conf.cmd b/test/cfg2cmd/q35-linux-hostpci-multifunction.conf.cmd
index 1f9beda..d393906 100644
--- a/test/cfg2cmd/q35-linux-hostpci-multifunction.conf.cmd
+++ b/test/cfg2cmd/q35-linux-hostpci-multifunction.conf.cmd
@@ -11,6 +11,7 @@
   -smbios 'type=1,uuid=3dd750ce-d910-44d0-9493-525c0be4e687' \
   -drive 'if=pflash,unit=0,format=raw,readonly=on,file=/usr/share/pve-edk2-firmware//OVMF_CODE.fd' \
   -drive 'if=pflash,unit=1,format=qcow2,id=drive-efidisk0,file=/var/lib/vz/images/100/vm-100-disk-1.qcow2' \
+  -global 'ICH9-LPC.acpi-pci-hotplug-with-bridge-support=off' \
   -smp '2,sockets=2,cores=1,maxcpus=2' \
   -nodefaults \
   -boot 'menu=on,strict=on,reboot-timeout=1000,splash=/usr/share/qemu-server/bootsplash.jpg' \
diff --git a/test/cfg2cmd/q35-linux-hostpci.conf.cmd b/test/cfg2cmd/q35-linux-hostpci.conf.cmd
index dd1bece..5da5c35 100644
--- a/test/cfg2cmd/q35-linux-hostpci.conf.cmd
+++ b/test/cfg2cmd/q35-linux-hostpci.conf.cmd
@@ -11,6 +11,7 @@
   -smbios 'type=1,uuid=3dd750ce-d910-44d0-9493-525c0be4e687' \
   -drive 'if=pflash,unit=0,format=raw,readonly=on,file=/usr/share/pve-edk2-firmware//OVMF_CODE.fd' \
   -drive 'if=pflash,unit=1,format=qcow2,id=drive-efidisk0,file=/var/lib/vz/images/100/vm-100-disk-1.qcow2' \
+  -global 'ICH9-LPC.acpi-pci-hotplug-with-bridge-support=off' \
   -smp '2,sockets=2,cores=1,maxcpus=2' \
   -nodefaults \
   -boot 'menu=on,strict=on,reboot-timeout=1000,splash=/usr/share/qemu-server/bootsplash.jpg' \
diff --git a/test/cfg2cmd/q35-simple.conf.cmd b/test/cfg2cmd/q35-simple.conf.cmd
index 5045caf..1c97a89 100644
--- a/test/cfg2cmd/q35-simple.conf.cmd
+++ b/test/cfg2cmd/q35-simple.conf.cmd
@@ -11,6 +11,7 @@
   -smbios 'type=1,uuid=3dd750ce-d910-44d0-9493-525c0be4e687' \
   -drive 'if=pflash,unit=0,format=raw,readonly=on,file=/usr/share/pve-edk2-firmware//OVMF_CODE.fd' \
   -drive 'if=pflash,unit=1,format=qcow2,id=drive-efidisk0,file=/var/lib/vz/images/100/vm-100-disk-1.qcow2' \
+  -global 'ICH9-LPC.acpi-pci-hotplug-with-bridge-support=off' \
   -smp '2,sockets=1,cores=2,maxcpus=2' \
   -nodefaults \
   -boot 'menu=on,strict=on,reboot-timeout=1000,splash=/usr/share/qemu-server/bootsplash.jpg' \
-- 
2.30.2





  parent reply	other threads:[~2021-11-03 15:58 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-11-03 15:58 [pve-devel] [PATCH v2 0/4] <add meta info and bandaid for QEMU 6.1 and unpinned q35 machine backward compat Thomas Lamprecht
2021-11-03 15:58 ` [pve-devel] [PATCH v2 1/4] config: add new meta property withe creation time Thomas Lamprecht
2021-11-03 15:58 ` [pve-devel] [PATCH v2 2/4] config: meta: also save the QEMU version installed during creation Thomas Lamprecht
2021-11-03 15:58 ` [pve-devel] [PATCH v2 3/4] tests: cfg2cmd: add a few q35 related tests Thomas Lamprecht
2021-11-03 15:58 ` Thomas Lamprecht [this message]
2021-11-04  8:05 ` [pve-devel] [PATCH v2 0/4] <add meta info and bandaid for QEMU 6.1 and unpinned q35 machine backward compat Dominik Csapak
2021-11-04 14:16 ` Wolfgang Bumiller
2021-11-04 14:33 ` [pve-devel] applied-series: " Thomas Lamprecht

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20211103155812.1461208-5-t.lamprecht@proxmox.com \
    --to=t.lamprecht@proxmox.com \
    --cc=pve-devel@lists.proxmox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
Service provided by Proxmox Server Solutions GmbH | Privacy | Legal