* [PATCH] tools/helpers: don't hardcode domain type for dom0 and xenstore domain
@ 2018-07-25 13:25 Juergen Gross
2018-07-25 13:31 ` Wei Liu
0 siblings, 1 reply; 3+ messages in thread
From: Juergen Gross @ 2018-07-25 13:25 UTC (permalink / raw)
To: xen-devel; +Cc: Juergen Gross, wei.liu2, ian.jackson
Today when setting up a minimal domain configuration file for dom0 and
eventually xenstore-domain the domain type is harcoded as PV. Change
that by asking the hypervisor for the correct type.
Signed-off-by: Juergen Gross <jgross@suse.com>
---
tools/helpers/init-dom-json.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/tools/helpers/init-dom-json.c b/tools/helpers/init-dom-json.c
index 91b1fdf3db..3bcf697ecf 100644
--- a/tools/helpers/init-dom-json.c
+++ b/tools/helpers/init-dom-json.c
@@ -13,6 +13,7 @@ int gen_stub_json_config(uint32_t domid)
xentoollog_logger_stdiostream *logger;
libxl_ctx *ctx;
libxl_domain_config dom_config;
+ libxl_dominfo dominfo;
char *json = NULL;
logger = xtl_createlogger_stdiostream(stderr, XTL_ERROR, 0);
@@ -25,12 +26,19 @@ int gen_stub_json_config(uint32_t domid)
goto outlog;
}
+ libxl_dominfo_init(&dominfo);
+ if (libxl_domain_info(ctx, &dominfo, domid)) {
+ fprintf(stderr, "cannot get domain type\n");
+ goto outdispose;
+ }
+
libxl_domain_config_init(&dom_config);
/* Generate stub JSON config. */
- dom_config.c_info.type = LIBXL_DOMAIN_TYPE_PV;
+ dom_config.c_info.type = (dominfo.domain_type == LIBXL_DOMAIN_TYPE_HVM)
+ ? LIBXL_DOMAIN_TYPE_PVH : LIBXL_DOMAIN_TYPE_PV;
libxl_domain_build_info_init_type(&dom_config.b_info,
- LIBXL_DOMAIN_TYPE_PV);
+ dom_config.c_info.type);
json = libxl_domain_config_to_json(ctx, &dom_config);
/* libxl-json format requires the string ends with '\0'. Code
@@ -42,6 +50,8 @@ int gen_stub_json_config(uint32_t domid)
if (rc)
fprintf(stderr, "cannot store stub json config for domain %u\n", domid);
+outdispose:
+ libxl_dominfo_dispose(&dominfo);
libxl_domain_config_dispose(&dom_config);
free(json);
libxl_ctx_free(ctx);
--
2.13.7
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] tools/helpers: don't hardcode domain type for dom0 and xenstore domain
2018-07-25 13:25 [PATCH] tools/helpers: don't hardcode domain type for dom0 and xenstore domain Juergen Gross
@ 2018-07-25 13:31 ` Wei Liu
2018-07-25 13:38 ` Juergen Gross
0 siblings, 1 reply; 3+ messages in thread
From: Wei Liu @ 2018-07-25 13:31 UTC (permalink / raw)
To: Juergen Gross; +Cc: xen-devel, ian.jackson, wei.liu2
On Wed, Jul 25, 2018 at 03:25:26PM +0200, Juergen Gross wrote:
> Today when setting up a minimal domain configuration file for dom0 and
> eventually xenstore-domain the domain type is harcoded as PV. Change
> that by asking the hypervisor for the correct type.
>
> Signed-off-by: Juergen Gross <jgross@suse.com>
> ---
> tools/helpers/init-dom-json.c | 14 ++++++++++++--
> 1 file changed, 12 insertions(+), 2 deletions(-)
>
> diff --git a/tools/helpers/init-dom-json.c b/tools/helpers/init-dom-json.c
> index 91b1fdf3db..3bcf697ecf 100644
> --- a/tools/helpers/init-dom-json.c
> +++ b/tools/helpers/init-dom-json.c
> @@ -13,6 +13,7 @@ int gen_stub_json_config(uint32_t domid)
> xentoollog_logger_stdiostream *logger;
> libxl_ctx *ctx;
> libxl_domain_config dom_config;
> + libxl_dominfo dominfo;
> char *json = NULL;
>
> logger = xtl_createlogger_stdiostream(stderr, XTL_ERROR, 0);
> @@ -25,12 +26,19 @@ int gen_stub_json_config(uint32_t domid)
> goto outlog;
> }
>
> + libxl_dominfo_init(&dominfo);
> + if (libxl_domain_info(ctx, &dominfo, domid)) {
> + fprintf(stderr, "cannot get domain type\n");
> + goto outdispose;
> + }
> +
> libxl_domain_config_init(&dom_config);
You should move this before the dominfo initialisation, otherwise
outdispose path is wrong.
Wei.
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] tools/helpers: don't hardcode domain type for dom0 and xenstore domain
2018-07-25 13:31 ` Wei Liu
@ 2018-07-25 13:38 ` Juergen Gross
0 siblings, 0 replies; 3+ messages in thread
From: Juergen Gross @ 2018-07-25 13:38 UTC (permalink / raw)
To: Wei Liu; +Cc: xen-devel, ian.jackson
On 25/07/18 15:31, Wei Liu wrote:
> On Wed, Jul 25, 2018 at 03:25:26PM +0200, Juergen Gross wrote:
>> Today when setting up a minimal domain configuration file for dom0 and
>> eventually xenstore-domain the domain type is harcoded as PV. Change
>> that by asking the hypervisor for the correct type.
>>
>> Signed-off-by: Juergen Gross <jgross@suse.com>
>
>> ---
>> tools/helpers/init-dom-json.c | 14 ++++++++++++--
>> 1 file changed, 12 insertions(+), 2 deletions(-)
>>
>> diff --git a/tools/helpers/init-dom-json.c b/tools/helpers/init-dom-json.c
>> index 91b1fdf3db..3bcf697ecf 100644
>> --- a/tools/helpers/init-dom-json.c
>> +++ b/tools/helpers/init-dom-json.c
>> @@ -13,6 +13,7 @@ int gen_stub_json_config(uint32_t domid)
>> xentoollog_logger_stdiostream *logger;
>> libxl_ctx *ctx;
>> libxl_domain_config dom_config;
>> + libxl_dominfo dominfo;
>> char *json = NULL;
>>
>> logger = xtl_createlogger_stdiostream(stderr, XTL_ERROR, 0);
>> @@ -25,12 +26,19 @@ int gen_stub_json_config(uint32_t domid)
>> goto outlog;
>> }
>>
>> + libxl_dominfo_init(&dominfo);
>> + if (libxl_domain_info(ctx, &dominfo, domid)) {
>> + fprintf(stderr, "cannot get domain type\n");
>> + goto outdispose;
>> + }
>> +
>> libxl_domain_config_init(&dom_config);
>
> You should move this before the dominfo initialisation, otherwise
> outdispose path is wrong.
Uuh, right.
V2 coming soon...
Juergen
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2018-07-25 13:38 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-07-25 13:25 [PATCH] tools/helpers: don't hardcode domain type for dom0 and xenstore domain Juergen Gross
2018-07-25 13:31 ` Wei Liu
2018-07-25 13:38 ` Juergen Gross
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.