From 382c762c4554df4fedce56966f83f6699c09d3a7 Mon Sep 17 00:00:00 2001 From: Laine Stump Date: Wed, 9 Oct 2019 09:52:25 -0400 Subject: [PATCH] conf: remove parse code for long-extinct " MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Back in July 2009, in the days before libvirt supported explicitly assigning a PCI address to every device, code was added to save the PCI addresses of hotplugged network, disk, and hostdevs in the domain status with this XML element: This was added in commits 4e21a95a, 01654107, in v0.7.0, and 0c5b7b93 in v0.7.1. Then just a few months later, in November 2009, The code that actually formatted the "devaddr='blah'" into the status XML was removed by commit 1b0cce7d3 (which "introduced a standardized data structure for device addresses"). The code to *parse* the devaddr from the status was left in for backward compatibility though (it just parses it into the "standard" PCI address). At the time the devaddr attribute was added, a few other attributes already existed in the element for network devices, and these were removed over time (I haven't checked the exact dates of this), but 10 years later, in libvirt v5.8.0, we *still* maintain code to parse from the domain status. In the meantime, even distros so old that we no longer support them in upstream libvirt are using a libvirt new enough that it doesn't ever write to the domain status XML. Since the only way a current libvirt would ever encounter this element would be if someone was upgrading directly from libvirt <= v0.7.5 with running guests, it seems safe to finally remove the code that parses it. Signed-off-by: Laine Stump Reviewed-by: Ján Tomko --- src/conf/domain_conf.c | 75 ++++-------------------------------------- 1 file changed, 7 insertions(+), 68 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 69464a3345..6cb7156664 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -7560,24 +7560,6 @@ virDomainDeviceInfoParseXML(virDomainXMLOptionPtr xmlopt G_GNUC_UNUSED, return ret; } -static int -virDomainParseLegacyDeviceAddress(char *devaddr, - virPCIDeviceAddressPtr pci) -{ - char *tmp; - - /* expected format: :: */ - if (/* domain */ - virStrToLong_ui(devaddr, &tmp, 16, &pci->domain) < 0 || *tmp != ':' || - /* bus */ - virStrToLong_ui(tmp + 1, &tmp, 16, &pci->bus) < 0 || *tmp != ':' || - /* slot */ - virStrToLong_ui(tmp + 1, NULL, 16, &pci->slot) < 0) - return -1; - - return 0; -} - static int virDomainHostdevSubsysUSBDefParseXML(xmlNodePtr node, virDomainHostdevDefPtr def) @@ -7760,19 +7742,6 @@ virDomainHostdevSubsysPCIDefParseXML(xmlNodePtr node, if (virPCIDeviceAddressParseXML(cur, addr) < 0) goto out; - } else if ((flags & VIR_DOMAIN_DEF_PARSE_STATUS) && - virXMLNodeNameEqual(cur, "state")) { - /* Legacy back-compat. Don't add any more attributes here */ - g_autofree char *devaddr = virXMLPropString(cur, "devaddr"); - if (devaddr && - virDomainParseLegacyDeviceAddress(devaddr, - &def->info->addr.pci) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to parse devaddr parameter '%s'"), - devaddr); - goto out; - } - def->info->type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; } else if ((flags & VIR_DOMAIN_DEF_PARSE_PCI_ORIG_STATES) && virXMLNodeNameEqual(cur, "origstates")) { virDomainHostdevOrigStatesPtr states = &def->origstates; @@ -9961,7 +9930,6 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt, g_autofree char *sgio = NULL; g_autofree char *target = NULL; g_autofree char *bus = NULL; - g_autofree char *devaddr = NULL; g_autofree char *serial = NULL; g_autofree char *startupPolicy = NULL; g_autofree char *tray = NULL; @@ -10128,10 +10096,6 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt, def->src->shared = true; } else if (virXMLNodeNameEqual(cur, "transient")) { def->transient = true; - } else if ((flags & VIR_DOMAIN_DEF_PARSE_STATUS) && - virXMLNodeNameEqual(cur, "state")) { - /* Legacy back-compat. Don't add any more attributes here */ - devaddr = virXMLPropString(cur, "devaddr"); } else if (!encryption && virXMLNodeNameEqual(cur, "encryption")) { /* If we've already parsed and found an child, @@ -10316,19 +10280,9 @@ virDomainDiskDefParseXML(virDomainXMLOptionPtr xmlopt, } } - if (devaddr) { - if (virDomainParseLegacyDeviceAddress(devaddr, - &def->info.addr.pci) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to parse devaddr parameter '%s'"), - devaddr); - goto error; - } - def->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; - } else { - if (virDomainDeviceInfoParseXML(xmlopt, node, &def->info, - flags | VIR_DOMAIN_DEF_PARSE_ALLOW_BOOT) < 0) - goto error; + if (virDomainDeviceInfoParseXML(xmlopt, node, &def->info, + flags | VIR_DOMAIN_DEF_PARSE_ALLOW_BOOT) < 0) { + goto error; } if (startupPolicy) { @@ -11490,7 +11444,6 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, g_autofree char *str = NULL; g_autofree char *filter = NULL; g_autofree char *internal = NULL; - g_autofree char *devaddr = NULL; g_autofree char *mode = NULL; g_autofree char *linkstate = NULL; g_autofree char *addrtype = NULL; @@ -11671,10 +11624,6 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, filter = virXMLPropString(cur, "filter"); virHashFree(filterparams); filterparams = virNWFilterParseParamAttributes(cur); - } else if ((flags & VIR_DOMAIN_DEF_PARSE_STATUS) && - virXMLNodeNameEqual(cur, "state")) { - /* Legacy back-compat. Don't add any more attributes here */ - devaddr = virXMLPropString(cur, "devaddr"); } else if (virXMLNodeNameEqual(cur, "boot")) { /* boot is parsed as part of virDomainDeviceInfoParseXML */ } else if (!actual && @@ -11727,20 +11676,10 @@ virDomainNetDefParseXML(virDomainXMLOptionPtr xmlopt, def->mac_generated = true; } - if (devaddr) { - if (virDomainParseLegacyDeviceAddress(devaddr, - &def->info.addr.pci) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - _("Unable to parse devaddr parameter '%s'"), - devaddr); - goto error; - } - def->info.type = VIR_DOMAIN_DEVICE_ADDRESS_TYPE_PCI; - } else { - if (virDomainDeviceInfoParseXML(xmlopt, node, &def->info, - flags | VIR_DOMAIN_DEF_PARSE_ALLOW_BOOT - | VIR_DOMAIN_DEF_PARSE_ALLOW_ROM) < 0) - goto error; + if (virDomainDeviceInfoParseXML(xmlopt, node, &def->info, + flags | VIR_DOMAIN_DEF_PARSE_ALLOW_BOOT + | VIR_DOMAIN_DEF_PARSE_ALLOW_ROM) < 0) { + goto error; } if (model != NULL && -- GitLab