mirror of
https://gitlab.com/libvirt/libvirt.git
synced 2025-04-26 07:04:42 +00:00
conf: new attribute "hotplug" for pci controllers
a <controller type='pci'...> element can now have a "hotplug" attribute in the <target> subelement. This is intended to control whether or not the slot(s) of the controller support hotplugging/unplugging a device: <controller type='pci' model='pcie-root-port'> <target hotplug='off'/> </controller> The default value of hotplug is "on". Since support for configuring such an option is hypervisor-dependent (and will vary among different types of PCI controllers even on a single hypervisor), no validation is done in this patch - that validation will be done in the patch that wires support for the setting into the hypervisor. Signed-off-by: Laine Stump <laine@redhat.com> Reviewed-by: Michal Privoznik <mprivozn@redhat.com>
This commit is contained in:
parent
cbd4ab4cc6
commit
78f4d5e6f1
@ -4726,6 +4726,17 @@
|
|||||||
which is visible to the virtual machine. If set, port must be
|
which is visible to the virtual machine. If set, port must be
|
||||||
between 0 and 255.
|
between 0 and 255.
|
||||||
</dd>
|
</dd>
|
||||||
|
<dt><code>hotplug</code></dt>
|
||||||
|
<dd>
|
||||||
|
pcie-root-port and pcie-switch-downstream-port controllers can
|
||||||
|
also have a <code>hotplug</code> attribute in
|
||||||
|
the <code><target></code> subelement, which is used to
|
||||||
|
disable hotplug/unplug of devices on a particular
|
||||||
|
controller. The default setting of <code>hotplug</code>
|
||||||
|
is <code>on</code>; it should be set to <code>off</code> to
|
||||||
|
disable hotplug/unplug of devices on a particular controller.
|
||||||
|
<span class="since">Since 6.3.0</span>
|
||||||
|
</dd>
|
||||||
<dt><code>busNr</code></dt>
|
<dt><code>busNr</code></dt>
|
||||||
<dd>
|
<dd>
|
||||||
pci-expander-bus and pcie-expander-bus controllers can have an
|
pci-expander-bus and pcie-expander-bus controllers can have an
|
||||||
|
@ -2475,6 +2475,11 @@
|
|||||||
<ref name='uint8'/>
|
<ref name='uint8'/>
|
||||||
</attribute>
|
</attribute>
|
||||||
</optional>
|
</optional>
|
||||||
|
<optional>
|
||||||
|
<attribute name='hotplug'>
|
||||||
|
<ref name="virOnOff"/>
|
||||||
|
</attribute>
|
||||||
|
</optional>
|
||||||
<optional>
|
<optional>
|
||||||
<element name='node'>
|
<element name='node'>
|
||||||
<ref name='unsignedInt'/>
|
<ref name='unsignedInt'/>
|
||||||
|
@ -11055,6 +11055,7 @@ virDomainControllerDefParseXML(virDomainXMLOptionPtr xmlopt,
|
|||||||
g_autofree char *port = NULL;
|
g_autofree char *port = NULL;
|
||||||
g_autofree char *busNr = NULL;
|
g_autofree char *busNr = NULL;
|
||||||
g_autofree char *targetIndex = NULL;
|
g_autofree char *targetIndex = NULL;
|
||||||
|
g_autofree char *hotplug = NULL;
|
||||||
g_autofree char *ioeventfd = NULL;
|
g_autofree char *ioeventfd = NULL;
|
||||||
g_autofree char *portsStr = NULL;
|
g_autofree char *portsStr = NULL;
|
||||||
g_autofree char *iothread = NULL;
|
g_autofree char *iothread = NULL;
|
||||||
@ -11126,6 +11127,7 @@ virDomainControllerDefParseXML(virDomainXMLOptionPtr xmlopt,
|
|||||||
chassis = virXMLPropString(cur, "chassis");
|
chassis = virXMLPropString(cur, "chassis");
|
||||||
port = virXMLPropString(cur, "port");
|
port = virXMLPropString(cur, "port");
|
||||||
busNr = virXMLPropString(cur, "busNr");
|
busNr = virXMLPropString(cur, "busNr");
|
||||||
|
hotplug = virXMLPropString(cur, "hotplug");
|
||||||
targetIndex = virXMLPropString(cur, "index");
|
targetIndex = virXMLPropString(cur, "index");
|
||||||
processedTarget = true;
|
processedTarget = true;
|
||||||
}
|
}
|
||||||
@ -11362,6 +11364,17 @@ virDomainControllerDefParseXML(virDomainXMLOptionPtr xmlopt,
|
|||||||
}
|
}
|
||||||
def->opts.pciopts.numaNode = numaNode;
|
def->opts.pciopts.numaNode = numaNode;
|
||||||
}
|
}
|
||||||
|
if (hotplug) {
|
||||||
|
int val = virTristateSwitchTypeFromString(hotplug);
|
||||||
|
|
||||||
|
if (val <= 0) {
|
||||||
|
virReportError(VIR_ERR_XML_ERROR,
|
||||||
|
_("PCI controller unrecognized hotplug setting '%s'"),
|
||||||
|
hotplug);
|
||||||
|
goto error;
|
||||||
|
}
|
||||||
|
def->opts.pciopts.hotplug = val;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case VIR_DOMAIN_CONTROLLER_TYPE_XENBUS: {
|
case VIR_DOMAIN_CONTROLLER_TYPE_XENBUS: {
|
||||||
g_autofree char *gntframes = virXMLPropString(node, "maxGrantFrames");
|
g_autofree char *gntframes = virXMLPropString(node, "maxGrantFrames");
|
||||||
@ -25375,7 +25388,8 @@ virDomainControllerDefFormat(virBufferPtr buf,
|
|||||||
def->opts.pciopts.port != -1 ||
|
def->opts.pciopts.port != -1 ||
|
||||||
def->opts.pciopts.busNr != -1 ||
|
def->opts.pciopts.busNr != -1 ||
|
||||||
def->opts.pciopts.targetIndex != -1 ||
|
def->opts.pciopts.targetIndex != -1 ||
|
||||||
def->opts.pciopts.numaNode != -1) {
|
def->opts.pciopts.numaNode != -1 ||
|
||||||
|
def->opts.pciopts.hotplug != VIR_TRISTATE_SWITCH_ABSENT) {
|
||||||
virBufferAddLit(&childBuf, "<target");
|
virBufferAddLit(&childBuf, "<target");
|
||||||
if (def->opts.pciopts.chassisNr != -1)
|
if (def->opts.pciopts.chassisNr != -1)
|
||||||
virBufferAsprintf(&childBuf, " chassisNr='%d'",
|
virBufferAsprintf(&childBuf, " chassisNr='%d'",
|
||||||
@ -25392,6 +25406,10 @@ virDomainControllerDefFormat(virBufferPtr buf,
|
|||||||
if (def->opts.pciopts.targetIndex != -1)
|
if (def->opts.pciopts.targetIndex != -1)
|
||||||
virBufferAsprintf(&childBuf, " index='%d'",
|
virBufferAsprintf(&childBuf, " index='%d'",
|
||||||
def->opts.pciopts.targetIndex);
|
def->opts.pciopts.targetIndex);
|
||||||
|
if (def->opts.pciopts.hotplug != VIR_TRISTATE_SWITCH_ABSENT) {
|
||||||
|
virBufferAsprintf(&childBuf, " hotplug='%s'",
|
||||||
|
virTristateSwitchTypeToString(def->opts.pciopts.hotplug));
|
||||||
|
}
|
||||||
if (def->opts.pciopts.numaNode == -1) {
|
if (def->opts.pciopts.numaNode == -1) {
|
||||||
virBufferAddLit(&childBuf, "/>\n");
|
virBufferAddLit(&childBuf, "/>\n");
|
||||||
} else {
|
} else {
|
||||||
|
@ -722,6 +722,7 @@ struct _virDomainPCIControllerOpts {
|
|||||||
* item in memory target config) -1 == unspecified
|
* item in memory target config) -1 == unspecified
|
||||||
*/
|
*/
|
||||||
int numaNode;
|
int numaNode;
|
||||||
|
virTristateSwitch hotplug; /* 'off' to prevent hotplug/unplug, default 'on' */
|
||||||
};
|
};
|
||||||
|
|
||||||
struct _virDomainUSBControllerOpts {
|
struct _virDomainUSBControllerOpts {
|
||||||
|
35
tests/qemuxml2argvdata/pcie-root-port-nohotplug.xml
Normal file
35
tests/qemuxml2argvdata/pcie-root-port-nohotplug.xml
Normal file
@ -0,0 +1,35 @@
|
|||||||
|
<domain type='qemu'>
|
||||||
|
<name>guest</name>
|
||||||
|
<uuid>11dbdcdd-4c3b-482b-8903-9bdb8c0a2774</uuid>
|
||||||
|
<memory unit='KiB'>2097152</memory>
|
||||||
|
<currentMemory unit='KiB'>2097152</currentMemory>
|
||||||
|
<vcpu placement='static'>2</vcpu>
|
||||||
|
<os>
|
||||||
|
<type arch='x86_64' machine='q35'>hvm</type>
|
||||||
|
</os>
|
||||||
|
<devices>
|
||||||
|
<emulator>/usr/bin/qemu-system-x86_64</emulator>
|
||||||
|
<controller type='pci' index='0' model='pcie-root'/>
|
||||||
|
<controller type='pci' index='1' model='pcie-root-port'/>
|
||||||
|
<controller type='pci' index='2' model='pcie-root-port'>
|
||||||
|
<target hotplug='off'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='3' model='pcie-root-port'>
|
||||||
|
<model name='ioh3420'/>
|
||||||
|
<target hotplug='off'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='4' model='pcie-switch-upstream-port'/>
|
||||||
|
<controller type='pci' index='5' model='pcie-switch-downstream-port'>
|
||||||
|
<target hotplug='off'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='6' model='pcie-switch-downstream-port'>
|
||||||
|
<target hotplug='on'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='7' model='pcie-switch-downstream-port'/>
|
||||||
|
<controller type='pci' index='8' model='pcie-switch-downstream-port'>
|
||||||
|
<model name='xio3130-downstream'/>
|
||||||
|
<target chassis='30' port='0x27'/>
|
||||||
|
</controller>
|
||||||
|
<memballoon model='none'/>
|
||||||
|
</devices>
|
||||||
|
</domain>
|
@ -0,0 +1,70 @@
|
|||||||
|
<domain type='qemu'>
|
||||||
|
<name>guest</name>
|
||||||
|
<uuid>11dbdcdd-4c3b-482b-8903-9bdb8c0a2774</uuid>
|
||||||
|
<memory unit='KiB'>2097152</memory>
|
||||||
|
<currentMemory unit='KiB'>2097152</currentMemory>
|
||||||
|
<vcpu placement='static'>2</vcpu>
|
||||||
|
<os>
|
||||||
|
<type arch='x86_64' machine='q35'>hvm</type>
|
||||||
|
<boot dev='hd'/>
|
||||||
|
</os>
|
||||||
|
<cpu mode='custom' match='exact' check='none'>
|
||||||
|
<model fallback='forbid'>qemu64</model>
|
||||||
|
</cpu>
|
||||||
|
<clock offset='utc'/>
|
||||||
|
<on_poweroff>destroy</on_poweroff>
|
||||||
|
<on_reboot>restart</on_reboot>
|
||||||
|
<on_crash>destroy</on_crash>
|
||||||
|
<devices>
|
||||||
|
<emulator>/usr/bin/qemu-system-x86_64</emulator>
|
||||||
|
<controller type='pci' index='0' model='pcie-root'/>
|
||||||
|
<controller type='pci' index='1' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='1' port='0x8'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x0' multifunction='on'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='2' model='pcie-root-port'>
|
||||||
|
<model name='pcie-root-port'/>
|
||||||
|
<target chassis='2' port='0x9' hotplug='off'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x1'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='3' model='pcie-root-port'>
|
||||||
|
<model name='ioh3420'/>
|
||||||
|
<target chassis='3' port='0xa' hotplug='off'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x01' function='0x2'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='4' model='pcie-switch-upstream-port'>
|
||||||
|
<model name='x3130-upstream'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x01' slot='0x00' function='0x0'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='5' model='pcie-switch-downstream-port'>
|
||||||
|
<model name='xio3130-downstream'/>
|
||||||
|
<target chassis='5' port='0x0' hotplug='off'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x04' slot='0x00' function='0x0'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='6' model='pcie-switch-downstream-port'>
|
||||||
|
<model name='xio3130-downstream'/>
|
||||||
|
<target chassis='6' port='0x1' hotplug='on'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x04' slot='0x01' function='0x0'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='7' model='pcie-switch-downstream-port'>
|
||||||
|
<model name='xio3130-downstream'/>
|
||||||
|
<target chassis='7' port='0x2'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x04' slot='0x02' function='0x0'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='pci' index='8' model='pcie-switch-downstream-port'>
|
||||||
|
<model name='xio3130-downstream'/>
|
||||||
|
<target chassis='30' port='0x27'/>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x04' slot='0x03' function='0x0'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='usb' index='0' model='qemu-xhci'>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x02' slot='0x00' function='0x0'/>
|
||||||
|
</controller>
|
||||||
|
<controller type='sata' index='0'>
|
||||||
|
<address type='pci' domain='0x0000' bus='0x00' slot='0x1f' function='0x2'/>
|
||||||
|
</controller>
|
||||||
|
<input type='mouse' bus='ps2'/>
|
||||||
|
<input type='keyboard' bus='ps2'/>
|
||||||
|
<memballoon model='none'/>
|
||||||
|
</devices>
|
||||||
|
</domain>
|
@ -959,7 +959,7 @@ mymain(void)
|
|||||||
QEMU_CAPS_DEVICE_IOH3420);
|
QEMU_CAPS_DEVICE_IOH3420);
|
||||||
DO_TEST("pcie-root-port-model-ioh3420",
|
DO_TEST("pcie-root-port-model-ioh3420",
|
||||||
QEMU_CAPS_DEVICE_IOH3420);
|
QEMU_CAPS_DEVICE_IOH3420);
|
||||||
|
DO_TEST_CAPS_LATEST("pcie-root-port-nohotplug");
|
||||||
DO_TEST("pcie-switch-upstream-port",
|
DO_TEST("pcie-switch-upstream-port",
|
||||||
QEMU_CAPS_DEVICE_IOH3420,
|
QEMU_CAPS_DEVICE_IOH3420,
|
||||||
QEMU_CAPS_DEVICE_X3130_UPSTREAM,
|
QEMU_CAPS_DEVICE_X3130_UPSTREAM,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user