From 78f4d5e6f188a9f0f8d6da6b1fe78b9f4172d9ad Mon Sep 17 00:00:00 2001 From: Laine Stump Date: Tue, 3 Mar 2020 12:23:52 -0500 Subject: [PATCH] conf: new attribute "hotplug" for pci controllers a element can now have a "hotplug" attribute in the subelement. This is intended to control whether or not the slot(s) of the controller support hotplugging/unplugging a device: 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 Reviewed-by: Michal Privoznik --- docs/formatdomain.html.in | 11 +++ docs/schemas/domaincommon.rng | 5 ++ src/conf/domain_conf.c | 20 +++++- src/conf/domain_conf.h | 1 + .../pcie-root-port-nohotplug.xml | 35 ++++++++++ ...pcie-root-port-nohotplug.x86_64-latest.xml | 70 +++++++++++++++++++ tests/qemuxml2xmltest.c | 2 +- 7 files changed, 142 insertions(+), 2 deletions(-) create mode 100644 tests/qemuxml2argvdata/pcie-root-port-nohotplug.xml create mode 100644 tests/qemuxml2xmloutdata/pcie-root-port-nohotplug.x86_64-latest.xml diff --git a/docs/formatdomain.html.in b/docs/formatdomain.html.in index 35ef2405a5..6f43976815 100644 --- a/docs/formatdomain.html.in +++ b/docs/formatdomain.html.in @@ -4726,6 +4726,17 @@ which is visible to the virtual machine. If set, port must be between 0 and 255. +
hotplug
+
+ pcie-root-port and pcie-switch-downstream-port controllers can + also have a hotplug attribute in + the <target> subelement, which is used to + disable hotplug/unplug of devices on a particular + controller. The default setting of hotplug + is on; it should be set to off to + disable hotplug/unplug of devices on a particular controller. + Since 6.3.0 +
busNr
pci-expander-bus and pcie-expander-bus controllers can have an diff --git a/docs/schemas/domaincommon.rng b/docs/schemas/domaincommon.rng index f7eeb0200f..65d6580434 100644 --- a/docs/schemas/domaincommon.rng +++ b/docs/schemas/domaincommon.rng @@ -2475,6 +2475,11 @@ + + + + + diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 639d471424..8e8146374c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -11055,6 +11055,7 @@ virDomainControllerDefParseXML(virDomainXMLOptionPtr xmlopt, g_autofree char *port = NULL; g_autofree char *busNr = NULL; g_autofree char *targetIndex = NULL; + g_autofree char *hotplug = NULL; g_autofree char *ioeventfd = NULL; g_autofree char *portsStr = NULL; g_autofree char *iothread = NULL; @@ -11126,6 +11127,7 @@ virDomainControllerDefParseXML(virDomainXMLOptionPtr xmlopt, chassis = virXMLPropString(cur, "chassis"); port = virXMLPropString(cur, "port"); busNr = virXMLPropString(cur, "busNr"); + hotplug = virXMLPropString(cur, "hotplug"); targetIndex = virXMLPropString(cur, "index"); processedTarget = true; } @@ -11362,6 +11364,17 @@ virDomainControllerDefParseXML(virDomainXMLOptionPtr xmlopt, } 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; case VIR_DOMAIN_CONTROLLER_TYPE_XENBUS: { g_autofree char *gntframes = virXMLPropString(node, "maxGrantFrames"); @@ -25375,7 +25388,8 @@ virDomainControllerDefFormat(virBufferPtr buf, def->opts.pciopts.port != -1 || def->opts.pciopts.busNr != -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, "opts.pciopts.chassisNr != -1) virBufferAsprintf(&childBuf, " chassisNr='%d'", @@ -25392,6 +25406,10 @@ virDomainControllerDefFormat(virBufferPtr buf, if (def->opts.pciopts.targetIndex != -1) virBufferAsprintf(&childBuf, " index='%d'", 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) { virBufferAddLit(&childBuf, "/>\n"); } else { diff --git a/src/conf/domain_conf.h b/src/conf/domain_conf.h index 9310fab169..aad3f82db7 100644 --- a/src/conf/domain_conf.h +++ b/src/conf/domain_conf.h @@ -722,6 +722,7 @@ struct _virDomainPCIControllerOpts { * item in memory target config) -1 == unspecified */ int numaNode; + virTristateSwitch hotplug; /* 'off' to prevent hotplug/unplug, default 'on' */ }; struct _virDomainUSBControllerOpts { diff --git a/tests/qemuxml2argvdata/pcie-root-port-nohotplug.xml b/tests/qemuxml2argvdata/pcie-root-port-nohotplug.xml new file mode 100644 index 0000000000..8a01494470 --- /dev/null +++ b/tests/qemuxml2argvdata/pcie-root-port-nohotplug.xml @@ -0,0 +1,35 @@ + + guest + 11dbdcdd-4c3b-482b-8903-9bdb8c0a2774 + 2097152 + 2097152 + 2 + + hvm + + + /usr/bin/qemu-system-x86_64 + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tests/qemuxml2xmloutdata/pcie-root-port-nohotplug.x86_64-latest.xml b/tests/qemuxml2xmloutdata/pcie-root-port-nohotplug.x86_64-latest.xml new file mode 100644 index 0000000000..9e22a4181c --- /dev/null +++ b/tests/qemuxml2xmloutdata/pcie-root-port-nohotplug.x86_64-latest.xml @@ -0,0 +1,70 @@ + + guest + 11dbdcdd-4c3b-482b-8903-9bdb8c0a2774 + 2097152 + 2097152 + 2 + + hvm + + + + qemu64 + + + destroy + restart + destroy + + /usr/bin/qemu-system-x86_64 + + + + +
+ + + + +
+ + + + +
+ + + +
+ + + + +
+ + + + +
+ + + + +
+ + + + +
+ + +
+ + +
+ + + + + + diff --git a/tests/qemuxml2xmltest.c b/tests/qemuxml2xmltest.c index 756d4e2ce6..cf5abeac35 100644 --- a/tests/qemuxml2xmltest.c +++ b/tests/qemuxml2xmltest.c @@ -959,7 +959,7 @@ mymain(void) QEMU_CAPS_DEVICE_IOH3420); DO_TEST("pcie-root-port-model-ioh3420", QEMU_CAPS_DEVICE_IOH3420); - + DO_TEST_CAPS_LATEST("pcie-root-port-nohotplug"); DO_TEST("pcie-switch-upstream-port", QEMU_CAPS_DEVICE_IOH3420, QEMU_CAPS_DEVICE_X3130_UPSTREAM, -- 2.47.2