[libvirt PATCH 00/11] lower maximum frame size

Ján Tomko (11): conf: split out virDomainDefParseIDs conf: split out virDomainDefParseMemory conf: introduce virDomainDefTunablesParse conf: introduce virDomainDefLifecycleParse conf: introduce virDomainDefClockParse conf: introduce virDomainDefControllersParse esx: esxConnectOpen: use allocated buffer libxl: allocate d_config lxc: virLXCProcessStart: use allocated buffers remote: allocate def in remoteRelayDomainEventCheckACL build: lower maximum frame size to 1972 meson.build | 7 +- src/conf/domain_conf.c | 728 ++++++++++++++++------------ src/esx/esx_driver.c | 7 +- src/libxl/libxl_domain.c | 24 +- src/lxc/lxc_process.c | 19 +- src/remote/remote_daemon_dispatch.c | 9 +- 6 files changed, 454 insertions(+), 340 deletions(-) -- 2.26.2

Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/conf/domain_conf.c | 139 +++++++++++++++++++++++------------------ 1 file changed, 79 insertions(+), 60 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 5d3ae8bb28..189f0ac71f 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -20952,6 +20952,83 @@ virDomainCachetuneDefParse(virDomainDefPtr def, } +static int +virDomainDefParseIDs(virDomainDefPtr def, + xmlXPathContextPtr ctxt, + unsigned int flags, + bool *uuid_generated) +{ + g_autofree xmlNodePtr *nodes = NULL; + g_autofree char *tmp = NULL; + long id = -1; + int n; + + if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)) + if (virXPathLong("string(./@id)", ctxt, &id) < 0) + id = -1; + def->id = (int)id; + + /* Extract domain name */ + if (!(def->name = virXPathString("string(./name[1])", ctxt))) { + virReportError(VIR_ERR_NO_NAME, NULL); + goto error; + } + + /* Extract domain uuid. If both uuid and sysinfo/system/entry/uuid + * exist, they must match; and if only the latter exists, it can + * also serve as the uuid. */ + tmp = virXPathString("string(./uuid[1])", ctxt); + if (!tmp) { + if (virUUIDGenerate(def->uuid) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Failed to generate UUID")); + goto error; + } + *uuid_generated = true; + } else { + if (virUUIDParse(tmp, def->uuid) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("malformed uuid element")); + goto error; + } + VIR_FREE(tmp); + } + + /* Extract domain genid - a genid can either be provided or generated */ + if ((n = virXPathNodeSet("./genid", ctxt, &nodes)) < 0) + goto error; + + if (n > 0) { + if (n != 1) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("element 'genid' can only appear once")); + goto error; + } + def->genidRequested = true; + if (!(tmp = virXPathString("string(./genid)", ctxt))) { + if (virUUIDGenerate(def->genid) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("Failed to generate genid")); + goto error; + } + def->genidGenerated = true; + } else { + if (virUUIDParse(tmp, def->genid) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, + "%s", _("malformed genid element")); + goto error; + } + VIR_FREE(tmp); + } + } + VIR_FREE(nodes); + return 0; + + error: + return -1; +} + + static int virDomainDefParseCaps(virDomainDefPtr def, xmlXPathContextPtr ctxt, @@ -21161,7 +21238,6 @@ virDomainDefParseXML(xmlDocPtr xml, xmlNodePtr node = NULL; size_t i, j; int n; - long id = -1; virDomainDefPtr def; bool uuid_generated = false; bool usb_none = false; @@ -21185,69 +21261,12 @@ virDomainDefParseXML(xmlDocPtr xml, if (!(def = virDomainDefNew())) return NULL; - if (!(flags & VIR_DOMAIN_DEF_PARSE_INACTIVE)) - if (virXPathLong("string(./@id)", ctxt, &id) < 0) - id = -1; - def->id = (int)id; + if (virDomainDefParseIDs(def, ctxt, flags, &uuid_generated) < 0) + goto error; if (virDomainDefParseCaps(def, ctxt, xmlopt) < 0) goto error; - /* Extract domain name */ - if (!(def->name = virXPathString("string(./name[1])", ctxt))) { - virReportError(VIR_ERR_NO_NAME, NULL); - goto error; - } - - /* Extract domain uuid. If both uuid and sysinfo/system/entry/uuid - * exist, they must match; and if only the latter exists, it can - * also serve as the uuid. */ - tmp = virXPathString("string(./uuid[1])", ctxt); - if (!tmp) { - if (virUUIDGenerate(def->uuid) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("Failed to generate UUID")); - goto error; - } - uuid_generated = true; - } else { - if (virUUIDParse(tmp, def->uuid) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("malformed uuid element")); - goto error; - } - VIR_FREE(tmp); - } - - /* Extract domain genid - a genid can either be provided or generated */ - if ((n = virXPathNodeSet("./genid", ctxt, &nodes)) < 0) - goto error; - - if (n > 0) { - if (n != 1) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("element 'genid' can only appear once")); - goto error; - } - def->genidRequested = true; - if (!(tmp = virXPathString("string(./genid)", ctxt))) { - if (virUUIDGenerate(def->genid) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("Failed to generate genid")); - goto error; - } - def->genidGenerated = true; - } else { - if (virUUIDParse(tmp, def->genid) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, - "%s", _("malformed genid element")); - goto error; - } - VIR_FREE(tmp); - } - } - VIR_FREE(nodes); - /* Extract short description of domain (title) */ def->title = virXPathString("string(./title[1])", ctxt); if (def->title && strchr(def->title, '\n')) { -- 2.26.2

Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/conf/domain_conf.c | 209 ++++++++++++++++++++++------------------- 1 file changed, 114 insertions(+), 95 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 189f0ac71f..94def18f8a 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -21101,6 +21101,119 @@ virDomainDefParseCaps(virDomainDefPtr def, } +static int +virDomainDefParseMemory(virDomainDefPtr def, + xmlXPathContextPtr ctxt) +{ + g_autofree xmlNodePtr *nodes = NULL; + g_autofree char *tmp = NULL; + xmlNodePtr node = NULL; + size_t i; + int n; + + /* Extract domain memory */ + if (virDomainParseMemory("./memory[1]", NULL, ctxt, + &def->mem.total_memory, false, true) < 0) + goto error; + + if (virDomainParseMemory("./currentMemory[1]", NULL, ctxt, + &def->mem.cur_balloon, false, true) < 0) + goto error; + + if (virDomainParseMemory("./maxMemory[1]", NULL, ctxt, + &def->mem.max_memory, false, false) < 0) + goto error; + + if (virXPathUInt("string(./maxMemory[1]/@slots)", ctxt, &def->mem.memory_slots) == -2) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Failed to parse memory slot count")); + goto error; + } + + /* and info about it */ + if ((tmp = virXPathString("string(./memory[1]/@dumpCore)", ctxt)) && + (def->mem.dump_core = virTristateSwitchTypeFromString(tmp)) <= 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("Invalid memory core dump attribute value '%s'"), tmp); + goto error; + } + VIR_FREE(tmp); + + tmp = virXPathString("string(./memoryBacking/source/@type)", ctxt); + if (tmp) { + if ((def->mem.source = virDomainMemorySourceTypeFromString(tmp)) <= 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown memoryBacking/source/type '%s'"), tmp); + goto error; + } + VIR_FREE(tmp); + } + + tmp = virXPathString("string(./memoryBacking/access/@mode)", ctxt); + if (tmp) { + if ((def->mem.access = virDomainMemoryAccessTypeFromString(tmp)) <= 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown memoryBacking/access/mode '%s'"), tmp); + goto error; + } + VIR_FREE(tmp); + } + + tmp = virXPathString("string(./memoryBacking/allocation/@mode)", ctxt); + if (tmp) { + if ((def->mem.allocation = virDomainMemoryAllocationTypeFromString(tmp)) <= 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown memoryBacking/allocation/mode '%s'"), tmp); + goto error; + } + VIR_FREE(tmp); + } + + if (virXPathNode("./memoryBacking/hugepages", ctxt)) { + /* hugepages will be used */ + if ((n = virXPathNodeSet("./memoryBacking/hugepages/page", ctxt, &nodes)) < 0) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("cannot extract hugepages nodes")); + goto error; + } + + if (n) { + if (VIR_ALLOC_N(def->mem.hugepages, n) < 0) + goto error; + + for (i = 0; i < n; i++) { + if (virDomainHugepagesParseXML(nodes[i], ctxt, + &def->mem.hugepages[i]) < 0) + goto error; + def->mem.nhugepages++; + } + + VIR_FREE(nodes); + } else { + /* no hugepage pages */ + if (VIR_ALLOC(def->mem.hugepages) < 0) + goto error; + + def->mem.nhugepages = 1; + } + } + + if ((node = virXPathNode("./memoryBacking/nosharepages", ctxt))) + def->mem.nosharepages = true; + + if (virXPathBoolean("boolean(./memoryBacking/locked)", ctxt)) + def->mem.locked = true; + + if (virXPathBoolean("boolean(./memoryBacking/discard)", ctxt)) + def->mem.discard = VIR_TRISTATE_BOOL_YES; + + return 0; + + error: + return -1; +} + + static int virDomainMemorytuneDefParseMemory(xmlXPathContextPtr ctxt, xmlNodePtr node, @@ -21285,102 +21398,8 @@ virDomainDefParseXML(xmlDocPtr xml, goto error; } - /* Extract domain memory */ - if (virDomainParseMemory("./memory[1]", NULL, ctxt, - &def->mem.total_memory, false, true) < 0) + if (virDomainDefParseMemory(def, ctxt) < 0) goto error; - - if (virDomainParseMemory("./currentMemory[1]", NULL, ctxt, - &def->mem.cur_balloon, false, true) < 0) - goto error; - - if (virDomainParseMemory("./maxMemory[1]", NULL, ctxt, - &def->mem.max_memory, false, false) < 0) - goto error; - - if (virXPathUInt("string(./maxMemory[1]/@slots)", ctxt, &def->mem.memory_slots) == -2) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Failed to parse memory slot count")); - goto error; - } - - /* and info about it */ - if ((tmp = virXPathString("string(./memory[1]/@dumpCore)", ctxt)) && - (def->mem.dump_core = virTristateSwitchTypeFromString(tmp)) <= 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("Invalid memory core dump attribute value '%s'"), tmp); - goto error; - } - VIR_FREE(tmp); - - tmp = virXPathString("string(./memoryBacking/source/@type)", ctxt); - if (tmp) { - if ((def->mem.source = virDomainMemorySourceTypeFromString(tmp)) <= 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown memoryBacking/source/type '%s'"), tmp); - goto error; - } - VIR_FREE(tmp); - } - - tmp = virXPathString("string(./memoryBacking/access/@mode)", ctxt); - if (tmp) { - if ((def->mem.access = virDomainMemoryAccessTypeFromString(tmp)) <= 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown memoryBacking/access/mode '%s'"), tmp); - goto error; - } - VIR_FREE(tmp); - } - - tmp = virXPathString("string(./memoryBacking/allocation/@mode)", ctxt); - if (tmp) { - if ((def->mem.allocation = virDomainMemoryAllocationTypeFromString(tmp)) <= 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown memoryBacking/allocation/mode '%s'"), tmp); - goto error; - } - VIR_FREE(tmp); - } - - if (virXPathNode("./memoryBacking/hugepages", ctxt)) { - /* hugepages will be used */ - if ((n = virXPathNodeSet("./memoryBacking/hugepages/page", ctxt, &nodes)) < 0) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("cannot extract hugepages nodes")); - goto error; - } - - if (n) { - if (VIR_ALLOC_N(def->mem.hugepages, n) < 0) - goto error; - - for (i = 0; i < n; i++) { - if (virDomainHugepagesParseXML(nodes[i], ctxt, - &def->mem.hugepages[i]) < 0) - goto error; - def->mem.nhugepages++; - } - - VIR_FREE(nodes); - } else { - /* no hugepage pages */ - if (VIR_ALLOC(def->mem.hugepages) < 0) - goto error; - - def->mem.nhugepages = 1; - } - } - - if ((node = virXPathNode("./memoryBacking/nosharepages", ctxt))) - def->mem.nosharepages = true; - - if (virXPathBoolean("boolean(./memoryBacking/locked)", ctxt)) - def->mem.locked = true; - - if (virXPathBoolean("boolean(./memoryBacking/discard)", ctxt)) - def->mem.discard = VIR_TRISTATE_BOOL_YES; - /* Extract blkio cgroup tunables */ if (virXPathUInt("string(./blkiotune/weight)", ctxt, &def->blkio.weight) < 0) -- 2.26.2

Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/conf/domain_conf.c | 129 ++++++++++++++++++++++++----------------- 1 file changed, 75 insertions(+), 54 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 94def18f8a..62f9b6316e 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -21342,64 +21342,16 @@ virDomainMemorytuneDefParse(virDomainDefPtr def, } -static virDomainDefPtr -virDomainDefParseXML(xmlDocPtr xml, - xmlXPathContextPtr ctxt, - virDomainXMLOptionPtr xmlopt, - unsigned int flags) +static int +virDomainDefTunablesParse(virDomainDefPtr def, + xmlXPathContextPtr ctxt, + virDomainXMLOptionPtr xmlopt, + unsigned int flags) { - xmlNodePtr node = NULL; + g_autofree xmlNodePtr *nodes = NULL; size_t i, j; int n; - virDomainDefPtr def; - bool uuid_generated = false; - bool usb_none = false; - bool usb_other = false; - bool usb_master = false; - g_autofree xmlNodePtr *nodes = NULL; - g_autofree char *tmp = NULL; - if (flags & VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA) { - g_autofree char *schema = NULL; - - schema = virFileFindResource("domain.rng", - abs_top_srcdir "/docs/schemas", - PKGDATADIR "/schemas"); - if (!schema) - return NULL; - if (virXMLValidateAgainstSchema(schema, xml) < 0) - return NULL; - } - - if (!(def = virDomainDefNew())) - return NULL; - - if (virDomainDefParseIDs(def, ctxt, flags, &uuid_generated) < 0) - goto error; - - if (virDomainDefParseCaps(def, ctxt, xmlopt) < 0) - goto error; - - /* Extract short description of domain (title) */ - def->title = virXPathString("string(./title[1])", ctxt); - if (def->title && strchr(def->title, '\n')) { - virReportError(VIR_ERR_XML_ERROR, "%s", - _("Domain title can't contain newlines")); - goto error; - } - - /* Extract documentation if present */ - def->description = virXPathString("string(./description[1])", ctxt); - - /* analysis of security label, done early even though we format it - * late, so devices can refer to this for defaults */ - if (!(flags & VIR_DOMAIN_DEF_PARSE_SKIP_SECLABEL)) { - if (virSecurityLabelDefsParseXML(def, ctxt, xmlopt, flags) == -1) - goto error; - } - - if (virDomainDefParseMemory(def, ctxt) < 0) - goto error; /* Extract blkio cgroup tunables */ if (virXPathUInt("string(./blkiotune/weight)", ctxt, &def->blkio.weight) < 0) @@ -21628,6 +21580,75 @@ virDomainDefParseXML(xmlDocPtr xml, } VIR_FREE(nodes); + return 0; + + error: + return -1; +} + + +static virDomainDefPtr +virDomainDefParseXML(xmlDocPtr xml, + xmlXPathContextPtr ctxt, + virDomainXMLOptionPtr xmlopt, + unsigned int flags) +{ + xmlNodePtr node = NULL; + size_t i, j; + int n; + virDomainDefPtr def; + bool uuid_generated = false; + bool usb_none = false; + bool usb_other = false; + bool usb_master = false; + g_autofree xmlNodePtr *nodes = NULL; + g_autofree char *tmp = NULL; + + if (flags & VIR_DOMAIN_DEF_PARSE_VALIDATE_SCHEMA) { + g_autofree char *schema = NULL; + + schema = virFileFindResource("domain.rng", + abs_top_srcdir "/docs/schemas", + PKGDATADIR "/schemas"); + if (!schema) + return NULL; + if (virXMLValidateAgainstSchema(schema, xml) < 0) + return NULL; + } + + if (!(def = virDomainDefNew())) + return NULL; + + if (virDomainDefParseIDs(def, ctxt, flags, &uuid_generated) < 0) + goto error; + + if (virDomainDefParseCaps(def, ctxt, xmlopt) < 0) + goto error; + + /* Extract short description of domain (title) */ + def->title = virXPathString("string(./title[1])", ctxt); + if (def->title && strchr(def->title, '\n')) { + virReportError(VIR_ERR_XML_ERROR, "%s", + _("Domain title can't contain newlines")); + goto error; + } + + /* Extract documentation if present */ + def->description = virXPathString("string(./description[1])", ctxt); + + /* analysis of security label, done early even though we format it + * late, so devices can refer to this for defaults */ + if (!(flags & VIR_DOMAIN_DEF_PARSE_SKIP_SECLABEL)) { + if (virSecurityLabelDefsParseXML(def, ctxt, xmlopt, flags) == -1) + goto error; + } + + if (virDomainDefParseMemory(def, ctxt) < 0) + goto error; + + if (virDomainDefTunablesParse(def, ctxt, xmlopt, flags) < 0) + goto error; + if (virCPUDefParseXML(ctxt, "./cpu[1]", VIR_CPU_TYPE_GUEST, &def->cpu) < 0) goto error; -- 2.26.2

Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/conf/domain_conf.c | 86 ++++++++++++++++++++++++------------------ 1 file changed, 50 insertions(+), 36 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 62f9b6316e..79998635ac 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -21587,6 +21587,55 @@ virDomainDefTunablesParse(virDomainDefPtr def, } +static int +virDomainDefLifecycleParse(virDomainDefPtr def, + xmlXPathContextPtr ctxt) +{ + if (virDomainEventActionParseXML(ctxt, "on_reboot", + "string(./on_reboot[1])", + &def->onReboot, + VIR_DOMAIN_LIFECYCLE_ACTION_RESTART, + virDomainLifecycleActionTypeFromString) < 0) + goto error; + + if (virDomainEventActionParseXML(ctxt, "on_poweroff", + "string(./on_poweroff[1])", + &def->onPoweroff, + VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY, + virDomainLifecycleActionTypeFromString) < 0) + goto error; + + if (virDomainEventActionParseXML(ctxt, "on_crash", + "string(./on_crash[1])", + &def->onCrash, + VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY, + virDomainLifecycleActionTypeFromString) < 0) + goto error; + + if (virDomainEventActionParseXML(ctxt, "on_lockfailure", + "string(./on_lockfailure[1])", + &def->onLockFailure, + VIR_DOMAIN_LOCK_FAILURE_DEFAULT, + virDomainLockFailureTypeFromString) < 0) + goto error; + + if (virDomainPMStateParseXML(ctxt, + "string(./pm/suspend-to-mem/@enabled)", + &def->pm.s3) < 0) + goto error; + + if (virDomainPMStateParseXML(ctxt, + "string(./pm/suspend-to-disk/@enabled)", + &def->pm.s4) < 0) + goto error; + + return 0; + + error: + return -1; +} + + static virDomainDefPtr virDomainDefParseXML(xmlDocPtr xml, xmlXPathContextPtr ctxt, @@ -21700,42 +21749,7 @@ virDomainDefParseXML(xmlDocPtr xml, if (virDomainFeaturesDefParse(def, ctxt) < 0) goto error; - if (virDomainEventActionParseXML(ctxt, "on_reboot", - "string(./on_reboot[1])", - &def->onReboot, - VIR_DOMAIN_LIFECYCLE_ACTION_RESTART, - virDomainLifecycleActionTypeFromString) < 0) - goto error; - - if (virDomainEventActionParseXML(ctxt, "on_poweroff", - "string(./on_poweroff[1])", - &def->onPoweroff, - VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY, - virDomainLifecycleActionTypeFromString) < 0) - goto error; - - if (virDomainEventActionParseXML(ctxt, "on_crash", - "string(./on_crash[1])", - &def->onCrash, - VIR_DOMAIN_LIFECYCLE_ACTION_DESTROY, - virDomainLifecycleActionTypeFromString) < 0) - goto error; - - if (virDomainEventActionParseXML(ctxt, "on_lockfailure", - "string(./on_lockfailure[1])", - &def->onLockFailure, - VIR_DOMAIN_LOCK_FAILURE_DEFAULT, - virDomainLockFailureTypeFromString) < 0) - goto error; - - if (virDomainPMStateParseXML(ctxt, - "string(./pm/suspend-to-mem/@enabled)", - &def->pm.s3) < 0) - goto error; - - if (virDomainPMStateParseXML(ctxt, - "string(./pm/suspend-to-disk/@enabled)", - &def->pm.s4) < 0) + if (virDomainDefLifecycleParse(def, ctxt) < 0) goto error; if (virDomainPerfDefParseXML(def, ctxt) < 0) -- 2.26.2

Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/conf/domain_conf.c | 185 +++++++++++++++++++++++------------------ 1 file changed, 102 insertions(+), 83 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 79998635ac..656277731c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -21636,6 +21636,107 @@ virDomainDefLifecycleParse(virDomainDefPtr def, } +static int +virDomainDefClockParse(virDomainDefPtr def, + xmlXPathContextPtr ctxt) +{ + size_t i; + int n; + g_autofree xmlNodePtr *nodes = NULL; + g_autofree char *tmp = NULL; + + if ((tmp = virXPathString("string(./clock/@offset)", ctxt)) && + (def->clock.offset = virDomainClockOffsetTypeFromString(tmp)) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown clock offset '%s'"), tmp); + goto error; + } + VIR_FREE(tmp); + + switch (def->clock.offset) { + case VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME: + case VIR_DOMAIN_CLOCK_OFFSET_UTC: + tmp = virXPathString("string(./clock/@adjustment)", ctxt); + if (tmp) { + if (STREQ(tmp, "reset")) { + def->clock.data.utc_reset = true; + } else { + if (virStrToLong_ll(tmp, NULL, 10, + &def->clock.data.variable.adjustment) < 0) { + virReportError(VIR_ERR_XML_ERROR, + _("unknown clock adjustment '%s'"), + tmp); + goto error; + } + switch (def->clock.offset) { + case VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME: + def->clock.data.variable.basis = VIR_DOMAIN_CLOCK_BASIS_LOCALTIME; + break; + case VIR_DOMAIN_CLOCK_OFFSET_UTC: + def->clock.data.variable.basis = VIR_DOMAIN_CLOCK_BASIS_UTC; + break; + } + def->clock.offset = VIR_DOMAIN_CLOCK_OFFSET_VARIABLE; + } + VIR_FREE(tmp); + } else { + def->clock.data.utc_reset = false; + } + break; + + case VIR_DOMAIN_CLOCK_OFFSET_VARIABLE: + if (virXPathLongLong("number(./clock/@adjustment)", ctxt, + &def->clock.data.variable.adjustment) < 0) + def->clock.data.variable.adjustment = 0; + if (virXPathLongLong("number(./clock/@adjustment0)", ctxt, + &def->clock.data.variable.adjustment0) < 0) + def->clock.data.variable.adjustment0 = 0; + tmp = virXPathString("string(./clock/@basis)", ctxt); + if (tmp) { + if ((def->clock.data.variable.basis = virDomainClockBasisTypeFromString(tmp)) < 0) { + virReportError(VIR_ERR_CONFIG_UNSUPPORTED, + _("unknown clock basis '%s'"), tmp); + goto error; + } + VIR_FREE(tmp); + } else { + def->clock.data.variable.basis = VIR_DOMAIN_CLOCK_BASIS_UTC; + } + break; + + case VIR_DOMAIN_CLOCK_OFFSET_TIMEZONE: + def->clock.data.timezone = virXPathString("string(./clock/@timezone)", ctxt); + if (!def->clock.data.timezone) { + virReportError(VIR_ERR_INTERNAL_ERROR, "%s", + _("missing 'timezone' attribute for clock with offset='timezone'")); + goto error; + } + break; + } + + if ((n = virXPathNodeSet("./clock/timer", ctxt, &nodes)) < 0) + goto error; + + if (n && VIR_ALLOC_N(def->clock.timers, n) < 0) + goto error; + + for (i = 0; i < n; i++) { + virDomainTimerDefPtr timer = virDomainTimerDefParseXML(nodes[i], + ctxt); + if (!timer) + goto error; + + def->clock.timers[def->clock.ntimers++] = timer; + } + VIR_FREE(nodes); + + return 0; + + error: + return -1; +} + + static virDomainDefPtr virDomainDefParseXML(xmlDocPtr xml, xmlXPathContextPtr ctxt, @@ -21755,90 +21856,8 @@ virDomainDefParseXML(xmlDocPtr xml, if (virDomainPerfDefParseXML(def, ctxt) < 0) goto error; - if ((tmp = virXPathString("string(./clock/@offset)", ctxt)) && - (def->clock.offset = virDomainClockOffsetTypeFromString(tmp)) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown clock offset '%s'"), tmp); + if (virDomainDefClockParse(def, ctxt) < 0) goto error; - } - VIR_FREE(tmp); - - switch (def->clock.offset) { - case VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME: - case VIR_DOMAIN_CLOCK_OFFSET_UTC: - tmp = virXPathString("string(./clock/@adjustment)", ctxt); - if (tmp) { - if (STREQ(tmp, "reset")) { - def->clock.data.utc_reset = true; - } else { - if (virStrToLong_ll(tmp, NULL, 10, - &def->clock.data.variable.adjustment) < 0) { - virReportError(VIR_ERR_XML_ERROR, - _("unknown clock adjustment '%s'"), - tmp); - goto error; - } - switch (def->clock.offset) { - case VIR_DOMAIN_CLOCK_OFFSET_LOCALTIME: - def->clock.data.variable.basis = VIR_DOMAIN_CLOCK_BASIS_LOCALTIME; - break; - case VIR_DOMAIN_CLOCK_OFFSET_UTC: - def->clock.data.variable.basis = VIR_DOMAIN_CLOCK_BASIS_UTC; - break; - } - def->clock.offset = VIR_DOMAIN_CLOCK_OFFSET_VARIABLE; - } - VIR_FREE(tmp); - } else { - def->clock.data.utc_reset = false; - } - break; - - case VIR_DOMAIN_CLOCK_OFFSET_VARIABLE: - if (virXPathLongLong("number(./clock/@adjustment)", ctxt, - &def->clock.data.variable.adjustment) < 0) - def->clock.data.variable.adjustment = 0; - if (virXPathLongLong("number(./clock/@adjustment0)", ctxt, - &def->clock.data.variable.adjustment0) < 0) - def->clock.data.variable.adjustment0 = 0; - tmp = virXPathString("string(./clock/@basis)", ctxt); - if (tmp) { - if ((def->clock.data.variable.basis = virDomainClockBasisTypeFromString(tmp)) < 0) { - virReportError(VIR_ERR_CONFIG_UNSUPPORTED, - _("unknown clock basis '%s'"), tmp); - goto error; - } - VIR_FREE(tmp); - } else { - def->clock.data.variable.basis = VIR_DOMAIN_CLOCK_BASIS_UTC; - } - break; - - case VIR_DOMAIN_CLOCK_OFFSET_TIMEZONE: - def->clock.data.timezone = virXPathString("string(./clock/@timezone)", ctxt); - if (!def->clock.data.timezone) { - virReportError(VIR_ERR_INTERNAL_ERROR, "%s", - _("missing 'timezone' attribute for clock with offset='timezone'")); - goto error; - } - break; - } - - if ((n = virXPathNodeSet("./clock/timer", ctxt, &nodes)) < 0) - goto error; - - if (n && VIR_ALLOC_N(def->clock.timers, n) < 0) - goto error; - - for (i = 0; i < n; i++) { - virDomainTimerDefPtr timer = virDomainTimerDefParseXML(nodes[i], - ctxt); - if (!timer) - goto error; - - def->clock.timers[def->clock.ntimers++] = timer; - } - VIR_FREE(nodes); if (virDomainDefParseBootOptions(def, ctxt) < 0) goto error; -- 2.26.2

Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/conf/domain_conf.c | 122 +++++++++++++++++++++++------------------ 1 file changed, 70 insertions(+), 52 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index 656277731c..8e2e1eadaa 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -21736,6 +21736,75 @@ virDomainDefClockParse(virDomainDefPtr def, return -1; } +static int +virDomainDefControllersParse(virDomainDefPtr def, + xmlXPathContextPtr ctxt, + virDomainXMLOptionPtr xmlopt, + unsigned int flags, + bool *usb_none) +{ + g_autofree xmlNodePtr *nodes = NULL; + bool usb_other = false; + bool usb_master = false; + size_t i; + int n; + + if ((n = virXPathNodeSet("./devices/controller", ctxt, &nodes)) < 0) + goto error; + + if (n && VIR_ALLOC_N(def->controllers, n) < 0) + goto error; + + for (i = 0; i < n; i++) { + virDomainControllerDefPtr controller = virDomainControllerDefParseXML(xmlopt, + nodes[i], + ctxt, + flags); + + if (!controller) + goto error; + + /* sanitize handling of "none" usb controller */ + if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_USB) { + if (controller->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE) { + if (usb_other || *usb_none) { + virDomainControllerDefFree(controller); + virReportError(VIR_ERR_XML_DETAIL, "%s", + _("Can't add another USB controller: " + "USB is disabled for this domain")); + goto error; + } + *usb_none = true; + } else { + if (*usb_none) { + virDomainControllerDefFree(controller); + virReportError(VIR_ERR_XML_DETAIL, "%s", + _("Can't add another USB controller: " + "USB is disabled for this domain")); + goto error; + } + usb_other = true; + } + + if (controller->info.mastertype == VIR_DOMAIN_CONTROLLER_MASTER_NONE) + usb_master = true; + } + + virDomainControllerInsertPreAlloced(def, controller); + } + VIR_FREE(nodes); + + if (usb_other && !usb_master) { + virReportError(VIR_ERR_XML_DETAIL, "%s", + _("No master USB controller specified")); + goto error; + } + + return 0; + + error: + return -1; +} static virDomainDefPtr virDomainDefParseXML(xmlDocPtr xml, @@ -21749,8 +21818,6 @@ virDomainDefParseXML(xmlDocPtr xml, virDomainDefPtr def; bool uuid_generated = false; bool usb_none = false; - bool usb_other = false; - bool usb_master = false; g_autofree xmlNodePtr *nodes = NULL; g_autofree char *tmp = NULL; @@ -21881,58 +21948,9 @@ virDomainDefParseXML(xmlDocPtr xml, } VIR_FREE(nodes); - /* analysis of the controller devices */ - if ((n = virXPathNodeSet("./devices/controller", ctxt, &nodes)) < 0) + if (virDomainDefControllersParse(def, ctxt, xmlopt, flags, &usb_none) < 0) goto error; - if (n && VIR_ALLOC_N(def->controllers, n) < 0) - goto error; - - for (i = 0; i < n; i++) { - virDomainControllerDefPtr controller = virDomainControllerDefParseXML(xmlopt, - nodes[i], - ctxt, - flags); - - if (!controller) - goto error; - - /* sanitize handling of "none" usb controller */ - if (controller->type == VIR_DOMAIN_CONTROLLER_TYPE_USB) { - if (controller->model == VIR_DOMAIN_CONTROLLER_MODEL_USB_NONE) { - if (usb_other || usb_none) { - virDomainControllerDefFree(controller); - virReportError(VIR_ERR_XML_DETAIL, "%s", - _("Can't add another USB controller: " - "USB is disabled for this domain")); - goto error; - } - usb_none = true; - } else { - if (usb_none) { - virDomainControllerDefFree(controller); - virReportError(VIR_ERR_XML_DETAIL, "%s", - _("Can't add another USB controller: " - "USB is disabled for this domain")); - goto error; - } - usb_other = true; - } - - if (controller->info.mastertype == VIR_DOMAIN_CONTROLLER_MASTER_NONE) - usb_master = true; - } - - virDomainControllerInsertPreAlloced(def, controller); - } - VIR_FREE(nodes); - - if (usb_other && !usb_master) { - virReportError(VIR_ERR_XML_DETAIL, "%s", - _("No master USB controller specified")); - goto error; - } - /* analysis of the resource leases */ if ((n = virXPathNodeSet("./devices/lease", ctxt, &nodes)) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, -- 2.26.2

Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/esx/esx_driver.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/esx/esx_driver.c b/src/esx/esx_driver.c index 3fb7a3b62c..9158a2bc89 100644 --- a/src/esx/esx_driver.c +++ b/src/esx/esx_driver.c @@ -813,7 +813,7 @@ esxConnectOpen(virConnectPtr conn, virConnectAuthPtr auth, virDrvOpenStatus result = VIR_DRV_OPEN_ERROR; esxPrivate *priv = NULL; char *potentialVCenterIPAddress = NULL; - char vCenterIPAddress[NI_MAXHOST] = ""; + g_autofree char *vCenterIPAddress = g_new0(char, NI_MAXHOST); virCheckFlags(VIR_CONNECT_RO, VIR_DRV_OPEN_ERROR); @@ -876,8 +876,9 @@ esxConnectOpen(virConnectPtr conn, virConnectAuthPtr auth, goto cleanup; } - if (virStrcpyStatic(vCenterIPAddress, - potentialVCenterIPAddress) < 0) { + if (virStrcpy(vCenterIPAddress, + potentialVCenterIPAddress, + NI_MAXHOST) < 0) { virReportError(VIR_ERR_INTERNAL_ERROR, _("vCenter IP address %s too big for destination"), potentialVCenterIPAddress); -- 2.26.2

clang reports: stack frame size of 2152 bytes in function 'libxlDomainStart' This is mostly due to the d_config variable: sizeof(libxl_domain_config) = 1232 Use g_new0 to allocate it and bring the frame size down. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/libxl/libxl_domain.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index de2059fa24..ae428fc7c1 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -1267,7 +1267,7 @@ libxlDomainStart(libxlDriverPrivatePtr driver, int restore_fd, uint32_t restore_ver LIBXL_DOMSTART_RESTORE_VER_ATTR) { - libxl_domain_config d_config; + libxl_domain_config *d_config = NULL; virDomainDefPtr def = NULL; virObjectEventPtr event = NULL; libxlSavefileHeader hdr; @@ -1288,7 +1288,9 @@ libxlDomainStart(libxlDriverPrivatePtr driver, hostdev_flags |= VIR_HOSTDEV_SP_USB; #endif - libxl_domain_config_init(&d_config); + d_config = g_new0(libxl_domain_config, 1); + + libxl_domain_config_init(d_config); /* If there is a managed saved state restore it instead of starting * from scratch. The old state is removed once the restoring succeeded. */ @@ -1364,10 +1366,10 @@ libxlDomainStart(libxlDriverPrivatePtr driver, goto cleanup_dom; if (libxlBuildDomainConfig(driver->reservedGraphicsPorts, vm->def, - cfg, &d_config) < 0) + cfg, d_config) < 0) goto cleanup_dom; - if (cfg->autoballoon && libxlDomainFreeMem(cfg->ctx, &d_config) < 0) + if (cfg->autoballoon && libxlDomainFreeMem(cfg->ctx, d_config) < 0) goto cleanup_dom; if (virHostdevPrepareDomainDevices(hostdev_mgr, LIBXL_DRIVER_INTERNAL_NAME, @@ -1407,14 +1409,14 @@ libxlDomainStart(libxlDriverPrivatePtr driver, aop_console_how.for_callback = vm; aop_console_how.callback = libxlConsoleCallback; if (restore_fd < 0) { - ret = libxl_domain_create_new(cfg->ctx, &d_config, + ret = libxl_domain_create_new(cfg->ctx, d_config, &domid, NULL, &aop_console_how); } else { libxl_domain_restore_params_init(¶ms); #ifdef LIBXL_HAVE_SRM_V2 params.stream_version = restore_ver; #endif - ret = libxl_domain_create_restore(cfg->ctx, &d_config, &domid, + ret = libxl_domain_create_restore(cfg->ctx, d_config, &domid, restore_fd, ¶ms, NULL, &aop_console_how); libxl_domain_restore_params_dispose(¶ms); @@ -1425,11 +1427,11 @@ libxlDomainStart(libxlDriverPrivatePtr driver, if (restore_fd < 0) virReportError(VIR_ERR_INTERNAL_ERROR, _("libxenlight failed to create new domain '%s'"), - d_config.c_info.name); + d_config->c_info.name); else virReportError(VIR_ERR_INTERNAL_ERROR, _("libxenlight failed to restore domain '%s'"), - d_config.c_info.name); + d_config->c_info.name); goto cleanup_dom; } @@ -1438,7 +1440,7 @@ libxlDomainStart(libxlDriverPrivatePtr driver, * be cleaned up if there are any subsequent failures. */ vm->def->id = domid; - config_json = libxl_domain_config_to_json(cfg->ctx, &d_config); + config_json = libxl_domain_config_to_json(cfg->ctx, d_config); libxlLoggerOpenFile(cfg->logger, domid, vm->def->name, config_json); @@ -1453,7 +1455,7 @@ libxlDomainStart(libxlDriverPrivatePtr driver, if (libxl_evenable_domain_death(cfg->ctx, vm->def->id, 0, &priv->deathW)) goto destroy_dom; - libxlDomainCreateIfaceNames(vm->def, &d_config); + libxlDomainCreateIfaceNames(vm->def, d_config); libxlDomainUpdateDiskParams(vm->def, cfg->ctx); #ifdef LIBXL_HAVE_DEVICE_CHANNEL @@ -1523,7 +1525,7 @@ libxlDomainStart(libxlDriverPrivatePtr driver, libxlDomainCleanup(driver, vm); cleanup: - libxl_domain_config_dispose(&d_config); + libxl_domain_config_dispose(d_config); VIR_FREE(config_json); VIR_FREE(dom_xml); VIR_FREE(managed_save_path); -- 2.26.2

On Thu, Aug 27, 2020 at 22:19:50 +0200, Ján Tomko wrote:
clang reports:
stack frame size of 2152 bytes in function 'libxlDomainStart'
This is mostly due to the d_config variable:
sizeof(libxl_domain_config) = 1232
Use g_new0 to allocate it and bring the frame size down.
Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/libxl/libxl_domain.c | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-)
diff --git a/src/libxl/libxl_domain.c b/src/libxl/libxl_domain.c index de2059fa24..ae428fc7c1 100644 --- a/src/libxl/libxl_domain.c +++ b/src/libxl/libxl_domain.c @@ -1267,7 +1267,7 @@ libxlDomainStart(libxlDriverPrivatePtr driver, int restore_fd, uint32_t restore_ver LIBXL_DOMSTART_RESTORE_VER_ATTR) { - libxl_domain_config d_config; + libxl_domain_config *d_config = NULL; virDomainDefPtr def = NULL; virObjectEventPtr event = NULL; libxlSavefileHeader hdr; @@ -1288,7 +1288,9 @@ libxlDomainStart(libxlDriverPrivatePtr driver, hostdev_flags |= VIR_HOSTDEV_SP_USB; #endif
- libxl_domain_config_init(&d_config); + d_config = g_new0(libxl_domain_config, 1); + + libxl_domain_config_init(d_config);
[...]
@@ -1523,7 +1525,7 @@ libxlDomainStart(libxlDriverPrivatePtr driver, libxlDomainCleanup(driver, vm);
cleanup: - libxl_domain_config_dispose(&d_config); + libxl_domain_config_dispose(d_config);
Since this was working properly on a pointer to a stack'd variable it means that libxl_domain_config_dispose isn't freeing it. So you should free the container too.
VIR_FREE(config_json); VIR_FREE(dom_xml); VIR_FREE(managed_save_path); -- 2.26.2

Lower the stack frame by using allocated buffers. Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/lxc/lxc_process.c | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/src/lxc/lxc_process.c b/src/lxc/lxc_process.c index fc59c2e5af..78509a718e 100644 --- a/src/lxc/lxc_process.c +++ b/src/lxc/lxc_process.c @@ -1185,7 +1185,6 @@ int virLXCProcessStart(virConnectPtr conn, VIR_AUTOSTRINGLIST veths = NULL; int handshakefds[2] = { -1, -1 }; off_t pos = -1; - char ebuf[1024]; g_autofree char *timestamp = NULL; int nsInheritFDs[VIR_LXC_DOMAIN_NAMESPACE_LAST]; virCommandPtr cmd = NULL; @@ -1402,13 +1401,14 @@ int virLXCProcessStart(virConnectPtr conn, goto cleanup; if (status != 0) { + g_autofree char *ebuf = g_new0(char, BUFSIZ); if (virLXCProcessReadLogOutput(vm, logfile, pos, ebuf, - sizeof(ebuf)) <= 0) { + BUFSIZ) <= 0) { if (WIFEXITED(status)) - g_snprintf(ebuf, sizeof(ebuf), _("unexpected exit status %d"), + g_snprintf(ebuf, BUFSIZ, _("unexpected exit status %d"), WEXITSTATUS(status)); else - g_snprintf(ebuf, sizeof(ebuf), "%s", _("terminated abnormally")); + g_snprintf(ebuf, BUFSIZ, "%s", _("terminated abnormally")); } virReportError(VIR_ERR_INTERNAL_ERROR, _("guest failed to start: %s"), ebuf); @@ -1417,7 +1417,8 @@ int virLXCProcessStart(virConnectPtr conn, /* It has started running, so get its pid */ if ((r = virPidFileReadPath(pidfile, &vm->pid)) < 0) { - if (virLXCProcessReadLogOutput(vm, logfile, pos, ebuf, sizeof(ebuf)) > 0) + g_autofree char *ebuf = g_new0(char, BUFSIZ); + if (virLXCProcessReadLogOutput(vm, logfile, pos, ebuf, BUFSIZ) > 0) virReportError(VIR_ERR_INTERNAL_ERROR, _("guest failed to start: %s"), ebuf); else @@ -1454,9 +1455,9 @@ int virLXCProcessStart(virConnectPtr conn, driver->inhibitCallback(true, driver->inhibitOpaque); if (lxcContainerWaitForContinue(handshakefds[0]) < 0) { - char out[1024]; + g_autofree char *out = g_new0(char, BUFSIZ); - if (!(virLXCProcessReadLogOutput(vm, logfile, pos, out, 1024) < 0)) { + if (!(virLXCProcessReadLogOutput(vm, logfile, pos, out, BUFSIZ) < 0)) { virReportError(VIR_ERR_INTERNAL_ERROR, _("guest failed to start: %s"), out); } @@ -1486,10 +1487,12 @@ int virLXCProcessStart(virConnectPtr conn, /* And we can get the first monitor connection now too */ if (!(priv->monitor = virLXCProcessConnectMonitor(driver, vm))) { + g_autofree char *ebuf = g_new0(char, BUFSIZ); + /* Intentionally overwrite the real monitor error message, * since a better one is almost always found in the logs */ - if (virLXCProcessReadLogOutput(vm, logfile, pos, ebuf, sizeof(ebuf)) > 0) { + if (virLXCProcessReadLogOutput(vm, logfile, pos, ebuf, BUFSIZ) > 0) { virResetLastError(); virReportError(VIR_ERR_INTERNAL_ERROR, _("guest failed to start: %s"), ebuf); -- 2.26.2

Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/remote/remote_daemon_dispatch.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c index 53d17a8f4a..84cc45e1ac 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -159,22 +159,21 @@ static bool remoteRelayDomainEventCheckACL(virNetServerClientPtr client, virConnectPtr conn, virDomainPtr dom) { - virDomainDef def; + g_autoptr(virDomainDef) def = g_new0(virDomainDef, 1); g_autoptr(virIdentity) identity = NULL; bool ret = false; /* For now, we just create a virDomainDef with enough contents to * satisfy what viraccessdriverpolkit.c references. This is a bit * fragile, but I don't know of anything better. */ - memset(&def, 0, sizeof(def)); - def.name = dom->name; - memcpy(def.uuid, dom->uuid, VIR_UUID_BUFLEN); + def->name = dom->name; + memcpy(def->uuid, dom->uuid, VIR_UUID_BUFLEN); if (!(identity = virNetServerClientGetIdentity(client))) goto cleanup; if (virIdentitySetCurrent(identity) < 0) goto cleanup; - ret = virConnectDomainEventRegisterAnyCheckACL(conn, &def); + ret = virConnectDomainEventRegisterAnyCheckACL(conn, def); cleanup: ignore_value(virIdentitySetCurrent(NULL)); -- 2.26.2

On Thu, Aug 27, 2020 at 22:19:52 +0200, Ján Tomko wrote:
Signed-off-by: Ján Tomko <jtomko@redhat.com> --- src/remote/remote_daemon_dispatch.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/src/remote/remote_daemon_dispatch.c b/src/remote/remote_daemon_dispatch.c index 53d17a8f4a..84cc45e1ac 100644 --- a/src/remote/remote_daemon_dispatch.c +++ b/src/remote/remote_daemon_dispatch.c @@ -159,22 +159,21 @@ static bool remoteRelayDomainEventCheckACL(virNetServerClientPtr client, virConnectPtr conn, virDomainPtr dom) { - virDomainDef def; + g_autoptr(virDomainDef) def = g_new0(virDomainDef, 1);
Registering this for a cleanup by 'virDomainDefFree' ...
g_autoptr(virIdentity) identity = NULL; bool ret = false;
/* For now, we just create a virDomainDef with enough contents to * satisfy what viraccessdriverpolkit.c references. This is a bit * fragile, but I don't know of anything better. */ - memset(&def, 0, sizeof(def)); - def.name = dom->name; - memcpy(def.uuid, dom->uuid, VIR_UUID_BUFLEN); + def->name = dom->name;
... will free the 'dom->name' pointer borrowed incorrectly here.
+ memcpy(def->uuid, dom->uuid, VIR_UUID_BUFLEN);
if (!(identity = virNetServerClientGetIdentity(client))) goto cleanup; if (virIdentitySetCurrent(identity) < 0) goto cleanup; - ret = virConnectDomainEventRegisterAnyCheckACL(conn, &def); + ret = virConnectDomainEventRegisterAnyCheckACL(conn, def);
cleanup: ignore_value(virIdentitySetCurrent(NULL)); -- 2.26.2

This number is the closest multiple of 100000000 above the largest frame value reported by clang in the current codebase. It is unrelated to the closure of the last trolleybus line in the UK: https://en.wikipedia.org/wiki/Trolleybuses_in_Bradford Signed-off-by: Ján Tomko <jtomko@redhat.com> --- meson.build | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/meson.build b/meson.build index dabd4196e6..68ae67a47c 100644 --- a/meson.build +++ b/meson.build @@ -417,10 +417,9 @@ cc_flags += [ # but need to rewrite various areas of code first '-Wno-format-truncation', - # This should be < 256 really. Currently we're down to 4096, - # but using 1024 bytes sized buffers (mostly for virStrerror) - # stops us from going down further - '-Wframe-larger-than=4096', + # This should be < 256 really. + # Using 1024 bytes sized buffers stops us from going down further + '-Wframe-larger-than=1972', # extra special flags '-fexceptions', -- 2.26.2
participants (2)
-
Ján Tomko
-
Peter Krempa