xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
From: Anthony PERARD <anthony.perard@citrix.com>
To: <xen-devel@lists.xenproject.org>
Cc: Anthony PERARD <anthony.perard@citrix.com>,
	Ian Jackson <ian.jackson@eu.citrix.com>, Wei Liu <wl@xen.org>
Subject: [Xen-devel] [PATCH 15/15] libxl_usb: Use usbctrl instead of usbctrlinfo
Date: Fri, 14 Jun 2019 12:24:44 +0100	[thread overview]
Message-ID: <20190614112444.29980-16-anthony.perard@citrix.com> (raw)
In-Reply-To: <20190614112444.29980-1-anthony.perard@citrix.com>

The functions that calls usbctrl_getinfo() only needs information that
can be found in a `libxl_device_usbctrl'. So avoid calling
libxl_device_usbctrl_getinfo and call libxl_devid_to_device_usbctrl
instead. (libxl_device_usbctrl_getinfo needs a `libxl_device_usbctrl'
anyway.)

Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
---
 tools/libxl/libxl_usb.c | 49 +++++++++++------------------------------
 1 file changed, 13 insertions(+), 36 deletions(-)

diff --git a/tools/libxl/libxl_usb.c b/tools/libxl/libxl_usb.c
index de49f8620c..3d69379c20 100644
--- a/tools/libxl/libxl_usb.c
+++ b/tools/libxl/libxl_usb.c
@@ -518,13 +518,10 @@ void libxl__initiate_device_usbctrl_remove(libxl__egc *egc,
     uint32_t domid = aodev->dev->domid;
     int usbctrl_devid = aodev->dev->devid;
     libxl_device_usbctrl usbctrl;
-    libxl_usbctrlinfo usbctrlinfo;
 
     libxl_device_usbctrl_init(&usbctrl);
-    libxl_usbctrlinfo_init(&usbctrlinfo);
-    usbctrl.devid = usbctrl_devid;
-
-    rc = libxl_device_usbctrl_getinfo(CTX, domid, &usbctrl, &usbctrlinfo);
+    rc = libxl_devid_to_device_usbctrl(CTX, domid, usbctrl_devid,
+                                       &usbctrl);
     if (rc) goto out;
 
     /* Remove usb devices first */
@@ -541,7 +538,7 @@ void libxl__initiate_device_usbctrl_remove(libxl__egc *egc,
         }
     }
 
