qemu-commits
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Qemu-commits] [qemu/qemu] 0254c4: hw/xen: Add xenstore wire implementat


From: Peter Maydell
Subject: [Qemu-commits] [qemu/qemu] 0254c4: hw/xen: Add xenstore wire implementation and imple...
Date: Thu, 09 Mar 2023 07:19:05 -0800

  Branch: refs/heads/master
  Home:   https://github.com/qemu/qemu
  Commit: 0254c4d19df3e89e964f121df1e73f2d871fd46e
      
https://github.com/qemu/qemu/commit/0254c4d19df3e89e964f121df1e73f2d871fd46e
  Author: David Woodhouse <dwmw@amazon.co.uk>
  Date:   2023-03-07 (Tue, 07 Mar 2023)

  Changed paths:
    M hw/i386/kvm/meson.build
    M hw/i386/kvm/trace-events
    M hw/i386/kvm/xen_xenstore.c
    A hw/i386/kvm/xenstore_impl.c
    A hw/i386/kvm/xenstore_impl.h

  Log Message:
  -----------
  hw/xen: Add xenstore wire implementation and implementation stubs

This implements the basic wire protocol for the XenStore commands, punting
all the actual implementation to xs_impl_* functions which all just return
errors for now.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>


  Commit: 3ef7ff83caa27d8b3bfc76805cd47bc97d23b7d7
      
https://github.com/qemu/qemu/commit/3ef7ff83caa27d8b3bfc76805cd47bc97d23b7d7
  Author: David Woodhouse <dwmw@amazon.co.uk>
  Date:   2023-03-07 (Tue, 07 Mar 2023)

  Changed paths:
    M hw/i386/kvm/xenstore_impl.c
    M tests/unit/meson.build
    A tests/unit/test-xs-node.c

  Log Message:
  -----------
  hw/xen: Add basic XenStore tree walk and write/read/directory support

This is a fairly simple implementation of a copy-on-write tree.

The node walk function starts off at the root, with 'inplace == true'.
If it ever encounters a node with a refcount greater than one (including
the root node), then that node is shared with other trees, and cannot
be modified in place, so the inplace flag is cleared and we copy on
write from there on down.

Xenstore write has 'mkdir -p' semantics and will create the intermediate
nodes if they don't already exist, so in that case we flip the inplace
flag back to true as we populate the newly-created nodes.

We put a copy of the absolute path into the buffer in the struct walk_op,
with *two* NUL terminators at the end. As xs_node_walk() goes down the
tree, it replaces the next '/' separator with a NUL so that it can use
the 'child name' in place. The next recursion down then puts the '/'
back and repeats the exercise for the next path element... if it doesn't
hit that *second* NUL termination which indicates the true end of the
path.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>


  Commit: 6e1330090d361d5904587b492afaad5041e63b66
      
https://github.com/qemu/qemu/commit/6e1330090d361d5904587b492afaad5041e63b66
  Author: David Woodhouse <dwmw@amazon.co.uk>
  Date:   2023-03-07 (Tue, 07 Mar 2023)

  Changed paths:
    M hw/i386/kvm/xenstore_impl.c
    M tests/unit/test-xs-node.c

  Log Message:
  -----------
  hw/xen: Implement XenStore watches

Starts out fairly simple: a hash table of watches based on the path.

Except there can be multiple watches on the same path, so the watch ends
up being a simple linked list, and the head of that list is in the hash
table. Which makes removal a bit of a PITA but it's not so bad; we just
special-case "I had to remove the head of the list and now I have to
replace it in / remove it from the hash table". And if we don't remove
the head, it's a simple linked-list operation.

We do need to fire watches on *deleted* nodes, so instead of just a simple
xs_node_unref() on the topmost victim, we need to recurse down and fire
watches on them all.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>


  Commit: 7248b87cb0292a13c0309a4aba9f5daf7a76d297
      
https://github.com/qemu/qemu/commit/7248b87cb0292a13c0309a4aba9f5daf7a76d297
  Author: David Woodhouse <dwmw@amazon.co.uk>
  Date:   2023-03-07 (Tue, 07 Mar 2023)

  Changed paths:
    M hw/i386/kvm/xenstore_impl.c
    M tests/unit/test-xs-node.c

  Log Message:
  -----------
  hw/xen: Implement XenStore transactions

Given that the whole thing supported copy on write from the beginning,
transactions end up being fairly simple. On starting a transaction, just
take a ref of the existing root; swap it back in on a successful commit.

The main tree has a transaction ID too, and we keep a record of the last
transaction ID given out. if the main tree is ever modified when it isn't
the latest, it gets a new transaction ID.

A commit can only succeed if the main tree hasn't moved on since it was
forked. Strictly speaking, the XenStore protocol allows a transaction to
succeed as long as nothing *it* read or wrote has changed in the interim,
but no implementations do that; *any* change is sufficient to abort a
transaction.

This does not yet fire watches on the changed nodes on a commit. That bit
is more fun and will come in a follow-on commit.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>


  Commit: 7cabbdb70df64fc7b0ed05f3e6aa4e1990eadc77
      
https://github.com/qemu/qemu/commit/7cabbdb70df64fc7b0ed05f3e6aa4e1990eadc77
  Author: David Woodhouse <dwmw@amazon.co.uk>
  Date:   2023-03-07 (Tue, 07 Mar 2023)

  Changed paths:
    M hw/i386/kvm/xenstore_impl.c
    M tests/unit/test-xs-node.c

  Log Message:
  -----------
  hw/xen: Watches on XenStore transactions

Firing watches on the nodes that still exist is relatively easy; just
walk the tree and look at the nodes with refcount of one.

Firing watches on *deleted* nodes is more fun. We add 'modified_in_tx'
and 'deleted_in_tx' flags to each node. Nodes with those flags cannot
be shared, as they will always be unique to the transaction in which
they were created.

When xs_node_walk would need to *create* a node as scaffolding and it
encounters a deleted_in_tx node, it can resurrect it simply by clearing
its deleted_in_tx flag. If that node originally had any *data*, they're
gone, and the modified_in_tx flag will have been set when it was first
deleted.

We then attempt to send appropriate watches when the transaction is
committed, properly delete the deleted_in_tx nodes, and remove the
modified_in_tx flag from the others.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>


  Commit: be1934dfefe74aa1b978c0cda64c2b6282301196
      
https://github.com/qemu/qemu/commit/be1934dfefe74aa1b978c0cda64c2b6282301196
  Author: Paul Durrant <pdurrant@amazon.com>
  Date:   2023-03-07 (Tue, 07 Mar 2023)

  Changed paths:
    M hw/i386/kvm/xen_xenstore.c
    M hw/i386/kvm/xenstore_impl.c
    M hw/i386/kvm/xenstore_impl.h
    M tests/unit/test-xs-node.c

  Log Message:
  -----------
  hw/xen: Implement XenStore permissions

Store perms as a GList of strings, check permissions.

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>


  Commit: 766804b101d7e452ad85995c231a5c3454f4e25b
      
https://github.com/qemu/qemu/commit/766804b101d7e452ad85995c231a5c3454f4e25b
  Author: David Woodhouse <dwmw@amazon.co.uk>
  Date:   2023-03-07 (Tue, 07 Mar 2023)

  Changed paths:
    M hw/i386/kvm/xen_xenstore.c
    M hw/i386/kvm/xenstore_impl.c
    M hw/i386/kvm/xenstore_impl.h
    M tests/unit/test-xs-node.c

  Log Message:
  -----------
  hw/xen: Implement core serialize/deserialize methods for xenstore_impl

This implements the basic migration support in the back end, with unit
tests that give additional confidence in the node-counting already in
the tree.

However, the existing PV back ends like xen-disk don't support migration
yet. They will reset the ring and fail to continue where they left off.
We will fix that in future, but not in time for the 8.0 release.

Since there's also an open question of whether we want to serialize the
full XenStore or only the guest-owned nodes in /local/domain/${domid},
for now just mark the XenStore device as unmigratable.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>


  Commit: 831b0db8abda1d837a299893c4e3027942c8ac49
      
https://github.com/qemu/qemu/commit/831b0db8abda1d837a299893c4e3027942c8ac49
  Author: Paul Durrant <pdurrant@amazon.com>
  Date:   2023-03-07 (Tue, 07 Mar 2023)

  Changed paths:
    M hw/i386/kvm/xen_xenstore.c

  Log Message:
  -----------
  hw/xen: Create initial XenStore nodes

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>


  Commit: b6cacfea0b38300e3ea5fd6d486d5085122554eb
      
https://github.com/qemu/qemu/commit/b6cacfea0b38300e3ea5fd6d486d5085122554eb
  Author: David Woodhouse <dwmw@amazon.co.uk>
  Date:   2023-03-07 (Tue, 07 Mar 2023)

  Changed paths:
    M hw/9pfs/xen-9p-backend.c
    M hw/i386/xen/xen-hvm.c
    M hw/xen/meson.build
    M hw/xen/xen-bus.c
    M hw/xen/xen-legacy-backend.c
    A hw/xen/xen-operations.c
    M hw/xen/xen_pvdev.c
    M include/hw/xen/xen-bus.h
    M include/hw/xen/xen-legacy-backend.h
    A include/hw/xen/xen_backend_ops.h
    M include/hw/xen/xen_common.h
    M include/hw/xen/xen_pvdev.h
    M softmmu/globals.c

  Log Message:
  -----------
  hw/xen: Add evtchn operations to allow redirection to internal emulation

The existing implementation calling into the real libxenevtchn moves to
a new file hw/xen/xen-operations.c, and is called via a function table
which in a subsequent commit will also be able to invoke the emulated
event channel support.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>


  Commit: c412ba47b2ec4c75e1ef84f39f898cfdec0630ad
      
https://github.com/qemu/qemu/commit/c412ba47b2ec4c75e1ef84f39f898cfdec0630ad
  Author: David Woodhouse <dwmw@amazon.co.uk>
  Date:   2023-03-07 (Tue, 07 Mar 2023)

  Changed paths:
    M hw/xen/xen-bus.c
    M hw/xen/xen-legacy-backend.c
    M hw/xen/xen-operations.c
    M hw/xen/xen_pvdev.c
    M include/hw/xen/xen-bus.h
    M include/hw/xen/xen-legacy-backend.h
    M include/hw/xen/xen_backend_ops.h
    M include/hw/xen/xen_common.h
    M softmmu/globals.c

  Log Message:
  -----------
  hw/xen: Add gnttab operations to allow redirection to internal emulation

Move the existing code using libxengnttab to xen-operations.c and allow
the operations to be redirected so that we can add emulation of grant
table mapping for backend drivers.

In emulation, mapping more than one grant ref to be virtually contiguous
would be fairly difficult. The best way to do it might be to make the
ram_block mappings actually backed by a file (shmem or a deleted file,
perhaps) so that we can have multiple *shared* mappings of it. But that
would be fairly intrusive.

Making the backend drivers cope with page *lists* instead of expecting
the mapping to be contiguous is also non-trivial, since some structures
would actually *cross* page boundaries (e.g. the 32-bit blkif responses
which are 12 bytes).

So for now, we'll support only single-page mappings in emulation. Add a
XEN_GNTTAB_OP_FEATURE_MAP_MULTIPLE flag to indicate that the native Xen
implementation *does* support multi-page maps, and a helper function to
query it.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>


  Commit: f80fad16afa5aebb8cce919e87f6c58fa03d16e6
      
https://github.com/qemu/qemu/commit/f80fad16afa5aebb8cce919e87f6c58fa03d16e6
  Author: David Woodhouse <dwmw@amazon.co.uk>
  Date:   2023-03-07 (Tue, 07 Mar 2023)

  Changed paths:
    M hw/9pfs/xen-9p-backend.c
    M hw/block/dataplane/xen-block.c
    M hw/char/xen_console.c
    M hw/net/xen_nic.c
    M hw/usb/xen-usb.c
    M hw/xen/xen-bus.c
    M hw/xen/xen-legacy-backend.c
    M hw/xen/xen-operations.c
    M include/hw/xen/xen-bus.h
    M include/hw/xen/xen-legacy-backend.h
    M include/hw/xen/xen_backend_ops.h

  Log Message:
  -----------
  hw/xen: Pass grant ref to gnttab unmap operation

The previous commit introduced redirectable gnttab operations fairly
much like-for-like, with the exception of the extra arguments to the
->open() call which were always NULL/0 anyway.

This *changes* the arguments to the ->unmap() operation to include the
original ref# that was mapped. Under real Xen it isn't necessary; all we
need to do from QEMU is munmap(), then the kernel will release the grant,
and Xen does the tracking/refcounting for the guest.

When we have emulated grant tables though, we need to do all that for
ourselves. So let's have the back ends keep track of what they mapped
and pass it in to the ->unmap() method for us.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>


  Commit: 15e283c5b684c2e502e9327186eb89eb69c68812
      
https://github.com/qemu/qemu/commit/15e283c5b684c2e502e9327186eb89eb69c68812
  Author: David Woodhouse <dwmw@amazon.co.uk>
  Date:   2023-03-07 (Tue, 07 Mar 2023)

  Changed paths:
    M hw/char/xen_console.c
    M hw/display/xenfb.c
    M hw/xen/xen-operations.c
    M include/hw/xen/xen_backend_ops.h
    M include/hw/xen/xen_common.h
    M softmmu/globals.c
    M tests/unit/test-xs-node.c

  Log Message:
  -----------
  hw/xen: Add foreignmem operations to allow redirection to internal emulation

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>


  Commit: ba2a92db1ff682c16730b1d7f156bac61928f04d
      
https://github.com/qemu/qemu/commit/ba2a92db1ff682c16730b1d7f156bac61928f04d
  Author: Paul Durrant <pdurrant@amazon.com>
  Date:   2023-03-07 (Tue, 07 Mar 2023)

  Changed paths:
    M accel/xen/xen-all.c
    M hw/char/xen_console.c
    M hw/i386/kvm/xen_xenstore.c
    M hw/i386/kvm/xenstore_impl.h
    M hw/xen/xen-bus-helper.c
    M hw/xen/xen-bus.c
    M hw/xen/xen-legacy-backend.c
    M hw/xen/xen-operations.c
    M hw/xen/xen_devconfig.c
    M hw/xen/xen_pt_graphics.c
    M hw/xen/xen_pvdev.c
    M include/hw/xen/xen-bus-helper.h
    M include/hw/xen/xen-bus.h
    M include/hw/xen/xen-legacy-backend.h
    M include/hw/xen/xen_backend_ops.h
    M include/hw/xen/xen_common.h
    M include/hw/xen/xen_pvdev.h
    M softmmu/globals.c

  Log Message:
  -----------
  hw/xen: Add xenstore operations to allow redirection to internal emulation

Signed-off-by: Paul Durrant <pdurrant@amazon.com>
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>


  Commit: 7a8a749da7d30b420291fa0b11e3eda7f72d9b83
      
https://github.com/qemu/qemu/commit/7a8a749da7d30b420291fa0b11e3eda7f72d9b83
  Author: David Woodhouse <dwmw@amazon.co.uk>
  Date:   2023-03-07 (Tue, 07 Mar 2023)

  Changed paths:
    M accel/xen/xen-all.c
    M hw/char/xen_console.c
    M include/hw/xen/xen.h

  Log Message:
  -----------
  hw/xen: Move xenstore_store_pv_console_info to xen_console.c

There's no need for this to be in the Xen accel code, and as we want to
use the Xen console support with KVM-emulated Xen we'll want to have a
platform-agnostic version of it. Make it use GString to build up the
path while we're at it.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>


  Commit: a9ae1418b36b20ab06fb760b1108f61f49a76164
      
https://github.com/qemu/qemu/commit/a9ae1418b36b20ab06fb760b1108f61f49a76164
  Author: David Woodhouse <dwmw@amazon.co.uk>
  Date:   2023-03-07 (Tue, 07 Mar 2023)

  Changed paths:
    M hw/block/dataplane/xen-block.c
    M hw/display/xenfb.c
    M hw/net/xen_nic.c
    M hw/usb/xen-usb.c

  Log Message:
  -----------
  hw/xen: Use XEN_PAGE_SIZE in PV backend drivers

XC_PAGE_SIZE comes from the actual Xen libraries, while XEN_PAGE_SIZE is
provided by QEMU itself in xen_backend_ops.h. For backends which may be
built for emulation mode, use the latter.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>


  Commit: e2abfe5ec67b69fb310fbeaacf7e68d61d16609e
      
https://github.com/qemu/qemu/commit/e2abfe5ec67b69fb310fbeaacf7e68d61d16609e
  Author: David Woodhouse <dwmw@amazon.co.uk>
  Date:   2023-03-07 (Tue, 07 Mar 2023)

  Changed paths:
    M accel/xen/xen-all.c
    M hw/9pfs/xen-9p-backend.c
    M hw/block/dataplane/xen-block.c
    M hw/block/xen-block.c
    M hw/i386/pc_piix.c
    M hw/i386/xen/xen-hvm.c
    M hw/i386/xen/xen-mapcache.c
    M hw/i386/xen/xen_platform.c
    M hw/xen/trace-events
    M hw/xen/xen-operations.c
    M hw/xen/xen_pt.c
    M hw/xen/xen_pt.h
    M hw/xen/xen_pt_config_init.c
    M hw/xen/xen_pt_msi.c
    M include/hw/xen/xen.h
    R include/hw/xen/xen_common.h
    A include/hw/xen/xen_native.h
    M include/hw/xen/xen_pvdev.h

  Log Message:
  -----------
  hw/xen: Rename xen_common.h to xen_native.h

This header is now only for native Xen code, not PV backends that may be
used in Xen emulation. Since the toolstack libraries may depend on the
specific version of Xen headers that they pull in (and will set the
__XEN_TOOLS__ macro to enable internal definitions that they depend on),
the rule is that xen_native.h (and thus the toolstack library headers)
must be included *before* any of the headers in include/hw/xen/interface.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>


  Commit: 4ca8cf092dabf934a32968c917f0d0682053cd4e
      
https://github.com/qemu/qemu/commit/4ca8cf092dabf934a32968c917f0d0682053cd4e
  Author: David Woodhouse <dwmw@amazon.co.uk>
  Date:   2023-03-07 (Tue, 07 Mar 2023)

  Changed paths:
    M hw/9pfs/meson.build
    M hw/block/dataplane/meson.build
    M hw/block/meson.build
    M hw/char/meson.build
    M hw/display/meson.build
    M hw/usb/meson.build
    M hw/xen/meson.build

  Log Message:
  -----------
  hw/xen: Build PV backend drivers for CONFIG_XEN_BUS

Now that we have the redirectable Xen backend operations we can build the
PV backends even without the Xen libraries.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>


  Commit: 240cc11369fc692c037a6ec46b358e75a55df894
      
https://github.com/qemu/qemu/commit/240cc11369fc692c037a6ec46b358e75a55df894
  Author: Paul Durrant <pdurrant@amazon.com>
  Date:   2023-03-07 (Tue, 07 Mar 2023)

  Changed paths:
    M hw/xen/xen-bus.c

  Log Message:
  -----------
  hw/xen: Avoid crash when backend watch fires too early

The xen-block code ends up calling aio_poll() through blkconf_geometry(),
which means we see watch events during the indirect call to
xendev_class->realize() in xen_device_realize(). Unfortunately this call
is made before populating the initial frontend and backend device nodes
in xenstore and hence xen_block_frontend_changed() (which is called from
a watch event) fails to read the frontend's 'state' node, and hence
believes the device is being torn down. This in-turn sets the backend
state to XenbusStateClosed and causes the device to be deleted before it
is fully set up, leading to the crash.
By simply moving the call to xendev_class->realize() after the initial
xenstore nodes are populated, this sorry state of affairs is avoided.

Reported-by: David Woodhouse <dwmw@amazon.co.uk>
Signed-off-by: Paul Durrant <pdurrant@amazon.com>
Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>


  Commit: 072519037dde8957cc8c519caad21e7816b46129
      
https://github.com/qemu/qemu/commit/072519037dde8957cc8c519caad21e7816b46129
  Author: David Woodhouse <dwmw@amazon.co.uk>
  Date:   2023-03-07 (Tue, 07 Mar 2023)

  Changed paths:
    M hw/block/xen-block.c

  Log Message:
  -----------
  hw/xen: Only advertise ring-page-order for xen-block if gnttab supports it

Whem emulating Xen, multi-page grants are distinctly non-trivial and we
have elected not to support them for the time being. Don't advertise
them to the guest.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>


  Commit: 4dfd5fb178f93c3636a20684e7378427f067ce35
      
https://github.com/qemu/qemu/commit/4dfd5fb178f93c3636a20684e7378427f067ce35
  Author: David Woodhouse <dwmw@amazon.co.uk>
  Date:   2023-03-07 (Tue, 07 Mar 2023)

  Changed paths:
    M hw/i386/kvm/xen_evtchn.c

  Log Message:
  -----------
  hw/xen: Hook up emulated implementation for event channel operations

We provided the backend-facing evtchn functions very early on as part of
the core Xen platform support, since things like timers and xenstore need
to use them.

By what may or may not be an astonishing coincidence, those functions
just *happen* all to have exactly the right function prototypes to slot
into the evtchn_backend_ops table and be called by the PV backends.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>


  Commit: b08d88e30f061d5d8ae080a453a078214d4b462a
      
https://github.com/qemu/qemu/commit/b08d88e30f061d5d8ae080a453a078214d4b462a
  Author: David Woodhouse <dwmw@amazon.co.uk>
  Date:   2023-03-07 (Tue, 07 Mar 2023)

  Changed paths:
    M hw/i386/kvm/xen_gnttab.c

  Log Message:
  -----------
  hw/xen: Add emulated implementation of grant table operations

