<div dir="auto">DanPB, </div><div dir="auto">Could you please reiterate the suggestion regarding the placement of the pci root hotplug xml you made in the irc channel?</div><div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Fri, Sep 24, 2021 at 02:16 Laine Stump <<a href="mailto:laine@redhat.com">laine@redhat.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On 9/11/21 11:26 PM, Ani Sinha wrote:<br>
> Hi all:<br>
> <br>
> This patchset introduces libvirt xml support for the following two pm conf<br>
> options:<br>
> <br>
> <pm><br>
>    <acpi-hotplug-bridge enabled='no'/><br>
>    <acpi-root-hotplug enabled='yes'/><br>
> </pm><br>
<br>
(before I get into a more radical discussion about different options - <br>
since we aren't exactly duplicating the QEMU option name anyway, what if <br>
we made these names more consistent, e.g. "acpi-hotplug-bridge" and <br>
"acpi-hotplug-root"?)<br>
<br>
I've thought quite a bit about whether to put these attributes here, or <br>
somewhere else, and I'm still undecided.<br>
<br>
My initial reaction to this was "PM == Power Management, and power <br>
management is all about suspend mode support. Hotplug isn't power <br>
management." But then you look at the name of the QEMU option and PM is <br>
right there in the name, and I guess it's *kind of related* (effectively <br>
suspending/resuming a single device), so maybe I'm thinking too narrowly.<br>
<br>
So are there alternate places that might fit the purpose of these new <br>
options better, rather than directly mimicking the QEMU option placement <br>
(for better or worse)? A couple alternative possibilities:<br>
<br>
1) ****<br>
<br>
One possibility would be to include these new flags within the existing <br>
<acpi> subelement of <features>, which is already used to control <br>
whether the guest exposes ACPI to the guest *at all* (via adding <br>
"-no-acpi" to the QEMU commandline when <acpi> is missing - NB: this <br>
feature flag is currently supported only on x86 and aarch64 QEMU <br>
platforms, and ignored for all other hypervisors).<br>
<br>
Possibly the new flags could be put in something like this:<br>
<br>
<features><br>
   <acpi><br>
     <hotplug-bridge enabled='no'/><br>
     <hotplug-root enabled='yes'/><br>
   </acpi><br>
   ...<br>
</features><br>
<br>
But:<br>
<br>
* currently there are no subelements to <acpi>. So this isn't "extending <br>
according to an existing pattern".<br>
<br>
* even though the <features> element uses presence of a subelement to <br>
indicate "enabled" and absence of the subelement to indicate "disabled". <br>
But in the case of these new acpi bridge options we would need to <br>
explicitly have the "enabled='yes/no'" rather than just using presence <br>
of the option to mean "enabled" and absence to mean "disabled" because <br>
the default for "root-hotplug" up until now has been *enabled*, and the <br>
default for hotplug-bridge is different depending on machinetype. We <br>
need to continue working properly (and identically) with old/existing <br>
XML, but if we didn't have an "enabled" attribute for these new flags, <br>
there would be no way to tell the difference between "not specified" and <br>
"disabled", and so no way to disable the feature for a QEMU where the <br>
default was "enabled". (Why does this matter? Because I don't like the <br>
inconsistency that would arise from some feature flags using absense to <br>
mean "disabled" and some using it to mean "use the default".)<br>
<br>
* Having something in <features> in the domain XML kind of implies that <br>
the associated capability flags should be represented in the <features> <br>
section of the domain capabilities. For example, <acpi/> is listed under <br>
<features> in the output of virsh capabilities, separately from the flag <br>
indicating presence of the -no-acpi option. I'm not sure if we would <br>
need to add something there for these options if we moved them into <br>
<features> (seems a bit redundant to me to have it in both places, but <br>
I'm sure there are $reasons).<br>
<br>
<br>
2) *****<br>
<br>
Alternately, there is an <acpi> subelement of <os>, which is currently <br>
used to add a SLIC table (some sort of software license table, which I'd <br>
never heard of before) using QEMU's -acpitable commandline option. It is <br>
also used somehow by the Xen driver.<br>
<br>
<os><br>
   <acpi><br>
     <table type='slic'>/path/to/slic.dat</table><br>
     <hotplug-bridge enabled='no'/><br>
     <hotplug-root enabled='yes'/><br>
   </acpi><br>
   ...<br>
