[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Xen-devel] [PATCH 2/4] libxl: use libxl__device_kind in LIBXL_DEFINE_UPDATE_DEVID



From: Oleksandr Grytsov <oleksandr_grytsov@xxxxxxxx>

Use libxl__..._devtype.type to update device id.

Signed-off-by: Oleksandr Grytsov <oleksandr_grytsov@xxxxxxxx>
---
 tools/libxl/libxl_9pfs.c     |  2 +-
 tools/libxl/libxl_console.c  |  2 +-
 tools/libxl/libxl_device.c   |  7 ++++---
 tools/libxl/libxl_internal.h | 12 +++++++-----
 tools/libxl/libxl_nic.c      |  2 +-
 tools/libxl/libxl_usb.c      |  2 +-
 tools/libxl/libxl_vdispl.c   |  2 +-
 tools/libxl/libxl_vkb.c      |  2 +-
 tools/libxl/libxl_vsnd.c     |  2 +-
 tools/libxl/libxl_vtpm.c     |  2 +-
 10 files changed, 19 insertions(+), 16 deletions(-)

diff --git a/tools/libxl/libxl_9pfs.c b/tools/libxl/libxl_9pfs.c
index c3dd786..1298db1 100644
--- a/tools/libxl/libxl_9pfs.c
+++ b/tools/libxl/libxl_9pfs.c
@@ -37,7 +37,7 @@ static int libxl__device_from_p9(libxl__gc *gc, uint32_t 
domid,
    return 0;
 }
 
-static LIBXL_DEFINE_UPDATE_DEVID(p9, "9pfs")
+static LIBXL_DEFINE_UPDATE_DEVID(p9)
 
 static int libxl__set_xenstore_p9(libxl__gc *gc, uint32_t domid,
                                   libxl_device_p9 *p9,
diff --git a/tools/libxl/libxl_console.c b/tools/libxl/libxl_console.c
index b7c0d34..002bcae 100644
--- a/tools/libxl/libxl_console.c
+++ b/tools/libxl/libxl_console.c
@@ -643,7 +643,7 @@ out:
     return AO_INPROGRESS;
 }
 
-static LIBXL_DEFINE_UPDATE_DEVID(vfb, "vfb")
+static LIBXL_DEFINE_UPDATE_DEVID(vfb)
 
 static int libxl__set_xenstore_vfb(libxl__gc *gc, uint32_t domid,
                                    libxl_device_vfb *vfb,
diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c
index 7aaf493..f84422e 100644
--- a/tools/libxl/libxl_device.c
+++ b/tools/libxl/libxl_device.c
@@ -1386,7 +1386,8 @@ out:
 }
 
 /* common function to get next device id */
-int libxl__device_nextid(libxl__gc *gc, uint32_t domid, char *device)
+int libxl__device_nextid(libxl__gc *gc, uint32_t domid,
+                         libxl__device_kind device)
 {
     char *libxl_dom_path, **l;
     unsigned int nb;
@@ -1396,8 +1397,8 @@ int libxl__device_nextid(libxl__gc *gc, uint32_t domid, 
char *device)
         return nextid;
 
     l = libxl__xs_directory(gc, XBT_NULL,
-        GCSPRINTF("%s/device/%s", libxl_dom_path, device),
-                            &nb);
+        GCSPRINTF("%s/device/%s", libxl_dom_path,
+                  libxl__device_kind_to_string(device)), &nb);
     if (l == NULL || nb == 0)
         nextid = 0;
     else
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 10ad52f..ef9e781 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -1222,7 +1222,8 @@ _hidden int libxl__init_console_from_channel(libxl__gc 
*gc,
                                              libxl__device_console *console,
                                              int dev_num,
                                              libxl_device_channel *channel);
-_hidden int libxl__device_nextid(libxl__gc *gc, uint32_t domid, char *device);
+_hidden int libxl__device_nextid(libxl__gc *gc, uint32_t domid,
+                                 libxl__device_kind device);
 _hidden int libxl__resolve_domid(libxl__gc *gc, const char *name,
                                  uint32_t *domid);
 
@@ -3441,13 +3442,14 @@ _hidden void libxl__bootloader_run(libxl__egc*, 
libxl__bootloader_state *st);
         return AO_INPROGRESS;                                           \
     }
 
-#define LIBXL_DEFINE_UPDATE_DEVID(type, name)                           \
-    int libxl__device_##type##_update_devid(libxl__gc *gc,              \
+#define LIBXL_DEFINE_UPDATE_DEVID(name)                                 \
+    int libxl__device_##name##_update_devid(libxl__gc *gc,              \
                                             uint32_t domid,             \
-                                            libxl_device_##type *type)  \
+                                            libxl_device_##name *type)  \
     {                                                                   \
         if (type->devid == -1)                                          \
-            type->devid = libxl__device_nextid(gc, domid, name);        \
+            type->devid = libxl__device_nextid(gc, domid,               \
+                          libxl__##name##_devtype.type);                \
         if (type->devid < 0)                                            \
             return ERROR_FAIL;                                          \
         return 0;                                                       \
diff --git a/tools/libxl/libxl_nic.c b/tools/libxl/libxl_nic.c
index 44d0fa7..fb5ae44 100644
--- a/tools/libxl/libxl_nic.c
+++ b/tools/libxl/libxl_nic.c
@@ -139,7 +139,7 @@ static void libxl__update_config_nic(libxl__gc *gc, 
libxl_device_nic *dst,
     libxl_mac_copy(CTX, &dst->mac, &src->mac);
 }
 
-static LIBXL_DEFINE_UPDATE_DEVID(nic, "vif")
+static LIBXL_DEFINE_UPDATE_DEVID(nic)
 
 static int libxl__set_xenstore_nic(libxl__gc *gc, uint32_t domid,
                                    libxl_device_nic *nic,
diff --git a/tools/libxl/libxl_usb.c b/tools/libxl/libxl_usb.c
index 6ce6957..045b50a 100644
--- a/tools/libxl/libxl_usb.c
+++ b/tools/libxl/libxl_usb.c
@@ -432,7 +432,7 @@ static int libxl__device_usbdev_del_hvm(libxl__gc *gc, 
uint32_t domid,
     return libxl__qmp_run_command_flexarray(gc, domid, "device_del", qmp_args);
 }
 
-static LIBXL_DEFINE_UPDATE_DEVID(usbctrl, "vusb")
+static LIBXL_DEFINE_UPDATE_DEVID(usbctrl)
 
 /* AO operation to add a usb controller.
  *
diff --git a/tools/libxl/libxl_vdispl.c b/tools/libxl/libxl_vdispl.c
index 31409a4..f2d1444 100644
--- a/tools/libxl/libxl_vdispl.c
+++ b/tools/libxl/libxl_vdispl.c
@@ -249,7 +249,7 @@ out:
 LIBXL_DEFINE_DEVICE_ADD(vdispl)
 static LIBXL_DEFINE_DEVICES_ADD(vdispl)
 LIBXL_DEFINE_DEVICE_REMOVE(vdispl)
-static LIBXL_DEFINE_UPDATE_DEVID(vdispl, "vdispl")
+static LIBXL_DEFINE_UPDATE_DEVID(vdispl)
 LIBXL_DEFINE_DEVICE_LIST(vdispl)
 
 DEFINE_DEVICE_TYPE_STRUCT(vdispl, VDISPL,
diff --git a/tools/libxl/libxl_vkb.c b/tools/libxl/libxl_vkb.c
index 1cd7feb..13aa01f 100644
--- a/tools/libxl/libxl_vkb.c
+++ b/tools/libxl/libxl_vkb.c
@@ -160,7 +160,7 @@ out:
      return rc;
 }
 
-static LIBXL_DEFINE_UPDATE_DEVID(vkb, "vkbd")
+static LIBXL_DEFINE_UPDATE_DEVID(vkb)
 
 #define libxl__add_vkbs NULL
 #define libxl_device_vkb_compare NULL
diff --git a/tools/libxl/libxl_vsnd.c b/tools/libxl/libxl_vsnd.c
index f81a9e2..8dfda46 100644
--- a/tools/libxl/libxl_vsnd.c
+++ b/tools/libxl/libxl_vsnd.c
@@ -644,7 +644,7 @@ out:
 LIBXL_DEFINE_DEVICE_ADD(vsnd)
 static LIBXL_DEFINE_DEVICES_ADD(vsnd)
 LIBXL_DEFINE_DEVICE_REMOVE(vsnd)
-static LIBXL_DEFINE_UPDATE_DEVID(vsnd, "vsnd")
+static LIBXL_DEFINE_UPDATE_DEVID(vsnd)
 LIBXL_DEFINE_DEVICE_LIST(vsnd)
 
 DEFINE_DEVICE_TYPE_STRUCT(vsnd, VSND,
diff --git a/tools/libxl/libxl_vtpm.c b/tools/libxl/libxl_vtpm.c
index c645074..f9ba481 100644
--- a/tools/libxl/libxl_vtpm.c
+++ b/tools/libxl/libxl_vtpm.c
@@ -49,7 +49,7 @@ static void libxl__update_config_vtpm(libxl__gc *gc, 
libxl_device_vtpm *dst,
     libxl_uuid_copy(CTX, &dst->uuid, &src->uuid);
 }
 
-static LIBXL_DEFINE_UPDATE_DEVID(vtpm, "vtpm")
+static LIBXL_DEFINE_UPDATE_DEVID(vtpm)
 
 static int libxl__set_xenstore_vtpm(libxl__gc *gc, uint32_t domid,
                                     libxl_device_vtpm *vtpm,
-- 
2.7.4


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

 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.