This is limited to mapping a single grant at a time, because under Xen the
pages are mapped *contiguously* into qemu's address space, and that's very
hard to do when those pages actually come from anonymous mappings in qemu
in the first place.

Eventually perhaps we can look at using shared mappings of actual objects
for system RAM, and then we can make new mappings of the same backing
store (be it deleted files, shmem, whatever). But for now let's stick to
a page at a time.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>


  Commit: 032475127225e5949c021dcb1dfcc0ffec400157
      
https://github.com/qemu/qemu/commit/032475127225e5949c021dcb1dfcc0ffec400157
  Author: David Woodhouse <dwmw@amazon.co.uk>
  Date:   2023-03-07 (Tue, 07 Mar 2023)

  Changed paths:
    M hw/i386/kvm/xen_xenstore.c

  Log Message:
  -----------
  hw/xen: Add emulated implementation of XenStore operations

Now that we have an internal implementation of XenStore, we can populate
the xenstore_backend_ops to allow PV backends to talk to it.

Watches can't be processed with immediate callbacks because that would
call back into XenBus code recursively. Defer them to a QEMUBH to be run
as appropriate from the main loop. We use a QEMUBH per XS handle, and it
walks all the watches (there shouldn't be many per handle) to fire any
which have pending events. We *could* have done it differently but this
allows us to use the same struct watch_event as we have for the guest
side, and keeps things relatively simple.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>


  Commit: d05864d23b1aa3263cd645e1dd881b543b0ad447
      
https://github.com/qemu/qemu/commit/d05864d23b1aa3263cd645e1dd881b543b0ad447
  Author: David Woodhouse <dwmw@amazon.co.uk>
  Date:   2023-03-07 (Tue, 07 Mar 2023)

  Changed paths:
    M hw/i386/kvm/xen_xenstore.c

  Log Message:
  -----------
  hw/xen: Map guest XENSTORE_PFN grant in emulated Xenstore

We don't actually access the guest's page through the grant, because
this isn't real Xen, and we can just use the page we gave it in the
first place. Map the grant anyway, mostly for cosmetic purposes so it
*looks* like it's in use in the guest-visible grant table.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>


  Commit: de26b26197895857631863e6dea575b91e86f6d5
      
https://github.com/qemu/qemu/commit/de26b26197895857631863e6dea575b91e86f6d5
  Author: David Woodhouse <dwmw@amazon.co.uk>
  Date:   2023-03-07 (Tue, 07 Mar 2023)

  Changed paths:
    M hw/i386/kvm/xen_gnttab.c
    M hw/i386/kvm/xen_gnttab.h
    M target/i386/kvm/xen-emu.c

  Log Message:
  -----------
  hw/xen: Implement soft reset for emulated gnttab

This is only part of it; we will also need to get the PV back end drivers
to tear down their own mappings (or do it for them, but they kind of need
to stop using the pointers too).

Some more work on the actual PV back ends and xen-bus code is going to be
needed to really make soft reset and migration fully functional, and this
part is the basis for that.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>


  Commit: a78c54c4f92c38d32211990b7b23b417fbfde8d1
      
https://github.com/qemu/qemu/commit/a78c54c4f92c38d32211990b7b23b417fbfde8d1
  Author: David Woodhouse <dwmw@amazon.co.uk>
  Date:   2023-03-07 (Tue, 07 Mar 2023)

  Changed paths:
    M hw/i386/pc.c

  Log Message:
  -----------
  i386/xen: Initialize Xen backends from pc_basic_device_init() for emulation

Now that all the work is done to enable the PV backends to work without
actual Xen, instantiate the bus from pc_basic_device_init() for emulated
mode.

This allows us finally to launch an emulated Xen guest with PV disk.

   qemu-system-x86_64 -serial mon:stdio -M q35 -cpu host -display none \
     -m 1G -smp 2 -accel kvm,xen-version=0x4000a,kernel-irqchip=split \
     -kernel bzImage -append "console=ttyS0 root=/dev/xvda1" \
     -drive file=/var/lib/libvirt/images/fedora28.qcow2,if=none,id=disk \
     -device xen-disk,drive=disk,vdev=xvda

If we use -M pc instead of q35, we can even add an IDE disk and boot a
guest image normally through grub. But q35 gives us AHCI and that isn't
unplugged by the Xen magic, so the guests ends up seeing "both" disks.

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>


  Commit: 438bec498be43656ebf5c492c3c2e05b792dba51
      
https://github.com/qemu/qemu/commit/438bec498be43656ebf5c492c3c2e05b792dba51
  Author: David Woodhouse <dwmw@amazon.co.uk>
  Date:   2023-03-07 (Tue, 07 Mar 2023)

  Changed paths:
    M MAINTAINERS

  Log Message:
  -----------
  MAINTAINERS: Add entry for Xen on KVM emulation

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>


  Commit: 154eac37190c4d80d29b09c226abd899e397530f
      
https://github.com/qemu/qemu/commit/154eac37190c4d80d29b09c226abd899e397530f
  Author: David Woodhouse <dwmw@amazon.co.uk>
  Date:   2023-03-07 (Tue, 07 Mar 2023)

  Changed paths:
    M docs/system/i386/xen.rst

  Log Message:
  -----------
  docs: Update Xen-on-KVM documentation for PV disk support

Signed-off-by: David Woodhouse <dwmw@amazon.co.uk>
Reviewed-by: Paul Durrant <paul@xen.org>


  Commit: 15002921e878e6cf485f655d580733b5319ea015
      
https://github.com/qemu/qemu/commit/15002921e878e6cf485f655d580733b5319ea015
  Author: Peter Maydell <peter.maydell@linaro.org>
  Date:   2023-03-09 (Thu, 09 Mar 2023)

  Changed paths:
    M MAINTAINERS
    M accel/xen/xen-all.c
    M docs/system/i386/xen.rst
    M hw/9pfs/meson.build
    M hw/9pfs/xen-9p-backend.c
    M hw/block/dataplane/meson.build
    M hw/block/dataplane/xen-block.c
    M hw/block/meson.build
    M hw/block/xen-block.c
    M hw/char/meson.build
    M hw/char/xen_console.c
    M hw/display/meson.build
    M hw/display/xenfb.c
    M hw/i386/kvm/meson.build
    M hw/i386/kvm/trace-events
    M hw/i386/kvm/xen_evtchn.c
    M hw/i386/kvm/xen_gnttab.c
    M hw/i386/kvm/xen_gnttab.h
    M hw/i386/kvm/xen_xenstore.c
    A hw/i386/kvm/xenstore_impl.c
    A hw/i386/kvm/xenstore_impl.h
    M hw/i386/pc.c
    M hw/i386/pc_piix.c
    M hw/i386/xen/xen-hvm.c
    M hw/i386/xen/xen-mapcache.c
    M hw/i386/xen/xen_platform.c
    M hw/net/xen_nic.c
    M hw/usb/meson.build
    M hw/usb/xen-usb.c
    M hw/xen/meson.build
    M hw/xen/trace-events
    M hw/xen/xen-bus-helper.c
    M hw/xen/xen-bus.c
    M hw/xen/xen-legacy-backend.c
    A hw/xen/xen-operations.c
    M hw/xen/xen_devconfig.c
    M hw/xen/xen_pt.c
    M hw/xen/xen_pt.h
    M hw/xen/xen_pt_config_init.c
    M hw/xen/xen_pt_graphics.c
    M hw/xen/xen_pt_msi.c
    M hw/xen/xen_pvdev.c
    M include/hw/xen/xen-bus-helper.h
    M include/hw/xen/xen-bus.h
    M include/hw/xen/xen-legacy-backend.h
    M include/hw/xen/xen.h
    A include/hw/xen/xen_backend_ops.h
    R include/hw/xen/xen_common.h
    A include/hw/xen/xen_native.h
    M include/hw/xen/xen_pvdev.h
    M softmmu/globals.c
    M target/i386/kvm/xen-emu.c
    M tests/unit/meson.build
    A tests/unit/test-xs-node.c

  Log Message:
  -----------
  Merge tag 'xenfv-2' of git://git.infradead.org/users/dwmw2/qemu into staging

Enable PV backends with Xen/KVM emulation

This is phase 2, following on from the basic platform support which was
already merged.

 • Add a simple single-tenant internal XenStore implementation
 • Indirect Xen gnttab/evtchn/foreignmem/xenstore through operations table
 • Provide emulated back ends for Xen operations
 • Header cleanups to allow PV back ends to build without Xen itself
 • Enable PV back ends in emulated mode
 • Documentation update

Tested-by: Paul Durrant <paul@xen.org>
... on real Xen (master branch, 4.18) with a Debian guest.

# -----BEGIN PGP SIGNATURE-----
#
# iQJGBAABCgAwFiEEMUsIrNDeSBEzpfKGm+mA/QrAFUQFAmQHu3wSHGR3bXdAYW1h
# em9uLmNvLnVrAAoJEJvpgP0KwBVE5LYP/0VodDsQdP7Z4L+/IzgBSgEec7qmyQFB
# KlBZS/PmvCZKb0DHLI3GhXIyzD+/fnLtGSRl0rYObnKP7im+MpEDGmn97f6nIITk
# AzkdsVhNEBQFXCkLgQ9y8kTrTmsod9O4sqn0+naa2TX4FPcRN0MaNmpuLEubvaRS
# +JuyHmwy9ZeeAnsU31uJ0nx4F1hW9IDaatNoDeFcFnKCXQp36rtdZUViMowUJvwu
# Q+Xyg6dybusznaoiXd485tTPrTt+FK/wEARse3q2gRh9QblLu0r5BFb0rOfhYCTQ
# jw+5lBsOX+UlffmB9IDakRpVe4RKhvvRQSkRvYkPCshsqud9zMGhaquKg1vKBgca
# I31XSN0LCcon/ahHGtmVAxyZUpWdEnfzO1TbTNpz9oacROklgVgEYdw5Vwca71VD
# SURl6uCt9Jb9WmsR4twus4i4qDjQIDOtOF0hcxpl7HGktkxlGxUVI4qVLXARtVCS
# OTB6N0LlhJ2woj2wYK5BRTiOj03T2MkJEWaYhDdIrQREKWe2Sn4xTOH5kGbQQnOr
# km93odjBZFRHsAUnzXHXW3+yHjMefH7KrHePbmvsO4foGF77bBxosuC2ehFfvNJ0
# VM/H04NDtPYCBwdAr545PSN/q+WzEPQaquLZ0UuTBuPpMMOYd+Ff8YvQWJPyCM18
# 1mq9v6Xe9RQZ
# =JGLX
# -----END PGP SIGNATURE-----
# gpg: Signature made Tue 07 Mar 2023 22:32:28 GMT
# gpg:                using RSA key 314B08ACD0DE481133A5F2869BE980FD0AC01544
# gpg:                issuer "dwmw@amazon.co.uk"
# gpg: Good signature from "David Woodhouse <dwmw@amazon.co.uk>" [unknown]
# gpg:                 aka "David Woodhouse <dwmw@amazon.com>" [unknown]
# gpg: WARNING: This key is not certified with a trusted signature!
# gpg:          There is no indication that the signature belongs to the owner.
# Primary key fingerprint: 314B 08AC D0DE 4811 33A5  F286 9BE9 80FD 0AC0 1544

* tag 'xenfv-2' of git://git.infradead.org/users/dwmw2/qemu: (27 commits)
  docs: Update Xen-on-KVM documentation for PV disk support
  MAINTAINERS: Add entry for Xen on KVM emulation
  i386/xen: Initialize Xen backends from pc_basic_device_init() for emulation
  hw/xen: Implement soft reset for emulated gnttab
  hw/xen: Map guest XENSTORE_PFN grant in emulated Xenstore
  hw/xen: Add emulated implementation of XenStore operations
  hw/xen: Add emulated implementation of grant table operations
  hw/xen: Hook up emulated implementation for event channel operations
  hw/xen: Only advertise ring-page-order for xen-block if gnttab supports it
  hw/xen: Avoid crash when backend watch fires too early
  hw/xen: Build PV backend drivers for CONFIG_XEN_BUS
  hw/xen: Rename xen_common.h to xen_native.h
  hw/xen: Use XEN_PAGE_SIZE in PV backend drivers
  hw/xen: Move xenstore_store_pv_console_info to xen_console.c
  hw/xen: Add xenstore operations to allow redirection to internal emulation
  hw/xen: Add foreignmem operations to allow redirection to internal emulation
  hw/xen: Pass grant ref to gnttab unmap operation
  hw/xen: Add gnttab operations to allow redirection to internal emulation
  hw/xen: Add evtchn operations to allow redirection to internal emulation
  hw/xen: Create initial XenStore nodes
  ...

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>


Compare: https://github.com/qemu/qemu/compare/ba44caac0741...15002921e878



reply via email to

[Prev in Thread] Current Thread [Next in Thread]