@@ -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,
@@ -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,
@@ -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
@@ -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; \
@@ -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,
@@ -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.
*
@@ -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,
@@ -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
@@ -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,
@@ -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,