libxl: add support for qemu base pvusb backend
v4 cover libxl: add support for qemu base pvusb backend
This patch series is meant to be applied on top of Chunyan's series to support pvusb in libxl.
It is adding support for an alternative pvusb backend "qusb" via qemu.
Changes in V4:
- dropped patch 5
- patch 1: Return (negative) error value in case of failure, 0 or 1 else
- patch 2: Bail out in case of usbback_is_loaded() error as requested by Chun Yan Liu
Changes in V3:
- added new patches 3 and 4 to at least report failure in case no device model is running when adding devices to a domain requiring a dm.
Changes in V2:
- patch 1: Return false if libxl__get_domid() fails as requested by George Dunlap
- Swapped patches 2 and 3 as former patch 2 has been questioned to make sense for 4.7. This will remove an obstacle for former patch 3 to go in.
Juergen Gross (4):
libxl: make libxl__need_xenpv_qemu() operate on domain config
libxl: add new pvusb backend "qusb" provided by qemu
libxl: add service function to check whether device model is running
libxl: check for dynamic device model start required
docs/man/xl.cfg.pod.5 | 11 +++- tools/libxl/libxl.c | 16 ++++- tools/libxl/libxl_create.c | 12 ++-- tools/libxl/libxl_device.c | 3 +- tools/libxl/libxl_dm.c | 96 ++++++++++++++++------------- tools/libxl/libxl_internal.h | 10 ++-- tools/libxl/libxl_pci.c | 3 + tools/libxl/libxl_pvusb.c | 113 ++++++++++++++++++++++++++++------- tools/libxl/libxl_types.idl | 1 + tools/libxl/libxl_types_internal.idl | 1 + 10 files changed, 185 insertions(+), 81 deletions(-)
Signature · 7 lines
2.6.2 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
PATCH v4 1/4 libxl: make libxl__need_xenpv_qemu() operate on domain config
libxl__need_xenpv_qemu() is called with configuration data for console, vfbs, disks and channels today in order to evaluate the need for starting a device model for a pv domain.
The console data is local to the caller and setup in a way to never require a device model. All other data is taken from the domain config structure.
In order to support other device backends via qemu change the interface of libxl__need_xenpv_qemu() to take the domain config structure as input instead of the single device arrays.
---
V4: Return (negative) error value in case of failure, 0 or 1 else
V2: Return false if libxl__get_domid() fails as requested by George Dunlap
--- tools/libxl/libxl_create.c | 12 +++------ tools/libxl/libxl_dm.c | 60 +++++++++++++------------------------------- tools/libxl/libxl_internal.h | 5 +--- 3 files changed, 23 insertions(+), 54 deletions(-)
tools/libxl/libxl_create.c +4 -8
@@ -1304,7 +1304,6 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev, }case LIBXL_DOMAIN_TYPE_PV : { -int need_qemu =0 ;libxl__device_console console;libxl__device device;
@@ -1314,17 +1313,14 @@ static void domcreate_launch_dm(libxl__egc *egc, libxl__multidev *multidev, }init_console_info (gc, &console,0 ); - - need_qemu =libxl__need_xenpv_qemu (gc,1 , &console, - d_config->num_vfbs, d_config->vfbs, - d_config->num_disks, &d_config->disks[0 ], - d_config->num_channels, &d_config->channels[0 ]); - console.backend_domid = state->console_domid;libxl__device_console_add (gc, domid, &console, state, &device);libxl__device_console_dispose (&console); -if (need_qemu) { + ret =libxl__need_xenpv_qemu (gc, d_config); +if (ret <0 ) + goto error_out; +if (ret) { dcs->dmss.dm.guest_domid = domid;libxl__spawn_local_dm (egc, &dcs->dmss.dm);return ;
tools/libxl/libxl_dm.c +18 -42
79 lines not on this page · raw message
tools/libxl/libxl_internal.h +1 -4
@@ -1616,10 +1616,7 @@ _hidden int libxl__domain_build(libxl__gc *gc, _hidden const char *libxl__domain_device_model(libxl__gc *gc,const libxl_domain_build_info *info); _hidden int libxl__need_xenpv_qemu(libxl__gc *gc, -int nr_consoles,libxl__device_console *consoles, -int nr_vfbs,libxl_device_vfb *vfbs, -int nr_disks,libxl_device_disk *disks, -int nr_channels,libxl_device_channel *channels); +libxl_domain_config *d_config);/* * This function will fix reserved device memory conflict
Signature · 7 lines
2.6.2 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
PATCH v4 2/4 libxl: add new pvusb backend "qusb" provided by qemu
In reply to Juergen GrossAdd a new pvusb backend type "qusb" which is provided by qemu. It can be selected either by specifying the type directly in the configuration or it is selected automatically by libxl in case there is no "usbback" driver loaded.
---
V4: bail out in case of usbback_is_loaded() error as requested by
Chun Yan Liu
--- docs/man/xl.cfg.pod.5 | 11 +++- tools/libxl/libxl_device.c | 3 +- tools/libxl/libxl_dm.c | 8 +++ tools/libxl/libxl_internal.h | 1 + tools/libxl/libxl_pvusb.c | 107 +++++++++++++++++++++++++++-------- tools/libxl/libxl_types.idl | 1 + tools/libxl/libxl_types_internal.idl | 1 + 7 files changed, 106 insertions(+), 26 deletions(-)
docs/man/xl.cfg.pod.5 +9 -2
@@ -737,8 +737,15 @@ Possible B<KEY>s are: =item B<type=TYPE> -Specifies the usb controller type. Currently only 'pv' and 'auto' -are supported. +Specifies the usb controller type. + +"pv" denotes a kernel based pvusb backend. + +"qusb" specifies a qemu base backend for pvusb. + +"auto" (the default) determines whether a kernel based backend is installed. +If this is the case, "pv" is selected, "qusb" will be selected if no kernel +backend is currently available. =item B<version=VERSION>
tools/libxl/libxl_device.c +2 -1
@@ -680,7 +680,8 @@ void libxl__devices_destroy(libxl__egc *egc, libxl__devices_remove_state *drs) aodev->action =LIBXL__DEVICE_ACTION_REMOVE ; aodev->dev = dev; aodev->force = drs->force; -if (dev->backend_kind ==LIBXL__DEVICE_KIND_VUSB ) +if (dev->backend_kind ==LIBXL__DEVICE_KIND_VUSB || + dev->backend_kind ==LIBXL__DEVICE_KIND_QUSB )libxl__initiate_device_usbctrl_remove (egc, aodev);else libxl__initiate_device_generic_remove (egc, aodev);
tools/libxl/libxl_dm.c +8 -0
@@ -2147,6 +2147,14 @@ int libxl__need_xenpv_qemu(libxl__gc *gc, libxl_domain_config *d_config) } } +for (i =0 ; i < d_config->num_usbctrls; i++) { +if (d_config->usbctrls[i].type ==LIBXL_USBCTRL_TYPE_QUSB && + d_config->usbctrls[i].backend_domid == domid) { + ret =1 ; + goto out; + } + } + out:return ret; }
tools/libxl/libxl_internal.h +1 -0
@@ -487,6 +487,7 @@ typedef struct {#define QEMU_BACKEND (dev) (\ (dev)->backend_kind == LIBXL__DEVICE_KIND_QDISK || \ (dev)->backend_kind == LIBXL__DEVICE_KIND_VFB || \ + (dev)->backend_kind == LIBXL__DEVICE_KIND_QUSB || \ (dev)->backend_kind == LIBXL__DEVICE_KIND_VKBD)#define XC_PCI_BDF "0x%x, 0x%x, 0x%x, 0x%x"
tools/libxl/libxl_pvusb.c +84 -23
248 lines not on this page · raw message
tools/libxl/libxl_types.idl +1 -0
@@ -618,6 +618,7 @@ libxl_usbctrl_type = Enumeration("usbctrl_type", [ (0, "AUTO"), (1, "PV"), (2, "DEVICEMODEL"), + (3, "QUSB"), ]) libxl_usbdev_type = Enumeration("usbdev_type", [
tools/libxl/libxl_types_internal.idl +1 -0
@@ -23,6 +23,7 @@ libxl__device_kind = Enumeration("device_kind", [ (7, "CONSOLE"), (8, "VTPM"), (9, "VUSB"), + (10, "QUSB"), ]) libxl__console_backend = Enumeration("console_backend", [
Signature · 7 lines
2.6.2 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
PATCH v4 3/4 libxl: add service function to check whether device model is running
In reply to Juergen GrossAdd an internal service function to check for a running device model. This can be used later when adding devices to a domain requiring a device model for either printing an error message or starting the device model in case it is not already running.
--- tools/libxl/libxl.c | 4 +--- tools/libxl/libxl_dm.c | 10 ++++++++++ 2 files changed, 11 insertions(+), 3 deletions(-)
tools/libxl/libxl.c +1 -3
@@ -1532,7 +1532,6 @@ void libxl__destroy_domid(libxl__egc *egc, libxl__destroy_domid_state *dis)libxl_ctx *ctx =CTX ;uint32_t domid = dis->domid;char *dom_path; -char *pid;int rc, dm_present;libxl__ev_child_init (&dis->destroyer);
@@ -1555,8 +1554,7 @@ void libxl__destroy_domid(libxl__egc *egc, libxl__destroy_domid_state *dis) }/* fall through */ case LIBXL_DOMAIN_TYPE_PV : - pid =libxl__xs_read (gc,XBT_NULL ,GCSPRINTF ("/local/domain/%d/image/device-model-pid" , domid)); - dm_present = (pid !=NULL ); + dm_present =libxl__dm_active (gc, domid);break ;case LIBXL_DOMAIN_TYPE_INVALID : rc =ERROR_FAIL ;
tools/libxl/libxl_dm.c +10 -0
@@ -2159,6 +2159,16 @@ out:return ret; } +int libxl__dm_active (libxl__gc *gc,uint32_t domid) +{ +char *pid, *path; + + path =GCSPRINTF ("/local/domain/%d/image/device-model-pid" , domid); + pid =libxl__xs_read (gc,XBT_NULL , path); + +return pid !=NULL ; +} +/* * Local variables: * mode: C
Signature · 7 lines
2.6.2 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
PATCH v4 4/4 libxl: check for dynamic device model start required
In reply to Juergen GrossAdd a service routine checking whether a device model must be started after adding a device to a domain.
--- tools/libxl/libxl.c | 12 ++++++++++++ tools/libxl/libxl_dm.c | 22 ++++++++++++++++++++++ tools/libxl/libxl_internal.h | 4 ++++ tools/libxl/libxl_pci.c | 3 +++ tools/libxl/libxl_pvusb.c | 6 ++++++ 5 files changed, 47 insertions(+)
tools/libxl/libxl.c +12 -0
@@ -2084,6 +2084,9 @@ void libxl__device_vtpm_add(libxl__egc *egc, uint32_t domid,if (rc) goto out;DEVICE_ADD (vtpm, vtpms, domid, &vtpm_saved,COMPARE_DEVID , &d_config); + + rc =libxl__dm_check_start (gc, &d_config, domid); +if (rc) goto out; }for (;;) {
@@ -2388,6 +2391,9 @@ static void device_disk_add(libxl__egc *egc, uint32_t domid,if (rc) goto out;DEVICE_ADD (disk, disks, domid, &disk_saved,COMPARE_DISK , &d_config); + + rc =libxl__dm_check_start (gc, &d_config, domid); +if (rc) goto out; }for (;;) {
@@ -2928,6 +2934,9 @@ int libxl_cdrom_insert(libxl_ctx *ctx, uint32_t domid, libxl_device_disk *disk,DEVICE_ADD (disk, disks, domid, &disk_saved,COMPARE_DISK , &d_config); + rc =libxl__dm_check_start (gc, &d_config, domid); +if (rc) goto out; +if (dm_ver ==LIBXL_DEVICE_MODEL_VERSION_QEMU_XEN ) { rc =libxl__qmp_insert_cdrom (gc, domid, disk);if (rc) goto out;
@@ -3354,6 +3363,9 @@ void libxl__device_nic_add(libxl__egc *egc, uint32_t domid,if (rc) goto out;DEVICE_ADD (nic, nics, domid, &nic_saved,COMPARE_DEVID , &d_config); + + rc =libxl__dm_check_start (gc, &d_config, domid); +if (rc) goto out; }for (;;) {
tools/libxl/libxl_dm.c +22 -0
@@ -2169,6 +2169,28 @@ int libxl__dm_active(libxl__gc *gc, uint32_t domid)return pid !=NULL ; } +int libxl__dm_check_start (libxl__gc *gc,libxl_domain_config *d_config, +uint32_t domid) +{ +int rc; + +if (libxl__dm_active (gc, domid)) +return 0 ; + + rc =libxl__need_xenpv_qemu (gc, d_config); +if (rc <0 ) + goto out; + +if (!rc) +return 0 ; + +LOG (ERROR ,"device model required but not running" ); + rc =ERROR_FAIL ; + +out: +return rc; +} +/* * Local variables: * mode: C
tools/libxl/libxl_internal.h +4 -0
@@ -1618,6 +1618,10 @@ _hidden const char *libxl__domain_device_model(libxl__gc *gc, const libxl_domain_build_info *info); _hidden int libxl__need_xenpv_qemu(libxl__gc *gc,libxl_domain_config *d_config); +_hidden int libxl__dm_active(libxl__gc *gc, uint32_t domid); +_hidden int libxl__dm_check_start(libxl__gc *gc, +libxl_domain_config *d_config, +uint32_t domid);/* * This function will fix reserved device memory conflict
tools/libxl/libxl_pci.c +3 -0
@@ -169,6 +169,9 @@ static int libxl__device_pci_add_xenstore(libxl__gc *gc, uint32_t domid, libxl_dDEVICE_ADD (pci, pcidevs, domid, &pcidev_saved,COMPARE_PCI , &d_config); + rc =libxl__dm_check_start (gc, &d_config, domid); +if (rc) goto out; +for (;;) { rc =libxl__xs_transaction_start (gc, &t);if (rc) goto out;
tools/libxl/libxl_pvusb.c +6 -0
@@ -144,6 +144,9 @@ static int libxl__device_usbctrl_add_xenstore(libxl__gc *gc, uint32_t domid,DEVICE_ADD (usbctrl, usbctrls, domid, &usbctrl_saved,COMPARE_USBCTRL , &d_config); + + rc =libxl__dm_check_start (gc, &d_config, domid); +if (rc) goto out; }for (;;) {
@@ -960,6 +963,9 @@ static int libxl__device_usbdev_add_xenstore(libxl__gc *gc, uint32_t domid,DEVICE_ADD (usbdev, usbdevs, domid, &usbdev_saved,COMPARE_USB , &d_config); + + rc =libxl__dm_check_start (gc, &d_config, domid); +if (rc) goto out; }for (;;) {
Signature · 7 lines
2.6.2 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel