From: Wei Liu <wei.liu2@citrix.com>
To: Xen-devel <xen-devel@lists.xenproject.org>
Cc: Anthony PERARD <anthony.perard@citrix.com>,
Ian Jackson <ian.jackson@eu.citrix.com>,
Wei Liu <wei.liu2@citrix.com>
Subject: [PATCH v3 2/5] libxl: factor out libxl__get_device_modlel_version
Date: Wed, 15 Jun 2016 10:31:39 +0100 [thread overview]
Message-ID: <1465983102-19308-3-git-send-email-wei.liu2@citrix.com> (raw)
In-Reply-To: <1465983102-19308-1-git-send-email-wei.liu2@citrix.com>
Factor out the logic to determine device model version to a function. It
will be used later. Note that code now also checks if the stbudom field
is actually set before trying to extract a value from it.
No functional change.
Signed-off-by: Wei Liu <wei.liu2@citrix.com>
---
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Anthony PERARD <anthony.perard@citrix.com>
v3: new patch
---
tools/libxl/libxl_create.c | 35 ++++++++++++++++++++++++-----------
tools/libxl/libxl_internal.h | 5 +++++
2 files changed, 29 insertions(+), 11 deletions(-)
diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index 1b99472..45fd7bc 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -62,6 +62,28 @@ void libxl__rdm_setdefault(libxl__gc *gc, libxl_domain_build_info *b_info)
LIBXL_RDM_MEM_BOUNDARY_MEMKB_DEFAULT;
}
+libxl_device_model_version
+libxl__get_device_model_version(libxl__gc *gc,
+ const libxl_domain_build_info *b_info)
+{
+ libxl_device_model_version version = LIBXL_DEVICE_MODEL_VERSION_UNKNOWN;
+
+ if (b_info->type == LIBXL_DOMAIN_TYPE_HVM) {
+ if (!libxl_defbool_is_default(b_info->device_model_stubdomain) &&
+ libxl_defbool_val(b_info->device_model_stubdomain)) {
+ version = LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL;
+ } else {
+ version = libxl__default_device_model(gc);
+ }
+ } else {
+ version = LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN;
+ }
+
+ assert(version != LIBXL_DEVICE_MODEL_VERSION_UNKNOWN);
+
+ return version;
+}
+
int libxl__domain_build_info_setdefault(libxl__gc *gc,
libxl_domain_build_info *b_info)
{
@@ -80,17 +102,8 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc,
b_info->device_model_ssidref = SECINITSID_DOMDM;
if (!b_info->device_model_version) {
- if (b_info->type == LIBXL_DOMAIN_TYPE_HVM) {
- if (libxl_defbool_val(b_info->device_model_stubdomain)) {
- b_info->device_model_version =
- LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN_TRADITIONAL;
- } else {
- b_info->device_model_version = libxl__default_device_model(gc);
- }
- } else {
- b_info->device_model_version =
- LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN;
- }
+ b_info->device_model_version =
+ libxl__get_device_model_version(gc, b_info);
if (b_info->device_model_version
== LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN) {
const char *dm;
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index e7ab85d..3958313 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -1999,6 +1999,11 @@ _hidden int libxl__device_model_version_running(libxl__gc *gc, uint32_t domid);
/* Return the system-wide default device model */
_hidden libxl_device_model_version libxl__default_device_model(libxl__gc *gc);
+/* Derive device model version from build info */
+_hidden libxl_device_model_version
+libxl__get_device_model_version(libxl__gc *gc,
+ const libxl_domain_build_info *b_info);
+
#define DEVICE_MODEL_XS_PATH(gc, dm_domid, domid, fmt, _a...) \
libxl__sprintf(gc, "/local/domain/%u/device-model/%u" fmt, dm_domid, \
domid, ##_a)
--
2.1.4
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel
next prev parent reply other threads:[~2016-06-15 9:31 UTC|newest]
Thread overview: 23+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-06-15 9:31 [PATCH v3 0/5] libxl: libxl: update available vcpus map in retrieve configuration function Wei Liu
2016-06-15 9:31 ` [PATCH v3 1/5] libxl: libxl_domain_need_memory shouldn't modify b_info Wei Liu
2016-06-15 13:31 ` Dario Faggioli
2016-06-15 13:38 ` Wei Liu
2016-07-08 17:35 ` Ian Jackson
2016-07-11 11:03 ` Wei Liu
2016-06-15 9:31 ` Wei Liu [this message]
2016-06-15 13:27 ` [PATCH v3 2/5] libxl: factor out libxl__get_device_modlel_version Dario Faggioli
2016-06-15 17:04 ` Anthony PERARD
2016-07-08 17:37 ` Ian Jackson
2016-06-15 9:31 ` [PATCH v3 3/5] libxl: introduce libxl__qmp_query_cpus Wei Liu
2016-06-15 13:26 ` Dario Faggioli
2016-06-15 16:48 ` Anthony PERARD
2016-07-08 17:45 ` Ian Jackson
2016-06-15 9:31 ` [PATCH v3 4/5] libxl: update vcpus bitmap in retrieved guest config Wei Liu
2016-06-15 17:20 ` Anthony PERARD
2016-07-08 17:44 ` Ian Jackson
2016-07-11 11:31 ` Wei Liu
2016-07-11 14:59 ` Wei Liu
2016-06-15 9:31 ` [PATCH v3 5/5] libxl: only issue cpu-add call to QEMU for not present CPU Wei Liu
2016-07-08 17:48 ` Ian Jackson
2016-07-11 11:32 ` Wei Liu
2016-07-02 10:22 ` [PATCH v3 0/5] libxl: libxl: update available vcpus map in retrieve configuration function Wei Liu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1465983102-19308-3-git-send-email-wei.liu2@citrix.com \
--to=wei.liu2@citrix.com \
--cc=anthony.perard@citrix.com \
--cc=ian.jackson@eu.citrix.com \
--cc=xen-devel@lists.xenproject.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).