Re: [Xen-devel] vsnd issue

2019-11-25 Thread Oleksandr Grytsov
ommandHandler  | DBG - Handle command
> > >>> [QUERY_HW_PARAM]
> > >>> 13.11.19 08:24:57.647 | AlsaPcm | DBG - Query pcm device
> > >>> hw:2,0 for HW parameters
> > >>> 13.11.19 08:24:57.656 | CommandHandler  | DBG - Return status: [0]
> > >>> 13.11.19 08:24:57.663 | XenEvtchn   | DBG - Notify event
> > >>> channel, port: 10
> > >>> 13.11.19 08:24:57.671 | XenEvtchn   | DBG - Event received,
> > >>> port: 10
> > >>> 13.11.19 08:24:57.678 | StreamRing  | DBG - Request received,
> > >>> id: alsa, cmd:9
> > >>> 13.11.19 08:24:57.686 | CommandHandler  | DBG - Handle command
> > >>> [QUERY_HW_PARAM]
> > >>> 13.11.19 08:24:57.694 | AlsaPcm | DBG - Query pcm device
> > >>> hw:2,0 for HW parameters
> > >>> 13.11.19 08:24:57.703 | CommandHandler  | DBG - Return status: [0]
> > >>> 13.11.19 08:24:57.709 | XenEvtchn   | DBG - Notify event
> > >>> channel, port: 10
> > >>>
> > >>>
> > >>> My xl.cfg:
> > >>>   vsnd = [
> > >>>   ['CARD, short-name=Main,
> > sample-formats=s16_le;s8;u32_be',
> > >>>   'PCM, name=Main',
> > >>>   'STREAM, unique-id=alsa, type=p',
> > >>>   'STREAM, unique-id=alsa, type=c,
> > channels-
> > >>> max=2'
> > >>>   ],
> > >>>   ]
> > Config seems to be ok
> > >>> The audio device on my board:
> > >>> aplay -l
> > >>>  List of PLAYBACK Hardware Devices  card 0: imxaudmix
> > >>> [imx-audmix], device 0: HiFi-AUDMIX-FE (*) []
> > >>> Subdevices: 1/1
> > >>> Subdevice #0: subdevice #0
> > >>> card 0: imxaudmix [imx-audmix], device 1: HiFi-AUDMIX-FE (*) []
> > >>> Subdevices: 1/1
> > >>> Subdevice #0: subdevice #0
> > >>> card 1: cs42888audio [cs42888-audio], device 0: HiFi cs42888-0 [HiFi
> > >>> cs42888-0]
> > >>> Subdevices: 1/1
> > >>> Subdevice #0: subdevice #0
> > >>> card 1: cs42888audio [cs42888-audio], device 1: HiFi-ASRC-FE (*) []
> > >>> Subdevices: 1/1
> > >>> Subdevice #0: subdevice #0
> > >>> card 2: wm8960audio [wm8960-audio], device 0: HiFi wm8960-hifi-0 []
> > >>> Subdevices: 0/1
> > >>> Subdevice #0: subdevice #0
> > >>>
> > >>> Is there something wrong in my configuration?
> > >>>
> > >>> Thanks,
> > >>> Peng.
> > >>>
> > >>> ___
> > >>> Xen-devel mailing list
> > >>> Xen-devel@lists.xenproject.org
> > >>>
> > >>> https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fur
> > >>>
> > ldefense.com%2Fv3%2F__https%3A%2F%2Flists.xenproject.org%2Fmailman
> > %2
> > >>>
> > Flistinfo%2Fxen-devel__%3B!K6dmGCEab4ueJg!iTeJON61Y2nUcGMQr_y7-27
> > bR_
> > >>>
> > QlOG8gXqvRMaU8yy8nJuDhzWizylvl_6stD-ILOQ%24data=02%7C01%7
> > Cpeng.
> > >>>
> > fan%40nxp.com%7Ca70282eacf484b0c054408d77196071d%7C686ea1d3bc2
> > b4c6fa
> > >>>
> > 92cd99c5c301635%7C0%7C0%7C637102761486569821sdata=eFoYN
> > WSSYod6l
> > >>> 7oBisDswR93cknmIpMaAcF70HqGKns%3Dreserved=0
> > >>>
> > >>>
> > >>
> > > ___
> > > Xen-devel mailing list
> > > Xen-devel@lists.xenproject.org
> > > https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Flist
> > >
> > s.xenproject.org%2Fmailman%2Flistinfo%2Fxen-develdata=02%7C01%
> > 7Cp
> > >
> > eng.fan%40nxp.com%7Ca70282eacf484b0c054408d77196071d%7C686ea1d
> > 3bc2b4c6
> > >
> > fa92cd99c5c301635%7C0%7C0%7C637102761486579808sdata=pfrVX
> > H1YFBOtX
> > > ECbv40KKwTwd7EFygcOWrhjHDjViu4%3Dreserved=0
> >
> > [1]
> > https://eur01.safelinks.protection.outlook.com/?url=https%3A%2F%2Felixir.b
> > ootlin.com%2Flinux%2Fv5.4-rc8%2Fsource%2Fsound%2Fxen%2Fxen_snd_fro
> > nt_alsa.c%23L685data=02%7C01%7Cpeng.fan%40nxp.com%7Ca7028
> > 2eacf484b0c054408d77196071d%7C686ea1d3bc2b4c6fa92cd99c5c301635%
> > 7C0%7C0%7C637102761486579808sdata=pEvilGNZSTvoY4YGg9%2BU
> > vDg7RHDzF26V2B4Bexkkaj0%3Dreserved=0
>
> ___
> Xen-devel mailing list
> Xen-devel@lists.xenproject.org
> https://lists.xenproject.org/mailman/listinfo/xen-devel

Hi Peng,

When you use ALSA as sound backend on Dom0, HW parameters introduced
in xl.cfg must match ones that real HW has, e.g. format, rate, num channels,
buffer size.

1. You could check your real HW by playing the file on Dom0:

 aplay -D hw:2,0 sound.wav --dump-hw-params

See supported formats, channels, rate and buffer in bytes.
Then update xl.cfg accordingly.

Also make sure that aplay works as expected on your Dom0.

2. I don't see any errors in the sndbe log, could you provide log with place
where the error occurs.

3. You can use pulseaudio as sound backend on Dom0. Pulseaudio doesn't
require exact matching of real HW params.

-- 
Best Regards,
Oleksandr Grytsov.

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

[Xen-devel] [PATCH v2 1/3] libxl: introduce new backend type VINPUT

2019-11-21 Thread Oleksandr Grytsov
From: Oleksandr Grytsov 

There are two kind of VKBD devices: with QEMU backend and user space PV
backend. In current implementation they can't be distinguished as both use
VKBD backend type. As result, user space PV KBD backend is started and
stopped as QEMU backend. This commit adds new device kind VINPUT to be
used as backend type for user space PV KBD backend.

Signed-off-by: Oleksandr Grytsov 
Acked-by: Ian Jackson 
---
 tools/libxl/libxl_types_internal.idl |  1 +
 tools/libxl/libxl_vkb.c  | 29 ++--
 2 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/tools/libxl/libxl_types_internal.idl 
b/tools/libxl/libxl_types_internal.idl
index cb85c3b37f..3593e21dbb 100644
--- a/tools/libxl/libxl_types_internal.idl
+++ b/tools/libxl/libxl_types_internal.idl
@@ -31,6 +31,7 @@ libxl__device_kind = Enumeration("device_kind", [
 (13, "VUART"),
 (14, "PVCALLS"),
 (15, "VSND"),
+(16, "VINPUT"),
 ])
 
 libxl__console_backend = Enumeration("console_backend", [
diff --git a/tools/libxl/libxl_vkb.c b/tools/libxl/libxl_vkb.c
index 26376a7eef..4c44a813c1 100644
--- a/tools/libxl/libxl_vkb.c
+++ b/tools/libxl/libxl_vkb.c
@@ -38,9 +38,6 @@ static int libxl__set_xenstore_vkb(libxl__gc *gc, uint32_t 
domid,
flexarray_t *back, flexarray_t *front,
flexarray_t *ro_front)
 {
-flexarray_append_pair(back, "backend-type",
-  (char 
*)libxl_vkb_backend_to_string(vkb->backend_type));
-
 if (vkb->unique_id) {
 flexarray_append_pair(back, XENKBD_FIELD_UNIQUE_ID, vkb->unique_id);
 }
@@ -93,7 +90,8 @@ static int libxl__vkb_from_xenstore(libxl__gc *gc, const char 
*libxl_path,
 libxl_devid devid,
 libxl_device_vkb *vkb)
 {
-const char *be_path, *be_type, *fe_path, *tmp;
+const char *be_path, *fe_path, *tmp;
+libxl__device dev;
 int rc;
 
 vkb->devid = devid;
@@ -111,13 +109,11 @@ static int libxl__vkb_from_xenstore(libxl__gc *gc, const 
char *libxl_path,
 rc = libxl__backendpath_parse_domid(gc, be_path, >backend_domid);
 if (rc) goto out;
 
-rc = libxl__xs_read_mandatory(gc, XBT_NULL,
-  GCSPRINTF("%s/backend-type", be_path),
-  _type);
+rc = libxl__parse_backend_path(gc, be_path, );
 if (rc) goto out;
 
-rc = libxl_vkb_backend_from_string(be_type, >backend_type);
-if (rc) goto out;
+vkb->backend_type = dev.backend_kind == LIBXL__DEVICE_KIND_VINPUT ?
+LIBXL_VKB_BACKEND_LINUX : 
LIBXL_VKB_BACKEND_QEMU;
 
 vkb->unique_id = xs_read(CTX->xsh, XBT_NULL, 
GCSPRINTF("%s/"XENKBD_FIELD_UNIQUE_ID, be_path), NULL);
 
@@ -218,6 +214,20 @@ out:
 return rc;
 }
 
+static int libxl__device_from_vkb(libxl__gc *gc, uint32_t domid,
+  libxl_device_vkb *type, libxl__device 
*device)
+{
+device->backend_devid   = type->devid;
+device->backend_domid   = type->backend_domid;
+device->backend_kind= type->backend_type == LIBXL_VKB_BACKEND_LINUX ?
+  LIBXL__DEVICE_KIND_VINPUT : 
LIBXL__DEVICE_KIND_VKBD;
+device->devid   = type->devid;
+device->domid   = domid;
+device->kind= LIBXL__DEVICE_KIND_VKBD;
+
+return 0;
+}
+
 int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb,
  const libxl_asyncop_how *ao_how)
 {
@@ -318,7 +328,6 @@ out:
  return rc;
 }
 
-static LIBXL_DEFINE_DEVICE_FROM_TYPE(vkb)
 static LIBXL_DEFINE_UPDATE_DEVID(vkb)
 
 #define libxl__add_vkbs NULL
-- 
2.17.1


___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

[Xen-devel] [PATCH v2 3/3] libxl: make default path to add/remove all PV devices

2019-11-21 Thread Oleksandr Grytsov
From: Oleksandr Grytsov 

Adding/removing device is handled for specific devices only: VBD, VIF,
QDISK. This commit adds default case to handle adding/removing for all PV
devices by default, except QDISK device, which requires special handling.
If any other device is required a special handling it should be done by
implementing separate case (similar to QDISK device). The default
behaviour for adding device is to wait when the backend goes to
XenbusStateInitWait and the default behaviour on removing device is to
start generic device remove procedure.

Also this commit fixes removing guest function: before the guest was
removed when all VIF and VBD devices are removed. The fix removes
guest when all created devices are removed. This is done by checking the
guest device list instead of checking num_vifs and num_vbds. num_vifs and
num_vbds variables are removed as redundant in this case.

Signed-off-by: Oleksandr Grytsov 
---
 tools/libxl/libxl_device.c | 63 +++---
 1 file changed, 24 insertions(+), 39 deletions(-)

diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c
index 1402b61a81..9d05d2fd13 100644
--- a/tools/libxl/libxl_device.c
+++ b/tools/libxl/libxl_device.c
@@ -1477,7 +1477,7 @@ typedef struct libxl__ddomain_device {
  */
 typedef struct libxl__ddomain_guest {
 uint32_t domid;
-int num_vifs, num_vbds, num_qdisks;
+int num_qdisks;
 LIBXL_SLIST_HEAD(, struct libxl__ddomain_device) devices;
 LIBXL_SLIST_ENTRY(struct libxl__ddomain_guest) next;
 } libxl__ddomain_guest;
@@ -1530,8 +1530,7 @@ static void check_and_maybe_remove_guest(libxl__gc *gc,
 {
 assert(ddomain);
 
-if (dguest != NULL &&
-dguest->num_vifs + dguest->num_vbds + dguest->num_qdisks == 0) {
+if (dguest != NULL && LIBXL_SLIST_FIRST(>devices) == NULL) {
 LIBXL_SLIST_REMOVE(>guests, dguest, libxl__ddomain_guest,
next);
 LOGD(DEBUG, dguest->domid, "Removed domain from the list of active 
guests");
@@ -1571,24 +1570,6 @@ static int add_device(libxl__egc *egc, libxl__ao *ao,
  libxl__device_backend_path(gc, dev));
 
 switch(dev->backend_kind) {
-case LIBXL__DEVICE_KIND_VBD:
-case LIBXL__DEVICE_KIND_VIF:
-if (dev->backend_kind == LIBXL__DEVICE_KIND_VBD) dguest->num_vbds++;
-if (dev->backend_kind == LIBXL__DEVICE_KIND_VIF) dguest->num_vifs++;
-
-GCNEW(aodev);
-libxl__prepare_ao_device(ao, aodev);
-/*
- * Clone the libxl__device to avoid races if remove_device is called
- * before the device addition has finished.
- */
-GCNEW(aodev->dev);
-*aodev->dev = *dev;
-aodev->action = LIBXL__DEVICE_ACTION_ADD;
-aodev->callback = device_complete;
-libxl__wait_device_connection(egc, aodev);
-
-break;
 case LIBXL__DEVICE_KIND_QDISK:
 if (dguest->num_qdisks == 0) {
 GCNEW(dmss);
@@ -1599,10 +1580,19 @@ static int add_device(libxl__egc *egc, libxl__ao *ao,
 libxl__spawn_qdisk_backend(egc, dmss);
 }
 dguest->num_qdisks++;
-
 break;
 default:
-rc = 1;
+GCNEW(aodev);
+libxl__prepare_ao_device(ao, aodev);
+/*
+ * Clone the libxl__device to avoid races if remove_device is called
+ * before the device addition has finished.
+ */
+GCNEW(aodev->dev);
+*aodev->dev = *dev;
+aodev->action = LIBXL__DEVICE_ACTION_ADD;
+aodev->callback = device_complete;
+libxl__wait_device_connection(egc, aodev);
 break;
 }
 
@@ -1619,11 +1609,17 @@ static int remove_device(libxl__egc *egc, libxl__ao *ao,
 int rc = 0;
 
 switch(ddev->dev->backend_kind) {
-case LIBXL__DEVICE_KIND_VBD:
-case LIBXL__DEVICE_KIND_VIF:
-if (dev->backend_kind == LIBXL__DEVICE_KIND_VBD) dguest->num_vbds--;
-if (dev->backend_kind == LIBXL__DEVICE_KIND_VIF) dguest->num_vifs--;
-
+case LIBXL__DEVICE_KIND_QDISK:
+if (--dguest->num_qdisks == 0) {
+rc = libxl__destroy_qdisk_backend(gc, dev->domid);
+if (rc)
+goto out;
+}
+libxl__device_destroy(gc, dev);
+/* Return > 0, no ao has been dispatched */
+rc = 1;
+break;
+default:
 GCNEW(aodev);
 libxl__prepare_ao_device(ao, aodev);
 /*
@@ -1636,17 +1632,6 @@ static int remove_device(libxl__egc *egc, libxl__ao *ao,
 aodev->callback = device_complete;
 libxl__initiate_device_generic_remove(egc, aodev);
 break;
-case LIBXL__DEVICE_KIND_QDISK:
-if (--dguest->num_qdisks == 0) {
-rc = libxl__destroy_qdisk_backend(gc, dev->domid);
-if (rc)
-goto out;
-}
-libxl__device_destroy

[Xen-devel] [PATCH v2 0/3] Remove backend xen store entry on domain destroy

2019-11-21 Thread Oleksandr Grytsov
From: Oleksandr Grytsov 

Changes since v1:

* add commit to rename VKB backend type "linux" to "pv";
* add default case to handle adding/removing PV devices in add_device,
  remove_device functions (libxl_device.c);
* add comment about removing num_vifs, num_vbds into commit message.

Oleksandr Grytsov (3):
  libxl: introduce new backend type VINPUT
  libxl: rename VKB backend type "linux" to "pv"
  libxl: make default path to add/remove all PV devices

 docs/man/xl.cfg.5.pod.in |  4 +-
 tools/libxl/libxl_device.c   | 63 +++-
 tools/libxl/libxl_types.idl  |  2 +-
 tools/libxl/libxl_types_internal.idl |  1 +
 tools/libxl/libxl_vkb.c  | 29 -
 5 files changed, 47 insertions(+), 52 deletions(-)

-- 
2.17.1


___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

[Xen-devel] [PATCH v2 2/3] libxl: rename VKB backend type "linux" to "pv"

2019-11-21 Thread Oleksandr Grytsov
From: Oleksandr Grytsov 

There are two kind of VKB backends: QEMU and user space PV backend.
For PV backend "linux" enum is used but this name is confused. Rename
"linux" enum to "pv" as it better matches user space PV backend.

Signed-off-by: Oleksandr Grytsov 
---
 docs/man/xl.cfg.5.pod.in| 4 ++--
 tools/libxl/libxl_types.idl | 2 +-
 tools/libxl/libxl_vkb.c | 4 ++--
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/docs/man/xl.cfg.5.pod.in b/docs/man/xl.cfg.5.pod.in
index 245d3f9472..37bdc595d3 100644
--- a/docs/man/xl.cfg.5.pod.in
+++ b/docs/man/xl.cfg.5.pod.in
@@ -1562,8 +1562,8 @@ Specifies the backend domain name or id.
 
 =item B
 
-Specifies the backend type: qemu - for QEMU backend or linux - for Linux PV
-domain.
+Specifies the backend type: qemu - for QEMU backend or pv - for PV
+backend.
 
 =item B
 
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index 0546d7865a..751dad8870 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -260,7 +260,7 @@ libxl_vuart_type = Enumeration("vuart_type", [
 libxl_vkb_backend = Enumeration("vkb_backend", [
 (0, "UNKNOWN"),
 (1, "QEMU"),
-(2, "LINUX")
+(2, "PV")
 ])
 
 libxl_passthrough = Enumeration("passthrough", [
diff --git a/tools/libxl/libxl_vkb.c b/tools/libxl/libxl_vkb.c
index 4c44a813c1..5f018f55b7 100644
--- a/tools/libxl/libxl_vkb.c
+++ b/tools/libxl/libxl_vkb.c
@@ -113,7 +113,7 @@ static int libxl__vkb_from_xenstore(libxl__gc *gc, const 
char *libxl_path,
 if (rc) goto out;
 
 vkb->backend_type = dev.backend_kind == LIBXL__DEVICE_KIND_VINPUT ?
-LIBXL_VKB_BACKEND_LINUX : 
LIBXL_VKB_BACKEND_QEMU;
+LIBXL_VKB_BACKEND_PV : 
LIBXL_VKB_BACKEND_QEMU;
 
 vkb->unique_id = xs_read(CTX->xsh, XBT_NULL, 
GCSPRINTF("%s/"XENKBD_FIELD_UNIQUE_ID, be_path), NULL);
 
@@ -219,7 +219,7 @@ static int libxl__device_from_vkb(libxl__gc *gc, uint32_t 
domid,
 {
 device->backend_devid   = type->devid;
 device->backend_domid   = type->backend_domid;
-device->backend_kind= type->backend_type == LIBXL_VKB_BACKEND_LINUX ?
+device->backend_kind= type->backend_type == LIBXL_VKB_BACKEND_PV ?
   LIBXL__DEVICE_KIND_VINPUT : 
LIBXL__DEVICE_KIND_VKBD;
 device->devid   = type->devid;
 device->domid   = domid;
-- 
2.17.1


___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] Status of 4.13

2019-11-21 Thread Oleksandr Grytsov
On Thu, Nov 21, 2019 at 4:16 PM Ian Jackson  wrote:
>
> Wei Liu writes ("Re: Status of 4.13"):
> > FWIW I've pushed all the toolstack patches that I'm aware of.
>
> The only thing outstanding that I am aware of is
>  [PATCH for-4.13 v1 1/2] libxl: introduce new backend type VINPUT
> of which I am awaiting a respin from Oleksandr Grytsov (in the To).
>
> There is a new defect in the 4.13 API, where a particular enum has the
> value `linux' for a non-Linux-specific protocol.  I'm wanting to
> change it and I think we have agreed a name change to `pv'.  Oleksandr
> was going to take care of that in his respin of that small 2-patch
> series.
>
> Oleksandr, when do you think you will be able to do your respin ?
> I am not sure I know exactly what you were planning to do but if you
> are not available I could have a go at it.  Please let me know ASAP.
>
> Ian.

The patches is ready, I'll submit them today soon.


-- 
Best Regards,
Oleksandr Grytsov.

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH for-4.13 v1 1/2] libxl: introduce new backend type VINPUT

2019-11-19 Thread Oleksandr Grytsov
On Mon, Nov 18, 2019 at 7:55 PM Ian Jackson  wrote:
>
> Oleksandr Grytsov writes ("[PATCH v1 1/2] libxl: introduce new backend type 
> VINPUT"):
> > From: Oleksandr Grytsov 
> >
> > There are two kind of VKBD devices: with QEMU backend and user space
> > backend. In current implementation they can't be distinguished as both use
> > VKBD backend type. As result, user space KBD backend is started and
> > stopped as QEMU backend. This commit adds new device kind VINPUT to be
> > used as backend type for user space KBD backend.
>
> Thank you for this patch and thank you for the explanations.
>
> Acked-by: Ian Jackson 
>
> I wasn't able to find a posting of this patch before the last posting
> date for 4.13 of the 13th of September.  Have I missed it ?  We might
> be able to justify a freeze exception on the grounds that this change
> affects only vkb users but it would be a matter for the RM (CC'd).
>

This commit was submitted with patcheset [1].
Earlier I've submitted the patch to solve the issue with patchest [2].
But that patchet was totally wrong.

>
> I would like to change the "linux" to "pv" or something else, for
> 4.13, at least.

I will submit V2 with renaming and comments addressed for second commit [3]
of the patchset.

>
> Ian.

[1] https://marc.info/?l=xen-devel=157054390006691=2
[2] https://marc.info/?l=xen-devel=151326089604524=2
[3] https://marc.info/?l=xen-devel=157054391506708=2


--
Best Regards,
Oleksandr Grytsov.

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH v1 1/2] libxl: introduce new backend type VINPUT

2019-11-18 Thread Oleksandr Grytsov
On Fri, Nov 15, 2019 at 9:43 PM Ian Jackson  wrote:
>
> Oleksandr Grytsov writes ("Re: [PATCH v1 1/2] libxl: introduce new backend 
> type VINPUT"):
> > 1. Move QEMU_BACKEND macro to libxl__device_type structure as function
> > and let the device to decide it has QEMU backend:
> >
> > struct libxl__device_type {
> > ...
> > device_qemu_backend_fn_t qemu_backend
> > }
> >
> > In this case, introducing new device type for VKBD is not needed. The VKBD
> > device will check backend type XS entry to define which backend is running.
>
> Sorry for the delay replying.  In your earlier mails I had trouble
> figuring out what you meant but this little vignette makes it clear to
> me.
>
> I think the problem you are trying to solve is this: in your case
> QEMU_BACKEND needs to depend on the visible vkb_backend field, but the
> device->backend_kind is set unconditionally to just VKB ?

Exactly.

>
> Could you solve this problem by inventing a new backend_kind, and
> writing your own function libxl__device_from_vkb, and putting
> *different* values into backend_kind ?  I think that is what
> backend_kind is for.  See for example various console functions and
> also libxl__device_from_disk.
>

This what was done in this patch. VINPUT backend type was introduced.
Probably the name should be changed but have no idea which backend
kind is more suitable for this purpose.

Also bakcend-type xenstore entry was removed as redundant in this case.
As the PV backend expects device kind VINPUT.

> > 2. Use string type for VKBD backend_type field instead of enum. It will be
> > empty for QEMU and generic for "user space" backends.
>
> This seems worse.
>
> > On Mon, Oct 28, 2019 at 4:06 PM Oleksandr Grytsov  wrote:
> > > On Wed, Oct 16, 2019 at 4:26 PM Oleksandr Grytsov  
> > > wrote:
> > > > [Ian:]
> > > > > [Oleksandr:]
> > > > > > [Ian:]
> > > > > > > I also don't understand why the "user space" kbd backend seems to 
> > > > > > > be
> > > > > > > "linux" in the enum.
> > > > > >
> > > > > > I agree this is not so good name. But I don't know how to call
> > > > > > backends which are not running
> > > > > > inside QEMU in general.
> > > > >
> > > > > I think this would be useable on freebsd ?  "linux" definitely seems
> > > > > wrong.  I see it hasn't been in a release so it is not too late to
> > > > > rename it, subject to discussion with Juergen as RM.
> ...
> > > > > Maybe "linux" should be "troops"...
> > > >
> > > > It doesn't look as generic solution. If some user implements own backend
> > > > it should add new entry into backend type enum.
>
> Would you be prepared to change it to *something* else ?
>
> AFAICT from the code it just uses what would the `usual' xenstore pv
> control plane path for a device called "vkb" ?
>

I guess yes.

> So maybe we could call it "pv" ?

Do you mean LIBXL_VKB_BACKEND_PV?

> Is there a protocol doc I should be
> looking at that defines this vkb interface ?
>

This PV backend utilizes the protocol described in kbdif.h

> Sorry still to be so confused.
>
> Regards,
> Ian.



-- 
Best Regards,
Oleksandr Grytsov.

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH v1 1/2] libxl: introduce new backend type VINPUT

2019-11-04 Thread Oleksandr Grytsov
On Mon, Oct 28, 2019 at 4:06 PM Oleksandr Grytsov  wrote:
>
> On Wed, Oct 16, 2019 at 4:26 PM Oleksandr Grytsov  wrote:
> >
> > On Fri, Oct 11, 2019 at 8:04 PM Ian Jackson  wrote:
> > >
> > > Oleksandr Grytsov writes ("Re: [PATCH v1 1/2] libxl: introduce new 
> > > backend type VINPUT"):
> > > > On Fri, Oct 11, 2019 at 5:58 PM Ian Jackson  
> > > > wrote:
> > > > > I think it was a48e00f14a2d "libxl: add backend type and id to vkb"
> > > > > which introduced what you are calling "user space" backends.  It
> > > > > appears that the vkb backend type enum was introduced there
> > > > > specifically to distinguish between these two situations.  For reasons
> > > > >
> > > > > Am I wrong ?  If not, why is this not working or not suitable ?
> > > >
> > > > You are right. It is not working in some cases due to QEMU_BACKEND 
> > > > macro.
> > > > QEMU_BACKEND treats both backends as QEMU. As result xl performs device
> > > > hotplug on add/remove device. Which is not expected in case "user
> > > > space" backend.
> > >
> > > Then perhaps this macro needs to be adjusted or called only
> > > conditionally or something ?
> >
> > I had an idea to move this macro to libxl__device_type and let device
> > itself decides
> > if it is qemu backend. But in case of VKBD it will read XS to determine 
> > backend
> > type. I guess it is ok.
> >
> > >
> > > > In this patch I propose solution similar to VUSB device. Where VUSB
> > > > used for frontend and depends on backend (kernel or QEMU) either
> > > > VUSB or QUSB used for backend device type e.g. use different backend
> > > > device type for different backends.
> > >
> > > I confess I don't quite follow all the VUSB stuff but I don't think it
> > > is necessarily a good model.
> >
> > If you don't mind to move QEMU_BACKEND macrto to libxl__device_type then
> > no need to add new device type at all.
> >
> > >
> > > > Introducing new backend device type for VKBD also allows to have
> > > > both backends (QEMU and non QEMU) run in same domain. Not sure if it
> > > > is useful scenario but with this proposal it is possible from
> > > > technical point of view.
> > >
> > > I don't understand why this is not possible simply by having a
> > > different backend type.
> > >
> > > > > I also don't understand why the "user space" kbd backend seems to be
> > > > > "linux" in the enum.
> > > >
> > > > I agree this is not so good name. But I don't know how to call
> > > > backends which are not running
> > > > inside QEMU in general.
> > >
> > > I think this would be useable on freebsd ?  "linux" definitely seems
> > > wrong.  I see it hasn't been in a release so it is not too late to
> > > rename it, subject to discussion with Juergen as RM.
> > >
> > > > > Where is the implementation of this user space
> > > > > backend ?
> > > >
> > > > We have extended kbd interface (kbdif.h) to support multi-touch events
> > > > as well. And we have
> > > > implemented own kbd backend https://github.com/xen-troops/displ_be/
> > > > It is integrated with display backend as both use wayland API.
> > >
> > > Great.
> > >
> > > > > Is it be controlled entirely through xenstore ?
> > > >
> > > > Yes it is controlled entirely through xenstore: lib xl creates
> > > > frontend/backend entries with
> > > > initial states and configuration.
> > >
> > > And your display backend in "troops" (is that the name of your
> > > project) checks whether the backend type is set to "linux", so that it
> > > knows to ignore ones that say "qemu" ?
> > >
> > > Maybe "linux" should be "troops"...
> > >
> >
> > It doesn't look as generic solution. If some user implements own backend
> > it should add new entry into backend type enum.
> > What about to have just string value instead of enum? In case QEMU
> > we don't have such entry at all but in case custom backend the user
> > can't put any string value here to be recognized by his backend.
> >
> > > Ian.
>
> ping

ping

Ian,

I'm waiting for your comments about following questions:

1. Move QEMU_BACKEND macro to libxl__device_type structure as function
and let the device to decide it has QEMU backend:

struct libxl__device_type {
...
device_qemu_backend_fn_t qemu_backend
}

In this case, introducing new device type for VKBD is not needed. The VKBD
device will check backend type XS entry to define which backend is running.

2. Use string type for VKBD backend_type field instead of enum. It will be
empty for QEMU and generic for "user space" backends.

Thanks.

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

[Xen-devel] [PATCH v1 0/1] libxl/gentypes: add range init to array elements in json parsing

2019-10-28 Thread Oleksandr Grytsov
From: Oleksandr Grytsov 

There are two old threads in which this issues was addresses ([1], [2]) but
the root cause wasn't defined. The real root cause is that when libxl creates
json file it doesn't put entries for fields with default value (which is
correct). Then during parsing json back to data, array elements are initialized
by zero in all cases. But they should be initialized to default value (if it is
not equals to zero).

[1] https://marc.info/?l=xen-devel=151378727210130=2
[2] https://marc.info/?l=xen-devel=157071551925734=2

Oleksandr Grytsov (1):
  libxl/gentypes: add range init to array elements in json parsing

 tools/libxl/gentypes.py | 2 ++
 1 file changed, 2 insertions(+)

-- 
2.17.1


___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

[Xen-devel] [PATCH v1 1/1] libxl/gentypes: add range init to array elements in json parsing

2019-10-28 Thread Oleksandr Grytsov
From: Oleksandr Grytsov 

Add initialization of array elements in parse json function.

Currently, array elements are initialized with calloc. Which means
initialize all element fields with zero values. If entries are missed in
json for such fields, it will be equal to zero instead of default values.
The fix is to add range init function before parsing array element for
structures which have defined range init function.

Signed-off-by: Oleksandr Grytsov 
---
 tools/libxl/gentypes.py | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/libxl/gentypes.py b/tools/libxl/gentypes.py
index 6417c9dd8c..4ff5d8a2d0 100644
--- a/tools/libxl/gentypes.py
+++ b/tools/libxl/gentypes.py
@@ -456,6 +456,8 @@ def libxl_C_type_parse_json(ty, w, v, indent = "", 
parent = None, discrimina
 s += "goto out;\n"
 s += "}\n"
 s += "for (i=0; (t=libxl__json_array_get(x,i)); i++) {\n"
+if ty.elem_type.init_fn is not None and 
ty.elem_type.autogenerate_init_fn:
+s += indent + ""+"%s_init(&%s[i]);\n" % 
(ty.elem_type.typename, v)
 s += libxl_C_type_parse_json(ty.elem_type, "t", v+"[i]",
  indent + "", parent)
 s += "}\n"
-- 
2.17.1


___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH v1 1/2] libxl: introduce new backend type VINPUT

2019-10-28 Thread Oleksandr Grytsov
On Wed, Oct 16, 2019 at 4:26 PM Oleksandr Grytsov  wrote:
>
> On Fri, Oct 11, 2019 at 8:04 PM Ian Jackson  wrote:
> >
> > Oleksandr Grytsov writes ("Re: [PATCH v1 1/2] libxl: introduce new backend 
> > type VINPUT"):
> > > On Fri, Oct 11, 2019 at 5:58 PM Ian Jackson  
> > > wrote:
> > > > I think it was a48e00f14a2d "libxl: add backend type and id to vkb"
> > > > which introduced what you are calling "user space" backends.  It
> > > > appears that the vkb backend type enum was introduced there
> > > > specifically to distinguish between these two situations.  For reasons
> > > >
> > > > Am I wrong ?  If not, why is this not working or not suitable ?
> > >
> > > You are right. It is not working in some cases due to QEMU_BACKEND macro.
> > > QEMU_BACKEND treats both backends as QEMU. As result xl performs device
> > > hotplug on add/remove device. Which is not expected in case "user
> > > space" backend.
> >
> > Then perhaps this macro needs to be adjusted or called only
> > conditionally or something ?
>
> I had an idea to move this macro to libxl__device_type and let device
> itself decides
> if it is qemu backend. But in case of VKBD it will read XS to determine 
> backend
> type. I guess it is ok.
>
> >
> > > In this patch I propose solution similar to VUSB device. Where VUSB
> > > used for frontend and depends on backend (kernel or QEMU) either
> > > VUSB or QUSB used for backend device type e.g. use different backend
> > > device type for different backends.
> >
> > I confess I don't quite follow all the VUSB stuff but I don't think it
> > is necessarily a good model.
>
> If you don't mind to move QEMU_BACKEND macrto to libxl__device_type then
> no need to add new device type at all.
>
> >
> > > Introducing new backend device type for VKBD also allows to have
> > > both backends (QEMU and non QEMU) run in same domain. Not sure if it
> > > is useful scenario but with this proposal it is possible from
> > > technical point of view.
> >
> > I don't understand why this is not possible simply by having a
> > different backend type.
> >
> > > > I also don't understand why the "user space" kbd backend seems to be
> > > > "linux" in the enum.
> > >
> > > I agree this is not so good name. But I don't know how to call
> > > backends which are not running
> > > inside QEMU in general.
> >
> > I think this would be useable on freebsd ?  "linux" definitely seems
> > wrong.  I see it hasn't been in a release so it is not too late to
> > rename it, subject to discussion with Juergen as RM.
> >
> > > > Where is the implementation of this user space
> > > > backend ?
> > >
> > > We have extended kbd interface (kbdif.h) to support multi-touch events
> > > as well. And we have
> > > implemented own kbd backend https://github.com/xen-troops/displ_be/
> > > It is integrated with display backend as both use wayland API.
> >
> > Great.
> >
> > > > Is it be controlled entirely through xenstore ?
> > >
> > > Yes it is controlled entirely through xenstore: lib xl creates
> > > frontend/backend entries with
> > > initial states and configuration.
> >
> > And your display backend in "troops" (is that the name of your
> > project) checks whether the backend type is set to "linux", so that it
> > knows to ignore ones that say "qemu" ?
> >
> > Maybe "linux" should be "troops"...
> >
>
> It doesn't look as generic solution. If some user implements own backend
> it should add new entry into backend type enum.
> What about to have just string value instead of enum? In case QEMU
> we don't have such entry at all but in case custom backend the user
> can't put any string value here to be recognized by his backend.
>
> > Ian.

ping

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [XEN PATCH for-4.13 v1] Reset iomem's gfn to LIBXL_INVALID_GFN on reboot

2019-10-24 Thread Oleksandr Grytsov
On Tue, Oct 22, 2019 at 9:14 PM Julien Grall  wrote:
>
> Hi Oleksandr,
>
> Apologies for the late answer.
>
> On 16/10/2019 14:09, Oleksandr Grytsov wrote:
> > On Mon, Oct 14, 2019 at 12:28 PM Julien Grall  wrote:
> > Thanks to point me out for this old thread. I completely forgot about it
> > (I haven't worked with xen since long time). I've performed additional
> > investigation
> > and found the root cause of the issue. It doesn't relate to iomem GFN 
> > directly.
> > The problem is in type from json parsing at place where libxl creates array 
> > of
> > struct.
> >
> > For example, libxl_domain_config_from_json calls libxl_domain_config_init
> > which initializes all child structures and arrays. But then when libxl 
> > parses
> > json and creates the array of structure, it doesn't initialize array 
> > elements
> > properly (see libxl__domain_build_info_parse_json iomem parsing):
> >
> > p->num_iomem = x->u.array->count;
> > p->iomem = libxl__calloc(NOGC, p->num_iomem, sizeof(*p->iomem));
> > if (!p->iomem && p->num_iomem != 0) {
> >  rc = -1;
> >  goto out;
> > }
> > for (i=0; (t=libxl__json_array_get(x,i)); i++) {
> >  rc = libxl__iomem_range_parse_json(gc, t, >iomem[i]);
> >  if (rc)
> > goto out;
> > }
> >
> > libxl creates array element with calloc function, so all element
> > fields are initialized
> > with zero values. Even some of them have default value different from zero.
> > For these purpose dedicated init function should be called for each element.
> > Above example should be:
> >
> > for (i=0; (t=libxl__json_array_get(x,i)); i++) {
> >  libxl_iomem_range_init(>iomem[i]);
> >  rc = libxl__iomem_range_parse_json(gc, t, >iomem[i]);
> >  if (rc)
> > goto out;
> > }
>
> Not initializing the values is fine as long as the JSON describes all the 
> fields
> of the structure.
>
> The key point here is the GFN is not described in the JSON (see
> libxl_iomem_range_gen_json) if it is equal to LIBXL_INVALID_GFN. As the field 
> is
> not described, it will be defaulted to 0.
>

Yes. So, either  ..._gen_json should generate entries for default
values or ..._parse_json
should set missing entries to its default values. Second solution looks more
correct.

> >
> > I've changes gentypes.py as following:
> >
> > diff --git a/tools/libxl/gentypes.py b/tools/libxl/gentypes.py
> > index 88e5c5f30e..92e28be469 100644
> > --- a/tools/libxl/gentypes.py
> > +++ b/tools/libxl/gentypes.py
> > @@ -454,6 +454,8 @@ def libxl_C_type_parse_json(ty, w, v, indent = "
> >   ", parent = None, discrimina
> >   s += "goto out;\n"
> >   s += "}\n"
> >   s += "for (i=0; (t=libxl__json_array_get(x,i)); i++) {\n"
> > +if ty.elem_type.init_fn is not None and
> > ty.elem_type.autogenerate_init_fn:
>
> My knowledge of libxl is quite limited. But I don't think this is correct, you
> want to call init_fn whether this has been autogenerated or not.
>
> > +s += indent + ""+"%s_init(&%s[i]);\n" %
> > (ty.elem_type.typename, v)
>
> Looking at the other usage (like _libxl_C_type_init), init_fn is called with
>
>  s += "%s(%s);\n" % (ty.init_fn, ty.pass_arg(v, parent is None))
>
> I am also not entirely sure whether we should also cater the ty.init_val != 
> None
> as well here.
>
> >   s += libxl_C_type_parse_json(ty.elem_type, "t", v+"[i]",
> >indent + "", parent)
> >   s += "}\n"
> >
> > I'm not sure is it right and complete fix.
> >
> > Ian, could you review?
> >
> > If the fix is ok, I will submit the patch.
>
> IHMO, the idea is there. The code may need some modifications (see above).
> Please post a patch so we can go forward in the process to review it.

Thanks. I will post the separate path.

>
> Cheers,
>
> --
> Julien Grall



-- 
Best Regards,
Oleksandr Grytsov.

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [XEN PATCH v1] libxl: Add DTB compatible list to config file

2019-10-16 Thread Oleksandr Grytsov
On Wed, Oct 16, 2019 at 5:12 PM Julien Grall  wrote:
>
> Hi Oleksandr,
>
> On 16/10/2019 15:04, Oleksandr Grytsov wrote:
> > On Fri, Oct 11, 2019 at 8:21 PM Stefano Stabellini
> >  wrote:
> >>
> >> On Fri, 11 Oct 2019, Julien Grall wrote:
> >>> Hi,
> >>>
> >>> On 11/10/2019 16:23, Ian Jackson wrote:
> >>>> Oleksandr Grytsov writes ("[PATCH v1] libxl: Add DTB compatible list to
> >>>> config file"):
> >>>>> From: Oleksandr Grytsov 
> >>>>>
> >>>>> Some platforms need more compatible property values in device
> >>>>> tree root node in addition to "xen,xenvm-%d.%d" and "xen,xenvm"
> >>>>> values that are given by Xen by default.
> >>>
> >>> I am pretty sure I have seen this patch a few years ago, but I can't find 
> >>> it
> >>> in my inbox. What is the exact problem here?
> >>>
> >>>>> Specify in domain configuration file which values should be added
> >>>>> by providing "dtb_compatible" list of strings separated by comas.
> >>>>
> >>>> Hi, thanks.
> >>>>
> >>>> I don't have an opinion about the principle of this and would like to
> >>>> hear from ARM folks about that.
> >>>>
> >>>> Also, Stefano, Julien: should we be asking for a freeze exception for
> >>>> this for 4.13 ?
> >>>
> >>> I don't have enough context to understand the exact issue he is trying to
> >>> solve.
> >>
> >> Same here. Is this patch needed because on some platform the OS checks
> >> for the platform "model" (also known as "machine name") on device tree
> >> before continuing or to trigger a difference behavior?
> >
> > Yes, exactly.
> >
> > I will redo the patch with Ian's comments if it is ok in general.
>
> By specifying a different compatible (let say "renesas,r8a774a1"), then you
> claim that your virtual machine is exactly the same as that board.
>
> This means, the OS is free to assume that the memory layout and all the 
> devices
> are exactly the same. This is definitely not true as the virtual machine we
> expose is specific to Xen.
>
> So I don't think this is the correct approach here. Can you provide a 
> real-life
> example on why you need this?
>
> Cheers,
>
> --
> Julien Grall

This is required for HW domains. Some drivers or initialization routines check
compatible. Below is example from linux kernel sources:

linux/sound/ppc/awacs.c:741:if (of_machine_is_compatible("PowerBook3,1")
linux/sound/ppc/awacs.c:742:||
of_machine_is_compatible("PowerBook3,2")) {
linux/sound/ppc/awacs.c:770:#define IS_PM7500
(of_machine_is_compatible("AAPL,7500") \
linux/sound/ppc/awacs.c:771:|| of_machine_is_compatible("AAPL,8500") \
linux/sound/ppc/awacs.c:772:|| of_machine_is_compatible("AAPL,9500"))
...
linux/arch/arm/mach-omap2/pdata-quirks.c:703:if
(of_machine_is_compatible(quirks->compatible)) {
linux/arch/arm/mach-omap2/pdata-quirks.c:717:if
(of_machine_is_compatible("ti,omap2420") ||
linux/arch/arm/mach-omap2/pdata-quirks.c:718:
of_machine_is_compatible("ti,omap3"))
linux/arch/arm/mach-omap2/pdata-quirks.c:721:if
(of_machine_is_compatible("ti,omap3"))
...

Also see [1]

[1] 
https://source.codeaurora.org/external/imx/imx-xen/commit/?h=imx_4.14.98_2.0.0_ga=6e58d478203639e71da3da69ffeae3fa5dc0197b

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [XEN PATCH v1] libxl: Add DTB compatible list to config file

2019-10-16 Thread Oleksandr Grytsov
On Fri, Oct 11, 2019 at 8:21 PM Stefano Stabellini
 wrote:
>
> On Fri, 11 Oct 2019, Julien Grall wrote:
> > Hi,
> >
> > On 11/10/2019 16:23, Ian Jackson wrote:
> > > Oleksandr Grytsov writes ("[PATCH v1] libxl: Add DTB compatible list to
> > > config file"):
> > > > From: Oleksandr Grytsov 
> > > >
> > > > Some platforms need more compatible property values in device
> > > > tree root node in addition to "xen,xenvm-%d.%d" and "xen,xenvm"
> > > > values that are given by Xen by default.
> >
> > I am pretty sure I have seen this patch a few years ago, but I can't find it
> > in my inbox. What is the exact problem here?
> >
> > > > Specify in domain configuration file which values should be added
> > > > by providing "dtb_compatible" list of strings separated by comas.
> > >
> > > Hi, thanks.
> > >
> > > I don't have an opinion about the principle of this and would like to
> > > hear from ARM folks about that.
> > >
> > > Also, Stefano, Julien: should we be asking for a freeze exception for
> > > this for 4.13 ?
> >
> > I don't have enough context to understand the exact issue he is trying to
> > solve.
>
> Same here. Is this patch needed because on some platform the OS checks
> for the platform "model" (also known as "machine name") on device tree
> before continuing or to trigger a difference behavior?

Yes, exactly.

I will redo the patch with Ian's comments if it is ok in general.

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH v1 1/2] libxl: introduce new backend type VINPUT

2019-10-16 Thread Oleksandr Grytsov
On Fri, Oct 11, 2019 at 8:04 PM Ian Jackson  wrote:
>
> Oleksandr Grytsov writes ("Re: [PATCH v1 1/2] libxl: introduce new backend 
> type VINPUT"):
> > On Fri, Oct 11, 2019 at 5:58 PM Ian Jackson  wrote:
> > > I think it was a48e00f14a2d "libxl: add backend type and id to vkb"
> > > which introduced what you are calling "user space" backends.  It
> > > appears that the vkb backend type enum was introduced there
> > > specifically to distinguish between these two situations.  For reasons
> > >
> > > Am I wrong ?  If not, why is this not working or not suitable ?
> >
> > You are right. It is not working in some cases due to QEMU_BACKEND macro.
> > QEMU_BACKEND treats both backends as QEMU. As result xl performs device
> > hotplug on add/remove device. Which is not expected in case "user
> > space" backend.
>
> Then perhaps this macro needs to be adjusted or called only
> conditionally or something ?

I had an idea to move this macro to libxl__device_type and let device
itself decides
if it is qemu backend. But in case of VKBD it will read XS to determine backend
type. I guess it is ok.

>
> > In this patch I propose solution similar to VUSB device. Where VUSB
> > used for frontend and depends on backend (kernel or QEMU) either
> > VUSB or QUSB used for backend device type e.g. use different backend
> > device type for different backends.
>
> I confess I don't quite follow all the VUSB stuff but I don't think it
> is necessarily a good model.

If you don't mind to move QEMU_BACKEND macrto to libxl__device_type then
no need to add new device type at all.

>
> > Introducing new backend device type for VKBD also allows to have
> > both backends (QEMU and non QEMU) run in same domain. Not sure if it
> > is useful scenario but with this proposal it is possible from
> > technical point of view.
>
> I don't understand why this is not possible simply by having a
> different backend type.
>
> > > I also don't understand why the "user space" kbd backend seems to be
> > > "linux" in the enum.
> >
> > I agree this is not so good name. But I don't know how to call
> > backends which are not running
> > inside QEMU in general.
>
> I think this would be useable on freebsd ?  "linux" definitely seems
> wrong.  I see it hasn't been in a release so it is not too late to
> rename it, subject to discussion with Juergen as RM.
>
> > > Where is the implementation of this user space
> > > backend ?
> >
> > We have extended kbd interface (kbdif.h) to support multi-touch events
> > as well. And we have
> > implemented own kbd backend https://github.com/xen-troops/displ_be/
> > It is integrated with display backend as both use wayland API.
>
> Great.
>
> > > Is it be controlled entirely through xenstore ?
> >
> > Yes it is controlled entirely through xenstore: lib xl creates
> > frontend/backend entries with
> > initial states and configuration.
>
> And your display backend in "troops" (is that the name of your
> project) checks whether the backend type is set to "linux", so that it
> knows to ignore ones that say "qemu" ?
>
> Maybe "linux" should be "troops"...
>

It doesn't look as generic solution. If some user implements own backend
it should add new entry into backend type enum.
What about to have just string value instead of enum? In case QEMU
we don't have such entry at all but in case custom backend the user
can't put any string value here to be recognized by his backend.

> Ian.

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [XEN PATCH for-4.13 v1] Reset iomem's gfn to LIBXL_INVALID_GFN on reboot

2019-10-16 Thread Oleksandr Grytsov
On Mon, Oct 14, 2019 at 12:28 PM Julien Grall  wrote:
>
> Hi Ian,
>
> On 11/10/2019 16:14, Ian Jackson wrote:
> > Oleksandr Grytsov writes ("[PATCH v1] Reset iomem's gfn to 
> > LIBXL_INVALID_GFN on reboot"):
> >> During domain reboot its configuration is partially reused
> >> to re-create a new domain, but iomem's GFN field for the
> >> iomem is only restored for those memory ranges, which are
> >> configured in form of [IOMEM_START,NUM_PAGES[@GFN], but not for
> >> those in form of [IOMEM_START,NUM_PAGES], e.g. without GFN.
> >> For the latter GFN is reset to 0, but while mapping ranges
> >> to a domain during reboot there is a check that GFN treated
> >> as valid if it is not equal to LIBXL_INVALID_GFN, thus making
> >> Xen to map IOMEM_START to address 0 in the guest's address space.
> >>
> >> Workaround it by resseting GFN to LIBXL_INVALID_GFN, so xl
> >> can set proper values for mapping on reboot.
> >
> > Thanks for this patch.
> >
> > I confess that I am not sure what is going on here.  Where is this
> > troublesome 0 coming from ?  I see that the default value for gfn in
> > the struct is 0 and looking for assignments before this patch, gfn is
> > defaulted from b_info->iomem[i].start, which is presumably non-0.
> >
> > I suspect that your patch may be fixing this the wrong way.  I have
> > addressed this mail to various people who have touched this area of
> > code and hope they will be able to clarify.
>
> I found a thread from December 2017 related to the problem described here [1].
>
> Looking at the thread, there were no conclusion on the root causes and some
> questions were left unanswered by the contributor (see [2]).
>
> Oleksandr, could you look at the thread and see if you can provide more 
> details
> what's going on? Answering back here would be fine.
>
> >
> > BTW, please do ping this (and your other patches) by email, if the
> > conversation seems to stall.
> >
> > Thanks,
> > Ian.
> >
> >> Signed-off-by: Oleksandr Andrushchenko 
> >> ---
> >>   tools/libxl/libxl_domain.c | 9 +
> >>   1 file changed, 9 insertions(+)
> >>
> >> diff --git a/tools/libxl/libxl_domain.c b/tools/libxl/libxl_domain.c
> >> index 9d0eb5aed1..0ae16a5b12 100644
> >> --- a/tools/libxl/libxl_domain.c
> >> +++ b/tools/libxl/libxl_domain.c
> >> @@ -2120,6 +2120,15 @@ static void 
> >> retrieve_domain_configuration_end(libxl__egc *egc,
> >>   }
> >>   }
> >>
> >> +/* reset IOMEM's GFN to initial value */
> >> +{
> >> +int i;
> >> +
> >> +for (i = 0; i < d_config->b_info.num_iomem; i++)
> >> +if (d_config->b_info.iomem[i].gfn == 0)
> >> +d_config->b_info.iomem[i].gfn = LIBXL_INVALID_GFN;
> >> +}
> >> +
> >>   /* Devices: disk, nic, vtpm, pcidev etc. */
> >>
> >>   /* The MERGE macro implements following logic:
> >> --
> >> 2.17.1
> >>
>
> Cheers,
>
> [1] 
> [2] <20180213122432.h4fh22ej4dfe7...@citrix.com>
>
> --
> Julien Grall

Julien,

Thanks to point me out for this old thread. I completely forgot about it
(I haven't worked with xen since long time). I've performed additional
investigation
and found the root cause of the issue. It doesn't relate to iomem GFN directly.
The problem is in type from json parsing at place where libxl creates array of
struct.

For example, libxl_domain_config_from_json calls libxl_domain_config_init
which initializes all child structures and arrays. But then when libxl parses
json and creates the array of structure, it doesn't initialize array elements
properly (see libxl__domain_build_info_parse_json iomem parsing):

p->num_iomem = x->u.array->count;
p->iomem = libxl__calloc(NOGC, p->num_iomem, sizeof(*p->iomem));
if (!p->iomem && p->num_iomem != 0) {
rc = -1;
goto out;
}
for (i=0; (t=libxl__json_array_get(x,i)); i++) {
rc = libxl__iomem_range_parse_json(gc, t, >iomem[i]);
if (rc)
   goto out;
}

libxl creates array element with calloc function, so all element
fields are initialized
with zero values. Even some of them have default value different from zero.
For these purpose dedicated init function should be called for each element.
Above example should be:

for (i=0; (t=libxl__json_array_get(x,i)); i++) {
libxl_iomem_range_init(>iomem[i]);
rc = libxl__iomem_range_parse_json(gc, t, >iomem[i]);
if (rc)
   goto out;
}

I've changes gentypes.py as foll

Re: [Xen-devel] [PATCH v1 2/2] libxl: add removing XS backend path for PV devices on domain destroy

2019-10-16 Thread Oleksandr Grytsov
On Tue, Oct 15, 2019 at 6:39 PM Roger Pau Monné  wrote:
>
> On Fri, Oct 11, 2019 at 04:55:32PM +0100, Ian Jackson wrote:
> > Roger Pau Monne writes ("Re: [PATCH v1 2/2] libxl: add removing XS backend 
> > path for PV devices on domain destroy"):
> > > When this code was added (devd) those where the only backends handled
> > > by libxl. VDISPL, VSND, VINPUT didn't exist at that point, so I think
> > > the issue is that when support for those was added, it wasn't properly
> > > wired into devd.
> > >
> > > > I think:
> > > >
> > > > >  switch(ddev->dev->backend_kind) {
> > > > > +case LIBXL__DEVICE_KIND_VDISPL:
> > > > > +case LIBXL__DEVICE_KIND_VSND:
> > > > > +case LIBXL__DEVICE_KIND_VINPUT:
> > > > >  case LIBXL__DEVICE_KIND_VBD:
> > > > >  case LIBXL__DEVICE_KIND_VIF:
> > > >
> > > > If we do want this to handle *all* kinds of device, maybe it should
> > > > have a fallback that aborts, or something ?  (I don't think it is
> > > > easy to make it a compile error to forget to add an entry here but if
> > > > we could do that it would probably be best.)
> > >
> > > Maybe we could have some generic handling for everything != qdisk?
> >
> > So make that the "default:" ?  That would be fine by me.
>
> If possible yes, that would be my preference, and would prevent having
> to add new device types to this switch unless special handling is
> required.
>
> >
> > > IIRC qdisk needs special handling so that devd can launch and destroy
> > > a QEMU instance when required, but other backends that run in the
> > > kernel don't need such handling and could maybe share the same generic
> > > code path.
> >
> > Right.
> >
> > > > All of that assuming that the basic idea is right, which I would like
> > > > Roger's opinion about.
> > >
> > > Looking at the patch itself, you also seem to be doing some changes
> > > related to num_vbds and num_vifs, but those are not mentioned in the
> > > commit message, is that a stray change?
> >
> > No, I don't think so.  Those variables just tell us when the thing is
> > torn down but Oleksandr's code is able to use the devices slist itself
> > for that.  Please do check to see if you agree.
>
> Yes, that's fine. I don't think those changes are wrong, I just think
> that at least they should be mentioned in the commit message. Ie:
> "while there remove the num_vifs and num_vbds since they are not
> needed and the same can be achieved by checking that the device list
> is empty." or some such.
>
> Thanks, Roger.

Ian, Roger,

Thanks for reviewing and comments. I will update the patch with your
comments above.

-- 
Best Regards,
Oleksandr Grytsov.

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH v1 1/2] libxl: introduce new backend type VINPUT

2019-10-11 Thread Oleksandr Grytsov
On Fri, Oct 11, 2019 at 5:58 PM Ian Jackson  wrote:
>
> Oleksandr Grytsov writes ("[PATCH v1 1/2] libxl: introduce new backend type 
> VINPUT"):
> > From: Oleksandr Grytsov 
> >
> > There are two kind of VKBD devices: with QEMU backend and user space
> > backend. In current implementation they can't be distinguished as both use
> > VKBD backend type. As result, user space KBD backend is started and
> > stopped as QEMU backend. This commit adds new device kind VINPUT to be
> > used as backend type for user space KBD backend.
>
> I find this confusing.  I'm not sure this change is right.  But I'm
> afraid the original patches in this area passed me by so I don't know
> much about it.
>
> I think it was a48e00f14a2d "libxl: add backend type and id to vkb"
> which introduced what you are calling "user space" backends.  It
> appears that the vkb backend type enum was introduced there
> specifically to distinguish between these two situations.  For reasons
>
> Am I wrong ?  If not, why is this not working or not suitable ?

You are right. It is not working in some cases due to QEMU_BACKEND macro.
QEMU_BACKEND treats both backends as QEMU. As result xl performs device
hotplug on add/remove device. Which is not expected in case "user
space" backend.

In this patch I propose solution similar to VUSB device. Where VUSB
used for frontend
and depends on backend (kernel or QEMU) either VUSB or QUSB used for backend
device type e.g. use different backend device type for different
backends. It would be
more clear if, for example, QEMU backend has QKBD name and all other
VKBD. But it
would require changes on QEMU side too. That's why I've chosen VINPUT name.

Introducing new backend device type for VKBD also allows to have both backends
(QEMU and non QEMU) run in same domain. Not sure if it is useful
scenario but with
this proposal it is possible from technical point of view.

>
> I also don't understand why the "user space" kbd backend seems to be
> "linux" in the enum.

I agree this is not so good name. But I don't know how to call
backends which are not running
inside QEMU in general.

> Where is the implementation of this user space
> backend ?

We have extended kbd interface (kbdif.h) to support multi-touch events
as well. And we have
implemented own kbd backend https://github.com/xen-troops/displ_be/
It is integrated with display backend as both use wayland API.

> Is it be controlled entirely through xenstore ?

Yes it is controlled entirely through xenstore: lib xl creates
frontend/backend entries with
initial states and configuration.

> Ian.

-- 
Best Regards,
Oleksandr Grytsov.

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

[Xen-devel] [PATCH v1] libxl: Add DTB compatible list to config file

2019-10-10 Thread Oleksandr Grytsov
From: Oleksandr Grytsov 

Some platforms need more compatible property values in device
tree root node in addition to "xen,xenvm-%d.%d" and "xen,xenvm"
values that are given by Xen by default.
Specify in domain configuration file which values should be added
by providing "dtb_compatible" list of strings separated by comas.

Signed-off-by: Iurii Konovalenko 
Signed-off-by: Oleksandr Andrushchenko 
---
 tools/libxl/libxl_arm.c | 42 ++---
 tools/libxl/libxl_types.idl |  1 +
 tools/xl/xl_parse.c |  7 +++
 3 files changed, 42 insertions(+), 8 deletions(-)

diff --git a/tools/libxl/libxl_arm.c b/tools/libxl/libxl_arm.c
index bf31b9b3ca..b956a6356c 100644
--- a/tools/libxl/libxl_arm.c
+++ b/tools/libxl/libxl_arm.c
@@ -270,20 +270,46 @@ static int fdt_property_regs(libxl__gc *gc, void *fdt,
 
 static int make_root_properties(libxl__gc *gc,
 const libxl_version_info *vers,
-void *fdt)
+void *fdt,
+const libxl_domain_build_info *info)
 {
-int res;
+const char *compat0 = GCSPRINTF("xen,xenvm-%d.%d",
+vers->xen_version_major,
+vers->xen_version_minor);
+const char *compat1 = "xen,xenvm";
+const char **compats;
+char *compat, *p;
+size_t sz = 0;
+int i, res, num_compats;
 
 res = fdt_property_string(fdt, "model", GCSPRINTF("XENVM-%d.%d",
   vers->xen_version_major,
   
vers->xen_version_minor));
 if (res) return res;
 
-res = fdt_property_compat(gc, fdt, 2,
-  GCSPRINTF("xen,xenvm-%d.%d",
-vers->xen_version_major,
-vers->xen_version_minor),
-  "xen,xenvm");
+num_compats = 2 + libxl_string_list_length(>dt_compatible);
+compats = libxl__zalloc(gc, num_compats * sizeof(*compats));
+if (!compats)
+return -FDT_ERR_INTERNAL;
+
+compats[0] = compat0;
+compats[1] = compat1;
+sz = strlen(compat0) + strlen(compat1) + 2;
+for (i = 0; info->dt_compatible && info->dt_compatible[i] != NULL; i++) {
+compats[2 + i] = info->dt_compatible[i];
+sz += strlen(info->dt_compatible[i]) + 1;
+}
+
+p = compat = libxl__zalloc(gc, sz);
+if (!p)
+return -FDT_ERR_INTERNAL;
+
+for (i = 0; i < num_compats; i++) {
+strcpy(p, compats[i]);
+p += strlen(compats[i]) + 1;
+}
+
+res = fdt_property(fdt, "compatible", compat, sz);
 if (res) return res;
 
 res = fdt_property_cell(fdt, "interrupt-parent", GUEST_PHANDLE_GIC);
@@ -930,7 +956,7 @@ next_resize:
 
 FDT( fdt_begin_node(fdt, "") );
 
-FDT( make_root_properties(gc, vers, fdt) );
+FDT( make_root_properties(gc, vers, fdt, info) );
 FDT( make_chosen_node(gc, fdt, !!dom->modules[0].blob, state, info) );
 FDT( make_cpus_node(gc, fdt, info->max_vcpus, ainfo) );
 FDT( make_psci_node(gc, fdt) );
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index 3ac9494b80..08ffb65904 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -544,6 +544,7 @@ libxl_domain_build_info = Struct("domain_build_info",[
 # Note that the partial device tree should avoid to use the phandle
 # 65000 which is reserved by the toolstack.
 ("device_tree",  string),
+("dt_compatible",libxl_string_list),
 ("acpi", libxl_defbool),
 ("bootloader",   string),
 ("bootloader_args",  libxl_string_list),
diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c
index 03a2c54dd2..db9821c765 100644
--- a/tools/xl/xl_parse.c
+++ b/tools/xl/xl_parse.c
@@ -2408,6 +2408,13 @@ skip_vfb:
 }
 }
 
+e = xlu_cfg_get_list_as_string_list(config, "dt_compatible",
+_info->dt_compatible, 1);
+if (e && e != ESRCH) {
+fprintf(stderr,"xl: Unable to parse dt_compatible\n");
+exit(-ERROR_FAIL);
+}
+
 if (!xlu_cfg_get_list(config, "usbctrl", , 0, 0)) {
 d_config->num_usbctrls = 0;
 d_config->usbctrls = NULL;
-- 
2.17.1


___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

[Xen-devel] [PATCH v1] Reset iomem's gfn to LIBXL_INVALID_GFN on reboot

2019-10-10 Thread Oleksandr Grytsov
From: Oleksandr Andrushchenko 

During domain reboot its configuration is partially reused
to re-create a new domain, but iomem's GFN field for the
iomem is only restored for those memory ranges, which are
configured in form of [IOMEM_START,NUM_PAGES[@GFN], but not for
those in form of [IOMEM_START,NUM_PAGES], e.g. without GFN.
For the latter GFN is reset to 0, but while mapping ranges
to a domain during reboot there is a check that GFN treated
as valid if it is not equal to LIBXL_INVALID_GFN, thus making
Xen to map IOMEM_START to address 0 in the guest's address space.

Workaround it by resseting GFN to LIBXL_INVALID_GFN, so xl
can set proper values for mapping on reboot.

Signed-off-by: Oleksandr Andrushchenko 
---
 tools/libxl/libxl_domain.c | 9 +
 1 file changed, 9 insertions(+)

diff --git a/tools/libxl/libxl_domain.c b/tools/libxl/libxl_domain.c
index 9d0eb5aed1..0ae16a5b12 100644
--- a/tools/libxl/libxl_domain.c
+++ b/tools/libxl/libxl_domain.c
@@ -2120,6 +2120,15 @@ static void retrieve_domain_configuration_end(libxl__egc 
*egc,
 }
 }
 
+/* reset IOMEM's GFN to initial value */
+{
+int i;
+
+for (i = 0; i < d_config->b_info.num_iomem; i++)
+if (d_config->b_info.iomem[i].gfn == 0)
+d_config->b_info.iomem[i].gfn = LIBXL_INVALID_GFN;
+}
+
 /* Devices: disk, nic, vtpm, pcidev etc. */
 
 /* The MERGE macro implements following logic:
-- 
2.17.1


___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

[Xen-devel] [PATCH v1 2/2] libxl: add removing XS backend path for PV devices on domain destroy

2019-10-08 Thread Oleksandr Grytsov
From: Oleksandr Grytsov 

Currently backend path is remove for specific devices: VBD, VIF, QDISK.
This commit adds removing backend path for: VDISPL, VSND, VINPUT.

Signed-off-by: Oleksandr Grytsov 
---
 tools/libxl/libxl_device.c | 14 +-
 1 file changed, 5 insertions(+), 9 deletions(-)

diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c
index 1402b61a81..8ce70661e5 100644
--- a/tools/libxl/libxl_device.c
+++ b/tools/libxl/libxl_device.c
@@ -1477,7 +1477,7 @@ typedef struct libxl__ddomain_device {
  */
 typedef struct libxl__ddomain_guest {
 uint32_t domid;
-int num_vifs, num_vbds, num_qdisks;
+int num_qdisks;
 LIBXL_SLIST_HEAD(, struct libxl__ddomain_device) devices;
 LIBXL_SLIST_ENTRY(struct libxl__ddomain_guest) next;
 } libxl__ddomain_guest;
@@ -1530,8 +1530,7 @@ static void check_and_maybe_remove_guest(libxl__gc *gc,
 {
 assert(ddomain);
 
-if (dguest != NULL &&
-dguest->num_vifs + dguest->num_vbds + dguest->num_qdisks == 0) {
+if (dguest != NULL && LIBXL_SLIST_FIRST(>devices) == NULL) {
 LIBXL_SLIST_REMOVE(>guests, dguest, libxl__ddomain_guest,
next);
 LOGD(DEBUG, dguest->domid, "Removed domain from the list of active 
guests");
@@ -1573,9 +1572,6 @@ static int add_device(libxl__egc *egc, libxl__ao *ao,
 switch(dev->backend_kind) {
 case LIBXL__DEVICE_KIND_VBD:
 case LIBXL__DEVICE_KIND_VIF:
-if (dev->backend_kind == LIBXL__DEVICE_KIND_VBD) dguest->num_vbds++;
-if (dev->backend_kind == LIBXL__DEVICE_KIND_VIF) dguest->num_vifs++;
-
 GCNEW(aodev);
 libxl__prepare_ao_device(ao, aodev);
 /*
@@ -1619,11 +1615,11 @@ static int remove_device(libxl__egc *egc, libxl__ao *ao,
 int rc = 0;
 
 switch(ddev->dev->backend_kind) {
+case LIBXL__DEVICE_KIND_VDISPL:
+case LIBXL__DEVICE_KIND_VSND:
+case LIBXL__DEVICE_KIND_VINPUT:
 case LIBXL__DEVICE_KIND_VBD:
 case LIBXL__DEVICE_KIND_VIF:
-if (dev->backend_kind == LIBXL__DEVICE_KIND_VBD) dguest->num_vbds--;
-if (dev->backend_kind == LIBXL__DEVICE_KIND_VIF) dguest->num_vifs--;
-
 GCNEW(aodev);
 libxl__prepare_ao_device(ao, aodev);
 /*
-- 
2.17.1


___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

[Xen-devel] [PATCH v1 1/2] libxl: introduce new backend type VINPUT

2019-10-08 Thread Oleksandr Grytsov
From: Oleksandr Grytsov 

There are two kind of VKBD devices: with QEMU backend and user space
backend. In current implementation they can't be distinguished as both use
VKBD backend type. As result, user space KBD backend is started and
stopped as QEMU backend. This commit adds new device kind VINPUT to be
used as backend type for user space KBD backend.

Signed-off-by: Oleksandr Grytsov 
---
 tools/libxl/libxl_types_internal.idl |  1 +
 tools/libxl/libxl_vkb.c  | 29 ++--
 2 files changed, 20 insertions(+), 10 deletions(-)

diff --git a/tools/libxl/libxl_types_internal.idl 
b/tools/libxl/libxl_types_internal.idl
index cb85c3b37f..3593e21dbb 100644
--- a/tools/libxl/libxl_types_internal.idl
+++ b/tools/libxl/libxl_types_internal.idl
@@ -31,6 +31,7 @@ libxl__device_kind = Enumeration("device_kind", [
 (13, "VUART"),
 (14, "PVCALLS"),
 (15, "VSND"),
+(16, "VINPUT"),
 ])
 
 libxl__console_backend = Enumeration("console_backend", [
diff --git a/tools/libxl/libxl_vkb.c b/tools/libxl/libxl_vkb.c
index 26376a7eef..4c44a813c1 100644
--- a/tools/libxl/libxl_vkb.c
+++ b/tools/libxl/libxl_vkb.c
@@ -38,9 +38,6 @@ static int libxl__set_xenstore_vkb(libxl__gc *gc, uint32_t 
domid,
flexarray_t *back, flexarray_t *front,
flexarray_t *ro_front)
 {
-flexarray_append_pair(back, "backend-type",
-  (char 
*)libxl_vkb_backend_to_string(vkb->backend_type));
-
 if (vkb->unique_id) {
 flexarray_append_pair(back, XENKBD_FIELD_UNIQUE_ID, vkb->unique_id);
 }
@@ -93,7 +90,8 @@ static int libxl__vkb_from_xenstore(libxl__gc *gc, const char 
*libxl_path,
 libxl_devid devid,
 libxl_device_vkb *vkb)
 {
-const char *be_path, *be_type, *fe_path, *tmp;
+const char *be_path, *fe_path, *tmp;
+libxl__device dev;
 int rc;
 
 vkb->devid = devid;
@@ -111,13 +109,11 @@ static int libxl__vkb_from_xenstore(libxl__gc *gc, const 
char *libxl_path,
 rc = libxl__backendpath_parse_domid(gc, be_path, >backend_domid);
 if (rc) goto out;
 
-rc = libxl__xs_read_mandatory(gc, XBT_NULL,
-  GCSPRINTF("%s/backend-type", be_path),
-  _type);
+rc = libxl__parse_backend_path(gc, be_path, );
 if (rc) goto out;
 
-rc = libxl_vkb_backend_from_string(be_type, >backend_type);
-if (rc) goto out;
+vkb->backend_type = dev.backend_kind == LIBXL__DEVICE_KIND_VINPUT ?
+LIBXL_VKB_BACKEND_LINUX : 
LIBXL_VKB_BACKEND_QEMU;
 
 vkb->unique_id = xs_read(CTX->xsh, XBT_NULL, 
GCSPRINTF("%s/"XENKBD_FIELD_UNIQUE_ID, be_path), NULL);
 
@@ -218,6 +214,20 @@ out:
 return rc;
 }
 
+static int libxl__device_from_vkb(libxl__gc *gc, uint32_t domid,
+  libxl_device_vkb *type, libxl__device 
*device)
+{
+device->backend_devid   = type->devid;
+device->backend_domid   = type->backend_domid;
+device->backend_kind= type->backend_type == LIBXL_VKB_BACKEND_LINUX ?
+  LIBXL__DEVICE_KIND_VINPUT : 
LIBXL__DEVICE_KIND_VKBD;
+device->devid   = type->devid;
+device->domid   = domid;
+device->kind= LIBXL__DEVICE_KIND_VKBD;
+
+return 0;
+}
+
 int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb,
  const libxl_asyncop_how *ao_how)
 {
@@ -318,7 +328,6 @@ out:
  return rc;
 }
 
-static LIBXL_DEFINE_DEVICE_FROM_TYPE(vkb)
 static LIBXL_DEFINE_UPDATE_DEVID(vkb)
 
 #define libxl__add_vkbs NULL
-- 
2.17.1


___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

[Xen-devel] [PATCH v1 0/2] Remove backend xen store entry on domain destroy

2019-10-08 Thread Oleksandr Grytsov
From: Oleksandr Grytsov 

We have added VKBD device with user space PV backend. But libxl can't
differentiate domain kind for this device. As result, it performs QEMU procedure
for adding and removing VKB device with user space backend. To fix this issue,
new device kind VINPUT is introduced. It is used as backend kind in case of
user space VKBD backend. 

Another issue addresses in this patch series is error timeout on guest domain
destroy in case using user space PV backends.

We have a driver domain with user space backends (VDISPL, VSND, VKBD). When a
guest domain destroyed, we see following error:

"timed out while waiting for ... to be removed"

xl expects that PV device backend entries is removed. xl devd removes these
entries for specific devices only: VBD, VIF, QDISK and then deletes the guest
domain from the list. The fix is to delete guest domain only after all devices
are removed and performs generic device remove procedure for following device:
VINPUT, VDISPL, VSND.

Oleksandr Grytsov (2):
  libxl: introduce new backend type VINPUT
  libxl: add removing XS backend path for PV devices on domain destroy

 tools/libxl/libxl_device.c   | 14 +-
 tools/libxl/libxl_types_internal.idl |  1 +
 tools/libxl/libxl_vkb.c  | 29 ++--
 3 files changed, 25 insertions(+), 19 deletions(-)

-- 
2.17.1


___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH] libxl: add libxl__is_driver_domain function

2019-10-02 Thread Oleksandr Grytsov
On Mon, Feb 26, 2018 at 12:14 PM Oleksandr Grytsov  wrote:
>
> On Fri, Feb 23, 2018 at 7:44 PM, Wei Liu  wrote:
>>
>> On Tue, Feb 13, 2018 at 03:32:04PM +0200, Oleksandr Grytsov wrote:
>> > On Tue, Feb 13, 2018 at 2:06 PM, Wei Liu  wrote:
>> >
>> > > On Tue, Feb 06, 2018 at 03:08:45PM +0200, Oleksandr Grytsov wrote:
>> > > > On Tue, Feb 6, 2018 at 2:36 PM, Wei Liu  wrote:
>> > > >
>> > > > > On Thu, Dec 14, 2017 at 04:14:12PM +0200, Oleksandr Grytsov wrote:
>> > > > > > From: Oleksandr Grytsov 
>> > > > > >
>> > > > > > We have following arm-based setup:
>> > > > > >
>> > > > > > - Dom0 with xen and xen tools;
>> > > > > > - Dom1 with device backends (but it is not the driver domain);
>> > > > >
>> > > > > What is your definition of a "driver domain"? What does it do in this
>> > > > > case?
>> > > > >
>> > > > > I seem to have seen people use this term in different contexts to 
>> > > > > mean
>> > > > > slightly different things. I need to figure out what you actually 
>> > > > > mean
>> > > > > first.
>> > > > >
>> > > > >
>> > > > I see in the libxl/xl sources that closing PV devices is done 
>> > > > differently
>> > > > in case backends are in Dom0 and are in other domain. It is called as
>> > > > driver domain in the sources. So, I don't have clear understanding
>> > > > what does it mean. In our setup backends are in Dom1 and xl is in Dom0.
>> > > > And I see that xl dosn't close PV device on domain reboot or shutdown.
>> > >
>> > > Do you run xl devd in your backend domain?
>> > >
>> > > Wei.
>> > >
>> >
>> > No I don't
>>
>> Can you try that? I think xl devd should clean up the stale entries --
>> that's how we envisage driver domains to be used.
>>
>> Wei.
>
>
> We will check this. Thanks.
>
> --
> Best Regards,
> Oleksandr Grytsov.


Let me renew this topic.

xl devd cleans up the state entries only for specific devices: VBD, VIF, QDISK.
I wonder, shall xl devd perform cleaning for all other backends in
driver domain as well?


-- 
Best Regards,
Oleksandr Grytsov.

___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

[Xen-devel] [PATCH v3 2/7] libxl: add backend type and id to vkb

2018-07-17 Thread Oleksandr Grytsov
From: Oleksandr Grytsov 

New field backend_type is added to vkb device in order to have QEMU and user
space backend simultaneously. Each vkb backend shall read appropriate XS entry
and service only own frontends. Id is a string field which used by the backend
to indentify the frontend.

Signed-off-by: Oleksandr Grytsov 
---
 tools/libxl/libxl_create.c  |  3 +++
 tools/libxl/libxl_dm.c  |  1 +
 tools/libxl/libxl_types.idl |  8 
 tools/libxl/libxl_vkb.c | 31 ++-
 4 files changed, 42 insertions(+), 1 deletion(-)

diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index 7d46824eac..1ccb3e35d3 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -1421,6 +1421,9 @@ static void domcreate_launch_dm(libxl__egc *egc, 
libxl__multidev *multidev,
 for (i = 0; i < d_config->num_vfbs; i++) {
 libxl__device_add(gc, domid, __vfb_devtype,
   _config->vfbs[i]);
+}
+
+for (i = 0; i < d_config->num_vkbs; i++) {
 libxl__device_add(gc, domid, __vkb_devtype,
   _config->vkbs[i]);
 }
diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index bd187463ec..fdd7fa3ba4 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -1790,6 +1790,7 @@ static int 
libxl__vfb_and_vkb_from_hvm_guest_config(libxl__gc *gc,
 
 vkb->backend_domid = 0;
 vkb->devid = 0;
+
 return 0;
 }
 
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index f1e50a0c0c..c01cf06035 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -247,6 +247,12 @@ libxl_vuart_type = Enumeration("vuart_type", [
 (1, "sbsa_uart"),
 ])
 
+libxl_vkb_backend = Enumeration("vkb_backend", [
+(0, "UNKNOWN"),
+(1, "QEMU"),
+(2, "LINUX")
+])
+
 #
 # Complex libxl types
 #
@@ -626,6 +632,8 @@ libxl_device_vkb = Struct("device_vkb", [
 ("backend_domid", libxl_domid),
 ("backend_domname", string),
 ("devid", libxl_devid),
+("backend_type", libxl_vkb_backend),
+("unique_id", string)
 ])
 
 libxl_device_disk = Struct("device_disk", [
diff --git a/tools/libxl/libxl_vkb.c b/tools/libxl/libxl_vkb.c
index 7652ad23ce..e271edc23f 100644
--- a/tools/libxl/libxl_vkb.c
+++ b/tools/libxl/libxl_vkb.c
@@ -14,12 +14,38 @@
 
 #include "libxl_internal.h"
 
+#include 
+
 static int libxl__device_vkb_setdefault(libxl__gc *gc, uint32_t domid,
 libxl_device_vkb *vkb, bool hotplug)
 {
+if (vkb->backend_type == LIBXL_VKB_BACKEND_UNKNOWN) {
+vkb->backend_type = LIBXL_VKB_BACKEND_QEMU;
+}
+
 return libxl__resolve_domid(gc, vkb->backend_domname, >backend_domid);
 }
 
+static int libxl__device_vkb_dm_needed(libxl_device_vkb *vkb, uint32_t domid)
+{
+return vkb->backend_type == LIBXL_VKB_BACKEND_QEMU;
+}
+
+static int libxl__set_xenstore_vkb(libxl__gc *gc, uint32_t domid,
+   libxl_device_vkb *vkb,
+   flexarray_t *back, flexarray_t *front,
+   flexarray_t *ro_front)
+{
+flexarray_append_pair(back, "backend-type",
+  (char 
*)libxl_vkb_backend_to_string(vkb->backend_type));
+
+if (vkb->unique_id) {
+flexarray_append_pair(back, XENKBD_FIELD_UNIQUE_ID, vkb->unique_id);
+}
+
+return 0;
+}
+
 int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb,
  const libxl_asyncop_how *ao_how)
 {
@@ -47,7 +73,10 @@ static LIBXL_DEFINE_UPDATE_DEVID(vkb)
 LIBXL_DEFINE_DEVICE_REMOVE(vkb)
 
 DEFINE_DEVICE_TYPE_STRUCT(vkb, VKBD,
-.skip_attach = 1
+.skip_attach = 1,
+.dm_needed = (device_dm_needed_fn_t)libxl__device_vkb_dm_needed,
+.set_xenstore_config = (device_set_xenstore_config_fn_t)
+   libxl__set_xenstore_vkb
 );
 
 /*
-- 
2.17.1


___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

[Xen-devel] [PATCH v3 1/7] libxl: move vkb device to libxl_vkb.c

2018-07-17 Thread Oleksandr Grytsov
From: Oleksandr Grytsov 

Logically it is better to move vkb to separate file as vkb device used not only
by vfb and console.

Signed-off-by: Oleksandr Grytsov 
Acked-by: Wei Liu 
---
 tools/libxl/Makefile|  2 +-
 tools/libxl/libxl_console.c | 53 -
 tools/libxl/libxl_vkb.c | 59 +
 3 files changed, 60 insertions(+), 54 deletions(-)
 create mode 100644 tools/libxl/libxl_vkb.c

diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile
index 684db995ca..6da342ed61 100644
--- a/tools/libxl/Makefile
+++ b/tools/libxl/Makefile
@@ -140,7 +140,7 @@ LIBXL_OBJS = flexarray.o libxl.o libxl_create.o libxl_dm.o 
libxl_pci.o \
libxl_vtpm.o libxl_nic.o libxl_disk.o libxl_console.o \
libxl_cpupool.o libxl_mem.o libxl_sched.o libxl_tmem.o \
libxl_9pfs.o libxl_domain.o libxl_vdispl.o \
-   libxl_pvcalls.o libxl_vsnd.o $(LIBXL_OBJS-y)
+   libxl_pvcalls.o libxl_vsnd.o libxl_vkb.o $(LIBXL_OBJS-y)
 LIBXL_OBJS += libxl_genid.o
 LIBXL_OBJS += _libxl_types.o libxl_flask.o _libxl_types_internal.o
 
diff --git a/tools/libxl/libxl_console.c b/tools/libxl/libxl_console.c
index 9a02a23c2a..36d79f5adc 100644
--- a/tools/libxl/libxl_console.c
+++ b/tools/libxl/libxl_console.c
@@ -638,45 +638,6 @@ int libxl_device_channel_getinfo(libxl_ctx *ctx, uint32_t 
domid,
 return rc;
 }
 
-static int libxl__device_vkb_setdefault(libxl__gc *gc, uint32_t domid,
-libxl_device_vkb *vkb, bool hotplug)
-{
-return libxl__resolve_domid(gc, vkb->backend_domname, >backend_domid);
-}
-
-static int libxl__device_from_vkb(libxl__gc *gc, uint32_t domid,
-  libxl_device_vkb *vkb,
-  libxl__device *device)
-{
-device->backend_devid = vkb->devid;
-device->backend_domid = vkb->backend_domid;
-device->backend_kind = LIBXL__DEVICE_KIND_VKBD;
-device->devid = vkb->devid;
-device->domid = domid;
-device->kind = LIBXL__DEVICE_KIND_VKBD;
-
-return 0;
-}
-
-int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb,
- const libxl_asyncop_how *ao_how)
-{
-AO_CREATE(ctx, domid, ao_how);
-int rc;
-
-rc = libxl__device_add(gc, domid, __vkb_devtype, vkb);
-if (rc) {
-LOGD(ERROR, domid, "Unable to add vkb device");
-goto out;
-}
-
-out:
-libxl__ao_complete(egc, ao, rc);
-return AO_INPROGRESS;
-}
-
-static LIBXL_DEFINE_UPDATE_DEVID(vkb)
-
 static int libxl__device_vfb_setdefault(libxl__gc *gc, uint32_t domid,
 libxl_device_vfb *vfb, bool hotplug)
 {
@@ -746,8 +707,6 @@ static int libxl__set_xenstore_vfb(libxl__gc *gc, uint32_t 
domid,
 }
 
 /* The following functions are defined:
- * libxl_device_vkb_remove
- * libxl_device_vkb_destroy
  * libxl_device_vfb_remove
  * libxl_device_vfb_destroy
  */
@@ -756,18 +715,6 @@ static int libxl__set_xenstore_vfb(libxl__gc *gc, uint32_t 
domid,
  * 1. add support for secondary consoles to xenconsoled
  * 2. dynamically add/remove qemu chardevs via qmp messages. */
 
-/* vkb */
-
-#define libxl__add_vkbs NULL
-#define libxl_device_vkb_list NULL
-#define libxl_device_vkb_compare NULL
-
-LIBXL_DEFINE_DEVICE_REMOVE(vkb)
-
-DEFINE_DEVICE_TYPE_STRUCT(vkb, VKBD,
-.skip_attach = 1
-);
-
 #define libxl__add_vfbs NULL
 #define libxl_device_vfb_list NULL
 #define libxl_device_vfb_compare NULL
diff --git a/tools/libxl/libxl_vkb.c b/tools/libxl/libxl_vkb.c
new file mode 100644
index 00..7652ad23ce
--- /dev/null
+++ b/tools/libxl/libxl_vkb.c
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2016 EPAM Systems Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ */
+
+#include "libxl_internal.h"
+
+static int libxl__device_vkb_setdefault(libxl__gc *gc, uint32_t domid,
+libxl_device_vkb *vkb, bool hotplug)
+{
+return libxl__resolve_domid(gc, vkb->backend_domname, >backend_domid);
+}
+
+int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb,
+ const libxl_asyncop_how *ao_how)
+{
+AO_CREATE(ctx, domid, ao_how);
+int rc;
+
+rc = libxl__device_add(gc, domid, __vkb_devtype, vkb);
+if (rc) {
+LOGD(ERROR, domid, "Unable to add vkb device");

[Xen-devel] [PATCH v3 3/7] libxl: vkb add list and info functions

2018-07-17 Thread Oleksandr Grytsov
From: Oleksandr Grytsov 

Signed-off-by: Oleksandr Grytsov 
Acked-by: Wei Liu 
---
 tools/libxl/libxl.h |  10 +++
 tools/libxl/libxl_types.idl |  11 
 tools/libxl/libxl_utils.h   |   3 +
 tools/libxl/libxl_vkb.c | 127 +++-
 4 files changed, 149 insertions(+), 2 deletions(-)

diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index bfc788594c..919f660c51 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -2037,6 +2037,16 @@ int libxl_device_vkb_destroy(libxl_ctx *ctx, uint32_t 
domid,
  const libxl_asyncop_how *ao_how)
 LIBXL_EXTERNAL_CALLERS_ONLY;
 
+libxl_device_vkb *libxl_device_vkb_list(libxl_ctx *ctx,
+uint32_t domid, int *num)
+LIBXL_EXTERNAL_CALLERS_ONLY;
+void libxl_device_vkb_list_free(libxl_device_vkb* list, int num)
+LIBXL_EXTERNAL_CALLERS_ONLY;
+int libxl_device_vkb_getinfo(libxl_ctx *ctx, uint32_t domid,
+ libxl_device_vkb *vkb,
+ libxl_vkbinfo *vkbinfo)
+ LIBXL_EXTERNAL_CALLERS_ONLY;
+
 /* Framebuffer */
 int libxl_device_vfb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb *vfb,
  const libxl_asyncop_how *ao_how)
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index c01cf06035..4b4dc9eb5d 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -1046,6 +1046,17 @@ libxl_vsndinfo = Struct("vsndinfo", [
 ("pcms", Array(libxl_pcminfo, "num_vsnd_pcms"))
 ])
 
+libxl_vkbinfo = Struct("vkbinfo", [
+("backend", string),
+("backend_id", uint32),
+("frontend", string),
+("frontend_id", uint32),
+("devid", libxl_devid),
+("state", integer),
+("evtch", integer),
+("rref", integer)
+], dir=DIR_OUT)
+
 # NUMA node characteristics: size and free are how much memory it has, and how
 # much of it is free, respectively. dists is an array of distances from this
 # node to each other node.
diff --git a/tools/libxl/libxl_utils.h b/tools/libxl/libxl_utils.h
index 5455752c6e..44409afdc4 100644
--- a/tools/libxl/libxl_utils.h
+++ b/tools/libxl/libxl_utils.h
@@ -79,6 +79,9 @@ int libxl_devid_to_device_vtpm(libxl_ctx *ctx, uint32_t domid,
 int libxl_devid_to_device_usbctrl(libxl_ctx *ctx, uint32_t domid,
   int devid, libxl_device_usbctrl *usbctrl);
 
+int libxl_devid_to_device_vkb(libxl_ctx *ctx, uint32_t domid,
+  int devid, libxl_device_vkb *vkb);
+
 int libxl_devid_to_device_vdispl(libxl_ctx *ctx, uint32_t domid,
  int devid, libxl_device_vdispl *vdispl);
 
diff --git a/tools/libxl/libxl_vkb.c b/tools/libxl/libxl_vkb.c
index e271edc23f..1262dbc7bd 100644
--- a/tools/libxl/libxl_vkb.c
+++ b/tools/libxl/libxl_vkb.c
@@ -46,6 +46,45 @@ static int libxl__set_xenstore_vkb(libxl__gc *gc, uint32_t 
domid,
 return 0;
 }
 
+static int libxl__vkb_from_xenstore(libxl__gc *gc, const char *libxl_path,
+libxl_devid devid,
+libxl_device_vkb *vkb)
+{
+const char *be_path, *be_type, *fe_path;
+int rc;
+
+vkb->devid = devid;
+
+rc = libxl__xs_read_mandatory(gc, XBT_NULL,
+  GCSPRINTF("%s/backend", libxl_path),
+  _path);
+if (rc) goto out;
+
+rc = libxl__xs_read_mandatory(gc, XBT_NULL,
+  GCSPRINTF("%s/frontend", libxl_path),
+  _path);
+if (rc) goto out;
+
+rc = libxl__backendpath_parse_domid(gc, be_path, >backend_domid);
+if (rc) goto out;
+
+rc = libxl__xs_read_mandatory(gc, XBT_NULL,
+  GCSPRINTF("%s/backend-type", be_path),
+  _type);
+if (rc) goto out;
+
+rc = libxl_vkb_backend_from_string(be_type, >backend_type);
+if (rc) goto out;
+
+vkb->unique_id = xs_read(CTX->xsh, XBT_NULL, 
GCSPRINTF("%s/"XENKBD_FIELD_UNIQUE_ID, be_path), NULL);
+
+rc = 0;
+
+out:
+
+return rc;
+}
+
 int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb,
  const libxl_asyncop_how *ao_how)
 {
@@ -63,20 +102,104 @@ out:
 return AO_INPROGRESS;
 }
 
+int libxl_devid_to_device_vkb(libxl_ctx *ctx, uint32_t domid,
+  int devid, libxl_device_vkb *vkb)
+{
+GC_INIT(ctx);
+
+libxl_device_vkb *vkbs = NULL;
+int n, i;
+int rc;
+
+libxl_device_vkb_init(vkb);
+
+vkbs = libxl__device_list(gc, __vkb_devtype, domid, );
+
+if (!vkbs) { 

[Xen-devel] [PATCH v3 5/7] docs: add vkb device to xl.cfg and xl

2018-07-17 Thread Oleksandr Grytsov
From: Oleksandr Grytsov 

Signed-off-by: Oleksandr Grytsov 
Acked-by: Wei Liu 
---
 docs/man/xl.cfg.pod.5.in | 24 
 docs/man/xl.pod.1.in | 22 ++
 2 files changed, 46 insertions(+)

diff --git a/docs/man/xl.cfg.pod.5.in b/docs/man/xl.cfg.pod.5.in
index 099a28dc7a..cc98b6003f 100644
--- a/docs/man/xl.cfg.pod.5.in
+++ b/docs/man/xl.cfg.pod.5.in
@@ -1563,6 +1563,30 @@ I
 ]
 ]
 
+=item B
+
+Specifies the virtual keyboard device to be provided to the guest.
+
+Each B is a comma-separated list of C
+settings from the following list:
+
+=over 4
+
+=item B
+
+Specifies the unique input device id.
+
+=item B
+
+Specifies the backend domain name or id.
+
+=item B
+
+Specifies the backend type: qemu - for QEMU backend or linux - for Linux PV
+domain.
+
+=back
+
 =back
 
 =head2 Paravirtualised (PV) Guest Specific Options
diff --git a/docs/man/xl.pod.1.in b/docs/man/xl.pod.1.in
index 90423bf3df..b74764dcd3 100644
--- a/docs/man/xl.pod.1.in
+++ b/docs/man/xl.pod.1.in
@@ -1522,6 +1522,28 @@ List vsnd devices for a domain.
 
 =back
 
+=head2 KEYBOARD DEVICES
+
+=over 4
+
+=item B I I
+
+Creates a new keyboard device in the domain specified by I.
+I describes the device to attach, using the same format as the
+B string in the domain config file. See L
+for more informations.
+
+=item B I I
+
+Removes the keyboard device from the domain specified by I.
+I is the virtual interface device number within the domain
+
+=item B I
+
+List virtual network interfaces for a domain.
+
+=back
+
 =head1 PCI PASS-THROUGH
 
 =over 4
-- 
2.17.1


___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

[Xen-devel] [PATCH v3 7/7] libxl: add LIBXL_HAVE_EXTENDED_VKB define

2018-07-17 Thread Oleksandr Grytsov
From: Oleksandr Grytsov 

LIBXL_HAVE_EXTENDED_VKB define indicates that libxl_device_vkb structure has
extended fields.

Signed-off-by: Oleksandr Grytsov 
---
 tools/libxl/libxl.h | 16 
 1 file changed, 16 insertions(+)

diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index 919f660c51..ae2d63df0c 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -354,6 +354,22 @@
 #define LIBXL_HAVE_BUILDINFO_BOOTLOADER 1
 #define LIBXL_HAVE_BUILDINFO_BOOTLOADER_ARGS 1
 
+/*
+ * LIBXL_HAVE_EXTENDED_VKB indicates that libxl_device_vkb has extended fields:
+ *  - unique_id;
+ *  - feature_disable_keyboard;
+ *  - feature_disable_pointer;
+ *  - feature_abs_pointer;
+ *  - feature_raw_pointer;
+ *  - feature_multi_touch;
+ *  - width;
+ *  - height;
+ *  - multi_touch_width;
+ *  - multi_touch_height;
+ *  - multi_touch_num_contacts.
+ */
+#define LIBXL_HAVE_EXTENDED_VKB 1
+
 /*
  * libxl ABI compatibility
  *
-- 
2.17.1


___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

[Xen-devel] [PATCH v3 6/7] libxl: vkb add extended parameters

2018-07-17 Thread Oleksandr Grytsov
From: Oleksandr Grytsov 

Add parsing and adding to xen store following extended parameters:
* feature-disable-keyboard
* feature-disable-pointer
* feature-abs-pointer
* feature-multi-touch
* feature-raw-pointer
* width
* height
* multi-touch-width
* multi-touch-height
* multi-touch-num-contacts

Signed-off-by: Oleksandr Grytsov 
Acked-by: Wei Liu 
---
 docs/man/xl.cfg.pod.5.in|  40 +++
 tools/libxl/libxl_types.idl |  12 +++-
 tools/libxl/libxl_vkb.c | 133 +++-
 tools/xl/xl_parse.c |  35 +-
 tools/xl/xl_vkb.c   |  14 
 5 files changed, 231 insertions(+), 3 deletions(-)

diff --git a/docs/man/xl.cfg.pod.5.in b/docs/man/xl.cfg.pod.5.in
index cc98b6003f..b72718151b 100644
--- a/docs/man/xl.cfg.pod.5.in
+++ b/docs/man/xl.cfg.pod.5.in
@@ -1585,6 +1585,46 @@ Specifies the backend domain name or id.
 Specifies the backend type: qemu - for QEMU backend or linux - for Linux PV
 domain.
 
+=item B
+
+Indicates if keyboard device is disabled.
+
+=item B
+
+Indicates if pointer device is disabled.
+
+=item B
+
+Indicates if pointer device can return absolute coordinates.
+
+=item B
+
+Indicates if pointer device can return raw (unscaled) absolute coordinates.
+
+=item B
+
+Indicates if input device supports multi touch.
+
+=item B
+
+Set maximum width for multi touch device.
+
+=item B
+
+Set maximum height for multi touch device.
+
+=item B
+
+Set maximum contacts number for multi touch device.
+
+=item B
+
+Set maximum width for pointer device.
+
+=item B
+
+Set maximum height for pointer device.
+
 =back
 
 =back
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index 4b4dc9eb5d..4a385801ba 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -633,7 +633,17 @@ libxl_device_vkb = Struct("device_vkb", [
 ("backend_domname", string),
 ("devid", libxl_devid),
 ("backend_type", libxl_vkb_backend),
-("unique_id", string)
+("unique_id", string),
+("feature_disable_keyboard", bool),
+("feature_disable_pointer", bool),
+("feature_abs_pointer", bool),
+("feature_raw_pointer", bool),
+("feature_multi_touch", bool),
+("width", uint32),
+("height", uint32),
+("multi_touch_width", uint32),
+("multi_touch_height", uint32),
+("multi_touch_num_contacts", uint32)
 ])
 
 libxl_device_disk = Struct("device_disk", [
diff --git a/tools/libxl/libxl_vkb.c b/tools/libxl/libxl_vkb.c
index 1262dbc7bd..e928839cfb 100644
--- a/tools/libxl/libxl_vkb.c
+++ b/tools/libxl/libxl_vkb.c
@@ -43,6 +43,47 @@ static int libxl__set_xenstore_vkb(libxl__gc *gc, uint32_t 
domid,
 flexarray_append_pair(back, XENKBD_FIELD_UNIQUE_ID, vkb->unique_id);
 }
 
+if (vkb->feature_disable_keyboard) {
+flexarray_append_pair(back, XENKBD_FIELD_FEAT_DSBL_KEYBRD,
+  GCSPRINTF("%u", vkb->feature_disable_keyboard));
+}
+
+if (vkb->feature_disable_pointer) {
+flexarray_append_pair(back, XENKBD_FIELD_FEAT_DSBL_POINTER,
+  GCSPRINTF("%u", vkb->feature_disable_pointer));
+}
+
+if (vkb->feature_abs_pointer) {
+flexarray_append_pair(back, XENKBD_FIELD_FEAT_ABS_POINTER,
+  GCSPRINTF("%u", vkb->feature_abs_pointer));
+}
+
+if (vkb->feature_raw_pointer) {
+flexarray_append_pair(back, XENKBD_FIELD_FEAT_RAW_POINTER,
+  GCSPRINTF("%u", vkb->feature_raw_pointer));
+}
+
+if (vkb->feature_multi_touch) {
+flexarray_append_pair(back, XENKBD_FIELD_FEAT_MTOUCH,
+  GCSPRINTF("%u", vkb->feature_multi_touch));
+flexarray_append_pair(back, XENKBD_FIELD_MT_WIDTH,
+  GCSPRINTF("%u", vkb->multi_touch_width));
+flexarray_append_pair(back, XENKBD_FIELD_MT_HEIGHT,
+  GCSPRINTF("%u", vkb->multi_touch_height));
+flexarray_append_pair(back, XENKBD_FIELD_MT_NUM_CONTACTS,
+  GCSPRINTF("%u", vkb->multi_touch_num_contacts));
+}
+
+if (vkb->width) {
+flexarray_append_pair(back, XENKBD_FIELD_WIDTH,
+  GCSPRINTF("%u", vkb->width));
+}
+
+if (vkb->height) {
+flexarray_append_pair(back, XENKBD_FIELD_HEIGHT,
+  GCSPRINTF("%u", vkb->height));
+}
+
 return 0;
 }
 
@@ -50,7 +91,7 @@ static int libxl__vkb_from_xenstore(libxl__gc *gc, const char 
*libxl_path,
 libxl_devid devid,
 libxl_device_vkb *vkb)
 {
-const char 

[Xen-devel] [PATCH v3 4/7] xl: add vkb config parser and CLI

2018-07-17 Thread Oleksandr Grytsov
From: Oleksandr Grytsov 

Signed-off-by: Oleksandr Grytsov 
Acked-by: Wei Liu 
---
 tools/xl/Makefile  |   2 +-
 tools/xl/xl.h  |   3 +
 tools/xl/xl_cmdtable.c |  16 +
 tools/xl/xl_parse.c|  76 -
 tools/xl/xl_parse.h|   1 +
 tools/xl/xl_vkb.c  | 147 +
 6 files changed, 243 insertions(+), 2 deletions(-)
 create mode 100644 tools/xl/xl_vkb.c

diff --git a/tools/xl/Makefile b/tools/xl/Makefile
index 66bdbdef13..2769295515 100644
--- a/tools/xl/Makefile
+++ b/tools/xl/Makefile
@@ -22,7 +22,7 @@ XL_OBJS += xl_vtpm.o xl_block.o xl_nic.o xl_usb.o
 XL_OBJS += xl_sched.o xl_pci.o xl_vcpu.o xl_cdrom.o xl_mem.o
 XL_OBJS += xl_info.o xl_console.o xl_misc.o
 XL_OBJS += xl_vmcontrol.o xl_saverestore.o xl_migrate.o
-XL_OBJS += xl_vdispl.o xl_vsnd.o
+XL_OBJS += xl_vdispl.o xl_vsnd.o xl_vkb.o
 
 $(XL_OBJS): CFLAGS += $(CFLAGS_libxentoollog)
 $(XL_OBJS): CFLAGS += $(CFLAGS_XL)
diff --git a/tools/xl/xl.h b/tools/xl/xl.h
index a6b85f6db2..15943f95dd 100644
--- a/tools/xl/xl.h
+++ b/tools/xl/xl.h
@@ -173,6 +173,9 @@ int main_vdispldetach(int argc, char **argv);
 int main_vsndattach(int argc, char **argv);
 int main_vsndlist(int argc, char **argv);
 int main_vsnddetach(int argc, char **argv);
+int main_vkbattach(int argc, char **argv);
+int main_vkblist(int argc, char **argv);
+int main_vkbdetach(int argc, char **argv);
 int main_usbctrl_attach(int argc, char **argv);
 int main_usbctrl_detach(int argc, char **argv);
 int main_usbdev_attach(int argc, char **argv);
diff --git a/tools/xl/xl_cmdtable.c b/tools/xl/xl_cmdtable.c
index 10426a2ffd..50d3e2e4a3 100644
--- a/tools/xl/xl_cmdtable.c
+++ b/tools/xl/xl_cmdtable.c
@@ -15,6 +15,7 @@
 #include 
 
 #include 
+
 #include "xl.h"
 
 struct cmd_spec cmd_table[] = {
@@ -380,6 +381,21 @@ struct cmd_spec cmd_table[] = {
   "Destroy a domain's virtual TPM device",
   " ",
 },
+{ "vkb-attach",
+  _vkbattach, 1, 1,
+  "Create a new virtual keyboard device",
+  " ...",
+},
+{ "vkb-list",
+  _vkblist, 0, 0,
+  "List virtual keyboard devices for a domain",
+  "",
+},
+{ "vkb-detach",
+  _vkbdetach, 0, 1,
+  "Destroy a domain's virtual keyboard device",
+  " ",
+},
 { "vdispl-attach",
   _vdisplattach, 1, 1,
   "Create a new virtual display device",
diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c
index f9147f6a5c..9b7b78c2a1 100644
--- a/tools/xl/xl_parse.c
+++ b/tools/xl/xl_parse.c
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -1095,6 +1096,77 @@ static void parse_vsnd_config(const XLU_Config *config,
 }
 }
 
+int parse_vkb_config(libxl_device_vkb *vkb, char *token)
+{
+char *oparg;
+
+if (MATCH_OPTION("backend", token, oparg)) {
+vkb->backend_domname = strdup(oparg);
+} else if (MATCH_OPTION("backend-type", token, oparg)) {
+libxl_vkb_backend backend_type;
+if (libxl_vkb_backend_from_string(oparg, _type)) {
+fprintf(stderr, "Unknown backend_type \"%s\" in vkb spec\n",
+oparg);
+return -1;
+}
+vkb->backend_type = backend_type;
+} else if (MATCH_OPTION(XENKBD_FIELD_UNIQUE_ID, token, oparg)) {
+vkb->unique_id = strdup(oparg);
+} else {
+fprintf(stderr, "Unknown string \"%s\" in vkb spec\n", token);
+return -1;
+}
+
+return 0;
+}
+
+static void parse_vkb_list(const XLU_Config *config,
+   libxl_domain_config *d_config)
+{
+XLU_ConfigList *vkbs;
+const char *item;
+char *buf = NULL;
+int rc;
+
+if (!xlu_cfg_get_list (config, "vkb", , 0, 0)) {
+int entry = 0;
+while ((item = xlu_cfg_get_listitem(vkbs, entry)) != NULL) {
+libxl_device_vkb *vkb;
+char *p;
+
+vkb = ARRAY_EXTEND_INIT(d_config->vkbs,
+d_config->num_vkbs,
+libxl_device_vkb_init);
+
+buf = strdup(item);
+
+p = strtok (buf, ",");
+while (p != NULL)
+{
+while (*p == ' ') p++;
+
+rc = parse_vkb_config(vkb, p);
+if (rc) goto out;
+
+p = strtok (NULL, ",");
+}
+
+if (vkb->backend_type == LIBXL_VKB_BACKEND_UNKNOWN) {
+fprintf(stderr, "backend-type should be set in vkb spec\n");
+rc = -1; goto out;
+}
+
+entry++;
+}
+}
+
+rc = 0;
+
+out:
+free(buf);
+if (rc) exit(EXIT_FAILURE);
+}
+
 void parse_config_data(const char *config_source,
  

[Xen-devel] [PATCH v3 0/7] libxl: create standalone vkb device

2018-07-17 Thread Oleksandr Grytsov
From: Oleksandr Grytsov 

Changes since v2:

* fix indentation in libxl__device_vkb_dm_needed
* add LIBXL_HAVE_EXTENDED_VKB define to indicates that libxl__device_vkb
  has extended fields

Oleksandr Grytsov (7):
  libxl: move vkb device to libxl_vkb.c
  libxl: add backend type and id to vkb
  libxl: vkb add list and info functions
  xl: add vkb config parser and CLI
  docs: add vkb device to xl.cfg and xl
  libxl: vkb add extended parameters
  libxl: add LIBXL_HAVE_EXTENDED_VKB define

 docs/man/xl.cfg.pod.5.in|  64 +++
 docs/man/xl.pod.1.in|  22 +++
 tools/libxl/Makefile|   2 +-
 tools/libxl/libxl.h |  26 +++
 tools/libxl/libxl_console.c |  53 --
 tools/libxl/libxl_create.c  |   3 +
 tools/libxl/libxl_dm.c  |   1 +
 tools/libxl/libxl_types.idl |  29 +++
 tools/libxl/libxl_utils.h   |   3 +
 tools/libxl/libxl_vkb.c | 342 
 tools/xl/Makefile   |   2 +-
 tools/xl/xl.h   |   3 +
 tools/xl/xl_cmdtable.c  |  16 ++
 tools/xl/xl_parse.c | 109 +++-
 tools/xl/xl_parse.h |   1 +
 tools/xl/xl_vkb.c   | 161 +
 16 files changed, 781 insertions(+), 56 deletions(-)
 create mode 100644 tools/libxl/libxl_vkb.c
 create mode 100644 tools/xl/xl_vkb.c

-- 
2.17.1


___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH v2 0/6] libxl: create standalone vkb device

2018-07-02 Thread Oleksandr Grytsov
On Tue, Jun 12, 2018 at 4:31 PM, Oleksandr Grytsov  wrote:

> From: Oleksandr Grytsov 
>
> Changes since initial:
>  * id field is changed to unique_id in libxl_device_vkb to be comply
>with protocol;
>  * use XENKBD_FIELD_... defines from protocol to address xen store entries
>and fields in domain config file;
>  * add support of new protocol parameters:
> - XENKBD_FIELD_FEAT_DSBL_KEYBRD
> - XENKBD_FIELD_FEAT_DSBL_POINTER
> - XENKBD_FIELD_FEAT_ABS_POINTER
> - XENKBD_FIELD_FEAT_RAW_POINTER
> - XENKBD_FIELD_FEAT_MTOUCH
>
> Oleksandr Grytsov (6):
>   libxl: move vkb device to libxl_vkb.c
>   libxl: add backend type and id to vkb
>   libxl: vkb add list and info functions
>   xl: add vkb config parser and CLI
>   docs: add vkb device to xl.cfg and xl
>   libxl: vkb add extended parameters
>
>  docs/man/xl.cfg.pod.5.in|  64 +++
>  docs/man/xl.pod.1.in|  22 +++
>  tools/libxl/Makefile|   2 +-
>  tools/libxl/libxl.h |  10 ++
>  tools/libxl/libxl_console.c |  53 --
>  tools/libxl/libxl_create.c  |   3 +
>  tools/libxl/libxl_dm.c  |   1 +
>  tools/libxl/libxl_types.idl |  29 +++
>  tools/libxl/libxl_utils.h   |   3 +
>  tools/libxl/libxl_vkb.c | 346 
>  tools/xl/Makefile   |   2 +-
>  tools/xl/xl.h   |   3 +
>  tools/xl/xl_cmdtable.c  |  16 ++
>  tools/xl/xl_parse.c | 109 +++-
>  tools/xl/xl_parse.h |   2 +-
>  tools/xl/xl_vkb.c   | 161 +
>  16 files changed, 769 insertions(+), 57 deletions(-)
>  create mode 100644 tools/libxl/libxl_vkb.c
>  create mode 100644 tools/xl/xl_vkb.c
>
> --
> 2.17.1
>
>
ping
___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH 0/1] libxl/xl: rename id to unique-id in vdispl xen store

2018-07-02 Thread Oleksandr Grytsov
On Tue, Jun 12, 2018 at 6:40 PM, Oleksandr Grytsov  wrote:

> From: Oleksandr Grytsov 
>
> As new version of the display protocol introduces unique-id variable, it
> needs
> to be changed in libxl/xl. This patchset renames it in the xen store and in
> display device structures. Also it uses XENDISPL_FIELD_... defines instead
> of
> inline names.
>
> Oleksandr Grytsov (1):
>   libxl/xl: rename id to unique-id in vdispl xen store
>
>  docs/man/xl.cfg.pod.5.in|  2 +-
>  tools/libxl/libxl_types.idl |  4 ++--
>  tools/libxl/libxl_vdispl.c  | 32 +---
>  tools/xl/xl_parse.c |  2 +-
>  tools/xl/xl_vdispl.c|  2 +-
>  5 files changed, 22 insertions(+), 20 deletions(-)
>
> --
> 2.17.1
>
>
ping
___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH v3 0/5] libxl: add PV sound device

2018-07-02 Thread Oleksandr Grytsov
On Fri, Jun 15, 2018 at 1:15 PM, Oleksandr Grytsov  wrote:

> From: Oleksandr Grytsov 
>
> This patch set adds PV sound device support to xl.cfg and xl.
> See sndif.h for protocol implementation details.
>
> Changes since v2:
>  * address comments
>  * rename libxl_vsnd_stream.id -> libxl_vsnd_stream.unique_id
>  * use XENSND_FIELD_... defines in xl_parse.c and xl_vsnd.c
>
> Oleksandr Grytsov (5):
>   libxl: add PV sound device
>   libxl: add vsnd list and info
>   xl: add PV sound condif parser
>   xl: add vsnd CLI commands
>   docs: add PV sound device config
>
>  docs/man/xl.cfg.pod.5.in | 149 ++
>  docs/man/xl.pod.1.in |  30 ++
>  tools/libxl/Makefile |   2 +-
>  tools/libxl/libxl.h  |  24 +
>  tools/libxl/libxl_create.c   |   1 +
>  tools/libxl/libxl_internal.h |   1 +
>  tools/libxl/libxl_types.idl  |  83 
>  tools/libxl/libxl_types_internal.idl |   1 +
>  tools/libxl/libxl_utils.h|   3 +
>  tools/libxl/libxl_vsnd.c | 684 +++
>  tools/xl/Makefile|   2 +-
>  tools/xl/xl.h|   3 +
>  tools/xl/xl_cmdtable.c   |  15 +
>  tools/xl/xl_parse.c  | 246 ++
>  tools/xl/xl_parse.h  |   1 +
>  tools/xl/xl_vsnd.c   | 206 
>  16 files changed, 1449 insertions(+), 2 deletions(-)
>  create mode 100644 tools/libxl/libxl_vsnd.c
>  create mode 100644 tools/xl/xl_vsnd.c
>
> --
> 2.17.1
>
>
ping
___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

[Xen-devel] [PATCH v3 1/5] libxl: add PV sound device

2018-06-15 Thread Oleksandr Grytsov
From: Oleksandr Grytsov 

Add PV sound device described in sndif.h

Signed-off-by: Oleksandr Grytsov 
Acked-by: Wei Liu 
---
 tools/libxl/Makefile |   2 +-
 tools/libxl/libxl.h  |  14 ++
 tools/libxl/libxl_create.c   |   1 +
 tools/libxl/libxl_internal.h |   1 +
 tools/libxl/libxl_types.idl  |  64 ++
 tools/libxl/libxl_types_internal.idl |   1 +
 tools/libxl/libxl_vsnd.c | 325 +++
 7 files changed, 407 insertions(+), 1 deletion(-)
 create mode 100644 tools/libxl/libxl_vsnd.c

diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile
index 035e66e22e..d60743d38b 100644
--- a/tools/libxl/Makefile
+++ b/tools/libxl/Makefile
@@ -140,7 +140,7 @@ LIBXL_OBJS = flexarray.o libxl.o libxl_create.o libxl_dm.o 
libxl_pci.o \
libxl_vtpm.o libxl_nic.o libxl_disk.o libxl_console.o \
libxl_cpupool.o libxl_mem.o libxl_sched.o libxl_tmem.o \
libxl_9pfs.o libxl_domain.o libxl_vdispl.o \
-libxl_pvcalls.o $(LIBXL_OBJS-y)
+   libxl_pvcalls.o libxl_vsnd.o $(LIBXL_OBJS-y)
 LIBXL_OBJS += libxl_genid.o
 LIBXL_OBJS += _libxl_types.o libxl_flask.o _libxl_types_internal.o
 
diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index a09d069358..a312166b48 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -2000,6 +2000,20 @@ int libxl_device_vdispl_getinfo(libxl_ctx *ctx, uint32_t 
domid,
 libxl_vdisplinfo *vdisplinfo)
 LIBXL_EXTERNAL_CALLERS_ONLY;
 
+/* Virtual sounds */
+int libxl_device_vsnd_add(libxl_ctx *ctx, uint32_t domid,
+  libxl_device_vsnd *vsnd,
+  const libxl_asyncop_how *ao_how)
+  LIBXL_EXTERNAL_CALLERS_ONLY;
+int libxl_device_vsnd_remove(libxl_ctx *ctx, uint32_t domid,
+ libxl_device_vsnd *vsnd,
+ const libxl_asyncop_how *ao_how)
+ LIBXL_EXTERNAL_CALLERS_ONLY;
+int libxl_device_vsnd_destroy(libxl_ctx *ctx, uint32_t domid,
+  libxl_device_vsnd *vsnd,
+  const libxl_asyncop_how *ao_how)
+  LIBXL_EXTERNAL_CALLERS_ONLY;
+
 /* Keyboard */
 int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb,
  const libxl_asyncop_how *ao_how)
diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index b5e27a7766..7d46824eac 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -1501,6 +1501,7 @@ const struct libxl_device_type *device_type_tbl[] = {
 __pcidev_devtype,
 __dtdev_devtype,
 __vdispl_devtype,
+__vsnd_devtype,
 NULL
 };
 
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index c582894589..17ac2083f6 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -3653,6 +3653,7 @@ extern const struct libxl_device_type 
libxl__pcidev_devtype;
 extern const struct libxl_device_type libxl__vdispl_devtype;
 extern const struct libxl_device_type libxl__p9_devtype;
 extern const struct libxl_device_type libxl__pvcallsif_devtype;
+extern const struct libxl_device_type libxl__vsnd_devtype;
 
 extern const struct libxl_device_type *device_type_tbl[];
 
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index 01ec1d1afa..4218bf466f 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -822,6 +822,69 @@ libxl_device_vdispl = Struct("device_vdispl", [
 ("connectors", Array(libxl_connector_param, "num_connectors"))
 ])
 
+libxl_vsnd_pcm_format = Enumeration("vsnd_pcm_format", [
+(1,  "S8"),
+(2,  "U8"),
+(3,  "S16_LE"),
+(4,  "S16_BE"),
+(5,  "U16_LE"),
+(6,  "U16_BE"),
+(7,  "S24_LE"),
+(8,  "S24_BE"),
+(9,  "U24_LE"),
+(10, "U24_BE"),
+(11, "S32_LE"),
+(12, "S32_BE"),
+(13, "U32_LE"),
+(14, "U32_BE"),
+(15, "F32_LE"),
+(16, "F32_BE"),
+(17, "F64_LE"),
+(18, "F64_BE"),
+(19, "IEC958_SUBFRAME_LE"),
+(20, "IEC958_SUBFRAME_BE"),
+(21, "MU_LAW"),
+(22, "A_LAW"),
+(23, "IMA_ADPCM"),
+(24, "MPEG"),
+(25, "GSM")
+])
+
+libxl_vsnd_params = Struct("vsnd_params", [
+("sample_rates", Array(uint32, "num_sample_rates")),
+("sample_formats", Array(libxl_vsnd_pcm_format, "num_sample_formats")),
+("channels_min", uint32),
+("channels_max", uint32),
+(&quo

[Xen-devel] [PATCH v3 5/5] docs: add PV sound device config

2018-06-15 Thread Oleksandr Grytsov
From: Oleksandr Grytsov 

Update documentation with virtual sound device

Signed-off-by: Oleksandr Grytsov 
Acked-by: Wei Liu 
---
 docs/man/xl.cfg.pod.5.in | 149 +++
 docs/man/xl.pod.1.in |  30 
 2 files changed, 179 insertions(+)

diff --git a/docs/man/xl.cfg.pod.5.in b/docs/man/xl.cfg.pod.5.in
index 47d88243b1..b6e699ee80 100644
--- a/docs/man/xl.cfg.pod.5.in
+++ b/docs/man/xl.cfg.pod.5.in
@@ -1414,6 +1414,155 @@ we may break backward compatibility.
 
 =back
 
+=item B
+
+Specifies the virtual sound cards to be provided to the guest.
+Each B is a list, which has a form of
+"[VSND_ITEM_SPEC, VSND_ITEM_SPEC, ... ]" (without the quotes).
+The virtual sound card has hierarchical structure.
+Every card has a set of PCM devices and streams, each could be individually
+configured.
+
+B describes individual item parameters.
+B is a string of comma separated item parameters
+headed by item identifier. Each item parameter is C pair:
+
+=over 4
+
+"identifier, param = value, ...".
+
+=back
+
+Identifier shall be one of following values: "CARD", "PCM", "STREAM".
+The child item treated as belonging to the previously defined parent item.
+
+All parameters are optional.
+
+There are group of parameters which are common for all items.
+This group can be defined at higher level of the hierarchy and be fully or
+partially re-used by the underlying layers. These parameters are:
+
+=over 4
+
+* number of channels (min/max)
+
+* supported sample rates
+
+* supported sample formats
+
+=back
+
+E.g. one can define these values for the whole card, device or stream.
+Every underlying layer in turn can re-define some or all of them to better
+fit its needs. For example, card may define number of channels to be
+in [1; 8] range, and some particular stream may be limited to [1; 2] only.
+The rule is that the underlying layer must be a subset of the upper layer
+range.
+
+I
+
+=over 4
+
+=over 4
+
+=item B
+
+List of integer values separated by semicolon: sample-rates=8000;22050;44100
+
+=item B
+
+List of string values separated by semicolon: sample-formats=s16_le;s8;u32_be
+
+Supported formats: s8, u8, s16_le, s16_be, u16_le, u16_be, s24_le, s24_be,
+u24_le, u24_be, s32_le, s32_be, u32_le, u32_be, float_le, float_be,
+float64_le, float64_be, iec958_subframe_le, iec958_subframe_be,
+mu_law, a_law, ima_adpcm, mpeg, gsm
+
+=item B
+
+The minimum amount of channels.
+
+=item B
+
+The maximum amount of channels.
+
+=item B
+
+The maximum size in octets of the buffer to allocate per stream.
+
+=back
+
+=back
+
+I
+
+=over 4
+
+=over 4
+
+=item B
+
+Specify the backend domain name or id, defaults to dom0.
+
+=item B
+
+Short name of the virtual sound card.
+
+=item B
+
+Long name of the virtual sound card.
+
+=back
+
+=back
+
+I
+
+=over 4
+
+=over 4
+
+=item B
+
+Name of the PCM sound device within the virtual sound card.
+
+=back
+
+=back
+
+I
+
+=over 4
+
+=over 4
+
+=item B
+
+Unique stream identifier.
+
+=item B
+
+Stream type: "p" - playback stream, "c" - capture stream.
+
+=back
+
+=back
+
+I
+
+vsnd = [
+['CARD, short-name=Main, sample-formats=s16_le;s8;u32_be',
+'PCM, name=Main',
+'STREAM, id=0, type=p',
+'STREAM, id=1, type=c, channels-max=2'
+],
+['CARD, short-name=Second',
+'PCM, name=Second, buffer-size=1024',
+'STREAM, id=2, type=p',
+'STREAM, id=3, type=c'
+]
+]
+
 =back
 
 =head2 Paravirtualised (PV) Guest Specific Options
diff --git a/docs/man/xl.pod.1.in b/docs/man/xl.pod.1.in
index 48da2052cc..90423bf3df 100644
--- a/docs/man/xl.pod.1.in
+++ b/docs/man/xl.pod.1.in
@@ -1492,6 +1492,36 @@ List virtual displays for a domain.
 
 =back
 
+=head2 VSND DEVICES
+
+=over 4
+
+=item B I I I ...
+
+Creates a new vsnd device in the domain specified by I.
+I's describe the vsnd device to attach, using the same format as the
+B string in the domain config file. See L for
+more information.
+
+B
+
+=over 4
+
+xl vsnd-attach DomU 'CARD, short-name=Main, sample-formats=s16_le;s8;u32_be'
+'PCM, name=Main' 'STREAM, id=0, type=p' 'STREAM, id=1, type=c, channels-max=2'
+
+=back
+
+=item B I I
+
+Removes the vsnd device specified by I from the domain specified by 
I.
+
+=item B I
+
+List vsnd devices for a domain.
+
+=back
+
 =head1 PCI PASS-THROUGH
 
 =over 4
-- 
2.17.1


___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

[Xen-devel] [PATCH v3 4/5] xl: add vsnd CLI commands

2018-06-15 Thread Oleksandr Grytsov
From: Oleksandr Grytsov 

Add CLI commands to attach, detach and list virtual sound devices

Signed-off-by: Oleksandr Grytsov 
Acked-by: Wei Liu 
---
 tools/xl/Makefile  |   2 +-
 tools/xl/xl.h  |   3 +
 tools/xl/xl_cmdtable.c |  15 +++
 tools/xl/xl_vsnd.c | 206 +
 4 files changed, 225 insertions(+), 1 deletion(-)
 create mode 100644 tools/xl/xl_vsnd.c

diff --git a/tools/xl/Makefile b/tools/xl/Makefile
index a5117ab3fb..66bdbdef13 100644
--- a/tools/xl/Makefile
+++ b/tools/xl/Makefile
@@ -22,7 +22,7 @@ XL_OBJS += xl_vtpm.o xl_block.o xl_nic.o xl_usb.o
 XL_OBJS += xl_sched.o xl_pci.o xl_vcpu.o xl_cdrom.o xl_mem.o
 XL_OBJS += xl_info.o xl_console.o xl_misc.o
 XL_OBJS += xl_vmcontrol.o xl_saverestore.o xl_migrate.o
-XL_OBJS += xl_vdispl.o
+XL_OBJS += xl_vdispl.o xl_vsnd.o
 
 $(XL_OBJS): CFLAGS += $(CFLAGS_libxentoollog)
 $(XL_OBJS): CFLAGS += $(CFLAGS_XL)
diff --git a/tools/xl/xl.h b/tools/xl/xl.h
index 4e784ff402..a6b85f6db2 100644
--- a/tools/xl/xl.h
+++ b/tools/xl/xl.h
@@ -170,6 +170,9 @@ int main_vtpmdetach(int argc, char **argv);
 int main_vdisplattach(int argc, char **argv);
 int main_vdispllist(int argc, char **argv);
 int main_vdispldetach(int argc, char **argv);
+int main_vsndattach(int argc, char **argv);
+int main_vsndlist(int argc, char **argv);
+int main_vsnddetach(int argc, char **argv);
 int main_usbctrl_attach(int argc, char **argv);
 int main_usbctrl_detach(int argc, char **argv);
 int main_usbdev_attach(int argc, char **argv);
diff --git a/tools/xl/xl_cmdtable.c b/tools/xl/xl_cmdtable.c
index bf2ced8140..10426a2ffd 100644
--- a/tools/xl/xl_cmdtable.c
+++ b/tools/xl/xl_cmdtable.c
@@ -399,6 +399,21 @@ struct cmd_spec cmd_table[] = {
   "Destroy a domain's virtual display device",
   " ",
 },
+{ "vsnd-attach",
+  _vsndattach, 1, 1,
+  "Create a new virtual sound device",
+  " ...",
+},
+{ "vsnd-list",
+  _vsndlist, 0, 0,
+  "List virtual display devices for a domain",
+  "",
+},
+{ "vsnd-detach",
+  _vsnddetach, 0, 1,
+  "Destroy a domain's virtual sound device",
+  " ",
+},
 { "uptime",
   _uptime, 0, 0,
   "Print uptime for all/some domains",
diff --git a/tools/xl/xl_vsnd.c b/tools/xl/xl_vsnd.c
new file mode 100644
index 00..6dd3a901b2
--- /dev/null
+++ b/tools/xl/xl_vsnd.c
@@ -0,0 +1,206 @@
+/*
+ * Copyright (C) 2016 EPAM Systems Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+
+#include 
+
+#include "xl.h"
+#include "xl_utils.h"
+#include "xl_parse.h"
+
+int main_vsndattach(int argc, char **argv)
+{
+int opt;
+int rc;
+uint32_t domid;
+libxl_device_vsnd vsnd;
+
+SWITCH_FOREACH_OPT(opt, "", NULL, "vsnd-attach", 2) {
+/* No options */
+}
+
+libxl_device_vsnd_init();
+domid = find_domain(argv[optind++]);
+
+for (argv += optind, argc -= optind; argc > 0; ++argv, --argc) {
+rc = parse_vsnd_item(, *argv);
+if (rc) goto out;
+}
+
+if (dryrun_only) {
+char *json = libxl_device_vsnd_to_json(ctx, );
+printf("vsnd: %s\n", json);
+free(json);
+goto out;
+}
+
+if (libxl_device_vsnd_add(ctx, domid, , 0)) {
+fprintf(stderr, "libxl_device_vsnd_add failed.\n");
+rc = ERROR_FAIL; goto out;
+}
+
+rc = 0;
+
+out:
+libxl_device_vsnd_dispose();
+return rc;
+}
+
+static void print_params(libxl_vsnd_params *params)
+{
+int i;
+
+if (params->channels_min) {
+printf(", "XENSND_FIELD_CHANNELS_MIN": %u", params->channels_min);
+}
+
+if (params->channels_max) {
+printf(", "XENSND_FIELD_CHANNELS_MAX": %u", params->channels_max);
+}
+
+if (params->buffer_size) {
+printf(", "XENSND_FIELD_BUFFER_SIZE": %u", params->buffer_size);
+}
+
+if (params->num_sample_rates) {
+printf(", "XENSND_FIELD_SAMPLE_RATES": ");
+for (i = 0; i < params->num_sample_rates - 1; i++) {
+printf("%u;", params->sample_rates[i]);
+}
+printf("%u", params->sample_rates[i]);
+}

[Xen-devel] [PATCH v3 3/5] xl: add PV sound condif parser

2018-06-15 Thread Oleksandr Grytsov
From: Oleksandr Grytsov 

Add config parser for virtual sound devices

Signed-off-by: Oleksandr Grytsov 
Acked-by: Wei Liu 
---
 tools/xl/xl_parse.c | 246 
 tools/xl/xl_parse.h |   1 +
 2 files changed, 247 insertions(+)

diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c
index e6c54483e0..4d1ecd5fa7 100644
--- a/tools/xl/xl_parse.c
+++ b/tools/xl/xl_parse.c
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -851,6 +852,249 @@ out:
 return rc;
 }
 
+static int parse_vsnd_params(libxl_vsnd_params *params, char *token)
+{
+char *oparg;
+int i;
+
+if (MATCH_OPTION(XENSND_FIELD_SAMPLE_RATES, token, oparg)) {
+libxl_string_list rates = NULL;
+
+split_string_into_string_list(oparg, ";", );
+
+params->num_sample_rates = libxl_string_list_length();
+params->sample_rates = calloc(params->num_sample_rates,
+  sizeof(*params->sample_rates));
+
+for (i = 0; i < params->num_sample_rates; i++) {
+params->sample_rates[i] = strtoul(rates[i], NULL, 0);
+}
+
+libxl_string_list_dispose();
+} else if (MATCH_OPTION(XENSND_FIELD_SAMPLE_FORMATS, token, oparg)) {
+libxl_string_list formats = NULL;
+
+split_string_into_string_list(oparg, ";", );
+
+params->num_sample_formats = libxl_string_list_length();
+params->sample_formats = calloc(params->num_sample_formats,
+sizeof(*params->sample_formats));
+
+for (i = 0; i < params->num_sample_formats; i++) {
+libxl_vsnd_pcm_format format;
+
+if (libxl_vsnd_pcm_format_from_string(formats[i], )) {
+fprintf(stderr, "Invalid pcm format: %s\n", formats[i]);
+exit(EXIT_FAILURE);
+}
+
+params->sample_formats[i] = format;
+}
+
+libxl_string_list_dispose();
+} else if (MATCH_OPTION(XENSND_FIELD_CHANNELS_MIN, token, oparg)) {
+params->channels_min = strtoul(oparg, NULL, 0);
+} else if (MATCH_OPTION(XENSND_FIELD_CHANNELS_MAX, token, oparg)) {
+params->channels_max = strtoul(oparg, NULL, 0);
+} else if (MATCH_OPTION(XENSND_FIELD_BUFFER_SIZE, token, oparg)) {
+params->buffer_size = strtoul(oparg, NULL, 0);
+} else {
+return 1;
+}
+
+return 0;
+}
+
+static int parse_vsnd_pcm_stream(libxl_device_vsnd *vsnd, char *param)
+{
+if (vsnd->num_vsnd_pcms == 0) {
+fprintf(stderr, "No vsnd pcm device\n");
+return -1;
+}
+
+libxl_vsnd_pcm *pcm = >pcms[vsnd->num_vsnd_pcms - 1];
+
+if (pcm->num_vsnd_streams == 0) {
+fprintf(stderr, "No vsnd stream\n");
+return -1;
+}
+
+libxl_vsnd_stream *stream = >streams[pcm->num_vsnd_streams - 1];
+
+if (parse_vsnd_params(>params, param)) {
+char *oparg;
+
+if (MATCH_OPTION(XENSND_FIELD_STREAM_UNIQUE_ID, param, oparg)) {
+stream->unique_id = strdup(oparg);
+} else if (MATCH_OPTION(XENSND_FIELD_TYPE, param, oparg)) {
+if (libxl_vsnd_stream_type_from_string(oparg, >type)) {
+fprintf(stderr, "Invalid stream type: %s\n", oparg);
+return -1;
+}
+} else {
+fprintf(stderr, "Invalid parameter: %s\n", param);
+return -1;
+}
+}
+
+return 0;
+}
+
+static int parse_vsnd_pcm_param(libxl_device_vsnd *vsnd, char *param)
+{
+if (vsnd->num_vsnd_pcms == 0) {
+fprintf(stderr, "No pcm device\n");
+return -1;
+}
+
+libxl_vsnd_pcm *pcm = >pcms[vsnd->num_vsnd_pcms - 1];
+
+if (parse_vsnd_params(>params, param)) {
+char *oparg;
+
+if (MATCH_OPTION(XENSND_FIELD_DEVICE_NAME, param, oparg)) {
+pcm->name = strdup(oparg);
+} else {
+fprintf(stderr, "Invalid parameter: %s\n", param);
+return -1;
+}
+}
+
+return 0;
+}
+
+static int parse_vsnd_card_param(libxl_device_vsnd *vsnd, char *param)
+{
+if (parse_vsnd_params(>params, param)) {
+char *oparg;
+
+if (MATCH_OPTION("backend", param, oparg)) {
+vsnd->backend_domname = strdup(oparg);
+} else if (MATCH_OPTION(XENSND_FIELD_VCARD_SHORT_NAME, param, oparg)) {
+vsnd->short_name = strdup(oparg);
+} else if (MATCH_OPTION(XENSND_FIELD_VCARD_LONG_NAME, param, oparg)) {
+vsnd->long_name = strdup(oparg);
+} else {
+fprintf(stderr, "Invalid parameter: %s\n", param);
+return -1;
+}
+}
+
+return 0;
+}
+
+static int parse_vsnd_create_item(libxl_device_vsnd *vsnd, const char *key)
+{
+if (st

[Xen-devel] [PATCH v3 0/5] libxl: add PV sound device

2018-06-15 Thread Oleksandr Grytsov
From: Oleksandr Grytsov 

This patch set adds PV sound device support to xl.cfg and xl.
See sndif.h for protocol implementation details.

Changes since v2:
 * address comments
 * rename libxl_vsnd_stream.id -> libxl_vsnd_stream.unique_id
 * use XENSND_FIELD_... defines in xl_parse.c and xl_vsnd.c

Oleksandr Grytsov (5):
  libxl: add PV sound device
  libxl: add vsnd list and info
  xl: add PV sound condif parser
  xl: add vsnd CLI commands
  docs: add PV sound device config

 docs/man/xl.cfg.pod.5.in | 149 ++
 docs/man/xl.pod.1.in |  30 ++
 tools/libxl/Makefile |   2 +-
 tools/libxl/libxl.h  |  24 +
 tools/libxl/libxl_create.c   |   1 +
 tools/libxl/libxl_internal.h |   1 +
 tools/libxl/libxl_types.idl  |  83 
 tools/libxl/libxl_types_internal.idl |   1 +
 tools/libxl/libxl_utils.h|   3 +
 tools/libxl/libxl_vsnd.c | 684 +++
 tools/xl/Makefile|   2 +-
 tools/xl/xl.h|   3 +
 tools/xl/xl_cmdtable.c   |  15 +
 tools/xl/xl_parse.c  | 246 ++
 tools/xl/xl_parse.h  |   1 +
 tools/xl/xl_vsnd.c   | 206 
 16 files changed, 1449 insertions(+), 2 deletions(-)
 create mode 100644 tools/libxl/libxl_vsnd.c
 create mode 100644 tools/xl/xl_vsnd.c

-- 
2.17.1


___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

[Xen-devel] [PATCH 1/1] libxl/xl: rename id to unique-id in vdispl xen store

2018-06-12 Thread Oleksandr Grytsov
From: Oleksandr Grytsov 

In the display protocol connector's id is named as unique-id. This patch renames
it in the libxl/xl code and uses XENDISPL_FIELD... definitions from the protocol
header.

Signed-off-by: Oleksandr Grytsov 
---
 docs/man/xl.cfg.pod.5.in|  2 +-
 tools/libxl/libxl_types.idl |  4 ++--
 tools/libxl/libxl_vdispl.c  | 32 +---
 tools/xl/xl_parse.c |  2 +-
 tools/xl/xl_vdispl.c|  2 +-
 5 files changed, 22 insertions(+), 20 deletions(-)

diff --git a/docs/man/xl.cfg.pod.5.in b/docs/man/xl.cfg.pod.5.in
index 47d88243b1..ea66d867da 100644
--- a/docs/man/xl.cfg.pod.5.in
+++ b/docs/man/xl.cfg.pod.5.in
@@ -1288,7 +1288,7 @@ Specifies virtual connectors for the device in following 
format
 
 =item C
 
-String connector ID. Space, comma symbols are not allowed.
+String connector unique id. Space, comma symbols are not allowed.
 
 =item C
 
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index 01ec1d1afa..9a9d0ed52d 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -809,7 +809,7 @@ libxl_device_channel = Struct("device_channel", [
 ])
 
 libxl_connector_param = Struct("connector_param", [
-("id", string),
+("unique_id", string),
 ("width", uint32),
 ("height", uint32)
 ])
@@ -935,7 +935,7 @@ libxl_physinfo = Struct("physinfo", [
 ], dir=DIR_OUT)
 
 libxl_connectorinfo = Struct("connectorinfo", [
-("id", string),
+("unique_id", string),
 ("width", uint32),
 ("height", uint32),
 ("req_evtch", integer),
diff --git a/tools/libxl/libxl_vdispl.c b/tools/libxl/libxl_vdispl.c
index 55dfac3e71..351f6beccb 100644
--- a/tools/libxl/libxl_vdispl.c
+++ b/tools/libxl/libxl_vdispl.c
@@ -14,6 +14,8 @@
 
 #include "libxl_internal.h"
 
+#include 
+
 static int libxl__device_vdispl_setdefault(libxl__gc *gc, uint32_t domid,
libxl_device_vdispl *vdispl,
bool hotplug)
@@ -66,15 +68,15 @@ static int libxl__set_xenstore_vdispl(libxl__gc *gc, 
uint32_t domid,
 {
 int i;
 
-flexarray_append_pair(ro_front, "be-alloc",
+flexarray_append_pair(ro_front, XENDISPL_FIELD_BE_ALLOC,
   GCSPRINTF("%d", vdispl->be_alloc));
 
 for (i = 0; i < vdispl->num_connectors; i++) {
-flexarray_append_pair(ro_front, GCSPRINTF("%d/resolution", i),
-  GCSPRINTF("%dx%d", vdispl->connectors[i].width,
+flexarray_append_pair(ro_front, 
GCSPRINTF("%d/"XENDISPL_FIELD_RESOLUTION, i),
+  GCSPRINTF("%d"XENDISPL_RESOLUTION_SEPARATOR"%d", 
vdispl->connectors[i].width,
  
vdispl->connectors[i].height));
-flexarray_append_pair(ro_front, GCSPRINTF("%d/id", i),
-  vdispl->connectors[i].id);
+flexarray_append_pair(ro_front, 
GCSPRINTF("%d/"XENDISPL_FIELD_UNIQUE_ID, i),
+  vdispl->connectors[i].unique_id);
 }
 
 return 0;
@@ -106,15 +108,15 @@ static int libxl__device_vdispl_getconnectors(libxl_ctx 
*ctx,
 char *value;
 char *value_path;
 
-value_path = GCSPRINTF("%s/%d/id", path, i);
-info->connectors[i].id = xs_read(ctx->xsh, XBT_NULL, value_path, NULL);
-if (info->connectors[i].id == NULL) { rc = ERROR_FAIL; goto out; }
+value_path = GCSPRINTF("%s/%d/"XENDISPL_FIELD_UNIQUE_ID, path, i);
+info->connectors[i].unique_id = xs_read(ctx->xsh, XBT_NULL, 
value_path, NULL);
+if (info->connectors[i].unique_id == NULL) { rc = ERROR_FAIL; goto 
out; }
 
-value_path = GCSPRINTF("%s/%d/resolution", path, i);
+value_path = GCSPRINTF("%s/%d/"XENDISPL_FIELD_RESOLUTION, path, i);
 value = xs_read(ctx->xsh, XBT_NULL, value_path, NULL);
 if (value == NULL) { rc = ERROR_FAIL; goto out; }
 
-rc = sscanf(value, "%ux%u", >connectors[i].width,
+rc = sscanf(value, "%u"XENDISPL_RESOLUTION_SEPARATOR"%u", 
>connectors[i].width,
 >connectors[i].height);
 free(value);
 
@@ -122,22 +124,22 @@ static int libxl__device_vdispl_getconnectors(libxl_ctx 
*ctx,
 rc = ERROR_FAIL; goto out;
 }
 
-value_path = GCSPRINTF("%s/%d/req-ring-ref", path, i);
+value_path = GCSPRINTF("%s/%d/"XENDISPL_FIELD_REQ_RING_REF, path, i);
 value = xs_read(ctx->xsh, XBT_NULL, value_path, NULL);
 info->connectors[i].req_rref = value ? strtoul(value, NULL, 10) : -1;
 free(value)

[Xen-devel] [PATCH v2 6/6] libxl: vkb add extended parameters

2018-06-12 Thread Oleksandr Grytsov
From: Oleksandr Grytsov 

Add parsing and adding to xen store following extended parameters:
* feature-disable-keyboard
* feature-disable-pointer
* feature-abs-pointer
* feature-multi-touch
* feature-raw-pointer
* width
* height
* multi-touch-width
* multi-touch-height
* multi-touch-num-contacts

Signed-off-by: Oleksandr Grytsov 
---
 docs/man/xl.cfg.pod.5.in|  40 +++
 tools/libxl/libxl_types.idl |  12 +++-
 tools/libxl/libxl_vkb.c | 133 +++-
 tools/xl/xl_parse.c |  35 +-
 tools/xl/xl_vkb.c   |  14 
 5 files changed, 231 insertions(+), 3 deletions(-)

diff --git a/docs/man/xl.cfg.pod.5.in b/docs/man/xl.cfg.pod.5.in
index d9d321d027..93602680a2 100644
--- a/docs/man/xl.cfg.pod.5.in
+++ b/docs/man/xl.cfg.pod.5.in
@@ -1436,6 +1436,46 @@ Specifies the backend domain name or id.
 Specifies the backend type: qemu - for QEMU backend or linux - for Linux PV
 domain.
 
+=item B
+
+Indicates if keyboard device is disabled.
+
+=item B
+
+Indicates if pointer device is disabled.
+
+=item B
+
+Indicates if pointer device can return absolute coordinates.
+
+=item B
+
+Indicates if pointer device can return raw (unscaled) absolute coordinates.
+
+=item B
+
+Indicates if input device supports multi touch.
+
+=item B
+
+Set maximum width for multi touch device.
+
+=item B
+
+Set maximum height for multi touch device.
+
+=item B
+
+Set maximum contacts number for multi touch device.
+
+=item B
+
+Set maximum width for pointer device.
+
+=item B
+
+Set maximum height for pointer device.
+
 =back
 
 =back
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index b7fa42fba0..6fb11d51e7 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -633,7 +633,17 @@ libxl_device_vkb = Struct("device_vkb", [
 ("backend_domname", string),
 ("devid", libxl_devid),
 ("backend_type", libxl_vkb_backend),
-("unique_id", string)
+("unique_id", string),
+("feature_disable_keyboard", bool),
+("feature_disable_pointer", bool),
+("feature_abs_pointer", bool),
+("feature_raw_pointer", bool),
+("feature_multi_touch", bool),
+("width", uint32),
+("height", uint32),
+("multi_touch_width", uint32),
+("multi_touch_height", uint32),
+("multi_touch_num_contacts", uint32)
 ])
 
 libxl_device_disk = Struct("device_disk", [
diff --git a/tools/libxl/libxl_vkb.c b/tools/libxl/libxl_vkb.c
index d2ffc74c0d..c71bb13a31 100644
--- a/tools/libxl/libxl_vkb.c
+++ b/tools/libxl/libxl_vkb.c
@@ -47,6 +47,47 @@ static int libxl__set_xenstore_vkb(libxl__gc *gc, uint32_t 
domid,
 flexarray_append_pair(back, XENKBD_FIELD_UNIQUE_ID, vkb->unique_id);
 }
 
+if (vkb->feature_disable_keyboard) {
+flexarray_append_pair(back, XENKBD_FIELD_FEAT_DSBL_KEYBRD,
+  GCSPRINTF("%u", vkb->feature_disable_keyboard));
+}
+
+if (vkb->feature_disable_pointer) {
+flexarray_append_pair(back, XENKBD_FIELD_FEAT_DSBL_POINTER,
+  GCSPRINTF("%u", vkb->feature_disable_pointer));
+}
+
+if (vkb->feature_abs_pointer) {
+flexarray_append_pair(back, XENKBD_FIELD_FEAT_ABS_POINTER,
+  GCSPRINTF("%u", vkb->feature_abs_pointer));
+}
+
+if (vkb->feature_raw_pointer) {
+flexarray_append_pair(back, XENKBD_FIELD_FEAT_RAW_POINTER,
+  GCSPRINTF("%u", vkb->feature_raw_pointer));
+}
+
+if (vkb->feature_multi_touch) {
+flexarray_append_pair(back, XENKBD_FIELD_FEAT_MTOUCH,
+  GCSPRINTF("%u", vkb->feature_multi_touch));
+flexarray_append_pair(back, XENKBD_FIELD_MT_WIDTH,
+  GCSPRINTF("%u", vkb->multi_touch_width));
+flexarray_append_pair(back, XENKBD_FIELD_MT_HEIGHT,
+  GCSPRINTF("%u", vkb->multi_touch_height));
+flexarray_append_pair(back, XENKBD_FIELD_MT_NUM_CONTACTS,
+  GCSPRINTF("%u", vkb->multi_touch_num_contacts));
+}
+
+if (vkb->width) {
+flexarray_append_pair(back, XENKBD_FIELD_WIDTH,
+  GCSPRINTF("%u", vkb->width));
+}
+
+if (vkb->height) {
+flexarray_append_pair(back, XENKBD_FIELD_HEIGHT,
+  GCSPRINTF("%u", vkb->height));
+}
+
 return 0;
 }
 
@@ -54,7 +95,7 @@ static int libxl__vkb_from_xenstore(libxl__gc *gc, const char 
*libxl_path,
 libxl_devid devid,
 libxl_device_vkb *vkb)
 {
-const char *be_path, *b

[Xen-devel] [PATCH v2 3/6] libxl: vkb add list and info functions

2018-06-12 Thread Oleksandr Grytsov
From: Oleksandr Grytsov 

Signed-off-by: Oleksandr Grytsov 
Acked-by: Wei Liu 
---
 tools/libxl/libxl.h |  10 +++
 tools/libxl/libxl_types.idl |  11 
 tools/libxl/libxl_utils.h   |   3 +
 tools/libxl/libxl_vkb.c | 127 +++-
 4 files changed, 149 insertions(+), 2 deletions(-)

diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index a09d069358..123b46078b 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -2013,6 +2013,16 @@ int libxl_device_vkb_destroy(libxl_ctx *ctx, uint32_t 
domid,
  const libxl_asyncop_how *ao_how)
 LIBXL_EXTERNAL_CALLERS_ONLY;
 
+libxl_device_vkb *libxl_device_vkb_list(libxl_ctx *ctx,
+uint32_t domid, int *num)
+LIBXL_EXTERNAL_CALLERS_ONLY;
+void libxl_device_vkb_list_free(libxl_device_vkb* list, int num)
+LIBXL_EXTERNAL_CALLERS_ONLY;
+int libxl_device_vkb_getinfo(libxl_ctx *ctx, uint32_t domid,
+ libxl_device_vkb *vkb,
+ libxl_vkbinfo *vkbinfo)
+ LIBXL_EXTERNAL_CALLERS_ONLY;
+
 /* Framebuffer */
 int libxl_device_vfb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb *vfb,
  const libxl_asyncop_how *ao_how)
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index 66c9444101..b7fa42fba0 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -963,6 +963,17 @@ libxl_vdisplinfo = Struct("vdisplinfo", [
 ("connectors", Array(libxl_connectorinfo, "num_connectors"))
 ], dir=DIR_OUT)
 
+libxl_vkbinfo = Struct("vkbinfo", [
+("backend", string),
+("backend_id", uint32),
+("frontend", string),
+("frontend_id", uint32),
+("devid", libxl_devid),
+("state", integer),
+("evtch", integer),
+("rref", integer)
+], dir=DIR_OUT)
+
 # NUMA node characteristics: size and free are how much memory it has, and how
 # much of it is free, respectively. dists is an array of distances from this
 # node to each other node.
diff --git a/tools/libxl/libxl_utils.h b/tools/libxl/libxl_utils.h
index 9e743dc598..91df06ec81 100644
--- a/tools/libxl/libxl_utils.h
+++ b/tools/libxl/libxl_utils.h
@@ -79,6 +79,9 @@ int libxl_devid_to_device_vtpm(libxl_ctx *ctx, uint32_t domid,
 int libxl_devid_to_device_usbctrl(libxl_ctx *ctx, uint32_t domid,
   int devid, libxl_device_usbctrl *usbctrl);
 
+int libxl_devid_to_device_vkb(libxl_ctx *ctx, uint32_t domid,
+  int devid, libxl_device_vkb *vkb);
+
 int libxl_devid_to_device_vdispl(libxl_ctx *ctx, uint32_t domid,
  int devid, libxl_device_vdispl *vdispl);
 
diff --git a/tools/libxl/libxl_vkb.c b/tools/libxl/libxl_vkb.c
index beaf17475d..d2ffc74c0d 100644
--- a/tools/libxl/libxl_vkb.c
+++ b/tools/libxl/libxl_vkb.c
@@ -50,6 +50,45 @@ static int libxl__set_xenstore_vkb(libxl__gc *gc, uint32_t 
domid,
 return 0;
 }
 
+static int libxl__vkb_from_xenstore(libxl__gc *gc, const char *libxl_path,
+libxl_devid devid,
+libxl_device_vkb *vkb)
+{
+const char *be_path, *be_type, *fe_path;
+int rc;
+
+vkb->devid = devid;
+
+rc = libxl__xs_read_mandatory(gc, XBT_NULL,
+  GCSPRINTF("%s/backend", libxl_path),
+  _path);
+if (rc) goto out;
+
+rc = libxl__xs_read_mandatory(gc, XBT_NULL,
+  GCSPRINTF("%s/frontend", libxl_path),
+  _path);
+if (rc) goto out;
+
+rc = libxl__backendpath_parse_domid(gc, be_path, >backend_domid);
+if (rc) goto out;
+
+rc = libxl__xs_read_mandatory(gc, XBT_NULL,
+  GCSPRINTF("%s/backend-type", be_path),
+  _type);
+if (rc) goto out;
+
+rc = libxl_vkb_backend_from_string(be_type, >backend_type);
+if (rc) goto out;
+
+vkb->unique_id = xs_read(CTX->xsh, XBT_NULL, 
GCSPRINTF("%s/"XENKBD_FIELD_UNIQUE_ID, be_path), NULL);
+
+rc = 0;
+
+out:
+
+return rc;
+}
+
 int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb,
  const libxl_asyncop_how *ao_how)
 {
@@ -67,20 +106,104 @@ out:
 return AO_INPROGRESS;
 }
 
+int libxl_devid_to_device_vkb(libxl_ctx *ctx, uint32_t domid,
+  int devid, libxl_device_vkb *vkb)
+{
+GC_INIT(ctx);
+
+libxl_device_vkb *vkbs = NULL;
+int n, i;
+int rc;
+
+libxl_device_vkb_init(vkb);
+
+vkbs = libxl__device_list(gc, __vkb_devtype, domid, 

[Xen-devel] [PATCH v2 0/6] libxl: create standalone vkb device

2018-06-12 Thread Oleksandr Grytsov
From: Oleksandr Grytsov 

Changes since initial:
 * id field is changed to unique_id in libxl_device_vkb to be comply
   with protocol;
 * use XENKBD_FIELD_... defines from protocol to address xen store entries
   and fields in domain config file;
 * add support of new protocol parameters:
- XENKBD_FIELD_FEAT_DSBL_KEYBRD
- XENKBD_FIELD_FEAT_DSBL_POINTER
- XENKBD_FIELD_FEAT_ABS_POINTER
- XENKBD_FIELD_FEAT_RAW_POINTER
- XENKBD_FIELD_FEAT_MTOUCH

Oleksandr Grytsov (6):
  libxl: move vkb device to libxl_vkb.c
  libxl: add backend type and id to vkb
  libxl: vkb add list and info functions
  xl: add vkb config parser and CLI
  docs: add vkb device to xl.cfg and xl
  libxl: vkb add extended parameters

 docs/man/xl.cfg.pod.5.in|  64 +++
 docs/man/xl.pod.1.in|  22 +++
 tools/libxl/Makefile|   2 +-
 tools/libxl/libxl.h |  10 ++
 tools/libxl/libxl_console.c |  53 --
 tools/libxl/libxl_create.c  |   3 +
 tools/libxl/libxl_dm.c  |   1 +
 tools/libxl/libxl_types.idl |  29 +++
 tools/libxl/libxl_utils.h   |   3 +
 tools/libxl/libxl_vkb.c | 346 
 tools/xl/Makefile   |   2 +-
 tools/xl/xl.h   |   3 +
 tools/xl/xl_cmdtable.c  |  16 ++
 tools/xl/xl_parse.c | 109 +++-
 tools/xl/xl_parse.h |   2 +-
 tools/xl/xl_vkb.c   | 161 +
 16 files changed, 769 insertions(+), 57 deletions(-)
 create mode 100644 tools/libxl/libxl_vkb.c
 create mode 100644 tools/xl/xl_vkb.c

-- 
2.17.1


___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

[Xen-devel] [PATCH v2 4/6] xl: add vkb config parser and CLI

2018-06-12 Thread Oleksandr Grytsov
From: Oleksandr Grytsov 

Signed-off-by: Oleksandr Grytsov 
Acked-by: Wei Liu 
---
 tools/xl/Makefile  |   2 +-
 tools/xl/xl.h  |   3 +
 tools/xl/xl_cmdtable.c |  16 +
 tools/xl/xl_parse.c|  76 -
 tools/xl/xl_parse.h|   2 +-
 tools/xl/xl_vkb.c  | 147 +
 6 files changed, 243 insertions(+), 3 deletions(-)
 create mode 100644 tools/xl/xl_vkb.c

diff --git a/tools/xl/Makefile b/tools/xl/Makefile
index a5117ab3fb..d34ec06420 100644
--- a/tools/xl/Makefile
+++ b/tools/xl/Makefile
@@ -22,7 +22,7 @@ XL_OBJS += xl_vtpm.o xl_block.o xl_nic.o xl_usb.o
 XL_OBJS += xl_sched.o xl_pci.o xl_vcpu.o xl_cdrom.o xl_mem.o
 XL_OBJS += xl_info.o xl_console.o xl_misc.o
 XL_OBJS += xl_vmcontrol.o xl_saverestore.o xl_migrate.o
-XL_OBJS += xl_vdispl.o
+XL_OBJS += xl_vdispl.o xl_vkb.o
 
 $(XL_OBJS): CFLAGS += $(CFLAGS_libxentoollog)
 $(XL_OBJS): CFLAGS += $(CFLAGS_XL)
diff --git a/tools/xl/xl.h b/tools/xl/xl.h
index 4e784ff402..47295b6772 100644
--- a/tools/xl/xl.h
+++ b/tools/xl/xl.h
@@ -170,6 +170,9 @@ int main_vtpmdetach(int argc, char **argv);
 int main_vdisplattach(int argc, char **argv);
 int main_vdispllist(int argc, char **argv);
 int main_vdispldetach(int argc, char **argv);
+int main_vkbattach(int argc, char **argv);
+int main_vkblist(int argc, char **argv);
+int main_vkbdetach(int argc, char **argv);
 int main_usbctrl_attach(int argc, char **argv);
 int main_usbctrl_detach(int argc, char **argv);
 int main_usbdev_attach(int argc, char **argv);
diff --git a/tools/xl/xl_cmdtable.c b/tools/xl/xl_cmdtable.c
index bf2ced8140..ceb08d65fc 100644
--- a/tools/xl/xl_cmdtable.c
+++ b/tools/xl/xl_cmdtable.c
@@ -15,6 +15,7 @@
 #include 
 
 #include 
+
 #include "xl.h"
 
 struct cmd_spec cmd_table[] = {
@@ -380,6 +381,21 @@ struct cmd_spec cmd_table[] = {
   "Destroy a domain's virtual TPM device",
   " ",
 },
+{ "vkb-attach",
+  _vkbattach, 1, 1,
+  "Create a new virtual keyboard device",
+  " ...",
+},
+{ "vkb-list",
+  _vkblist, 0, 0,
+  "List virtual keyboard devices for a domain",
+  "",
+},
+{ "vkb-detach",
+  _vkbdetach, 0, 1,
+  "Destroy a domain's virtual keyboard device",
+  " ",
+},
 { "vdispl-attach",
   _vdisplattach, 1, 1,
   "Create a new virtual display device",
diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c
index e6c54483e0..8b43a46889 100644
--- a/tools/xl/xl_parse.c
+++ b/tools/xl/xl_parse.c
@@ -19,6 +19,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -851,6 +852,77 @@ out:
 return rc;
 }
 
+int parse_vkb_config(libxl_device_vkb *vkb, char *token)
+{
+char *oparg;
+
+if (MATCH_OPTION("backend", token, oparg)) {
+vkb->backend_domname = strdup(oparg);
+} else if (MATCH_OPTION("backend-type", token, oparg)) {
+libxl_vkb_backend backend_type;
+if (libxl_vkb_backend_from_string(oparg, _type)) {
+fprintf(stderr, "Unknown backend_type \"%s\" in vkb spec\n",
+oparg);
+return -1;
+}
+vkb->backend_type = backend_type;
+} else if (MATCH_OPTION(XENKBD_FIELD_UNIQUE_ID, token, oparg)) {
+vkb->unique_id = strdup(oparg);
+} else {
+fprintf(stderr, "Unknown string \"%s\" in vkb spec\n", token);
+return -1;
+}
+
+return 0;
+}
+
+static void parse_vkb_list(const XLU_Config *config,
+   libxl_domain_config *d_config)
+{
+XLU_ConfigList *vkbs;
+const char *item;
+char *buf = NULL;
+int rc;
+
+if (!xlu_cfg_get_list (config, "vkb", , 0, 0)) {
+int entry = 0;
+while ((item = xlu_cfg_get_listitem(vkbs, entry)) != NULL) {
+libxl_device_vkb *vkb;
+char *p;
+
+vkb = ARRAY_EXTEND_INIT(d_config->vkbs,
+d_config->num_vkbs,
+libxl_device_vkb_init);
+
+buf = strdup(item);
+
+p = strtok (buf, ",");
+while (p != NULL)
+{
+while (*p == ' ') p++;
+
+rc = parse_vkb_config(vkb, p);
+if (rc) goto out;
+
+p = strtok (NULL, ",");
+}
+
+if (vkb->backend_type == LIBXL_VKB_BACKEND_UNKNOWN) {
+fprintf(stderr, "backend-type should be set in vkb spec\n");
+rc = -1; goto out;
+}
+
+entry++;
+}
+}
+
+rc = 0;
+
+out:
+free(buf);
+if (rc) exit(EXIT_FAILURE);
+}
+
 void parse_config_data(const char *config_source,
const char *config_data,

[Xen-devel] [PATCH v2 1/6] libxl: move vkb device to libxl_vkb.c

2018-06-12 Thread Oleksandr Grytsov
From: Oleksandr Grytsov 

Logically it is better to move vkb to
separate file as vkb device used not only by vfb
and console.

Signed-off-by: Oleksandr Grytsov 
Acked-by: Wei Liu 
---
 tools/libxl/Makefile|  2 +-
 tools/libxl/libxl_console.c | 53 -
 tools/libxl/libxl_vkb.c | 59 +
 3 files changed, 60 insertions(+), 54 deletions(-)
 create mode 100644 tools/libxl/libxl_vkb.c

diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile
index 035e66e22e..c6eb5e77fa 100644
--- a/tools/libxl/Makefile
+++ b/tools/libxl/Makefile
@@ -140,7 +140,7 @@ LIBXL_OBJS = flexarray.o libxl.o libxl_create.o libxl_dm.o 
libxl_pci.o \
libxl_vtpm.o libxl_nic.o libxl_disk.o libxl_console.o \
libxl_cpupool.o libxl_mem.o libxl_sched.o libxl_tmem.o \
libxl_9pfs.o libxl_domain.o libxl_vdispl.o \
-libxl_pvcalls.o $(LIBXL_OBJS-y)
+libxl_pvcalls.o libxl_vkb.o $(LIBXL_OBJS-y)
 LIBXL_OBJS += libxl_genid.o
 LIBXL_OBJS += _libxl_types.o libxl_flask.o _libxl_types_internal.o
 
diff --git a/tools/libxl/libxl_console.c b/tools/libxl/libxl_console.c
index 9a02a23c2a..36d79f5adc 100644
--- a/tools/libxl/libxl_console.c
+++ b/tools/libxl/libxl_console.c
@@ -638,45 +638,6 @@ int libxl_device_channel_getinfo(libxl_ctx *ctx, uint32_t 
domid,
 return rc;
 }
 
-static int libxl__device_vkb_setdefault(libxl__gc *gc, uint32_t domid,
-libxl_device_vkb *vkb, bool hotplug)
-{
-return libxl__resolve_domid(gc, vkb->backend_domname, >backend_domid);
-}
-
-static int libxl__device_from_vkb(libxl__gc *gc, uint32_t domid,
-  libxl_device_vkb *vkb,
-  libxl__device *device)
-{
-device->backend_devid = vkb->devid;
-device->backend_domid = vkb->backend_domid;
-device->backend_kind = LIBXL__DEVICE_KIND_VKBD;
-device->devid = vkb->devid;
-device->domid = domid;
-device->kind = LIBXL__DEVICE_KIND_VKBD;
-
-return 0;
-}
-
-int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb,
- const libxl_asyncop_how *ao_how)
-{
-AO_CREATE(ctx, domid, ao_how);
-int rc;
-
-rc = libxl__device_add(gc, domid, __vkb_devtype, vkb);
-if (rc) {
-LOGD(ERROR, domid, "Unable to add vkb device");
-goto out;
-}
-
-out:
-libxl__ao_complete(egc, ao, rc);
-return AO_INPROGRESS;
-}
-
-static LIBXL_DEFINE_UPDATE_DEVID(vkb)
-
 static int libxl__device_vfb_setdefault(libxl__gc *gc, uint32_t domid,
 libxl_device_vfb *vfb, bool hotplug)
 {
@@ -746,8 +707,6 @@ static int libxl__set_xenstore_vfb(libxl__gc *gc, uint32_t 
domid,
 }
 
 /* The following functions are defined:
- * libxl_device_vkb_remove
- * libxl_device_vkb_destroy
  * libxl_device_vfb_remove
  * libxl_device_vfb_destroy
  */
@@ -756,18 +715,6 @@ static int libxl__set_xenstore_vfb(libxl__gc *gc, uint32_t 
domid,
  * 1. add support for secondary consoles to xenconsoled
  * 2. dynamically add/remove qemu chardevs via qmp messages. */
 
-/* vkb */
-
-#define libxl__add_vkbs NULL
-#define libxl_device_vkb_list NULL
-#define libxl_device_vkb_compare NULL
-
-LIBXL_DEFINE_DEVICE_REMOVE(vkb)
-
-DEFINE_DEVICE_TYPE_STRUCT(vkb, VKBD,
-.skip_attach = 1
-);
-
 #define libxl__add_vfbs NULL
 #define libxl_device_vfb_list NULL
 #define libxl_device_vfb_compare NULL
diff --git a/tools/libxl/libxl_vkb.c b/tools/libxl/libxl_vkb.c
new file mode 100644
index 00..7652ad23ce
--- /dev/null
+++ b/tools/libxl/libxl_vkb.c
@@ -0,0 +1,59 @@
+/*
+ * Copyright (C) 2016 EPAM Systems Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ */
+
+#include "libxl_internal.h"
+
+static int libxl__device_vkb_setdefault(libxl__gc *gc, uint32_t domid,
+libxl_device_vkb *vkb, bool hotplug)
+{
+return libxl__resolve_domid(gc, vkb->backend_domname, >backend_domid);
+}
+
+int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb,
+ const libxl_asyncop_how *ao_how)
+{
+AO_CREATE(ctx, domid, ao_how);
+int rc;
+
+rc = libxl__device_add(gc, domid, __vkb_devtype, vkb);
+if (rc) {
+LOGD(ERROR, domid, "Unable to add vkb device");
+goto out;
+}
+

[Xen-devel] [PATCH v2 5/6] docs: add vkb device to xl.cfg and xl

2018-06-12 Thread Oleksandr Grytsov
From: Oleksandr Grytsov 

Signed-off-by: Oleksandr Grytsov 
Acked-by: Wei Liu 
---
 docs/man/xl.cfg.pod.5.in | 24 
 docs/man/xl.pod.1.in | 22 ++
 2 files changed, 46 insertions(+)

diff --git a/docs/man/xl.cfg.pod.5.in b/docs/man/xl.cfg.pod.5.in
index 47d88243b1..d9d321d027 100644
--- a/docs/man/xl.cfg.pod.5.in
+++ b/docs/man/xl.cfg.pod.5.in
@@ -1414,6 +1414,30 @@ we may break backward compatibility.
 
 =back
 
+=item B
+
+Specifies the virtual keyboard device to be provided to the guest.
+
+Each B is a comma-separated list of C
+settings from the following list:
+
+=over 4
+
+=item B
+
+Specifies the unique input device id.
+
+=item B
+
+Specifies the backend domain name or id.
+
+=item B
+
+Specifies the backend type: qemu - for QEMU backend or linux - for Linux PV
+domain.
+
+=back
+
 =back
 
 =head2 Paravirtualised (PV) Guest Specific Options
diff --git a/docs/man/xl.pod.1.in b/docs/man/xl.pod.1.in
index 48da2052cc..6ae281a4c4 100644
--- a/docs/man/xl.pod.1.in
+++ b/docs/man/xl.pod.1.in
@@ -1492,6 +1492,28 @@ List virtual displays for a domain.
 
 =back
 
+=head2 KEYBOARD DEVICES
+
+=over 4
+
+=item B I I
+
+Creates a new keyboard device in the domain specified by I.
+I describes the device to attach, using the same format as the
+B string in the domain config file. See L
+for more informations.
+
+=item B I I
+
+Removes the keyboard device from the domain specified by I.
+I is the virtual interface device number within the domain
+
+=item B I
+
+List virtual network interfaces for a domain.
+
+=back
+
 =head1 PCI PASS-THROUGH
 
 =over 4
-- 
2.17.1


___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

[Xen-devel] [PATCH v2 2/6] libxl: add backend type and id to vkb

2018-06-12 Thread Oleksandr Grytsov
From: Oleksandr Grytsov 

New field backend_type is added to vkb device
in order to have QEMU and user space backend
simultaneously. Each vkb backend shall read
appropriate XS entry and service only own
frontends.
Id is a string field which used by the backend
to indentify the frontend.

Signed-off-by: Oleksandr Grytsov 
---
 tools/libxl/libxl_create.c  |  3 +++
 tools/libxl/libxl_dm.c  |  1 +
 tools/libxl/libxl_types.idl |  8 
 tools/libxl/libxl_vkb.c | 35 ++-
 4 files changed, 46 insertions(+), 1 deletion(-)

diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index b5e27a7766..70029600af 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -1421,6 +1421,9 @@ static void domcreate_launch_dm(libxl__egc *egc, 
libxl__multidev *multidev,
 for (i = 0; i < d_config->num_vfbs; i++) {
 libxl__device_add(gc, domid, __vfb_devtype,
   _config->vfbs[i]);
+}
+
+for (i = 0; i < d_config->num_vkbs; i++) {
 libxl__device_add(gc, domid, __vkb_devtype,
   _config->vkbs[i]);
 }
diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
index 18ada69e8b..2362ecdce9 100644
--- a/tools/libxl/libxl_dm.c
+++ b/tools/libxl/libxl_dm.c
@@ -1786,6 +1786,7 @@ static int 
libxl__vfb_and_vkb_from_hvm_guest_config(libxl__gc *gc,
 
 vkb->backend_domid = 0;
 vkb->devid = 0;
+
 return 0;
 }
 
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index 01ec1d1afa..66c9444101 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -247,6 +247,12 @@ libxl_vuart_type = Enumeration("vuart_type", [
 (1, "sbsa_uart"),
 ])
 
+libxl_vkb_backend = Enumeration("vkb_backend", [
+(0, "UNKNOWN"),
+(1, "QEMU"),
+(2, "LINUX")
+])
+
 #
 # Complex libxl types
 #
@@ -626,6 +632,8 @@ libxl_device_vkb = Struct("device_vkb", [
 ("backend_domid", libxl_domid),
 ("backend_domname", string),
 ("devid", libxl_devid),
+("backend_type", libxl_vkb_backend),
+("unique_id", string)
 ])
 
 libxl_device_disk = Struct("device_disk", [
diff --git a/tools/libxl/libxl_vkb.c b/tools/libxl/libxl_vkb.c
index 7652ad23ce..beaf17475d 100644
--- a/tools/libxl/libxl_vkb.c
+++ b/tools/libxl/libxl_vkb.c
@@ -14,12 +14,42 @@
 
 #include "libxl_internal.h"
 
+#include 
+
 static int libxl__device_vkb_setdefault(libxl__gc *gc, uint32_t domid,
 libxl_device_vkb *vkb, bool hotplug)
 {
+if (vkb->backend_type == LIBXL_VKB_BACKEND_UNKNOWN) {
+vkb->backend_type = LIBXL_VKB_BACKEND_QEMU;
+}
+
 return libxl__resolve_domid(gc, vkb->backend_domname, >backend_domid);
 }
 
+static int libxl__device_vkb_dm_needed(libxl_device_vkb *vkb, uint32_t domid)
+{
+   if (vkb->backend_type == LIBXL_VKB_BACKEND_QEMU) {
+return 1;
+   }
+
+return 0;
+}
+
+static int libxl__set_xenstore_vkb(libxl__gc *gc, uint32_t domid,
+   libxl_device_vkb *vkb,
+   flexarray_t *back, flexarray_t *front,
+   flexarray_t *ro_front)
+{
+flexarray_append_pair(back, "backend-type",
+  (char 
*)libxl_vkb_backend_to_string(vkb->backend_type));
+
+if (vkb->unique_id) {
+flexarray_append_pair(back, XENKBD_FIELD_UNIQUE_ID, vkb->unique_id);
+}
+
+return 0;
+}
+
 int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb,
  const libxl_asyncop_how *ao_how)
 {
@@ -47,7 +77,10 @@ static LIBXL_DEFINE_UPDATE_DEVID(vkb)
 LIBXL_DEFINE_DEVICE_REMOVE(vkb)
 
 DEFINE_DEVICE_TYPE_STRUCT(vkb, VKBD,
-.skip_attach = 1
+.skip_attach = 1,
+.dm_needed = (device_dm_needed_fn_t)libxl__device_vkb_dm_needed,
+.set_xenstore_config = (device_set_xenstore_config_fn_t)
+   libxl__set_xenstore_vkb
 );
 
 /*
-- 
2.17.1


___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

[Xen-devel] [PATCH v2 3/5] xl: add PV sound condif parser

2018-05-18 Thread Oleksandr Grytsov
From: Oleksandr Grytsov <oleksandr_gryt...@epam.com>

Add config parser for virtual sound devices

Signed-off-by: Oleksandr Grytsov <oleksandr_gryt...@epam.com>
Acked-by: Wei Liu <wei.l...@citrix.com>
---
 tools/xl/xl_parse.c | 246 
 tools/xl/xl_parse.h |   1 +
 2 files changed, 247 insertions(+)

diff --git a/tools/xl/xl_parse.c b/tools/xl/xl_parse.c
index e6c54483e0..b9e8e1f997 100644
--- a/tools/xl/xl_parse.c
+++ b/tools/xl/xl_parse.c
@@ -851,6 +851,250 @@ out:
 return rc;
 }
 
+static int parse_vsnd_params(libxl_vsnd_params *params, char *token)
+{
+char *oparg;
+int i;
+
+if (MATCH_OPTION("sample-rates", token, oparg)) {
+libxl_string_list rates = NULL;
+
+split_string_into_string_list(oparg, ";", );
+
+params->num_sample_rates = libxl_string_list_length();
+params->sample_rates = calloc(params->num_sample_rates,
+  sizeof(*params->sample_rates));
+
+for (i = 0; i < params->num_sample_rates; i++) {
+params->sample_rates[i] = strtoul(rates[i], NULL, 0);
+}
+
+libxl_string_list_dispose();
+} else if (MATCH_OPTION("sample-formats", token, oparg)) {
+libxl_string_list formats = NULL;
+
+split_string_into_string_list(oparg, ";", );
+
+params->num_sample_formats = libxl_string_list_length();
+params->sample_formats = calloc(params->num_sample_formats,
+sizeof(*params->sample_formats));
+
+for (i = 0; i < params->num_sample_formats; i++) {
+libxl_vsnd_pcm_format format;
+
+if (libxl_vsnd_pcm_format_from_string(formats[i], )) {
+fprintf(stderr, "Invalid pcm format: %s\n", formats[i]);
+exit(EXIT_FAILURE);
+}
+
+params->sample_formats[i] = format;
+}
+
+libxl_string_list_dispose();
+} else if (MATCH_OPTION("channels-min", token, oparg)) {
+params->channels_min = strtoul(oparg, NULL, 0);
+} else if (MATCH_OPTION("channels-max", token, oparg)) {
+params->channels_max = strtoul(oparg, NULL, 0);
+} else if (MATCH_OPTION("buffer-size", token, oparg)) {
+params->buffer_size = strtoul(oparg, NULL, 0);
+} else {
+return 1;
+}
+
+return 0;
+}
+
+static int parse_vsnd_pcm_stream(libxl_device_vsnd *vsnd, char *param)
+{
+if (vsnd->num_vsnd_pcms == 0) {
+fprintf(stderr, "No vsnd pcm device\n");
+return -1;
+}
+
+libxl_vsnd_pcm *pcm = >pcms[vsnd->num_vsnd_pcms - 1];
+
+if (pcm->num_vsnd_streams == 0) {
+fprintf(stderr, "No vsnd stream\n");
+return -1;
+}
+
+libxl_vsnd_stream *stream = >streams[pcm->num_vsnd_streams - 1];
+
+if (parse_vsnd_params(>params, param)) {
+char *oparg;
+
+if (MATCH_OPTION("id", param, oparg)) {
+stream->id = strdup(oparg);
+} else if (MATCH_OPTION("type", param, oparg)) {
+
+if (libxl_vsnd_stream_type_from_string(oparg, >type)) {
+fprintf(stderr, "Invalid stream type: %s\n", oparg);
+return -1;
+}
+} else {
+fprintf(stderr, "Invalid parameter: %s\n", param);
+return -1;
+}
+}
+
+return 0;
+}
+
+static int parse_vsnd_pcm_param(libxl_device_vsnd *vsnd, char *param)
+{
+if (vsnd->num_vsnd_pcms == 0) {
+fprintf(stderr, "No pcm device\n");
+return -1;
+}
+
+libxl_vsnd_pcm *pcm = >pcms[vsnd->num_vsnd_pcms - 1];
+
+if (parse_vsnd_params(>params, param)) {
+char *oparg;
+
+if (MATCH_OPTION("name", param, oparg)) {
+pcm->name = strdup(oparg);
+} else {
+fprintf(stderr, "Invalid parameter: %s\n", param);
+return -1;
+}
+}
+
+return 0;
+}
+
+static int parse_vsnd_card_param(libxl_device_vsnd *vsnd, char *param)
+{
+if (parse_vsnd_params(>params, param)) {
+char *oparg;
+
+if (MATCH_OPTION("backend", param, oparg)) {
+vsnd->backend_domname = strdup(oparg);
+} else if (MATCH_OPTION("short-name", param, oparg)) {
+vsnd->short_name = strdup(oparg);
+} else if (MATCH_OPTION("long-name", param, oparg)) {
+vsnd->long_name = strdup(oparg);
+} else {
+fprintf(stderr, "Invalid parameter: %s\n", param);
+return -1;
+}
+}
+
+return 0;
+}
+
+static int parse_vsnd_create_item(libxl_device_vsnd *vsnd, const char *key)
+{
+if (strcasecmp(key, "card") 

[Xen-devel] [PATCH v2 4/5] xl: add vsnd CLI commands

2018-05-18 Thread Oleksandr Grytsov
From: Oleksandr Grytsov <oleksandr_gryt...@epam.com>

Add CLI commands to attach, detach and list virtual sound devices

Signed-off-by: Oleksandr Grytsov <oleksandr_gryt...@epam.com>
Acked-by: Wei Liu <wei.l...@citrix.com>
---
 tools/xl/Makefile  |   2 +-
 tools/xl/xl.h  |   3 +
 tools/xl/xl_cmdtable.c |  15 +++
 tools/xl/xl_vsnd.c | 203 +
 4 files changed, 222 insertions(+), 1 deletion(-)
 create mode 100644 tools/xl/xl_vsnd.c

diff --git a/tools/xl/Makefile b/tools/xl/Makefile
index a5117ab3fb..66bdbdef13 100644
--- a/tools/xl/Makefile
+++ b/tools/xl/Makefile
@@ -22,7 +22,7 @@ XL_OBJS += xl_vtpm.o xl_block.o xl_nic.o xl_usb.o
 XL_OBJS += xl_sched.o xl_pci.o xl_vcpu.o xl_cdrom.o xl_mem.o
 XL_OBJS += xl_info.o xl_console.o xl_misc.o
 XL_OBJS += xl_vmcontrol.o xl_saverestore.o xl_migrate.o
-XL_OBJS += xl_vdispl.o
+XL_OBJS += xl_vdispl.o xl_vsnd.o
 
 $(XL_OBJS): CFLAGS += $(CFLAGS_libxentoollog)
 $(XL_OBJS): CFLAGS += $(CFLAGS_XL)
diff --git a/tools/xl/xl.h b/tools/xl/xl.h
index 4e784ff402..a6b85f6db2 100644
--- a/tools/xl/xl.h
+++ b/tools/xl/xl.h
@@ -170,6 +170,9 @@ int main_vtpmdetach(int argc, char **argv);
 int main_vdisplattach(int argc, char **argv);
 int main_vdispllist(int argc, char **argv);
 int main_vdispldetach(int argc, char **argv);
+int main_vsndattach(int argc, char **argv);
+int main_vsndlist(int argc, char **argv);
+int main_vsnddetach(int argc, char **argv);
 int main_usbctrl_attach(int argc, char **argv);
 int main_usbctrl_detach(int argc, char **argv);
 int main_usbdev_attach(int argc, char **argv);
diff --git a/tools/xl/xl_cmdtable.c b/tools/xl/xl_cmdtable.c
index bf2ced8140..10426a2ffd 100644
--- a/tools/xl/xl_cmdtable.c
+++ b/tools/xl/xl_cmdtable.c
@@ -399,6 +399,21 @@ struct cmd_spec cmd_table[] = {
   "Destroy a domain's virtual display device",
   " ",
 },
+{ "vsnd-attach",
+  _vsndattach, 1, 1,
+  "Create a new virtual sound device",
+  " <vsnd-spec-component(s)>...",
+},
+{ "vsnd-list",
+  _vsndlist, 0, 0,
+  "List virtual display devices for a domain",
+  "<Domain(s)>",
+},
+{ "vsnd-detach",
+  _vsnddetach, 0, 1,
+  "Destroy a domain's virtual sound device",
+  " ",
+},
 { "uptime",
   _uptime, 0, 0,
   "Print uptime for all/some domains",
diff --git a/tools/xl/xl_vsnd.c b/tools/xl/xl_vsnd.c
new file mode 100644
index 00..41ee0ba5fe
--- /dev/null
+++ b/tools/xl/xl_vsnd.c
@@ -0,0 +1,203 @@
+/*
+ * Copyright (C) 2016 EPAM Systems Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU Lesser General Public License as published
+ * by the Free Software Foundation; version 2.1 only. with the special
+ * exception on linking described in file LICENSE.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU Lesser General Public License for more details.
+ */
+
+#include 
+
+#include 
+#include 
+#include 
+
+#include "xl.h"
+#include "xl_utils.h"
+#include "xl_parse.h"
+
+int main_vsndattach(int argc, char **argv)
+{
+int opt;
+int rc;
+uint32_t domid;
+libxl_device_vsnd vsnd;
+
+SWITCH_FOREACH_OPT(opt, "", NULL, "vsnd-attach", 2) {
+/* No options */
+}
+
+libxl_device_vsnd_init();
+domid = find_domain(argv[optind++]);
+
+for (argv += optind, argc -= optind; argc > 0; ++argv, --argc) {
+rc = parse_vsnd_item(, *argv);
+if (rc) goto out;
+}
+
+if (dryrun_only) {
+char *json = libxl_device_vsnd_to_json(ctx, );
+printf("vsnd: %s\n", json);
+free(json);
+goto out;
+}
+
+if (libxl_device_vsnd_add(ctx, domid, , 0)) {
+fprintf(stderr, "libxl_device_vsnd_add failed.\n");
+rc = ERROR_FAIL; goto out;
+}
+
+rc = 0;
+
+out:
+libxl_device_vsnd_dispose();
+return rc;
+}
+
+static void print_params(libxl_vsnd_params *params)
+{
+int i;
+
+if (params->channels_min) {
+printf(", channels-min: %u", params->channels_min);
+}
+
+if (params->channels_max) {
+printf(", channels-max: %u", params->channels_max);
+}
+
+if (params->buffer_size) {
+printf(", buffer-size: %u", params->buffer_size);
+}
+
+if (params->num_sample_rates) {
+printf(", sample-rates: ");
+for (i = 0; i < params->num_sample_rates - 1; i++) {
+printf("%u;", params->sample_rates[i]);
+}
+printf("%u", params->samp

[Xen-devel] [PATCH v2 2/5] libxl: add vsnd list and info

2018-05-18 Thread Oleksandr Grytsov
From: Oleksandr Grytsov <oleksandr_gryt...@epam.com>

Add getting vsnd list amd info API

Signed-off-by: Oleksandr Grytsov <oleksandr_gryt...@epam.com>
---
 tools/libxl/libxl.h |  10 +
 tools/libxl/libxl_types.idl |  19 ++
 tools/libxl/libxl_utils.h   |   3 +
 tools/libxl/libxl_vsnd.c| 374 +++-
 4 files changed, 403 insertions(+), 3 deletions(-)

diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index a312166b48..bfc788594c 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -2014,6 +2014,16 @@ int libxl_device_vsnd_destroy(libxl_ctx *ctx, uint32_t 
domid,
   const libxl_asyncop_how *ao_how)
   LIBXL_EXTERNAL_CALLERS_ONLY;
 
+libxl_device_vsnd *libxl_device_vsnd_list(libxl_ctx *ctx,
+  uint32_t domid, int *num)
+  LIBXL_EXTERNAL_CALLERS_ONLY;
+void libxl_device_vsnd_list_free(libxl_device_vsnd* list, int num)
+ LIBXL_EXTERNAL_CALLERS_ONLY;
+int libxl_device_vsnd_getinfo(libxl_ctx *ctx, uint32_t domid,
+  libxl_device_vsnd *vsnd,
+  libxl_vsndinfo *vsndlinfo)
+  LIBXL_EXTERNAL_CALLERS_ONLY;
+
 /* Keyboard */
 int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb,
  const libxl_asyncop_how *ao_how)
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index ad978fb413..d959127dc2 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -1019,6 +1019,25 @@ libxl_vdisplinfo = Struct("vdisplinfo", [
 ("connectors", Array(libxl_connectorinfo, "num_connectors"))
 ], dir=DIR_OUT)
 
+libxl_streaminfo = Struct("streaminfo", [
+("req_evtch", integer),
+("req_rref", integer)
+])
+
+libxl_pcminfo = Struct("pcminfo", [
+("streams", Array(libxl_streaminfo, "num_vsnd_streams"))
+])
+
+libxl_vsndinfo = Struct("vsndinfo", [
+("backend", string),
+("backend_id", uint32),
+("frontend", string),
+("frontend_id", uint32),
+("devid", libxl_devid),
+("state", integer),
+("pcms", Array(libxl_pcminfo, "num_vsnd_pcms"))
+])
+
 # NUMA node characteristics: size and free are how much memory it has, and how
 # much of it is free, respectively. dists is an array of distances from this
 # node to each other node.
diff --git a/tools/libxl/libxl_utils.h b/tools/libxl/libxl_utils.h
index 9e743dc598..5455752c6e 100644
--- a/tools/libxl/libxl_utils.h
+++ b/tools/libxl/libxl_utils.h
@@ -82,6 +82,9 @@ int libxl_devid_to_device_usbctrl(libxl_ctx *ctx, uint32_t 
domid,
 int libxl_devid_to_device_vdispl(libxl_ctx *ctx, uint32_t domid,
  int devid, libxl_device_vdispl *vdispl);
 
+int libxl_devid_to_device_vsnd(libxl_ctx *ctx, uint32_t domid,
+   int devid, libxl_device_vsnd *vsnd);
+
 int libxl_ctrlport_to_device_usbdev(libxl_ctx *ctx, uint32_t domid,
 int ctrl, int port,
 libxl_device_usbdev *usbdev);
diff --git a/tools/libxl/libxl_vsnd.c b/tools/libxl/libxl_vsnd.c
index 1e19217811..b188eb2fb3 100644
--- a/tools/libxl/libxl_vsnd.c
+++ b/tools/libxl/libxl_vsnd.c
@@ -37,22 +37,247 @@ static int libxl__device_from_vsnd(libxl__gc *gc, uint32_t 
domid,
return 0;
 }
 
+static int libxl__sample_rates_from_string(libxl__gc *gc, const char *str,
+   libxl_vsnd_params *params)
+{
+char *tmp = libxl__strdup(gc, str);
+
+params->num_sample_rates = 0;
+params->sample_rates = NULL;
+
+char *p = strtok(tmp, " ,");
+
+while (p != NULL) {
+params->sample_rates = libxl__realloc(NOGC, params->sample_rates,
+  sizeof(*params->sample_rates) *
+  (params->num_sample_rates + 1));
+params->sample_rates[params->num_sample_rates++] = strtoul(p, NULL, 0);
+p = strtok(NULL, " ,");
+}
+
+return 0;
+}
+
+static int libxl__sample_formats_from_string(libxl__gc *gc, const char *str,
+ libxl_vsnd_params *params)
+{
+int rc;
+char *tmp = libxl__strdup(gc, str);
+
+params->num_sample_formats = 0;
+params->sample_formats = NULL;
+
+char *p = strtok(tmp, " ,");
+
+while (p != NULL) {
+params->sample_formats = libxl__realloc(NOGC, params->sample_formats,
+
sizeof(*params->sample_formats) *
+ 

[Xen-devel] [PATCH v2 5/5] docs: add PV sound device config

2018-05-18 Thread Oleksandr Grytsov
From: Oleksandr Grytsov <oleksandr_gryt...@epam.com>

Update documentation with virtual sound device

Signed-off-by: Oleksandr Grytsov <oleksandr_gryt...@epam.com>
Acked-by: Wei Liu <wei.l...@citrix.com>
---
 docs/man/xl.cfg.pod.5.in | 149 +++
 docs/man/xl.pod.1.in |  30 
 2 files changed, 179 insertions(+)

diff --git a/docs/man/xl.cfg.pod.5.in b/docs/man/xl.cfg.pod.5.in
index 47d88243b1..f96bd1b9ad 100644
--- a/docs/man/xl.cfg.pod.5.in
+++ b/docs/man/xl.cfg.pod.5.in
@@ -1414,6 +1414,155 @@ we may break backward compatibility.
 
 =back
 
+=item B

[Xen-devel] [PATCH v2 1/5] libxl: add PV sound device

2018-05-18 Thread Oleksandr Grytsov
From: Oleksandr Grytsov <oleksandr_gryt...@epam.com>

Add PV sound device described in sndif.h

Signed-off-by: Oleksandr Grytsov <oleksandr_gryt...@epam.com>
Acked-by: Wei Liu <wei.l...@citrix.com>
---
 tools/libxl/Makefile |   2 +-
 tools/libxl/libxl.h  |  14 ++
 tools/libxl/libxl_create.c   |   1 +
 tools/libxl/libxl_internal.h |   1 +
 tools/libxl/libxl_types.idl  |  64 ++
 tools/libxl/libxl_types_internal.idl |   1 +
 tools/libxl/libxl_vsnd.c | 331 +++
 7 files changed, 413 insertions(+), 1 deletion(-)
 create mode 100644 tools/libxl/libxl_vsnd.c

diff --git a/tools/libxl/Makefile b/tools/libxl/Makefile
index 035e66e22e..d60743d38b 100644
--- a/tools/libxl/Makefile
+++ b/tools/libxl/Makefile
@@ -140,7 +140,7 @@ LIBXL_OBJS = flexarray.o libxl.o libxl_create.o libxl_dm.o 
libxl_pci.o \
libxl_vtpm.o libxl_nic.o libxl_disk.o libxl_console.o \
libxl_cpupool.o libxl_mem.o libxl_sched.o libxl_tmem.o \
libxl_9pfs.o libxl_domain.o libxl_vdispl.o \
-libxl_pvcalls.o $(LIBXL_OBJS-y)
+   libxl_pvcalls.o libxl_vsnd.o $(LIBXL_OBJS-y)
 LIBXL_OBJS += libxl_genid.o
 LIBXL_OBJS += _libxl_types.o libxl_flask.o _libxl_types_internal.o
 
diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
index a09d069358..a312166b48 100644
--- a/tools/libxl/libxl.h
+++ b/tools/libxl/libxl.h
@@ -2000,6 +2000,20 @@ int libxl_device_vdispl_getinfo(libxl_ctx *ctx, uint32_t 
domid,
 libxl_vdisplinfo *vdisplinfo)
 LIBXL_EXTERNAL_CALLERS_ONLY;
 
+/* Virtual sounds */
+int libxl_device_vsnd_add(libxl_ctx *ctx, uint32_t domid,
+  libxl_device_vsnd *vsnd,
+  const libxl_asyncop_how *ao_how)
+  LIBXL_EXTERNAL_CALLERS_ONLY;
+int libxl_device_vsnd_remove(libxl_ctx *ctx, uint32_t domid,
+ libxl_device_vsnd *vsnd,
+ const libxl_asyncop_how *ao_how)
+ LIBXL_EXTERNAL_CALLERS_ONLY;
+int libxl_device_vsnd_destroy(libxl_ctx *ctx, uint32_t domid,
+  libxl_device_vsnd *vsnd,
+  const libxl_asyncop_how *ao_how)
+  LIBXL_EXTERNAL_CALLERS_ONLY;
+
 /* Keyboard */
 int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vkb *vkb,
  const libxl_asyncop_how *ao_how)
diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
index b5e27a7766..7d46824eac 100644
--- a/tools/libxl/libxl_create.c
+++ b/tools/libxl/libxl_create.c
@@ -1501,6 +1501,7 @@ const struct libxl_device_type *device_type_tbl[] = {
 __pcidev_devtype,
 __dtdev_devtype,
 __vdispl_devtype,
+__vsnd_devtype,
 NULL
 };
 
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index c582894589..17ac2083f6 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -3653,6 +3653,7 @@ extern const struct libxl_device_type 
libxl__pcidev_devtype;
 extern const struct libxl_device_type libxl__vdispl_devtype;
 extern const struct libxl_device_type libxl__p9_devtype;
 extern const struct libxl_device_type libxl__pvcallsif_devtype;
+extern const struct libxl_device_type libxl__vsnd_devtype;
 
 extern const struct libxl_device_type *device_type_tbl[];
 
diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
index 01ec1d1afa..ad978fb413 100644
--- a/tools/libxl/libxl_types.idl
+++ b/tools/libxl/libxl_types.idl
@@ -822,6 +822,69 @@ libxl_device_vdispl = Struct("device_vdispl", [
 ("connectors", Array(libxl_connector_param, "num_connectors"))
 ])
 
+libxl_vsnd_pcm_format = Enumeration("vsnd_pcm_format", [
+(1,  "S8"),
+(2,  "U8"),
+(3,  "S16_LE"),
+(4,  "S16_BE"),
+(5,  "U16_LE"),
+(6,  "U16_BE"),
+(7,  "S24_LE"),
+(8,  "S24_BE"),
+(9,  "U24_LE"),
+(10, "U24_BE"),
+(11, "S32_LE"),
+(12, "S32_BE"),
+(13, "U32_LE"),
+(14, "U32_BE"),
+(15, "F32_LE"),
+(16, "F32_BE"),
+(17, "F64_LE"),
+(18, "F64_BE"),
+(19, "IEC958_SUBFRAME_LE"),
+(20, "IEC958_SUBFRAME_BE"),
+(21, "MU_LAW"),
+(22, "A_LAW"),
+(23, "IMA_ADPCM"),
+(24, "MPEG"),
+(25, "GSM")
+])
+
+libxl_vsnd_params = Struct("vsnd_params", [
+("sample_rates", Array(uint32, "num_sample_rates")),
+("sample_formats", Array(libxl_vsnd_pcm_format, "num_sample_formats")),
+(&

Re: [Xen-devel] [PATCH] tools/xl: fix uninitialized variable in xl_vdispl

2018-03-13 Thread Oleksandr Grytsov
On Tue, Mar 13, 2018 at 10:03 AM, Jan Beulich <jbeul...@suse.com> wrote:

> >>> On 13.03.18 at 05:43, <car...@cardoe.com> wrote:
> > The code added in 7a48622a78a0b452e8afa55b8442c958abd226a7 could use rc
> > uninitialized in main_vdisplattach().
> >
> > Signed-off-by: Doug Goldstein <car...@cardoe.com>
> > ---
> > CC: Oleksandr Grytsov <oleksandr_gryt...@epam.com>
> > ---
> >  tools/xl/xl_vdispl.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
>
> Please trim your Cc list - I've removed all individuals here, and I
> don't see why you've copied all REST maintainers when this is
> clearly a pure tool stack change.
>
> Jan
>
>
> ___
> Xen-devel mailing list
> Xen-devel@lists.xenproject.org
> https://lists.xenproject.org/mailman/listinfo/xen-devel
>


Hi, Doug,

Thanks for pointing it out.

The implementation is done according to CODING_STYLE document (see ERROR
HANDLING)
which requests to define return value rc uninitialized. The only path where
rc is uninitialized it is
when dryrun_only set to true. So, proper fix should be:

if (dryrun_only) {
char *json = libxl_device_vdispl_to_json(ctx, );
    printf("vdispl: %s\n", json);
free(json);
+  rc = 0;
goto out;
}


-- 
Best Regards,
Oleksandr Grytsov.
___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH] libxl: add libxl__is_driver_domain function

2018-02-26 Thread Oleksandr Grytsov
On Fri, Feb 23, 2018 at 7:44 PM, Wei Liu <wei.l...@citrix.com> wrote:

> On Tue, Feb 13, 2018 at 03:32:04PM +0200, Oleksandr Grytsov wrote:
> > On Tue, Feb 13, 2018 at 2:06 PM, Wei Liu <wei.l...@citrix.com> wrote:
> >
> > > On Tue, Feb 06, 2018 at 03:08:45PM +0200, Oleksandr Grytsov wrote:
> > > > On Tue, Feb 6, 2018 at 2:36 PM, Wei Liu <wei.l...@citrix.com> wrote:
> > > >
> > > > > On Thu, Dec 14, 2017 at 04:14:12PM +0200, Oleksandr Grytsov wrote:
> > > > > > From: Oleksandr Grytsov <oleksandr_gryt...@epam.com>
> > > > > >
> > > > > > We have following arm-based setup:
> > > > > >
> > > > > > - Dom0 with xen and xen tools;
> > > > > > - Dom1 with device backends (but it is not the driver domain);
> > > > >
> > > > > What is your definition of a "driver domain"? What does it do in
> this
> > > > > case?
> > > > >
> > > > > I seem to have seen people use this term in different contexts to
> mean
> > > > > slightly different things. I need to figure out what you actually
> mean
> > > > > first.
> > > > >
> > > > >
> > > > I see in the libxl/xl sources that closing PV devices is done
> differently
> > > > in case backends are in Dom0 and are in other domain. It is called as
> > > > driver domain in the sources. So, I don't have clear understanding
> > > > what does it mean. In our setup backends are in Dom1 and xl is in
> Dom0.
> > > > And I see that xl dosn't close PV device on domain reboot or
> shutdown.
> > >
> > > Do you run xl devd in your backend domain?
> > >
> > > Wei.
> > >
> >
> > No I don't
>
> Can you try that? I think xl devd should clean up the stale entries --
> that's how we envisage driver domains to be used.
>
> Wei.
>

We will check this. Thanks.

-- 
Best Regards,
Oleksandr Grytsov.
___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH] libxl: add libxl__is_driver_domain function

2018-02-13 Thread Oleksandr Grytsov
On Tue, Feb 13, 2018 at 2:06 PM, Wei Liu <wei.l...@citrix.com> wrote:

> On Tue, Feb 06, 2018 at 03:08:45PM +0200, Oleksandr Grytsov wrote:
> > On Tue, Feb 6, 2018 at 2:36 PM, Wei Liu <wei.l...@citrix.com> wrote:
> >
> > > On Thu, Dec 14, 2017 at 04:14:12PM +0200, Oleksandr Grytsov wrote:
> > > > From: Oleksandr Grytsov <oleksandr_gryt...@epam.com>
> > > >
> > > > We have following arm-based setup:
> > > >
> > > > - Dom0 with xen and xen tools;
> > > > - Dom1 with device backends (but it is not the driver domain);
> > >
> > > What is your definition of a "driver domain"? What does it do in this
> > > case?
> > >
> > > I seem to have seen people use this term in different contexts to mean
> > > slightly different things. I need to figure out what you actually mean
> > > first.
> > >
> > >
> > I see in the libxl/xl sources that closing PV devices is done differently
> > in case backends are in Dom0 and are in other domain. It is called as
> > driver domain in the sources. So, I don't have clear understanding
> > what does it mean. In our setup backends are in Dom1 and xl is in Dom0.
> > And I see that xl dosn't close PV device on domain reboot or shutdown.
>
> Do you run xl devd in your backend domain?
>
> Wei.
>

No I don't

-- 
Best Regards,
Oleksandr Grytsov.
___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH v1 2/5] libxl: add vsnd list and info

2018-02-08 Thread Oleksandr Grytsov
On Tue, Feb 6, 2018 at 4:43 PM, Wei Liu <wei.l...@citrix.com> wrote:

> On Wed, Nov 01, 2017 at 05:04:44PM +0200, Oleksandr Grytsov wrote:
> > From: Oleksandr Grytsov <oleksandr_gryt...@epam.com>
> >
> > Add getting vsnd list amd info API
> >
> > Signed-off-by: Oleksandr Grytsov <oleksandr_gryt...@epam.com>
> > ---
> >  tools/libxl/libxl.h |  10 ++
> >  tools/libxl/libxl_types.idl |  19 +++
> >  tools/libxl/libxl_utils.h   |   3 +
> >  tools/libxl/libxl_vsnd.c| 375 ++
> +-
> >  4 files changed, 404 insertions(+), 3 deletions(-)
> >
> > diff --git a/tools/libxl/libxl.h b/tools/libxl/libxl.h
> > index 7200d49..acb73ce 100644
> > --- a/tools/libxl/libxl.h
> > +++ b/tools/libxl/libxl.h
> > @@ -1927,6 +1927,16 @@ int libxl_device_vsnd_destroy(libxl_ctx *ctx,
> uint32_t domid,
> >const libxl_asyncop_how *ao_how)
> >LIBXL_EXTERNAL_CALLERS_ONLY;
> >
> > +libxl_device_vsnd *libxl_device_vsnd_list(libxl_ctx *ctx,
> > +  uint32_t domid, int *num)
> > +  LIBXL_EXTERNAL_CALLERS_ONLY;
> > +void libxl_device_vsnd_list_free(libxl_device_vsnd* list, int num)
> > + LIBXL_EXTERNAL_CALLERS_ONLY;
> > +int libxl_device_vsnd_getinfo(libxl_ctx *ctx, uint32_t domid,
> > +  libxl_device_vsnd *vsnd,
> > +  libxl_vsndinfo *vsndlinfo)
> > +  LIBXL_EXTERNAL_CALLERS_ONLY;
> > +
> >  /* Keyboard */
> >  int libxl_device_vkb_add(libxl_ctx *ctx, uint32_t domid,
> libxl_device_vkb *vkb,
> >   const libxl_asyncop_how *ao_how)
> > diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
> > index aa30196..553e724 100644
> > --- a/tools/libxl/libxl_types.idl
> > +++ b/tools/libxl/libxl_types.idl
> > @@ -988,6 +988,25 @@ libxl_vdisplinfo = Struct("vdisplinfo", [
> >  ("connectors", Array(libxl_connectorinfo, "num_connectors"))
> >  ], dir=DIR_OUT)
> >
> > +libxl_streaminfo = Struct("streaminfo", [
> > +("req_evtch", integer),
> > +("req_rref", integer)
> > +])
> > +
> > +libxl_pcminfo = Struct("pcminfo", [
> > +("streams", Array(libxl_streaminfo, "num_vsnd_streams"))
> > +])
> > +
> > +libxl_vsndinfo = Struct("vsndinfo", [
> > +("backend", string),
> > +("backend_id", uint32),
> > +("frontend", string),
> > +("frontend_id", uint32),
> > +("devid", libxl_devid),
> > +("state", integer),
> > +("pcms", Array(libxl_pcminfo, "num_vsnd_pcms"))
> > +])
> > +
> >  # NUMA node characteristics: size and free are how much memory it has,
> and how
> >  # much of it is free, respectively. dists is an array of distances from
> this
> >  # node to each other node.
> > diff --git a/tools/libxl/libxl_utils.h b/tools/libxl/libxl_utils.h
> > index 9e743dc..5455752 100644
> > --- a/tools/libxl/libxl_utils.h
> > +++ b/tools/libxl/libxl_utils.h
> > @@ -82,6 +82,9 @@ int libxl_devid_to_device_usbctrl(libxl_ctx *ctx,
> uint32_t domid,
> >  int libxl_devid_to_device_vdispl(libxl_ctx *ctx, uint32_t domid,
> >   int devid, libxl_device_vdispl
> *vdispl);
> >
> > +int libxl_devid_to_device_vsnd(libxl_ctx *ctx, uint32_t domid,
> > +   int devid, libxl_device_vsnd *vsnd);
> > +
> >  int libxl_ctrlport_to_device_usbdev(libxl_ctx *ctx, uint32_t domid,
> >  int ctrl, int port,
> >  libxl_device_usbdev *usbdev);
> > diff --git a/tools/libxl/libxl_vsnd.c b/tools/libxl/libxl_vsnd.c
> > index 99e4be3..35f1aed 100644
> > --- a/tools/libxl/libxl_vsnd.c
> > +++ b/tools/libxl/libxl_vsnd.c
> > @@ -37,22 +37,247 @@ static int libxl__device_from_vsnd(libxl__gc *gc,
> uint32_t domid,
> > return 0;
> >  }
> >
> > +static int libxl__sample_rates_from_string(libxl__gc *gc, const char
> *str,
> > +   libxl_vsnd_params *params)
> > +{
> > +char *tmp = libxl__strdup(gc, str);
> > +
> > +params->num_sample_rates = 0;
> > +params->sam

Re: [Xen-devel] [PATCH v1 3/6] libxl: add backend type and id to vkb

2018-02-06 Thread Oleksandr Grytsov
On Tue, Feb 6, 2018 at 4:25 PM, Wei Liu <wei.l...@citrix.com> wrote:

> On Wed, Nov 01, 2017 at 05:05:04PM +0200, Oleksandr Grytsov wrote:
> > From: Oleksandr Grytsov <oleksandr_gryt...@epam.com>
> >
> > New field backend_type is added to vkb device
> > in order to have QEMU and user space backend
> > simultaneously. Each vkb backend shall read
> > appropriate XS entry and service only own
> > frontends.
> > Id is a string field which used by the backend
> > to indentify the frontend.
> >
> > Signed-off-by: Oleksandr Grytsov <oleksandr_gryt...@epam.com>
> > ---
> >  tools/libxl/libxl_create.c  |  3 +++
> >  tools/libxl/libxl_dm.c  |  1 +
> >  tools/libxl/libxl_types.idl |  8 
> >  tools/libxl/libxl_vkb.c | 33 -
> >  4 files changed, 44 insertions(+), 1 deletion(-)
> >
> > diff --git a/tools/libxl/libxl_create.c b/tools/libxl/libxl_create.c
> > index f813114..60d8686 100644
> > --- a/tools/libxl/libxl_create.c
> > +++ b/tools/libxl/libxl_create.c
> > @@ -1376,6 +1376,9 @@ static void domcreate_launch_dm(libxl__egc *egc,
> libxl__multidev *multidev,
> >  for (i = 0; i < d_config->num_vfbs; i++) {
> >  libxl__device_add(gc, domid, __vfb_devtype,
> >_config->vfbs[i]);
> > +}
> > +
> > +for (i = 0; i < d_config->num_vkbs; i++) {
> >  libxl__device_add(gc, domid, __vkb_devtype,
> >_config->vkbs[i]);
> >  }
> > diff --git a/tools/libxl/libxl_dm.c b/tools/libxl/libxl_dm.c
> > index 98f89a9..f07de35 100644
> > --- a/tools/libxl/libxl_dm.c
> > +++ b/tools/libxl/libxl_dm.c
> > @@ -1728,6 +1728,7 @@ static int 
> > libxl__vfb_and_vkb_from_hvm_guest_config(libxl__gc
> *gc,
> >
> >  vkb->backend_domid = 0;
> >  vkb->devid = 0;
> > +
>
> Stray change. I don't have objection though.
>
> >  return 0;
> >  }
> >
> > diff --git a/tools/libxl/libxl_types.idl b/tools/libxl/libxl_types.idl
> > index cd0c06f..c3876a2 100644
> > --- a/tools/libxl/libxl_types.idl
> > +++ b/tools/libxl/libxl_types.idl
> > @@ -240,6 +240,12 @@ libxl_checkpointed_stream =
> Enumeration("checkpointed_stream", [
> >  (2, "COLO"),
> >  ])
> >
> > +libxl_vkb_backend = Enumeration("vkb_backend", [
> > +(0, "UNKNOWN"),
> > +(1, "QEMU"),
> > +(2, "LINUX")
> > +])
> > +
> >  #
> >  # Complex libxl types
> >  #
> > @@ -603,6 +609,8 @@ libxl_device_vkb = Struct("device_vkb", [
> >  ("backend_domid", libxl_domid),
> >  ("backend_domname", string),
> >  ("devid", libxl_devid),
> > +("backend_type", libxl_vkb_backend),
> > +("id", string)
> >  ])
> >
> >  libxl_device_disk = Struct("device_disk", [
> > diff --git a/tools/libxl/libxl_vkb.c b/tools/libxl/libxl_vkb.c
> > index ea6fca8..88ab186 100644
> > --- a/tools/libxl/libxl_vkb.c
> > +++ b/tools/libxl/libxl_vkb.c
> > @@ -17,6 +17,10 @@
> >  static int libxl__device_vkb_setdefault(libxl__gc *gc, uint32_t domid,
> >  libxl_device_vkb *vkb, bool
> hotplug)
> >  {
> > +if (vkb->backend_type == LIBXL_VKB_BACKEND_UNKNOWN) {
> > +vkb->backend_type = LIBXL_VKB_BACKEND_QEMU;
> > +}
> > +
> >  return libxl__resolve_domid(gc, vkb->backend_domname,
> >backend_domid);
> >  }
> >
> > @@ -34,6 +38,30 @@ static int libxl__device_from_vkb(libxl__gc *gc,
> uint32_t domid,
> >  return 0;
> >  }
> >
> > +static int libxl__device_vkb_dm_needed(libxl_device_vkb *vkb, uint32_t
> domid)
> > +{
> > +   if (vkb->backend_type == LIBXL_VKB_BACKEND_QEMU) {
> > +    return 1;
> > +   }
>
> No need to have {} for a single statement here.
>
> > +
> > +return 0;
> > +}
> > +
> > +static int libxl__set_xenstore_vkb(libxl__gc *gc, uint32_t domid,
> > +   libxl_device_vkb *vkb,
> > +   flexarray_t *back, flexarray_t
> *front,
> > +   flexarray_t *ro_front)
> > +{
> > +if (vkb->id) {
> > +flexarray_append_pair(front, "id", vkb->id);
> > +}
> > +
>
> Ditto.
>
> And, isn't 0 a valid device id?
>
>
id here is char *. I put it to xenstore only if it is defined. It shall be
defined for linux backend
in case of multiple instances of kbd device are defined. The backend
distinguishes them
by id.

Wei.
>



-- 
Best Regards,
Oleksandr Grytsov.
___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH] libxl: add libxl__is_driver_domain function

2018-02-06 Thread Oleksandr Grytsov
On Tue, Feb 6, 2018 at 2:36 PM, Wei Liu <wei.l...@citrix.com> wrote:

> On Thu, Dec 14, 2017 at 04:14:12PM +0200, Oleksandr Grytsov wrote:
> > From: Oleksandr Grytsov <oleksandr_gryt...@epam.com>
> >
> > We have following arm-based setup:
> >
> > - Dom0 with xen and xen tools;
> > - Dom1 with device backends (but it is not the driver domain);
>
> What is your definition of a "driver domain"? What does it do in this
> case?
>
> I seem to have seen people use this term in different contexts to mean
> slightly different things. I need to figure out what you actually mean
> first.
>
>
I see in the libxl/xl sources that closing PV devices is done differently
in case backends are in Dom0 and are in other domain. It is called as
driver domain in the sources. So, I don't have clear understanding
what does it mean. In our setup backends are in Dom1 and xl is in Dom0.
And I see that xl dosn't close PV device on domain reboot or shutdown.


> > - Dom2 with device frontend;
> >
> > On Dom2 destroying we have timeout error. Because xl treats our
> > Dom1 as driver domain and waits for backend path to be cleared
> > by the driver domain which is not our case.
> >
> > According to libxl__domain_make in case of driver domain it has
> > "libxl" xen store entry:
> >
> > if (libxl_defbool_val(info->driver_domain)) {
> > /*
> >  * Create a local "libxl" directory for each guest, since we
> might want
> >  * to use libxl from inside the guest
> >  */
> > libxl__xs_mknod(gc, t, GCSPRINTF("%s/libxl", dom_path), rwperm,
> > ARRAY_SIZE(rwperm));
> >
> > This patch introduces libxl__is_driver_domain which determines the driver
> > domain by checking if "libxl" entry is present and uses this function on
> > device destroy to check by whom domain path should be cleaned up (libxl
> > or the driver domain).
> >
> > Oleksandr Grytsov (1):
> >   libxl: add libxl__is_driver_domain function
> >
> >  tools/libxl/libxl_device.c   | 17 ++---
> >  tools/libxl/libxl_internal.c | 16 
> >  tools/libxl/libxl_internal.h |  4 
> >  3 files changed, 30 insertions(+), 7 deletions(-)
> >
> > --
> > 2.7.4
> >
>



-- 
Best Regards,
Oleksandr Grytsov.
___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH v1 0/5] libxl: add PV sound device

2018-02-05 Thread Oleksandr Grytsov
On Tue, Jan 9, 2018 at 1:30 PM, Oleksandr Grytsov <al1...@gmail.com> wrote:

> On Mon, Nov 20, 2017 at 3:44 PM, Oleksandr Grytsov <al1...@gmail.com>
> wrote:
>
>> On Tue, Nov 14, 2017 at 2:38 PM, Oleksandr Grytsov <al1...@gmail.com>
>> wrote:
>>
>>> On Wed, Nov 1, 2017 at 5:04 PM, Oleksandr Grytsov <al1...@gmail.com>
>>> wrote:
>>>
>>>> From: Oleksandr Grytsov <oleksandr_gryt...@epam.com>
>>>>
>>>> This patch set adds PV sound device support to xl.cfg and xl.
>>>> See sndif.h for protocol implementation details.
>>>>
>>>> Changes since initial:
>>>>  * fix code style
>>>>  * change unique-id from int to string (to make id more user readable)
>>>>
>>>> Oleksandr Grytsov (5):
>>>>   libxl: add PV sound device
>>>>   libxl: add vsnd list and info
>>>>   xl: add PV sound condif parser
>>>>   xl: add vsnd CLI commands
>>>>   docs: add PV sound device config
>>>>
>>>>  docs/man/xl.cfg.pod.5.in | 150 
>>>>  docs/man/xl.pod.1.in |  30 ++
>>>>  tools/libxl/Makefile |   2 +-
>>>>  tools/libxl/libxl.h  |  24 ++
>>>>  tools/libxl/libxl_create.c   |   1 +
>>>>  tools/libxl/libxl_internal.h |   1 +
>>>>  tools/libxl/libxl_types.idl  |  83 +
>>>>  tools/libxl/libxl_types_internal.idl |   1 +
>>>>  tools/libxl/libxl_utils.h|   3 +
>>>>  tools/libxl/libxl_vsnd.c | 699
>>>> +++
>>>>  tools/xl/Makefile|   2 +-
>>>>  tools/xl/xl.h|   3 +
>>>>  tools/xl/xl_cmdtable.c   |  15 +
>>>>  tools/xl/xl_parse.c  | 246 
>>>>  tools/xl/xl_parse.h  |   1 +
>>>>  tools/xl/xl_vsnd.c       | 203 ++
>>>>  16 files changed, 1462 insertions(+), 2 deletions(-)
>>>>  create mode 100644 tools/libxl/libxl_vsnd.c
>>>>  create mode 100644 tools/xl/xl_vsnd.c
>>>>
>>>> --
>>>> 2.7.4
>>>>
>>>>
>>> ping
>>>
>>> --
>>> Best Regards,
>>> Oleksandr Grytsov.
>>>
>>
>> ping
>>
>> --
>> Best Regards,
>> Oleksandr Grytsov.
>>
>
> Ian, Wei,
>
> Could you review this patch set?
>
> --
> Best Regards,
> Oleksandr Grytsov.
>

ping

-- 
Best Regards,
Oleksandr Grytsov.
___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH v1 0/6] libxl: create standalone vkb device

2018-02-05 Thread Oleksandr Grytsov
On Tue, Jan 9, 2018 at 1:31 PM, Oleksandr Grytsov <al1...@gmail.com> wrote:

>
>
> On Mon, Nov 20, 2017 at 3:44 PM, Oleksandr Grytsov <al1...@gmail.com>
> wrote:
>
>> On Tue, Nov 14, 2017 at 2:39 PM, Oleksandr Grytsov <al1...@gmail.com>
>> wrote:
>>
>>> On Wed, Nov 1, 2017 at 5:05 PM, Oleksandr Grytsov <al1...@gmail.com>
>>> wrote:
>>>
>>>> From: Oleksandr Grytsov <oleksandr_gryt...@epam.com>
>>>>
>>>> Changes since initial:
>>>>  * add setting backend-type to xenstore
>>>>  * add id field to indentify the vkb device on backend side
>>>>
>>>> Oleksandr Grytsov (6):
>>>>   libxl: move vkb device to libxl_vkb.c
>>>>   libxl: fix vkb XS entry and type
>>>>   libxl: add backend type and id to vkb
>>>>   libxl: vkb add list and info functions
>>>>   xl: add vkb config parser and CLI
>>>>   docs: add vkb device to xl.cfg and xl
>>>>
>>>>  docs/man/xl.cfg.pod.5.in|  28 ++
>>>>  docs/man/xl.pod.1.in|  22 +
>>>>  tools/libxl/Makefile|   1 +
>>>>  tools/libxl/libxl.h |  10 ++
>>>>  tools/libxl/libxl_console.c |  53 ---
>>>>  tools/libxl/libxl_create.c  |   3 +
>>>>  tools/libxl/libxl_dm.c  |   1 +
>>>>  tools/libxl/libxl_types.idl |  19 
>>>>  tools/libxl/libxl_utils.h   |   3 +
>>>>  tools/libxl/libxl_vkb.c | 226 ++
>>>> ++
>>>>  tools/xl/Makefile   |   2 +-
>>>>  tools/xl/xl.h   |   3 +
>>>>  tools/xl/xl_cmdtable.c  |  15 +++
>>>>  tools/xl/xl_parse.c |  75 ++-
>>>>  tools/xl/xl_parse.h |   2 +-
>>>>  tools/xl/xl_vkb.c   | 142 ++++++++
>>>>  16 files changed, 549 insertions(+), 56 deletions(-)
>>>>  create mode 100644 tools/libxl/libxl_vkb.c
>>>>  create mode 100644 tools/xl/xl_vkb.c
>>>>
>>>> --
>>>> 2.7.4
>>>>
>>>>
>>> ping
>>>
>>> --
>>> Best Regards,
>>> Oleksandr Grytsov.
>>>
>>
>> ping
>>
>> --
>> Best Regards,
>> Oleksandr Grytsov.
>>
>
> Ian, Wei,
>
> Could you review this patch set?
>
> --
> Best Regards,
> Oleksandr Grytsov.
>

ping

-- 
Best Regards,
Oleksandr Grytsov.
___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH] libxl: add libxl__is_driver_domain function

2018-02-05 Thread Oleksandr Grytsov
On Tue, Jan 9, 2018 at 1:34 PM, Oleksandr Grytsov <al1...@gmail.com> wrote:

> On Thu, Dec 14, 2017 at 4:14 PM, Oleksandr Grytsov <al1...@gmail.com>
> wrote:
>
>> From: Oleksandr Grytsov <oleksandr_gryt...@epam.com>
>>
>> We have following arm-based setup:
>>
>> - Dom0 with xen and xen tools;
>> - Dom1 with device backends (but it is not the driver domain);
>> - Dom2 with device frontend;
>>
>> On Dom2 destroying we have timeout error. Because xl treats our
>> Dom1 as driver domain and waits for backend path to be cleared
>> by the driver domain which is not our case.
>>
>> According to libxl__domain_make in case of driver domain it has
>> "libxl" xen store entry:
>>
>> if (libxl_defbool_val(info->driver_domain)) {
>> /*
>>  * Create a local "libxl" directory for each guest, since we
>> might want
>>  * to use libxl from inside the guest
>>  */
>> libxl__xs_mknod(gc, t, GCSPRINTF("%s/libxl", dom_path), rwperm,
>> ARRAY_SIZE(rwperm));
>>
>> This patch introduces libxl__is_driver_domain which determines the driver
>> domain by checking if "libxl" entry is present and uses this function on
>> device destroy to check by whom domain path should be cleaned up (libxl
>> or the driver domain).
>>
>> Oleksandr Grytsov (1):
>>   libxl: add libxl__is_driver_domain function
>>
>>  tools/libxl/libxl_device.c   | 17 ++---
>>  tools/libxl/libxl_internal.c | 16 
>>  tools/libxl/libxl_internal.h |  4 
>>  3 files changed, 30 insertions(+), 7 deletions(-)
>>
>> --
>> 2.7.4
>>
>>
>
> ping and update
>
> There is run_hotplug_scripts parameter in xl.cfg. I guess it is related to
> this issue. But looking
> through the code I see that this parameter is not used. Could anyone
> provide more info about
> this parameter?
>
> --
> Best Regards,
> Oleksandr Grytsov.
>

ping

-- 
Best Regards,
Oleksandr Grytsov.
___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

[Xen-devel] [PATCH v1 2/4] libxl: use libxl__device_kind in LIBXL_DEFINE_UPDATE_DEVID

2018-01-24 Thread Oleksandr Grytsov
From: Oleksandr Grytsov <oleksandr_gryt...@epam.com>

Use libxl__..._devtype.type to update device id.

Signed-off-by: Oleksandr Grytsov <oleksandr_gryt...@epam.com>
Acked-by: Wei Liu <wei.l...@citrix.com>
---
 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),
-);
+GCSPRINTF("%s/device/%s", libxl_dom_path,
+  libxl__device_kind_to_string(device)), );
 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/to

[Xen-devel] [PATCH v1 1/4] libxl: use libxl__device_kind to get device XS entry

2018-01-24 Thread Oleksandr Grytsov
From: Oleksandr Grytsov <oleksandr_gryt...@epam.com>

On adding to XS name of device is taken from
libxl__device_kind enum. On getting device from XS
the name is hardcoded. It leads to potential
mistmatch errors. The patch is using libxl__device_kind
everywere to have one source of device name.

Signed-off-by: Oleksandr Grytsov <oleksandr_gryt...@epam.com>
---
 tools/libxl/libxl_9pfs.c  |  2 +-
 tools/libxl/libxl_colo_nic.c  |  5 ++--
 tools/libxl/libxl_console.c   | 30 +--
 tools/libxl/libxl_create.c|  4 ++--
 tools/libxl/libxl_device.c| 39 +++---
 tools/libxl/libxl_disk.c  | 42 +++--
 tools/libxl/libxl_domain.c|  2 +-
 tools/libxl/libxl_internal.h  | 19 +--
 tools/libxl/libxl_netbuffer.c |  6 +++--
 tools/libxl/libxl_nic.c   | 20 +++-
 tools/libxl/libxl_pci.c   | 18 +-
 tools/libxl/libxl_usb.c   | 55 +++
 tools/libxl/libxl_vdispl.c| 14 +--
 tools/libxl/libxl_vtpm.c  | 12 +-
 14 files changed, 158 insertions(+), 110 deletions(-)

diff --git a/tools/libxl/libxl_9pfs.c b/tools/libxl/libxl_9pfs.c
index 9db887b..c3dd786 100644
--- a/tools/libxl/libxl_9pfs.c
+++ b/tools/libxl/libxl_9pfs.c
@@ -58,7 +58,7 @@ static int libxl__set_xenstore_p9(libxl__gc *gc, uint32_t 
domid,
 
 LIBXL_DEFINE_DEVICE_REMOVE(p9)
 
-DEFINE_DEVICE_TYPE_STRUCT(p9,
+DEFINE_DEVICE_TYPE_STRUCT(p9, 9PFS,
 .skip_attach = 1,
 .set_xenstore_config = (device_set_xenstore_config_fn_t)
libxl__set_xenstore_p9,
diff --git a/tools/libxl/libxl_colo_nic.c b/tools/libxl/libxl_colo_nic.c
index a164e22..bf5c48f 100644
--- a/tools/libxl/libxl_colo_nic.c
+++ b/tools/libxl/libxl_colo_nic.c
@@ -60,8 +60,9 @@ static const char *get_vifname(libxl__checkpoint_device *dev,
 /* Convenience aliases */
 const uint32_t domid = dev->cds->domid;
 
-path = GCSPRINTF("%s/backend/vif/%d/%d/vifname",
- libxl__xs_get_dompath(gc, 0), domid, nic->devid);
+path = GCSPRINTF("%s/vifname",
+ libxl__domain_device_backend_path(gc, 0,
+ domid, nic->devid, LIBXL__DEVICE_KIND_VIF));
 rc = libxl__xs_read_checked(gc, XBT_NULL, path, );
 if (!rc && !vifname) {
 vifname = libxl__device_nic_devname(gc, domid,
diff --git a/tools/libxl/libxl_console.c b/tools/libxl/libxl_console.c
index 6bfc0e5..4891aa1 100644
--- a/tools/libxl/libxl_console.c
+++ b/tools/libxl/libxl_console.c
@@ -37,8 +37,9 @@ static int libxl__console_tty_path(libxl__gc *gc, uint32_t 
domid, int cons_num,
 if (cons_num == 0)
 *tty_path = GCSPRINTF("%s/console/tty", dom_path);
 else
-*tty_path = GCSPRINTF("%s/device/console/%d/tty", dom_path,
-  cons_num);
+*tty_path = GCSPRINTF("%s/tty",
+  libxl__domain_device_frontend_path(gc, domid,
+  cons_num, LIBXL__DEVICE_KIND_CONSOLE));
 rc = 0;
 break;
 default:
@@ -498,8 +499,10 @@ static int libxl__append_channel_list(libxl__gc *gc,
 libxl_device_channel *next = NULL;
 int rc = 0, i;
 
-libxl_dir_path = GCSPRINTF("%s/device/console",
-   libxl__xs_libxl_path(gc, domid));
+libxl_dir_path = GCSPRINTF("%s/device/%s",
+   libxl__xs_libxl_path(gc, domid),
+   libxl__device_kind_to_string(
+   LIBXL__DEVICE_KIND_CONSOLE));
 dir = libxl__xs_directory(gc, XBT_NULL, libxl_dir_path, );
 if (!dir || !n)
   goto out;
@@ -564,18 +567,19 @@ int libxl_device_channel_getinfo(libxl_ctx *ctx, uint32_t 
domid,
  libxl_channelinfo *channelinfo)
 {
 GC_INIT(ctx);
-char *dompath, *fe_path, *libxl_path;
+char *fe_path, *libxl_path;
 char *val;
 int rc;
 
-dompath = libxl__xs_get_dompath(gc, domid);
 channelinfo->devid = channel->devid;
 
-fe_path = GCSPRINTF("%s/device/console/%d", dompath,
-channelinfo->devid + 1);
-libxl_path = GCSPRINTF("%s/device/console/%d",
-   libxl__xs_libxl_path(gc, domid),
-   channelinfo->devid + 1);
+fe_path = libxl__domain_device_frontend_path(gc, domid,
+ channelinfo->devid + 1,
+ LIBXL__DEVICE_KIND_CONSOLE);
+libxl_path = libxl__domain_device_libxl_path(gc, domid,
+ channelinfo->devid + 1,
+ LIBXL__DEVICE_KIND_CONSOLE);
+
 channelinfo->backend = xs_read(ctx->

[Xen-devel] [PATCH v1 4/4] libxl: move ibxl_devid_to_device_... to LIBXL_DEFINE_DEVID_TO_DEVICE

2018-01-24 Thread Oleksandr Grytsov
From: Oleksandr Grytsov <oleksandr_gryt...@epam.com>

Signed-off-by: Oleksandr Grytsov <oleksandr_gryt...@epam.com>
Acked-by: Wei Liu <wei.l...@citrix.com>
---
 tools/libxl/libxl_internal.h | 38 ++
 tools/libxl/libxl_nic.c  | 22 +-
 tools/libxl/libxl_vdispl.c   | 35 +--
 3 files changed, 40 insertions(+), 55 deletions(-)

diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 4f1e026..506687f 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -3490,6 +3490,44 @@ _hidden void libxl__bootloader_run(libxl__egc*, 
libxl__bootloader_state *st);
 return 0;   \
 }
 
+#define LIBXL_DEFINE_DEVID_TO_DEVICE(name)  \
+int libxl_devid_to_device_##name(libxl_ctx *ctx, uint32_t domid,\
+ int devid, \
+ libxl_device_##name *type) \
+{   \
+GC_INIT(ctx);   \
+\
+char *device_path;  \
+const char *tmp;\
+int rc; \
+\
+libxl_device_##name##_init(type);   \
+\
+device_path = GCSPRINTF("%s/device/%s/%d",  \
+libxl__xs_libxl_path(gc, domid),\
+libxl__device_kind_to_string(   \
+libxl__##name##_devtype.type),  \
+devid); \
+\
+if (libxl__xs_read_mandatory(gc, XBT_NULL, device_path, )) {\
+rc = ERROR_NOTFOUND; goto out;  \
+}   \
+\
+if (libxl__##name##_devtype.from_xenstore) {\
+rc = libxl__##name##_devtype.from_xenstore(gc, device_path, \
+   devid, type);\
+if (rc) goto out;   \
+}   \
+\
+rc = 0; \
+\
+out:\
+\
+GC_FREE;\
+return rc;  \
+}
+
+
 #define LIBXL_DEFINE_DEVICE_REMOVE(type)\
 LIBXL_DEFINE_DEVICE_REMOVE_EXT(type, generic, remove, 0)\
 LIBXL_DEFINE_DEVICE_REMOVE_EXT(type, generic, destroy, 1)
diff --git a/tools/libxl/libxl_nic.c b/tools/libxl/libxl_nic.c
index e028fda..01b711b 100644
--- a/tools/libxl/libxl_nic.c
+++ b/tools/libxl/libxl_nic.c
@@ -380,27 +380,6 @@ static int libxl__nic_from_xenstore(libxl__gc *gc, const 
char *libxl_path,
 return rc;
 }
 
-int libxl_devid_to_device_nic(libxl_ctx *ctx, uint32_t domid,
-  int devid, libxl_device_nic *nic)
-{
-GC_INIT(ctx);
-char *libxl_path;
-int rc = ERROR_FAIL;
-
-libxl_device_nic_init(nic);
-
-libxl_path = libxl__domain_device_libxl_path(gc, domid, devid,
- LIBXL__DEVICE_KIND_VIF);
-
-rc = libxl__nic_from_xenstore(gc, libxl_path, devid, nic);
-if (rc) goto out;
-
-rc = 0;
-out:
-GC_FREE;
-return rc;
-}
-
 libxl_device_nic *libxl_device_nic_list(libxl_ctx *ctx, uint32_t domid, int 
*num)
 {
 libxl_device_nic *r;
@@ -520,6 +499,7 @@ out:
 static LIBXL_DEFINE_UPDATE_DEVID(nic)
 static LIBXL_DEFINE_DEVICE_FROM_TYPE(nic)
 
+LIBXL_DEFINE_DEVID_TO_DEVICE(nic)
 LIBXL_DEFINE_DEVICE_ADD(nic)
 LIBXL_DEFINE_DEVICES_ADD(nic)
 LIBXL_DEFINE_DEVICE_REMOVE(nic)
diff --git a/tools/libxl/libxl_vdispl.c b/tools/libxl/libxl_vdispl.c
index da5b10f..55dfac3 100644
--- a/tools/libxl/libxl_vdispl.c
+++ b/tools/libxl/libxl_vdispl.c
@@ -195,44 +195,11 @@ out

[Xen-devel] [PATCH v1 3/4] libxl: move libxl__device_from_ to LIBXL_DEFINE_DEVICE_FROM_TYPE

2018-01-24 Thread Oleksandr Grytsov
From: Oleksandr Grytsov <oleksandr_gryt...@epam.com>

LIBXL_DEFINE_DEVICE_FROM_TYPE uses libxl__..._devtype.type to
be assigned as device and backend type.

Signed-off-by: Oleksandr Grytsov <oleksandr_gryt...@epam.com>
Acked-by: Wei Liu <wei.l...@citrix.com>
---
 tools/libxl/libxl_9pfs.c | 19 +++
 tools/libxl/libxl_console.c  | 18 +++---
 tools/libxl/libxl_internal.h | 15 +++
 tools/libxl/libxl_nic.c  | 19 +++
 tools/libxl/libxl_vdispl.c   | 20 
 tools/libxl/libxl_vtpm.c | 21 -
 6 files changed, 32 insertions(+), 80 deletions(-)

diff --git a/tools/libxl/libxl_9pfs.c b/tools/libxl/libxl_9pfs.c
index 1298db1..e5c41e9 100644
--- a/tools/libxl/libxl_9pfs.c
+++ b/tools/libxl/libxl_9pfs.c
@@ -23,22 +23,6 @@ static int libxl__device_p9_setdefault(libxl__gc *gc, 
uint32_t domid,
 return libxl__resolve_domid(gc, p9->backend_domname, >backend_domid);
 }
 
-static int libxl__device_from_p9(libxl__gc *gc, uint32_t domid,
- libxl_device_p9 *p9,
- libxl__device *device)
-{
-   device->backend_devid   = p9->devid;
-   device->backend_domid   = p9->backend_domid;
-   device->backend_kind= LIBXL__DEVICE_KIND_9PFS;
-   device->devid   = p9->devid;
-   device->domid   = domid;
-   device->kind= LIBXL__DEVICE_KIND_9PFS;
-
-   return 0;
-}
-
-static LIBXL_DEFINE_UPDATE_DEVID(p9)
-
 static int libxl__set_xenstore_p9(libxl__gc *gc, uint32_t domid,
   libxl_device_p9 *p9,
   flexarray_t *back, flexarray_t *front,
@@ -56,6 +40,9 @@ static int libxl__set_xenstore_p9(libxl__gc *gc, uint32_t 
domid,
 #define libxl_device_p9_list NULL
 #define libxl_device_p9_compare NULL
 
+static LIBXL_DEFINE_UPDATE_DEVID(p9)
+static LIBXL_DEFINE_DEVICE_FROM_TYPE(p9)
+
 LIBXL_DEFINE_DEVICE_REMOVE(p9)
 
 DEFINE_DEVICE_TYPE_STRUCT(p9, 9PFS,
diff --git a/tools/libxl/libxl_console.c b/tools/libxl/libxl_console.c
index 1a0eb05..39d8430 100644
--- a/tools/libxl/libxl_console.c
+++ b/tools/libxl/libxl_console.c
@@ -698,19 +698,6 @@ static int libxl__device_vfb_setdefault(libxl__gc *gc, 
uint32_t domid,
 return rc;
 }
 
-static int libxl__device_from_vfb(libxl__gc *gc, uint32_t domid,
-  libxl_device_vfb *vfb,
-  libxl__device *device)
-{
-device->backend_devid = vfb->devid;
-device->backend_domid = vfb->backend_domid;
-device->backend_kind = LIBXL__DEVICE_KIND_VFB;
-device->devid = vfb->devid;
-device->domid = domid;
-device->kind = LIBXL__DEVICE_KIND_VFB;
-return 0;
-}
-
 int libxl_device_vfb_add(libxl_ctx *ctx, uint32_t domid, libxl_device_vfb *vfb,
  const libxl_asyncop_how *ao_how)
 {
@@ -728,8 +715,6 @@ out:
 return AO_INPROGRESS;
 }
 
-static LIBXL_DEFINE_UPDATE_DEVID(vfb)
-
 static int libxl__set_xenstore_vfb(libxl__gc *gc, uint32_t domid,
libxl_device_vfb *vfb,
   flexarray_t *back, flexarray_t *front,
@@ -784,6 +769,9 @@ DEFINE_DEVICE_TYPE_STRUCT(vkb, VKBD,
 #define libxl_device_vfb_list NULL
 #define libxl_device_vfb_compare NULL
 
+static LIBXL_DEFINE_UPDATE_DEVID(vfb)
+static LIBXL_DEFINE_DEVICE_FROM_TYPE(vfb)
+
 /* vfb */
 LIBXL_DEFINE_DEVICE_REMOVE(vfb)
 
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index e9f3960..4f1e026 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -3475,6 +3475,21 @@ _hidden void libxl__bootloader_run(libxl__egc*, 
libxl__bootloader_state *st);
 return 0;   \
 }
 
+#define LIBXL_DEFINE_DEVICE_FROM_TYPE(name) \
+int libxl__device_from_##name(libxl__gc *gc, uint32_t domid,\
+  libxl_device_##name *type,\
+  libxl__device *device)\
+{   \
+device->backend_devid   = type->devid;  \
+device->backend_domid   = type->backend_domid;  \
+device->backend_kind= libxl__##name##_devtype.type; \
+device->devid   = type->devid;  \
+device->domid   = domid;\
+device->kind= libxl__##name##_devtype.type; \
+\
+return 0;   \
+}
+
 #define LIBXL_DEFINE_DEVICE_REMOVE(type)\
 LIBXL_DEFINE_DEVICE_REMOVE_EXT(t

[Xen-devel] [PATCH v1 0/4] libxl: use libxl__device_kind string to access device

2018-01-24 Thread Oleksandr Grytsov
From: Oleksandr Grytsov <oleksandr_gryt...@epam.com>

Changes since initial version:
  * add libxl__domain_device_..._path functions to get backend, frontend,
libxl device path's from device type, domain id and device id
  * rebase

Oleksandr Grytsov (4):
  libxl: use libxl__device_kind to get device XS entry
  libxl: use libxl__device_kind in LIBXL_DEFINE_UPDATE_DEVID
  libxl: move libxl__device_from_ to LIBXL_DEFINE_DEVICE_FROM_TYPE
  libxl: move ibxl_devid_to_device_... to LIBXL_DEFINE_DEVID_TO_DEVICE

 tools/libxl/libxl_9pfs.c  | 21 +++
 tools/libxl/libxl_colo_nic.c  |  5 +--
 tools/libxl/libxl_console.c   | 50 +++---
 tools/libxl/libxl_create.c|  4 +--
 tools/libxl/libxl_device.c| 46 
 tools/libxl/libxl_disk.c  | 42 ++
 tools/libxl/libxl_domain.c|  2 +-
 tools/libxl/libxl_internal.h  | 84 ---
 tools/libxl/libxl_netbuffer.c |  6 ++--
 tools/libxl/libxl_nic.c   | 55 ++--
 tools/libxl/libxl_pci.c   | 18 ++
 tools/libxl/libxl_usb.c   | 57 +++--
 tools/libxl/libxl_vdispl.c| 67 ++
 tools/libxl/libxl_vtpm.c  | 33 ++---
 14 files changed, 239 insertions(+), 251 deletions(-)

-- 
2.7.4


___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH] libxl: add libxl__is_driver_domain function

2018-01-09 Thread Oleksandr Grytsov
On Thu, Dec 14, 2017 at 4:14 PM, Oleksandr Grytsov <al1...@gmail.com> wrote:

> From: Oleksandr Grytsov <oleksandr_gryt...@epam.com>
>
> We have following arm-based setup:
>
> - Dom0 with xen and xen tools;
> - Dom1 with device backends (but it is not the driver domain);
> - Dom2 with device frontend;
>
> On Dom2 destroying we have timeout error. Because xl treats our
> Dom1 as driver domain and waits for backend path to be cleared
> by the driver domain which is not our case.
>
> According to libxl__domain_make in case of driver domain it has
> "libxl" xen store entry:
>
> if (libxl_defbool_val(info->driver_domain)) {
> /*
>  * Create a local "libxl" directory for each guest, since we might
> want
>  * to use libxl from inside the guest
>  */
> libxl__xs_mknod(gc, t, GCSPRINTF("%s/libxl", dom_path), rwperm,
> ARRAY_SIZE(rwperm));
>
> This patch introduces libxl__is_driver_domain which determines the driver
> domain by checking if "libxl" entry is present and uses this function on
> device destroy to check by whom domain path should be cleaned up (libxl
> or the driver domain).
>
> Oleksandr Grytsov (1):
>   libxl: add libxl__is_driver_domain function
>
>  tools/libxl/libxl_device.c   | 17 ++---
>  tools/libxl/libxl_internal.c | 16 
>  tools/libxl/libxl_internal.h |  4 
>  3 files changed, 30 insertions(+), 7 deletions(-)
>
> --
> 2.7.4
>
>

ping and update

There is run_hotplug_scripts parameter in xl.cfg. I guess it is related to
this issue. But looking
through the code I see that this parameter is not used. Could anyone
provide more info about
this parameter?

-- 
Best Regards,
Oleksandr Grytsov.
___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH v1 0/6] libxl: create standalone vkb device

2018-01-09 Thread Oleksandr Grytsov
On Mon, Nov 20, 2017 at 3:44 PM, Oleksandr Grytsov <al1...@gmail.com> wrote:

> On Tue, Nov 14, 2017 at 2:39 PM, Oleksandr Grytsov <al1...@gmail.com>
> wrote:
>
>> On Wed, Nov 1, 2017 at 5:05 PM, Oleksandr Grytsov <al1...@gmail.com>
>> wrote:
>>
>>> From: Oleksandr Grytsov <oleksandr_gryt...@epam.com>
>>>
>>> Changes since initial:
>>>  * add setting backend-type to xenstore
>>>  * add id field to indentify the vkb device on backend side
>>>
>>> Oleksandr Grytsov (6):
>>>   libxl: move vkb device to libxl_vkb.c
>>>   libxl: fix vkb XS entry and type
>>>   libxl: add backend type and id to vkb
>>>   libxl: vkb add list and info functions
>>>   xl: add vkb config parser and CLI
>>>   docs: add vkb device to xl.cfg and xl
>>>
>>>  docs/man/xl.cfg.pod.5.in|  28 ++
>>>  docs/man/xl.pod.1.in|  22 +
>>>  tools/libxl/Makefile|   1 +
>>>  tools/libxl/libxl.h |  10 ++
>>>  tools/libxl/libxl_console.c |  53 ---
>>>  tools/libxl/libxl_create.c  |   3 +
>>>  tools/libxl/libxl_dm.c  |   1 +
>>>  tools/libxl/libxl_types.idl |  19 
>>>  tools/libxl/libxl_utils.h   |   3 +
>>>  tools/libxl/libxl_vkb.c | 226 ++
>>> ++
>>>  tools/xl/Makefile   |   2 +-
>>>  tools/xl/xl.h   |   3 +
>>>  tools/xl/xl_cmdtable.c  |  15 +++
>>>  tools/xl/xl_parse.c |  75 ++-
>>>  tools/xl/xl_parse.h |   2 +-
>>>  tools/xl/xl_vkb.c   | 142 
>>>  16 files changed, 549 insertions(+), 56 deletions(-)
>>>  create mode 100644 tools/libxl/libxl_vkb.c
>>>  create mode 100644 tools/xl/xl_vkb.c
>>>
>>> --
>>> 2.7.4
>>>
>>>
>> ping
>>
>> --
>> Best Regards,
>> Oleksandr Grytsov.
>>
>
> ping
>
> --
> Best Regards,
> Oleksandr Grytsov.
>

Ian, Wei,

Could you review this patch set?

-- 
Best Regards,
Oleksandr Grytsov.
___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

Re: [Xen-devel] [PATCH v1 0/5] libxl: add PV sound device

2018-01-09 Thread Oleksandr Grytsov
On Mon, Nov 20, 2017 at 3:44 PM, Oleksandr Grytsov <al1...@gmail.com> wrote:

> On Tue, Nov 14, 2017 at 2:38 PM, Oleksandr Grytsov <al1...@gmail.com>
> wrote:
>
>> On Wed, Nov 1, 2017 at 5:04 PM, Oleksandr Grytsov <al1...@gmail.com>
>> wrote:
>>
>>> From: Oleksandr Grytsov <oleksandr_gryt...@epam.com>
>>>
>>> This patch set adds PV sound device support to xl.cfg and xl.
>>> See sndif.h for protocol implementation details.
>>>
>>> Changes since initial:
>>>  * fix code style
>>>  * change unique-id from int to string (to make id more user readable)
>>>
>>> Oleksandr Grytsov (5):
>>>   libxl: add PV sound device
>>>   libxl: add vsnd list and info
>>>   xl: add PV sound condif parser
>>>   xl: add vsnd CLI commands
>>>   docs: add PV sound device config
>>>
>>>  docs/man/xl.cfg.pod.5.in | 150 
>>>  docs/man/xl.pod.1.in |  30 ++
>>>  tools/libxl/Makefile |   2 +-
>>>  tools/libxl/libxl.h  |  24 ++
>>>  tools/libxl/libxl_create.c   |   1 +
>>>  tools/libxl/libxl_internal.h |   1 +
>>>  tools/libxl/libxl_types.idl  |  83 +
>>>  tools/libxl/libxl_types_internal.idl |   1 +
>>>  tools/libxl/libxl_utils.h|   3 +
>>>  tools/libxl/libxl_vsnd.c | 699
>>> +++
>>>  tools/xl/Makefile|   2 +-
>>>  tools/xl/xl.h|   3 +
>>>  tools/xl/xl_cmdtable.c   |  15 +
>>>  tools/xl/xl_parse.c  | 246 
>>>  tools/xl/xl_parse.h  |   1 +
>>>  tools/xl/xl_vsnd.c   | 203 ++
>>>  16 files changed, 1462 insertions(+), 2 deletions(-)
>>>  create mode 100644 tools/libxl/libxl_vsnd.c
>>>  create mode 100644 tools/xl/xl_vsnd.c
>>>
>>> --
>>> 2.7.4
>>>
>>>
>> ping
>>
>> --
>> Best Regards,
>> Oleksandr Grytsov.
>>
>
> ping
>
> --
> Best Regards,
> Oleksandr Grytsov.
>

Ian, Wei,

Could you review this patch set?

-- 
Best Regards,
Oleksandr Grytsov.
___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

[Xen-devel] [PATCH] libxl: add libxl__is_driver_domain function

2017-12-14 Thread Oleksandr Grytsov
From: Oleksandr Grytsov <oleksandr_gryt...@epam.com>

libxl__is_driver_domain determines the driver domain by
presence of libxl entry in the domain xen store. Use
this function on device destroy to properly manage cleanup
in case backends are located on domain with non zero id.

Signed-off-by: Oleksandr Grytsov <oleksandr_gryt...@epam.com>
---
 tools/libxl/libxl_device.c   | 17 ++---
 tools/libxl/libxl_internal.c | 16 
 tools/libxl/libxl_internal.h |  4 
 3 files changed, 30 insertions(+), 7 deletions(-)

diff --git a/tools/libxl/libxl_device.c b/tools/libxl/libxl_device.c
index f84422e..08a33e2 100644
--- a/tools/libxl/libxl_device.c
+++ b/tools/libxl/libxl_device.c
@@ -732,7 +732,7 @@ int libxl__device_destroy(libxl__gc *gc, libxl__device *dev)
 libxl__xs_path_cleanup(gc, t, fe_path);
 libxl__xs_path_cleanup(gc, t, libxl_path);
 }
-if (dev->backend_domid == domid && !libxl_only) {
+if (!libxl__is_driver_domain(gc, dev->backend_domid) && !libxl_only) {
 /*
  * The driver domain is in charge of removing what it can
  * from the backend path.
@@ -1110,16 +1110,19 @@ static void device_hotplug(libxl__egc *egc, 
libxl__ao_device *aodev)
 LOGD(ERROR, aodev->dev->domid, "Failed to get domid");
 goto out;
 }
-if (aodev->dev->backend_domid != domid) {
+
+if (aodev->dev->backend_domid != domid &&
+aodev->action != LIBXL__DEVICE_ACTION_REMOVE) {
+LOG(DEBUG, "Not a remove, not executing hotplug scripts");
+goto out;
+}
+
+if (libxl__is_driver_domain(gc, aodev->dev->backend_domid) &&
+aodev->action == LIBXL__DEVICE_ACTION_REMOVE) {
 LOGD(DEBUG, aodev->dev->domid,
  "Backend domid %d, domid %d, assuming driver domains",
  aodev->dev->backend_domid, domid);
 
-if (aodev->action != LIBXL__DEVICE_ACTION_REMOVE) {
-LOG(DEBUG, "Not a remove, not executing hotplug scripts");
-goto out;
-}
-
 aodev->xswait.ao = ao;
 aodev->xswait.what = "removal of backend path";
 aodev->xswait.path = be_path;
diff --git a/tools/libxl/libxl_internal.c b/tools/libxl/libxl_internal.c
index f492dae..a65bc58 100644
--- a/tools/libxl/libxl_internal.c
+++ b/tools/libxl/libxl_internal.c
@@ -575,6 +575,22 @@ void libxl__update_domain_configuration(libxl__gc *gc,
 dst->b_info.video_memkb = src->b_info.video_memkb;
 }
 
+bool libxl__is_driver_domain(libxl__gc *gc, uint32_t domid)
+{
+const char *val;
+int rc;
+
+char *dom_path = libxl__xs_get_dompath(gc, domid);
+
+if (!dom_path) return false;
+
+rc = libxl__xs_read_checked(gc, XBT_NULL,
+GCSPRINTF("%s/libxl", dom_path), );
+if (rc) return false;
+
+return val != NULL;
+}
+
 /*
  * Local variables:
  * mode: C
diff --git a/tools/libxl/libxl_internal.h b/tools/libxl/libxl_internal.h
index 7fab561..f566d81 100644
--- a/tools/libxl/libxl_internal.h
+++ b/tools/libxl/libxl_internal.h
@@ -4414,6 +4414,10 @@ void* libxl__device_list(libxl__gc *gc, const struct 
libxl_device_type *dt,
  uint32_t domid, int *num);
 void libxl__device_list_free(const struct libxl_device_type *dt,
  void *list, int num);
+
+/* Check if domain is driver domain */
+_hidden bool libxl__is_driver_domain(libxl__gc *gc, uint32_t domid);
+
 #endif
 
 /*
-- 
2.7.4


___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel

[Xen-devel] [PATCH] libxl: add libxl__is_driver_domain function

2017-12-14 Thread Oleksandr Grytsov
From: Oleksandr Grytsov <oleksandr_gryt...@epam.com>

We have following arm-based setup:

- Dom0 with xen and xen tools;
- Dom1 with device backends (but it is not the driver domain);
- Dom2 with device frontend;

On Dom2 destroying we have timeout error. Because xl treats our
Dom1 as driver domain and waits for backend path to be cleared
by the driver domain which is not our case.

According to libxl__domain_make in case of driver domain it has
"libxl" xen store entry:

if (libxl_defbool_val(info->driver_domain)) {
/*
 * Create a local "libxl" directory for each guest, since we might want
 * to use libxl from inside the guest
 */
libxl__xs_mknod(gc, t, GCSPRINTF("%s/libxl", dom_path), rwperm,
ARRAY_SIZE(rwperm));

This patch introduces libxl__is_driver_domain which determines the driver
domain by checking if "libxl" entry is present and uses this function on
device destroy to check by whom domain path should be cleaned up (libxl
or the driver domain).

Oleksandr Grytsov (1):
  libxl: add libxl__is_driver_domain function

 tools/libxl/libxl_device.c   | 17 ++---
 tools/libxl/libxl_internal.c | 16 
 tools/libxl/libxl_internal.h |  4 
 3 files changed, 30 insertions(+), 7 deletions(-)

-- 
2.7.4


___
Xen-devel mailing list
Xen-devel@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel