qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Philippe Mathieu-Daudé" <philmd@redhat.com>
To: paul@xen.org, 'Anthony PERARD' <anthony.perard@citrix.com>,
	qemu-devel@nongnu.org
Cc: xen-devel@lists.xenproject.org,
	'Markus Armbruster' <armbru@redhat.com>,
	'Peter Maydell' <peter.maydell@linaro.org>
Subject: Re: [Qemu-devel] [PULL 06/25] xen: create xenstore areas for XenDevice-s
Date: Thu, 2 Apr 2020 14:07:22 +0200	[thread overview]
Message-ID: <5f7e6e45-bf73-8a64-81a6-a41cc7b9d747@redhat.com> (raw)
In-Reply-To: <001001d608d4$0e7b9f40$2b72ddc0$@xen.org>

On 4/2/20 11:49 AM, Paul Durrant wrote:
>> -----Original Message-----
>> From: Philippe Mathieu-Daudé <philmd@redhat.com>
>> Sent: 01 April 2020 17:14
>> To: Anthony PERARD <anthony.perard@citrix.com>; qemu-devel@nongnu.org
>> Cc: xen-devel@lists.xenproject.org; Peter Maydell <peter.maydell@linaro.org>; Paul Durrant
>> <paul@xen.org>; Markus Armbruster <armbru@redhat.com>
>> Subject: Re: [Qemu-devel] [PULL 06/25] xen: create xenstore areas for XenDevice-s
>>
>> Hi Anthony, Paul.
>>
>> Cc'ing Markus too.
>>
>> On 1/14/19 2:51 PM, Anthony PERARD wrote:
>>> From: Paul Durrant <paul.durrant@citrix.com>
>>>
>>> This patch adds a new source module, xen-bus-helper.c, which builds on
>>> basic libxenstore primitives to provide functions to create (setting
>>> permissions appropriately) and destroy xenstore areas, and functions to
>>> 'printf' and 'scanf' nodes therein. The main xen-bus code then uses
>>> these primitives [1] to initialize and destroy the frontend and backend
>>> areas for a XenDevice during realize and unrealize respectively.
>>>
>>> The 'xen-block' implementation is extended with a 'get_name' method that
>>> returns the VBD number. This number is required to 'name' the xenstore
>>> areas.
>>>
>>> NOTE: An exit handler is also added to make sure the xenstore areas are
>>>         cleaned up if QEMU terminates without devices being unrealized.
>>>
>>> [1] The 'scanf' functions are actually not yet needed, but they will be
>>>       needed by code delivered in subsequent patches.
>>>
>>> Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
>>> Reviewed-by: Anthony Perard <anthony.perard@citrix.com>
>>> Signed-off-by: Anthony PERARD <anthony.perard@citrix.com>
>>> ---
>>>    hw/block/xen-block.c            |   9 +
>>>    hw/xen/Makefile.objs            |   2 +-
>>>    hw/xen/trace-events             |  12 +-
>>>    hw/xen/xen-bus-helper.c         | 150 +++++++++++++++
>>>    hw/xen/xen-bus.c                | 321 +++++++++++++++++++++++++++++++-
>>>    include/hw/xen/xen-bus-helper.h |  39 ++++
>>>    include/hw/xen/xen-bus.h        |  12 ++
>>>    7 files changed, 540 insertions(+), 5 deletions(-)
>>>    create mode 100644 hw/xen/xen-bus-helper.c
>>>    create mode 100644 include/hw/xen/xen-bus-helper.h
>>>
>> [...]
>>> +static void xen_device_exit(Notifier *n, void *data)
>>> +{
>>> +    XenDevice *xendev = container_of(n, XenDevice, exit);
>>> +
>>> +    xen_device_unrealize(DEVICE(xendev), &error_abort);
>>>    }
>>>
>>>    static void xen_device_realize(DeviceState *dev, Error **errp)
>>>    {
>>>        XenDevice *xendev = XEN_DEVICE(dev);
>>>        XenDeviceClass *xendev_class = XEN_DEVICE_GET_CLASS(xendev);
>>> +    XenBus *xenbus = XEN_BUS(qdev_get_parent_bus(DEVICE(xendev)));
>>>        const char *type = object_get_typename(OBJECT(xendev));
>>>        Error *local_err = NULL;
>>>
>>> -    trace_xen_device_realize(type);
>>> +    if (xendev->frontend_id == DOMID_INVALID) {
>>> +        xendev->frontend_id = xen_domid;
>>> +    }
>>> +
>>> +    if (xendev->frontend_id >= DOMID_FIRST_RESERVED) {
>>> +        error_setg(errp, "invalid frontend-id");
>>> +        goto unrealize;
>>> +    }
>>> +
>>> +    if (!xendev_class->get_name) {
>>> +        error_setg(errp, "get_name method not implemented");
>>> +        goto unrealize;
>>> +    }
>>> +
>>> +    xendev->name = xendev_class->get_name(xendev, &local_err);
>>> +    if (local_err) {
>>> +        error_propagate_prepend(errp, local_err,
>>> +                                "failed to get device name: ");
>>> +        goto unrealize;
>>> +    }
>>> +
>>> +    trace_xen_device_realize(type, xendev->name);
>>> +
>>> +    xen_device_backend_create(xendev, &local_err);
>>> +    if (local_err) {
>>> +        error_propagate(errp, local_err);
>>> +        goto unrealize;
>>> +    }
>>> +
>>> +    xen_device_frontend_create(xendev, &local_err);
>>> +    if (local_err) {
>>> +        error_propagate(errp, local_err);
>>> +        goto unrealize;
>>> +    }
>>>
>>>        if (xendev_class->realize) {
>>>            xendev_class->realize(xendev, &local_err);
>>> @@ -72,18 +364,43 @@ static void xen_device_realize(DeviceState *dev, Error **errp)
>>>            }
>>>        }
>>>
>>> +    xen_device_backend_printf(xendev, "frontend", "%s",
>>> +                              xendev->frontend_path);
>>> +    xen_device_backend_printf(xendev, "frontend-id", "%u",
>>> +                              xendev->frontend_id);
>>> +    xen_device_backend_printf(xendev, "online", "%u", 1);
>>> +    xen_device_backend_printf(xendev, "hotplug-status", "connected");
>>> +
>>> +    xen_device_backend_set_state(xendev, XenbusStateInitWait);
>>> +
>>> +    xen_device_frontend_printf(xendev, "backend", "%s",
>>> +                               xendev->backend_path);
>>> +    xen_device_frontend_printf(xendev, "backend-id", "%u",
>>> +                               xenbus->backend_id);
>>> +
>>> +    xen_device_frontend_set_state(xendev, XenbusStateInitialising);
>>> +
>>> +    xendev->exit.notify = xen_device_exit;
>>> +    qemu_add_exit_notifier(&xendev->exit);
>>>        return;
>>>
>>>    unrealize:
>>>        xen_device_unrealize(dev, &error_abort);
>>
>> It seems if unrealize() fails, the error stored in &local_err is never
>> reported. Not sure if this can be improved although.
> 
> In this case that's essentially a "don't care". We want to know why the realize failed but if the unrealize fails something is probably pretty seriously screwed (hence the error_abort).

