Skip to contentSkip to conversation

tools/xl:Call init and dispose function for libxl_dominfo

PATCH In review Uma Sharma 2 participants 5 messages Oct 20, 2014 – Oct 21, 2014

lore
Share & tools
lore

Uma Sharma

author
#0 lore raw

PATCH 4/4 tools/xl:Call init and dispose function for libxl_dominfo

This patch calls init and dispose function for libxl_dominfo type in function main_list in tools/libxl/xl_cmdimpl.c
IDL generated libxl types should be used only after calling the init function.

--

tools/libxl/xl_cmdimpl.c +2 -0
index 2e923b4..133e796 100644
@@ -4330,6 +4330,7 @@ int main_list(int argc, char **argv)
     libxl_dominfo *info, *info_free=0;
     int nb_domain, rc;
 
+    libxl_dominfo_init(&info_buf);
     SWITCH_FOREACH_OPT(opt, "lvhZn", opts, "list", 0) {
     case 'l':
         details = 1;
@@ -4381,6 +4382,7 @@ int main_list(int argc, char **argv)
     else
         libxl_dominfo_dispose(info);
 
+    libxl_dominfo_dispose(&info_buf);
     return 0;
 }
#1 lore raw
Quoted 20 lines · Uma Sharma

This patch calls init and dispose function for libxl_dominfo type in function main_list in tools/libxl/xl_cmdimpl.c
IDL generated libxl types should be used only after calling the init function.

--

tools/libxl/xl_cmdimpl.c +1 -0
index 2e923b4..133e796 100644
@@ -4330,6 +4330,7 @@ int main_list(int argc, char **argv)
     libxl_dominfo *info, *info_free=0;
     int nb_domain, rc;
 
+    libxl_dominfo_init(&info_buf);
     SWITCH_FOREACH_OPT(opt, "lvhZn", opts, "list", 0) {
     case 'l':
         details = 1;

tools/libxl/xl_cmdimpl.c int main_list(int argc, char **argv) · line 4385

Quoted 4 lines
tools/libxl/xl_cmdimpl.c +1 -0
@@ -4381,6 +4382,7 @@ int main_list(int argc, char **argv)
     else
         libxl_dominfo_dispose(info);
 
+    libxl_dominfo_dispose(&info_buf);

I'm sorry that main_list is a bit entangled. But I don't think the patch proposed here is right. There's one branch that makes info point to &info_buf.

Though we intend to make _dispose idempotent, but it's not idempotent for libxl_dominfo_dispose. Calling it on the same object twice yields no good result.

Wei.

Quoted 3 lines
tools/libxl/xl_cmdimpl.c +0 -0
     return 0;
 }
 
#2 lore raw
Quoted 30 lines · Wei Liu
Quoted 20 lines · Uma Sharma

This patch calls init and dispose function for libxl_dominfo type in function main_list in tools/libxl/xl_cmdimpl.c
IDL generated libxl types should be used only after calling the init function.

--

tools/libxl/xl_cmdimpl.c +1 -0
index 2e923b4..133e796 100644
@@ -4330,6 +4330,7 @@ int main_list(int argc, char **argv)
     libxl_dominfo *info, *info_free=0;
     int nb_domain, rc;
 
+    libxl_dominfo_init(&info_buf);
     SWITCH_FOREACH_OPT(opt, "lvhZn", opts, "list", 0) {
     case 'l':
         details = 1;

tools/libxl/xl_cmdimpl.c int main_list(int argc, char **argv) · line 4385

Quoted 4 lines
tools/libxl/xl_cmdimpl.c +1 -0
@@ -4381,6 +4382,7 @@ int main_list(int argc, char **argv)
     else
         libxl_dominfo_dispose(info);
 
+    libxl_dominfo_dispose(&info_buf);

I'm sorry that main_list is a bit entangled. But I don't think the patch proposed here is right. There's one branch that makes info point to &info_buf.

Quoted 6 lines

Though we intend to make _dispose idempotent, but it's not idempotent for libxl_dominfo_dispose. Calling it on the same object twice yields no good result.

Wei.

BTW I think main_sharing suffers from the same problem. If you figure out a way to improve main_list, you can take main_sharing as extra bonus. :-)

Wei.

Quoted 3 lines
Quoted 3 lines
tools/libxl/xl_cmdimpl.c +0 -0
     return 0;
 }
 
author
#3 lore raw

I was thinking to call _dispose at all the relevant exit sections of main_list instead calling at the end so that I can avoid calling _dispose twice on info_buf.
Will that work?

Regards,
Uma

Quoted 47 lines · Wei Liu
Quoted 30 lines · Wei Liu
Quoted 20 lines · Uma Sharma

This patch calls init and dispose function for libxl_dominfo type in function main_list in tools/libxl/xl_cmdimpl.c
IDL generated libxl types should be used only after calling the init function.

--

tools/libxl/xl_cmdimpl.c +1 -0
index 2e923b4..133e796 100644
@@ -4330,6 +4330,7 @@ int main_list(int argc, char **argv)
     libxl_dominfo *info, *info_free=0;
     int nb_domain, rc;
 
+    libxl_dominfo_init(&info_buf);
     SWITCH_FOREACH_OPT(opt, "lvhZn", opts, "list", 0) {
     case 'l':
         details = 1;

tools/libxl/xl_cmdimpl.c int main_list(int argc, char **argv) · line 4385

Quoted 4 lines
tools/libxl/xl_cmdimpl.c +1 -0
@@ -4381,6 +4382,7 @@ int main_list(int argc, char **argv)
     else
         libxl_dominfo_dispose(info);
 
+    libxl_dominfo_dispose(&info_buf);

I'm sorry that main_list is a bit entangled. But I don't think the patch proposed here is right. There's one branch that makes info point to &info_buf.

Quoted 6 lines

Though we intend to make _dispose idempotent, but it's not idempotent for libxl_dominfo_dispose. Calling it on the same object twice yields no good result.

Wei.

BTW I think main_sharing suffers from the same problem. If you figure out a way to improve main_list, you can take main_sharing as extra bonus. :-)

Wei.

Quoted 3 lines
Quoted 3 lines
tools/libxl/xl_cmdimpl.c +0 -0
     return 0;
 }
 
#4 lore raw
Quoted 5 lines · Uma Sharma

I was thinking to call _dispose at all the relevant exit sections of main_list instead calling at the end so that I can avoid calling _dispose twice on info_buf.
Will that work?

Not sure what you mean by "exit sections", but keep in mind that info is used by list_domains / list_domains_details, the way you described doesn't look right either.

You might need to spend some time disentangle that function first.

Wei.