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

[Xen-devel] [PATCH v1 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>
Acked-by: Wei Liu <wei.liu2@xxxxxxxxxx>
---
 tools/libxl/libxl_9pfs.c     |  2 +-
 tools/libxl/libxl_console.c  |  4 ++--
 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_vtpm.c     |  2 +-
 8 files changed, 18 insertions(+), 15 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 4891aa1..1a0eb05 100644
--- a/tools/libxl/libxl_console.c
+++ b/tools/libxl/libxl_console.c
@@ -672,7 +672,7 @@ out:
     return AO_INPROGRESS;
 }
 
-static LIBXL_DEFINE_UPDATE_DEVID(vkb, "vkb")
+static LIBXL_DEFINE_UPDATE_DEVID(vkb)
 
 static int libxl__device_vfb_setdefault(libxl__gc *gc, uint32_t domid,
                                         libxl_device_vfb *vfb, bool hotplug)
@@ -728,7 +728,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 6e2c93f..1b796bd 100644
--- a/tools/libxl/libxl_device.c
+++ b/tools/libxl/libxl_device.c
@@ -1423,7 +1423,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;
@@ -1433,8 +1434,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 1e5e2e7..e9f3960 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -1242,7 +1242,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);
 
@@ -3461,13 +3462,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 e2512fc..4b1b131 100644
--- a/tools/libxl/libxl_nic.c
+++ b/tools/libxl/libxl_nic.c
@@ -138,7 +138,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 78a78c7..67d2fb4 100644
--- a/tools/libxl/libxl_usb.c
+++ b/tools/libxl/libxl_usb.c
@@ -430,7 +430,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 d9889b8..602e690 100644
--- a/tools/libxl/libxl_vdispl.c
+++ b/tools/libxl/libxl_vdispl.c
@@ -246,7 +246,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_vtpm.c b/tools/libxl/libxl_vtpm.c
index d273edd..f0a4610 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@xxxxxxxxxxxxxxxxxxxx
https://lists.xenproject.org/mailman/listinfo/xen-devel

 


Rackspace

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