Add xl usb-assignable-list command to list assignable USB devices. Assignable USB device means the USB device type is assignable and it's not assigned to any guest yet.
Signed-off-by: Chunyan Liu <cy...@suse.com> --- Same as "libxl: add libxl_device_usb_assignable_list API" patch, this patch could be sqaushed to previous one. Split because of some dispute. Could be squashed if acceptable, otherwise could be removed. tools/libxl/xl.h | 1 + tools/libxl/xl_cmdimpl.c | 27 +++++++++++++++++++++++++++ tools/libxl/xl_cmdtable.c | 4 ++++ 3 files changed, 32 insertions(+) diff --git a/tools/libxl/xl.h b/tools/libxl/xl.h index ddd9690..2c6f370 100644 --- a/tools/libxl/xl.h +++ b/tools/libxl/xl.h @@ -85,6 +85,7 @@ int main_blockdetach(int argc, char **argv); int main_vtpmattach(int argc, char **argv); int main_vtpmlist(int argc, char **argv); int main_vtpmdetach(int argc, char **argv); +int main_usbassignable_list(int argc, char **argv); int main_usbctrl_attach(int argc, char **argv); int main_usbctrl_detach(int argc, char **argv); int main_usbattach(int argc, char **argv); diff --git a/tools/libxl/xl_cmdimpl.c b/tools/libxl/xl_cmdimpl.c index 25b472c..5043f25 100644 --- a/tools/libxl/xl_cmdimpl.c +++ b/tools/libxl/xl_cmdimpl.c @@ -3448,6 +3448,33 @@ int main_cd_insert(int argc, char **argv) return 0; } +static void usb_assignable_list(void) +{ + libxl_device_usb *usbs; + int num, i; + + usbs = libxl_device_usb_assignable_list(ctx, &num); + + for (i = 0; i < num; i++) { + printf("%d.%d\n", usbs[i].u.hostdev.hostbus, + usbs[i].u.hostdev.hostaddr); + } + + libxl_device_usb_list_free(usbs, num); +} + +int main_usbassignable_list(int argc, char **argv) +{ + int opt; + + SWITCH_FOREACH_OPT(opt, "", NULL, "usb-assignable-list", 0) { + /* No options */ + } + + usb_assignable_list(); + return 0; +} + int main_usbctrl_attach(int argc, char **argv) { uint32_t domid; diff --git a/tools/libxl/xl_cmdtable.c b/tools/libxl/xl_cmdtable.c index c7231ae..4e9c0c8 100644 --- a/tools/libxl/xl_cmdtable.c +++ b/tools/libxl/xl_cmdtable.c @@ -576,6 +576,10 @@ struct cmd_spec cmd_table[] = { "List information about USB devices for a domain", "<Domain>", }, + { "usb-assignable-list", + &main_usbassignable_list, 0, 0, + "List all assignable USB devices", + }, }; int cmdtable_len = sizeof(cmd_table)/sizeof(struct cmd_spec); -- 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@lists.xen.org http://lists.xen.org/xen-devel