-    if (usbctrlinfo.type == LIBXL_USBCTRL_TYPE_DEVICEMODEL) {
+    if (usbctrl.type == LIBXL_USBCTRL_TYPE_DEVICEMODEL) {
         rc = libxl__device_usbctrl_del_hvm(gc, domid, usbctrl_devid);
         if (!rc)
             libxl__device_usbctrl_del_xenstore(gc, domid, &usbctrl);
@@ -549,7 +546,6 @@ void libxl__initiate_device_usbctrl_remove(libxl__egc *egc,
     }
 
     libxl_device_usbctrl_dispose(&usbctrl);
-    libxl_usbctrlinfo_dispose(&usbctrlinfo);
 
     /* Remove usbctrl */
     libxl__initiate_device_generic_remove(egc, aodev);
@@ -557,7 +553,6 @@ void libxl__initiate_device_usbctrl_remove(libxl__egc *egc,
 
 out:
     libxl_device_usbctrl_dispose(&usbctrl);
-    libxl_usbctrlinfo_dispose(&usbctrlinfo);
     aodev->rc = rc;
     aodev->callback(egc, aodev);
     return;
@@ -1531,16 +1526,12 @@ static int do_usbdev_add(libxl__gc *gc, uint32_t domid,
     int rc;
     char *busid;
     libxl_device_usbctrl usbctrl;
-    libxl_usbctrlinfo usbctrlinfo;
 
     libxl_device_usbctrl_init(&usbctrl);
-    libxl_usbctrlinfo_init(&usbctrlinfo);
-    usbctrl.devid = usbdev->ctrl;
-
-    rc = libxl_device_usbctrl_getinfo(CTX, domid, &usbctrl, &usbctrlinfo);
+    rc = libxl_devid_to_device_usbctrl(CTX, domid, usbdev->ctrl, &usbctrl);
     if (rc) goto out;
 
-    switch (usbctrlinfo.type) {
+    switch (usbctrl.type) {
     case LIBXL_USBCTRL_TYPE_PV:
         busid = usbdev_busaddr_to_busid(gc, usbdev->u.hostdev.hostbus,
                                         usbdev->u.hostdev.hostaddr);
@@ -1591,7 +1582,6 @@ static int do_usbdev_add(libxl__gc *gc, uint32_t domid,
 
 out:
     libxl_device_usbctrl_dispose(&usbctrl);
-    libxl_usbctrlinfo_dispose(&usbctrlinfo);
     return rc;
 }
 
@@ -1620,21 +1610,19 @@ static void libxl__device_usbdev_add(libxl__egc *egc, uint32_t domid,
     libxl_device_usbdev *assigned;
     int num_assigned;
     libxl_device_usbctrl usbctrl;
-    libxl_usbctrlinfo usbctrlinfo;
 
     libxl_device_usbctrl_init(&usbctrl);
-    libxl_usbctrlinfo_init(&usbctrlinfo);
 
     /* Currently only support adding USB device from Dom0 backend.
      * So, if USB controller is specified, check its backend domain,
      * if it's not Dom0, report error.
      */
     if (usbdev->ctrl != -1) {
-        usbctrl.devid = usbdev->ctrl;
-        rc = libxl_device_usbctrl_getinfo(CTX, domid, &usbctrl, &usbctrlinfo);
+        rc = libxl_devid_to_device_usbctrl(CTX, domid, usbdev->ctrl,
+                                           &usbctrl);
         if (rc) goto out;
 
-        if (usbctrlinfo.backend_id != LIBXL_TOOLSTACK_DOMID) {
+        if (usbctrl.backend_domid != LIBXL_TOOLSTACK_DOMID) {
             LOGD(ERROR, domid,
                  "Don't support adding USB device from non-Dom0 backend");
             rc = ERROR_INVAL;
@@ -1674,7 +1662,6 @@ static void libxl__device_usbdev_add(libxl__egc *egc, uint32_t domid,
 
 out:
     libxl_device_usbctrl_dispose(&usbctrl);
-    libxl_usbctrlinfo_dispose(&usbctrlinfo);
     aodev->rc = rc;
     aodev->callback(egc, aodev);
     return;
@@ -1689,18 +1676,14 @@ static int do_usbdev_remove(libxl__gc *gc, uint32_t domid,
     int rc;
     char *busid;
     libxl_device_usbctrl usbctrl;
-    libxl_usbctrlinfo usbctrlinfo;
 
     libxl_device_usbctrl_init(&usbctrl);
-    libxl_usbctrlinfo_init(&usbctrlinfo);
-    usbctrl.devid = usbdev->ctrl;
-
-    rc = libxl_device_usbctrl_getinfo(CTX, domid, &usbctrl, &usbctrlinfo);
+    rc = libxl_devid_to_device_usbctrl(CTX, domid, usbdev->ctrl, &usbctrl);
     if (rc) goto out;
 
-    switch (usbctrlinfo.type) {
+    switch (usbctrl.type) {
     case LIBXL_USBCTRL_TYPE_PV:
-        busid = usbdev_busid_from_ctrlport(gc, domid, usbdev, usbctrlinfo.type);
+        busid = usbdev_busid_from_ctrlport(gc, domid, usbdev, usbctrl.type);
         if (!busid) {
             rc = ERROR_FAIL;
             goto out;
@@ -1772,7 +1755,6 @@ static int do_usbdev_remove(libxl__gc *gc, uint32_t domid,
 
 out:
     libxl_device_usbctrl_dispose(&usbctrl);
-    libxl_usbctrlinfo_dispose(&usbctrlinfo);
     return rc;
 }
 
@@ -1787,7 +1769,6 @@ static int do_usbdev_remove(libxl__gc *gc, uint32_t domid,
 static int libxl__device_usbdev_remove(libxl__gc *gc, uint32_t domid,
                                        libxl_device_usbdev *usbdev)
 {
-    libxl_usbctrlinfo usbctrlinfo;
     libxl_device_usbctrl usbctrl;
     int rc;
 
@@ -1797,13 +1778,10 @@ static int libxl__device_usbdev_remove(libxl__gc *gc, uint32_t domid,
     }
 
     libxl_device_usbctrl_init(&usbctrl);
-    libxl_usbctrlinfo_init(&usbctrlinfo);
-    usbctrl.devid = usbdev->ctrl;
-
-    rc = libxl_device_usbctrl_getinfo(CTX, domid, &usbctrl, &usbctrlinfo);
+    rc = libxl_devid_to_device_usbctrl(CTX, domid, usbdev->ctrl, &usbctrl);
     if (rc) goto out;
 
-    if (usbctrlinfo.backend_id != LIBXL_TOOLSTACK_DOMID) {
+    if (usbctrl.backend_domid != LIBXL_TOOLSTACK_DOMID) {
         LOGD(ERROR, domid,
              "Don't support removing USB device from non-Dom0 backend");
         rc = ERROR_INVAL;
@@ -1815,7 +1793,6 @@ static int libxl__device_usbdev_remove(libxl__gc *gc, uint32_t domid,
 
 out:
     libxl_device_usbctrl_dispose(&usbctrl);
-    libxl_usbctrlinfo_dispose(&usbctrlinfo);
     return rc;
 }
 
-- 
Anthony PERARD


_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

  parent reply	other threads:[~2019-06-14 11:28 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-06-14 11:24 [Xen-devel] [PATCH 00/15] Some cleanup of libxl Anthony PERARD
2019-06-14 11:24 ` [Xen-devel] [PATCH 01/15] libxl: Rename struct libxl_device_type to libxl__device_type Anthony PERARD
2019-09-17 16:28   ` Ian Jackson
2019-06-14 11:24 ` [Xen-devel] [PATCH 02/15] libxl: Remove unused variable in libxl__device_pci_add_xenstore Anthony PERARD
2019-09-17 16:31   ` Ian Jackson
2019-06-14 11:24 ` [Xen-devel] [PATCH 03/15] libxl_pci: Make libxl__create_pci_backend static Anthony PERARD
2019-09-17 16:40   ` Ian Jackson
2019-06-14 11:24 ` [Xen-devel] [PATCH 04/15] libxl_pci: Constify arg `pcidev' of libxl__device_pci_add_xenstore Anthony PERARD
2019-09-17 16:41   ` Ian Jackson
2019-06-14 11:24 ` [Xen-devel] [PATCH 05/15] libxl_pci: `starting' is a bool Anthony PERARD
2019-09-17 16:41   ` Ian Jackson
2019-06-14 11:24 ` [Xen-devel] [PATCH 06/15] libxl_dom_save: Reorder functions for switch_qemu_logdirty Anthony PERARD
2019-09-17 16:41   ` Ian Jackson
2019-06-14 11:24 ` [Xen-devel] [PATCH 07/15] libxl_dm: Fix initialisation of libxl__stub_dm_spawn_state Anthony PERARD
2019-09-17 16:42   ` Ian Jackson
2019-06-14 11:24 ` [Xen-devel] [PATCH 08/15] libxl: Comment libxl__dm_spawn_state aboud init and dispose Anthony PERARD
2019-09-17 16:42   ` Ian Jackson
2019-06-14 11:24 ` [Xen-devel] [PATCH 09/15] libxl_domain: Cleanup libxl__destroy_domid Anthony PERARD
2019-09-17 16:42   ` Ian Jackson
2019-06-14 11:24 ` [Xen-devel] [PATCH 10/15] libxl_usb: Use proper domid value, from libxl__device Anthony PERARD
2019-09-17 16:43   ` Ian Jackson
2019-06-14 11:24 ` [Xen-devel] [PATCH 11/15] libxl_usb: Fix wrong usage of asserts Anthony PERARD
2019-09-17 16:44   ` Ian Jackson
2019-09-18 10:17     ` Anthony PERARD
2019-09-18 10:39       ` Ian Jackson
2019-09-19 10:03         ` [Xen-devel] [PATCH v2 " Anthony PERARD
2019-09-19 11:21           ` Ian Jackson
2019-06-14 11:24 ` [Xen-devel] [PATCH 12/15] libxl_usb: Fix libxl_device_usbctrl_getinfo Anthony PERARD
2019-09-17 16:44   ` Ian Jackson
2019-06-14 11:24 ` [Xen-devel] [PATCH 13/15] libxl: Constify libxl_device_* param of *_getinfo Anthony PERARD
2019-09-17 16:45   ` Ian Jackson
2019-06-14 11:24 ` [Xen-devel] [PATCH 14/15] libxl_usb: usbctrl, make use of generic device handling functions Anthony PERARD
2019-09-17 16:46   ` Ian Jackson
2019-06-14 11:24 ` Anthony PERARD [this message]
2019-09-17 16:46   ` [Xen-devel] [PATCH 15/15] libxl_usb: Use usbctrl instead of usbctrlinfo Ian Jackson
2019-09-19 17:07 ` [Xen-devel] [PATCH 00/15] Some cleanup of libxl Anthony PERARD

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=20190614112444.29980-16-anthony.perard@citrix.com \
    --to=anthony.perard@citrix.com \
    --cc=ian.jackson@eu.citrix.com \
    --cc=wl@xen.org \
    --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).