All of lore.kernel.org
 help / color / mirror / Atom feed
From: Roger Pau Monne <roger.pau@citrix.com>
To: xen-devel@lists.xenproject.org
Cc: Wei Liu <wei.liu2@citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>,
	Roger Pau Monne <roger.pau@citrix.com>
Subject: [PATCH 1/4] libxl: set the device model version earlier in xenstore
Date: Thu, 7 Apr 2016 19:45:26 +0200	[thread overview]
Message-ID: <1460051129-20817-2-git-send-email-roger.pau@citrix.com> (raw)
In-Reply-To: <1460051129-20817-1-git-send-email-roger.pau@citrix.com>

So libxl doesn't have to pass the build info around just to get the device
model used by the guest. This allows to simplify
libxl__device_nic_setdefault.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Cc: Ian Jackson <ian.jackson@eu.citrix.com>
Cc: Wei Liu <wei.liu2@citrix.com>
---
 tools/libxl/libxl.c          | 24 +++++++-----------------
 tools/libxl/libxl_create.c   |  9 +++++++--
 tools/libxl/libxl_dm.c       |  3 +--
 tools/libxl/libxl_internal.h |  3 +--
 4 files changed, 16 insertions(+), 23 deletions(-)

diff --git a/tools/libxl/libxl.c b/tools/libxl/libxl.c
index 5cdc09e..d35fc33 100644
--- a/tools/libxl/libxl.c
+++ b/tools/libxl/libxl.c
@@ -3292,7 +3292,7 @@ out:
 /******************************************************************************/
 
 int libxl__device_nic_setdefault(libxl__gc *gc, libxl_device_nic *nic,
-                                 uint32_t domid, libxl_domain_build_info *info)
+                                 uint32_t domid)
 {
     int rc;
 
@@ -3330,21 +3330,11 @@ int libxl__device_nic_setdefault(libxl__gc *gc, libxl_device_nic *nic,
     switch (libxl__domain_type(gc, domid)) {
     case LIBXL_DOMAIN_TYPE_HVM:
         if (!nic->nictype) {
-            if (info != NULL) {
-                /* Path taken at creation time. */
-                if (info->device_model_version ==
-                    LIBXL_DEVICE_MODEL_VERSION_NONE)
-                    nic->nictype = LIBXL_NIC_TYPE_VIF;
-                else
-                    nic->nictype = LIBXL_NIC_TYPE_VIF_IOEMU;
-            } else {
-                /* Path taken when hot-adding a nic. */
-                if (libxl__device_model_version_running(gc, domid) ==
-                    LIBXL_DEVICE_MODEL_VERSION_NONE)
-                    nic->nictype = LIBXL_NIC_TYPE_VIF;
-                else
-                    nic->nictype = LIBXL_NIC_TYPE_VIF_IOEMU;
-            }
+            if (libxl__device_model_version_running(gc, domid) ==
+                LIBXL_DEVICE_MODEL_VERSION_NONE)
+                nic->nictype = LIBXL_NIC_TYPE_VIF;
+            else
+                nic->nictype = LIBXL_NIC_TYPE_VIF_IOEMU;
         }
         break;
     case LIBXL_DOMAIN_TYPE_PV:
@@ -3394,7 +3384,7 @@ void libxl__device_nic_add(libxl__egc *egc, uint32_t domid,
     libxl_device_nic_init(&nic_saved);
     libxl_device_nic_copy(CTX, &nic_saved, nic);
 
-    rc = libxl__device_nic_setdefault(gc, nic, domid, NULL);
+    rc = libxl__device_nic_setdefault(gc, nic, domid);
     if (rc) goto out;
 
     front = flexarray_make(gc, 16, 1);
diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index 4b02de9..24f168b 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -916,6 +916,12 @@ static void initiate_domain_create(libxl__egc *egc,
         goto error_out;
     }
 
+    /*
+     * Set the dm version quite early so that libxl doesn't have to pass the
+     * build info around just to know if the domain has a device model or not.
+     */
+    store_libxl_entry(gc, domid, &d_config->b_info);
+
     for (i = 0; i < d_config->num_disks; i++) {
         ret = libxl__device_disk_setdefault(gc, &d_config->disks[i]);
         if (ret) {
@@ -940,8 +946,7 @@ static void initiate_domain_create(libxl__egc *egc,
          * called libxl_device_nic_add when domcreate_launch_dm gets called,
          * but qemu needs the nic information to be complete.
          */
-        ret = libxl__device_nic_setdefault(gc, &d_config->nics[i], domid,
-                                           &d_config->b_info);
+        ret = libxl__device_nic_setdefault(gc, &d_config->nics[i], domid);
         if (ret) {
             LOG(ERROR, "Unable to set nic defaults for nic %d", i);
             goto error_out;
diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index eac5501..a12c90d 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -1810,8 +1810,7 @@ static void spawn_stub_launch_dm(libxl__egc *egc,
          * called libxl_device_nic_add at this point, but qemu needs
          * the nic information to be complete.
          */
-        ret = libxl__device_nic_setdefault(gc, &dm_config->nics[i], dm_domid,
-                                           &dm_config->b_info);
+        ret = libxl__device_nic_setdefault(gc, &dm_config->nics[i], dm_domid);
         if (ret)
             goto out;
     }
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 653c152..55896f8 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -1206,8 +1206,7 @@ _hidden int libxl__domain_build_info_setdefault(libxl__gc *gc,
 _hidden int libxl__device_disk_setdefault(libxl__gc *gc,
                                           libxl_device_disk *disk);
 _hidden int libxl__device_nic_setdefault(libxl__gc *gc, libxl_device_nic *nic,
-                                         uint32_t domid,
-                                         libxl_domain_build_info *info);
+                                         uint32_t domid);
 _hidden int libxl__device_vtpm_setdefault(libxl__gc *gc, libxl_device_vtpm *vtpm);
 _hidden int libxl__device_vfb_setdefault(libxl__gc *gc, libxl_device_vfb *vfb);
 _hidden int libxl__device_vkb_setdefault(libxl__gc *gc, libxl_device_vkb *vkb);
-- 
2.6.4 (Apple Git-63)


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
http://lists.xen.org/xen-devel

  reply	other threads:[~2016-04-07 17:45 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-04-07 17:45 [PATCH 0/4] libxl: fix CDROM issues Roger Pau Monne
2016-04-07 17:45 ` Roger Pau Monne [this message]
2016-04-08 13:14   ` [PATCH 1/4] libxl: set the device model version earlier in xenstore Wei Liu
2016-04-08 14:16     ` Roger Pau Monné
2016-04-08 14:24       ` Wei Liu
2016-04-07 17:45 ` [PATCH 2/4] libxl: set the backend type to Qdisk for CDROM devices on DM HVM guests Roger Pau Monne
2016-04-08 13:29   ` Wei Liu
2016-04-07 17:45 ` [PATCH 3/4] libxl: only allow guests with a device model to use cd-{eject/insert} Roger Pau Monne
2016-04-08 13:21   ` Wei Liu
2016-04-08 14:17     ` Roger Pau Monné
2016-04-08 14:25       ` Wei Liu
2016-04-08 14:34         ` Ian Jackson
2016-04-08 14:35         ` Roger Pau Monné
2016-04-08 14:47           ` Wei Liu
2016-04-08 14:51             ` Roger Pau Monné
2016-04-08 14:59               ` Andrew Cooper
2016-04-08 15:06                 ` George Dunlap
2016-04-08 15:07               ` Wei Liu
2016-04-07 17:45 ` [PATCH 4/4] libxl: remove code added to use the 'phy' backend with CDROM devices Roger Pau Monne
2016-04-08 13:30   ` Wei Liu
2016-04-08 15:07   ` Ian Jackson

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=1460051129-20817-2-git-send-email-roger.pau@citrix.com \
    --to=roger.pau@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=wei.liu2@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 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.