Skip to contentSkip to conversation

QEMU:Xen stubdom vTPM for HVM virtual machine(QEMU Part)

PATCH In review Emil Condrea 7 participants 49 messages Jul 10, 2016 – Oct 4, 2016

lore
Share & tools
lore
#0 lore raw

v9 cover QEMU:Xen stubdom vTPM for HVM virtual machine(QEMU Part)

*INTRODUCTION*
The goal of virtual Trusted Platform Module (vTPM) is to provide a TPM functionality to virtual machines (Fedora, Ubuntu, Redhat, Windows .etc). This allows programs to interact with a TPM in a virtual machine the same way they interact with a TPM on the physical system. Each virtual machine gets its own unique, emulated, software TPM. Each major component of vTPM is implemented as a stubdom, providing secure separation guaranteed by the hypervisor.

The vTPM stubdom is a Xen mini-OS domain that emulates a TPM for the virtual machine to use. It is a small wrapper around the Berlios TPM emulator. TPM commands are passed from mini-os TPM backend driver.

*ARCHITECTURE*
The architecture of stubdom vTPM for HVM virtual machine:

            +--------------------+
            | Windows/Linux DomU | ...
            |        |  ^        |
            |        v  |        |
            |  Qemu tpm1.2 Tis   |
            |        |  ^        |
            |        v  |        |
            | XenStubdoms backend|
            +--------------------+
                     |  ^
                     v  |
            +--------------------+
            |      XenDevOps     |
            +--------------------+
                     |  ^
                     v  |
            +--------------------+
            |  mini-os/tpmback   |
            |        |  ^        |
            |        v  |        |
            |   vtpm-stubdom     | ...
            |        |  ^        |
            |        v  |        |
            |  mini-os/tpmfront  |
            +--------------------+
                     |  ^
                     v  |
            +--------------------+
            |  mini-os/tpmback   |
            |        |  ^        |
            |        v  |        |
            |  vtpmmgr-stubdom   |
            |        |  ^        |
            |        v  |        |
            |  mini-os/tpm_tis   |
            +--------------------+
                     |  ^
                     v  |
            +--------------------+
            |    Hardware TPM    |
            +--------------------+

* Windows/Linux DomU:
The HVM based guest that wants to use a vTPM. There may be more than one of these.

* Qemu tpm1.2 Tis:
Implementation of the tpm1.2 Tis interface for HVM virtual machines. It is Qemu emulation device.

* vTPM xenstubdoms driver:
Qemu vTPM driver. This driver provides vtpm initialization and sending data and commends to a para-virtualized vtpm stubdom.

* XenDevOps:
Register Xen stubdom vTPM frontend driver, and transfer any request/repond between TPM xenstubdoms driver and Xen vTPM stubdom. Facilitate communications between Xen vTPM stubdom and vTPM xenstubdoms driver.

* mini-os/tpmback:
Mini-os TPM backend driver. The Linux frontend driver connects to this backend driver to facilitate communications between the Linux DomU and its vTPM. This driver is also used by vtpmmgr stubdom to communicate with vtpm-stubdom.

* vtpm-stubdom:
A mini-os stub domain that implements a vTPM. There is a one to one mapping between running vtpm-stubdom instances and logical vtpms on the system. The vTPM Platform Configuration Registers (PCRs) are all initialized to zero.

* mini-os/tpmfront:
Mini-os TPM frontend driver. The vTPM mini-os domain vtpm stubdom uses this driver to communicate with vtpmmgr-stubdom. This driver could also be used separately to implement a mini-os domain that wishes to use a vTPM of its own.

* vtpmmgr-stubdom:
A mini-os domain that implements the vTPM manager. There is only one vTPM manager and it should be running during the entire lifetime of the machine. vtpmmgr domain securely stores encryption keys for each of the vtpms and accesses to the hardware TPM to get the root of trust for the entire system.

* mini-os/tpm_tis:
Mini-os TPM version 1.2 TPM Interface Specification (TIS) driver. This driver used by vtpmmgr-stubdom to talk directly to the hardware TPM. Communication is facilitated by mapping hardware memory pages into vtpmmgr stubdom.

* Hardware TPM: The physical TPM 1.2 that is soldered onto the motherboard.

---
Changes in v9
High level changes: (each patch has a detailed history versioning)
* rebase on upstream qemu
* refactor qemu xendevs, xenstore functions in order to be shared with both backend and frontends
* convert tpm stubdoms to new qapi layout
* use libxengnttab, libxenevtchn stable API instead of xc_* calls
* added reset_tpm_established_flag and get_tpm_version for TPMDriverOps
* instead of xen_frontend.c global variable xenstore_dev, use vtpm specific
xenstore_vtpm_dev (since it will be needed just for tpm_xenstubdoms qemu driver)

Emil Condrea (19):
xen: Create a new file xen_pvdev.c
xen: Create a new file xen_frontend.c
xen: Move xenstore_update to xen_pvdev.c
xen: Move evtchn functions to xen_pvdev.c
xen: Prepare xendev qtail to be shared with frontends
xen: Rename xen_be_printf to xen_pv_printf
xen: Rename xen_be_unbind_evtchn
xen: Rename xen_be_send_notify
xen: Rename xen_be_evtchn_event
xen: Rename xen_be_find_xendev
xen: Rename xen_be_del_xendev
xen: Rename xen_be_frontend_changed
xen: Distinguish between frontend and backend devops
Qemu-Xen-vTPM: Support for Xen stubdom vTPM command line options
Qemu-Xen-vTPM: Xen frontend driver infrastructure
Qemu-Xen-vTPM: Register Xen stubdom vTPM frontend driver
Qemu-Xen-vTPM: Move tpm_passthrough_is_selftest() into tpm_util.c
Qemu-Xen-vTPM: Qemu vTPM xenstubdoms backend
Qemu-Xen-vTPM: QEMU machine class is initialized before tpm_init()

 backends/tpm.c                   |  11 ++
 configure                        |  14 ++
 hmp.c                            |   2 +
 hw/block/xen_disk.c              |  59 +++---
 hw/char/xen_console.c            |  16 +-
 hw/display/xenfb.c               |  57 +++---
 hw/net/xen_nic.c                 |  29 +--
 hw/tpm/Makefile.objs             |   3 +-
 hw/tpm/tpm_passthrough.c         |  13 +-
 hw/tpm/tpm_util.c                |  11 ++
 hw/tpm/tpm_util.h                |   1 +
 hw/tpm/tpm_xenstubdoms.c         | 284 ++++++++++++++++++++++++++
 hw/tpm/xen_vtpm_frontend.c       | 303 ++++++++++++++++++++++++++++
 hw/tpm/xen_vtpm_frontend.h       |  10 +
 hw/usb/xen-usb.c                 |  38 ++--
 hw/xen/Makefile.objs             |   2 +-
 hw/xen/xen_backend.c             | 378 ++++-------------------------------
 hw/xen/xen_devconfig.c           |   4 +-
 hw/xen/xen_frontend.c            | 416 +++++++++++++++++++++++++++++++++++++++
 hw/xen/xen_pvdev.c               | 298 ++++++++++++++++++++++++++++
 include/hw/xen/xen_backend.h     |  71 +------
 include/hw/xen/xen_frontend.h    |  20 ++
 include/hw/xen/xen_pvdev.h       |  83 ++++++++
 include/sysemu/tpm_backend_int.h |   2 +
 qapi-schema.json                 |  16 +-
 qemu-options.hx                  |  13 +-
 tpm.c                            |   7 +-
 vl.c                             |  17 +-
 xen-common.c                     |   4 +-
 xen-hvm.c                        |   6 +
 30 files changed, 1649 insertions(+), 539 deletions(-)
 create mode 100644 hw/tpm/tpm_xenstubdoms.c
 create mode 100644 hw/tpm/xen_vtpm_frontend.c
 create mode 100644 hw/tpm/xen_vtpm_frontend.h
 create mode 100644 hw/xen/xen_frontend.c
 create mode 100644 hw/xen/xen_pvdev.c
 create mode 100644 include/hw/xen/xen_frontend.h
 create mode 100644 include/hw/xen/xen_pvdev.h
Signature · 1 line
1.9.1
#1 lore raw

PATCH v9 1/19 xen: Create a new file xen_pvdev.c

The purpose of the new file is to store generic functions shared by frontend and backends such as xenstore operations, xendevs.

---
 hw/xen/Makefile.objs         |   2 +-
 hw/xen/xen_backend.c         | 125 +-----------------------------------
 hw/xen/xen_pvdev.c           | 149 +++++++++++++++++++++++++++++++++++++++++++
 include/hw/xen/xen_backend.h |  63 +-----------------
 include/hw/xen/xen_pvdev.h   |  71 +++++++++++++++++++++
 5 files changed, 223 insertions(+), 187 deletions(-)
 create mode 100644 hw/xen/xen_pvdev.c
 create mode 100644 include/hw/xen/xen_pvdev.h
hw/xen/Makefile.objs +1 -1
index d367094..591cdc2 100644
@@ -1,5 +1,5 @@
 # xen backend driver support
-common-obj-$(CONFIG_XEN_BACKEND) += xen_backend.o xen_devconfig.o
+common-obj-$(CONFIG_XEN_BACKEND) += xen_backend.o xen_devconfig.o xen_pvdev.o
 
 obj-$(CONFIG_XEN_PCI_PASSTHROUGH) += xen-host-pci-device.o
 obj-$(CONFIG_XEN_PCI_PASSTHROUGH) += xen_pt.o xen_pt_config_init.o xen_pt_graphics.o xen_pt_msi.o
hw/xen/xen_backend.c +1 -124

161 lines not on this page · raw message

hw/xen/xen_pvdev.c new file +149 -0

149 lines not on this page · raw message

include/hw/xen/xen_backend.h +1 -62

93 lines not on this page · raw message

include/hw/xen/xen_pvdev.h new file +71 -0

71 lines not on this page · raw message

Signature · 7 lines
1.9.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#2 lore raw

PATCH v9 1/19 xen: Create a new file xen_pvdev.c

In reply to Emil Condrea

The purpose of the new file is to store generic functions shared by frontend and backends such as xenstore operations, xendevs.

---
 hw/xen/Makefile.objs         |   2 +-
 hw/xen/xen_backend.c         | 125 +-----------------------------------
 hw/xen/xen_pvdev.c           | 149 +++++++++++++++++++++++++++++++++++++++++++
 include/hw/xen/xen_backend.h |  63 +-----------------
 include/hw/xen/xen_pvdev.h   |  71 +++++++++++++++++++++
 5 files changed, 223 insertions(+), 187 deletions(-)
 create mode 100644 hw/xen/xen_pvdev.c
 create mode 100644 include/hw/xen/xen_pvdev.h
hw/xen/Makefile.objs +1 -1
index d367094..591cdc2 100644
@@ -1,5 +1,5 @@
 # xen backend driver support
-common-obj-$(CONFIG_XEN_BACKEND) += xen_backend.o xen_devconfig.o
+common-obj-$(CONFIG_XEN_BACKEND) += xen_backend.o xen_devconfig.o xen_pvdev.o
 
 obj-$(CONFIG_XEN_PCI_PASSTHROUGH) += xen-host-pci-device.o
 obj-$(CONFIG_XEN_PCI_PASSTHROUGH) += xen_pt.o xen_pt_config_init.o xen_pt_graphics.o xen_pt_msi.o
hw/xen/xen_backend.c +1 -124

161 lines not on this page · raw message

hw/xen/xen_pvdev.c new file +149 -0

149 lines not on this page · raw message

include/hw/xen/xen_backend.h +1 -62

93 lines not on this page · raw message

include/hw/xen/xen_pvdev.h new file +71 -0

71 lines not on this page · raw message

Signature · 1 line
1.9.1
#3 lore raw

Re: [Qemu-devel] [PATCH 01/19] xen: Create a new file xen_pvdev.c

Quoted 21 lines · Emil Condrea

The purpose of the new file is to store generic functions shared by frontend and backends such as xenstore operations, xendevs.

---
 hw/xen/Makefile.objs         |   2 +-
 hw/xen/xen_backend.c         | 125 +-----------------------------------
 hw/xen/xen_pvdev.c           | 149 +++++++++++++++++++++++++++++++++++++++++++
 include/hw/xen/xen_backend.h |  63 +-----------------
 include/hw/xen/xen_pvdev.h   |  71 +++++++++++++++++++++
 5 files changed, 223 insertions(+), 187 deletions(-)
 create mode 100644 hw/xen/xen_pvdev.c
 create mode 100644 include/hw/xen/xen_pvdev.h
include/hw/xen/xen_pvdev.h new file +0 -0
new file mode 100644
index 0000000..f60bfae

include/hw/xen/xen_pvdev.h line 2

Quoted 2 lines
include/hw/xen/xen_pvdev.h new file +2 -0
@@ -0,0 +1,71 @@
+#ifndef QEMU_HW_XEN_PVDEV_H
+#define QEMU_HW_XEN_PVDEV_H 1

No need for the 1. Just "#define X" is enough.

include/hw/xen/xen_pvdev.h line 5

Quoted 3 lines
include/hw/xen/xen_pvdev.h new file +3 -0
+
+#include "hw/xen/xen_common.h"
+#include <inttypes.h>

I don't think this include is needed.

Signature · 6 lines
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#4 lore raw

Re: [Qemu-devel] [PATCH 01/19] xen: Create a new file xen_pvdev.c

In reply to Emil Condrea
Quoted 21 lines · Emil Condrea

The purpose of the new file is to store generic functions shared by frontend and backends such as xenstore operations, xendevs.

---
 hw/xen/Makefile.objs         |   2 +-
 hw/xen/xen_backend.c         | 125 +-----------------------------------
 hw/xen/xen_pvdev.c           | 149 +++++++++++++++++++++++++++++++++++++++++++
 include/hw/xen/xen_backend.h |  63 +-----------------
 include/hw/xen/xen_pvdev.h   |  71 +++++++++++++++++++++
 5 files changed, 223 insertions(+), 187 deletions(-)
 create mode 100644 hw/xen/xen_pvdev.c
 create mode 100644 include/hw/xen/xen_pvdev.h
include/hw/xen/xen_pvdev.h new file +0 -0
new file mode 100644
index 0000000..f60bfae

include/hw/xen/xen_pvdev.h line 2

Quoted 2 lines
include/hw/xen/xen_pvdev.h new file +2 -0
@@ -0,0 +1,71 @@
+#ifndef QEMU_HW_XEN_PVDEV_H
+#define QEMU_HW_XEN_PVDEV_H 1

No need for the 1. Just "#define X" is enough.

include/hw/xen/xen_pvdev.h line 5

Quoted 3 lines
include/hw/xen/xen_pvdev.h new file +3 -0
+
+#include "hw/xen/xen_common.h"
+#include <inttypes.h>

I don't think this include is needed.

Signature · 1 line
Anthony PERARD
#5 lore raw

PATCH v9 2/19 xen: Create a new file xen_frontend.c

In reply to Emil Condrea

Its purpose is to store frontend related functions.

---
 hw/block/xen_disk.c           |  1 +
 hw/display/xenfb.c            |  1 +
 hw/net/xen_nic.c              |  1 +
 hw/xen/Makefile.objs          |  2 +-
 hw/xen/xen_backend.c          | 47 +----------------------------
 hw/xen/xen_frontend.c         | 70 +++++++++++++++++++++++++++++++++++++++++++
 include/hw/xen/xen_backend.h  |  3 --
 include/hw/xen/xen_frontend.h | 10 +++++++
 8 files changed, 85 insertions(+), 50 deletions(-)
 create mode 100644 hw/xen/xen_frontend.c
 create mode 100644 include/hw/xen/xen_frontend.h
hw/block/xen_disk.c +1 -0
index 90aca73..28fbf24 100644
@@ -25,6 +25,7 @@
 
 #include "hw/hw.h"
 #include "hw/xen/xen_backend.h"
+#include "hw/xen/xen_frontend.h"
 #include "xen_blkif.h"
 #include "sysemu/blockdev.h"
 #include "sysemu/block-backend.h"
hw/display/xenfb.c +1 -0
index 46b7d5e..5751113 100644
@@ -30,6 +30,7 @@
 #include "ui/console.h"
 #include "sysemu/char.h"
 #include "hw/xen/xen_backend.h"
+#include "hw/xen/xen_frontend.h"
 
 #include <xen/event_channel.h>
 #include <xen/io/fbif.h>
hw/net/xen_nic.c +1 -0
index 0b4ddae..bdfa789 100644
@@ -29,6 +29,7 @@
 #include "net/checksum.h"
 #include "net/util.h"
 #include "hw/xen/xen_backend.h"
+#include "hw/xen/xen_frontend.h"
 
 #include <xen/io/netif.h>
 
hw/xen/Makefile.objs +1 -1
index 591cdc2..1000294 100644
@@ -1,5 +1,5 @@
 # xen backend driver support
-common-obj-$(CONFIG_XEN_BACKEND) += xen_backend.o xen_devconfig.o xen_pvdev.o
+common-obj-$(CONFIG_XEN_BACKEND) += xen_backend.o xen_frontend.o xen_devconfig.o xen_pvdev.o
 
 obj-$(CONFIG_XEN_PCI_PASSTHROUGH) += xen-host-pci-device.o
 obj-$(CONFIG_XEN_PCI_PASSTHROUGH) += xen_pt.o xen_pt_config_init.o xen_pt_graphics.o xen_pt_msi.o
hw/xen/xen_backend.c +1 -46

65 lines not on this page · raw message

hw/xen/xen_frontend.c new file +70 -0

70 lines not on this page · raw message

include/hw/xen/xen_backend.h +0 -3
index 0f009e3..0daaf7c 100644
@@ -19,9 +19,6 @@ int xenstore_write_be_int(struct XenDevice *xendev, const char *node, int ival);
 int xenstore_write_be_int64(struct XenDevice *xendev, const char *node, int64_t ival);
 char *xenstore_read_be_str(struct XenDevice *xendev, const char *node);
 int xenstore_read_be_int(struct XenDevice *xendev, const char *node, int *ival);
-char *xenstore_read_fe_str(struct XenDevice *xendev, const char *node);
-int xenstore_read_fe_int(struct XenDevice *xendev, const char *node, int *ival);
-int xenstore_read_fe_uint64(struct XenDevice *xendev, const char *node, uint64_t *uval);
 
 struct XenDevice *xen_be_find_xendev(const char *type, int dom, int dev);
 void xen_be_check_state(struct XenDevice *xendev);
include/hw/xen/xen_frontend.h new file +10 -0
new file mode 100644
index 0000000..46485b9
@@ -0,0 +1,10 @@
+#ifndef QEMU_HW_XEN_FRONTEND_H
+#define QEMU_HW_XEN_FRONTEND_H 1
+
+char *xenstore_read_fe_str(struct XenDevice *xendev, const char *node);
+int xenstore_read_fe_int(struct XenDevice *xendev, const char *node, int *ival);
+int xenstore_read_fe_uint64(struct XenDevice *xendev, const char *node, uint64_t *uval);
+
+void xen_be_frontend_changed(struct XenDevice *xendev, const char *node);
+
+#endif /* QEMU_HW_XEN_FRONTEND_H */
Signature · 7 lines
1.9.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#6 lore raw

Re: [PATCH 02/19] xen: Create a new file xen_frontend.c

Quoted 46 lines · Emil Condrea

Its purpose is to store frontend related functions.

---
 hw/block/xen_disk.c           |  1 +
 hw/display/xenfb.c            |  1 +
 hw/net/xen_nic.c              |  1 +
 hw/xen/Makefile.objs          |  2 +-
 hw/xen/xen_backend.c          | 47 +----------------------------
 hw/xen/xen_frontend.c         | 70 +++++++++++++++++++++++++++++++++++++++++++
 include/hw/xen/xen_backend.h  |  3 --
 include/hw/xen/xen_frontend.h | 10 +++++++
 8 files changed, 85 insertions(+), 50 deletions(-)
 create mode 100644 hw/xen/xen_frontend.c
 create mode 100644 include/hw/xen/xen_frontend.h
hw/block/xen_disk.c +1 -0
index 90aca73..28fbf24 100644
@@ -25,6 +25,7 @@
 
 #include "hw/hw.h"
 #include "hw/xen/xen_backend.h"
+#include "hw/xen/xen_frontend.h"
 #include "xen_blkif.h"
 #include "sysemu/blockdev.h"
 #include "sysemu/block-backend.h"
hw/display/xenfb.c +1 -0
index 46b7d5e..5751113 100644
@@ -30,6 +30,7 @@
 #include "ui/console.h"
 #include "sysemu/char.h"
 #include "hw/xen/xen_backend.h"
+#include "hw/xen/xen_frontend.h"
 
 #include <xen/event_channel.h>
 #include <xen/io/fbif.h>
hw/net/xen_nic.c +0 -0
index 0b4ddae..bdfa789 100644

hw/net/xen_nic.c line 35

Quoted 7 lines
hw/net/xen_nic.c +1 -0
@@ -29,6 +29,7 @@
 #include "net/checksum.h"
 #include "net/util.h"
 #include "hw/xen/xen_backend.h"
+#include "hw/xen/xen_frontend.h"
 
 #include <xen/io/netif.h>
 

There is also "hw/usb/xen-usb.c" that needs to be updated to include "hw/xen/xen_frontend.h".

include/hw/xen/xen_frontend.h line 2

Quoted 8 lines
include/hw/xen/xen_frontend.h new file +2 -0
new file mode 100644
index 0000000..46485b9
@@ -0,0 +1,10 @@
+#ifndef QEMU_HW_XEN_FRONTEND_H
+#define QEMU_HW_XEN_FRONTEND_H 1

No need for the 1 here.

Signature · 6 lines
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#7 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH 02/19] xen: Create a new file xen_frontend.c

In reply to Emil Condrea
Quoted 46 lines · Emil Condrea

Its purpose is to store frontend related functions.

---
 hw/block/xen_disk.c           |  1 +
 hw/display/xenfb.c            |  1 +
 hw/net/xen_nic.c              |  1 +
 hw/xen/Makefile.objs          |  2 +-
 hw/xen/xen_backend.c          | 47 +----------------------------
 hw/xen/xen_frontend.c         | 70 +++++++++++++++++++++++++++++++++++++++++++
 include/hw/xen/xen_backend.h  |  3 --
 include/hw/xen/xen_frontend.h | 10 +++++++
 8 files changed, 85 insertions(+), 50 deletions(-)
 create mode 100644 hw/xen/xen_frontend.c
 create mode 100644 include/hw/xen/xen_frontend.h
hw/block/xen_disk.c +1 -0
index 90aca73..28fbf24 100644
@@ -25,6 +25,7 @@
 
 #include "hw/hw.h"
 #include "hw/xen/xen_backend.h"
+#include "hw/xen/xen_frontend.h"
 #include "xen_blkif.h"
 #include "sysemu/blockdev.h"
 #include "sysemu/block-backend.h"
hw/display/xenfb.c +1 -0
index 46b7d5e..5751113 100644
@@ -30,6 +30,7 @@
 #include "ui/console.h"
 #include "sysemu/char.h"
 #include "hw/xen/xen_backend.h"
+#include "hw/xen/xen_frontend.h"
 
 #include <xen/event_channel.h>
 #include <xen/io/fbif.h>
hw/net/xen_nic.c +0 -0
index 0b4ddae..bdfa789 100644

hw/net/xen_nic.c line 35

Quoted 7 lines
hw/net/xen_nic.c +1 -0
@@ -29,6 +29,7 @@
 #include "net/checksum.h"
 #include "net/util.h"
 #include "hw/xen/xen_backend.h"
+#include "hw/xen/xen_frontend.h"
 
 #include <xen/io/netif.h>
 

There is also "hw/usb/xen-usb.c" that needs to be updated to include "hw/xen/xen_frontend.h".

include/hw/xen/xen_frontend.h line 2

Quoted 8 lines
include/hw/xen/xen_frontend.h new file +2 -0
new file mode 100644
index 0000000..46485b9
@@ -0,0 +1,10 @@
+#ifndef QEMU_HW_XEN_FRONTEND_H
+#define QEMU_HW_XEN_FRONTEND_H 1

No need for the 1 here.

Signature · 1 line
Anthony PERARD
#8 lore raw

PATCH v9 3/19 xen: Move xenstore_update to xen_pvdev.c

In reply to Emil Condrea

* xenstore_update -> xen_pvdev.c
* xenstore_update_fe -> xen_frontend.c

---
 hw/xen/xen_backend.c          | 43 +------------------------------------------
 hw/xen/xen_frontend.c         | 18 ++++++++++++++++++
 hw/xen/xen_pvdev.c            | 24 ++++++++++++++++++++++++
 include/hw/xen/xen_backend.h  |  1 +
 include/hw/xen/xen_frontend.h |  1 +
 include/hw/xen/xen_pvdev.h    |  1 +
 6 files changed, 46 insertions(+), 42 deletions(-)
hw/xen/xen_backend.c +1 -42
index 7a83a7d..0a9f9bb 100644
@@ -527,7 +527,7 @@ static int xenstore_scan(const char *type, int dom, struct XenDevOps *ops)
     return 0;
 }
 
-static void xenstore_update_be(char *watch, char *type, int dom,
+void xenstore_update_be(char *watch, char *type, int dom,
                                struct XenDevOps *ops)
 {
     struct XenDevice *xendev;
@@ -561,47 +561,6 @@ static void xenstore_update_be(char *watch, char *type, int dom,
     }
 }
 
-static void xenstore_update_fe(char *watch, struct XenDevice *xendev)
-{
-    char *node;
-    unsigned int len;
-
-    len = strlen(xendev->fe);
-    if (strncmp(xendev->fe, watch, len) != 0) {
-        return;
-    }
-    if (watch[len] != '/') {
-        return;
-    }
-    node = watch + len + 1;
-
-    xen_be_frontend_changed(xendev, node);
-    xen_be_check_state(xendev);
-}
-
-static void xenstore_update(void *unused)
-{
-    char **vec = NULL;
-    intptr_t type, ops, ptr;
-    unsigned int dom, count;
-
-    vec = xs_read_watch(xenstore, &count);
-    if (vec == NULL) {
-        goto cleanup;
-    }
-
-    if (sscanf(vec[XS_WATCH_TOKEN], "be:%" PRIxPTR ":%d:%" PRIxPTR,
-               &type, &dom, &ops) == 3) {
-        xenstore_update_be(vec[XS_WATCH_PATH], (void*)type, dom, (void*)ops);
-    }
-    if (sscanf(vec[XS_WATCH_TOKEN], "fe:%" PRIxPTR, &ptr) == 1) {
-        xenstore_update_fe(vec[XS_WATCH_PATH], (void*)ptr);
-    }
-
-cleanup:
-    free(vec);
-}
-
 static void xen_be_evtchn_event(void *opaque)
 {
     struct XenDevice *xendev = opaque;
hw/xen/xen_frontend.c +18 -0
index b4bf8da..4e01169 100644
@@ -68,3 +68,21 @@ void xen_be_frontend_changed(struct XenDevice *xendev, const char *node)
         }
     }
 }
+
+void xenstore_update_fe(char *watch, struct XenDevice *xendev)
+{
+    char *node;
+    unsigned int len;
+
+    len = strlen(xendev->fe);
+    if (strncmp(xendev->fe, watch, len) != 0) {
+        return;
+    }
+    if (watch[len] != '/') {
+        return;
+    }
+    node = watch + len + 1;
+
+    xen_be_frontend_changed(xendev, node);
+    xen_be_check_state(xendev);
+}
hw/xen/xen_pvdev.c +24 -0
index a444855..001fda2 100644
@@ -20,6 +20,7 @@
 #include "qemu/osdep.h"
 
 #include "hw/xen/xen_backend.h"
+#include "hw/xen/xen_frontend.h"
 #include "hw/xen/xen_pvdev.h"
 
 static int debug = 0;
@@ -95,6 +96,29 @@ int xenstore_read_uint64(const char *base, const char *node, uint64_t *uval)
     return rc;
 }
 
+void xenstore_update(void *unused)
+{
+    char **vec = NULL;
+    intptr_t type, ops, ptr;
+    unsigned int dom, count;
+
+    vec = xs_read_watch(xenstore, &count);
+    if (vec == NULL) {
+        goto cleanup;
+    }
+
+    if (sscanf(vec[XS_WATCH_TOKEN], "be:%" PRIxPTR ":%d:%" PRIxPTR,
+               &type, &dom, &ops) == 3) {
+        xenstore_update_be(vec[XS_WATCH_PATH], (void*)type, dom, (void*)ops);
+    }
+    if (sscanf(vec[XS_WATCH_TOKEN], "fe:%" PRIxPTR, &ptr) == 1) {
+        xenstore_update_fe(vec[XS_WATCH_PATH], (void*)ptr);
+    }
+
+cleanup:
+    free(vec);
+}
+
 const char *xenbus_strstate(enum xenbus_state state)
 {
     static const char *const name[] = {
include/hw/xen/xen_backend.h +1 -0
index 0daaf7c..4832f79 100644
@@ -19,6 +19,7 @@ int xenstore_write_be_int(struct XenDevice *xendev, const char *node, int ival);
 int xenstore_write_be_int64(struct XenDevice *xendev, const char *node, int64_t ival);
 char *xenstore_read_be_str(struct XenDevice *xendev, const char *node);
 int xenstore_read_be_int(struct XenDevice *xendev, const char *node, int *ival);
+void xenstore_update_be(char *watch, char *type, int dom, struct XenDevOps *ops);
 
 struct XenDevice *xen_be_find_xendev(const char *type, int dom, int dev);
 void xen_be_check_state(struct XenDevice *xendev);
include/hw/xen/xen_frontend.h +1 -0
index 46485b9..7d87da4 100644
@@ -4,6 +4,7 @@
 char *xenstore_read_fe_str(struct XenDevice *xendev, const char *node);
 int xenstore_read_fe_int(struct XenDevice *xendev, const char *node, int *ival);
 int xenstore_read_fe_uint64(struct XenDevice *xendev, const char *node, uint64_t *uval);
+void xenstore_update_fe(char *watch, struct XenDevice *xendev);
 
 void xen_be_frontend_changed(struct XenDevice *xendev, const char *node);
 
include/hw/xen/xen_pvdev.h +1 -0
index f60bfae..cc49636 100644
@@ -62,6 +62,7 @@ int xenstore_write_int64(const char *base, const char *node, int64_t ival);
 char *xenstore_read_str(const char *base, const char *node);
 int xenstore_read_int(const char *base, const char *node, int *ival);
 int xenstore_read_uint64(const char *base, const char *node, uint64_t *uval);
+void xenstore_update(void *unused);
 
 const char *xenbus_strstate(enum xenbus_state state);
 
Signature · 7 lines
1.9.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#9 lore raw

PATCH v9 4/19 xen: Move evtchn functions to xen_pvdev.c

In reply to Emil Condrea

The name of the functions moved:
* xen_be_evtchn_event
* xen_be_unbind_evtchn
* xen_be_send_notify

---
 hw/xen/xen_backend.c         | 37 +------------------------------------
 hw/xen/xen_pvdev.c           | 35 +++++++++++++++++++++++++++++++++++
 include/hw/xen/xen_backend.h |  2 --
 include/hw/xen/xen_pvdev.h   |  4 ++++
 4 files changed, 40 insertions(+), 38 deletions(-)
hw/xen/xen_backend.c +1 -36
index 0a9f9bb..5f2821a 100644
@@ -561,25 +561,6 @@ void xenstore_update_be(char *watch, char *type, int dom,
     }
 }
 
-static void xen_be_evtchn_event(void *opaque)
-{
-    struct XenDevice *xendev = opaque;
-    evtchn_port_t port;
-
-    port = xenevtchn_pending(xendev->evtchndev);
-    if (port != xendev->local_port) {
-        xen_be_printf(xendev, 0,
-                      "xenevtchn_pending returned %d (expected %d)\n",
-                      port, xendev->local_port);
-        return;
-    }
-    xenevtchn_unmask(xendev->evtchndev, port);
-
-    if (xendev->ops->event) {
-        xendev->ops->event(xendev);
-    }
-}
-
 /* -------------------------------------------------------------------- */
 
 int xen_be_init(void)
@@ -646,22 +627,6 @@ int xen_be_bind_evtchn(struct XenDevice *xendev)
     return 0;
 }
 
-void xen_be_unbind_evtchn(struct XenDevice *xendev)
-{
-    if (xendev->local_port == -1) {
-        return;
-    }
-    qemu_set_fd_handler(xenevtchn_fd(xendev->evtchndev), NULL, NULL, NULL);
-    xenevtchn_unbind(xendev->evtchndev, xendev->local_port);
-    xen_be_printf(xendev, 2, "unbind evtchn port %d\n", xendev->local_port);
-    xendev->local_port = -1;
-}
-
-int xen_be_send_notify(struct XenDevice *xendev)
-{
-    return xenevtchn_notify(xendev->evtchndev, xendev->local_port);
-}
-
 
 static int xen_sysdev_init(SysBusDevice *dev)
 {
@@ -693,4 +658,4 @@ static void xenbe_register_types(void)
     type_register_static(&xensysdev_info);
 }
 
-type_init(xenbe_register_types);
+type_init(xenbe_register_types);
\ No newline at end of file
hw/xen/xen_pvdev.c +35 -0
index 001fda2..7876724 100644
@@ -171,3 +171,38 @@ void xen_be_printf(struct XenDevice *xendev, int msg_level, const char *fmt, ...
     }
     qemu_log_flush();
 }
+
+void xen_be_evtchn_event(void *opaque)
+{
+    struct XenDevice *xendev = opaque;
+    evtchn_port_t port;
+
+    port = xenevtchn_pending(xendev->evtchndev);
+    if (port != xendev->local_port) {
+        xen_be_printf(xendev, 0,
+                      "xenevtchn_pending returned %d (expected %d)\n",
+                      port, xendev->local_port);
+        return;
+    }
+    xenevtchn_unmask(xendev->evtchndev, port);
+
+    if (xendev->ops->event) {
+        xendev->ops->event(xendev);
+    }
+}
+
+void xen_be_unbind_evtchn(struct XenDevice *xendev)
+{
+    if (xendev->local_port == -1) {
+        return;
+    }
+    qemu_set_fd_handler(xenevtchn_fd(xendev->evtchndev), NULL, NULL, NULL);
+    xenevtchn_unbind(xendev->evtchndev, xendev->local_port);
+    xen_be_printf(xendev, 2, "unbind evtchn port %d\n", xendev->local_port);
+    xendev->local_port = -1;
+}
+
+int xen_be_send_notify(struct XenDevice *xendev)
+{
+    return xenevtchn_notify(xendev->evtchndev, xendev->local_port);
+}
include/hw/xen/xen_backend.h +0 -2
index 4832f79..60b634e 100644
@@ -29,8 +29,6 @@ int xen_be_init(void);
 int xen_be_register(const char *type, struct XenDevOps *ops);
 int xen_be_set_state(struct XenDevice *xendev, enum xenbus_state state);
 int xen_be_bind_evtchn(struct XenDevice *xendev);