OK. I was surprised by the singular pattern (which confuses Coccinelle 
semantic transformations), but it works.

Thanks for the quick feedback Paul!

Regards,

Phil.

> 
>    Paul
> 



  reply	other threads:[~2020-04-02 12:08 UTC|newest]

Thread overview: 31+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-01-14 13:51 [Qemu-devel] [PULL 00/25] Xen queue v2 Anthony PERARD
2019-01-14 13:51 ` [Qemu-devel] [PULL 01/25] hw/xen/xen_pt_graphics: Don't trust the BIOS ROM contents so much Anthony PERARD
2019-01-14 13:51 ` [Qemu-devel] [PULL 02/25] xen/pt: allow passthrough of devices with bogus interrupt pin Anthony PERARD
2019-01-14 13:51 ` [Qemu-devel] [PULL 03/25] xen: re-name XenDevice to XenLegacyDevice Anthony PERARD
2019-01-14 13:51 ` [Qemu-devel] [PULL 04/25] xen: introduce new 'XenBus' and 'XenDevice' object hierarchy Anthony PERARD
2019-01-14 13:51 ` [Qemu-devel] [PULL 05/25] xen: introduce 'xen-block', 'xen-disk' and 'xen-cdrom' Anthony PERARD
2019-01-14 13:51 ` [Qemu-devel] [PULL 06/25] xen: create xenstore areas for XenDevice-s Anthony PERARD
2020-04-01 16:14   ` Philippe Mathieu-Daudé
2020-04-02  9:49     ` Paul Durrant
2020-04-02 12:07       ` Philippe Mathieu-Daudé [this message]
2019-01-14 13:51 ` [Qemu-devel] [PULL 07/25] xen: add xenstore watcher infrastructure Anthony PERARD
2019-01-14 13:51 ` [Qemu-devel] [PULL 08/25] xen: add grant table interface for XenDevice-s Anthony PERARD
2019-01-14 13:51 ` [Qemu-devel] [PULL 09/25] xen: add event channel " Anthony PERARD
2019-01-14 13:51 ` [Qemu-devel] [PULL 10/25] xen: duplicate xen_disk.c as basis of dataplane/xen-block.c Anthony PERARD
2019-01-14 13:51 ` [Qemu-devel] [PULL 11/25] xen: remove unnecessary code from dataplane/xen-block.c Anthony PERARD
2019-01-14 13:51 ` [Qemu-devel] [PULL 12/25] xen: add header and build dataplane/xen-block.c Anthony PERARD
2019-01-14 13:51 ` [Qemu-devel] [PULL 13/25] xen: remove 'XenBlkDev' and 'blkdev' names from dataplane/xen-block Anthony PERARD
2019-01-14 13:51 ` [Qemu-devel] [PULL 14/25] xen: remove 'ioreq' struct/varable/field names from dataplane/xen-block.c Anthony PERARD
2019-01-14 13:51 ` [Qemu-devel] [PULL 15/25] xen: purge 'blk' and 'ioreq' from function names in dataplane/xen-block.c Anthony PERARD
2019-01-14 13:51 ` [Qemu-devel] [PULL 16/25] xen: add implementations of xen-block connect and disconnect functions Anthony PERARD
2019-01-14 13:51 ` [Qemu-devel] [PULL 17/25] xen: add a mechanism to automatically create XenDevice-s Anthony PERARD
2019-01-14 13:51 ` [Qemu-devel] [PULL 18/25] xen: automatically create XenBlockDevice-s Anthony PERARD
2019-01-14 13:51 ` [Qemu-devel] [PULL 19/25] MAINTAINERS: add myself as a Xen maintainer Anthony PERARD
2019-01-14 13:51 ` [Qemu-devel] [PULL 20/25] xen: remove the legacy 'xen_disk' backend Anthony PERARD
2019-01-14 13:51 ` [Qemu-devel] [PULL 21/25] Remove broken Xen PV domain builder Anthony PERARD
2019-01-14 13:51 ` [Qemu-devel] [PULL 22/25] xen: Replace few mentions of xend by libxl Anthony PERARD
2019-01-14 13:51 ` [Qemu-devel] [PULL 23/25] xen-block: improve batching behaviour Anthony PERARD
2019-01-14 13:51 ` [Qemu-devel] [PULL 24/25] xen-block: improve response latency Anthony PERARD
2019-01-14 13:51 ` [Qemu-devel] [PULL 25/25] xen-block: avoid repeated memory allocation Anthony PERARD
2019-01-14 17:34 ` [Qemu-devel] [PULL 00/25] Xen queue v2 Peter Maydell
  -- strict thread matches above, loose matches on Subject: below --
2019-01-10 13:48 [Qemu-devel] [PULL 00/25] xen queue Anthony PERARD
2019-01-10 13:48 ` [Qemu-devel] [PULL 06/25] xen: create xenstore areas for XenDevice-s Anthony PERARD

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=5f7e6e45-bf73-8a64-81a6-a41cc7b9d747@redhat.com \
    --to=philmd@redhat.com \
    --cc=anthony.perard@citrix.com \
    --cc=armbru@redhat.com \
    --cc=paul@xen.org \
    --cc=peter.maydell@linaro.org \
    --cc=qemu-devel@nongnu.org \
    --cc=xen-devel@lists.xenproject.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).