[libvirt] [PATCH] conf: fix cannot get mutli value settings when parse controllers XML

We will free the old parameter value settings in next loop when we get scsi controller's driver specific options. Signed-off-by: Luyao Huang <lhuang@redhat.com> --- src/conf/domain_conf.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b9858cd..f7b4a7c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6870,11 +6870,21 @@ virDomainControllerDefParseXML(xmlNodePtr node, cur = node->children; while (cur != NULL) { + char *queues2 = NULL; + char *cmd_per_lun2 = NULL; + char *max_sectors2 = NULL; + if (cur->type == XML_ELEMENT_NODE) { if (xmlStrEqual(cur->name, BAD_CAST "driver")) { - queues = virXMLPropString(cur, "queues"); - cmd_per_lun = virXMLPropString(cur, "cmd_per_lun"); - max_sectors = virXMLPropString(cur, "max_sectors"); + queues2 = virXMLPropString(cur, "queues"); + if (queues2) + queues = queues2; + cmd_per_lun2 = virXMLPropString(cur, "cmd_per_lun"); + if (cmd_per_lun2) + cmd_per_lun = cmd_per_lun2; + max_sectors2 = virXMLPropString(cur, "max_sectors"); + if (max_sectors2) + max_sectors = max_sectors2; } } cur = cur->next; -- 1.8.3.1

On 01/07/15 10:36, Luyao Huang wrote:
We will free the old parameter value settings in next loop when we get scsi controller's driver specific options.
This description doesn't really explain what is the actual problem you are fixing. Please be more specific and as this is in the XML parsing code it should be fairly easy to do a test case for the scenario.
Signed-off-by: Luyao Huang <lhuang@redhat.com> --- src/conf/domain_conf.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b9858cd..f7b4a7c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6870,11 +6870,21 @@ virDomainControllerDefParseXML(xmlNodePtr node,
cur = node->children; while (cur != NULL) { + char *queues2 = NULL; + char *cmd_per_lun2 = NULL; + char *max_sectors2 = NULL; + if (cur->type == XML_ELEMENT_NODE) { if (xmlStrEqual(cur->name, BAD_CAST "driver")) { - queues = virXMLPropString(cur, "queues"); - cmd_per_lun = virXMLPropString(cur, "cmd_per_lun"); - max_sectors = virXMLPropString(cur, "max_sectors"); + queues2 = virXMLPropString(cur, "queues"); + if (queues2) + queues = queues2; + cmd_per_lun2 = virXMLPropString(cur, "cmd_per_lun"); + if (cmd_per_lun2) + cmd_per_lun = cmd_per_lun2; + max_sectors2 = virXMLPropString(cur, "max_sectors"); + if (max_sectors2) + max_sectors = max_sectors2; } } cur = cur->next;
Without a proper explanation it's hard to see if the fix is right. Peter

On 01/07/2015 05:54 PM, Peter Krempa wrote:
On 01/07/15 10:36, Luyao Huang wrote:
We will free the old parameter value settings in next loop when we get scsi controller's driver specific options. This description doesn't really explain what is the actual problem you are fixing.
Please be more specific and as this is in the XML parsing code it should be fairly easy to do a test case for the scenario.
OK, i will give a better description in next version.
Signed-off-by: Luyao Huang <lhuang@redhat.com> --- src/conf/domain_conf.c | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-)
diff --git a/src/conf/domain_conf.c b/src/conf/domain_conf.c index b9858cd..f7b4a7c 100644 --- a/src/conf/domain_conf.c +++ b/src/conf/domain_conf.c @@ -6870,11 +6870,21 @@ virDomainControllerDefParseXML(xmlNodePtr node,
cur = node->children; while (cur != NULL) { + char *queues2 = NULL; + char *cmd_per_lun2 = NULL; + char *max_sectors2 = NULL; + if (cur->type == XML_ELEMENT_NODE) { if (xmlStrEqual(cur->name, BAD_CAST "driver")) { - queues = virXMLPropString(cur, "queues"); - cmd_per_lun = virXMLPropString(cur, "cmd_per_lun"); - max_sectors = virXMLPropString(cur, "max_sectors"); + queues2 = virXMLPropString(cur, "queues"); + if (queues2) + queues = queues2; + cmd_per_lun2 = virXMLPropString(cur, "cmd_per_lun"); + if (cmd_per_lun2) + cmd_per_lun = cmd_per_lun2; + max_sectors2 = virXMLPropString(cur, "max_sectors"); + if (max_sectors2) + max_sectors = max_sectors2; } } cur = cur->next;
Without a proper explanation it's hard to see if the fix is right.
Peter
I found another way to fix this issue, please ignore this patch and i will give another one.
Luyao
participants (3)
-
lhuang
-
Luyao Huang
-
Peter Krempa