</os><br>
<br>
My problem with adding these new PCI controller acpi options to os/acpi <br>
is simply that it's in the <os> subelement, which is claimed elsewhere <br>
to be intended for OS boot options, and is used for things like <br>
specifying the path to a kernel / initrd to boot from.<br>
<br>
3) ****<br>
<br>
A third option, suggested somewhere by Ani, would be to make a <br>
completely new top-level element, called something like <acpiHotplug> <br>
that would have separate attributes for the two flags, e.g.:<br>
<br>
    <acpiHotplug bridge='yes' root='yes'/><br>
<br>
I dislike new toplevel options because they just seem so adhoc, as if <br>
the XML namespace is a cluttered, disorganized room. That reminds me too <br>
much of my own workspace, which is just... depressing.<br>
<br>
****<br>
<br>
Since I always seem to spend *way too much time* worrying about naming, <br>
only to have it come out wrong in the end anyway, I'm looking for some <br>
other opinions. Counting the version that is in Ani's patch currently as <br>
option "0", which option do you all think is the best? Or is it <br>
completely unimportant?<br>
<br>
> The above two options are only available for qemu driver and that too for x86<br>
> guests only. Both of them are global options.<br>
> <br>
> ``acpi-hotplug-bridge`` option enables or disables ACPI hotplug support for cold<br>
> plugged bridges. Examples of cold plugged bridges include PCI-PCI bridge<br>
> (pci-bridge controller) for pc machines and pcie-root-port controller for q35<br>
> machines. The corresponding commandline options to qemu for x86 guests are:<br>
<br>
The "cold plugged bridges" term here throws me for a loop - it implies <br>
that hotplugging bridges is something that's supported, and I think it <br>
still isn't. Of course this is just the cover letter, so it won't go <br>
into git anywhere, but I think it should be enough to say "enables ACPI <br>
hotplug into non-root bus PCI bridges/ports".<br>
<br>
> <br>
> (pc machines): -global PIIX4_PM.acpi-pci-hotplug-with-bridge-support=<off/on><br>
> (q35 machines): -global ICH9-LPC.acpi-pci-hotplug-with-bridge-support=<off/on><br>
<br>
So I'm curious - if the QEMU commandline also included "-no-acpi" along <br>
with these, what would happen? Would it be silently ignored? Generate an <br>
error? Or does -no-acpi only control the suspend support, and acpi <br>
hotplug is still available?<br>
<br>
> <br>
> Being global options, no other bridge specific options for pci-bridge<br>
> controller or pcie-root-port controllers are required. For pc machine type in<br>
> x86, this option is available in qemu for a long time, from version 2.1.<br>
> Please see the changes in qemu.git:<br>
> <br>
> 9e047b982452c6 ("piix4: add acpi pci hotplug support")<br>
<br>
Interesting. So how was hotplug handled before this? With SHPC? I know <br>
there must be *some* kind of hotplug support in older QEMU, because <br>
RHEL6 QEMU supported hotplug, and it was based on qemu 0.12 or something <br>
ancient like that...<br>
<br>
> 133a2da488062e ("pc: acpi: generate AML only for PCI0 devices if PCI bridge hotplug is disabled")<br>
> <br>
> For q35 machine type, this was introduced in qemu 6.1 with the following<br>
> changes in qemu.git:<br>
> <br>
> (a) c0e427d6eb5fef ("hw/acpi/ich9: Enable ACPI PCI hot-plug")<br>
> (b) 17858a16950860 ("hw/acpi/ich9: Set ACPI PCI hot-plug as default on Q35")<br>
> <br>
> The reasons for enabling ACPI based hotplug for PCIe (q35) based machines (as<br>
> opposed to native hotplug) for bridges are outlined in (b). It is possible that<br>
> some users might still want to use native hotplug on PCIe [1]. Therefore,<br>
> this conf option enables users to choose either ACPI based hotplug or native<br>
> hotplug for cold plugged bridges (for example for pcie root port controller<br>
> in q35 machines).<br>
> <br>
> ``acpi-root-hotplug`` option enables or disables ACPI based hotplug for PCI root<br>
> bus (pci-root controller). This option is only available for pc machine type.<br>
> The corresponding commandline option to qemu for x86 guests is:<br>
> <br>
> -global PIIX4_PM.acpi-root-pci-hotplug=<off/on><br>
> <br>
> This additional option enables users to disable hotplug for all devices in the<br>
> system without adding an additional PCI-PCI bridge, putting the devices behind<br>
> the bridge and using the existing ``acpi-hotplug-bridge`` option to disable<br>
> hotplug on that bridge. This feature was introduced from qemu version 5.2 with<br>
> the following change in qemu.git:<br>
> <br>
> 3d7e78aa7777f ("Introduce a new flag for i440fx to disable PCI hotplug on the root bus")<br>
> <br>
> The above qemu commit describes some compelling reasons why users might to<br>
> disable hotplug on PCI root buses [2].<br>
> <br>
> A brief summary of the patches:<br>
> <br>
>> [PATCH v3 1/5] qemu: capablities: detect presence of<br>
>> [PATCH v3 2/5] qemu: capablities: detect presence of<br>
> Patches 1 and 2 implement support for qemu capability checks for the above<br>
> config options.<br>
> <br>
>> [PATCH v3 3/5] conf: introduce acpi-hotplug-bridge and<br>
> Patch 3 actually adds the config option to the schema and adds related unit<br>
> tests.<br>
> <br>
>> [PATCH v3 4/5] qemu: command: add support for qemu options that<br>
> Patch 4 adds the backend qemu commandline support for the options. It also adds<br>
> relevant unit tests for the same.<br>
> <br>
>> [PATCH v3 5/5] NEWS: add new acpi pci hotplug options in the release<br>
> Patch 5 adds the release notes for the next libvirt release.<br>
> <br>
> <br>
> Changelog:<br>
> v1: initial implementation. Had some bugs and missed some unit tests.<br>
> v2: fixed bugs and added additional missing unit tests.<br>
> v3: reorganized the patches as per Laine's suggestion. Added more<br>
>      details in commit messages. Added conf description in formatdomain.rst.<br>
>      Added changelog for next release.<br>
>      <br>
> <br>
> Notes:<br>
> <br>
> [1] One concrete example of why one might still want to use native hotplug with<br>
> pcie-root-port controller is the fact that we are still discovering issues with<br>
> acpi hotplug on PCIE.<br>
<br>
Yes, sigh. I recall someone saying something like "if we switch to ACPI <br>
hotplug then all these bugs just go away and everything works" or <br>
something like that. Reality never matches the ideal picture we put in <br>
our brains.<br>
<br>
At least ACPI hotplug is only the default on new machinetypes (doesn't <br>
help much for management platforms that always just use "q35" every time <br>
they start a guest). And it can also cause problems with distro-specific <br>
machinetypes in downstream distros when they are rebased: <br>
<a href="https://bugzilla.redhat.com/2006409" rel="noreferrer" target="_blank">https://bugzilla.redhat.com/2006409</a><br>
<br>
> One such issue is:<br>
> <a href="https://lists.gnu.org/archive/html/qemu-devel/2021-09/msg02146.html" rel="noreferrer" target="_blank">https://lists.gnu.org/archive/html/qemu-devel/2021-09/msg02146.html</a><br>
> Another reason is that users have been using native hotplug on pcie root ports<br>
> up until now. They have built and tested their systems based on native hotplug.<br>
> They may not want to suddenly move to acpi based hotplug just because it is now<br>
> the default in qemu. Supporting the option to chose one or the other through<br>
> libvirt makes things simpler for end users.<br>
> <br>
> [2] The use case scenario described by Laine in<br>
> <a href="https://listman.redhat.com/archives/libvir-list/2020-February/msg00110.html" rel="noreferrer" target="_blank">https://listman.redhat.com/archives/libvir-list/2020-February/msg00110.html</a><br>
> intentionally does not discuss i440fx and focusses solely on q35. I do realize<br>
> that redhat has moved on from i440fx and currently efforts for new features<br>
> are concentrated on q35 machines only. We have had some hard debates on this<br>
> on the qemu mailing list before. The fact of the matter is that i440fx is<br>
> not at 1-1 parity with q35. There are many users who are currenly using i440fx<br>
> and are simply not ready to move to q35 without sacrificing some<br>
> existing features they support today. For example<br>
> <a href="https://wiki.qemu.org/images/4/4e/Q35.pdf" rel="noreferrer" target="_blank">https://wiki.qemu.org/images/4/4e/Q35.pdf</a> lists some of q35 limitations.<br>
<br>
To be fair, aside from "support for Win2000/WinXP", none of the items on <br>
the "limitations" page of that slide deck is something that's impossible <br>
to do with a Q35 machinetype; it's just that accomplishing some things <br>
may be more complicated. But I understand your point. Mainly I brought <br>
it up because I wanted to be sure that we're adding these to fulfill an <br>
actual need, rather than just adding bulk for the sake of completeness, <br>
or to satisfy curiosity.<br>
<br>
> <a href="https://www.linux-kvm.org/images/0/06/2012-forum-Q35.pdf" rel="noreferrer" target="_blank">https://www.linux-kvm.org/images/0/06/2012-forum-Q35.pdf</a> provides more<br>
> information on the differences. Hence we need to solve the issue Laine has<br>
> described in the above email for i440fx without adding additional bridges.<br>
> <br>
> Further, in  Daniel Berrange's words from :<br>
> <a href="https://lists.gnu.org/archive/html/qemu-devel/2020-04/msg03012.html" rel="noreferrer" target="_blank">https://lists.gnu.org/archive/html/qemu-devel/2020-04/msg03012.html</a><br>
> <br>
> "From the upstream POV, there's been no decision / agreement to phase<br>
> out PIIX, this is purely a RHEL downstream decision & plan. If other<br>
> distros / users have a different POV, and find the feature useful, we<br>
> should accept the patch if it meets the normal QEMU patch requirements.<br>
> "<br>
> <br>
> Also to be noted that I have already experimented this qemu commandline option<br>
> using libvirt passthrough feature as has been documented in<br>
> <a href="http://blog.vmsplice.net/2011/04/how-to-pass-qemu-command-line-options.html" rel="noreferrer" target="_blank">http://blog.vmsplice.net/2011/04/how-to-pass-qemu-command-line-options.html</a><br>
> This was only meant to be a short term solution until libvirt started<br>
> supporting this natively. Supporting this option through libvirt would simplify<br>
> their use case as well as add capability validations<br>
> and graceful failure scenarios in case qemu did not support the option.<br>
> <br>
> [3] Finally, I implemented support for ``acpi-root-hotplug`` option in Qemu.<br>
> Since adding the support for this option, I have not run away :-) I am still<br>
> around, fixing other issues in the same subsystem in qemu and also now I have<br>
> added myself as a reviewer of patches in this area. I will also be trying to<br>
> support/maintain this new xml conf option in libvirt to the extent I can in<br>
> future with the help of other experienced maintainers. Obviously this is all<br>
> freelance work at this moment and is highly dependent on available free time.<br>
> <br>
> <br>
<br>
Since I don't follow qemu-devel closely, I didn't have prior knowledge <br>
of exactly what the options did, and it was unclear in the earlier <br>
versions of your patches that what <acpi-hotplug-bridge enabled='no'/> <br>
did was to disable ACPI hotplug for the entire guest (which on Q35 means <br>
that native PCIe hotplug will be found/used, and on 440fx means that <br>
hotplug won't be possible (unless SHPC hotplugged is enabled)). Your <br>
exaplanation and documentation in this spin of the patches makes that <br>
all clear though, so I'm beyond the "what does this do and do we need <br>
it?" stage to the "are there any problems with the code?" stage, and <br>
that's what I'll try to address in my review of the patches.<br>
<br>
</blockquote></div></div>