-void xen_be_unbind_evtchn(struct XenDevice *xendev);
-int xen_be_send_notify(struct XenDevice *xendev);
 
 /* actual backend drivers */
 extern struct XenDevOps xen_console_ops;      /* xen_console.c     */
include/hw/xen/xen_pvdev.h +4 -0
index cc49636..f269b04 100644
@@ -66,6 +66,10 @@ void xenstore_update(void *unused);
 
 const char *xenbus_strstate(enum xenbus_state state);
 
+void xen_be_evtchn_event(void *opaque);
+void xen_be_unbind_evtchn(struct XenDevice *xendev);
+int xen_be_send_notify(struct XenDevice *xendev);
+
 void xen_be_printf(struct XenDevice *xendev, int msg_level, const char *fmt, ...)
     GCC_FMT_ATTR(3, 4);
 
Signature · 7 lines
1.9.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#10 lore raw

Re: [PATCH 04/19] xen: Move evtchn functions to xen_pvdev.c

Quoted 18 lines · Emil Condrea

The name of the functions moved:
* xen_be_evtchn_event
* xen_be_unbind_evtchn
* xen_be_send_notify

---
 hw/xen/xen_backend.c         | 37 +------------------------------------
 hw/xen/xen_pvdev.c           | 35 +++++++++++++++++++++++++++++++++++
 include/hw/xen/xen_backend.h |  2 --
 include/hw/xen/xen_pvdev.h   |  4 ++++
 4 files changed, 40 insertions(+), 38 deletions(-)
hw/xen/xen_backend.c +0 -0
index 0a9f9bb..5f2821a 100644

hw/xen/xen_backend.c static void xenbe_register_types(void) · line 661

Quoted 6 lines
hw/xen/xen_backend.c +1 -1
@@ -693,4 +658,4 @@ static void xenbe_register_types(void)
     type_register_static(&xensysdev_info);
 }
 
-type_init(xenbe_register_types);
+type_init(xenbe_register_types);
\ No newline at end of file

Looks like this change does not belong to this patch.

Signature · 6 lines
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#11 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH 04/19] xen: Move evtchn functions to xen_pvdev.c

In reply to Emil Condrea
Quoted 18 lines · Emil Condrea

The name of the functions moved:
* xen_be_evtchn_event
* xen_be_unbind_evtchn
* xen_be_send_notify

---
 hw/xen/xen_backend.c         | 37 +------------------------------------
 hw/xen/xen_pvdev.c           | 35 +++++++++++++++++++++++++++++++++++
 include/hw/xen/xen_backend.h |  2 --
 include/hw/xen/xen_pvdev.h   |  4 ++++
 4 files changed, 40 insertions(+), 38 deletions(-)
hw/xen/xen_backend.c +0 -0
index 0a9f9bb..5f2821a 100644

hw/xen/xen_backend.c static void xenbe_register_types(void) · line 661

Quoted 6 lines
hw/xen/xen_backend.c +1 -1
@@ -693,4 +658,4 @@ static void xenbe_register_types(void)
     type_register_static(&xensysdev_info);
 }
 
-type_init(xenbe_register_types);
+type_init(xenbe_register_types);
\ No newline at end of file

Looks like this change does not belong to this patch.

Signature · 1 line
Anthony PERARD
#12 lore raw

Re: [PATCH 04/19] xen: Move evtchn functions to xen_pvdev.c

Quoted 22 lines · Anthony PERARD
Quoted 21 lines · Emil Condrea

The name of the functions moved:
* xen_be_evtchn_event
* xen_be_unbind_evtchn
* xen_be_send_notify

---
 hw/xen/xen_backend.c         | 37 +------------------------------------
 hw/xen/xen_pvdev.c           | 35 +++++++++++++++++++++++++++++++++++
 include/hw/xen/xen_backend.h |  2 --
 include/hw/xen/xen_pvdev.h   |  4 ++++
 4 files changed, 40 insertions(+), 38 deletions(-)
hw/xen/xen_backend.c +0 -0
index 0a9f9bb..5f2821a 100644
@@ -693,4 +658,4 @@ static void xenbe_register_types(void)
     type_register_static(&xensysdev_info);
 }
 
Quoted 5 lines

hw/xen/xen_backend.c static void xenbe_register_types(void) · line 661

Quoted 3 lines
hw/xen/xen_backend.c +1 -1
-type_init(xenbe_register_types);
+type_init(xenbe_register_types);
\ No newline at end of file

Looks like this change does not belong to this patch.

For that matter, we prefer that all text files in qemu.git end in a newline (since according to POSIX, a non-empty file that does not end in newline is not a text file).

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#13 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH 04/19] xen: Move evtchn functions to xen_pvdev.c

In reply to Anthony PERARD
Quoted 22 lines · Anthony PERARD
Quoted 21 lines · Emil Condrea

The name of the functions moved:
* xen_be_evtchn_event
* xen_be_unbind_evtchn
* xen_be_send_notify

---
 hw/xen/xen_backend.c         | 37 +------------------------------------
 hw/xen/xen_pvdev.c           | 35 +++++++++++++++++++++++++++++++++++
 include/hw/xen/xen_backend.h |  2 --
 include/hw/xen/xen_pvdev.h   |  4 ++++
 4 files changed, 40 insertions(+), 38 deletions(-)
hw/xen/xen_backend.c +0 -0
index 0a9f9bb..5f2821a 100644
@@ -693,4 +658,4 @@ static void xenbe_register_types(void)
     type_register_static(&xensysdev_info);
 }
 
Quoted 5 lines

hw/xen/xen_backend.c static void xenbe_register_types(void) · line 661

Quoted 3 lines
hw/xen/xen_backend.c +1 -1
-type_init(xenbe_register_types);
+type_init(xenbe_register_types);
\ No newline at end of file

Looks like this change does not belong to this patch.

For that matter, we prefer that all text files in qemu.git end in a newline (since according to POSIX, a non-empty file that does not end in newline is not a text file).

Signature · 2 lines
Eric Blake   eblake redhat com    +1-919-301-3266
Libvirt virtualization library http://libvirt.org
#14 lore raw

Re: [PATCH 04/19] xen: Move evtchn functions to xen_pvdev.c

In reply to Anthony PERARD
Quoted 22 lines · Anthony PERARD
Quoted 21 lines · Emil Condrea

The name of the functions moved:
* xen_be_evtchn_event
* xen_be_unbind_evtchn
* xen_be_send_notify

---
 hw/xen/xen_backend.c         | 37 +------------------------------------
 hw/xen/xen_pvdev.c           | 35 +++++++++++++++++++++++++++++++++++
 include/hw/xen/xen_backend.h |  2 --
 include/hw/xen/xen_pvdev.h   |  4 ++++
 4 files changed, 40 insertions(+), 38 deletions(-)
hw/xen/xen_backend.c +0 -0
index 0a9f9bb..5f2821a 100644
@@ -693,4 +658,4 @@ static void xenbe_register_types(void)
     type_register_static(&xensysdev_info);
 }
 
Quoted 6 lines

hw/xen/xen_backend.c static void xenbe_register_types(void) · line 661

Quoted 3 lines
hw/xen/xen_backend.c +1 -1
-type_init(xenbe_register_types);
+type_init(xenbe_register_types);
\ No newline at end of file

Looks like this change does not belong to this patch.

Will fix this in v10.

Quoted 4 lines

--
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#15 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH 04/19] xen: Move evtchn functions to xen_pvdev.c

In reply to Anthony PERARD
Quoted 22 lines · Anthony PERARD
Quoted 21 lines · Emil Condrea

The name of the functions moved:
* xen_be_evtchn_event
* xen_be_unbind_evtchn
* xen_be_send_notify

---
 hw/xen/xen_backend.c         | 37 +------------------------------------
 hw/xen/xen_pvdev.c           | 35 +++++++++++++++++++++++++++++++++++
 include/hw/xen/xen_backend.h |  2 --
 include/hw/xen/xen_pvdev.h   |  4 ++++
 4 files changed, 40 insertions(+), 38 deletions(-)
hw/xen/xen_backend.c +0 -0
index 0a9f9bb..5f2821a 100644
@@ -693,4 +658,4 @@ static void xenbe_register_types(void)
     type_register_static(&xensysdev_info);
 }
 
Quoted 6 lines

hw/xen/xen_backend.c static void xenbe_register_types(void) · line 661

Quoted 3 lines
hw/xen/xen_backend.c +1 -1
-type_init(xenbe_register_types);
+type_init(xenbe_register_types);
\ No newline at end of file

Looks like this change does not belong to this patch.

Will fix this in v10.

Quoted 4 lines

--
Anthony PERARD

#16 lore raw

PATCH v9 5/19 xen: Prepare xendev qtail to be shared with frontends

In reply to Emil Condrea

* move xendevs qtail to xen_pvdev.c
* change xen_be_get_xendev to use a new function: xen_pv_insert_xendev

---
 hw/xen/xen_backend.c          | 70 +---------------------------------------
 hw/xen/xen_pvdev.c            | 75 +++++++++++++++++++++++++++++++++++++++++++
 include/hw/xen/xen_backend.h  |  1 -
 include/hw/xen/xen_frontend.h |  2 ++
 include/hw/xen/xen_pvdev.h    |  4 +++
 5 files changed, 82 insertions(+), 70 deletions(-)
hw/xen/xen_backend.c +1 -69
index 5f2821a..2f7f1a6 100644
@@ -55,7 +55,6 @@ struct xs_dirs {
 static QTAILQ_HEAD(xs_dirs_head, xs_dirs) xs_cleanup =
     QTAILQ_HEAD_INITIALIZER(xs_cleanup);
 
-static QTAILQ_HEAD(XenDeviceHead, XenDevice) xendevs = QTAILQ_HEAD_INITIALIZER(xendevs);
 static int debug = 0;
 
 static void xenstore_cleanup_dir(char *dir)
@@ -141,27 +140,6 @@ int xen_be_set_state(struct XenDevice *xendev, enum xenbus_state state)
     return 0;
 }
 
-/* ------------------------------------------------------------- */
-
-struct XenDevice *xen_be_find_xendev(const char *type, int dom, int dev)
-{
-    struct XenDevice *xendev;
-
-    QTAILQ_FOREACH(xendev, &xendevs, next) {
-        if (xendev->dom != dom) {
-            continue;
-        }
-        if (xendev->dev != dev) {
-            continue;
-        }
-        if (strcmp(xendev->type, type) != 0) {
-            continue;
-        }
-        return xendev;
-    }
-    return NULL;
-}
-
 /*
  * get xen backend device, allocate a new one if it doesn't exist.
  */
@@ -210,7 +188,7 @@ static struct XenDevice *xen_be_get_xendev(const char *type, int dom, int dev,
         xendev->gnttabdev = NULL;
     }
 
