libxl: add support for qemu base pvusb backend
v3 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 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 (5):
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
libxl: add domain config parameter to force start of qemu
docs/man/xl.cfg.pod.5 | 17 +++++- tools/libxl/libxl.c | 16 +++++- tools/libxl/libxl_create.c | 10 +--- tools/libxl/libxl_device.c | 3 +- tools/libxl/libxl_dm.c | 88 +++++++++++++++------------- tools/libxl/libxl_internal.h | 10 ++-- tools/libxl/libxl_pci.c | 3 + tools/libxl/libxl_pvusb.c | 108 +++++++++++++++++++++++++++-------- tools/libxl/libxl_types.idl | 2 + tools/libxl/libxl_types_internal.idl | 1 + tools/libxl/xl_cmdimpl.c | 3 + 11 files changed, 181 insertions(+), 80 deletions(-)
Signature · 7 lines
2.6.2 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
PATCH v3 1/5 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.
---
V2: Return false if libxl__get_domid() fails as requested by George Dunlap
--- tools/libxl/libxl_create.c | 9 +------ tools/libxl/libxl_dm.c | 57 ++++++++++++-------------------------------- tools/libxl/libxl_internal.h | 5 +--- 3 files changed, 17 insertions(+), 54 deletions(-)
tools/libxl/libxl_create.c +1 -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,11 @@ 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) { +if (libxl__need_xenpv_qemu (gc, d_config)) { dcs->dmss.dm.guest_domid = domid;libxl__spawn_local_dm (egc, &dcs->dmss.dm);return ;
tools/libxl/libxl_dm.c +15 -42
76 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
Re: [PATCH v3 1/5] libxl: make libxl__need_xenpv_qemu() operate on domain config
Quoted 8 lines · Juergen Gross
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.
Quoted 7 lines
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.Signed-off-by Juergen Gross <[email protected]>---
V2: Return false iflibxl__get_domid()fails as requested by George Dunlap
This is a bug that should be addressed properly -- returning true or false doesn't make sense in the context of this function.
It would make sense to push calling libxl__get_domid to the sole caller, then expose a new parameter called backend_id for libxl__need_xenpv_qemu. A patch like that would also be easily backportable. What do you think?
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v3 1/5] libxl: make libxl__need_xenpv_qemu() operate on domain config
Quoted 17 lines · Wei Liu
Quoted 8 lines · Juergen Gross
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.
Quoted 7 lines
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.Signed-off-by Juergen Gross <[email protected]>---
V2: Return false iflibxl__get_domid()fails as requested by George Dunlap
Quoted 7 lines
This is a bug that should be addressed properly -- returning true or false doesn't make sense in the context of this function.
It would make sense to push calling
libxl__get_domidto the sole caller, then expose a new parameter calledbackend_idforlibxl__need_xenpv_qemu. A patch like that would also be easily backportable. What do you think?
Hmm, right now there is only one caller. Patch 4 adds another one. I'd rather return a negative value for an error, and 0 or 1 indicating the device model isn't or is to be started.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v3 2/5 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.
--- 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 | 102 +++++++++++++++++++++++++++-------- tools/libxl/libxl_types.idl | 1 + tools/libxl/libxl_types_internal.idl | 1 + 7 files changed, 101 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
@@ -2138,6 +2138,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 +79 -23
237 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
Re: [PATCH v3 2/5] libxl: add new pvusb backend "qusb" provided by qemu
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
On 3/23/2016 at 08:24 PM, in message
<[email protected]>, Juergen Gross
Quoted 113 lines · <[email protected]> wrote:
Add 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.
Signed-off-by Juergen Gross <[email protected]>---
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 | 102 +++++++++++++++++++++++++++-------- tools/libxl/libxl_types.idl | 1 + tools/libxl/libxl_types_internal.idl | 1 + 7 files changed, 101 insertions(+), 26 deletions(-)docs/man/xl.cfg.pod.5 +7
-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 isinstalled.
docs/man/xl.cfg.pod.5 +2
-0+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@@ -2138,6 +2138,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 +15
-0@@ -22,6 +22,21 @@#define USBHUB_CLASS_CODE 9 +static int usbback_is_loaded (libxl__gc *gc) +{ +int r; +struct stat st; + + r =lstat (SYSFS_USBBACK_DRIVER , &st); + +if (r ==0 ) +return 1 ; +if (r <0 && errno ==ENOENT ) +return 0 ; +LOGE (ERROR ,"Accessing %s" ,SYSFS_USBBACK_DRIVER ); +return -1 ; +} +static int libxl__device_usbctrl_setdefault (libxl__gc *gc,uint32_t domid,libxl_device_usbctrl *usbctrl) {
tools/libxl/libxl_pvusb.c static int libxl__device_usbctrl_setdefault(libxl__gc *gc, · line 55
Quoted 6 lines
tools/libxl/libxl_pvusb.c +1
-1@@ -36,7 +51,8 @@ static int libxl__device_usbctrl_setdefault(libxl__gc *gc, uint32_t domid, if (usbctrl->type == LIBXL_USBCTRL_TYPE_AUTO) {if (domtype ==LIBXL_DOMAIN_TYPE_PV ) { - usbctrl->type =LIBXL_USBCTRL_TYPE_PV ; + usbctrl->type = usbback_is_loaded(gc) ? LIBXL_USBCTRL_TYPE_PV
The condition should be (usbback_is_loaded(gc) > 0)? usbback_is_loaded(gc) < 0 means lstat error, cannot determine if the usbback driver is loaded.
Otherwise, it looks good!
-Chunyan
Quoted 273 lines
tools/libxl/libxl_pvusb.c +1
-0+ :LIBXL_USBCTRL_TYPE_QUSB ; }else if (domtype ==LIBXL_DOMAIN_TYPE_HVM ) {/* FIXME: See if we can detect PV frontend */ usbctrl->type = LIBXL_USBCTRL_TYPE_DEVICEMODEL;tools/libxl/libxl_pvusb.c +3
-1@@ -54,7 +70,9 @@ int libxl__device_from_usbctrl(libxl__gc *gc, uint32_t domid, { device->backend_devid = usbctrl->devid; device->backend_domid = usbctrl->backend_domid; - device->backend_kind =LIBXL__DEVICE_KIND_VUSB ; + device->backend_kind = (usbctrl->type ==LIBXL_USBCTRL_TYPE_PV ) + ?LIBXL__DEVICE_KIND_VUSB + :LIBXL__DEVICE_KIND_QUSB ; device->devid = usbctrl->devid; device->domid = domid;device->kind = LIBXL__DEVICE_KIND_VUSB;tools/libxl/libxl_pvusb.c +3
-3@@ -64,9 +82,9 @@ int libxl__device_from_usbctrl(libxl__gc *gc, uint32_t domid,/* Add usbctrl information to xenstore. * -* Adding a usb controller will add a new 'vusb' device in xenstore, and -* add corresponding frontend, backend information to it. According to -* "update_json", decide wether to update json config file. +* Adding a usb controller will add a new 'qusb' or 'vusb' device in xenstore, +* and add corresponding frontend, backend information to it. According to +* "update_json", decide whether to update json config file. */static int libxl__device_usbctrl_add_xenstore(libxl__gc *gc,
uint32_t
domid,
libxl_device_usbctrl
*usbctrl,tools/libxl/libxl_pvusb.c +14
-1@@ -159,6 +177,18 @@ out:return rc; } +static char *pvusb_get_device_type (libxl_usbctrl_type type) +{ +switch (type) { +case LIBXL_USBCTRL_TYPE_PV : +return "vusb" ; +case LIBXL_USBCTRL_TYPE_QUSB : +return "qusb" ; +default : +return NULL ; + } +} +/* AO operation to add a usb controller. * * Generally, it does: @@ -190,7 +220,8 @@ void libxl__device_usbctrl_add(libxl__egc *egc, uint32_t domid, } } -if (usbctrl->type !=LIBXL_USBCTRL_TYPE_PV ) { +if (usbctrl->type !=LIBXL_USBCTRL_TYPE_PV && + usbctrl->type !=LIBXL_USBCTRL_TYPE_QUSB ) {LOG (ERROR ,"Unsupported USB controller type" ); rc =ERROR_FAIL ;goto out;tools/libxl/libxl_pvusb.c +2
-1@@ -252,7 +283,8 @@ void libxl__initiate_device_usbctrl_remove(libxl__egc *egc, rc =libxl_device_usbctrl_getinfo (CTX , domid, &usbctrl, &usbctrlinfo);if (rc) goto out; -if (usbctrlinfo.type !=LIBXL_USBCTRL_TYPE_PV ) { +if (usbctrlinfo.type !=LIBXL_USBCTRL_TYPE_PV && + usbctrlinfo.type !=LIBXL_USBCTRL_TYPE_QUSB ) {LOG (ERROR ,"Unsupported USB controller type" ); rc =ERROR_FAIL ;goto out;tools/libxl/libxl_pvusb.c +1
-0@@ -293,6 +325,7 @@ static const char *vusb_be_from_xs_fe(libxl__gc *gc,const char *fe_path, const char *be_path;int r;uint32_t be_domid, fe_domid; +char be_type[16 ]; r = libxl__xs_read_checked(gc, XBT_NULL, GCSPRINTF("%s/backend",
fe_path),&be_path);tools/libxl/libxl_pvusb.c +3
-3@@ -300,10 +333,10 @@ static const char *vusb_be_from_xs_fe(libxl__gc *gc,const char *fe_path,/* Check to see that it has the proper form, and that fe_domid == * target domid */ - r =sscanf (be_path,"/local/domain/%d/backend/vusb/%d" , - &be_domid, &fe_domid); + r =sscanf (be_path,"/local/domain/%d/backend/%15[^/]/%d" , + &be_domid, be_type, &fe_domid); -if (r !=2 || fe_domid != tgt_domid) { +if (r !=3 || fe_domid != tgt_domid) {LOG (ERROR ,"Malformed backend, refusing to use" );return NULL ;}tools/libxl/libxl_pvusb.c +2
-1@@ -740,8 +773,9 @@ libxl__device_usbdev_set_default_usbctrl(libxl__gc *gc,uint32_t domid, for (j = 0; j < usbctrls[i].ports; j++) {const char *path, *tmp; - path =GCSPRINTF ("%s/backend/vusb/%d/%d/port/%d" , + path =GCSPRINTF ("%s/backend/%s/%d/%d/port/%d" ,libxl__xs_get_dompath (gc,LIBXL_TOOLSTACK_DOMID ), +pvusb_get_device_type (usbctrls[i].type), domid, usbctrls[i].devid, j +1 );rc = libxl__xs_read_checked(gc, XBT_NULL, path, &tmp); if (rc) goto out;tools/libxl/libxl_pvusb.c +1
-1@@ -883,11 +917,12 @@ out:/* Add usb information to xenstore * -* Adding a usb device won't create new 'vusb' device, but only write +* Adding a usb device won't create new 'qusb'/'vusb' device, but only write
* the device busid to the controller:port in xenstore.
*/
static int libxl__device_usbdev_add_xenstore(libxl__gc *gc,uint32_tdomid,
libxl_device_usbdev*usbdev,tools/libxl/libxl_pvusb.c +3
-1+libxl_usbctrl_type type, bool update_json) { char *be_path, *busid;@@ -931,8 +966,9 @@ static int libxl__device_usbdev_add_xenstore(libxl__gc *gc, uint32_t domid, if (rc) goto out; } - be_path =GCSPRINTF ("%s/backend/vusb/%d/%d/port/%d" , + be_path =GCSPRINTF ("%s/backend/%s/%d/%d/port/%d" ,libxl__xs_get_dompath (gc,LIBXL_TOOLSTACK_DOMID ), +pvusb_get_device_type (type), domid, usbdev->ctrl, usbdev->port);LOG(DEBUG, "Adding usb device %s to xenstore: controller %d, port
%d",tools/libxl/libxl_pvusb.c +4
-2@@ -956,12 +992,14 @@ out: }static int libxl__device_usbdev_remove_xenstore (libxl__gc *gc,uint32_t domid, - libxl_device_usbdev *usbdev) +libxl_device_usbdev *usbdev, +libxl_usbctrl_type type) {char *be_path; - be_path =GCSPRINTF ("%s/backend/vusb/%d/%d/port/%d" , + be_path =GCSPRINTF ("%s/backend/%s/%d/%d/port/%d" ,libxl__xs_get_dompath (gc,LIBXL_TOOLSTACK_DOMID ), +pvusb_get_device_type (type), domid, usbdev->ctrl, usbdev->port);LOG(DEBUG, "Removing usb device from xenstore: controller %d, port %d",
tools/libxl/libxl_pvusb.c +5
-3@@ -971,12 +1009,14 @@ static int libxl__device_usbdev_remove_xenstore(libxl__gc *gc, uint32_t domid, } static char *usbdev_busid_from_ctrlport(libxl__gc *gc, uint32_t domid, - libxl_device_usbdev *usbdev) + libxl_device_usbdev *usbdev, + libxl_usbctrl_type type) {return libxl__xs_read (gc,XBT_NULL , -GCSPRINTF ("%s/backend/vusb/%d/%d/port/%d" , +GCSPRINTF ("%s/backend/%s/%d/%d/port/%d" ,libxl__xs_get_dompath (gc,LIBXL_TOOLSTACK_DOMID ), - domid, usbdev->ctrl, usbdev->port)); +pvusb_get_device_type (type), + domid, usbdev->ctrl, usbdev->port)); }/* get original driver path of usb interface, stored in @drvpath */
tools/libxl/libxl_pvusb.c +12
-2@@ -1333,15 +1373,25 @@ static int do_usbdev_add(libxl__gc *gc, uint32_t domid, goto out; } - rc =libxl__device_usbdev_add_xenstore (gc, domid, usbdev, update_json); + rc =libxl__device_usbdev_add_xenstore (gc, domid, usbdev, +LIBXL_USBCTRL_TYPE_PV , + update_json);if (rc) goto out; rc =usbback_dev_assign (gc, busid);if (rc) { -libxl__device_usbdev_remove_xenstore (gc, domid, usbdev); +libxl__device_usbdev_remove_xenstore (gc, domid, usbdev, +LIBXL_USBCTRL_TYPE_PV ); goto out; }break ; +case LIBXL_USBCTRL_TYPE_QUSB : + rc =libxl__device_usbdev_add_xenstore (gc, domid, usbdev, +LIBXL_USBCTRL_TYPE_QUSB , + update_json); +if (rc) goto out; + +break ;case LIBXL_USBCTRL_TYPE_DEVICEMODEL :default: LOG(ERROR, "Unsupported usb controller type");tools/libxl/libxl_pvusb.c +1
-1@@ -1458,7 +1508,7 @@ static int do_usbdev_remove(libxl__gc *gc, uint32_t domid, switch (usbctrlinfo.type) {case LIBXL_USBCTRL_TYPE_PV : - busid =usbdev_busid_from_ctrlport (gc, domid, usbdev); + busid =usbdev_busid_from_ctrlport (gc, domid, usbdev, usbctrlinfo.type);if (!busid) {rc = ERROR_FAIL; goto out;tools/libxl/libxl_pvusb.c +2
-1@@ -1483,7 +1533,8 @@ static int do_usbdev_remove(libxl__gc *gc, uint32_t domid, goto out; } - rc =libxl__device_usbdev_remove_xenstore (gc, domid, usbdev); + rc =libxl__device_usbdev_remove_xenstore (gc, domid, usbdev, +LIBXL_USBCTRL_TYPE_PV );if (rc) { LOG(ERROR, "Error removing device from guest."" Try running usbdev-detach again.");tools/libxl/libxl_pvusb.c +6
-0@@ -1499,6 +1550,12 @@ static int do_usbdev_remove(libxl__gc *gc, uint32_t domid, }break ; +case LIBXL_USBCTRL_TYPE_QUSB : + rc =libxl__device_usbdev_remove_xenstore (gc, domid, usbdev, +LIBXL_USBCTRL_TYPE_QUSB ); +if (rc) goto out; + +break ;case LIBXL_USBCTRL_TYPE_DEVICEMODEL :default :LOG(ERROR, "Unsupported usb controller type");tools/libxl/libxl_pvusb.c +0
-1@@ -1583,7 +1640,6 @@ int libxl_ctrlport_to_device_usbdev(libxl_ctx *ctx, dompath =libxl__xs_get_dompath (gc, domid); fe_path =GCSPRINTF ("%s/device/vusb/%d" , dompath, ctrl); - be_path =vusb_be_from_xs_fe (gc, fe_path, domid);if (!be_path) { rc =ERROR_FAIL ;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 +0
-0
tools/libxl/libxl_types_internal.idl libxl__device_kind = Enumeration("device_kind", [ · line 29
Quoted 7 lines
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", [
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v3 2/5] libxl: add new pvusb backend "qusb" provided by qemu
Quoted 50 lines · Chun Yan Liu
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
On 3/23/2016 at 08:24 PM, in message
<[email protected]>, Juergen Gross
Quoted 45 lines · <[email protected]> wrote:
Add 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.
Signed-off-by Juergen Gross <[email protected]>---
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 | 102 +++++++++++++++++++++++++++-------- tools/libxl/libxl_types.idl | 1 + tools/libxl/libxl_types_internal.idl | 1 + 7 files changed, 101 insertions(+), 26 deletions(-)tools/libxl/libxl_internal.h +15
-0@@ -22,6 +22,21 @@#define USBHUB_CLASS_CODE 9 +static int usbback_is_loaded (libxl__gc *gc) +{ +int r; +struct stat st; + + r =lstat (SYSFS_USBBACK_DRIVER , &st); + +if (r ==0 ) +return 1 ; +if (r <0 && errno ==ENOENT ) +return 0 ; +LOGE (ERROR ,"Accessing %s" ,SYSFS_USBBACK_DRIVER ); +return -1 ; +} +static int libxl__device_usbctrl_setdefault (libxl__gc *gc,uint32_t domid,libxl_device_usbctrl *usbctrl) {@@ -36,7 +51,8 @@ static int libxl__device_usbctrl_setdefault(libxl__gc *gc, uint32_t domid,
Quoted 7 lines
tools/libxl/libxl_internal.h static int libxl__device_usbctrl_setdefault(libxl__gc *gc, · line 55
Quoted 4 lines
tools/libxl/libxl_internal.h +1
-1if (usbctrl->type ==LIBXL_USBCTRL_TYPE_AUTO ) {if (domtype ==LIBXL_DOMAIN_TYPE_PV ) { - usbctrl->type =LIBXL_USBCTRL_TYPE_PV ; + usbctrl->type = usbback_is_loaded(gc) ? LIBXL_USBCTRL_TYPE_PVThe condition should be (
usbback_is_loaded(gc)> 0)?usbback_is_loaded(gc)< 0 means lstat error, cannot determine if the usbback driver is loaded.
Good point. I think in error case I should rather abort the operation.
Thoughts?
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v3 2/5] libxl: add new pvusb backend "qusb" provided by qemu
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
On 3/25/2016 at 02:29 PM, in message <[email protected]>, Juergen Gross
Quoted 59 lines · <[email protected]> wrote:
Quoted 17 lines · Chun Yan Liu
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
On 3/23/2016 at 08:24 PM, in message
<[email protected]>, Juergen Gross
Quoted 12 lines · <[email protected]> wrote:
Add 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.
Signed-off-by Juergen Gross <[email protected]>---
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 | 102+++++++++++++++++++++++++++--------
Quoted 29 lines
Quoted 28 lines
tools/libxl/libxl_types.idl | 1 + tools/libxl/libxl_types_internal.idl | 1 + 7 files changed, 101 insertions(+), 26 deletions(-)tools/libxl/libxl_internal.h +15
-0@@ -22,6 +22,21 @@#define USBHUB_CLASS_CODE 9 +static int usbback_is_loaded (libxl__gc *gc) +{ +int r; +struct stat st; + + r =lstat (SYSFS_USBBACK_DRIVER , &st); + +if (r ==0 ) +return 1 ; +if (r <0 && errno ==ENOENT ) +return 0 ; +LOGE (ERROR ,"Accessing %s" ,SYSFS_USBBACK_DRIVER ); +return -1 ; +} + static int libxl__device_usbctrl_setdefault(libxl__gc *gc, uint32_t domid,Quoted 4 lines
tools/libxl/libxl_internal.h static int libxl__device_usbctrl_setdefault(libxl__gc
Quoted 4 lines
tools/libxl/libxl_internal.h +0
-0libxl_device_usbctrl *usbctrl){
tools/libxl/libxl_internal.h +0
-0@@ -36,7 +51,8 @@ static int libxl__device_usbctrl_setdefault(libxl__gc*gc,
Quoted 6 lines
Quoted 6 lines
tools/libxl/libxl_internal.h +1
-1uint32_t domid, if (usbctrl->type == LIBXL_USBCTRL_TYPE_AUTO) {if (domtype ==LIBXL_DOMAIN_TYPE_PV ) { - usbctrl->type =LIBXL_USBCTRL_TYPE_PV ; + usbctrl->type = usbback_is_loaded(gc) ? LIBXL_USBCTRL_TYPE_PV
Quoted 7 lines
Quoted 3 lines
The condition should be (
usbback_is_loaded(gc)> 0)?usbback_is_loaded(gc)< 0 means lstat error, cannot determine if the usbback driver is loaded.Good point. I think in error case I should rather abort the operation.
Thoughts?
I think it's OK. In another case when we check if a USB device is assigned or not, we call get_assigned_devices(), it that function fails, we cannot determine if a USB device is assigned or not, the handling is just abort. So I think here if cannot determine usbback is loaded or not, we can also abort and report error directly.
Chunyan
Quoted 4 lines
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v3 3/5 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
@@ -2150,6 +2150,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
Re: [PATCH v3 3/5] libxl: add service function to check whether device model is running
Quoted 6 lines · Juergen Gross
Add 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.
Signed-off-by Juergen Gross <[email protected]>
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v3 4/5 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 | 14 ++++++++++++++ tools/libxl/libxl_internal.h | 4 ++++ tools/libxl/libxl_pci.c | 3 +++ tools/libxl/libxl_pvusb.c | 6 ++++++ 5 files changed, 39 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 +14 -0
@@ -2160,6 +2160,20 @@ 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) +{ +if (libxl__dm_active (gc, domid)) +return 0 ; + +if (!libxl__need_xenpv_qemu (gc, d_config)) +return 0 ; + +LOG (ERROR ,"device model required but not running" ); + +return ERROR_FAIL ; +} +/* * 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
@@ -139,6 +139,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 (;;) {
@@ -955,6 +958,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
Re: [PATCH v3 4/5] libxl: check for dynamic device model start required
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
On 3/23/2016 at 08:24 PM, in message
<[email protected]>, Juergen Gross
Quoted 17 lines · <[email protected]> wrote:
Add a service routine checking whether a device model must be started after adding a device to a domain.
Signed-off-by Juergen Gross <[email protected]>---
tools/libxl/libxl.c | 12 ++++++++++++ tools/libxl/libxl_dm.c | 14 ++++++++++++++ tools/libxl/libxl_internal.h | 4 ++++ tools/libxl/libxl_pci.c | 3 +++ tools/libxl/libxl_pvusb.c | 6 ++++++ 5 files changed, 39 insertions(+)tools/libxl/libxl.c +0
-0
tools/libxl/libxl.c void libxl__device_vtpm_add(libxl__egc *egc, uint32_t · line 2092
Quoted 9 lines
tools/libxl/libxl.c +3
-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; }
Why is this check put inside the if (aodev->update_json) { }? I think it's a common check, so should move outside.
- Chunyan
Quoted 117 lines
for (;;) {tools/libxl/libxl.c +3
-0@@ -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 (;;) {tools/libxl/libxl.c +3
-0@@ -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;tools/libxl/libxl.c +3
-0@@ -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 +14
-0@@ -2160,6 +2160,20 @@ 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) +{ +if (libxl__dm_active (gc, domid)) +return 0 ; + +if (!libxl__need_xenpv_qemu (gc, d_config)) +return 0 ; + +LOG (ERROR ,"device model required but not running" ); + +return ERROR_FAIL ; +} +/* * 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 conflicttools/libxl/libxl_pci.c +0
-0@@ -169,6 +169,9 @@ static int libxl__device_pci_add_xenstore(libxl__gc *gc,
uint32_tdomid,libxl_dDEVICE_ADD(pci, pcidevs, domid, &pcidev_saved, COMPARE_PCI, &d_config);tools/libxl/libxl_pci.c +3
-0+ 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 +3
-0@@ -139,6 +139,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 (;;) {tools/libxl/libxl_pvusb.c +3
-0@@ -955,6 +958,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; }
Quoted 1 line
for (;;) { _______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
A message that is not in the archive (sent off-list or not yet received): [email protected]
Re: [PATCH v3 4/5] libxl: check for dynamic device model start required
Quoted 25 lines · Chun Yan Liu
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
On 3/23/2016 at 08:24 PM, in message
<[email protected]>, Juergen Gross
Quoted 20 lines · <[email protected]> wrote:
Add a service routine checking whether a device model must be started after adding a device to a domain.
Signed-off-by Juergen Gross <[email protected]>---
tools/libxl/libxl.c | 12 ++++++++++++ tools/libxl/libxl_dm.c | 14 ++++++++++++++ tools/libxl/libxl_internal.h | 4 ++++ tools/libxl/libxl_pci.c | 3 +++ tools/libxl/libxl_pvusb.c | 6 ++++++ 5 files changed, 39 insertions(+)tools/libxl/libxl.c +0
-0@@ -2084,6 +2084,9 @@ void libxl__device_vtpm_add(libxl__egc *egc, uint32_t domid, if (rc) goto out;
Quoted 9 lines
tools/libxl/libxl.c void libxl__device_vtpm_add(libxl__egc *egc, uint32_t domid, · line 2090
Quoted 6 lines
tools/libxl/libxl.c +3
-0DEVICE_ADD (vtpm, vtpms, domid, &vtpm_saved,COMPARE_DEVID , &d_config); + + rc =libxl__dm_check_start (gc, &d_config, domid); +if (rc) goto out; }Why is this check put inside the if (
aodev->update_json) { }? I think it's a common check, so should move outside.
It is the only case where the check makes sense: update_json isn't set when we are just creating the domain, in which case the test for the device model needed is already in place. When the device is added to an already running domain update_json will always be true.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v3 4/5] libxl: check for dynamic device model start required
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
On 3/25/2016 at 02:25 PM, in message <[email protected]>, Juergen Gross
Quoted 34 lines · <[email protected]> wrote:
Quoted 33 lines · Chun Yan Liu
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
On 3/23/2016 at 08:24 PM, in message
<[email protected]>, Juergen Gross
Quoted 27 lines · <[email protected]> wrote:
Add a service routine checking whether a device model must be started after adding a device to a domain.
Signed-off-by Juergen Gross <[email protected]>---
tools/libxl/libxl.c | 12 ++++++++++++ tools/libxl/libxl_dm.c | 14 ++++++++++++++ tools/libxl/libxl_internal.h | 4 ++++ tools/libxl/libxl_pci.c | 3 +++ tools/libxl/libxl_pvusb.c | 6 ++++++ 5 files changed, 39 insertions(+)tools/libxl/libxl.c +3
-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;}
Quoted 7 lines
Quoted 1 line
Why is this check put inside the if (
aodev->update_json) { }? I think it'sa common
Quoted 1 line
check, so should move outside.
It is the only case where the check makes sense:
update_jsonisn't set when we are just creating the domain, in which case the test for the device model needed is already in place.
See. That's OK then.
Thanks,
Chunyan
Quoted 6 lines
When the device is added to an
already running domainupdate_jsonwill always be true.Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
PATCH v3 5/5 libxl: add domain config parameter to force start of qemu
In reply to Juergen GrossToday the device model (qemu) is started for a pv domain only in case a device requiring qemu is specified in the domain configuration (qdisk, vfb, channel). If there is no such device the device model isn't started and hence it is impossible to add such a device to the domain later.
Add a domain configuration parameter to specify the device model is to be started in any case. This will enable adding devices with a qemu based backend later.
While the optimal solution would be to start the device model automatically when needed this would require some major rework of libxl at multiple places.
--- docs/man/xl.cfg.pod.5 | 6 ++++++ tools/libxl/libxl_create.c | 1 + tools/libxl/libxl_dm.c | 5 +++++ tools/libxl/libxl_types.idl | 1 + tools/libxl/xl_cmdimpl.c | 3 +++ 5 files changed, 16 insertions(+)
docs/man/xl.cfg.pod.5 +6 -0
@@ -1956,6 +1956,12 @@ xen-qemudepriv-domid$domid or xen-qemudepriv-shared or root. Please note that running QEMU as non-root causes migration and PCI passthrough not to work properly. +=item B<device_model_always=BOOLEAN> + +If true, start the device model for paravirtualized domains even if this isn't +required according to the configured devices. This allows to add such devices +later when the domain is already running. + =back =head2 Keymaps
tools/libxl/libxl_create.c +1 -0
@@ -73,6 +73,7 @@ int libxl__domain_build_info_setdefault(libxl__gc *gc,return ERROR_INVAL ; } +libxl_defbool_setdefault (&b_info->device_model_always, false);libxl_defbool_setdefault (&b_info->device_model_stubdomain, false); if (libxl_defbool_val(b_info->device_model_stubdomain) &&
tools/libxl/libxl_dm.c +5 -0
@@ -2115,6 +2115,11 @@ int libxl__need_xenpv_qemu(libxl__gc *gc, libxl_domain_config *d_config)if (libxl__get_domid (gc, &domid)) goto out; +if (libxl_defbool_val (d_config->b_info.device_model_always)) { + ret =1 ; + goto out; + } +if (d_config->num_vfbs >0 ) { ret =1 ; goto out;
tools/libxl/libxl_types.idl +1 -0
@@ -451,6 +451,7 @@ libxl_domain_build_info = Struct("domain_build_info",[ ("device_model_ssidref", uint32), ("device_model_ssid_label", string), ("device_model_user", string), + ("device_model_always", libxl_defbool), # extra parameters pass directly to qemu, NULL terminated ("extra", libxl_string_list),
tools/libxl/xl_cmdimpl.c +3 -0
@@ -2269,6 +2269,9 @@ skip_usbdev: }/* parse device model arguments, this works for pv, hvm and stubdom */ +xlu_cfg_get_defbool (config,"device_model_always" , + &b_info->device_model_always,0 ); +if (!xlu_cfg_get_string (config,"device_model" , &buf,0 )) {fprintf (stderr, "WARNING: ignoring device_model directive.\n"
Signature · 7 lines
2.6.2 _______________________________________________ Xen-devel mailing list [email protected] http://lists.xen.org/xen-devel
Re: [PATCH v3 5/5] libxl: add domain config parameter to force start of qemu
Quoted 10 lines · Juergen Gross
Today the device model (qemu) is started for a pv domain only in case a device requiring qemu is specified in the domain configuration (qdisk, vfb, channel). If there is no such device the device model isn't started and hence it is impossible to add such a device to the domain later.
Add a domain configuration parameter to specify the device model is to be started in any case. This will enable adding devices with a qemu based backend later.
Quoted 5 lines
While the optimal solution would be to start the device model automatically when needed this would require some major rework of libxl at multiple places.
Signed-off-by Juergen Gross <[email protected]>
I can't say I like this.
Libxl can be made smart enough to detect whether starting a device model is required (as you already did in previous patch) then start qemu on demand.
There is a xen-attach mode in qemu, and libxl already has machinery for starting qemu. I suspect what you need to do is refactoring existing code and expose the right parameter for qemu. Then you wouldn't need this user visible option at all. You would also save the resources for always having an idle qemu in toolstack domain.
Let me know if this is to vague.
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v3 5/5] libxl: add domain config parameter to force start of qemu
Quoted 23 lines · Wei Liu
Quoted 10 lines · Juergen Gross
Today the device model (qemu) is started for a pv domain only in case a device requiring qemu is specified in the domain configuration (qdisk, vfb, channel). If there is no such device the device model isn't started and hence it is impossible to add such a device to the domain later.
Add a domain configuration parameter to specify the device model is to be started in any case. This will enable adding devices with a qemu based backend later.
Quoted 5 lines
While the optimal solution would be to start the device model automatically when needed this would require some major rework of libxl at multiple places.
Signed-off-by Juergen Gross <[email protected]>I can't say I like this.
Libxl can be made smart enough to detect whether starting a device model is required (as you already did in previous patch) then start qemu on demand.
Quoted 8 lines
There is a xen-attach mode in qemu, and libxl already has machinery for starting qemu. I suspect what you need to do is refactoring existing code and expose the right parameter for qemu. Then you wouldn't need this user visible option at all. You would also save the resources for always having an idle qemu in toolstack domain.
Let me know if this is to vague.
Actually I don't think this is your problem. I would consider this a bug in libxl for not starting qemu on demand. I can take a stab at it, but that will need to wait until next release.
I think the functionality you care about can live without this patch, but I'm not sure if it would become too cumbersome to use.
Wei.
Quoted 1 line
Wei.
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v3 5/5] libxl: add domain config parameter to force start of qemu
Quoted 33 lines · Wei Liu
Quoted 23 lines · Wei Liu
Quoted 10 lines · Juergen Gross
Today the device model (qemu) is started for a pv domain only in case a device requiring qemu is specified in the domain configuration (qdisk, vfb, channel). If there is no such device the device model isn't started and hence it is impossible to add such a device to the domain later.
Add a domain configuration parameter to specify the device model is to be started in any case. This will enable adding devices with a qemu based backend later.
Quoted 5 lines
While the optimal solution would be to start the device model automatically when needed this would require some major rework of libxl at multiple places.
Signed-off-by Juergen Gross <[email protected]>I can't say I like this.
Libxl can be made smart enough to detect whether starting a device model is required (as you already did in previous patch) then start qemu on demand.
Quoted 8 lines
There is a xen-attach mode in qemu, and libxl already has machinery for starting qemu. I suspect what you need to do is refactoring existing code and expose the right parameter for qemu. Then you wouldn't need this user visible option at all. You would also save the resources for always having an idle qemu in toolstack domain.
Let me know if this is to vague.
Quoted 6 lines
Actually I don't think this is your problem. I would consider this a bug in libxl for not starting qemu on demand. I can take a stab at it, but that will need to wait until next release.
I think the functionality you care about can live without this patch, but I'm not sure if it would become too cumbersome to use.
The "normal" block backend is qdisk these days. So normally the device model will be running. And in many cases a pvusb device will be assigned via the xl config of the domain which will start the device model automatically.
I just wanted to make clear there is a potential problem and presented a solution for this which I could implement in time for 4.7.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel
Re: [PATCH v3 5/5] libxl: add domain config parameter to force start of qemu
In reply to Wei LiuQuoted 23 lines · Wei Liu
Quoted 10 lines · Juergen Gross
Today the device model (qemu) is started for a pv domain only in case a device requiring qemu is specified in the domain configuration (qdisk, vfb, channel). If there is no such device the device model isn't started and hence it is impossible to add such a device to the domain later.
Add a domain configuration parameter to specify the device model is to be started in any case. This will enable adding devices with a qemu based backend later.
Quoted 5 lines
While the optimal solution would be to start the device model automatically when needed this would require some major rework of libxl at multiple places.
Signed-off-by Juergen Gross <[email protected]>I can't say I like this.
Libxl can be made smart enough to detect whether starting a device model is required (as you already did in previous patch) then start qemu on demand.
Quoted 7 lines
There is a xen-attach mode in qemu, and libxl already has machinery for starting qemu. I suspect what you need to do is refactoring existing code and expose the right parameter for qemu. Then you wouldn't need this user visible option at all. You would also save the resources for always having an idle qemu in toolstack domain.
Let me know if this is to vague.
No, that's okay. I think I'll drop this patch for now and start a clean attempt after 4.7 is out.
Juergen
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xen.org/xen-devel