-    QTAILQ_INSERT_TAIL(&xendevs, xendev, next);
+    xen_pv_insert_xendev(xendev);
 
     if (xendev->ops->alloc) {
         xendev->ops->alloc(xendev);
@@ -219,52 +197,6 @@ static struct XenDevice *xen_be_get_xendev(const char *type, int dom, int dev,
     return xendev;
 }
 
-/*
- * release xen backend device.
- */
-static struct XenDevice *xen_be_del_xendev(int dom, int dev)
-{
-    struct XenDevice *xendev, *xnext;
-
-    /*
-     * This is pretty much like QTAILQ_FOREACH(xendev, &xendevs, next) but
-     * we save the next pointer in xnext because we might free xendev.
-     */
-    xnext = xendevs.tqh_first;
-    while (xnext) {
-        xendev = xnext;
-        xnext = xendev->next.tqe_next;
-
-        if (xendev->dom != dom) {
-            continue;
-        }
-        if (xendev->dev != dev && dev != -1) {
-            continue;
-        }
-
-        if (xendev->ops->free) {
-            xendev->ops->free(xendev);
-        }
-
-        if (xendev->fe) {
-            char token[XEN_BUFSIZE];
-            snprintf(token, sizeof(token), "fe:%p", xendev);
-            xs_unwatch(xenstore, xendev->fe, token);
-            g_free(xendev->fe);
-        }
-
-        if (xendev->evtchndev != NULL) {
-            xenevtchn_close(xendev->evtchndev);
-        }
-        if (xendev->gnttabdev != NULL) {
-            xengnttab_close(xendev->gnttabdev);
-        }
-
-        QTAILQ_REMOVE(&xendevs, xendev, next);
-        g_free(xendev);
-    }
-    return NULL;
-}
 
 /*
  * Sync internal data structures on xenstore updates.
hw/xen/xen_pvdev.c +75 -0

85 lines not on this page · raw message

include/hw/xen/xen_backend.h +0 -1
index 60b634e..71dd158 100644
@@ -21,7 +21,6 @@ char *xenstore_read_be_str(struct XenDevice *xendev, const char *node);
 int xenstore_read_be_int(struct XenDevice *xendev, const char *node, int *ival);
 void xenstore_update_be(char *watch, char *type, int dom, struct XenDevOps *ops);
 
-struct XenDevice *xen_be_find_xendev(const char *type, int dom, int dev);
 void xen_be_check_state(struct XenDevice *xendev);
 
 /* xen backend driver bits */
include/hw/xen/xen_frontend.h +2 -0
index 7d87da4..ae587e1 100644
@@ -1,6 +1,8 @@
 #ifndef QEMU_HW_XEN_FRONTEND_H
 #define QEMU_HW_XEN_FRONTEND_H 1
 
+#include "hw/xen/xen_pvdev.h"
+
 char *xenstore_read_fe_str(struct XenDevice *xendev, const char *node);
 int xenstore_read_fe_int(struct XenDevice *xendev, const char *node, int *ival);
 int xenstore_read_fe_uint64(struct XenDevice *xendev, const char *node, uint64_t *uval);
include/hw/xen/xen_pvdev.h +4 -0
index f269b04..234e111 100644
@@ -67,6 +67,10 @@ void xenstore_update(void *unused);
 const char *xenbus_strstate(enum xenbus_state state);
 
 void xen_be_evtchn_event(void *opaque);
+void xen_pv_insert_xendev(struct XenDevice *xendev);
+struct XenDevice *xen_be_del_xendev(int dom, int dev);
+struct XenDevice *xen_be_find_xendev(const char *type, int dom, int dev);
+
 void xen_be_unbind_evtchn(struct XenDevice *xendev);
 int xen_be_send_notify(struct XenDevice *xendev);
 
Signature · 7 lines
1.9.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#17 lore raw

PATCH v9 5/19 xen: Prepare xendev qtail to be shared with frontends

In reply to Emil Condrea

* move xendevs qtail to xen_pvdev.c
* change xen_be_get_xendev to use a new function: xen_pv_insert_xendev

---
 hw/xen/xen_backend.c          | 70 +---------------------------------------
 hw/xen/xen_pvdev.c            | 75 +++++++++++++++++++++++++++++++++++++++++++
 include/hw/xen/xen_backend.h  |  1 -
 include/hw/xen/xen_frontend.h |  2 ++
 include/hw/xen/xen_pvdev.h    |  4 +++
 5 files changed, 82 insertions(+), 70 deletions(-)
hw/xen/xen_backend.c +1 -69
index 5f2821a..2f7f1a6 100644
@@ -55,7 +55,6 @@ struct xs_dirs {
 static QTAILQ_HEAD(xs_dirs_head, xs_dirs) xs_cleanup =
     QTAILQ_HEAD_INITIALIZER(xs_cleanup);
 
-static QTAILQ_HEAD(XenDeviceHead, XenDevice) xendevs = QTAILQ_HEAD_INITIALIZER(xendevs);
 static int debug = 0;
 
 static void xenstore_cleanup_dir(char *dir)
@@ -141,27 +140,6 @@ int xen_be_set_state(struct XenDevice *xendev, enum xenbus_state state)
     return 0;
 }
 
-/* ------------------------------------------------------------- */
-
-struct XenDevice *xen_be_find_xendev(const char *type, int dom, int dev)
-{
-    struct XenDevice *xendev;
-
-    QTAILQ_FOREACH(xendev, &xendevs, next) {
-        if (xendev->dom != dom) {
-            continue;
-        }
-        if (xendev->dev != dev) {
-            continue;
-        }
-        if (strcmp(xendev->type, type) != 0) {
-            continue;
-        }
-        return xendev;
-    }
-    return NULL;
-}
-
 /*
  * get xen backend device, allocate a new one if it doesn't exist.
  */
@@ -210,7 +188,7 @@ static struct XenDevice *xen_be_get_xendev(const char *type, int dom, int dev,
         xendev->gnttabdev = NULL;
     }
 
-    QTAILQ_INSERT_TAIL(&xendevs, xendev, next);
+    xen_pv_insert_xendev(xendev);
 
     if (xendev->ops->alloc) {
         xendev->ops->alloc(xendev);
@@ -219,52 +197,6 @@ static struct XenDevice *xen_be_get_xendev(const char *type, int dom, int dev,
     return xendev;
 }
 
-/*
- * release xen backend device.
- */
-static struct XenDevice *xen_be_del_xendev(int dom, int dev)
-{
-    struct XenDevice *xendev, *xnext;
-
-    /*
-     * This is pretty much like QTAILQ_FOREACH(xendev, &xendevs, next) but
-     * we save the next pointer in xnext because we might free xendev.
-     */
-    xnext = xendevs.tqh_first;
-    while (xnext) {
-        xendev = xnext;
-        xnext = xendev->next.tqe_next;
-
-        if (xendev->dom != dom) {
-            continue;
-        }
-        if (xendev->dev != dev && dev != -1) {
-            continue;
-        }
-
-        if (xendev->ops->free) {
-            xendev->ops->free(xendev);
-        }
-
-        if (xendev->fe) {
-            char token[XEN_BUFSIZE];
-            snprintf(token, sizeof(token), "fe:%p", xendev);
-            xs_unwatch(xenstore, xendev->fe, token);
-            g_free(xendev->fe);
-        }
-
-        if (xendev->evtchndev != NULL) {
-            xenevtchn_close(xendev->evtchndev);
-        }
-        if (xendev->gnttabdev != NULL) {
-            xengnttab_close(xendev->gnttabdev);
-        }
-
-        QTAILQ_REMOVE(&xendevs, xendev, next);
-        g_free(xendev);
-    }
-    return NULL;
-}
 
 /*
  * Sync internal data structures on xenstore updates.
hw/xen/xen_pvdev.c +75 -0

85 lines not on this page · raw message

include/hw/xen/xen_backend.h +0 -1
index 60b634e..71dd158 100644
@@ -21,7 +21,6 @@ char *xenstore_read_be_str(struct XenDevice *xendev, const char *node);
 int xenstore_read_be_int(struct XenDevice *xendev, const char *node, int *ival);
 void xenstore_update_be(char *watch, char *type, int dom, struct XenDevOps *ops);
 
-struct XenDevice *xen_be_find_xendev(const char *type, int dom, int dev);
 void xen_be_check_state(struct XenDevice *xendev);
 
 /* xen backend driver bits */
include/hw/xen/xen_frontend.h +2 -0
index 7d87da4..ae587e1 100644
@@ -1,6 +1,8 @@
 #ifndef QEMU_HW_XEN_FRONTEND_H
 #define QEMU_HW_XEN_FRONTEND_H 1
 
+#include "hw/xen/xen_pvdev.h"
+
 char *xenstore_read_fe_str(struct XenDevice *xendev, const char *node);
 int xenstore_read_fe_int(struct XenDevice *xendev, const char *node, int *ival);
 int xenstore_read_fe_uint64(struct XenDevice *xendev, const char *node, uint64_t *uval);
include/hw/xen/xen_pvdev.h +4 -0
index f269b04..234e111 100644
@@ -67,6 +67,10 @@ void xenstore_update(void *unused);
 const char *xenbus_strstate(enum xenbus_state state);
 
 void xen_be_evtchn_event(void *opaque);
+void xen_pv_insert_xendev(struct XenDevice *xendev);
+struct XenDevice *xen_be_del_xendev(int dom, int dev);
+struct XenDevice *xen_be_find_xendev(const char *type, int dom, int dev);
+
 void xen_be_unbind_evtchn(struct XenDevice *xendev);
 int xen_be_send_notify(struct XenDevice *xendev);
 
Signature · 1 line
1.9.1
#18 lore raw

PATCH v9 6/19 xen: Rename xen_be_printf to xen_pv_printf

In reply to Emil Condrea

Prepare xen_be_printf to be used by both backend and frontends:
* xen_be_printf -> xen_pv_printf

---
 hw/block/xen_disk.c        | 52 +++++++++++++++++++++++-----------------------
 hw/char/xen_console.c      | 10 ++++-----
 hw/display/xenfb.c         | 42 ++++++++++++++++++-------------------
 hw/net/xen_nic.c           | 22 ++++++++++----------
 hw/usb/xen-usb.c           | 38 ++++++++++++++++-----------------
 hw/xen/xen_backend.c       | 44 +++++++++++++++++++--------------------
 hw/xen/xen_devconfig.c     |  4 ++--
 hw/xen/xen_frontend.c      |  6 +++---
 hw/xen/xen_pvdev.c         |  6 +++---
 include/hw/xen/xen_pvdev.h |  2 +-
 xen-common.c               |  4 ++--
 11 files changed, 115 insertions(+), 115 deletions(-)
hw/block/xen_disk.c +26 -26
index 28fbf24..ad3f519 100644
@@ -165,12 +165,12 @@ static void destroy_grant(gpointer pgnt)
     xengnttab_handle *gnt = grant->blkdev->xendev.gnttabdev;
 
     if (xengnttab_unmap(gnt, grant->page, 1) != 0) {
-        xen_be_printf(&grant->blkdev->xendev, 0,
+        xen_pv_printf(&grant->blkdev->xendev, 0,
                       "xengnttab_unmap failed: %s\n",
                       strerror(errno));
     }
     grant->blkdev->persistent_gnt_count--;
-    xen_be_printf(&grant->blkdev->xendev, 3,
+    xen_pv_printf(&grant->blkdev->xendev, 3,
                   "unmapped grant %p\n", grant->page);
     g_free(grant);
 }
@@ -182,11 +182,11 @@ static void remove_persistent_region(gpointer data, gpointer dev)
     xengnttab_handle *gnt = blkdev->xendev.gnttabdev;
 
     if (xengnttab_unmap(gnt, region->addr, region->num) != 0) {
-        xen_be_printf(&blkdev->xendev, 0,
+        xen_pv_printf(&blkdev->xendev, 0,
                       "xengnttab_unmap region %p failed: %s\n",
                       region->addr, strerror(errno));
     }
-    xen_be_printf(&blkdev->xendev, 3,
+    xen_pv_printf(&blkdev->xendev, 3,
                   "unmapped grant region %p with %d pages\n",
                   region->addr, region->num);
     g_free(region);
@@ -253,7 +253,7 @@ static int ioreq_parse(struct ioreq *ioreq)
     size_t len;
     int i;
 
-    xen_be_printf(&blkdev->xendev, 3,
+    xen_pv_printf(&blkdev->xendev, 3,
                   "op %d, nr %d, handle %d, id %" PRId64 ", sector %" PRId64 "\n",
                   ioreq->req.operation, ioreq->req.nr_segments,
                   ioreq->req.handle, ioreq->req.id, ioreq->req.sector_number);
@@ -273,28 +273,28 @@ static int ioreq_parse(struct ioreq *ioreq)
     case BLKIF_OP_DISCARD:
         return 0;
     default:
-        xen_be_printf(&blkdev->xendev, 0, "error: unknown operation (%d)\n",
+        xen_pv_printf(&blkdev->xendev, 0, "error: unknown operation (%d)\n",
                       ioreq->req.operation);
         goto err;
     };
 
     if (ioreq->req.operation != BLKIF_OP_READ && blkdev->mode[0] != 'w') {
-        xen_be_printf(&blkdev->xendev, 0, "error: write req for ro device\n");
+        xen_pv_printf(&blkdev->xendev, 0, "error: write req for ro device\n");
         goto err;
     }
 
     ioreq->start = ioreq->req.sector_number * blkdev->file_blk;
     for (i = 0; i < ioreq->req.nr_segments; i++) {
         if (i == BLKIF_MAX_SEGMENTS_PER_REQUEST) {
-            xen_be_printf(&blkdev->xendev, 0, "error: nr_segments too big\n");
+            xen_pv_printf(&blkdev->xendev, 0, "error: nr_segments too big\n");
             goto err;
         }
         if (ioreq->req.seg[i].first_sect > ioreq->req.seg[i].last_sect) {
-            xen_be_printf(&blkdev->xendev, 0, "error: first > last sector\n");
+            xen_pv_printf(&blkdev->xendev, 0, "error: first > last sector\n");
             goto err;
         }
         if (ioreq->req.seg[i].last_sect * BLOCK_SIZE >= XC_PAGE_SIZE) {
-            xen_be_printf(&blkdev->xendev, 0, "error: page crossing\n");
+            xen_pv_printf(&blkdev->xendev, 0, "error: page crossing\n");
             goto err;
         }
 
@@ -306,7 +306,7 @@ static int ioreq_parse(struct ioreq *ioreq)
         qemu_iovec_add(&ioreq->v, (void*)mem, len);
     }
     if (ioreq->start + ioreq->v.size > blkdev->file_size) {
-        xen_be_printf(&blkdev->xendev, 0, "error: access beyond end of file\n");
+        xen_pv_printf(&blkdev->xendev, 0, "error: access beyond end of file\n");
         goto err;
     }
     return 0;
@@ -329,7 +329,7 @@ static void ioreq_unmap(struct ioreq *ioreq)
             return;
         }
         if (xengnttab_unmap(gnt, ioreq->pages, ioreq->num_unmap) != 0) {
-            xen_be_printf(&ioreq->blkdev->xendev, 0,
+            xen_pv_printf(&ioreq->blkdev->xendev, 0,
                           "xengnttab_unmap failed: %s\n",
                           strerror(errno));
         }
@@ -341,7 +341,7 @@ static void ioreq_unmap(struct ioreq *ioreq)
                 continue;
             }
             if (xengnttab_unmap(gnt, ioreq->page[i], 1) != 0) {
-                xen_be_printf(&ioreq->blkdev->xendev, 0,
+                xen_pv_printf(&ioreq->blkdev->xendev, 0,
                               "xengnttab_unmap failed: %s\n",
                               strerror(errno));
             }
@@ -379,7 +379,7 @@ static int ioreq_map(struct ioreq *ioreq)
 
             if (grant != NULL) {
                 page[i] = grant->page;
-                xen_be_printf(&ioreq->blkdev->xendev, 3,
+                xen_pv_printf(&ioreq->blkdev->xendev, 3,
                               "using persistent-grant %" PRIu32 "\n",
                               ioreq->refs[i]);
             } else {
@@ -408,7 +408,7 @@ static int ioreq_map(struct ioreq *ioreq)
         ioreq->pages = xengnttab_map_grant_refs
             (gnt, new_maps, domids, refs, ioreq->prot);
         if (ioreq->pages == NULL) {
-            xen_be_printf(&ioreq->blkdev->xendev, 0,
+            xen_pv_printf(&ioreq->blkdev->xendev, 0,
                           "can't map %d grant refs (%s, %d maps)\n",
                           new_maps, strerror(errno), ioreq->blkdev->cnt_map);
             return -1;
@@ -424,7 +424,7 @@ static int ioreq_map(struct ioreq *ioreq)
             ioreq->page[i] = xengnttab_map_grant_ref
                 (gnt, domids[i], refs[i], ioreq->prot);
             if (ioreq->page[i] == NULL) {
-                xen_be_printf(&ioreq->blkdev->xendev, 0,
+                xen_pv_printf(&ioreq->blkdev->xendev, 0,
                               "can't map grant ref %d (%s, %d maps)\n",
                               refs[i], strerror(errno), ioreq->blkdev->cnt_map);
                 ioreq->mapped = 1;
@@ -472,7 +472,7 @@ static int ioreq_map(struct ioreq *ioreq)
                 grant->page = ioreq->page[new_maps];
             }
             grant->blkdev = ioreq->blkdev;
-            xen_be_printf(&ioreq->blkdev->xendev, 3,
+            xen_pv_printf(&ioreq->blkdev->xendev, 3,
                           "adding grant %" PRIu32 " page: %p\n",
                           refs[new_maps], grant->page);
             g_tree_insert(ioreq->blkdev->persistent_gnts,
@@ -497,7 +497,7 @@ static void qemu_aio_complete(void *opaque, int ret)
     struct ioreq *ioreq = opaque;
 
     if (ret != 0) {
-        xen_be_printf(&ioreq->blkdev->xendev, 0, "%s I/O error\n",
+        xen_pv_printf(&ioreq->blkdev->xendev, 0, "%s I/O error\n",
                       ioreq->req.operation == BLKIF_OP_READ ? "read" : "write");
         ioreq->aio_errors++;
     }
@@ -773,7 +773,7 @@ static void blk_alloc(struct XenDevice *xendev)
     }
     if (xengnttab_set_max_grants(xendev->gnttabdev,
             MAX_GRANTS(max_requests, BLKIF_MAX_SEGMENTS_PER_REQUEST)) < 0) {
-        xen_be_printf(xendev, 0, "xengnttab_set_max_grants failed: %s\n",
+        xen_pv_printf(xendev, 0, "xengnttab_set_max_grants failed: %s\n",
                       strerror(errno));
     }
 }
@@ -919,11 +919,11 @@ static int blk_connect(struct XenDevice *xendev)
         }
 
         /* setup via xenbus -> create new block driver instance */
-        xen_be_printf(&blkdev->xendev, 2, "create new bdrv (xenbus setup)\n");
+        xen_pv_printf(&blkdev->xendev, 2, "create new bdrv (xenbus setup)\n");
         blkdev->blk = blk_new_open(blkdev->filename, NULL, options,
                                    qflags, &local_err);
         if (!blkdev->blk) {
-            xen_be_printf(&blkdev->xendev, 0, "error: %s\n",
+            xen_pv_printf(&blkdev->xendev, 0, "error: %s\n",
                           error_get_pretty(local_err));
             error_free(local_err);
             return -1;
@@ -931,10 +931,10 @@ static int blk_connect(struct XenDevice *xendev)
         blk_set_enable_write_cache(blkdev->blk, !writethrough);
     } else {
         /* setup via qemu cmdline -> already setup for us */
-        xen_be_printf(&blkdev->xendev, 2, "get configured bdrv (cmdline setup)\n");
+        xen_pv_printf(&blkdev->xendev, 2, "get configured bdrv (cmdline setup)\n");
         blkdev->blk = blk_by_legacy_dinfo(blkdev->dinfo);
         if (blk_is_read_only(blkdev->blk) && !readonly) {
-            xen_be_printf(&blkdev->xendev, 0, "Unexpected read-only drive");
+            xen_pv_printf(&blkdev->xendev, 0, "Unexpected read-only drive");
             blkdev->blk = NULL;
             return -1;
         }
@@ -947,13 +947,13 @@ static int blk_connect(struct XenDevice *xendev)
     if (blkdev->file_size < 0) {
         BlockDriverState *bs = blk_bs(blkdev->blk);
         const char *drv_name = bs ? bdrv_get_format_name(bs) : NULL;
-        xen_be_printf(&blkdev->xendev, 1, "blk_getlength: %d (%s) | drv %s\n",
+        xen_pv_printf(&blkdev->xendev, 1, "blk_getlength: %d (%s) | drv %s\n",
                       (int)blkdev->file_size, strerror(-blkdev->file_size),
                       drv_name ?: "-");
         blkdev->file_size = 0;
     }
 
-    xen_be_printf(xendev, 1, "type \"%s\", fileproto \"%s\", filename \"%s\","
+    xen_pv_printf(xendev, 1, "type \"%s\", fileproto \"%s\", filename \"%s\","
                   " size %" PRId64 " (%" PRId64 " MB)\n",
                   blkdev->type, blkdev->fileproto, blkdev->filename,
                   blkdev->file_size, blkdev->file_size >> 20);
@@ -1032,7 +1032,7 @@ static int blk_connect(struct XenDevice *xendev)
 
     xen_be_bind_evtchn(&blkdev->xendev);
 
-    xen_be_printf(&blkdev->xendev, 1, "ok: proto %s, ring-ref %d, "
+    xen_pv_printf(&blkdev->xendev, 1, "ok: proto %s, ring-ref %d, "
                   "remote port %d, local port %d\n",
                   blkdev->xendev.protocol, blkdev->ring_ref,
                   blkdev->xendev.remote_port, blkdev->xendev.local_port);
hw/char/xen_console.c +5 -5
index 83108b0..e6bae67 100644
@@ -156,13 +156,13 @@ static void xencons_send(struct XenConsole *con)
     if (len < 1) {
 	if (!con->backlog) {
 	    con->backlog = 1;
-	    xen_be_printf(&con->xendev, 1, "backlog piling up, nobody listening?\n");
+	    xen_pv_printf(&con->xendev, 1, "backlog piling up, nobody listening?\n");
 	}
     } else {
 	buffer_advance(&con->buffer, len);
 	if (con->backlog && len == size) {
 	    con->backlog = 0;
-	    xen_be_printf(&con->xendev, 1, "backlog is gone\n");
+	    xen_pv_printf(&con->xendev, 1, "backlog is gone\n");
 	}
     }
 }
@@ -187,7 +187,7 @@ static int con_init(struct XenDevice *xendev)
 
     type = xenstore_read_str(con->console, "type");
     if (!type || strcmp(type, "ioemu") != 0) {
-	xen_be_printf(xendev, 1, "not for me (type=%s)\n", type);
+	xen_pv_printf(xendev, 1, "not for me (type=%s)\n", type);
         ret = -1;
         goto out;
     }
@@ -240,14 +240,14 @@ static int con_initialise(struct XenDevice *xendev)
             qemu_chr_add_handlers(con->chr, xencons_can_receive,
                                   xencons_receive, NULL, con);
         } else {
-            xen_be_printf(xendev, 0,
+            xen_pv_printf(xendev, 0,
                           "xen_console_init error chardev %s already used\n",
                           con->chr->label);
             con->chr = NULL;
         }
     }
 
-    xen_be_printf(xendev, 1, "ring mfn %d, remote port %d, local port %d, limit %zd\n",
+    xen_pv_printf(xendev, 1, "ring mfn %d, remote port %d, local port %d, limit %zd\n",
 		  con->ring_ref,
 		  con->xendev.remote_port,
 		  con->xendev.local_port,
hw/display/xenfb.c +21 -21

153 lines not on this page · raw message

hw/net/xen_nic.c +11 -11
index bdfa789..91126b5 100644
@@ -129,30 +129,30 @@ static void net_tx_packets(struct XenNetDev *netdev)
             /* should not happen in theory, we don't announce the *
              * feature-{sg,gso,whatelse} flags in xenstore (yet?) */
             if (txreq.flags & NETTXF_extra_info) {
-                xen_be_printf(&netdev->xendev, 0, "FIXME: extra info flag\n");
+                xen_pv_printf(&netdev->xendev, 0, "FIXME: extra info flag\n");
                 net_tx_error(netdev, &txreq, rc);
                 continue;
             }
             if (txreq.flags & NETTXF_more_data) {
-                xen_be_printf(&netdev->xendev, 0, "FIXME: more data flag\n");
+                xen_pv_printf(&netdev->xendev, 0, "FIXME: more data flag\n");
                 net_tx_error(netdev, &txreq, rc);
                 continue;
             }
 #endif
 
             if (txreq.size < 14) {
-                xen_be_printf(&netdev->xendev, 0, "bad packet size: %d\n", txreq.size);
+                xen_pv_printf(&netdev->xendev, 0, "bad packet size: %d\n", txreq.size);
                 net_tx_error(netdev, &txreq, rc);
                 continue;
             }
 
             if ((txreq.offset + txreq.size) > XC_PAGE_SIZE) {
-                xen_be_printf(&netdev->xendev, 0, "error: page crossing\n");
+                xen_pv_printf(&netdev->xendev, 0, "error: page crossing\n");
                 net_tx_error(netdev, &txreq, rc);
                 continue;
             }
 
-            xen_be_printf(&netdev->xendev, 3, "tx packet ref %d, off %d, len %d, flags 0x%x%s%s%s%s\n",
+            xen_pv_printf(&netdev->xendev, 3, "tx packet ref %d, off %d, len %d, flags 0x%x%s%s%s%s\n",
                           txreq.gref, txreq.offset, txreq.size, txreq.flags,
                           (txreq.flags & NETTXF_csum_blank)     ? " csum_blank"     : "",
                           (txreq.flags & NETTXF_data_validated) ? " data_validated" : "",
@@ -163,7 +163,7 @@ static void net_tx_packets(struct XenNetDev *netdev)
                                            netdev->xendev.dom,
                                            txreq.gref, PROT_READ);
             if (page == NULL) {
-                xen_be_printf(&netdev->xendev, 0, "error: tx gref dereference failed (%d)\n",
+                xen_pv_printf(&netdev->xendev, 0, "error: tx gref dereference failed (%d)\n",
                               txreq.gref);
                 net_tx_error(netdev, &txreq, rc);
                 continue;
@@ -212,7 +212,7 @@ static void net_rx_response(struct XenNetDev *netdev,
         resp->status = (int16_t)st;
     }
 
-    xen_be_printf(&netdev->xendev, 3, "rx response: idx %d, status %d, flags 0x%x\n",
+    xen_pv_printf(&netdev->xendev, 3, "rx response: idx %d, status %d, flags 0x%x\n",
                   i, resp->status, resp->flags);
 
     netdev->rx_ring.rsp_prod_pvt = ++i;
@@ -243,7 +243,7 @@ static ssize_t net_rx_packet(NetClientState *nc, const uint8_t *buf, size_t size
         return 0;
     }
     if (size > XC_PAGE_SIZE - NET_IP_ALIGN) {
-        xen_be_printf(&netdev->xendev, 0, "packet too big (%lu > %ld)",
+        xen_pv_printf(&netdev->xendev, 0, "packet too big (%lu > %ld)",
                       (unsigned long)size, XC_PAGE_SIZE - NET_IP_ALIGN);
         return -1;
     }
@@ -255,7 +255,7 @@ static ssize_t net_rx_packet(NetClientState *nc, const uint8_t *buf, size_t size
                                    netdev->xendev.dom,
                                    rxreq.gref, PROT_WRITE);
     if (page == NULL) {
-        xen_be_printf(&netdev->xendev, 0, "error: rx gref dereference failed (%d)\n",
+        xen_pv_printf(&netdev->xendev, 0, "error: rx gref dereference failed (%d)\n",
                       rxreq.gref);
         net_rx_response(netdev, &rxreq, NETIF_RSP_ERROR, 0, 0, 0);
         return -1;
@@ -329,7 +329,7 @@ static int net_connect(struct XenDevice *xendev)
         rx_copy = 0;
     }
     if (rx_copy == 0) {
-        xen_be_printf(&netdev->xendev, 0, "frontend doesn't support rx-copy.\n");
+        xen_pv_printf(&netdev->xendev, 0, "frontend doesn't support rx-copy.\n");
         return -1;
     }
 
@@ -354,7 +354,7 @@ static int net_connect(struct XenDevice *xendev)
 
     xen_be_bind_evtchn(&netdev->xendev);
 
-    xen_be_printf(&netdev->xendev, 1, "ok: tx-ring-ref %d, rx-ring-ref %d, "
+    xen_pv_printf(&netdev->xendev, 1, "ok: tx-ring-ref %d, rx-ring-ref %d, "
                   "remote port %d, local port %d\n",
                   netdev->tx_ring_ref, netdev->rx_ring_ref,
                   netdev->xendev.remote_port, netdev->xendev.local_port);
hw/usb/xen-usb.c +19 -19
index 0fd34c6..bcf5c2e 100644
@@ -47,7 +47,7 @@
         struct timeval tv;                                          \
                                                                     \
         gettimeofday(&tv, NULL);                                    \
-        xen_be_printf(xendev, lvl, "%8ld.%06ld xen-usb(%s):" fmt,   \
+        xen_pv_printf(xendev, lvl, "%8ld.%06ld xen-usb(%s):" fmt,   \
                       tv.tv_sec, tv.tv_usec, __func__, ##args);     \
     }
 #define TR_BUS(xendev, fmt, args...) TR(xendev, 2, fmt, ##args)
@@ -151,7 +151,7 @@ static int usbback_gnttab_map(struct usbback_req *usbback_req)
     }
 
     if (nr_segs > USBIF_MAX_SEGMENTS_PER_REQUEST) {
-        xen_be_printf(xendev, 0, "bad number of segments in request (%d)\n",
+        xen_pv_printf(xendev, 0, "bad number of segments in request (%d)\n",
                       nr_segs);
         return -EINVAL;
     }
@@ -159,7 +159,7 @@ static int usbback_gnttab_map(struct usbback_req *usbback_req)
     for (i = 0; i < nr_segs; i++) {
         if ((unsigned)usbback_req->req.seg[i].offset +
             (unsigned)usbback_req->req.seg[i].length > PAGE_SIZE) {
-            xen_be_printf(xendev, 0, "segment crosses page boundary\n");
+            xen_pv_printf(xendev, 0, "segment crosses page boundary\n");
             return -EINVAL;
         }
     }
@@ -197,7 +197,7 @@ static int usbback_gnttab_map(struct usbback_req *usbback_req)
      */
 
     if (!usbback_req->nr_extra_segs) {
-        xen_be_printf(xendev, 0, "iso request without descriptor segments\n");
+        xen_pv_printf(xendev, 0, "iso request without descriptor segments\n");
         return -EINVAL;
     }
 
@@ -548,14 +548,14 @@ static void usbback_dispatch(struct usbback_req *usbback_req)
 
     ret = usbback_init_packet(usbback_req);
     if (ret) {
-        xen_be_printf(&usbif->xendev, 0, "invalid request\n");
+        xen_pv_printf(&usbif->xendev, 0, "invalid request\n");
         ret = -ESHUTDOWN;
         goto fail_free_urb;
     }
 
     ret = usbback_gnttab_map(usbback_req);
     if (ret) {
-        xen_be_printf(&usbif->xendev, 0, "invalid buffer, ret=%d\n", ret);
+        xen_pv_printf(&usbif->xendev, 0, "invalid buffer, ret=%d\n", ret);
         ret = -ESHUTDOWN;
         goto fail_free_urb;
     }
@@ -643,7 +643,7 @@ static void usbback_bh(void *opaque)
 
     if (RING_REQUEST_PROD_OVERFLOW(urb_ring, rp)) {
         rc = urb_ring->rsp_prod_pvt;
-        xen_be_printf(&usbif->xendev, 0, "domU provided bogus ring requests "
+        xen_pv_printf(&usbif->xendev, 0, "domU provided bogus ring requests "
                       "(%#x - %#x = %u). Halting ring processing.\n",
                       rp, rc, rp - rc);
         usbif->ring_error = true;
@@ -716,7 +716,7 @@ static void usbback_portid_add(struct usbback_info *usbif, unsigned port,
 
     portname = strchr(busid, '-');
     if (!portname) {
-        xen_be_printf(&usbif->xendev, 0, "device %s illegal specification\n",
+        xen_pv_printf(&usbif->xendev, 0, "device %s illegal specification\n",
                       busid);
         return;
     }
@@ -755,7 +755,7 @@ static void usbback_portid_add(struct usbback_info *usbif, unsigned port,
         break;
     }
     if (speed == USBIF_SPEED_NONE) {
-        xen_be_printf(&usbif->xendev, 0, "device %s wrong speed\n", busid);
+        xen_pv_printf(&usbif->xendev, 0, "device %s wrong speed\n", busid);
         object_unparent(OBJECT(usbif->ports[port - 1].dev));
         usbif->ports[port - 1].dev = NULL;
         return;
@@ -772,7 +772,7 @@ static void usbback_portid_add(struct usbback_info *usbif, unsigned port,
 err:
     QDECREF(qdict);
     snprintf(p->path, sizeof(p->path), "%d", 99);
-    xen_be_printf(&usbif->xendev, 0, "device %s could not be opened\n", busid);
+    xen_pv_printf(&usbif->xendev, 0, "device %s could not be opened\n", busid);
 }
 
 static void usbback_process_port(struct usbback_info *usbif, unsigned port)
@@ -783,7 +783,7 @@ static void usbback_process_port(struct usbback_info *usbif, unsigned port)
     snprintf(node, sizeof(node), "port/%d", port);
     busid = xenstore_read_be_str(&usbif->xendev, node);
     if (busid == NULL) {
-        xen_be_printf(&usbif->xendev, 0, "xenstore_read %s failed\n", node);
+        xen_pv_printf(&usbif->xendev, 0, "xenstore_read %s failed\n", node);
         return;
     }
 
@@ -844,15 +844,15 @@ static int usbback_connect(struct XenDevice *xendev)
     usbif = container_of(xendev, struct usbback_info, xendev);
 
     if (xenstore_read_fe_int(xendev, "urb-ring-ref", &urb_ring_ref)) {
-        xen_be_printf(xendev, 0, "error reading urb-ring-ref\n");
+        xen_pv_printf(xendev, 0, "error reading urb-ring-ref\n");
         return -1;
     }
     if (xenstore_read_fe_int(xendev, "conn-ring-ref", &conn_ring_ref)) {
-        xen_be_printf(xendev, 0, "error reading conn-ring-ref\n");
+        xen_pv_printf(xendev, 0, "error reading conn-ring-ref\n");
         return -1;
     }
     if (xenstore_read_fe_int(xendev, "event-channel", &xendev->remote_port)) {
-        xen_be_printf(xendev, 0, "error reading event-channel\n");
+        xen_pv_printf(xendev, 0, "error reading event-channel\n");
         return -1;
     }
 
@@ -863,7 +863,7 @@ static int usbback_connect(struct XenDevice *xendev)
                                                 conn_ring_ref,
                                                 PROT_READ | PROT_WRITE);
     if (!usbif->urb_sring || !usbif->conn_sring) {
-        xen_be_printf(xendev, 0, "error mapping rings\n");
+        xen_pv_printf(xendev, 0, "error mapping rings\n");
         usbback_disconnect(xendev);
         return -1;
     }
@@ -875,7 +875,7 @@ static int usbback_connect(struct XenDevice *xendev)
 
     xen_be_bind_evtchn(xendev);
 
-    xen_be_printf(xendev, 1, "urb-ring-ref %d, conn-ring-ref %d, "
+    xen_pv_printf(xendev, 1, "urb-ring-ref %d, conn-ring-ref %d, "
                   "remote port %d, local port %d\n", urb_ring_ref,
                   conn_ring_ref, xendev->remote_port, xendev->local_port);
 
@@ -911,12 +911,12 @@ static int usbback_init(struct XenDevice *xendev)
 
     if (xenstore_read_be_int(xendev, "num-ports", &usbif->num_ports) ||
         usbif->num_ports < 1 || usbif->num_ports > USBBACK_MAXPORTS) {
-        xen_be_printf(xendev, 0, "num-ports not readable or out of bounds\n");
+        xen_pv_printf(xendev, 0, "num-ports not readable or out of bounds\n");
         return -1;
     }
     if (xenstore_read_be_int(xendev, "usb-ver", &usbif->usb_ver) ||
         (usbif->usb_ver != USB_VER_USB11 && usbif->usb_ver != USB_VER_USB20)) {
-        xen_be_printf(xendev, 0, "usb-ver not readable or out of bounds\n");
+        xen_pv_printf(xendev, 0, "usb-ver not readable or out of bounds\n");
         return -1;
     }
 
@@ -998,7 +998,7 @@ static void usbback_alloc(struct XenDevice *xendev)
     /* max_grants: for each request and for the rings (request and connect). */
     max_grants = USBIF_MAX_SEGMENTS_PER_REQUEST * USB_URB_RING_SIZE + 2;
     if (xengnttab_set_max_grants(xendev->gnttabdev, max_grants) < 0) {
-        xen_be_printf(xendev, 0, "xengnttab_set_max_grants failed: %s\n",
+        xen_pv_printf(xendev, 0, "xengnttab_set_max_grants failed: %s\n",
                       strerror(errno));
     }
 }
hw/xen/xen_backend.c +22 -22

159 lines not on this page · raw message

hw/xen/xen_devconfig.c +2 -2
index b7d290d..a80e78c 100644
@@ -55,7 +55,7 @@ int xen_config_dev_blk(DriveInfo *disk)
     const char *filename = qemu_opt_get(disk->opts, "file");
 
     snprintf(device_name, sizeof(device_name), "xvd%c", 'a' + disk->unit);
-    xen_be_printf(NULL, 1, "config disk %d [%s]: %s\n",
+    xen_pv_printf(NULL, 1, "config disk %d [%s]: %s\n",
                   disk->unit, device_name, filename);
     xen_config_dev_dirs("vbd", "qdisk", vdev, fe, be, sizeof(fe));
 
@@ -83,7 +83,7 @@ int xen_config_dev_nic(NICInfo *nic)
     snprintf(mac, sizeof(mac), "%02x:%02x:%02x:%02x:%02x:%02x",
              nic->macaddr.a[0], nic->macaddr.a[1], nic->macaddr.a[2],
              nic->macaddr.a[3], nic->macaddr.a[4], nic->macaddr.a[5]);
-    xen_be_printf(NULL, 1, "config nic %d: mac=\"%s\"\n", vlan_id, mac);
+    xen_pv_printf(NULL, 1, "config nic %d: mac=\"%s\"\n", vlan_id, mac);
     xen_config_dev_dirs("vif", "qnic", vlan_id, fe, be, sizeof(fe));
 
     /* frontend */
hw/xen/xen_frontend.c +3 -3
index 4e01169..474c74a 100644
@@ -47,7 +47,7 @@ void xen_be_frontend_changed(struct XenDevice *xendev, const char *node)
             fe_state = XenbusStateUnknown;
         }
         if (xendev->fe_state != fe_state) {
-            xen_be_printf(xendev, 1, "frontend state: %s -> %s\n",
+            xen_pv_printf(xendev, 1, "frontend state: %s -> %s\n",
                           xenbus_strstate(xendev->fe_state),
                           xenbus_strstate(fe_state));
         }
@@ -57,12 +57,12 @@ void xen_be_frontend_changed(struct XenDevice *xendev, const char *node)
         g_free(xendev->protocol);
         xendev->protocol = xenstore_read_fe_str(xendev, "protocol");
         if (xendev->protocol) {
-            xen_be_printf(xendev, 1, "frontend protocol: %s\n", xendev->protocol);
+            xen_pv_printf(xendev, 1, "frontend protocol: %s\n", xendev->protocol);
         }
     }
 
     if (node) {
-        xen_be_printf(xendev, 2, "frontend update: %s\n", node);
+        xen_pv_printf(xendev, 2, "frontend update: %s\n", node);
         if (xendev->ops->frontend_changed) {
             xendev->ops->frontend_changed(xendev, node);
         }
hw/xen/xen_pvdev.c +3 -3
index 042adeb..7375b43 100644
@@ -142,7 +142,7 @@ const char *xenbus_strstate(enum xenbus_state state)
  *  2 == noisy debug messages (logfile only).
  *  3 == will flood your log (logfile only).
  */
-void xen_be_printf(struct XenDevice *xendev, int msg_level, const char *fmt, ...)
+void xen_pv_printf(struct XenDevice *xendev, int msg_level, const char *fmt, ...)
 {
     va_list args;
 
@@ -181,7 +181,7 @@ void xen_be_evtchn_event(void *opaque)
 
     port = xenevtchn_pending(xendev->evtchndev);
     if (port != xendev->local_port) {
-        xen_be_printf(xendev, 0,
+        xen_pv_printf(xendev, 0,
                       "xenevtchn_pending returned %d (expected %d)\n",
                       port, xendev->local_port);
         return;
@@ -200,7 +200,7 @@ void xen_be_unbind_evtchn(struct XenDevice *xendev)
     }
     qemu_set_fd_handler(xenevtchn_fd(xendev->evtchndev), NULL, NULL, NULL);
     xenevtchn_unbind(xendev->evtchndev, xendev->local_port);
-    xen_be_printf(xendev, 2, "unbind evtchn port %d\n", xendev->local_port);
+    xen_pv_printf(xendev, 2, "unbind evtchn port %d\n", xendev->local_port);
     xendev->local_port = -1;
 }
 
include/hw/xen/xen_pvdev.h +1 -1
index 234e111..3e2dfd8 100644
@@ -74,7 +74,7 @@ struct XenDevice *xen_be_find_xendev(const char *type, int dom, int dev);
 void xen_be_unbind_evtchn(struct XenDevice *xendev);
 int xen_be_send_notify(struct XenDevice *xendev);
 
-void xen_be_printf(struct XenDevice *xendev, int msg_level, const char *fmt, ...)
+void xen_pv_printf(struct XenDevice *xendev, int msg_level, const char *fmt, ...)
     GCC_FMT_ATTR(3, 4);
 
 #endif /* QEMU_HW_XEN_PVDEV_H */
xen-common.c +2 -2
index e641ad1..9099760 100644
@@ -116,12 +116,12 @@ static int xen_init(MachineState *ms)
 {
     xen_xc = xc_interface_open(0, 0, 0);
     if (xen_xc == NULL) {
-        xen_be_printf(NULL, 0, "can't open xen interface\n");
+        xen_pv_printf(NULL, 0, "can't open xen interface\n");
         return -1;
     }
     xen_fmem = xenforeignmemory_open(0, 0);
     if (xen_fmem == NULL) {
-        xen_be_printf(NULL, 0, "can't open xen fmem interface\n");
+        xen_pv_printf(NULL, 0, "can't open xen fmem interface\n");
         xc_interface_close(xen_xc);
         return -1;
     }
Signature · 7 lines
1.9.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#19 lore raw

PATCH v9 6/19 xen: Rename xen_be_printf to xen_pv_printf

In reply to Emil Condrea

Prepare xen_be_printf to be used by both backend and frontends:
* xen_be_printf -> xen_pv_printf

---
 hw/block/xen_disk.c        | 52 +++++++++++++++++++++++-----------------------
 hw/char/xen_console.c      | 10 ++++-----
 hw/display/xenfb.c         | 42 ++++++++++++++++++-------------------
 hw/net/xen_nic.c           | 22 ++++++++++----------
 hw/usb/xen-usb.c           | 38 ++++++++++++++++-----------------
 hw/xen/xen_backend.c       | 44 +++++++++++++++++++--------------------
 hw/xen/xen_devconfig.c     |  4 ++--
 hw/xen/xen_frontend.c      |  6 +++---
 hw/xen/xen_pvdev.c         |  6 +++---
 include/hw/xen/xen_pvdev.h |  2 +-
 xen-common.c               |  4 ++--
 11 files changed, 115 insertions(+), 115 deletions(-)
hw/block/xen_disk.c +26 -26
index 28fbf24..ad3f519 100644
@@ -165,12 +165,12 @@ static void destroy_grant(gpointer pgnt)
     xengnttab_handle *gnt = grant->blkdev->xendev.gnttabdev;
 
     if (xengnttab_unmap(gnt, grant->page, 1) != 0) {
-        xen_be_printf(&grant->blkdev->xendev, 0,
+        xen_pv_printf(&grant->blkdev->xendev, 0,
                       "xengnttab_unmap failed: %s\n",
                       strerror(errno));
     }
     grant->blkdev->persistent_gnt_count--;
-    xen_be_printf(&grant->blkdev->xendev, 3,
+    xen_pv_printf(&grant->blkdev->xendev, 3,
                   "unmapped grant %p\n", grant->page);
     g_free(grant);
 }
@@ -182,11 +182,11 @@ static void remove_persistent_region(gpointer data, gpointer dev)
     xengnttab_handle *gnt = blkdev->xendev.gnttabdev;
 
     if (xengnttab_unmap(gnt, region->addr, region->num) != 0) {
-        xen_be_printf(&blkdev->xendev, 0,
+        xen_pv_printf(&blkdev->xendev, 0,
                       "xengnttab_unmap region %p failed: %s\n",
                       region->addr, strerror(errno));
     }
-    xen_be_printf(&blkdev->xendev, 3,
+    xen_pv_printf(&blkdev->xendev, 3,
                   "unmapped grant region %p with %d pages\n",
                   region->addr, region->num);
     g_free(region);
@@ -253,7 +253,7 @@ static int ioreq_parse(struct ioreq *ioreq)
     size_t len;
     int i;
 
-    xen_be_printf(&blkdev->xendev, 3,
+    xen_pv_printf(&blkdev->xendev, 3,
                   "op %d, nr %d, handle %d, id %" PRId64 ", sector %" PRId64 "\n",
                   ioreq->req.operation, ioreq->req.nr_segments,
                   ioreq->req.handle, ioreq->req.id, ioreq->req.sector_number);
@@ -273,28 +273,28 @@ static int ioreq_parse(struct ioreq *ioreq)
     case BLKIF_OP_DISCARD:
         return 0;
     default:
-        xen_be_printf(&blkdev->xendev, 0, "error: unknown operation (%d)\n",
+        xen_pv_printf(&blkdev->xendev, 0, "error: unknown operation (%d)\n",
                       ioreq->req.operation);
         goto err;
     };
 
     if (ioreq->req.operation != BLKIF_OP_READ && blkdev->mode[0] != 'w') {
-        xen_be_printf(&blkdev->xendev, 0, "error: write req for ro device\n");
+        xen_pv_printf(&blkdev->xendev, 0, "error: write req for ro device\n");
         goto err;
     }
 
     ioreq->start = ioreq->req.sector_number * blkdev->file_blk;
     for (i = 0; i < ioreq->req.nr_segments; i++) {
         if (i == BLKIF_MAX_SEGMENTS_PER_REQUEST) {
-            xen_be_printf(&blkdev->xendev, 0, "error: nr_segments too big\n");
+            xen_pv_printf(&blkdev->xendev, 0, "error: nr_segments too big\n");
             goto err;
         }
         if (ioreq->req.seg[i].first_sect > ioreq->req.seg[i].last_sect) {
-            xen_be_printf(&blkdev->xendev, 0, "error: first > last sector\n");
+            xen_pv_printf(&blkdev->xendev, 0, "error: first > last sector\n");
             goto err;
         }
         if (ioreq->req.seg[i].last_sect * BLOCK_SIZE >= XC_PAGE_SIZE) {
-            xen_be_printf(&blkdev->xendev, 0, "error: page crossing\n");
+            xen_pv_printf(&blkdev->xendev, 0, "error: page crossing\n");
             goto err;
         }
 
@@ -306,7 +306,7 @@ static int ioreq_parse(struct ioreq *ioreq)
         qemu_iovec_add(&ioreq->v, (void*)mem, len);
     }
     if (ioreq->start + ioreq->v.size > blkdev->file_size) {
-        xen_be_printf(&blkdev->xendev, 0, "error: access beyond end of file\n");
+        xen_pv_printf(&blkdev->xendev, 0, "error: access beyond end of file\n");
         goto err;
     }
     return 0;
@@ -329,7 +329,7 @@ static void ioreq_unmap(struct ioreq *ioreq)
             return;
         }
         if (xengnttab_unmap(gnt, ioreq->pages, ioreq->num_unmap) != 0) {
-            xen_be_printf(&ioreq->blkdev->xendev, 0,
+            xen_pv_printf(&ioreq->blkdev->xendev, 0,
                           "xengnttab_unmap failed: %s\n",
                           strerror(errno));
         }
@@ -341,7 +341,7 @@ static void ioreq_unmap(struct ioreq *ioreq)
                 continue;
             }
             if (xengnttab_unmap(gnt, ioreq->page[i], 1) != 0) {
-                xen_be_printf(&ioreq->blkdev->xendev, 0,
+                xen_pv_printf(&ioreq->blkdev->xendev, 0,
                               "xengnttab_unmap failed: %s\n",
                               strerror(errno));
             }
@@ -379,7 +379,7 @@ static int ioreq_map(struct ioreq *ioreq)
 
             if (grant != NULL) {
                 page[i] = grant->page;
-                xen_be_printf(&ioreq->blkdev->xendev, 3,
+                xen_pv_printf(&ioreq->blkdev->xendev, 3,
                               "using persistent-grant %" PRIu32 "\n",
                               ioreq->refs[i]);
             } else {
@@ -408,7 +408,7 @@ static int ioreq_map(struct ioreq *ioreq)
         ioreq->pages = xengnttab_map_grant_refs
             (gnt, new_maps, domids, refs, ioreq->prot);
         if (ioreq->pages == NULL) {
-            xen_be_printf(&ioreq->blkdev->xendev, 0,
+            xen_pv_printf(&ioreq->blkdev->xendev, 0,
                           "can't map %d grant refs (%s, %d maps)\n",
                           new_maps, strerror(errno), ioreq->blkdev->cnt_map);
             return -1;
@@ -424,7 +424,7 @@ static int ioreq_map(struct ioreq *ioreq)
             ioreq->page[i] = xengnttab_map_grant_ref
                 (gnt, domids[i], refs[i], ioreq->prot);
             if (ioreq->page[i] == NULL) {
-                xen_be_printf(&ioreq->blkdev->xendev, 0,
+                xen_pv_printf(&ioreq->blkdev->xendev, 0,
                               "can't map grant ref %d (%s, %d maps)\n",
                               refs[i], strerror(errno), ioreq->blkdev->cnt_map);
                 ioreq->mapped = 1;
@@ -472,7 +472,7 @@ static int ioreq_map(struct ioreq *ioreq)
                 grant->page = ioreq->page[new_maps];
             }
             grant->blkdev = ioreq->blkdev;
-            xen_be_printf(&ioreq->blkdev->xendev, 3,
+            xen_pv_printf(&ioreq->blkdev->xendev, 3,
                           "adding grant %" PRIu32 " page: %p\n",
                           refs[new_maps], grant->page);
             g_tree_insert(ioreq->blkdev->persistent_gnts,
@@ -497,7 +497,7 @@ static void qemu_aio_complete(void *opaque, int ret)
     struct ioreq *ioreq = opaque;
 
     if (ret != 0) {
-        xen_be_printf(&ioreq->blkdev->xendev, 0, "%s I/O error\n",
+        xen_pv_printf(&ioreq->blkdev->xendev, 0, "%s I/O error\n",
                       ioreq->req.operation == BLKIF_OP_READ ? "read" : "write");
         ioreq->aio_errors++;
     }
@@ -773,7 +773,7 @@ static void blk_alloc(struct XenDevice *xendev)
     }
     if (xengnttab_set_max_grants(xendev->gnttabdev,
             MAX_GRANTS(max_requests, BLKIF_MAX_SEGMENTS_PER_REQUEST)) < 0) {
-        xen_be_printf(xendev, 0, "xengnttab_set_max_grants failed: %s\n",
+        xen_pv_printf(xendev, 0, "xengnttab_set_max_grants failed: %s\n",
                       strerror(errno));
     }
 }
@@ -919,11 +919,11 @@ static int blk_connect(struct XenDevice *xendev)
         }
 
         /* setup via xenbus -> create new block driver instance */
-        xen_be_printf(&blkdev->xendev, 2, "create new bdrv (xenbus setup)\n");
+        xen_pv_printf(&blkdev->xendev, 2, "create new bdrv (xenbus setup)\n");
         blkdev->blk = blk_new_open(blkdev->filename, NULL, options,
                                    qflags, &local_err);
         if (!blkdev->blk) {
-            xen_be_printf(&blkdev->xendev, 0, "error: %s\n",
+            xen_pv_printf(&blkdev->xendev, 0, "error: %s\n",
                           error_get_pretty(local_err));
             error_free(local_err);
             return -1;
@@ -931,10 +931,10 @@ static int blk_connect(struct XenDevice *xendev)
         blk_set_enable_write_cache(blkdev->blk, !writethrough);
     } else {
         /* setup via qemu cmdline -> already setup for us */
-        xen_be_printf(&blkdev->xendev, 2, "get configured bdrv (cmdline setup)\n");
+        xen_pv_printf(&blkdev->xendev, 2, "get configured bdrv (cmdline setup)\n");
         blkdev->blk = blk_by_legacy_dinfo(blkdev->dinfo);
         if (blk_is_read_only(blkdev->blk) && !readonly) {
-            xen_be_printf(&blkdev->xendev, 0, "Unexpected read-only drive");
+            xen_pv_printf(&blkdev->xendev, 0, "Unexpected read-only drive");
             blkdev->blk = NULL;
             return -1;
         }
@@ -947,13 +947,13 @@ static int blk_connect(struct XenDevice *xendev)
     if (blkdev->file_size < 0) {
         BlockDriverState *bs = blk_bs(blkdev->blk);
         const char *drv_name = bs ? bdrv_get_format_name(bs) : NULL;
-        xen_be_printf(&blkdev->xendev, 1, "blk_getlength: %d (%s) | drv %s\n",
+        xen_pv_printf(&blkdev->xendev, 1, "blk_getlength: %d (%s) | drv %s\n",
                       (int)blkdev->file_size, strerror(-blkdev->file_size),
                       drv_name ?: "-");
         blkdev->file_size = 0;
     }
 
-    xen_be_printf(xendev, 1, "type \"%s\", fileproto \"%s\", filename \"%s\","
+    xen_pv_printf(xendev, 1, "type \"%s\", fileproto \"%s\", filename \"%s\","
                   " size %" PRId64 " (%" PRId64 " MB)\n",
                   blkdev->type, blkdev->fileproto, blkdev->filename,
                   blkdev->file_size, blkdev->file_size >> 20);
@@ -1032,7 +1032,7 @@ static int blk_connect(struct XenDevice *xendev)
 
     xen_be_bind_evtchn(&blkdev->xendev);
 
-    xen_be_printf(&blkdev->xendev, 1, "ok: proto %s, ring-ref %d, "
+    xen_pv_printf(&blkdev->xendev, 1, "ok: proto %s, ring-ref %d, "
                   "remote port %d, local port %d\n",
                   blkdev->xendev.protocol, blkdev->ring_ref,
                   blkdev->xendev.remote_port, blkdev->xendev.local_port);
hw/char/xen_console.c +5 -5
index 83108b0..e6bae67 100644
@@ -156,13 +156,13 @@ static void xencons_send(struct XenConsole *con)
     if (len < 1) {
 	if (!con->backlog) {
 	    con->backlog = 1;
-	    xen_be_printf(&con->xendev, 1, "backlog piling up, nobody listening?\n");
+	    xen_pv_printf(&con->xendev, 1, "backlog piling up, nobody listening?\n");
 	}
     } else {
 	buffer_advance(&con->buffer, len);
 	if (con->backlog && len == size) {
 	    con->backlog = 0;
-	    xen_be_printf(&con->xendev, 1, "backlog is gone\n");
+	    xen_pv_printf(&con->xendev, 1, "backlog is gone\n");
 	}
     }
 }
@@ -187,7 +187,7 @@ static int con_init(struct XenDevice *xendev)
 
     type = xenstore_read_str(con->console, "type");
     if (!type || strcmp(type, "ioemu") != 0) {
-	xen_be_printf(xendev, 1, "not for me (type=%s)\n", type);
+	xen_pv_printf(xendev, 1, "not for me (type=%s)\n", type);
         ret = -1;
         goto out;
     }
@@ -240,14 +240,14 @@ static int con_initialise(struct XenDevice *xendev)
             qemu_chr_add_handlers(con->chr, xencons_can_receive,
                                   xencons_receive, NULL, con);
         } else {
-            xen_be_printf(xendev, 0,
+            xen_pv_printf(xendev, 0,
                           "xen_console_init error chardev %s already used\n",
                           con->chr->label);
             con->chr = NULL;
         }
     }
 
-    xen_be_printf(xendev, 1, "ring mfn %d, remote port %d, local port %d, limit %zd\n",
+    xen_pv_printf(xendev, 1, "ring mfn %d, remote port %d, local port %d, limit %zd\n",
 		  con->ring_ref,
 		  con->xendev.remote_port,
 		  con->xendev.local_port,
hw/display/xenfb.c +21 -21

153 lines not on this page · raw message

hw/net/xen_nic.c +11 -11
index bdfa789..91126b5 100644
@@ -129,30 +129,30 @@ static void net_tx_packets(struct XenNetDev *netdev)
             /* should not happen in theory, we don't announce the *
              * feature-{sg,gso,whatelse} flags in xenstore (yet?) */
             if (txreq.flags & NETTXF_extra_info) {
-                xen_be_printf(&netdev->xendev, 0, "FIXME: extra info flag\n");
+                xen_pv_printf(&netdev->xendev, 0, "FIXME: extra info flag\n");
                 net_tx_error(netdev, &txreq, rc);
                 continue;
             }
             if (txreq.flags & NETTXF_more_data) {
-                xen_be_printf(&netdev->xendev, 0, "FIXME: more data flag\n");
+                xen_pv_printf(&netdev->xendev, 0, "FIXME: more data flag\n");
                 net_tx_error(netdev, &txreq, rc);
                 continue;
             }
 #endif
 
             if (txreq.size < 14) {
-                xen_be_printf(&netdev->xendev, 0, "bad packet size: %d\n", txreq.size);
+                xen_pv_printf(&netdev->xendev, 0, "bad packet size: %d\n", txreq.size);
                 net_tx_error(netdev, &txreq, rc);
                 continue;
             }
 
             if ((txreq.offset + txreq.size) > XC_PAGE_SIZE) {
-                xen_be_printf(&netdev->xendev, 0, "error: page crossing\n");
+                xen_pv_printf(&netdev->xendev, 0, "error: page crossing\n");
                 net_tx_error(netdev, &txreq, rc);
                 continue;
             }
 
-            xen_be_printf(&netdev->xendev, 3, "tx packet ref %d, off %d, len %d, flags 0x%x%s%s%s%s\n",
+            xen_pv_printf(&netdev->xendev, 3, "tx packet ref %d, off %d, len %d, flags 0x%x%s%s%s%s\n",
                           txreq.gref, txreq.offset, txreq.size, txreq.flags,
                           (txreq.flags & NETTXF_csum_blank)     ? " csum_blank"     : "",
                           (txreq.flags & NETTXF_data_validated) ? " data_validated" : "",
@@ -163,7 +163,7 @@ static void net_tx_packets(struct XenNetDev *netdev)
                                            netdev->xendev.dom,
                                            txreq.gref, PROT_READ);
             if (page == NULL) {
-                xen_be_printf(&netdev->xendev, 0, "error: tx gref dereference failed (%d)\n",
+                xen_pv_printf(&netdev->xendev, 0, "error: tx gref dereference failed (%d)\n",
                               txreq.gref);
                 net_tx_error(netdev, &txreq, rc);
                 continue;
@@ -212,7 +212,7 @@ static void net_rx_response(struct XenNetDev *netdev,
         resp->status = (int16_t)st;
     }
 
-    xen_be_printf(&netdev->xendev, 3, "rx response: idx %d, status %d, flags 0x%x\n",
+    xen_pv_printf(&netdev->xendev, 3, "rx response: idx %d, status %d, flags 0x%x\n",
                   i, resp->status, resp->flags);
 
     netdev->rx_ring.rsp_prod_pvt = ++i;
@@ -243,7 +243,7 @@ static ssize_t net_rx_packet(NetClientState *nc, const uint8_t *buf, size_t size
         return 0;
     }
     if (size > XC_PAGE_SIZE - NET_IP_ALIGN) {
-        xen_be_printf(&netdev->xendev, 0, "packet too big (%lu > %ld)",
+        xen_pv_printf(&netdev->xendev, 0, "packet too big (%lu > %ld)",
                       (unsigned long)size, XC_PAGE_SIZE - NET_IP_ALIGN);
         return -1;
     }
@@ -255,7 +255,7 @@ static ssize_t net_rx_packet(NetClientState *nc, const uint8_t *buf, size_t size
                                    netdev->xendev.dom,
                                    rxreq.gref, PROT_WRITE);
     if (page == NULL) {
-        xen_be_printf(&netdev->xendev, 0, "error: rx gref dereference failed (%d)\n",
+        xen_pv_printf(&netdev->xendev, 0, "error: rx gref dereference failed (%d)\n",
                       rxreq.gref);
         net_rx_response(netdev, &rxreq, NETIF_RSP_ERROR, 0, 0, 0);
         return -1;
@@ -329,7 +329,7 @@ static int net_connect(struct XenDevice *xendev)
         rx_copy = 0;
     }
     if (rx_copy == 0) {
-        xen_be_printf(&netdev->xendev, 0, "frontend doesn't support rx-copy.\n");
+        xen_pv_printf(&netdev->xendev, 0, "frontend doesn't support rx-copy.\n");
         return -1;
     }
 
@@ -354,7 +354,7 @@ static int net_connect(struct XenDevice *xendev)
 
     xen_be_bind_evtchn(&netdev->xendev);
 
-    xen_be_printf(&netdev->xendev, 1, "ok: tx-ring-ref %d, rx-ring-ref %d, "
+    xen_pv_printf(&netdev->xendev, 1, "ok: tx-ring-ref %d, rx-ring-ref %d, "
                   "remote port %d, local port %d\n",
                   netdev->tx_ring_ref, netdev->rx_ring_ref,
                   netdev->xendev.remote_port, netdev->xendev.local_port);
hw/usb/xen-usb.c +19 -19
index 0fd34c6..bcf5c2e 100644
@@ -47,7 +47,7 @@
         struct timeval tv;                                          \
                                                                     \
         gettimeofday(&tv, NULL);                                    \
-        xen_be_printf(xendev, lvl, "%8ld.%06ld xen-usb(%s):" fmt,   \
+        xen_pv_printf(xendev, lvl, "%8ld.%06ld xen-usb(%s):" fmt,   \
                       tv.tv_sec, tv.tv_usec, __func__, ##args);     \
     }
 #define TR_BUS(xendev, fmt, args...) TR(xendev, 2, fmt, ##args)
@@ -151,7 +151,7 @@ static int usbback_gnttab_map(struct usbback_req *usbback_req)
     }
 
     if (nr_segs > USBIF_MAX_SEGMENTS_PER_REQUEST) {
-        xen_be_printf(xendev, 0, "bad number of segments in request (%d)\n",
+        xen_pv_printf(xendev, 0, "bad number of segments in request (%d)\n",
                       nr_segs);
         return -EINVAL;
     }
@@ -159,7 +159,7 @@ static int usbback_gnttab_map(struct usbback_req *usbback_req)
     for (i = 0; i < nr_segs; i++) {
         if ((unsigned)usbback_req->req.seg[i].offset +
             (unsigned)usbback_req->req.seg[i].length > PAGE_SIZE) {
-            xen_be_printf(xendev, 0, "segment crosses page boundary\n");
+            xen_pv_printf(xendev, 0, "segment crosses page boundary\n");
             return -EINVAL;
         }
     }
@@ -197,7 +197,7 @@ static int usbback_gnttab_map(struct usbback_req *usbback_req)
      */
 
     if (!usbback_req->nr_extra_segs) {
-        xen_be_printf(xendev, 0, "iso request without descriptor segments\n");
+        xen_pv_printf(xendev, 0, "iso request without descriptor segments\n");
         return -EINVAL;
     }
 
@@ -548,14 +548,14 @@ static void usbback_dispatch(struct usbback_req *usbback_req)
 
     ret = usbback_init_packet(usbback_req);
     if (ret) {
-        xen_be_printf(&usbif->xendev, 0, "invalid request\n");
+        xen_pv_printf(&usbif->xendev, 0, "invalid request\n");
         ret = -ESHUTDOWN;
         goto fail_free_urb;
     }
 
     ret = usbback_gnttab_map(usbback_req);
     if (ret) {
-        xen_be_printf(&usbif->xendev, 0, "invalid buffer, ret=%d\n", ret);
+        xen_pv_printf(&usbif->xendev, 0, "invalid buffer, ret=%d\n", ret);
         ret = -ESHUTDOWN;
         goto fail_free_urb;
     }
@@ -643,7 +643,7 @@ static void usbback_bh(void *opaque)
 
     if (RING_REQUEST_PROD_OVERFLOW(urb_ring, rp)) {
         rc = urb_ring->rsp_prod_pvt;
-        xen_be_printf(&usbif->xendev, 0, "domU provided bogus ring requests "
+        xen_pv_printf(&usbif->xendev, 0, "domU provided bogus ring requests "
                       "(%#x - %#x = %u). Halting ring processing.\n",
                       rp, rc, rp - rc);
         usbif->ring_error = true;
@@ -716,7 +716,7 @@ static void usbback_portid_add(struct usbback_info *usbif, unsigned port,
 
     portname = strchr(busid, '-');
     if (!portname) {
-        xen_be_printf(&usbif->xendev, 0, "device %s illegal specification\n",
+        xen_pv_printf(&usbif->xendev, 0, "device %s illegal specification\n",
                       busid);
         return;
     }
@@ -755,7 +755,7 @@ static void usbback_portid_add(struct usbback_info *usbif, unsigned port,
         break;
     }
     if (speed == USBIF_SPEED_NONE) {
-        xen_be_printf(&usbif->xendev, 0, "device %s wrong speed\n", busid);
+        xen_pv_printf(&usbif->xendev, 0, "device %s wrong speed\n", busid);
         object_unparent(OBJECT(usbif->ports[port - 1].dev));
         usbif->ports[port - 1].dev = NULL;
         return;
@@ -772,7 +772,7 @@ static void usbback_portid_add(struct usbback_info *usbif, unsigned port,
 err:
     QDECREF(qdict);
     snprintf(p->path, sizeof(p->path), "%d", 99);
-    xen_be_printf(&usbif->xendev, 0, "device %s could not be opened\n", busid);
+    xen_pv_printf(&usbif->xendev, 0, "device %s could not be opened\n", busid);
 }
 
 static void usbback_process_port(struct usbback_info *usbif, unsigned port)
@@ -783,7 +783,7 @@ static void usbback_process_port(struct usbback_info *usbif, unsigned port)
     snprintf(node, sizeof(node), "port/%d", port);
     busid = xenstore_read_be_str(&usbif->xendev, node);
     if (busid == NULL) {
-        xen_be_printf(&usbif->xendev, 0, "xenstore_read %s failed\n", node);
+        xen_pv_printf(&usbif->xendev, 0, "xenstore_read %s failed\n", node);
         return;
     }
 
@@ -844,15 +844,15 @@ static int usbback_connect(struct XenDevice *xendev)
     usbif = container_of(xendev, struct usbback_info, xendev);
 
     if (xenstore_read_fe_int(xendev, "urb-ring-ref", &urb_ring_ref)) {
-        xen_be_printf(xendev, 0, "error reading urb-ring-ref\n");
+        xen_pv_printf(xendev, 0, "error reading urb-ring-ref\n");
         return -1;
     }
     if (xenstore_read_fe_int(xendev, "conn-ring-ref", &conn_ring_ref)) {
-        xen_be_printf(xendev, 0, "error reading conn-ring-ref\n");
+        xen_pv_printf(xendev, 0, "error reading conn-ring-ref\n");
         return -1;
     }
     if (xenstore_read_fe_int(xendev, "event-channel", &xendev->remote_port)) {
-        xen_be_printf(xendev, 0, "error reading event-channel\n");
+        xen_pv_printf(xendev, 0, "error reading event-channel\n");
         return -1;
     }
 
@@ -863,7 +863,7 @@ static int usbback_connect(struct XenDevice *xendev)
                                                 conn_ring_ref,
                                                 PROT_READ | PROT_WRITE);
     if (!usbif->urb_sring || !usbif->conn_sring) {
-        xen_be_printf(xendev, 0, "error mapping rings\n");
+        xen_pv_printf(xendev, 0, "error mapping rings\n");
         usbback_disconnect(xendev);
         return -1;
     }
@@ -875,7 +875,7 @@ static int usbback_connect(struct XenDevice *xendev)
 
     xen_be_bind_evtchn(xendev);
 
-    xen_be_printf(xendev, 1, "urb-ring-ref %d, conn-ring-ref %d, "
+    xen_pv_printf(xendev, 1, "urb-ring-ref %d, conn-ring-ref %d, "
                   "remote port %d, local port %d\n", urb_ring_ref,
                   conn_ring_ref, xendev->remote_port, xendev->local_port);
 
@@ -911,12 +911,12 @@ static int usbback_init(struct XenDevice *xendev)
 
     if (xenstore_read_be_int(xendev, "num-ports", &usbif->num_ports) ||
         usbif->num_ports < 1 || usbif->num_ports > USBBACK_MAXPORTS) {
-        xen_be_printf(xendev, 0, "num-ports not readable or out of bounds\n");
+        xen_pv_printf(xendev, 0, "num-ports not readable or out of bounds\n");
         return -1;
     }
     if (xenstore_read_be_int(xendev, "usb-ver", &usbif->usb_ver) ||
         (usbif->usb_ver != USB_VER_USB11 && usbif->usb_ver != USB_VER_USB20)) {
-        xen_be_printf(xendev, 0, "usb-ver not readable or out of bounds\n");
+        xen_pv_printf(xendev, 0, "usb-ver not readable or out of bounds\n");
         return -1;
     }
 
@@ -998,7 +998,7 @@ static void usbback_alloc(struct XenDevice *xendev)
     /* max_grants: for each request and for the rings (request and connect). */
     max_grants = USBIF_MAX_SEGMENTS_PER_REQUEST * USB_URB_RING_SIZE + 2;
     if (xengnttab_set_max_grants(xendev->gnttabdev, max_grants) < 0) {
-        xen_be_printf(xendev, 0, "xengnttab_set_max_grants failed: %s\n",
+        xen_pv_printf(xendev, 0, "xengnttab_set_max_grants failed: %s\n",
                       strerror(errno));
     }
 }
hw/xen/xen_backend.c +22 -22

159 lines not on this page · raw message

hw/xen/xen_devconfig.c +2 -2
index b7d290d..a80e78c 100644
@@ -55,7 +55,7 @@ int xen_config_dev_blk(DriveInfo *disk)
     const char *filename = qemu_opt_get(disk->opts, "file");
 
     snprintf(device_name, sizeof(device_name), "xvd%c", 'a' + disk->unit);
-    xen_be_printf(NULL, 1, "config disk %d [%s]: %s\n",
+    xen_pv_printf(NULL, 1, "config disk %d [%s]: %s\n",
                   disk->unit, device_name, filename);
     xen_config_dev_dirs("vbd", "qdisk", vdev, fe, be, sizeof(fe));
 
@@ -83,7 +83,7 @@ int xen_config_dev_nic(NICInfo *nic)
     snprintf(mac, sizeof(mac), "%02x:%02x:%02x:%02x:%02x:%02x",
              nic->macaddr.a[0], nic->macaddr.a[1], nic->macaddr.a[2],
              nic->macaddr.a[3], nic->macaddr.a[4], nic->macaddr.a[5]);
-    xen_be_printf(NULL, 1, "config nic %d: mac=\"%s\"\n", vlan_id, mac);
+    xen_pv_printf(NULL, 1, "config nic %d: mac=\"%s\"\n", vlan_id, mac);
     xen_config_dev_dirs("vif", "qnic", vlan_id, fe, be, sizeof(fe));
 
     /* frontend */
hw/xen/xen_frontend.c +3 -3
index 4e01169..474c74a 100644
@@ -47,7 +47,7 @@ void xen_be_frontend_changed(struct XenDevice *xendev, const char *node)
             fe_state = XenbusStateUnknown;
         }
         if (xendev->fe_state != fe_state) {
-            xen_be_printf(xendev, 1, "frontend state: %s -> %s\n",
+            xen_pv_printf(xendev, 1, "frontend state: %s -> %s\n",
                           xenbus_strstate(xendev->fe_state),
                           xenbus_strstate(fe_state));
         }
@@ -57,12 +57,12 @@ void xen_be_frontend_changed(struct XenDevice *xendev, const char *node)
         g_free(xendev->protocol);
         xendev->protocol = xenstore_read_fe_str(xendev, "protocol");
         if (xendev->protocol) {
-            xen_be_printf(xendev, 1, "frontend protocol: %s\n", xendev->protocol);
+            xen_pv_printf(xendev, 1, "frontend protocol: %s\n", xendev->protocol);
         }
     }
 
     if (node) {
-        xen_be_printf(xendev, 2, "frontend update: %s\n", node);
+        xen_pv_printf(xendev, 2, "frontend update: %s\n", node);
         if (xendev->ops->frontend_changed) {
             xendev->ops->frontend_changed(xendev, node);
         }
hw/xen/xen_pvdev.c +3 -3
index 042adeb..7375b43 100644
@@ -142,7 +142,7 @@ const char *xenbus_strstate(enum xenbus_state state)
  *  2 == noisy debug messages (logfile only).
  *  3 == will flood your log (logfile only).
  */
-void xen_be_printf(struct XenDevice *xendev, int msg_level, const char *fmt, ...)
+void xen_pv_printf(struct XenDevice *xendev, int msg_level, const char *fmt, ...)
 {
     va_list args;
 
@@ -181,7 +181,7 @@ void xen_be_evtchn_event(void *opaque)
 
     port = xenevtchn_pending(xendev->evtchndev);
     if (port != xendev->local_port) {
-        xen_be_printf(xendev, 0,
+        xen_pv_printf(xendev, 0,
                       "xenevtchn_pending returned %d (expected %d)\n",
                       port, xendev->local_port);
         return;
@@ -200,7 +200,7 @@ void xen_be_unbind_evtchn(struct XenDevice *xendev)
     }
     qemu_set_fd_handler(xenevtchn_fd(xendev->evtchndev), NULL, NULL, NULL);
     xenevtchn_unbind(xendev->evtchndev, xendev->local_port);
-    xen_be_printf(xendev, 2, "unbind evtchn port %d\n", xendev->local_port);
+    xen_pv_printf(xendev, 2, "unbind evtchn port %d\n", xendev->local_port);
     xendev->local_port = -1;
 }
 
include/hw/xen/xen_pvdev.h +1 -1
index 234e111..3e2dfd8 100644
@@ -74,7 +74,7 @@ struct XenDevice *xen_be_find_xendev(const char *type, int dom, int dev);
 void xen_be_unbind_evtchn(struct XenDevice *xendev);
 int xen_be_send_notify(struct XenDevice *xendev);
 
-void xen_be_printf(struct XenDevice *xendev, int msg_level, const char *fmt, ...)
+void xen_pv_printf(struct XenDevice *xendev, int msg_level, const char *fmt, ...)
     GCC_FMT_ATTR(3, 4);
 
 #endif /* QEMU_HW_XEN_PVDEV_H */
xen-common.c +2 -2
index e641ad1..9099760 100644
@@ -116,12 +116,12 @@ static int xen_init(MachineState *ms)
 {
     xen_xc = xc_interface_open(0, 0, 0);
     if (xen_xc == NULL) {
-        xen_be_printf(NULL, 0, "can't open xen interface\n");
+        xen_pv_printf(NULL, 0, "can't open xen interface\n");
         return -1;
     }
     xen_fmem = xenforeignmemory_open(0, 0);
     if (xen_fmem == NULL) {
-        xen_be_printf(NULL, 0, "can't open xen fmem interface\n");
+        xen_pv_printf(NULL, 0, "can't open xen fmem interface\n");
         xc_interface_close(xen_xc);
         return -1;
     }
Signature · 1 line
1.9.1
#20 lore raw

PATCH v9 7/19 xen: Rename xen_be_unbind_evtchn

In reply to Emil Condrea

Prepare xen_be_unbind_evtchn to be shared with frontends:
* xen_be_unbind_evtchn -> xen_pv_unbind_evtchn

---
 hw/block/xen_disk.c        | 2 +-
 hw/char/xen_console.c      | 2 +-
 hw/display/xenfb.c         | 2 +-
 hw/net/xen_nic.c           | 2 +-
 hw/xen/xen_pvdev.c         | 2 +-
 include/hw/xen/xen_pvdev.h | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)
hw/block/xen_disk.c +1 -1
index ad3f519..0716ca2 100644
@@ -1048,7 +1048,7 @@ static void blk_disconnect(struct XenDevice *xendev)
         blk_unref(blkdev->blk);
         blkdev->blk = NULL;
     }
-    xen_be_unbind_evtchn(&blkdev->xendev);
+    xen_pv_unbind_evtchn(&blkdev->xendev);
 
     if (blkdev->sring) {
         xengnttab_unmap(blkdev->xendev.gnttabdev, blkdev->sring, 1);
hw/char/xen_console.c +1 -1
index e6bae67..889f7b2 100644
@@ -263,7 +263,7 @@ static void con_disconnect(struct XenDevice *xendev)
         qemu_chr_add_handlers(con->chr, NULL, NULL, NULL, NULL);
         qemu_chr_fe_release(con->chr);
     }
-    xen_be_unbind_evtchn(&con->xendev);
+    xen_pv_unbind_evtchn(&con->xendev);
 
     if (con->sring) {
         if (!xendev->dev) {
hw/display/xenfb.c +1 -1
index b1e8b3b..250dbc2 100644
@@ -112,7 +112,7 @@ static int common_bind(struct common *c)
 
 static void common_unbind(struct common *c)
 {
-    xen_be_unbind_evtchn(&c->xendev);
+    xen_pv_unbind_evtchn(&c->xendev);
     if (c->page) {
         xenforeignmemory_unmap(xen_fmem, c->page, 1);
 	c->page = NULL;
hw/net/xen_nic.c +1 -1
index 91126b5..1fc6a22 100644
@@ -367,7 +367,7 @@ static void net_disconnect(struct XenDevice *xendev)
 {
     struct XenNetDev *netdev = container_of(xendev, struct XenNetDev, xendev);
 
-    xen_be_unbind_evtchn(&netdev->xendev);
+    xen_pv_unbind_evtchn(&netdev->xendev);
 
     if (netdev->txs) {
         xengnttab_unmap(netdev->xendev.gnttabdev, netdev->txs, 1);
hw/xen/xen_pvdev.c +1 -1
index 7375b43..6bf1ae4 100644
@@ -193,7 +193,7 @@ void xen_be_evtchn_event(void *opaque)
     }
 }
 
-void xen_be_unbind_evtchn(struct XenDevice *xendev)
+void xen_pv_unbind_evtchn(struct XenDevice *xendev)
 {
     if (xendev->local_port == -1) {
         return;
include/hw/xen/xen_pvdev.h +1 -1
index 3e2dfd8..5c27184 100644
@@ -71,7 +71,7 @@ void xen_pv_insert_xendev(struct XenDevice *xendev);
 struct XenDevice *xen_be_del_xendev(int dom, int dev);
 struct XenDevice *xen_be_find_xendev(const char *type, int dom, int dev);
 
-void xen_be_unbind_evtchn(struct XenDevice *xendev);
+void xen_pv_unbind_evtchn(struct XenDevice *xendev);
 int xen_be_send_notify(struct XenDevice *xendev);
 
 void xen_pv_printf(struct XenDevice *xendev, int msg_level, const char *fmt, ...)
Signature · 7 lines
1.9.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#21 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH 07/19] xen: Rename xen_be_unbind_evtchn

Quoted 4 lines · Emil Condrea

Prepare xen_be_unbind_evtchn to be shared with frontends:
* xen_be_unbind_evtchn -> xen_pv_unbind_evtchn

Quoted 8 lines
---
 hw/block/xen_disk.c        | 2 +-
 hw/char/xen_console.c      | 2 +-
 hw/display/xenfb.c         | 2 +-
 hw/net/xen_nic.c           | 2 +-
 hw/xen/xen_pvdev.c         | 2 +-
 include/hw/xen/xen_pvdev.h | 2 +-
 6 files changed, 6 insertions(+), 6 deletions(-)

There is one change missing in hw/usb/xen-usb.c.

Signature · 6 lines
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#22 lore raw

PATCH v9 8/19 xen: Rename xen_be_send_notify

In reply to Emil Condrea

Prepare xen_be_send_notify to be shared with frontends:
* xen_be_send_notify -> xen_pv_send_notify

---
 hw/block/xen_disk.c        | 4 ++--
 hw/char/xen_console.c      | 4 ++--
 hw/display/xenfb.c         | 8 ++++----
 hw/net/xen_nic.c           | 4 ++--
 hw/xen/xen_pvdev.c         | 2 +-
 include/hw/xen/xen_pvdev.h | 2 +-
 6 files changed, 12 insertions(+), 12 deletions(-)
hw/block/xen_disk.c +2 -2
index 0716ca2..c36b08b 100644
@@ -659,7 +659,7 @@ static void blk_send_response_all(struct XenBlkDev *blkdev)
         ioreq_release(ioreq, true);
     }
     if (send_notify) {
-        xen_be_send_notify(&blkdev->xendev);
+        xen_pv_send_notify(&blkdev->xendev);
     }
 }
 
@@ -729,7 +729,7 @@ static void blk_handle_requests(struct XenBlkDev *blkdev)
             };
 
             if (blk_send_response_one(ioreq)) {
-                xen_be_send_notify(&blkdev->xendev);
+                xen_pv_send_notify(&blkdev->xendev);
             }
             ioreq_release(ioreq, false);
             continue;
hw/char/xen_console.c +2 -2
index 889f7b2..94e6ab0 100644
@@ -72,7 +72,7 @@ static void buffer_append(struct XenConsole *con)
 
     xen_mb();
     intf->out_cons = cons;
-    xen_be_send_notify(&con->xendev);
+    xen_pv_send_notify(&con->xendev);
 
     if (buffer->max_capacity &&
 	buffer->size > buffer->max_capacity) {
@@ -140,7 +140,7 @@ static void xencons_receive(void *opaque, const uint8_t *buf, int len)
     }
     xen_wmb();
     intf->in_prod = prod;
-    xen_be_send_notify(&con->xendev);
+    xen_pv_send_notify(&con->xendev);
 }
 
 static void xencons_send(struct XenConsole *con)
hw/display/xenfb.c +4 -4
index 250dbc2..01ae00f 100644
@@ -215,7 +215,7 @@ static int xenfb_kbd_event(struct XenInput *xenfb,
     XENKBD_IN_RING_REF(page, prod) = *event;
     xen_wmb();		/* ensure ring contents visible */
     page->in_prod = prod + 1;
-    return xen_be_send_notify(&xenfb->c.xendev);
+    return xen_pv_send_notify(&xenfb->c.xendev);
 }
 
 /* Send a keyboard (or mouse button) event */
@@ -397,7 +397,7 @@ static void input_event(struct XenDevice *xendev)
     if (page->out_prod == page->out_cons)
 	return;
     page->out_cons = page->out_prod;
-    xen_be_send_notify(&xenfb->c.xendev);
+    xen_pv_send_notify(&xenfb->c.xendev);
 }
 
 /* -------------------------------------------------------------------- */
@@ -664,7 +664,7 @@ static void xenfb_send_event(struct XenFB *xenfb, union xenfb_in_event *event)
     xen_wmb();                  /* ensure ring contents visible */
     page->in_prod = prod + 1;
 
-    xen_be_send_notify(&xenfb->c.xendev);
+    xen_pv_send_notify(&xenfb->c.xendev);
 }
 
 static void xenfb_send_refresh_period(struct XenFB *xenfb, int period)
@@ -935,7 +935,7 @@ static void fb_event(struct XenDevice *xendev)
     struct XenFB *xenfb = container_of(xendev, struct XenFB, c.xendev);
 
     xenfb_handle_events(xenfb);
-    xen_be_send_notify(&xenfb->c.xendev);
+    xen_pv_send_notify(&xenfb->c.xendev);
 }
 
 /* -------------------------------------------------------------------- */
hw/net/xen_nic.c +2 -2
index 1fc6a22..f46c745 100644
@@ -70,7 +70,7 @@ static void net_tx_response(struct XenNetDev *netdev, netif_tx_request_t *txp, i
     netdev->tx_ring.rsp_prod_pvt = ++i;
     RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(&netdev->tx_ring, notify);
     if (notify) {
-        xen_be_send_notify(&netdev->xendev);
+        xen_pv_send_notify(&netdev->xendev);
     }
 
     if (i == netdev->tx_ring.req_cons) {
@@ -218,7 +218,7 @@ static void net_rx_response(struct XenNetDev *netdev,
     netdev->rx_ring.rsp_prod_pvt = ++i;
     RING_PUSH_RESPONSES_AND_CHECK_NOTIFY(&netdev->rx_ring, notify);
     if (notify) {
-        xen_be_send_notify(&netdev->xendev);
+        xen_pv_send_notify(&netdev->xendev);
     }
 }
 
hw/xen/xen_pvdev.c +1 -1
index 6bf1ae4..3d8b2c2 100644
@@ -204,7 +204,7 @@ void xen_pv_unbind_evtchn(struct XenDevice *xendev)
     xendev->local_port = -1;
 }
 
-int xen_be_send_notify(struct XenDevice *xendev)
+int xen_pv_send_notify(struct XenDevice *xendev)
 {
     return xenevtchn_notify(xendev->evtchndev, xendev->local_port);
 }
include/hw/xen/xen_pvdev.h +1 -1
index 5c27184..80e242f 100644
@@ -72,7 +72,7 @@ struct XenDevice *xen_be_del_xendev(int dom, int dev);
 struct XenDevice *xen_be_find_xendev(const char *type, int dom, int dev);
 
 void xen_pv_unbind_evtchn(struct XenDevice *xendev);
-int xen_be_send_notify(struct XenDevice *xendev);
+int xen_pv_send_notify(struct XenDevice *xendev);
 
 void xen_pv_printf(struct XenDevice *xendev, int msg_level, const char *fmt, ...)
     GCC_FMT_ATTR(3, 4);
Signature · 7 lines
1.9.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#23 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH 08/19] xen: Rename xen_be_send_notify

Quoted 4 lines · Emil Condrea

Prepare xen_be_send_notify to be shared with frontends:
* xen_be_send_notify -> xen_pv_send_notify

Quoted 8 lines
---
 hw/block/xen_disk.c        | 4 ++--
 hw/char/xen_console.c      | 4 ++--
 hw/display/xenfb.c         | 8 ++++----
 hw/net/xen_nic.c           | 4 ++--
 hw/xen/xen_pvdev.c         | 2 +-
 include/hw/xen/xen_pvdev.h | 2 +-
 6 files changed, 12 insertions(+), 12 deletions(-)

hw/usb/xen-usb.c needs to be updated as well.

Signature · 6 lines
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#24 lore raw

PATCH v9 9/19 xen: Rename xen_be_evtchn_event

In reply to Emil Condrea

Prepare xen_be_evtchn_event to be shared with frontends:
* xen_be_evtchn_event -> xen_pv_evtchn_event

---
 hw/xen/xen_backend.c       | 2 +-
 hw/xen/xen_pvdev.c         | 2 +-
 include/hw/xen/xen_pvdev.h | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
hw/xen/xen_backend.c +1 -1
index 46e1944..d6c04c7 100644
@@ -555,7 +555,7 @@ int xen_be_bind_evtchn(struct XenDevice *xendev)
     }
     xen_pv_printf(xendev, 2, "bind evtchn port %d\n", xendev->local_port);
     qemu_set_fd_handler(xenevtchn_fd(xendev->evtchndev),
-                        xen_be_evtchn_event, NULL, xendev);
+                        xen_pv_evtchn_event, NULL, xendev);
     return 0;
 }
 
hw/xen/xen_pvdev.c +1 -1
index 3d8b2c2..5482ab0 100644
@@ -174,7 +174,7 @@ void xen_pv_printf(struct XenDevice *xendev, int msg_level, const char *fmt, ...
     qemu_log_flush();
 }
 
-void xen_be_evtchn_event(void *opaque)
+void xen_pv_evtchn_event(void *opaque)
 {
     struct XenDevice *xendev = opaque;
     evtchn_port_t port;
include/hw/xen/xen_pvdev.h +1 -1
index 80e242f..a06afb6 100644
@@ -66,7 +66,7 @@ void xenstore_update(void *unused);
 
 const char *xenbus_strstate(enum xenbus_state state);
 
-void xen_be_evtchn_event(void *opaque);
+void xen_pv_evtchn_event(void *opaque);
 void xen_pv_insert_xendev(struct XenDevice *xendev);
 struct XenDevice *xen_be_del_xendev(int dom, int dev);
 struct XenDevice *xen_be_find_xendev(const char *type, int dom, int dev);
Signature · 7 lines
1.9.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#25 lore raw

PATCH v9 10/19 xen: Rename xen_be_find_xendev

In reply to Emil Condrea

Prepare xen_be_find_xendev to be shared with frontends:
* xen_be_find_xendev -> xen_pv_find_xendev

---
 hw/display/xenfb.c         | 4 ++--
 hw/xen/xen_backend.c       | 2 +-
 hw/xen/xen_pvdev.c         | 2 +-
 include/hw/xen/xen_pvdev.h | 2 +-
 4 files changed, 5 insertions(+), 5 deletions(-)
hw/display/xenfb.c +2 -2
index 01ae00f..df13912 100644
@@ -978,8 +978,8 @@ void xen_init_display(int domid)
 wait_more:
     i++;
     main_loop_wait(true);
-    xfb = xen_be_find_xendev("vfb", domid, 0);
-    xin = xen_be_find_xendev("vkbd", domid, 0);
+    xfb = xen_pv_find_xendev("vfb", domid, 0);
+    xin = xen_pv_find_xendev("vkbd", domid, 0);
     if (!xfb || !xin) {
         if (i < 256) {
             usleep(10000);
hw/xen/xen_backend.c +1 -1
index d6c04c7..51afb1c 100644
@@ -148,7 +148,7 @@ static struct XenDevice *xen_be_get_xendev(const char *type, int dom, int dev,
 {
     struct XenDevice *xendev;
 
-    xendev = xen_be_find_xendev(type, dom, dev);
+    xendev = xen_pv_find_xendev(type, dom, dev);
     if (xendev) {
         return xendev;
     }
hw/xen/xen_pvdev.c +1 -1
index 5482ab0..24266fa 100644
@@ -211,7 +211,7 @@ int xen_pv_send_notify(struct XenDevice *xendev)
 
 /* ------------------------------------------------------------- */
 
-struct XenDevice *xen_be_find_xendev(const char *type, int dom, int dev)
+struct XenDevice *xen_pv_find_xendev(const char *type, int dom, int dev)
 {
     struct XenDevice *xendev;
 
include/hw/xen/xen_pvdev.h +1 -1
index a06afb6..f26d82a 100644
@@ -69,7 +69,7 @@ const char *xenbus_strstate(enum xenbus_state state);
 void xen_pv_evtchn_event(void *opaque);
 void xen_pv_insert_xendev(struct XenDevice *xendev);
 struct XenDevice *xen_be_del_xendev(int dom, int dev);
-struct XenDevice *xen_be_find_xendev(const char *type, int dom, int dev);
+struct XenDevice *xen_pv_find_xendev(const char *type, int dom, int dev);
 
 void xen_pv_unbind_evtchn(struct XenDevice *xendev);
 int xen_pv_send_notify(struct XenDevice *xendev);
Signature · 7 lines
1.9.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#26 lore raw

PATCH v9 11/19 xen: Rename xen_be_del_xendev

In reply to Emil Condrea

Prepare xen_be_del_xendev to be shared with frontends:
* xen_be_del_xendev -> xen_pv_del_xendev

---
 hw/xen/xen_backend.c       | 2 +-
 hw/xen/xen_pvdev.c         | 2 +-
 include/hw/xen/xen_pvdev.h | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
hw/xen/xen_backend.c +1 -1
index 51afb1c..9efe4b9 100644
@@ -484,7 +484,7 @@ void xenstore_update_be(char *watch, char *type, int dom,
     if (xendev != NULL) {
         bepath = xs_read(xenstore, 0, xendev->be, &len);
         if (bepath == NULL) {
-            xen_be_del_xendev(dom, dev);
+            xen_pv_del_xendev(dom, dev);
         } else {
             free(bepath);
             xen_be_backend_changed(xendev, path);
hw/xen/xen_pvdev.c +1 -1
index 24266fa..394ddc1 100644
@@ -233,7 +233,7 @@ struct XenDevice *xen_pv_find_xendev(const char *type, int dom, int dev)
 /*
  * release xen backend device.
  */
-struct XenDevice *xen_be_del_xendev(int dom, int dev)
+struct XenDevice *xen_pv_del_xendev(int dom, int dev)
 {
     struct XenDevice *xendev, *xnext;
 
include/hw/xen/xen_pvdev.h +1 -1
index f26d82a..c19e1df 100644
@@ -68,7 +68,7 @@ const char *xenbus_strstate(enum xenbus_state state);
 
 void xen_pv_evtchn_event(void *opaque);
 void xen_pv_insert_xendev(struct XenDevice *xendev);
-struct XenDevice *xen_be_del_xendev(int dom, int dev);
+struct XenDevice *xen_pv_del_xendev(int dom, int dev);
 struct XenDevice *xen_pv_find_xendev(const char *type, int dom, int dev);
 
 void xen_pv_unbind_evtchn(struct XenDevice *xendev);
Signature · 7 lines
1.9.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#27 lore raw

PATCH v9 12/19 xen: Rename xen_be_frontend_changed

In reply to Emil Condrea

xen_be_frontend_changed -> xen_fe_frontend_changed

---
 hw/xen/xen_backend.c          | 2 +-
 hw/xen/xen_frontend.c         | 4 ++--
 include/hw/xen/xen_frontend.h | 2 +-
 3 files changed, 4 insertions(+), 4 deletions(-)
hw/xen/xen_backend.c +1 -1
index 9efe4b9..d0e3f50 100644
@@ -262,7 +262,7 @@ static int xen_be_try_setup(struct XenDevice *xendev)
     xen_be_set_state(xendev, XenbusStateInitialising);
 
     xen_be_backend_changed(xendev, NULL);
-    xen_be_frontend_changed(xendev, NULL);
+    xen_fe_frontend_changed(xendev, NULL);
     return 0;
 }
 
hw/xen/xen_frontend.c +2 -2
index 474c74a..6b92cf1 100644
@@ -38,7 +38,7 @@ int xenstore_read_fe_uint64(struct XenDevice *xendev, const char *node, uint64_t
     return xenstore_read_uint64(xendev->fe, node, uval);
 }
 
-void xen_be_frontend_changed(struct XenDevice *xendev, const char *node)
+void xen_fe_frontend_changed(struct XenDevice *xendev, const char *node)
 {
     int fe_state;
 
@@ -83,6 +83,6 @@ void xenstore_update_fe(char *watch, struct XenDevice *xendev)
     }
     node = watch + len + 1;
 
-    xen_be_frontend_changed(xendev, node);
+    xen_fe_frontend_changed(xendev, node);
     xen_be_check_state(xendev);
 }
include/hw/xen/xen_frontend.h +1 -1
index ae587e1..5d03f4e 100644
@@ -8,6 +8,6 @@ int xenstore_read_fe_int(struct XenDevice *xendev, const char *node, int *ival);
 int xenstore_read_fe_uint64(struct XenDevice *xendev, const char *node, uint64_t *uval);
 void xenstore_update_fe(char *watch, struct XenDevice *xendev);
 
-void xen_be_frontend_changed(struct XenDevice *xendev, const char *node);
+void xen_fe_frontend_changed(struct XenDevice *xendev, const char *node);
 
 #endif /* QEMU_HW_XEN_FRONTEND_H */
Signature · 7 lines
1.9.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#28 lore raw

PATCH v9 13/19 xen: Distinguish between frontend and backend devops

In reply to Emil Condrea

xen_be_check_state should not be called for frontends Use DEVOPS_FLAG_FE flag to distinguish a frontend.

---
Changes in v9:
* Removed not needed strstr from xenstore_update_be
It was left over from first patch series when domu was included in xenstore
schema: "%s/backend/%s/%d/%d"

---
 hw/xen/xen_backend.c       | 4 +++-
 include/hw/xen/xen_pvdev.h | 2 ++
 2 files changed, 5 insertions(+), 1 deletion(-)
hw/xen/xen_backend.c +3 -1
index d0e3f50..3931128 100644
@@ -488,7 +488,9 @@ void xenstore_update_be(char *watch, char *type, int dom,
         } else {
             free(bepath);
             xen_be_backend_changed(xendev, path);
-            xen_be_check_state(xendev);
+            if (!(ops->flags & DEVOPS_FLAG_FE)) {
+                xen_be_check_state(xendev);
+            }
         }
     }
 }
include/hw/xen/xen_pvdev.h +2 -0
index c19e1df..c985a9d 100644
@@ -14,6 +14,8 @@ struct XenDevice;
 #define DEVOPS_FLAG_NEED_GNTDEV   1
 /* don't expect frontend doing correct state transitions (aka console quirk) */
 #define DEVOPS_FLAG_IGNORE_STATE  2
+/*dev is frontend device*/
+#define DEVOPS_FLAG_FE            4
 
 struct XenDevOps {
     size_t    size;
Signature · 7 lines
1.9.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#29 lore raw

PATCH v9 14/19 Qemu-Xen-vTPM: Support for Xen stubdom vTPM command line options

In reply to Emil Condrea

---
Changes in v9:
* Replace type with struct as required by 895a2a80e
* Change qpm_query_tpm_inst as required by ce21131a0

---
 configure        | 14 ++++++++++++++
 hmp.c            |  2 ++
 qapi-schema.json | 16 ++++++++++++++--
 qemu-options.hx  | 13 +++++++++++--
 tpm.c            |  7 ++++++-
 5 files changed, 47 insertions(+), 5 deletions(-)
configure +14 -0
index e9090a0..29e982e 100755
@@ -3242,6 +3242,16 @@ else
 fi
 
 ##########################################
+# TPM xenstubdoms is only on x86 Linux
+
+if test "$targetos" = Linux && test "$cpu" = i386 -o "$cpu" = x86_64 && \
+   test "$xen" = "yes"; then
+  tpm_xenstubdoms=$tpm
+else
+  tpm_xenstubdoms=no
+fi
+
+##########################################
 # attr probe
 
 if test "$attr" != "no" ; then
@@ -4891,6 +4901,7 @@ echo "gcov              $gcov_tool"
 echo "gcov enabled      $gcov"
 echo "TPM support       $tpm"
 echo "libssh2 support   $libssh2"
+echo "TPM xenstubdoms   $tpm_xenstubdoms"
 echo "TPM passthrough   $tpm_passthrough"
 echo "QOM debugging     $qom_cast_debug"
 echo "vhdx              $vhdx"
@@ -5431,6 +5442,9 @@ if test "$tpm" = "yes"; then
   if test "$tpm_passthrough" = "yes"; then
     echo "CONFIG_TPM_PASSTHROUGH=y" >> $config_host_mak
   fi
+  if test "$tpm_xenstubdoms" = "yes"; then
+    echo "CONFIG_TPM_XENSTUBDOMS=y" >> $config_host_mak
+  fi
 fi
 
 echo "TRACE_BACKENDS=$trace_backends" >> $config_host_mak
hmp.c +2 -0
index 0cf5baa..1ed7a28 100644
@@ -883,6 +883,8 @@ void hmp_info_tpm(Monitor *mon, const QDict *qdict)
                            tpo->has_cancel_path ? ",cancel-path=" : "",
                            tpo->has_cancel_path ? tpo->cancel_path : "");
             break;
+        case TPM_TYPE_OPTIONS_KIND_XENSTUBDOMS:
+            break;
         case TPM_TYPE_OPTIONS_KIND__MAX:
             break;
         }
qapi-schema.json +14 -2
index d2d6506..12efb23 100644
@@ -3502,9 +3502,11 @@
 #
 # @passthrough: TPM passthrough type
 #
+# @xenstubdoms: TPM xenstubdoms type (since 2.7)
+#
 # Since: 1.5
 ##
-{ 'enum': 'TpmType', 'data': [ 'passthrough' ] }
+{ 'enum': 'TpmType', 'data': [ 'passthrough', 'xenstubdoms' ] }
 
 ##
 # @query-tpm-types:
@@ -3533,6 +3535,15 @@
                                              '*cancel-path' : 'str'} }
 
 ##
+# @TPMXenstubdomsOptions:
+#
+# Information about the TPM xenstubdoms type
+#
+# Since: 2.7
+##
+{ 'struct': 'TPMXenstubdomsOptions', 'data': {  } }
+
+##
 # @TpmTypeOptions:
 #
 # A union referencing different TPM backend types' configuration options
@@ -3542,7 +3553,8 @@
 # Since: 1.5
 ##
 { 'union': 'TpmTypeOptions',
-   'data': { 'passthrough' : 'TPMPassthroughOptions' } }
+  'data': { 'passthrough' : 'TPMPassthroughOptions',
+            'xenstubdoms' : 'TPMXenstubdomsOptions' } }
 
 ##
 # @TpmInfo:
qemu-options.hx +11 -2
index 8e0d9a5..748fb62 100644
@@ -2748,7 +2748,8 @@ DEF("tpmdev", HAS_ARG, QEMU_OPTION_tpmdev, \
     "-tpmdev passthrough,id=id[,path=path][,cancel-path=path]\n"
     "                use path to provide path to a character device; default is /dev/tpm0\n"
     "                use cancel-path to provide path to TPM's cancel sysfs entry; if\n"
-    "                not provided it will be searched for in /sys/class/misc/tpm?/device\n",
+    "                not provided it will be searched for in /sys/class/misc/tpm?/device\n"
+    "-tpmdev xenstubdoms,id=id\n",
     QEMU_ARCH_ALL)
 STEXI
 
@@ -2758,7 +2759,8 @@ The general form of a TPM device option is:
 @item -tpmdev @var{backend} ,id=@var{id} [,@var{options}]
 @findex -tpmdev
 Backend type must be:
-@option{passthrough}.
+@option{passthrough}, or
+@option{xenstubdoms}.
 
 The specific backend type will determine the applicable options.
 The @code{-tpmdev} option creates the TPM backend and requires a
@@ -2808,6 +2810,13 @@ To create a passthrough TPM use the following two options:
 Note that the @code{-tpmdev} id is @code{tpm0} and is referenced by
 @code{tpmdev=tpm0} in the device option.
 
+To create a xenstubdoms TPM use the following two options:
+@example
+-tpmdev xenstubdoms,id=tpm0 -device tpm-tis,tpmdev=tpm0
+@end example
+Note that the @code{-tpmdev} id is @code{tpm0} and is referenced by
+@code{tpmdev=tpm0} in the device option.
+
 @end table
 
 ETEXI
tpm.c +6 -1
index 9a7c711..df1b9b0 100644
@@ -25,7 +25,7 @@ static QLIST_HEAD(, TPMBackend) tpm_backends =
 
 
 #define TPM_MAX_MODELS      1
-#define TPM_MAX_DRIVERS     1
+#define TPM_MAX_DRIVERS     2
 
 static TPMDriverOps const *be_drivers[TPM_MAX_DRIVERS] = {
     NULL,
@@ -253,6 +253,7 @@ static TPMInfo *qmp_query_tpm_inst(TPMBackend *drv)
 {
     TPMInfo *res = g_new0(TPMInfo, 1);
     TPMPassthroughOptions *tpo;
+    TPMXenstubdomsOptions *txo;
 
     res->id = g_strdup(drv->id);
     res->model = drv->fe_model;
@@ -272,6 +273,10 @@ static TPMInfo *qmp_query_tpm_inst(TPMBackend *drv)
             tpo->has_cancel_path = true;
         }
         break;
+    case TPM_TYPE_XENSTUBDOMS:
+        res->options->type = TPM_TYPE_OPTIONS_KIND_XENSTUBDOMS;
+        txo = g_new0(TPMXenstubdomsOptions, 1);
+        res->options->u.xenstubdoms.data = txo;
     case TPM_TYPE__MAX:
         break;
     }
Signature · 7 lines
1.9.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#30 lore raw

PATCH v9 15/19 Qemu-Xen-vTPM: Xen frontend driver infrastructure

In reply to Emil Condrea

This patch adds infrastructure for xen front drivers living in qemu, so drivers don't need to implement common stuff on their own. It's mostly xenbus management stuff: some functions to access XenStore, setting up XenStore watches, callbacks on device discovery and state changes, and handle event channel between the virtual machines.

Call xen_fe_register() function to register XenDevOps, and make sure, XenDevOps's flags is DEVOPS_FLAG_FE, which is flag bit to point out the XenDevOps is Xen frontend.

---
Changes in v9:
* xenstore_dev should not be global, it will not work correctly with
multiple xen frontends living in qemu
* reuse some common functions:
- xen_fe_printf -> xen_pv_printf
- xen_fe_evtchn_event -> xen_pv_evtchn_event
* use libxenevtchn stable API instead of xc_* calls:
- xc_evtchn_fd -> xenevtchn_fd
- xc_evtchn_close -> xenevtchn_close
- xc_evtchn_bind_unbound_port -> xenevtchn_bind_unbound_port

---
 hw/xen/xen_frontend.c         | 308 ++++++++++++++++++++++++++++++++++++++++++
 hw/xen/xen_pvdev.c            |  15 ++
 include/hw/xen/xen_frontend.h |   6 +
 include/hw/xen/xen_pvdev.h    |   1 +
 4 files changed, 330 insertions(+)
hw/xen/xen_frontend.c +308 -0
index 6b92cf1..7b305ce 100644
@@ -3,6 +3,10 @@
  *
  *  (c) 2008 Gerd Hoffmann <[email protected]>
  *
+ *  Copyright (c) 2015 Intel Corporation
+ *  Authors:
+ *    Quan Xu <[email protected]>
+ *
  * This library 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; either
@@ -23,6 +27,8 @@
 #include "hw/xen/xen_frontend.h"
 #include "hw/xen/xen_backend.h"
 
+static int debug = 0;
+
 char *xenstore_read_fe_str(struct XenDevice *xendev, const char *node)
 {
     return xenstore_read_str(xendev->fe, node);
@@ -86,3 +92,305 @@ void xenstore_update_fe(char *watch, struct XenDevice *xendev)
     xen_fe_frontend_changed(xendev, node);
     xen_be_check_state(xendev);
 }
+
+struct XenDevice *xen_fe_get_xendev(const char *type, int dom, int dev,
+                                    char *backend, struct XenDevOps *ops)
+{
+    struct XenDevice *xendev;
+
+    xendev = xen_pv_find_xendev(type, dom, dev);
+    if (xendev) {
+        return xendev;
+    }
+
+    /* init new xendev */
+    xendev = g_malloc0(ops->size);
+    xendev->type  = type;
+    xendev->dom   = dom;
+    xendev->dev   = dev;
+    xendev->ops   = ops;
+
+    /*return if the ops->flags is not DEVOPS_FLAG_FE*/
+    if (!(ops->flags & DEVOPS_FLAG_FE)) {
+        return NULL;
+    }
+
+    snprintf(xendev->be, sizeof(xendev->be), "%s", backend);
+    snprintf(xendev->name, sizeof(xendev->name), "%s-%d",
+             xendev->type, xendev->dev);
+
+    xendev->debug = debug;
+    xendev->local_port = -1;
+
+    xendev->evtchndev = xenevtchn_open(NULL, 0);
+    if (xendev->evtchndev == NULL) {
+        xen_pv_printf(NULL, 0, "can't open evtchn device\n");
+        g_free(xendev);
+        return NULL;
+    }
+    fcntl(xenevtchn_fd(xendev->evtchndev), F_SETFD, FD_CLOEXEC);
+
+    if (ops->flags & DEVOPS_FLAG_NEED_GNTDEV) {
+        xendev->gnttabdev = xengnttab_open(NULL, 0);
+        if (xendev->gnttabdev == NULL) {
+            xen_pv_printf(NULL, 0, "can't open gnttab device\n");
+            xenevtchn_close(xendev->evtchndev);
+            g_free(xendev);
+            return NULL;
+        }
+    } else {
+        xendev->gnttabdev = NULL;
+    }
+
+    xen_pv_insert_xendev(xendev);
+
+    if (xendev->ops->alloc) {
+        xendev->ops->alloc(xendev);
+    }
+
+    return xendev;
+}
+
+int xen_fe_alloc_unbound(struct XenDevice *xendev, int dom, int remote_dom){
+    xendev->local_port = xenevtchn_bind_unbound_port(xendev->evtchndev,
+                                                     remote_dom);
+    if (xendev->local_port == -1) {
+        xen_pv_printf(xendev, 0, "xenevtchn_bind_unbound_port failed\n");
+        return -1;
+    }
+    xen_pv_printf(xendev, 2, "bind evtchn port %d\n", xendev->local_port);
+    qemu_set_fd_handler(xenevtchn_fd(xendev->evtchndev),
+                        xen_pv_evtchn_event, NULL, xendev);
+    return 0;
+}
+
+/*
+ * Make sure, initialize the 'xendev->fe' in xendev->ops->init() or
+ * xendev->ops->initialize()
+ */
+int xenbus_switch_state(struct XenDevice *xendev, enum xenbus_state xbus)
+{
+    xs_transaction_t xbt = XBT_NULL;
+
+    if (xendev->fe_state == xbus) {
+        return 0;
+    }
+
+    xendev->fe_state = xbus;
+    if (xendev->fe == NULL) {
+        xen_pv_printf(NULL, 0, "xendev->fe is NULL\n");
+        return -1;
+    }
+
+retry_transaction:
+    xbt = xs_transaction_start(xenstore);
+    if (xbt == XBT_NULL) {
+        goto abort_transaction;
+    }
+
+    if (xenstore_write_int(xendev->fe, "state", xbus)) {
+        goto abort_transaction;
+    }
+
+    if (!xs_transaction_end(xenstore, xbt, 0)) {
+        if (errno == EAGAIN) {
+            goto retry_transaction;
+        }
+    }
+
+    return 0;
+
+abort_transaction:
+    xs_transaction_end(xenstore, xbt, 1);
+    return -1;
+}
+
+/*
+ * Simplify QEMU side, a thread is running in Xen backend, which will
+ * connect frontend when the frontend is initialised. Call these initialised
+ * functions.
+ */
+static int xen_fe_try_init(void *opaque)
+{
+    struct XenDevOps *ops = opaque;
+    int rc = -1;
+
+    if (ops->init) {
+        rc = ops->init(NULL);
+    }
+
+    return rc;
+}
+
+static int xen_fe_try_initialise(struct XenDevice *xendev)
+{
+    int rc = 0, fe_state;
+
+    if (xenstore_read_fe_int(xendev, "state", &fe_state) == -1) {
+        fe_state = XenbusStateUnknown;
+    }
+    xendev->fe_state = fe_state;
+
+    if (xendev->ops->initialise) {
+        rc = xendev->ops->initialise(xendev);
+    }
+    if (rc != 0) {
+        xen_pv_printf(xendev, 0, "initialise() failed\n");
+        return rc;
+    }
+
+    xenbus_switch_state(xendev, XenbusStateInitialised);
+    return 0;
+}
+
+static void xen_fe_try_connected(struct XenDevice *xendev)
+{
+    if (!xendev->ops->connected) {
+        return;
+    }
+
+    if (xendev->fe_state != XenbusStateConnected) {
+        if (xendev->ops->flags & DEVOPS_FLAG_IGNORE_STATE) {
+            xen_pv_printf(xendev, 2, "frontend not ready, ignoring\n");
+        } else {
+            xen_pv_printf(xendev, 2, "frontend not ready (yet)\n");
+            return;
+        }
+    }
+
+    xendev->ops->connected(xendev);
+}
+
+static int xen_fe_check(struct XenDevice *xendev, uint32_t domid,
+                        int handle)
+{
+    int rc = 0;
+
+    rc = xen_fe_try_initialise(xendev);
+    if (rc != 0) {
+        xen_pv_printf(xendev, 0, "xendev %s initialise error\n",
+                      xendev->name);
+        goto err;
+    }
+    xen_fe_try_connected(xendev);
+
+    return rc;
+
+err:
+    xen_pv_del_xendev(domid, handle);
+    return -1;
+}
+
+static char *xenstore_fe_get_backend(const char *type, int be_domid,
+                                     uint32_t domid, int *hdl)
+{
+    char *name, *str, *ret = NULL;
+    uint32_t i, cdev;
+    int handle = 0;
+    char path[XEN_BUFSIZE];
+    char **dev = NULL;
+
+    name = xenstore_get_domain_name(domid);
+    snprintf(path, sizeof(path), "frontend/%s/%d", type, be_domid);
+    dev = xs_directory(xenstore, 0, path, &cdev);
+    for (i = 0; i < cdev; i++) {
+        handle = i;
+        snprintf(path, sizeof(path), "frontend/%s/%d/%d",
+        type, be_domid, handle);
+        str = xenstore_read_str(path, "domain");
+        if (!strcmp(name, str)) {
+            break;
+        }
+
+        free(str);
+
+        /* Not the backend domain */
+        if (handle == (cdev - 1)) {
+            goto err;
+        }
+    }
+
+    snprintf(path, sizeof(path), "frontend/%s/%d/%d",
+    type, be_domid, handle);
+    str = xenstore_read_str(path, "backend");
+    if (str != NULL) {
+        ret = g_strdup(str);
+        free(str);
+    }
+
+    *hdl = handle;
+    free(dev);
+
+    return ret;
+err:
+    *hdl = -1;
+    free(dev);
+    return NULL;
+}
+
+static int xenstore_fe_scan(const char *type, uint32_t domid,
+                            struct XenDevOps *ops)
+{
+    struct XenDevice *xendev;
+    char path[XEN_BUFSIZE], token[XEN_BUFSIZE];
+    unsigned int cdev, j;
+    char *backend;
+    char **dev = NULL;
+    int rc;
+    int xenstore_dev;
+
+    /* ops .init check, xendev is NOT initialized */
+    rc = xen_fe_try_init(ops);
+    if (rc != 0) {
+        return -1;
+    }
+
+    /* Get /local/domain/0/${type}/{} directory */
+    snprintf(path, sizeof(path), "frontend/%s", type);
+    dev = xs_directory(xenstore, 0, path, &cdev);
+    if (dev == NULL) {
+        return 0;
+    }
+
+    for (j = 0; j < cdev; j++) {
+
+        /* Get backend via domain name */
+        backend = xenstore_fe_get_backend(type, atoi(dev[j]),
+                                          domid, &xenstore_dev);
+        if (backend == NULL) {
+            continue;
+        }
+
+        xendev = xen_fe_get_xendev(type, domid, xenstore_dev, backend, ops);
+        free(backend);
+        if (xendev == NULL) {
+            xen_pv_printf(xendev, 0, "xendev is NULL.\n");
+            continue;
+        }
+
+        /*
+         * Simplify QEMU side, a thread is running in Xen backend, which will
+         * connect frontend when the frontend is initialised.
+         */
+        if (xen_fe_check(xendev, domid, xenstore_dev) < 0) {
+            xen_pv_printf(xendev, 0, "xendev fe_check error.\n");
+            continue;
+        }
+
+        /* Setup watch */
+        snprintf(token, sizeof(token), "be:%p:%d:%p",
+                 type, domid, xendev->ops);
+        if (!xs_watch(xenstore, xendev->be, token)) {
+            xen_pv_printf(xendev, 0, "xs_watch failed.\n");
+            continue;
+        }
+    }
+
+    free(dev);
+    return 0;
+}
+
+int xen_fe_register(const char *type, struct XenDevOps *ops)
+{
+    return xenstore_fe_scan(type, xen_domid, ops);
+}
hw/xen/xen_pvdev.c +15 -0
index 394ddc1..cb51e87 100644
@@ -121,6 +121,21 @@ cleanup:
     free(vec);
 }
 
+char *xenstore_get_domain_name(uint32_t domid)
+{
+    char *dom_path, *str, *ret = NULL;
+
+    dom_path = xs_get_domain_path(xenstore, domid);
+    str = xenstore_read_str(dom_path, "name");
+    free(dom_path);
+    if (str != NULL) {
+        ret = g_strdup(str);
+        free(str);
+    }
+
+    return ret;
+}
+
 const char *xenbus_strstate(enum xenbus_state state)
 {
     static const char *const name[] = {
include/hw/xen/xen_frontend.h +6 -0
index 5d03f4e..8fc0422 100644
@@ -8,6 +8,12 @@ int xenstore_read_fe_int(struct XenDevice *xendev, const char *node, int *ival);
 int xenstore_read_fe_uint64(struct XenDevice *xendev, const char *node, uint64_t *uval);
 void xenstore_update_fe(char *watch, struct XenDevice *xendev);
 
+struct XenDevice *xen_fe_get_xendev(const char *type, int dom, int dev,
+                                    char *backend, struct XenDevOps *ops);
 void xen_fe_frontend_changed(struct XenDevice *xendev, const char *node);
+int xen_fe_register(const char *type, struct XenDevOps *ops);
+int xen_fe_alloc_unbound(struct XenDevice *xendev, int dom, int remote_dom);
+int xenbus_switch_state(struct XenDevice *xendev, enum xenbus_state xbus);
+
 
 #endif /* QEMU_HW_XEN_FRONTEND_H */
include/hw/xen/xen_pvdev.h +1 -0
index c985a9d..11bab56 100644
@@ -65,6 +65,7 @@ char *xenstore_read_str(const char *base, const char *node);
 int xenstore_read_int(const char *base, const char *node, int *ival);
 int xenstore_read_uint64(const char *base, const char *node, uint64_t *uval);
 void xenstore_update(void *unused);
+char *xenstore_get_domain_name(uint32_t domid);
 
 const char *xenbus_strstate(enum xenbus_state state);
 
Signature · 7 lines
1.9.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#31 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH 15/19] Qemu-Xen-vTPM: Xen frontend driver infrastructure

Quoted 56 lines · Emil Condrea

This patch adds infrastructure for xen front drivers living in qemu, so drivers don't need to implement common stuff on their own. It's mostly xenbus management stuff: some functions to access XenStore, setting up XenStore watches, callbacks on device discovery and state changes, and handle event channel between the virtual machines.

Call xen_fe_register() function to register XenDevOps, and make sure, XenDevOps's flags is DEVOPS_FLAG_FE, which is flag bit to point out the XenDevOps is Xen frontend.

---
Changes in v9:
* xenstore_dev should not be global, it will not work correctly with
multiple xen frontends living in qemu
* reuse some common functions:
- xen_fe_printf -> xen_pv_printf
- xen_fe_evtchn_event -> xen_pv_evtchn_event
* use libxenevtchn stable API instead of xc_* calls:
- xc_evtchn_fd -> xenevtchn_fd
- xc_evtchn_close -> xenevtchn_close
- xc_evtchn_bind_unbound_port -> xenevtchn_bind_unbound_port

---
 hw/xen/xen_frontend.c         | 308 ++++++++++++++++++++++++++++++++++++++++++
 hw/xen/xen_pvdev.c            |  15 ++
 include/hw/xen/xen_frontend.h |   6 +
 include/hw/xen/xen_pvdev.h    |   1 +
 4 files changed, 330 insertions(+)
hw/xen/xen_frontend.c +6 -0
index 6b92cf1..7b305ce 100644
@@ -3,6 +3,10 @@
  *
  *  (c) 2008 Gerd Hoffmann <[email protected]>
  *
+ *  Copyright (c) 2015 Intel Corporation
+ *  Authors:
+ *    Quan Xu <[email protected]>
+ *
  * This library 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; either
@@ -23,6 +27,8 @@
 #include "hw/xen/xen_frontend.h"
 #include "hw/xen/xen_backend.h"
 
+static int debug = 0;
+
 char *xenstore_read_fe_str(struct XenDevice *xendev, const char *node)
 {
     return xenstore_read_str(xendev->fe, node);

hw/xen/xen_frontend.c void xenstore_update_fe(char *watch, struct XenDevice *xendev) · line 97

Quoted 6 lines
hw/xen/xen_frontend.c +3 -0
@@ -86,3 +92,305 @@ void xenstore_update_fe(char *watch, struct XenDevice *xendev)
     xen_fe_frontend_changed(xendev, node);
     xen_be_check_state(xendev);
 }
+
+struct XenDevice *xen_fe_get_xendev(const char *type, int dom, int dev,
+                                    char *backend, struct XenDevOps *ops)

This function looks similare to xen_be_get_xendev(), could they be shared?

In any case, there is a few issue with this implementation.

Quoted 7 lines
hw/xen/xen_frontend.c +7 -0
+{
+    struct XenDevice *xendev;
+
+    xendev = xen_pv_find_xendev(type, dom, dev);
+    if (xendev) {
+        return xendev;
+    }

hw/xen/xen_frontend.c void xenstore_update_fe(char *watch, struct XenDevice *xendev) · line 114

Quoted 10 lines
hw/xen/xen_frontend.c +10 -0
+
+    /* init new xendev */
+    xendev = g_malloc0(ops->size);
+    xendev->type  = type;
+    xendev->dom   = dom;
+    xendev->dev   = dev;
+    xendev->ops   = ops;
+
+    /*return if the ops->flags is not DEVOPS_FLAG_FE*/
+    if (!(ops->flags & DEVOPS_FLAG_FE)) {

Here, xendev is leaked.

Quoted 4 lines
hw/xen/xen_frontend.c +4 -0
+        return NULL;
+    }
+
+    snprintf(xendev->be, sizeof(xendev->be), "%s", backend);

hw/xen/xen_frontend.c void xenstore_update_fe(char *watch, struct XenDevice *xendev) · line 128

Quoted 10 lines
hw/xen/xen_frontend.c +10 -0
+    snprintf(xendev->name, sizeof(xendev->name), "%s-%d",
+             xendev->type, xendev->dev);
+
+    xendev->debug = debug;
+    xendev->local_port = -1;
+
+    xendev->evtchndev = xenevtchn_open(NULL, 0);
+    if (xendev->evtchndev == NULL) {
+        xen_pv_printf(NULL, 0, "can't open evtchn device\n");
+        g_free(xendev);

We could use goto here, so there would be only one cleanup path.

hw/xen/xen_frontend.c void xenstore_update_fe(char *watch, struct XenDevice *xendev) · line 138

Quoted 10 lines
hw/xen/xen_frontend.c +10 -0
+        return NULL;
+    }
+    fcntl(xenevtchn_fd(xendev->evtchndev), F_SETFD, FD_CLOEXEC);
+
+    if (ops->flags & DEVOPS_FLAG_NEED_GNTDEV) {
+        xendev->gnttabdev = xengnttab_open(NULL, 0);
+        if (xendev->gnttabdev == NULL) {
+            xen_pv_printf(NULL, 0, "can't open gnttab device\n");
+            xenevtchn_close(xendev->evtchndev);
+            g_free(xendev);

goto, same as before.

Quoted 6 lines
hw/xen/xen_frontend.c +6 -0
+            return NULL;
+        }
+    } else {
+        xendev->gnttabdev = NULL;
+    }
+

hw/xen/xen_frontend.c void xenstore_update_fe(char *watch, struct XenDevice *xendev) · line 154

Quoted 10 lines
hw/xen/xen_frontend.c +10 -0
+    xen_pv_insert_xendev(xendev);
+
+    if (xendev->ops->alloc) {
+        xendev->ops->alloc(xendev);
+    }
+
+    return xendev;
+}
+
+int xen_fe_alloc_unbound(struct XenDevice *xendev, int dom, int remote_dom){

'{' should be on a new line.

Quoted 7 lines
hw/xen/xen_frontend.c +7 -0
+    xendev->local_port = xenevtchn_bind_unbound_port(xendev->evtchndev,
+                                                     remote_dom);
+    if (xendev->local_port == -1) {
+        xen_pv_printf(xendev, 0, "xenevtchn_bind_unbound_port failed\n");
+        return -1;
+    }
+    xen_pv_printf(xendev, 2, "bind evtchn port %d\n", xendev->local_port);

hw/xen/xen_frontend.c void xenstore_update_fe(char *watch, struct XenDevice *xendev) · line 171

Quoted 10 lines
hw/xen/xen_frontend.c +10 -0
+    qemu_set_fd_handler(xenevtchn_fd(xendev->evtchndev),
+                        xen_pv_evtchn_event, NULL, xendev);
+    return 0;
+}
+
+/*
+ * Make sure, initialize the 'xendev->fe' in xendev->ops->init() or
+ * xendev->ops->initialize()
+ */
+int xenbus_switch_state(struct XenDevice *xendev, enum xenbus_state xbus)

There is a function that do a similar job for backends, xen_be_set_state(). I think we could rename this function xen_fe_set_state. Also "xbus" is a confusing name, "state" would be fine.

Quoted 8 lines
hw/xen/xen_frontend.c +8 -0
+{
+    xs_transaction_t xbt = XBT_NULL;
+
+    if (xendev->fe_state == xbus) {
+        return 0;
+    }
+
+    xendev->fe_state = xbus;

hw/xen/xen_frontend.c void xenstore_update_fe(char *watch, struct XenDevice *xendev) · line 189

Quoted 10 lines
hw/xen/xen_frontend.c +10 -0
+    if (xendev->fe == NULL) {
+        xen_pv_printf(NULL, 0, "xendev->fe is NULL\n");
+        return -1;
+    }
+
+retry_transaction:
+    xbt = xs_transaction_start(xenstore);
+    if (xbt == XBT_NULL) {
+        goto abort_transaction;
+    }

There is a transaction started, but I don't think it is used by the function below. Could you remove the transaction?

Quoted 12 lines
hw/xen/xen_frontend.c +12 -0
+    if (xenstore_write_int(xendev->fe, "state", xbus)) {
+        goto abort_transaction;
+    }
+
+    if (!xs_transaction_end(xenstore, xbt, 0)) {
+        if (errno == EAGAIN) {
+            goto retry_transaction;
+        }
+    }
+
+    return 0;
+

hw/xen/xen_frontend.c void xenstore_update_fe(char *watch, struct XenDevice *xendev) · line 212

Quoted 10 lines
hw/xen/xen_frontend.c +10 -0
+abort_transaction:
+    xs_transaction_end(xenstore, xbt, 1);
+    return -1;
+}
+
+/*
+ * Simplify QEMU side, a thread is running in Xen backend, which will
+ * connect frontend when the frontend is initialised. Call these initialised
+ * functions.
+ */

This comment does not make much sense to me.

Quoted 24 lines
hw/xen/xen_frontend.c +24 -0
+static int xen_fe_try_init(void *opaque)
+{
+    struct XenDevOps *ops = opaque;
+    int rc = -1;
+
+    if (ops->init) {
+        rc = ops->init(NULL);
+    }
+
+    return rc;
+}
+
+static int xen_fe_try_initialise(struct XenDevice *xendev)
+{
+    int rc = 0, fe_state;
+
+    if (xenstore_read_fe_int(xendev, "state", &fe_state) == -1) {
+        fe_state = XenbusStateUnknown;
+    }
+    xendev->fe_state = fe_state;
+
+    if (xendev->ops->initialise) {
+        rc = xendev->ops->initialise(xendev);
+    }

hw/xen/xen_frontend.c void xenstore_update_fe(char *watch, struct XenDevice *xendev) · line 246

Quoted 10 lines
hw/xen/xen_frontend.c +10 -0
+    if (rc != 0) {
+        xen_pv_printf(xendev, 0, "initialise() failed\n");
+        return rc;
+    }
+
+    xenbus_switch_state(xendev, XenbusStateInitialised);
+    return 0;
+}
+
+static void xen_fe_try_connected(struct XenDevice *xendev)

This function looks exactly the same as xen_be_try_connected, should not it be different and check the status of the backend?

Quoted 9 lines
hw/xen/xen_frontend.c +9 -0
+{
+    if (!xendev->ops->connected) {
+        return;
+    }
+
+    if (xendev->fe_state != XenbusStateConnected) {
+        if (xendev->ops->flags & DEVOPS_FLAG_IGNORE_STATE) {
+            xen_pv_printf(xendev, 2, "frontend not ready, ignoring\n");
+        } else {

hw/xen/xen_frontend.c void xenstore_update_fe(char *watch, struct XenDevice *xendev) · line 265

Quoted 10 lines
hw/xen/xen_frontend.c +10 -0
+            xen_pv_printf(xendev, 2, "frontend not ready (yet)\n");
+            return;
+        }
+    }
+
+    xendev->ops->connected(xendev);
+}
+
+static int xen_fe_check(struct XenDevice *xendev, uint32_t domid,
+                        int handle)

What is this function checking? The name of the function is not very helpfull.

Quoted 18 lines
hw/xen/xen_frontend.c +18 -0
+{
+    int rc = 0;
+
+    rc = xen_fe_try_initialise(xendev);
+    if (rc != 0) {
+        xen_pv_printf(xendev, 0, "xendev %s initialise error\n",
+                      xendev->name);
+        goto err;
+    }
+    xen_fe_try_connected(xendev);
+
+    return rc;
+
+err:
+    xen_pv_del_xendev(domid, handle);
+    return -1;
+}
+

hw/xen/xen_frontend.c void xenstore_update_fe(char *watch, struct XenDevice *xendev) · line 293

Quoted 10 lines
hw/xen/xen_frontend.c +10 -0
+static char *xenstore_fe_get_backend(const char *type, int be_domid,
+                                     uint32_t domid, int *hdl)
+{
+    char *name, *str, *ret = NULL;
+    uint32_t i, cdev;
+    int handle = 0;
+    char path[XEN_BUFSIZE];
+    char **dev = NULL;
+
+    name = xenstore_get_domain_name(domid);

The path backend of the backend would normally be located in:
device/$type/$devid/backend

Could not you use that instead of a domain name?

Quoted 45 lines
hw/xen/xen_frontend.c +45 -0
+    snprintf(path, sizeof(path), "frontend/%s/%d", type, be_domid);
+    dev = xs_directory(xenstore, 0, path, &cdev);
+    for (i = 0; i < cdev; i++) {
+        handle = i;
+        snprintf(path, sizeof(path), "frontend/%s/%d/%d",
+        type, be_domid, handle);
+        str = xenstore_read_str(path, "domain");
+        if (!strcmp(name, str)) {
+            break;
+        }
+
+        free(str);
+
+        /* Not the backend domain */
+        if (handle == (cdev - 1)) {
+            goto err;
+        }
+    }
+
+    snprintf(path, sizeof(path), "frontend/%s/%d/%d",
+    type, be_domid, handle);
+    str = xenstore_read_str(path, "backend");
+    if (str != NULL) {
+        ret = g_strdup(str);
+        free(str);
+    }
+
+    *hdl = handle;
+    free(dev);
+
+    return ret;
+err:
+    *hdl = -1;
+    free(dev);
+    return NULL;
+}
+
+static int xenstore_fe_scan(const char *type, uint32_t domid,
+                            struct XenDevOps *ops)
+{
+    struct XenDevice *xendev;
+    char path[XEN_BUFSIZE], token[XEN_BUFSIZE];
+    unsigned int cdev, j;
+    char *backend;
+    char **dev = NULL;

hw/xen/xen_frontend.c void xenstore_update_fe(char *watch, struct XenDevice *xendev) · line 348

Quoted 10 lines
hw/xen/xen_frontend.c +10 -0
+    int rc;
+    int xenstore_dev;
+
+    /* ops .init check, xendev is NOT initialized */
+    rc = xen_fe_try_init(ops);
+    if (rc != 0) {
+        return -1;
+    }
+
+    /* Get /local/domain/0/${type}/{} directory */

This comment does not reflect what is done by the next line, also what is "{}"?

hw/xen/xen_frontend.c void xenstore_update_fe(char *watch, struct XenDevice *xendev) · line 349

Quoted 1 line
hw/xen/xen_frontend.c +1 -0
+    snprintf(path, sizeof(path), "frontend/%s", type);

I have not seen "frontend" used anywhere else, frontends are usully within "device", like "device/vbd/$DEVID/*" for a block device frontend. Can this be change?

Quoted 37 lines
hw/xen/xen_frontend.c +37 -0
+    dev = xs_directory(xenstore, 0, path, &cdev);
+    if (dev == NULL) {
+        return 0;
+    }
+
+    for (j = 0; j < cdev; j++) {
+
+        /* Get backend via domain name */
+        backend = xenstore_fe_get_backend(type, atoi(dev[j]),
+                                          domid, &xenstore_dev);
+        if (backend == NULL) {
+            continue;
+        }
+
+        xendev = xen_fe_get_xendev(type, domid, xenstore_dev, backend, ops);
+        free(backend);
+        if (xendev == NULL) {
+            xen_pv_printf(xendev, 0, "xendev is NULL.\n");
+            continue;
+        }
+
+        /*
+         * Simplify QEMU side, a thread is running in Xen backend, which will
+         * connect frontend when the frontend is initialised.
+         */
+        if (xen_fe_check(xendev, domid, xenstore_dev) < 0) {
+            xen_pv_printf(xendev, 0, "xendev fe_check error.\n");
+            continue;
+        }
+
+        /* Setup watch */
+        snprintf(token, sizeof(token), "be:%p:%d:%p",
+                 type, domid, xendev->ops);
+        if (!xs_watch(xenstore, xendev->be, token)) {
+            xen_pv_printf(xendev, 0, "xs_watch failed.\n");
+            continue;
+        }

hw/xen/xen_frontend.c void xenstore_update_fe(char *watch, struct XenDevice *xendev) · line 396

Quoted 10 lines
hw/xen/xen_frontend.c +10 -0
+    }
+
+    free(dev);
+    return 0;
+}
+
+int xen_fe_register(const char *type, struct XenDevOps *ops)
+{
+    return xenstore_fe_scan(type, xen_domid, ops);
+}

Thanks,

Signature · 6 lines
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#32 lore raw

Re: [PATCH 15/19] Qemu-Xen-vTPM: Xen frontend driver infrastructure

Quoted 68 lines · Anthony PERARD
Quoted 56 lines · Emil Condrea

This patch adds infrastructure for xen front drivers living in qemu, so drivers don't need to implement common stuff on their own. It's mostly xenbus management stuff: some functions to access XenStore, setting up XenStore watches, callbacks on device discovery and state changes, and handle event channel between the virtual machines.

Call xen_fe_register() function to register XenDevOps, and make sure, XenDevOps's flags is DEVOPS_FLAG_FE, which is flag bit to point out the XenDevOps is Xen frontend.

---
Changes in v9:
* xenstore_dev should not be global, it will not work correctly with
multiple xen frontends living in qemu
* reuse some common functions:
- xen_fe_printf -> xen_pv_printf
- xen_fe_evtchn_event -> xen_pv_evtchn_event
* use libxenevtchn stable API instead of xc_* calls:
- xc_evtchn_fd -> xenevtchn_fd
- xc_evtchn_close -> xenevtchn_close
- xc_evtchn_bind_unbound_port -> xenevtchn_bind_unbound_port

---
 hw/xen/xen_frontend.c         | 308 ++++++++++++++++++++++++++++++++++++++++++
 hw/xen/xen_pvdev.c            |  15 ++
 include/hw/xen/xen_frontend.h |   6 +
 include/hw/xen/xen_pvdev.h    |   1 +
 4 files changed, 330 insertions(+)
hw/xen/xen_frontend.c +6 -0
index 6b92cf1..7b305ce 100644
@@ -3,6 +3,10 @@
  *
  *  (c) 2008 Gerd Hoffmann <[email protected]>
  *
+ *  Copyright (c) 2015 Intel Corporation
+ *  Authors:
+ *    Quan Xu <[email protected]>
+ *
  * This library 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; either
@@ -23,6 +27,8 @@
 #include "hw/xen/xen_frontend.h"
 #include "hw/xen/xen_backend.h"
 
+static int debug = 0;
+
 char *xenstore_read_fe_str(struct XenDevice *xendev, const char *node)
 {
     return xenstore_read_str(xendev->fe, node);

hw/xen/xen_frontend.c void xenstore_update_fe(char *watch, struct XenDevice *xendev) · line 97

Quoted 6 lines
hw/xen/xen_frontend.c +3 -0
@@ -86,3 +92,305 @@ void xenstore_update_fe(char *watch, struct XenDevice *xendev)
     xen_fe_frontend_changed(xendev, node);
     xen_be_check_state(xendev);
 }
+
+struct XenDevice *xen_fe_get_xendev(const char *type, int dom, int dev,
+                                    char *backend, struct XenDevOps *ops)

This function looks similare to xen_be_get_xendev(), could they be shared?

Quoted 1 line

In any case, there is a few issue with this implementation.

There is some special initialization in each function but we can group common behavior in xen_pv_get_xendev which will be called by xen_be_get_xendev and xen_fe_get_xendev

Quoted 12 lines
Quoted 12 lines
hw/xen/xen_frontend.c +11 -0
+{
+    struct XenDevice *xendev;
+
+    xendev = xen_pv_find_xendev(type, dom, dev);
+    if (xendev) {
+        return xendev;
+    }
+
+    /* init new xendev */
+    xendev = g_malloc0(ops->size);
+    xendev->type  = type;
Quoted 8 lines

hw/xen/xen_frontend.c void xenstore_update_fe(char *watch, struct XenDevice *xendev) · line 114

Quoted 6 lines
hw/xen/xen_frontend.c +6 -0
+    xendev->dom   = dom;
+    xendev->dev   = dev;
+    xendev->ops   = ops;
+
+    /*return if the ops->flags is not DEVOPS_FLAG_FE*/
+    if (!(ops->flags & DEVOPS_FLAG_FE)) {

Here, xendev is leaked.

Will fix in v10

Quoted 18 lines
Quoted 6 lines
hw/xen/xen_frontend.c +4 -0
+        return NULL;
+    }
+
+    snprintf(xendev->be, sizeof(xendev->be), "%s", backend);

hw/xen/xen_frontend.c void xenstore_update_fe(char *watch, struct XenDevice *xendev) · line 128

Quoted 10 lines
hw/xen/xen_frontend.c +10 -0
+    snprintf(xendev->name, sizeof(xendev->name), "%s-%d",
+             xendev->type, xendev->dev);
+
+    xendev->debug = debug;
+    xendev->local_port = -1;
+
+    xendev->evtchndev = xenevtchn_open(NULL, 0);
+    if (xendev->evtchndev == NULL) {
+        xen_pv_printf(NULL, 0, "can't open evtchn device\n");
+        g_free(xendev);

We could use goto here, so there would be only one cleanup path.

Will fix in v10

Quoted 13 lines

hw/xen/xen_frontend.c void xenstore_update_fe(char *watch, struct XenDevice *xendev) · line 138

Quoted 12 lines
hw/xen/xen_frontend.c +10 -0
+        return NULL;
+    }
+    fcntl(xenevtchn_fd(xendev->evtchndev), F_SETFD, FD_CLOEXEC);
+
+    if (ops->flags & DEVOPS_FLAG_NEED_GNTDEV) {
+        xendev->gnttabdev = xengnttab_open(NULL, 0);
+        if (xendev->gnttabdev == NULL) {
+            xen_pv_printf(NULL, 0, "can't open gnttab device\n");
+            xenevtchn_close(xendev->evtchndev);
+            g_free(xendev);
Quoted 1 line

goto, same as before.

Will fix in v10

Quoted 35 lines
Quoted 8 lines
hw/xen/xen_frontend.c +6 -0
+            return NULL;
+        }
+    } else {
+        xendev->gnttabdev = NULL;
+    }
+

hw/xen/xen_frontend.c void xenstore_update_fe(char *watch, struct XenDevice *xendev) · line 154

Quoted 10 lines
hw/xen/xen_frontend.c +10 -0
+    xen_pv_insert_xendev(xendev);
+
+    if (xendev->ops->alloc) {
+        xendev->ops->alloc(xendev);
+    }
+
+    return xendev;
+}
+
+int xen_fe_alloc_unbound(struct XenDevice *xendev, int dom, int remote_dom){

'{' should be on a new line.

Quoted 14 lines
hw/xen/xen_frontend.c +14 -0
+    xendev->local_port = xenevtchn_bind_unbound_port(xendev->evtchndev,
+                                                     remote_dom);
+    if (xendev->local_port == -1) {
+        xen_pv_printf(xendev, 0, "xenevtchn_bind_unbound_port failed\n");
+        return -1;
+    }
+    xen_pv_printf(xendev, 2, "bind evtchn port %d\n", xendev->local_port);
+    qemu_set_fd_handler(xenevtchn_fd(xendev->evtchndev),
+                        xen_pv_evtchn_event, NULL, xendev);
+    return 0;
+}
+
+/*
+ * Make sure, initialize the 'xendev->fe' in xendev->ops->init() or
Quoted 8 lines

hw/xen/xen_frontend.c void xenstore_update_fe(char *watch, struct XenDevice *xendev) · line 171

Quoted 3 lines
hw/xen/xen_frontend.c +3 -0
+ * xendev->ops->initialize()
+ */
+int xenbus_switch_state(struct XenDevice *xendev, enum xenbus_state xbus)

There is a function that do a similar job for backends, xen_be_set_state(). I think we could rename this function xen_fe_set_state. Also "xbus" is a confusing name, "state" would be fine.

I will rename the function and the variable in v10

Quoted 15 lines
Quoted 15 lines
hw/xen/xen_frontend.c +13 -0
+{
+    xs_transaction_t xbt = XBT_NULL;
+
+    if (xendev->fe_state == xbus) {
+        return 0;
+    }
+
+    xendev->fe_state = xbus;
+    if (xendev->fe == NULL) {
+        xen_pv_printf(NULL, 0, "xendev->fe is NULL\n");
+        return -1;
+    }
+
Quoted 8 lines

hw/xen/xen_frontend.c void xenstore_update_fe(char *watch, struct XenDevice *xendev) · line 189

Quoted 5 lines
hw/xen/xen_frontend.c +5 -0
+retry_transaction:
+    xbt = xs_transaction_start(xenstore);
+    if (xbt == XBT_NULL) {
+        goto abort_transaction;
+    }

There is a transaction started, but I don't think it is used by the function below. Could you remove the transaction?

I will remove it. For current version I don't see a direct usage of this transaction.
Quan, did you have a specific reason for past versions for this transaction?

Quoted 57 lines
Quoted 14 lines
hw/xen/xen_frontend.c +12 -0
+    if (xenstore_write_int(xendev->fe, "state", xbus)) {
+        goto abort_transaction;
+    }
+
+    if (!xs_transaction_end(xenstore, xbt, 0)) {
+        if (errno == EAGAIN) {
+            goto retry_transaction;
+        }
+    }
+
+    return 0;
+

hw/xen/xen_frontend.c void xenstore_update_fe(char *watch, struct XenDevice *xendev) · line 212

Quoted 10 lines
hw/xen/xen_frontend.c +10 -0
+abort_transaction:
+    xs_transaction_end(xenstore, xbt, 1);
+    return -1;
+}
+
+/*
+ * Simplify QEMU side, a thread is running in Xen backend, which will
+ * connect frontend when the frontend is initialised. Call these initialised
+ * functions.
+ */

This comment does not make much sense to me.

Quoted 29 lines
hw/xen/xen_frontend.c +29 -0
+static int xen_fe_try_init(void *opaque)
+{
+    struct XenDevOps *ops = opaque;
+    int rc = -1;
+
+    if (ops->init) {
+        rc = ops->init(NULL);
+    }
+
+    return rc;
+}
+
+static int xen_fe_try_initialise(struct XenDevice *xendev)
+{
+    int rc = 0, fe_state;
+
+    if (xenstore_read_fe_int(xendev, "state", &fe_state) == -1) {
+        fe_state = XenbusStateUnknown;
+    }
+    xendev->fe_state = fe_state;
+
+    if (xendev->ops->initialise) {
+        rc = xendev->ops->initialise(xendev);
+    }
+    if (rc != 0) {
+        xen_pv_printf(xendev, 0, "initialise() failed\n");
+        return rc;
+    }
+
Quoted 8 lines

hw/xen/xen_frontend.c void xenstore_update_fe(char *watch, struct XenDevice *xendev) · line 246

Quoted 5 lines
hw/xen/xen_frontend.c +5 -0
+    xenbus_switch_state(xendev, XenbusStateInitialised);
+    return 0;
+}
+
+static void xen_fe_try_connected(struct XenDevice *xendev)

This function looks exactly the same as xen_be_try_connected, should not it be different and check the status of the backend?

You are right, I will fix this in v10.

Quoted 16 lines
Quoted 16 lines
hw/xen/xen_frontend.c +14 -0
+{
+    if (!xendev->ops->connected) {
+        return;
+    }
+
+    if (xendev->fe_state != XenbusStateConnected) {
+        if (xendev->ops->flags & DEVOPS_FLAG_IGNORE_STATE) {
+            xen_pv_printf(xendev, 2, "frontend not ready, ignoring\n");
+        } else {
+            xen_pv_printf(xendev, 2, "frontend not ready (yet)\n");
+            return;
+        }
+    }
+
Quoted 8 lines

hw/xen/xen_frontend.c void xenstore_update_fe(char *watch, struct XenDevice *xendev) · line 265

Quoted 5 lines
hw/xen/xen_frontend.c +5 -0
+    xendev->ops->connected(xendev);
+}
+
+static int xen_fe_check(struct XenDevice *xendev, uint32_t domid,
+                        int handle)

What is this function checking? The name of the function is not very helpfull.

I will rename it to xen_fe_connect

Quoted 34 lines
Quoted 20 lines
hw/xen/xen_frontend.c +18 -0
+{
+    int rc = 0;
+
+    rc = xen_fe_try_initialise(xendev);
+    if (rc != 0) {
+        xen_pv_printf(xendev, 0, "xendev %s initialise error\n",
+                      xendev->name);
+        goto err;
+    }
+    xen_fe_try_connected(xendev);
+
+    return rc;
+
+err:
+    xen_pv_del_xendev(domid, handle);
+    return -1;
+}
+

hw/xen/xen_frontend.c void xenstore_update_fe(char *watch, struct XenDevice *xendev) · line 293

Quoted 10 lines
hw/xen/xen_frontend.c +10 -0
+static char *xenstore_fe_get_backend(const char *type, int be_domid,
+                                     uint32_t domid, int *hdl)
+{
+    char *name, *str, *ret = NULL;
+    uint32_t i, cdev;
+    int handle = 0;
+    char path[XEN_BUFSIZE];
+    char **dev = NULL;
+
+    name = xenstore_get_domain_name(domid);

The path backend of the backend would normally be located in:
device/$type/$devid/backend

Quoted 1 line

Could not you use that instead of a domain name?

Multiple domains might share one vTPM.

All frontends are under domain 0. For example, for 2 guests sharing a vTPM:

/local/domain/0/frontend/vtpm = ""
/local/domain/0/frontend/vtpm/41 = "" /local/domain/0/frontend/vtpm/41/0 = "" /local/domain/0/frontend/vtpm/41/0/backend = "/local/domain/41/backend/vtpm/0/0" /local/domain/0/frontend/vtpm/41/0/backend-id = "41" /local/domain/0/frontend/vtpm/41/0/state = "3" /local/domain/0/frontend/vtpm/41/0/handle = "0" /local/domain/0/frontend/vtpm/41/0/domain = "hvm-guest" /local/domain/0/frontend/vtpm/41/0/ring-ref = "8" /local/domain/0/frontend/vtpm/41/0/event-channel = "99" /local/domain/0/frontend/vtpm/41/0/feature-protocol-v2 = "1" /local/domain/0/frontend/vtpm/41/1 = "" /local/domain/0/frontend/vtpm/41/1/backend = "/local/domain/41/backend/vtpm/0/1" /local/domain/0/frontend/vtpm/41/1/backend-id = "41" /local/domain/0/frontend/vtpm/41/1/state = "3" /local/domain/0/frontend/vtpm/41/1/handle = "1" /local/domain/0/frontend/vtpm/41/1/domain = "hvm-guest2" /local/domain/0/frontend/vtpm/41/1/ring-ref = "9" /local/domain/0/frontend/vtpm/41/1/event-channel = "104" /local/domain/0/frontend/vtpm/41/1/feature-protocol-v2 = "1"

Quoted 52 lines
Quoted 52 lines
hw/xen/xen_frontend.c +50 -0
+    snprintf(path, sizeof(path), "frontend/%s/%d", type, be_domid);
+    dev = xs_directory(xenstore, 0, path, &cdev);
+    for (i = 0; i < cdev; i++) {
+        handle = i;
+        snprintf(path, sizeof(path), "frontend/%s/%d/%d",
+        type, be_domid, handle);
+        str = xenstore_read_str(path, "domain");
+        if (!strcmp(name, str)) {
+            break;
+        }
+
+        free(str);
+
+        /* Not the backend domain */
+        if (handle == (cdev - 1)) {
+            goto err;
+        }
+    }
+
+    snprintf(path, sizeof(path), "frontend/%s/%d/%d",
+    type, be_domid, handle);
+    str = xenstore_read_str(path, "backend");
+    if (str != NULL) {
+        ret = g_strdup(str);
+        free(str);
+    }
+
+    *hdl = handle;
+    free(dev);
+
+    return ret;
+err:
+    *hdl = -1;
+    free(dev);
+    return NULL;
+}
+
+static int xenstore_fe_scan(const char *type, uint32_t domid,
+                            struct XenDevOps *ops)
+{
+    struct XenDevice *xendev;
+    char path[XEN_BUFSIZE], token[XEN_BUFSIZE];
+    unsigned int cdev, j;
+    char *backend;
+    char **dev = NULL;
+    int rc;
+    int xenstore_dev;
+
+    /* ops .init check, xendev is NOT initialized */
+    rc = xen_fe_try_init(ops);
Quoted 8 lines

hw/xen/xen_frontend.c void xenstore_update_fe(char *watch, struct XenDevice *xendev) · line 348

Quoted 5 lines
hw/xen/xen_frontend.c +5 -0
+    if (rc != 0) {
+        return -1;
+    }
+
+    /* Get /local/domain/0/${type}/{} directory */

This comment does not reflect what is done by the next line, also what is "{}"?

Will update the comment.
frontend/vtpm/ is a directory with all xen hvm vtpm frontends. Eg. frontend/vtpm/[vtpm-domain-id]

Quoted 7 lines

hw/xen/xen_frontend.c void xenstore_update_fe(char *watch, struct XenDevice *xendev) · line 349

Quoted 3 lines
hw/xen/xen_frontend.c +1 -0
+    snprintf(path, sizeof(path), "frontend/%s", type);

I have not seen "frontend" used anywhere else, frontends are usully within "device", like "device/vbd/$DEVID/*" for a block device frontend. Can this be change?

vTPM for pv architecture use /local/domain/0/device/ and it was proposed that /local/domain/0/frontend/ would be used for hvm vTPM.

The design for this protocol was discussed last year here:
http://markmail.org/message/blpbzgyfzbpskwbf

Quoted 41 lines
Quoted 41 lines
hw/xen/xen_frontend.c +39 -0
+    dev = xs_directory(xenstore, 0, path, &cdev);
+    if (dev == NULL) {
+        return 0;
+    }
+
+    for (j = 0; j < cdev; j++) {
+
+        /* Get backend via domain name */
+        backend = xenstore_fe_get_backend(type, atoi(dev[j]),
+                                          domid, &xenstore_dev);
+        if (backend == NULL) {
+            continue;
+        }
+
+        xendev = xen_fe_get_xendev(type, domid, xenstore_dev, backend, ops);
+        free(backend);
+        if (xendev == NULL) {
+            xen_pv_printf(xendev, 0, "xendev is NULL.\n");
+            continue;
+        }
+
+        /*
+         * Simplify QEMU side, a thread is running in Xen backend, which will
+         * connect frontend when the frontend is initialised.
+         */
+        if (xen_fe_check(xendev, domid, xenstore_dev) < 0) {
+            xen_pv_printf(xendev, 0, "xendev fe_check error.\n");
+            continue;
+        }
+
+        /* Setup watch */
+        snprintf(token, sizeof(token), "be:%p:%d:%p",
+                 type, domid, xendev->ops);
+        if (!xs_watch(xenstore, xendev->be, token)) {
+            xen_pv_printf(xendev, 0, "xs_watch failed.\n");
+            continue;
+        }
+    }
+
Quoted 9 lines

hw/xen/xen_frontend.c void xenstore_update_fe(char *watch, struct XenDevice *xendev) · line 396

Quoted 8 lines
hw/xen/xen_frontend.c +8 -0
+    free(dev);
+    return 0;
+}
+
+int xen_fe_register(const char *type, struct XenDevOps *ops)
+{
+    return xenstore_fe_scan(type, xen_domid, ops);
+}

Thanks for the review, Anthony.

Quoted 5 lines

Thanks,

--
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#33 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH 15/19] Qemu-Xen-vTPM: Xen frontend driver infrastructure

In reply to Anthony PERARD
Quoted 68 lines · Anthony PERARD
Quoted 56 lines · Emil Condrea

This patch adds infrastructure for xen front drivers living in qemu, so drivers don't need to implement common stuff on their own. It's mostly xenbus management stuff: some functions to access XenStore, setting up XenStore watches, callbacks on device discovery and state changes, and handle event channel between the virtual machines.

Call xen_fe_register() function to register XenDevOps, and make sure, XenDevOps's flags is DEVOPS_FLAG_FE, which is flag bit to point out the XenDevOps is Xen frontend.

---
Changes in v9:
* xenstore_dev should not be global, it will not work correctly with
multiple xen frontends living in qemu
* reuse some common functions:
- xen_fe_printf -> xen_pv_printf
- xen_fe_evtchn_event -> xen_pv_evtchn_event
* use libxenevtchn stable API instead of xc_* calls:
- xc_evtchn_fd -> xenevtchn_fd
- xc_evtchn_close -> xenevtchn_close
- xc_evtchn_bind_unbound_port -> xenevtchn_bind_unbound_port

---
 hw/xen/xen_frontend.c         | 308 ++++++++++++++++++++++++++++++++++++++++++
 hw/xen/xen_pvdev.c            |  15 ++
 include/hw/xen/xen_frontend.h |   6 +
 include/hw/xen/xen_pvdev.h    |   1 +
 4 files changed, 330 insertions(+)
hw/xen/xen_frontend.c +6 -0
index 6b92cf1..7b305ce 100644
@@ -3,6 +3,10 @@
  *
  *  (c) 2008 Gerd Hoffmann <[email protected]>
  *
+ *  Copyright (c) 2015 Intel Corporation
+ *  Authors:
+ *    Quan Xu <[email protected]>
+ *
  * This library 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; either
@@ -23,6 +27,8 @@
 #include "hw/xen/xen_frontend.h"
 #include "hw/xen/xen_backend.h"
 
+static int debug = 0;
+
 char *xenstore_read_fe_str(struct XenDevice *xendev, const char *node)
 {
     return xenstore_read_str(xendev->fe, node);

hw/xen/xen_frontend.c void xenstore_update_fe(char *watch, struct XenDevice *xendev) · line 97

Quoted 6 lines
hw/xen/xen_frontend.c +3 -0
@@ -86,3 +92,305 @@ void xenstore_update_fe(char *watch, struct XenDevice *xendev)
     xen_fe_frontend_changed(xendev, node);
     xen_be_check_state(xendev);
 }
+
+struct XenDevice *xen_fe_get_xendev(const char *type, int dom, int dev,
+                                    char *backend, struct XenDevOps *ops)

This function looks similare to xen_be_get_xendev(), could they be shared?

Quoted 1 line

In any case, there is a few issue with this implementation.

There is some special initialization in each function but we can group common behavior in xen_pv_get_xendev which will be called by xen_be_get_xendev and xen_fe_get_xendev

Quoted 12 lines
Quoted 12 lines
hw/xen/xen_frontend.c +11 -0
+{
+    struct XenDevice *xendev;
+
+    xendev = xen_pv_find_xendev(type, dom, dev);
+    if (xendev) {
+        return xendev;
+    }
+
+    /* init new xendev */
+    xendev = g_malloc0(ops->size);
+    xendev->type  = type;
Quoted 8 lines

hw/xen/xen_frontend.c void xenstore_update_fe(char *watch, struct XenDevice *xendev) · line 114

Quoted 6 lines
hw/xen/xen_frontend.c +6 -0
+    xendev->dom   = dom;
+    xendev->dev   = dev;
+    xendev->ops   = ops;
+
+    /*return if the ops->flags is not DEVOPS_FLAG_FE*/
+    if (!(ops->flags & DEVOPS_FLAG_FE)) {

Here, xendev is leaked.

Will fix in v10

Quoted 18 lines
Quoted 6 lines
hw/xen/xen_frontend.c +4 -0
+        return NULL;
+    }
+
+    snprintf(xendev->be, sizeof(xendev->be), "%s", backend);

hw/xen/xen_frontend.c void xenstore_update_fe(char *watch, struct XenDevice *xendev) · line 128

Quoted 10 lines
hw/xen/xen_frontend.c +10 -0
+    snprintf(xendev->name, sizeof(xendev->name), "%s-%d",
+             xendev->type, xendev->dev);
+
+    xendev->debug = debug;
+    xendev->local_port = -1;
+
+    xendev->evtchndev = xenevtchn_open(NULL, 0);
+    if (xendev->evtchndev == NULL) {
+        xen_pv_printf(NULL, 0, "can't open evtchn device\n");
+        g_free(xendev);

We could use goto here, so there would be only one cleanup path.

Will fix in v10

Quoted 13 lines

hw/xen/xen_frontend.c void xenstore_update_fe(char *watch, struct XenDevice *xendev) · line 138

Quoted 12 lines
hw/xen/xen_frontend.c +10 -0
+        return NULL;
+    }
+    fcntl(xenevtchn_fd(xendev->evtchndev), F_SETFD, FD_CLOEXEC);
+
+    if (ops->flags & DEVOPS_FLAG_NEED_GNTDEV) {
+        xendev->gnttabdev = xengnttab_open(NULL, 0);
+        if (xendev->gnttabdev == NULL) {
+            xen_pv_printf(NULL, 0, "can't open gnttab device\n");
+            xenevtchn_close(xendev->evtchndev);
+            g_free(xendev);
Quoted 1 line

goto, same as before.

Will fix in v10

Quoted 35 lines
Quoted 8 lines
hw/xen/xen_frontend.c +6 -0
+            return NULL;
+        }
+    } else {
+        xendev->gnttabdev = NULL;
+    }
+

hw/xen/xen_frontend.c void xenstore_update_fe(char *watch, struct XenDevice *xendev) · line 154

Quoted 10 lines
hw/xen/xen_frontend.c +10 -0
+    xen_pv_insert_xendev(xendev);
+
+    if (xendev->ops->alloc) {
+        xendev->ops->alloc(xendev);
+    }
+
+    return xendev;
+}
+
+int xen_fe_alloc_unbound(struct XenDevice *xendev, int dom, int remote_dom){

'{' should be on a new line.

Quoted 14 lines
hw/xen/xen_frontend.c +14 -0
+    xendev->local_port = xenevtchn_bind_unbound_port(xendev->evtchndev,
+                                                     remote_dom);
+    if (xendev->local_port == -1) {
+        xen_pv_printf(xendev, 0, "xenevtchn_bind_unbound_port failed\n");
+        return -1;
+    }
+    xen_pv_printf(xendev, 2, "bind evtchn port %d\n", xendev->local_port);
+    qemu_set_fd_handler(xenevtchn_fd(xendev->evtchndev),
+                        xen_pv_evtchn_event, NULL, xendev);
+    return 0;
+}
+
+/*
+ * Make sure, initialize the 'xendev->fe' in xendev->ops->init() or
Quoted 8 lines

hw/xen/xen_frontend.c void xenstore_update_fe(char *watch, struct XenDevice *xendev) · line 171

Quoted 3 lines
hw/xen/xen_frontend.c +3 -0
+ * xendev->ops->initialize()
+ */
+int xenbus_switch_state(struct XenDevice *xendev, enum xenbus_state xbus)

There is a function that do a similar job for backends, xen_be_set_state(). I think we could rename this function xen_fe_set_state. Also "xbus" is a confusing name, "state" would be fine.

I will rename the function and the variable in v10

Quoted 15 lines
Quoted 15 lines
hw/xen/xen_frontend.c +13 -0
+{
+    xs_transaction_t xbt = XBT_NULL;
+
+    if (xendev->fe_state == xbus) {
+        return 0;
+    }
+
+    xendev->fe_state = xbus;
+    if (xendev->fe == NULL) {
+        xen_pv_printf(NULL, 0, "xendev->fe is NULL\n");
+        return -1;
+    }
+
Quoted 8 lines

hw/xen/xen_frontend.c void xenstore_update_fe(char *watch, struct XenDevice *xendev) · line 189

Quoted 5 lines
hw/xen/xen_frontend.c +5 -0
+retry_transaction:
+    xbt = xs_transaction_start(xenstore);
+    if (xbt == XBT_NULL) {
+        goto abort_transaction;
+    }

There is a transaction started, but I don't think it is used by the function below. Could you remove the transaction?

I will remove it. For current version I don't see a direct usage of this transaction.
Quan, did you have a specific reason for past versions for this transaction?

Quoted 57 lines
Quoted 14 lines
hw/xen/xen_frontend.c +12 -0
+    if (xenstore_write_int(xendev->fe, "state", xbus)) {
+        goto abort_transaction;
+    }
+
+    if (!xs_transaction_end(xenstore, xbt, 0)) {
+        if (errno == EAGAIN) {
+            goto retry_transaction;
+        }
+    }
+
+    return 0;
+

hw/xen/xen_frontend.c void xenstore_update_fe(char *watch, struct XenDevice *xendev) · line 212

Quoted 10 lines
hw/xen/xen_frontend.c +10 -0
+abort_transaction:
+    xs_transaction_end(xenstore, xbt, 1);
+    return -1;
+}
+
+/*
+ * Simplify QEMU side, a thread is running in Xen backend, which will
+ * connect frontend when the frontend is initialised. Call these initialised
+ * functions.
+ */

This comment does not make much sense to me.

Quoted 29 lines
hw/xen/xen_frontend.c +29 -0
+static int xen_fe_try_init(void *opaque)
+{
+    struct XenDevOps *ops = opaque;
+    int rc = -1;
+
+    if (ops->init) {
+        rc = ops->init(NULL);
+    }
+
+    return rc;
+}
+
+static int xen_fe_try_initialise(struct XenDevice *xendev)
+{
+    int rc = 0, fe_state;
+
+    if (xenstore_read_fe_int(xendev, "state", &fe_state) == -1) {
+        fe_state = XenbusStateUnknown;
+    }
+    xendev->fe_state = fe_state;
+
+    if (xendev->ops->initialise) {
+        rc = xendev->ops->initialise(xendev);
+    }
+    if (rc != 0) {
+        xen_pv_printf(xendev, 0, "initialise() failed\n");
+        return rc;
+    }
+
Quoted 8 lines

hw/xen/xen_frontend.c void xenstore_update_fe(char *watch, struct XenDevice *xendev) · line 246

Quoted 5 lines
hw/xen/xen_frontend.c +5 -0
+    xenbus_switch_state(xendev, XenbusStateInitialised);
+    return 0;
+}
+
+static void xen_fe_try_connected(struct XenDevice *xendev)

This function looks exactly the same as xen_be_try_connected, should not it be different and check the status of the backend?

You are right, I will fix this in v10.

Quoted 16 lines
Quoted 16 lines
hw/xen/xen_frontend.c +14 -0
+{
+    if (!xendev->ops->connected) {
+        return;
+    }
+
+    if (xendev->fe_state != XenbusStateConnected) {
+        if (xendev->ops->flags & DEVOPS_FLAG_IGNORE_STATE) {
+            xen_pv_printf(xendev, 2, "frontend not ready, ignoring\n");
+        } else {
+            xen_pv_printf(xendev, 2, "frontend not ready (yet)\n");
+            return;
+        }
+    }
+
Quoted 8 lines

hw/xen/xen_frontend.c void xenstore_update_fe(char *watch, struct XenDevice *xendev) · line 265

Quoted 5 lines
hw/xen/xen_frontend.c +5 -0
+    xendev->ops->connected(xendev);
+}
+
+static int xen_fe_check(struct XenDevice *xendev, uint32_t domid,
+                        int handle)

What is this function checking? The name of the function is not very helpfull.

I will rename it to xen_fe_connect

Quoted 34 lines
Quoted 20 lines
hw/xen/xen_frontend.c +18 -0
+{
+    int rc = 0;
+
+    rc = xen_fe_try_initialise(xendev);
+    if (rc != 0) {
+        xen_pv_printf(xendev, 0, "xendev %s initialise error\n",
+                      xendev->name);
+        goto err;
+    }
+    xen_fe_try_connected(xendev);
+
+    return rc;
+
+err:
+    xen_pv_del_xendev(domid, handle);
+    return -1;
+}
+

hw/xen/xen_frontend.c void xenstore_update_fe(char *watch, struct XenDevice *xendev) · line 293

Quoted 10 lines
hw/xen/xen_frontend.c +10 -0
+static char *xenstore_fe_get_backend(const char *type, int be_domid,
+                                     uint32_t domid, int *hdl)
+{
+    char *name, *str, *ret = NULL;
+    uint32_t i, cdev;
+    int handle = 0;
+    char path[XEN_BUFSIZE];
+    char **dev = NULL;
+
+    name = xenstore_get_domain_name(domid);

The path backend of the backend would normally be located in:
device/$type/$devid/backend

Quoted 1 line

Could not you use that instead of a domain name?

Multiple domains might share one vTPM.

All frontends are under domain 0. For example, for 2 guests sharing a vTPM:

/local/domain/0/frontend/vtpm = ""
/local/domain/0/frontend/vtpm/41 = "" /local/domain/0/frontend/vtpm/41/0 = "" /local/domain/0/frontend/vtpm/41/0/backend = "/local/domain/41/backend/vtpm/0/0" /local/domain/0/frontend/vtpm/41/0/backend-id = "41" /local/domain/0/frontend/vtpm/41/0/state = "3" /local/domain/0/frontend/vtpm/41/0/handle = "0" /local/domain/0/frontend/vtpm/41/0/domain = "hvm-guest" /local/domain/0/frontend/vtpm/41/0/ring-ref = "8" /local/domain/0/frontend/vtpm/41/0/event-channel = "99" /local/domain/0/frontend/vtpm/41/0/feature-protocol-v2 = "1" /local/domain/0/frontend/vtpm/41/1 = "" /local/domain/0/frontend/vtpm/41/1/backend = "/local/domain/41/backend/vtpm/0/1" /local/domain/0/frontend/vtpm/41/1/backend-id = "41" /local/domain/0/frontend/vtpm/41/1/state = "3" /local/domain/0/frontend/vtpm/41/1/handle = "1" /local/domain/0/frontend/vtpm/41/1/domain = "hvm-guest2" /local/domain/0/frontend/vtpm/41/1/ring-ref = "9" /local/domain/0/frontend/vtpm/41/1/event-channel = "104" /local/domain/0/frontend/vtpm/41/1/feature-protocol-v2 = "1"

Quoted 52 lines
Quoted 52 lines
hw/xen/xen_frontend.c +50 -0
+    snprintf(path, sizeof(path), "frontend/%s/%d", type, be_domid);
+    dev = xs_directory(xenstore, 0, path, &cdev);
+    for (i = 0; i < cdev; i++) {
+        handle = i;
+        snprintf(path, sizeof(path), "frontend/%s/%d/%d",
+        type, be_domid, handle);
+        str = xenstore_read_str(path, "domain");
+        if (!strcmp(name, str)) {
+            break;
+        }
+
+        free(str);
+
+        /* Not the backend domain */
+        if (handle == (cdev - 1)) {
+            goto err;
+        }
+    }
+
+    snprintf(path, sizeof(path), "frontend/%s/%d/%d",
+    type, be_domid, handle);
+    str = xenstore_read_str(path, "backend");
+    if (str != NULL) {
+        ret = g_strdup(str);
+        free(str);
+    }
+
+    *hdl = handle;
+    free(dev);
+
+    return ret;
+err:
+    *hdl = -1;
+    free(dev);
+    return NULL;
+}
+
+static int xenstore_fe_scan(const char *type, uint32_t domid,
+                            struct XenDevOps *ops)
+{
+    struct XenDevice *xendev;
+    char path[XEN_BUFSIZE], token[XEN_BUFSIZE];
+    unsigned int cdev, j;
+    char *backend;
+    char **dev = NULL;
+    int rc;
+    int xenstore_dev;
+
+    /* ops .init check, xendev is NOT initialized */
+    rc = xen_fe_try_init(ops);
Quoted 8 lines

hw/xen/xen_frontend.c void xenstore_update_fe(char *watch, struct XenDevice *xendev) · line 348

Quoted 5 lines
hw/xen/xen_frontend.c +5 -0
+    if (rc != 0) {
+        return -1;
+    }
+
+    /* Get /local/domain/0/${type}/{} directory */

This comment does not reflect what is done by the next line, also what is "{}"?

Will update the comment.
frontend/vtpm/ is a directory with all xen hvm vtpm frontends. Eg. frontend/vtpm/[vtpm-domain-id]

Quoted 7 lines

hw/xen/xen_frontend.c void xenstore_update_fe(char *watch, struct XenDevice *xendev) · line 349

Quoted 3 lines
hw/xen/xen_frontend.c +1 -0
+    snprintf(path, sizeof(path), "frontend/%s", type);

I have not seen "frontend" used anywhere else, frontends are usully within "device", like "device/vbd/$DEVID/*" for a block device frontend. Can this be change?

vTPM for pv architecture use /local/domain/0/device/ and it was proposed that /local/domain/0/frontend/ would be used for hvm vTPM.

The design for this protocol was discussed last year here:
http://markmail.org/message/blpbzgyfzbpskwbf

Quoted 41 lines
Quoted 41 lines
hw/xen/xen_frontend.c +39 -0
+    dev = xs_directory(xenstore, 0, path, &cdev);
+    if (dev == NULL) {
+        return 0;
+    }
+
+    for (j = 0; j < cdev; j++) {
+
+        /* Get backend via domain name */
+        backend = xenstore_fe_get_backend(type, atoi(dev[j]),
+                                          domid, &xenstore_dev);
+        if (backend == NULL) {
+            continue;
+        }
+
+        xendev = xen_fe_get_xendev(type, domid, xenstore_dev, backend, ops);
+        free(backend);
+        if (xendev == NULL) {
+            xen_pv_printf(xendev, 0, "xendev is NULL.\n");
+            continue;
+        }
+
+        /*
+         * Simplify QEMU side, a thread is running in Xen backend, which will
+         * connect frontend when the frontend is initialised.
+         */
+        if (xen_fe_check(xendev, domid, xenstore_dev) < 0) {
+            xen_pv_printf(xendev, 0, "xendev fe_check error.\n");
+            continue;
+        }
+
+        /* Setup watch */
+        snprintf(token, sizeof(token), "be:%p:%d:%p",
+                 type, domid, xendev->ops);
+        if (!xs_watch(xenstore, xendev->be, token)) {
+            xen_pv_printf(xendev, 0, "xs_watch failed.\n");
+            continue;
+        }
+    }
+
Quoted 9 lines

hw/xen/xen_frontend.c void xenstore_update_fe(char *watch, struct XenDevice *xendev) · line 396

Quoted 8 lines
hw/xen/xen_frontend.c +8 -0
+    free(dev);
+    return 0;
+}
+
+int xen_fe_register(const char *type, struct XenDevOps *ops)
+{
+    return xenstore_fe_scan(type, xen_domid, ops);
+}

Thanks for the review, Anthony.

Quoted 5 lines

Thanks,

--
Anthony PERARD

#34 lore raw

Re: [Qemu-devel] [Xen-devel] [PATCH 15/19] Qemu-Xen-vTPM: Xen frontend driver infrastructure

On August 07, 2016 7:39 PM, Emil Condrea <[email protected]> wrote:

Quoted 15 lines · Anthony PERARD
Quoted 15 lines
Quoted 5 lines
hw/xen/xen_frontend.c +4 -0
+{
+    xs_transaction_t xbt = XBT_NULL;
+
+    if (xendev->fe_state == xbus) {

hw/xen/xen_frontend.c void xenstore_update_fe(char *watch, struct XenDevice *xendev) · line 185

Quoted 10 lines
hw/xen/xen_frontend.c +10 -0
+        return 0;
+    }
+
+    xendev->fe_state = xbus;
+    if (xendev->fe == NULL) {
+        xen_pv_printf(NULL, 0, "xendev->fe is NULL\n");
+        return -1;
+    }
+
+retry_transaction:

Add a space here, then
s/retry_transaction:/ retry_transaction:/
the same for the other cases..

Quoted 10 lines
Quoted 7 lines

hw/xen/xen_frontend.c void xenstore_update_fe(char *watch, struct XenDevice *xendev) · line 189

Quoted 4 lines
hw/xen/xen_frontend.c +4 -0
+    xbt = xs_transaction_start(xenstore);
+    if (xbt == XBT_NULL) {
+        goto abort_transaction;
+    }

There is a transaction started, but I don't think it is used by the function below. Could you remove the transaction?

I will remove it. For current version I don't see a direct usage of this transaction. Quan, did you have a specific reason for past versions for this transaction?

No specific reason, maybe I copied these code from xen / libxl .. btw, why does libxl use ' retry_transaction: ' logic ... but QEMU doesn't ?

Thank you both.

Quan

Quoted 18 lines
Quoted 18 lines
Quoted 8 lines
hw/xen/xen_frontend.c +6 -0
+    if (xenstore_write_int(xendev->fe, "state", xbus)) {
+        goto abort_transaction;
+    }
+
+    if (!xs_transaction_end(xenstore, xbt, 0)) {
+        if (errno == EAGAIN) {

hw/xen/xen_frontend.c void xenstore_update_fe(char *watch, struct XenDevice *xendev) · line 206

Quoted 10 lines
hw/xen/xen_frontend.c +10 -0
+            goto retry_transaction;
+        }
+    }
+
+    return 0;
+
+abort_transaction:
+    xs_transaction_end(xenstore, xbt, 1);
+    return -1;
+}

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#35 lore raw

PATCH v9 16/19 Qemu-Xen-vTPM: Register Xen stubdom vTPM frontend driver

In reply to Emil Condrea

This driver transfers any request/repond between TPM xenstubdoms driver and Xen vTPM stubdom, and facilitates communications between Xen vTPM stubdom domain and vTPM xenstubdoms driver. It is a glue for the TPM xenstubdoms driver and Xen stubdom vTPM domain that provides the actual TPM functionality.

(Xen) Xen backend driver should run before running this frontend, and initialize XenStore as the following for communication.

[XenStore]

for example:

Domain 0: runs QEMU for guest A
Domain 1: vtpmmgr
Domain 2: vTPM for guest A
Domain 3: HVM guest A

[...]
local = ""
domain = ""

    0 = ""
     frontend = ""
      vtpm = ""
       2 = ""
        0 = ""
         backend = "/local/domain/2/backend/vtpm/0/0"
         backend-id = "2"
         state = "*"
         handle = "0"
         domain = "Domain3's name"
         ring-ref = "*"
         event-channel = "*"
         feature-protocol-v2 = "1"
     backend = ""
      qdisk = ""
       [...]
      console = ""
      vif = ""
       [...]
    2 = ""
     [...]
     backend = ""
      vtpm = ""
       0 = ""
        0 = ""
         frontend = "/local/domain/0/frontend/vtpm/2/0"
         frontend-id = "0" ('0', frontend is running in Domain-0)
         [...]
    3 = ""
     [...]
     device = "" (frontend device, the backend is running in QEMU/.etc)
      vkbd = ""
       [...]
      vif = ""
       [...]

..

(QEMU) xen_vtpmdev_ops is initialized with the following process:
xen_hvm_init()

    [...]
    -->xen_fe_register("vtpm", ...)
      -->xenstore_fe_scan()
        -->xen_fe_try_init(ops)
          --> XenDevOps.init()
        -->xen_fe_get_xendev()
          --> XenDevOps.alloc()
        -->xen_fe_check()
          -->xen_fe_try_initialise()
            --> XenDevOps.initialise()
          -->xen_fe_try_connected()
            --> XenDevOps.connected()
        -->xs_watch()
    [...]

---
Changed in v9:
* instead of xen_frontend.c global variable xenstore_dev, use vtpm specific
xenstore_vtpm_dev (since it will be needed just for tpm_xenstubdoms qemu driver)
* added xen_vtpm_frontend.h
* move vtpm_backend_changed -> xen_fe_backend_changed to xen_frontend.c
* use libxengnttab, libxenevtchn stable API instead of xc_* calls:
- xc_gntshr_share_pages -> xengntshr_share_pages
- xc_gntshr_munmap -> xengntshr_unshare
- xc_interface_close -> xengntshr_close
- xc_evtchn_unmask -> xenevtchn_unmask

---
 hw/tpm/Makefile.objs          |   1 +
 hw/tpm/xen_vtpm_frontend.c    | 303 ++++++++++++++++++++++++++++++++++++++++++
 hw/tpm/xen_vtpm_frontend.h    |  10 ++
 hw/xen/xen_frontend.c         |  20 +++
 include/hw/xen/xen_backend.h  |   1 +
 include/hw/xen/xen_frontend.h |   1 +
 xen-hvm.c                     |   6 +
 7 files changed, 342 insertions(+)
 create mode 100644 hw/tpm/xen_vtpm_frontend.c
 create mode 100644 hw/tpm/xen_vtpm_frontend.h
hw/tpm/Makefile.objs +1 -0
index 64cecc3..b0a821c 100644
@@ -1,2 +1,3 @@
 common-obj-$(CONFIG_TPM_TIS) += tpm_tis.o
 common-obj-$(CONFIG_TPM_PASSTHROUGH) += tpm_passthrough.o tpm_util.o
+common-obj-$(CONFIG_TPM_XENSTUBDOMS) += xen_vtpm_frontend.o
hw/tpm/xen_vtpm_frontend.c new file +303 -0

304 lines not on this page · raw message

hw/tpm/xen_vtpm_frontend.h new file +10 -0
new file mode 100644
index 0000000..72f586b
@@ -0,0 +1,10 @@
+#ifndef TPM_XEN_VTPM_FRONTEND_H
+#define TPM_XEN_VTPM_FRONTEND_H 1
+
+struct XenDevice;
+extern int xenstore_vtpm_dev;
+/* Xen vtpm */
+int vtpm_send(struct XenDevice *xendev, uint8_t* buf, size_t count);
+int vtpm_recv(struct XenDevice *xendev, uint8_t* buf, size_t *count);
+
+#endif /* TPM_XEN_VTPM_FRONTEND_H */
hw/xen/xen_frontend.c +20 -0
index 7b305ce..f110411 100644
@@ -75,6 +75,26 @@ void xen_fe_frontend_changed(struct XenDevice *xendev, const char *node)
     }
 }
 
+void xen_fe_backend_changed(struct XenDevice *xendev, const char *node)
+{
+    int be_state;
+
+    if (strcmp(node, "state") == 0) {
+        xenstore_read_be_int(xendev, node, &be_state);
+        switch (be_state) {
+        case XenbusStateConnected:
+            /* TODO */
+            break;
+        case XenbusStateClosing:
+        case XenbusStateClosed:
+            xenbus_switch_state(xendev, XenbusStateClosing);
+            break;
+        default:
+            break;
+        }
+    }
+}
+
 void xenstore_update_fe(char *watch, struct XenDevice *xendev)
 {
     char *node;
include/hw/xen/xen_backend.h +1 -0
index 71dd158..4a8808e 100644
@@ -35,6 +35,7 @@ extern struct XenDevOps xen_kbdmouse_ops;     /* xen_framebuffer.c */
 extern struct XenDevOps xen_framebuffer_ops;  /* xen_framebuffer.c */
 extern struct XenDevOps xen_blkdev_ops;       /* xen_disk.c        */
 extern struct XenDevOps xen_netdev_ops;       /* xen_nic.c         */
+extern struct XenDevOps xen_vtpmdev_ops;      /* xen_vtpm_frontend.c*/
 #ifdef CONFIG_USB_LIBUSB
 extern struct XenDevOps xen_usb_ops;          /* xen-usb.c         */
 #endif
include/hw/xen/xen_frontend.h +1 -0
index 8fc0422..912f333 100644
@@ -11,6 +11,7 @@ void xenstore_update_fe(char *watch, struct XenDevice *xendev);
 struct XenDevice *xen_fe_get_xendev(const char *type, int dom, int dev,
                                     char *backend, struct XenDevOps *ops);
 void xen_fe_frontend_changed(struct XenDevice *xendev, const char *node);
+void xen_fe_backend_changed(struct XenDevice *xendev, const char *node);
 int xen_fe_register(const char *type, struct XenDevOps *ops);
 int xen_fe_alloc_unbound(struct XenDevice *xendev, int dom, int remote_dom);
 int xenbus_switch_state(struct XenDevice *xendev, enum xenbus_state xbus);
xen-hvm.c +6 -0
index eb57792..ef3fc53 100644
@@ -16,6 +16,7 @@
 #include "hw/i386/apic-msidef.h"
 #include "hw/xen/xen_common.h"
 #include "hw/xen/xen_backend.h"
+#include "hw/xen/xen_frontend.h"
 #include "qmp-commands.h"
 
 #include "sysemu/char.h"
@@ -1318,6 +1319,11 @@ void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory)
         error_report("xen backend core setup failed");
         goto err;
     }
+
+#ifdef CONFIG_TPM_XENSTUBDOMS
+    xen_fe_register("vtpm", &xen_vtpmdev_ops);
+#endif
+
     xen_be_register("console", &xen_console_ops);
     xen_be_register("vkbd", &xen_kbdmouse_ops);
     xen_be_register("qdisk", &xen_blkdev_ops);
Signature · 7 lines
1.9.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#36 lore raw

PATCH v9 17/19 Qemu-Xen-vTPM: Move tpm_passthrough_is_selftest() into tpm_util.c

In reply to Emil Condrea

Also rename it to tpm_util_is_selftest().

---
 hw/tpm/Makefile.objs     |  2 +-
 hw/tpm/tpm_passthrough.c | 13 +------------
 hw/tpm/tpm_util.c        | 11 +++++++++++
 hw/tpm/tpm_util.h        |  1 +
 4 files changed, 14 insertions(+), 13 deletions(-)
hw/tpm/Makefile.objs +1 -1
index b0a821c..16b1447 100644
@@ -1,3 +1,3 @@
-common-obj-$(CONFIG_TPM_TIS) += tpm_tis.o
+common-obj-$(CONFIG_TPM_TIS) += tpm_tis.o tpm_util.o
 common-obj-$(CONFIG_TPM_PASSTHROUGH) += tpm_passthrough.o tpm_util.o
 common-obj-$(CONFIG_TPM_XENSTUBDOMS) += xen_vtpm_frontend.o
hw/tpm/tpm_passthrough.c +1 -12
index e88c0d2..dba408b 100644
@@ -137,17 +137,6 @@ static void tpm_write_fatal_error_response(uint8_t *out, uint32_t out_len)
     }
 }
 
-static bool tpm_passthrough_is_selftest(const uint8_t *in, uint32_t in_len)
-{
-    struct tpm_req_hdr *hdr = (struct tpm_req_hdr *)in;
-
-    if (in_len >= sizeof(*hdr)) {
-        return (be32_to_cpu(hdr->ordinal) == TPM_ORD_ContinueSelfTest);
-    }
-
-    return false;
-}
-
 static int tpm_passthrough_unix_tx_bufs(TPMPassthruState *tpm_pt,
                                         const uint8_t *in, uint32_t in_len,
                                         uint8_t *out, uint32_t out_len,
@@ -161,7 +150,7 @@ static int tpm_passthrough_unix_tx_bufs(TPMPassthruState *tpm_pt,
     tpm_pt->tpm_executing = true;
     *selftest_done = false;
 
-    is_selftest = tpm_passthrough_is_selftest(in, in_len);
+    is_selftest = tpm_util_is_selftest(in, in_len);
 
     ret = tpm_passthrough_unix_write(tpm_pt->tpm_fd, in, in_len);
     if (ret != in_len) {
hw/tpm/tpm_util.c +11 -0
index 7b35429..323f4ae 100644
@@ -125,3 +125,14 @@ int tpm_util_test_tpmdev(int tpm_fd, TPMVersion *tpm_version)
 
     return 1;
 }
+
+bool tpm_util_is_selftest(const uint8_t *in, uint32_t in_len)
+{
+    struct tpm_req_hdr *hdr = (struct tpm_req_hdr *)in;
+
+    if (in_len >= sizeof(*hdr)) {
+        return (be32_to_cpu(hdr->ordinal) == TPM_ORD_ContinueSelfTest);
+    }
+
+    return false;
+}
hw/tpm/tpm_util.h +1 -0
index e7f354a..b629663 100644
@@ -24,5 +24,6 @@
 #include "sysemu/tpm_backend.h"
 
 int tpm_util_test_tpmdev(int tpm_fd, TPMVersion *tpm_version);
+bool tpm_util_is_selftest(const uint8_t *in, uint32_t in_len);
 
 #endif /* TPM_TPM_UTILS_H */
Signature · 7 lines
1.9.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#37 lore raw

PATCH v9 18/19 Qemu-Xen-vTPM: Qemu vTPM xenstubdoms backend

In reply to Emil Condrea

This Patch provides the glue for the TPM_TIS(Qemu frontend) to Xen stubdom vTPM domain that provides the actual TPM functionality. It sends data and TPM commends with xen_vtpm_frontend. It is similar as another two vTPM backends:
*vTPM passthrough backend Since QEMU 1.5.
*vTPM libtpms-based backend.

Some details:
This part of the patch provides support for the spawning of a thread that will interact with stubdom vTPM domain by the xen_vtpm_frontend. It expects a signal from the frontend to wake and pick up the TPM command that is supposed to be processed and delivers the response packet using a callback function provided by the frontend.

The backend connects itself to the frontend by filling out an interface structure with pointers to the function implementing support for various operations.

(QEMU) vTPM XenStubdoms backend is initialized by Qemu command line options,
"-tpmdev xenstubdoms,id=xenvtpm0 -device tpm-tis,tpmdev=xenvtpm0"

---
Changes in v9:
* added reset_tpm_established_flag and get_tpm_version for TPMDriverOps
* readded tpm_backend_thread_tpm_reset which was removed because it
was not used
* tpm_xenstubdoms_unix_transfer use xenstore_vtpm_dev instead of xenstore_dev

---
 backends/tpm.c                   |  11 ++
 hw/tpm/Makefile.objs             |   2 +-
 hw/tpm/tpm_xenstubdoms.c         | 284 +++++++++++++++++++++++++++++++++++++++
 include/sysemu/tpm_backend_int.h |   2 +
 4 files changed, 298 insertions(+), 1 deletion(-)
 create mode 100644 hw/tpm/tpm_xenstubdoms.c
backends/tpm.c +11 -0
index 536f262..9e0dfaa 100644
@@ -181,6 +181,17 @@ void tpm_backend_thread_end(TPMBackendThread *tbt)
     }
 }
 
+void tpm_backend_thread_tpm_reset(TPMBackendThread *tbt,
+                                  GFunc func, gpointer user_data)
+{
+    if (!tbt->pool) {
+        tpm_backend_thread_create(tbt, func, user_data);
+    } else {
+        g_thread_pool_push(tbt->pool, (gpointer)TPM_BACKEND_CMD_TPM_RESET,
+                           NULL);
+    }
+}
+
 static const TypeInfo tpm_backend_info = {
     .name = TYPE_TPM_BACKEND,
     .parent = TYPE_OBJECT,
hw/tpm/Makefile.objs +1 -1
index 16b1447..5e1e282 100644
@@ -1,3 +1,3 @@
 common-obj-$(CONFIG_TPM_TIS) += tpm_tis.o tpm_util.o
 common-obj-$(CONFIG_TPM_PASSTHROUGH) += tpm_passthrough.o tpm_util.o
-common-obj-$(CONFIG_TPM_XENSTUBDOMS) += xen_vtpm_frontend.o
+common-obj-$(CONFIG_TPM_XENSTUBDOMS) += xen_vtpm_frontend.o tpm_xenstubdoms.o
hw/tpm/tpm_xenstubdoms.c new file +284 -0

284 lines not on this page · raw message

include/sysemu/tpm_backend_int.h +2 -0
index cc0dcb3..c840ae9 100644
@@ -31,6 +31,8 @@ void tpm_backend_thread_deliver_request(TPMBackendThread *tbt);
 void tpm_backend_thread_create(TPMBackendThread *tbt,
                                GFunc func, gpointer user_data);
 void tpm_backend_thread_end(TPMBackendThread *tbt);
+void tpm_backend_thread_tpm_reset(TPMBackendThread *tbt,
+                                  GFunc func, gpointer user_data);
 
 typedef enum TPMBackendCmd {
     TPM_BACKEND_CMD_INIT = 1,
Signature · 7 lines
1.9.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#38 lore raw

PATCH v9 19/19 Qemu-Xen-vTPM: QEMU machine class is initialized before tpm_init()

In reply to Emil Condrea

make sure QEMU machine class is initialized and QEMU has registered Xen stubdom vTPM driver when call tpm_init()

---
 vl.c | 17 +++++++++++------
 1 file changed, 11 insertions(+), 6 deletions(-)
vl.c +11 -6
index 5cd0f2a..a22b0c9 100644
@@ -4353,12 +4353,6 @@ int main(int argc, char **argv, char **envp)
         exit(1);
     }
 
-#ifdef CONFIG_TPM
-    if (tpm_init() < 0) {
-        exit(1);
-    }
-#endif
-
     /* init the bluetooth world */
     if (foreach_device_config(DEV_BT, bt_parse))
         exit(1);
@@ -4477,6 +4471,17 @@ int main(int argc, char **argv, char **envp)
             exit(1);
     }
 
+    /*
+     * For compatible with Xen stubdom vTPM driver, make
+     * sure QEMU machine class is initialized and QEMU has
+     * registered Xen stubdom vTPM driver.
+     */
+#ifdef CONFIG_TPM
+    if (tpm_init() < 0) {
+        exit(1);
+    }
+#endif
+
     /* Check if IGD GFX passthrough. */
     igd_gfx_passthru();
 
Signature · 7 lines
1.9.1


_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#39 lore raw
In reply to Emil Condrea

Emil, Thanks for your effort ( today I just come back to return my laptop).

btw, [email protected] may be the right email.
Stefan / Stefano, could you help us review these patches? Thanks in advance!!

Quan

Quoted 185 lines · Emil Condrea

*INTRODUCTION*
The goal of virtual Trusted Platform Module (vTPM) is to provide a TPM functionality to virtual machines (Fedora, Ubuntu, Redhat, Windows .etc). This allows programs to interact with a TPM in a virtual machine the same way they interact with a TPM on the physical system. Each virtual machine gets its own unique, emulated, software TPM. Each major component of vTPM is implemented as a stubdom, providing secure separation guaranteed by the hypervisor.

The vTPM stubdom is a Xen mini-OS domain that emulates a TPM for the virtual machine to use. It is a small wrapper around the Berlios TPM emulator. TPM commands are passed from mini-os TPM backend driver.

*ARCHITECTURE*
The architecture of stubdom vTPM for HVM virtual machine:

            +--------------------+
            | Windows/Linux DomU | ...
            |        |  ^        |
            |        v  |        |
            |  Qemu tpm1.2 Tis   |
            |        |  ^        |
            |        v  |        |
            | XenStubdoms backend|
            +--------------------+
                     |  ^
                     v  |
            +--------------------+
            |      XenDevOps     |
            +--------------------+
                     |  ^
                     v  |
            +--------------------+
            |  mini-os/tpmback   |
            |        |  ^        |
            |        v  |        |
            |   vtpm-stubdom     | ...
            |        |  ^        |
            |        v  |        |
            |  mini-os/tpmfront  |
            +--------------------+
                     |  ^
                     v  |
            +--------------------+
            |  mini-os/tpmback   |
            |        |  ^        |
            |        v  |        |
            |  vtpmmgr-stubdom   |
            |        |  ^        |
            |        v  |        |
            |  mini-os/tpm_tis   |
            +--------------------+
                     |  ^
                     v  |
            +--------------------+
            |    Hardware TPM    |
            +--------------------+

* Windows/Linux DomU:
The HVM based guest that wants to use a vTPM. There may be more than one of these.

* Qemu tpm1.2 Tis:
Implementation of the tpm1.2 Tis interface for HVM virtual machines. It is Qemu emulation device.

* vTPM xenstubdoms driver:
Qemu vTPM driver. This driver provides vtpm initialization and sending data and commends to a para-virtualized vtpm stubdom.

* XenDevOps:
Register Xen stubdom vTPM frontend driver, and transfer any request/repond between TPM xenstubdoms driver and Xen vTPM stubdom. Facilitate communications between Xen vTPM stubdom and vTPM xenstubdoms driver.

* mini-os/tpmback:
Mini-os TPM backend driver. The Linux frontend driver connects to this backend driver to facilitate communications between the Linux DomU and its vTPM. This driver is also used by vtpmmgr stubdom to communicate with vtpm-stubdom.

* vtpm-stubdom:
A mini-os stub domain that implements a vTPM. There is a one to one mapping between running vtpm-stubdom instances and logical vtpms on the system. The vTPM Platform Configuration Registers (PCRs) are all initialized to zero.

* mini-os/tpmfront:
Mini-os TPM frontend driver. The vTPM mini-os domain vtpm stubdom uses this driver to communicate with vtpmmgr-stubdom. This driver could also be used separately to implement a mini-os domain that wishes to use a vTPM of its own.

* vtpmmgr-stubdom:
A mini-os domain that implements the vTPM manager. There is only one vTPM manager and it should be running during the entire lifetime of the machine. vtpmmgr domain securely stores encryption keys for each of the vtpms and accesses to the hardware TPM to get the root of trust for the entire system.

* mini-os/tpm_tis:
Mini-os TPM version 1.2 TPM Interface Specification (TIS) driver. This driver used by vtpmmgr-stubdom to talk directly to the hardware TPM. Communication is facilitated by mapping hardware memory pages into vtpmmgr stubdom.

* Hardware TPM: The physical TPM 1.2 that is soldered onto the
motherboard.

---
Changes in v9
High level changes: (each patch has a detailed history versioning)
* rebase on upstream qemu
* refactor qemu xendevs, xenstore functions in order to be shared with both
backend and frontends
* convert tpm stubdoms to new qapi layout
* use libxengnttab, libxenevtchn stable API instead of xc_* calls
* added reset_tpm_established_flag and get_tpm_version for TPMDriverOps
* instead of xen_frontend.c global variable xenstore_dev, use vtpm specific
xenstore_vtpm_dev (since it will be needed just for tpm_xenstubdoms qemu driver)

Emil Condrea (19):
xen: Create a new file xen_pvdev.c
xen: Create a new file xen_frontend.c
xen: Move xenstore_update to xen_pvdev.c
xen: Move evtchn functions to xen_pvdev.c
xen: Prepare xendev qtail to be shared with frontends
xen: Rename xen_be_printf to xen_pv_printf
xen: Rename xen_be_unbind_evtchn
xen: Rename xen_be_send_notify
xen: Rename xen_be_evtchn_event
xen: Rename xen_be_find_xendev
xen: Rename xen_be_del_xendev
xen: Rename xen_be_frontend_changed
xen: Distinguish between frontend and backend devops
Qemu-Xen-vTPM: Support for Xen stubdom vTPM command line options
Qemu-Xen-vTPM: Xen frontend driver infrastructure
Qemu-Xen-vTPM: Register Xen stubdom vTPM frontend driver
Qemu-Xen-vTPM: Move tpm_passthrough_is_selftest() into tpm_util.c
Qemu-Xen-vTPM: Qemu vTPM xenstubdoms backend
Qemu-Xen-vTPM: QEMU machine class is initialized before tpm_init()

 backends/tpm.c                   |  11 ++
 configure                        |  14 ++
 hmp.c                            |   2 +
 hw/block/xen_disk.c              |  59 +++---
 hw/char/xen_console.c            |  16 +-
 hw/display/xenfb.c               |  57 +++---
 hw/net/xen_nic.c                 |  29 +--
 hw/tpm/Makefile.objs             |   3 +-
 hw/tpm/tpm_passthrough.c         |  13 +-
 hw/tpm/tpm_util.c                |  11 ++
 hw/tpm/tpm_util.h                |   1 +
 hw/tpm/tpm_xenstubdoms.c         | 284 ++++++++++++++++++++++++++
 hw/tpm/xen_vtpm_frontend.c       | 303 ++++++++++++++++++++++++++++
 hw/tpm/xen_vtpm_frontend.h       |  10 +
 hw/usb/xen-usb.c                 |  38 ++--
 hw/xen/Makefile.objs             |   2 +-
 hw/xen/xen_backend.c             | 378 ++++-------------------------------
 hw/xen/xen_devconfig.c           |   4 +-
 hw/xen/xen_frontend.c            | 416
+++++++++++++++++++++++++++++++++++++++
 hw/xen/xen_pvdev.c               | 298 ++++++++++++++++++++++++++++
 include/hw/xen/xen_backend.h     |  71 +------
 include/hw/xen/xen_frontend.h    |  20 ++
 include/hw/xen/xen_pvdev.h       |  83 ++++++++
 include/sysemu/tpm_backend_int.h |   2 +
 qapi-schema.json                 |  16 +-
 qemu-options.hx                  |  13 +-
 tpm.c                            |   7 +-
 vl.c                             |  17 +-
 xen-common.c                     |   4 +-
 xen-hvm.c                        |   6 +
 30 files changed, 1649 insertions(+), 539 deletions(-)  create mode 100644

hw/tpm/tpm_xenstubdoms.c create mode 100644 hw/tpm/xen_vtpm_frontend.c create mode 100644 hw/tpm/xen_vtpm_frontend.h create mode 100644 hw/xen/xen_frontend.c create mode 100644 hw/xen/xen_pvdev.c create mode 100644 include/hw/xen/xen_frontend.h create mode 100644 include/hw/xen/xen_pvdev.h

Quoted 2 lines

--
1.9.1

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#40 lore raw
In reply to Emil Condrea

Emil, Thanks for your effort ( today I just come back to return my laptop).

btw, [email protected] may be the right email.
Stefan / Stefano, could you help us review these patches? Thanks in advance!!

Quan

Quoted 187 lines · Emil Condrea

*INTRODUCTION*
The goal of virtual Trusted Platform Module (vTPM) is to provide a TPM functionality to virtual machines (Fedora, Ubuntu, Redhat, Windows .etc). This allows programs to interact with a TPM in a virtual machine the same way they interact with a TPM on the physical system. Each virtual machine gets its own unique, emulated, software TPM. Each major component of vTPM is implemented as a stubdom, providing secure separation guaranteed by the hypervisor.

The vTPM stubdom is a Xen mini-OS domain that emulates a TPM for the virtual machine to use. It is a small wrapper around the Berlios TPM emulator. TPM commands are passed from mini-os TPM backend driver.

*ARCHITECTURE*
The architecture of stubdom vTPM for HVM virtual machine:

            +--------------------+
            | Windows/Linux DomU | ...
            |        |  ^        |
            |        v  |        |
            |  Qemu tpm1.2 Tis   |
            |        |  ^        |
            |        v  |        |
            | XenStubdoms backend|
            +--------------------+
                     |  ^
                     v  |
            +--------------------+
            |      XenDevOps     |
            +--------------------+
                     |  ^
                     v  |
            +--------------------+
            |  mini-os/tpmback   |
            |        |  ^        |
            |        v  |        |
            |   vtpm-stubdom     | ...
            |        |  ^        |
            |        v  |        |
            |  mini-os/tpmfront  |
            +--------------------+
                     |  ^
                     v  |
            +--------------------+
            |  mini-os/tpmback   |
            |        |  ^        |
            |        v  |        |
            |  vtpmmgr-stubdom   |
            |        |  ^        |
            |        v  |        |
            |  mini-os/tpm_tis   |
            +--------------------+
                     |  ^
                     v  |
            +--------------------+
            |    Hardware TPM    |
            +--------------------+

* Windows/Linux DomU:
The HVM based guest that wants to use a vTPM. There may be more than one of these.

* Qemu tpm1.2 Tis:
Implementation of the tpm1.2 Tis interface for HVM virtual machines. It is Qemu emulation device.

* vTPM xenstubdoms driver:
Qemu vTPM driver. This driver provides vtpm initialization and sending data and commends to a para-virtualized vtpm stubdom.

* XenDevOps:
Register Xen stubdom vTPM frontend driver, and transfer any request/repond between TPM xenstubdoms driver and Xen vTPM stubdom. Facilitate communications between Xen vTPM stubdom and vTPM xenstubdoms driver.

* mini-os/tpmback:
Mini-os TPM backend driver. The Linux frontend driver connects to this backend driver to facilitate communications between the Linux DomU and its vTPM. This driver is also used by vtpmmgr stubdom to communicate with vtpm-stubdom.

* vtpm-stubdom:
A mini-os stub domain that implements a vTPM. There is a one to one mapping between running vtpm-stubdom instances and logical vtpms on the system. The vTPM Platform Configuration Registers (PCRs) are all initialized to zero.

* mini-os/tpmfront:
Mini-os TPM frontend driver. The vTPM mini-os domain vtpm stubdom uses this driver to communicate with vtpmmgr-stubdom. This driver could also be used separately to implement a mini-os domain that wishes to use a vTPM of its own.

* vtpmmgr-stubdom:
A mini-os domain that implements the vTPM manager. There is only one vTPM manager and it should be running during the entire lifetime of the machine. vtpmmgr domain securely stores encryption keys for each of the vtpms and accesses to the hardware TPM to get the root of trust for the entire system.

* mini-os/tpm_tis:
Mini-os TPM version 1.2 TPM Interface Specification (TIS) driver. This driver used by vtpmmgr-stubdom to talk directly to the hardware TPM. Communication is facilitated by mapping hardware memory pages into vtpmmgr stubdom.

* Hardware TPM: The physical TPM 1.2 that is soldered onto the
motherboard.

---
Changes in v9
High level changes: (each patch has a detailed history versioning)
* rebase on upstream qemu
* refactor qemu xendevs, xenstore functions in order to be shared with both
backend and frontends
* convert tpm stubdoms to new qapi layout
* use libxengnttab, libxenevtchn stable API instead of xc_* calls
* added reset_tpm_established_flag and get_tpm_version for TPMDriverOps
* instead of xen_frontend.c global variable xenstore_dev, use vtpm specific
xenstore_vtpm_dev (since it will be needed just for tpm_xenstubdoms qemu driver)

Emil Condrea (19):
xen: Create a new file xen_pvdev.c
xen: Create a new file xen_frontend.c
xen: Move xenstore_update to xen_pvdev.c
xen: Move evtchn functions to xen_pvdev.c
xen: Prepare xendev qtail to be shared with frontends
xen: Rename xen_be_printf to xen_pv_printf
xen: Rename xen_be_unbind_evtchn
xen: Rename xen_be_send_notify
xen: Rename xen_be_evtchn_event
xen: Rename xen_be_find_xendev
xen: Rename xen_be_del_xendev
xen: Rename xen_be_frontend_changed
xen: Distinguish between frontend and backend devops
Qemu-Xen-vTPM: Support for Xen stubdom vTPM command line options
Qemu-Xen-vTPM: Xen frontend driver infrastructure
Qemu-Xen-vTPM: Register Xen stubdom vTPM frontend driver
Qemu-Xen-vTPM: Move tpm_passthrough_is_selftest() into tpm_util.c
Qemu-Xen-vTPM: Qemu vTPM xenstubdoms backend
Qemu-Xen-vTPM: QEMU machine class is initialized before tpm_init()

 backends/tpm.c                   |  11 ++
 configure                        |  14 ++
 hmp.c                            |   2 +
 hw/block/xen_disk.c              |  59 +++---
 hw/char/xen_console.c            |  16 +-
 hw/display/xenfb.c               |  57 +++---
 hw/net/xen_nic.c                 |  29 +--
 hw/tpm/Makefile.objs             |   3 +-
 hw/tpm/tpm_passthrough.c         |  13 +-
 hw/tpm/tpm_util.c                |  11 ++
 hw/tpm/tpm_util.h                |   1 +
 hw/tpm/tpm_xenstubdoms.c         | 284 ++++++++++++++++++++++++++
 hw/tpm/xen_vtpm_frontend.c       | 303 ++++++++++++++++++++++++++++
 hw/tpm/xen_vtpm_frontend.h       |  10 +
 hw/usb/xen-usb.c                 |  38 ++--
 hw/xen/Makefile.objs             |   2 +-
 hw/xen/xen_backend.c             | 378 ++++-------------------------------
 hw/xen/xen_devconfig.c           |   4 +-
 hw/xen/xen_frontend.c            | 416
+++++++++++++++++++++++++++++++++++++++
 hw/xen/xen_pvdev.c               | 298 ++++++++++++++++++++++++++++
 include/hw/xen/xen_backend.h     |  71 +------
 include/hw/xen/xen_frontend.h    |  20 ++
 include/hw/xen/xen_pvdev.h       |  83 ++++++++
 include/sysemu/tpm_backend_int.h |   2 +
 qapi-schema.json                 |  16 +-
 qemu-options.hx                  |  13 +-
 tpm.c                            |   7 +-
 vl.c                             |  17 +-
 xen-common.c                     |   4 +-
 xen-hvm.c                        |   6 +
 30 files changed, 1649 insertions(+), 539 deletions(-)  create mode 100644

hw/tpm/tpm_xenstubdoms.c create mode 100644 hw/tpm/xen_vtpm_frontend.c create mode 100644 hw/tpm/xen_vtpm_frontend.h create mode 100644 hw/xen/xen_frontend.c create mode 100644 hw/xen/xen_pvdev.c create mode 100644 include/hw/xen/xen_frontend.h create mode 100644 include/hw/xen/xen_pvdev.h

--
1.9.1

#41 lore raw

Hi Quan,

thanks for CC'ing me. [email protected] is the right address to reach me now.

I am also CC'ing Anthony Perard who is Xen co-maintainer in QEMU.

Cheers,

Stefano

Quoted 197 lines · Quan

Emil, Thanks for your effort ( today I just come back to return my laptop).

btw, [email protected] may be the right email.
Stefan / Stefano, could you help us review these patches? Thanks in advance!!

Quan

Quoted 187 lines · Emil Condrea

*INTRODUCTION*
The goal of virtual Trusted Platform Module (vTPM) is to provide a TPM functionality to virtual machines (Fedora, Ubuntu, Redhat, Windows .etc). This allows programs to interact with a TPM in a virtual machine the same way they interact with a TPM on the physical system. Each virtual machine gets its own unique, emulated, software TPM. Each major component of vTPM is implemented as a stubdom, providing secure separation guaranteed by the hypervisor.

The vTPM stubdom is a Xen mini-OS domain that emulates a TPM for the virtual machine to use. It is a small wrapper around the Berlios TPM emulator. TPM commands are passed from mini-os TPM backend driver.

*ARCHITECTURE*
The architecture of stubdom vTPM for HVM virtual machine:

            +--------------------+
            | Windows/Linux DomU | ...
            |        |  ^        |
            |        v  |        |
            |  Qemu tpm1.2 Tis   |
            |        |  ^        |
            |        v  |        |
            | XenStubdoms backend|
            +--------------------+
                     |  ^
                     v  |
            +--------------------+
            |      XenDevOps     |
            +--------------------+
                     |  ^
                     v  |
            +--------------------+
            |  mini-os/tpmback   |
            |        |  ^        |
            |        v  |        |
            |   vtpm-stubdom     | ...
            |        |  ^        |
            |        v  |        |
            |  mini-os/tpmfront  |
            +--------------------+
                     |  ^
                     v  |
            +--------------------+
            |  mini-os/tpmback   |
            |        |  ^        |
            |        v  |        |
            |  vtpmmgr-stubdom   |
            |        |  ^        |
            |        v  |        |
            |  mini-os/tpm_tis   |
            +--------------------+
                     |  ^
                     v  |
            +--------------------+
            |    Hardware TPM    |
            +--------------------+

* Windows/Linux DomU:
The HVM based guest that wants to use a vTPM. There may be more than one of these.

* Qemu tpm1.2 Tis:
Implementation of the tpm1.2 Tis interface for HVM virtual machines. It is Qemu emulation device.

* vTPM xenstubdoms driver:
Qemu vTPM driver. This driver provides vtpm initialization and sending data and commends to a para-virtualized vtpm stubdom.

* XenDevOps:
Register Xen stubdom vTPM frontend driver, and transfer any request/repond between TPM xenstubdoms driver and Xen vTPM stubdom. Facilitate communications between Xen vTPM stubdom and vTPM xenstubdoms driver.

* mini-os/tpmback:
Mini-os TPM backend driver. The Linux frontend driver connects to this backend driver to facilitate communications between the Linux DomU and its vTPM. This driver is also used by vtpmmgr stubdom to communicate with vtpm-stubdom.

* vtpm-stubdom:
A mini-os stub domain that implements a vTPM. There is a one to one mapping between running vtpm-stubdom instances and logical vtpms on the system. The vTPM Platform Configuration Registers (PCRs) are all initialized to zero.

* mini-os/tpmfront:
Mini-os TPM frontend driver. The vTPM mini-os domain vtpm stubdom uses this driver to communicate with vtpmmgr-stubdom. This driver could also be used separately to implement a mini-os domain that wishes to use a vTPM of its own.

* vtpmmgr-stubdom:
A mini-os domain that implements the vTPM manager. There is only one vTPM manager and it should be running during the entire lifetime of the machine. vtpmmgr domain securely stores encryption keys for each of the vtpms and accesses to the hardware TPM to get the root of trust for the entire system.

* mini-os/tpm_tis:
Mini-os TPM version 1.2 TPM Interface Specification (TIS) driver. This driver used by vtpmmgr-stubdom to talk directly to the hardware TPM. Communication is facilitated by mapping hardware memory pages into vtpmmgr stubdom.

* Hardware TPM: The physical TPM 1.2 that is soldered onto the
motherboard.

---
Changes in v9
High level changes: (each patch has a detailed history versioning)
* rebase on upstream qemu
* refactor qemu xendevs, xenstore functions in order to be shared with both
backend and frontends
* convert tpm stubdoms to new qapi layout
* use libxengnttab, libxenevtchn stable API instead of xc_* calls
* added reset_tpm_established_flag and get_tpm_version for TPMDriverOps
* instead of xen_frontend.c global variable xenstore_dev, use vtpm specific
xenstore_vtpm_dev (since it will be needed just for tpm_xenstubdoms qemu driver)

Emil Condrea (19):
xen: Create a new file xen_pvdev.c
xen: Create a new file xen_frontend.c
xen: Move xenstore_update to xen_pvdev.c
xen: Move evtchn functions to xen_pvdev.c
xen: Prepare xendev qtail to be shared with frontends
xen: Rename xen_be_printf to xen_pv_printf
xen: Rename xen_be_unbind_evtchn
xen: Rename xen_be_send_notify
xen: Rename xen_be_evtchn_event
xen: Rename xen_be_find_xendev
xen: Rename xen_be_del_xendev
xen: Rename xen_be_frontend_changed
xen: Distinguish between frontend and backend devops
Qemu-Xen-vTPM: Support for Xen stubdom vTPM command line options
Qemu-Xen-vTPM: Xen frontend driver infrastructure
Qemu-Xen-vTPM: Register Xen stubdom vTPM frontend driver
Qemu-Xen-vTPM: Move tpm_passthrough_is_selftest() into tpm_util.c
Qemu-Xen-vTPM: Qemu vTPM xenstubdoms backend
Qemu-Xen-vTPM: QEMU machine class is initialized before tpm_init()

 backends/tpm.c                   |  11 ++
 configure                        |  14 ++
 hmp.c                            |   2 +
 hw/block/xen_disk.c              |  59 +++---
 hw/char/xen_console.c            |  16 +-
 hw/display/xenfb.c               |  57 +++---
 hw/net/xen_nic.c                 |  29 +--
 hw/tpm/Makefile.objs             |   3 +-
 hw/tpm/tpm_passthrough.c         |  13 +-
 hw/tpm/tpm_util.c                |  11 ++
 hw/tpm/tpm_util.h                |   1 +
 hw/tpm/tpm_xenstubdoms.c         | 284 ++++++++++++++++++++++++++
 hw/tpm/xen_vtpm_frontend.c       | 303 ++++++++++++++++++++++++++++
 hw/tpm/xen_vtpm_frontend.h       |  10 +
 hw/usb/xen-usb.c                 |  38 ++--
 hw/xen/Makefile.objs             |   2 +-
 hw/xen/xen_backend.c             | 378 ++++-------------------------------
 hw/xen/xen_devconfig.c           |   4 +-
 hw/xen/xen_frontend.c            | 416
+++++++++++++++++++++++++++++++++++++++
 hw/xen/xen_pvdev.c               | 298 ++++++++++++++++++++++++++++
 include/hw/xen/xen_backend.h     |  71 +------
 include/hw/xen/xen_frontend.h    |  20 ++
 include/hw/xen/xen_pvdev.h       |  83 ++++++++
 include/sysemu/tpm_backend_int.h |   2 +
 qapi-schema.json                 |  16 +-
 qemu-options.hx                  |  13 +-
 tpm.c                            |   7 +-
 vl.c                             |  17 +-
 xen-common.c                     |   4 +-
 xen-hvm.c                        |   6 +
 30 files changed, 1649 insertions(+), 539 deletions(-)  create mode 100644

hw/tpm/tpm_xenstubdoms.c create mode 100644 hw/tpm/xen_vtpm_frontend.c create mode 100644 hw/tpm/xen_vtpm_frontend.h create mode 100644 hw/xen/xen_frontend.c create mode 100644 hw/xen/xen_pvdev.c create mode 100644 include/hw/xen/xen_frontend.h create mode 100644 include/hw/xen/xen_pvdev.h

--
1.9.1

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#42 lore raw
In reply to Xu, Quan

Hi Quan,

thanks for CC'ing me. [email protected] is the right address to reach me now.

I am also CC'ing Anthony Perard who is Xen co-maintainer in QEMU.

Cheers,

Stefano

Quoted 197 lines · Quan

Emil, Thanks for your effort ( today I just come back to return my laptop).

btw, [email protected] may be the right email.
Stefan / Stefano, could you help us review these patches? Thanks in advance!!

Quan

Quoted 187 lines · Emil Condrea

*INTRODUCTION*
The goal of virtual Trusted Platform Module (vTPM) is to provide a TPM functionality to virtual machines (Fedora, Ubuntu, Redhat, Windows .etc). This allows programs to interact with a TPM in a virtual machine the same way they interact with a TPM on the physical system. Each virtual machine gets its own unique, emulated, software TPM. Each major component of vTPM is implemented as a stubdom, providing secure separation guaranteed by the hypervisor.

The vTPM stubdom is a Xen mini-OS domain that emulates a TPM for the virtual machine to use. It is a small wrapper around the Berlios TPM emulator. TPM commands are passed from mini-os TPM backend driver.

*ARCHITECTURE*
The architecture of stubdom vTPM for HVM virtual machine:

            +--------------------+
            | Windows/Linux DomU | ...
            |        |  ^        |
            |        v  |        |
            |  Qemu tpm1.2 Tis   |
            |        |  ^        |
            |        v  |        |
            | XenStubdoms backend|
            +--------------------+
                     |  ^
                     v  |
            +--------------------+
            |      XenDevOps     |
            +--------------------+
                     |  ^
                     v  |
            +--------------------+
            |  mini-os/tpmback   |
            |        |  ^        |
            |        v  |        |
            |   vtpm-stubdom     | ...
            |        |  ^        |
            |        v  |        |
            |  mini-os/tpmfront  |
            +--------------------+
                     |  ^
                     v  |
            +--------------------+
            |  mini-os/tpmback   |
            |        |  ^        |
            |        v  |        |
            |  vtpmmgr-stubdom   |
            |        |  ^        |
            |        v  |        |
            |  mini-os/tpm_tis   |
            +--------------------+
                     |  ^
                     v  |
            +--------------------+
            |    Hardware TPM    |
            +--------------------+

* Windows/Linux DomU:
The HVM based guest that wants to use a vTPM. There may be more than one of these.

* Qemu tpm1.2 Tis:
Implementation of the tpm1.2 Tis interface for HVM virtual machines. It is Qemu emulation device.

* vTPM xenstubdoms driver:
Qemu vTPM driver. This driver provides vtpm initialization and sending data and commends to a para-virtualized vtpm stubdom.

* XenDevOps:
Register Xen stubdom vTPM frontend driver, and transfer any request/repond between TPM xenstubdoms driver and Xen vTPM stubdom. Facilitate communications between Xen vTPM stubdom and vTPM xenstubdoms driver.

* mini-os/tpmback:
Mini-os TPM backend driver. The Linux frontend driver connects to this backend driver to facilitate communications between the Linux DomU and its vTPM. This driver is also used by vtpmmgr stubdom to communicate with vtpm-stubdom.

* vtpm-stubdom:
A mini-os stub domain that implements a vTPM. There is a one to one mapping between running vtpm-stubdom instances and logical vtpms on the system. The vTPM Platform Configuration Registers (PCRs) are all initialized to zero.

* mini-os/tpmfront:
Mini-os TPM frontend driver. The vTPM mini-os domain vtpm stubdom uses this driver to communicate with vtpmmgr-stubdom. This driver could also be used separately to implement a mini-os domain that wishes to use a vTPM of its own.

* vtpmmgr-stubdom:
A mini-os domain that implements the vTPM manager. There is only one vTPM manager and it should be running during the entire lifetime of the machine. vtpmmgr domain securely stores encryption keys for each of the vtpms and accesses to the hardware TPM to get the root of trust for the entire system.

* mini-os/tpm_tis:
Mini-os TPM version 1.2 TPM Interface Specification (TIS) driver. This driver used by vtpmmgr-stubdom to talk directly to the hardware TPM. Communication is facilitated by mapping hardware memory pages into vtpmmgr stubdom.

* Hardware TPM: The physical TPM 1.2 that is soldered onto the
motherboard.

---
Changes in v9
High level changes: (each patch has a detailed history versioning)
* rebase on upstream qemu
* refactor qemu xendevs, xenstore functions in order to be shared with both
backend and frontends
* convert tpm stubdoms to new qapi layout
* use libxengnttab, libxenevtchn stable API instead of xc_* calls
* added reset_tpm_established_flag and get_tpm_version for TPMDriverOps
* instead of xen_frontend.c global variable xenstore_dev, use vtpm specific
xenstore_vtpm_dev (since it will be needed just for tpm_xenstubdoms qemu driver)

Emil Condrea (19):
xen: Create a new file xen_pvdev.c
xen: Create a new file xen_frontend.c
xen: Move xenstore_update to xen_pvdev.c
xen: Move evtchn functions to xen_pvdev.c
xen: Prepare xendev qtail to be shared with frontends
xen: Rename xen_be_printf to xen_pv_printf
xen: Rename xen_be_unbind_evtchn
xen: Rename xen_be_send_notify
xen: Rename xen_be_evtchn_event
xen: Rename xen_be_find_xendev
xen: Rename xen_be_del_xendev
xen: Rename xen_be_frontend_changed
xen: Distinguish between frontend and backend devops
Qemu-Xen-vTPM: Support for Xen stubdom vTPM command line options
Qemu-Xen-vTPM: Xen frontend driver infrastructure
Qemu-Xen-vTPM: Register Xen stubdom vTPM frontend driver
Qemu-Xen-vTPM: Move tpm_passthrough_is_selftest() into tpm_util.c
Qemu-Xen-vTPM: Qemu vTPM xenstubdoms backend
Qemu-Xen-vTPM: QEMU machine class is initialized before tpm_init()

 backends/tpm.c                   |  11 ++
 configure                        |  14 ++
 hmp.c                            |   2 +
 hw/block/xen_disk.c              |  59 +++---
 hw/char/xen_console.c            |  16 +-
 hw/display/xenfb.c               |  57 +++---
 hw/net/xen_nic.c                 |  29 +--
 hw/tpm/Makefile.objs             |   3 +-
 hw/tpm/tpm_passthrough.c         |  13 +-
 hw/tpm/tpm_util.c                |  11 ++
 hw/tpm/tpm_util.h                |   1 +
 hw/tpm/tpm_xenstubdoms.c         | 284 ++++++++++++++++++++++++++
 hw/tpm/xen_vtpm_frontend.c       | 303 ++++++++++++++++++++++++++++
 hw/tpm/xen_vtpm_frontend.h       |  10 +
 hw/usb/xen-usb.c                 |  38 ++--
 hw/xen/Makefile.objs             |   2 +-
 hw/xen/xen_backend.c             | 378 ++++-------------------------------
 hw/xen/xen_devconfig.c           |   4 +-
 hw/xen/xen_frontend.c            | 416
+++++++++++++++++++++++++++++++++++++++
 hw/xen/xen_pvdev.c               | 298 ++++++++++++++++++++++++++++
 include/hw/xen/xen_backend.h     |  71 +------
 include/hw/xen/xen_frontend.h    |  20 ++
 include/hw/xen/xen_pvdev.h       |  83 ++++++++
 include/sysemu/tpm_backend_int.h |   2 +
 qapi-schema.json                 |  16 +-
 qemu-options.hx                  |  13 +-
 tpm.c                            |   7 +-
 vl.c                             |  17 +-
 xen-common.c                     |   4 +-
 xen-hvm.c                        |   6 +
 30 files changed, 1649 insertions(+), 539 deletions(-)  create mode 100644

hw/tpm/tpm_xenstubdoms.c create mode 100644 hw/tpm/xen_vtpm_frontend.c create mode 100644 hw/tpm/xen_vtpm_frontend.h create mode 100644 hw/xen/xen_frontend.c create mode 100644 hw/xen/xen_pvdev.c create mode 100644 include/hw/xen/xen_frontend.h create mode 100644 include/hw/xen/xen_pvdev.h

--
1.9.1

#44 lore raw
In reply to Emil Condrea
Quoted 5 lines · Emil Condrea

Emil Condrea (19):
xen: Create a new file xen_pvdev.c
xen: Create a new file xen_frontend.c
xen: Move xenstore_update to xen_pvdev.c
xen: Move evtchn functions to xen_pvdev.c

Quoted 8 lines

xen: Prepare xendev qtail to be shared with frontends
xen: Rename xen_be_printf to xen_pv_printf
xen: Rename xen_be_unbind_evtchn
xen: Rename xen_be_send_notify
xen: Rename xen_be_evtchn_event
xen: Rename xen_be_find_xendev
xen: Rename xen_be_del_xendev
xen: Rename xen_be_frontend_changed

Patches from 1 to 12 looks fine but ./script/checkpatch.pl reveal some coding style issue in the code that is moved. Could you fix those issues in separate patches? (Having separate patches for code movement and for coding style fix makes it easier to review.)

I'll start reviewing the more complicated patches now.

Thanks,

Signature · 6 lines
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel
#45 lore raw
In reply to Emil Condrea
Quoted 5 lines · Emil Condrea

Emil Condrea (19):
xen: Create a new file xen_pvdev.c
xen: Create a new file xen_frontend.c
xen: Move xenstore_update to xen_pvdev.c
xen: Move evtchn functions to xen_pvdev.c

Quoted 8 lines

xen: Prepare xendev qtail to be shared with frontends
xen: Rename xen_be_printf to xen_pv_printf
xen: Rename xen_be_unbind_evtchn
xen: Rename xen_be_send_notify
xen: Rename xen_be_evtchn_event
xen: Rename xen_be_find_xendev
xen: Rename xen_be_del_xendev
xen: Rename xen_be_frontend_changed

Patches from 1 to 12 looks fine but ./script/checkpatch.pl reveal some coding style issue in the code that is moved. Could you fix those issues in separate patches? (Having separate patches for code movement and for coding style fix makes it easier to review.)

I'll start reviewing the more complicated patches now.

Thanks,

Signature · 1 line
Anthony PERARD
#46 lore raw

Thanks Anthony for the feedback.
I will send v10 containing fixes for patches 1 to 12 + additional patches for
fixing code style issues for moved code.

Quoted 20 lines · Anthony PERARD
Quoted 5 lines · Emil Condrea

Emil Condrea (19):
xen: Create a new file xen_pvdev.c
xen: Create a new file xen_frontend.c
xen: Move xenstore_update to xen_pvdev.c
xen: Move evtchn functions to xen_pvdev.c

Quoted 8 lines

xen: Prepare xendev qtail to be shared with frontends
xen: Rename xen_be_printf to xen_pv_printf
xen: Rename xen_be_unbind_evtchn
xen: Rename xen_be_send_notify
xen: Rename xen_be_evtchn_event
xen: Rename xen_be_find_xendev
xen: Rename xen_be_del_xendev
xen: Rename xen_be_frontend_changed

Patches from 1 to 12 looks fine but ./script/checkpatch.pl reveal some coding style issue in the code that is moved. Could you fix those issues in separate patches? (Having separate patches for code movement and for coding style fix makes it easier to review.)

Quoted 7 lines

I'll start reviewing the more complicated patches now.

Thanks,

--
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel

#47 lore raw
In reply to Anthony PERARD

Thanks Anthony for the feedback.
I will send v10 containing fixes for patches 1 to 12 + additional patches for
fixing code style issues for moved code.

Quoted 27 lines · Anthony PERARD
Quoted 5 lines · Emil Condrea

Emil Condrea (19):
xen: Create a new file xen_pvdev.c
xen: Create a new file xen_frontend.c
xen: Move xenstore_update to xen_pvdev.c
xen: Move evtchn functions to xen_pvdev.c

Quoted 8 lines

xen: Prepare xendev qtail to be shared with frontends
xen: Rename xen_be_printf to xen_pv_printf
xen: Rename xen_be_unbind_evtchn
xen: Rename xen_be_send_notify
xen: Rename xen_be_evtchn_event
xen: Rename xen_be_find_xendev
xen: Rename xen_be_del_xendev
xen: Rename xen_be_frontend_changed

Patches from 1 to 12 looks fine but ./script/checkpatch.pl reveal some coding style issue in the code that is moved. Could you fix those issues in separate patches? (Having separate patches for code movement and for coding style fix makes it easier to review.)

I'll start reviewing the more complicated patches now.

Thanks,

--
Anthony PERARD

#48 lore raw
In reply to Anthony PERARD

Anthony, I've split the reorganization and code style issues in a separate patch series which I've posted today:

http://markmail.org/message/feu6u3f7py5vt77v

Thanks

Quoted 20 lines · Anthony PERARD
Quoted 5 lines · Emil Condrea

Emil Condrea (19):
xen: Create a new file xen_pvdev.c
xen: Create a new file xen_frontend.c
xen: Move xenstore_update to xen_pvdev.c
xen: Move evtchn functions to xen_pvdev.c

Quoted 8 lines

xen: Prepare xendev qtail to be shared with frontends
xen: Rename xen_be_printf to xen_pv_printf
xen: Rename xen_be_unbind_evtchn
xen: Rename xen_be_send_notify
xen: Rename xen_be_evtchn_event
xen: Rename xen_be_find_xendev
xen: Rename xen_be_del_xendev
xen: Rename xen_be_frontend_changed

Patches from 1 to 12 looks fine but ./script/checkpatch.pl reveal some coding style issue in the code that is moved. Could you fix those issues in separate patches? (Having separate patches for code movement and for coding style fix makes it easier to review.)

Quoted 6 lines

I'll start reviewing the more complicated patches now.

Thanks,

--
Anthony PERARD

_______________________________________________
Xen-devel mailing list
[email protected]
https://lists.xen.org/xen-devel