[02/18] xen: introduce new 'XenBus' and 'XenDevice' object hierarchy
diff mbox series

Message ID 20181121151211.15997-3-paul.durrant@citrix.com
State New
Headers show
Series
  • Xen PV backend 'qdevification'
Related show

Commit Message

Paul Durrant Nov. 21, 2018, 3:11 p.m. UTC
This patch adds the basic boilerplate for a 'XenBus' object that will act
as a parent to 'XenDevice' PV backends.
A new 'XenBridge' object is also added to connect XenBus to the system bus.

The XenBus object is instantiated by a new xen_bus_init() function called
from the same sites as the legacy xen_be_init() function.

Subsequent patches will flesh-out the functionality of these objects.

Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
---
Cc: Stefano Stabellini <sstabellini@kernel.org>
Cc: Anthony Perard <anthony.perard@citrix.com>
Cc: "Michael S. Tsirkin" <mst@redhat.com>
Cc: Marcel Apfelbaum <marcel.apfelbaum@gmail.com>
Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Richard Henderson <rth@twiddle.net>
Cc: Eduardo Habkost <ehabkost@redhat.com>
---
 hw/i386/xen/xen-hvm.c     |   3 ++
 hw/xen/Makefile.objs      |   2 +-
 hw/xen/trace-events       |   6 +++
 hw/xen/xen-bus.c          | 125 ++++++++++++++++++++++++++++++++++++++++++++++
 hw/xenpv/xen_machine_pv.c |   3 ++
 include/hw/xen/xen-bus.h  |  53 ++++++++++++++++++++
 6 files changed, 191 insertions(+), 1 deletion(-)
 create mode 100644 hw/xen/xen-bus.c
 create mode 100644 include/hw/xen/xen-bus.h

Comments

Kevin Wolf Nov. 28, 2018, 4:19 p.m. UTC | #1
Am 21.11.2018 um 16:11 hat Paul Durrant geschrieben:
> This patch adds the basic boilerplate for a 'XenBus' object that will act
> as a parent to 'XenDevice' PV backends.
> A new 'XenBridge' object is also added to connect XenBus to the system bus.
> 
> The XenBus object is instantiated by a new xen_bus_init() function called
> from the same sites as the legacy xen_be_init() function.
> 
> Subsequent patches will flesh-out the functionality of these objects.
> 
> Signed-off-by: Paul Durrant <paul.durrant@citrix.com>

> diff --git a/hw/xen/xen-bus.c b/hw/xen/xen-bus.c
> new file mode 100644
> index 0000000000..dede2d914a
> --- /dev/null
> +++ b/hw/xen/xen-bus.c
> @@ -0,0 +1,125 @@
> +/*
> + * Copyright (c) Citrix Systems Inc.
> + * All rights reserved.
> + */

This doesn't look very compatible with the GPL. In fact it might even
make it illegal for the QEMU project to distribute this code. :-)

Other files you add throughout the series seem to have the same problem.

Kevin
Paul Durrant Nov. 28, 2018, 4:26 p.m. UTC | #2
> -----Original Message-----
> From: Kevin Wolf [mailto:kwolf@redhat.com]
> Sent: 28 November 2018 16:19
> To: Paul Durrant <Paul.Durrant@citrix.com>
> Cc: qemu-block@nongnu.org; qemu-devel@nongnu.org; xen-
> devel@lists.xenproject.org; Stefano Stabellini <sstabellini@kernel.org>;
> Eduardo Habkost <ehabkost@redhat.com>; Michael S. Tsirkin
> <mst@redhat.com>; Marcel Apfelbaum <marcel.apfelbaum@gmail.com>; Anthony
> Perard <anthony.perard@citrix.com>; Paolo Bonzini <pbonzini@redhat.com>;
> Richard Henderson <rth@twiddle.net>
> Subject: Re: [Qemu-block] [PATCH 02/18] xen: introduce new 'XenBus' and
> 'XenDevice' object hierarchy
> 
> Am 21.11.2018 um 16:11 hat Paul Durrant geschrieben:
> > This patch adds the basic boilerplate for a 'XenBus' object that will
> act
> > as a parent to 'XenDevice' PV backends.
> > A new 'XenBridge' object is also added to connect XenBus to the system
> bus.
> >
> > The XenBus object is instantiated by a new xen_bus_init() function
> called
> > from the same sites as the legacy xen_be_init() function.
> >
> > Subsequent patches will flesh-out the functionality of these objects.
> >
> > Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> 
> > diff --git a/hw/xen/xen-bus.c b/hw/xen/xen-bus.c
> > new file mode 100644
> > index 0000000000..dede2d914a
> > --- /dev/null
> > +++ b/hw/xen/xen-bus.c
> > @@ -0,0 +1,125 @@
> > +/*
> > + * Copyright (c) Citrix Systems Inc.
> > + * All rights reserved.
> > + */
> 
> This doesn't look very compatible with the GPL. In fact it might even
> make it illegal for the QEMU project to distribute this code. :-)
> 
> Other files you add throughout the series seem to have the same problem.
> 

I was working on the assumption that a lack of explicit license meant that the overall project license as described in item 2 in LICENSE. Did I misinterpret that text?

  Paul

> Kevin
Paul Durrant Nov. 28, 2018, 4:28 p.m. UTC | #3
> -----Original Message-----
> From: Paul Durrant
> Sent: 28 November 2018 16:27
> To: 'Kevin Wolf' <kwolf@redhat.com>
> Cc: qemu-block@nongnu.org; qemu-devel@nongnu.org; xen-
> devel@lists.xenproject.org; Stefano Stabellini <sstabellini@kernel.org>;
> Eduardo Habkost <ehabkost@redhat.com>; Michael S. Tsirkin
> <mst@redhat.com>; Marcel Apfelbaum <marcel.apfelbaum@gmail.com>; Anthony
> Perard <anthony.perard@citrix.com>; Paolo Bonzini <pbonzini@redhat.com>;
> Richard Henderson <rth@twiddle.net>
> Subject: RE: [Qemu-block] [PATCH 02/18] xen: introduce new 'XenBus' and
> 'XenDevice' object hierarchy
> 
> > -----Original Message-----
> > From: Kevin Wolf [mailto:kwolf@redhat.com]
> > Sent: 28 November 2018 16:19
> > To: Paul Durrant <Paul.Durrant@citrix.com>
> > Cc: qemu-block@nongnu.org; qemu-devel@nongnu.org; xen-
> > devel@lists.xenproject.org; Stefano Stabellini <sstabellini@kernel.org>;
> > Eduardo Habkost <ehabkost@redhat.com>; Michael S. Tsirkin
> > <mst@redhat.com>; Marcel Apfelbaum <marcel.apfelbaum@gmail.com>; Anthony
> > Perard <anthony.perard@citrix.com>; Paolo Bonzini <pbonzini@redhat.com>;
> > Richard Henderson <rth@twiddle.net>
> > Subject: Re: [Qemu-block] [PATCH 02/18] xen: introduce new 'XenBus' and
> > 'XenDevice' object hierarchy
> >
> > Am 21.11.2018 um 16:11 hat Paul Durrant geschrieben:
> > > This patch adds the basic boilerplate for a 'XenBus' object that will
> > act
> > > as a parent to 'XenDevice' PV backends.
> > > A new 'XenBridge' object is also added to connect XenBus to the system
> > bus.
> > >
> > > The XenBus object is instantiated by a new xen_bus_init() function
> > called
> > > from the same sites as the legacy xen_be_init() function.
> > >
> > > Subsequent patches will flesh-out the functionality of these objects.
> > >
> > > Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> >
> > > diff --git a/hw/xen/xen-bus.c b/hw/xen/xen-bus.c
> > > new file mode 100644
> > > index 0000000000..dede2d914a
> > > --- /dev/null
> > > +++ b/hw/xen/xen-bus.c
> > > @@ -0,0 +1,125 @@
> > > +/*
> > > + * Copyright (c) Citrix Systems Inc.
> > > + * All rights reserved.
> > > + */
> >
> > This doesn't look very compatible with the GPL. In fact it might even
> > make it illegal for the QEMU project to distribute this code. :-)
> >
> > Other files you add throughout the series seem to have the same problem.
> >
> 
> I was working on the assumption that a lack of explicit license meant that
> the overall project license as described in item 2 in LICENSE. Did I
                             ^ applied
> misinterpret that text?
> 
>   Paul
> 
> > Kevin
Stefano Stabellini Nov. 28, 2018, 4:28 p.m. UTC | #4
On Wed, 28 Nov 2018, Paul Durrant wrote:
> > -----Original Message-----
> > From: Kevin Wolf [mailto:kwolf@redhat.com]
> > Sent: 28 November 2018 16:19
> > To: Paul Durrant <Paul.Durrant@citrix.com>
> > Cc: qemu-block@nongnu.org; qemu-devel@nongnu.org; xen-
> > devel@lists.xenproject.org; Stefano Stabellini <sstabellini@kernel.org>;
> > Eduardo Habkost <ehabkost@redhat.com>; Michael S. Tsirkin
> > <mst@redhat.com>; Marcel Apfelbaum <marcel.apfelbaum@gmail.com>; Anthony
> > Perard <anthony.perard@citrix.com>; Paolo Bonzini <pbonzini@redhat.com>;
> > Richard Henderson <rth@twiddle.net>
> > Subject: Re: [Qemu-block] [PATCH 02/18] xen: introduce new 'XenBus' and
> > 'XenDevice' object hierarchy
> > 
> > Am 21.11.2018 um 16:11 hat Paul Durrant geschrieben:
> > > This patch adds the basic boilerplate for a 'XenBus' object that will
> > act
> > > as a parent to 'XenDevice' PV backends.
> > > A new 'XenBridge' object is also added to connect XenBus to the system
> > bus.
> > >
> > > The XenBus object is instantiated by a new xen_bus_init() function
> > called
> > > from the same sites as the legacy xen_be_init() function.
> > >
> > > Subsequent patches will flesh-out the functionality of these objects.
> > >
> > > Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> > 
> > > diff --git a/hw/xen/xen-bus.c b/hw/xen/xen-bus.c
> > > new file mode 100644
> > > index 0000000000..dede2d914a
> > > --- /dev/null
> > > +++ b/hw/xen/xen-bus.c
> > > @@ -0,0 +1,125 @@
> > > +/*
> > > + * Copyright (c) Citrix Systems Inc.
> > > + * All rights reserved.
> > > + */
> > 
> > This doesn't look very compatible with the GPL. In fact it might even
> > make it illegal for the QEMU project to distribute this code. :-)
> > 
> > Other files you add throughout the series seem to have the same problem.
> > 
> 
> I was working on the assumption that a lack of explicit license meant that the overall project license as described in item 2 in LICENSE. Did I misinterpret that text?

It's "All rights reserved." the problem
Paul Durrant Nov. 28, 2018, 4:29 p.m. UTC | #5
> -----Original Message-----
> From: Stefano Stabellini [mailto:sstabellini@kernel.org]
> Sent: 28 November 2018 16:28
> To: Paul Durrant <Paul.Durrant@citrix.com>
> Cc: 'Kevin Wolf' <kwolf@redhat.com>; qemu-block@nongnu.org; qemu-
> devel@nongnu.org; xen-devel@lists.xenproject.org; Stefano Stabellini
> <sstabellini@kernel.org>; Eduardo Habkost <ehabkost@redhat.com>; Michael
> S. Tsirkin <mst@redhat.com>; Marcel Apfelbaum
> <marcel.apfelbaum@gmail.com>; Anthony Perard <anthony.perard@citrix.com>;
> Paolo Bonzini <pbonzini@redhat.com>; Richard Henderson <rth@twiddle.net>
> Subject: RE: [Qemu-block] [PATCH 02/18] xen: introduce new 'XenBus' and
> 'XenDevice' object hierarchy
> 
> On Wed, 28 Nov 2018, Paul Durrant wrote:
> > > -----Original Message-----
> > > From: Kevin Wolf [mailto:kwolf@redhat.com]
> > > Sent: 28 November 2018 16:19
> > > To: Paul Durrant <Paul.Durrant@citrix.com>
> > > Cc: qemu-block@nongnu.org; qemu-devel@nongnu.org; xen-
> > > devel@lists.xenproject.org; Stefano Stabellini
> <sstabellini@kernel.org>;
> > > Eduardo Habkost <ehabkost@redhat.com>; Michael S. Tsirkin
> > > <mst@redhat.com>; Marcel Apfelbaum <marcel.apfelbaum@gmail.com>;
> Anthony
> > > Perard <anthony.perard@citrix.com>; Paolo Bonzini
> <pbonzini@redhat.com>;
> > > Richard Henderson <rth@twiddle.net>
> > > Subject: Re: [Qemu-block] [PATCH 02/18] xen: introduce new 'XenBus'
> and
> > > 'XenDevice' object hierarchy
> > >
> > > Am 21.11.2018 um 16:11 hat Paul Durrant geschrieben:
> > > > This patch adds the basic boilerplate for a 'XenBus' object that
> will
> > > act
> > > > as a parent to 'XenDevice' PV backends.
> > > > A new 'XenBridge' object is also added to connect XenBus to the
> system
> > > bus.
> > > >
> > > > The XenBus object is instantiated by a new xen_bus_init() function
> > > called
> > > > from the same sites as the legacy xen_be_init() function.
> > > >
> > > > Subsequent patches will flesh-out the functionality of these
> objects.
> > > >
> > > > Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> > >
> > > > diff --git a/hw/xen/xen-bus.c b/hw/xen/xen-bus.c
> > > > new file mode 100644
> > > > index 0000000000..dede2d914a
> > > > --- /dev/null
> > > > +++ b/hw/xen/xen-bus.c
> > > > @@ -0,0 +1,125 @@
> > > > +/*
> > > > + * Copyright (c) Citrix Systems Inc.
> > > > + * All rights reserved.
> > > > + */
> > >
> > > This doesn't look very compatible with the GPL. In fact it might even
> > > make it illegal for the QEMU project to distribute this code. :-)
> > >
> > > Other files you add throughout the series seem to have the same
> problem.
> > >
> >
> > I was working on the assumption that a lack of explicit license meant
> that the overall project license as described in item 2 in LICENSE. Did I
> misinterpret that text?
> 
> It's "All rights reserved." the problem

Oh, I see. I'm happy to remove that.

  Paul
Kevin Wolf Nov. 28, 2018, 4:39 p.m. UTC | #6
Am 28.11.2018 um 17:29 hat Paul Durrant geschrieben:
> > -----Original Message-----
> > From: Stefano Stabellini [mailto:sstabellini@kernel.org]
> > Sent: 28 November 2018 16:28
> > To: Paul Durrant <Paul.Durrant@citrix.com>
> > Cc: 'Kevin Wolf' <kwolf@redhat.com>; qemu-block@nongnu.org; qemu-
> > devel@nongnu.org; xen-devel@lists.xenproject.org; Stefano Stabellini
> > <sstabellini@kernel.org>; Eduardo Habkost <ehabkost@redhat.com>; Michael
> > S. Tsirkin <mst@redhat.com>; Marcel Apfelbaum
> > <marcel.apfelbaum@gmail.com>; Anthony Perard <anthony.perard@citrix.com>;
> > Paolo Bonzini <pbonzini@redhat.com>; Richard Henderson <rth@twiddle.net>
> > Subject: RE: [Qemu-block] [PATCH 02/18] xen: introduce new 'XenBus' and
> > 'XenDevice' object hierarchy
> > 
> > On Wed, 28 Nov 2018, Paul Durrant wrote:
> > > > -----Original Message-----
> > > > From: Kevin Wolf [mailto:kwolf@redhat.com]
> > > > Sent: 28 November 2018 16:19
> > > > To: Paul Durrant <Paul.Durrant@citrix.com>
> > > > Cc: qemu-block@nongnu.org; qemu-devel@nongnu.org; xen-
> > > > devel@lists.xenproject.org; Stefano Stabellini
> > <sstabellini@kernel.org>;
> > > > Eduardo Habkost <ehabkost@redhat.com>; Michael S. Tsirkin
> > > > <mst@redhat.com>; Marcel Apfelbaum <marcel.apfelbaum@gmail.com>;
> > Anthony
> > > > Perard <anthony.perard@citrix.com>; Paolo Bonzini
> > <pbonzini@redhat.com>;
> > > > Richard Henderson <rth@twiddle.net>
> > > > Subject: Re: [Qemu-block] [PATCH 02/18] xen: introduce new 'XenBus'
> > and
> > > > 'XenDevice' object hierarchy
> > > >
> > > > Am 21.11.2018 um 16:11 hat Paul Durrant geschrieben:
> > > > > This patch adds the basic boilerplate for a 'XenBus' object that
> > will
> > > > act
> > > > > as a parent to 'XenDevice' PV backends.
> > > > > A new 'XenBridge' object is also added to connect XenBus to the
> > system
> > > > bus.
> > > > >
> > > > > The XenBus object is instantiated by a new xen_bus_init() function
> > > > called
> > > > > from the same sites as the legacy xen_be_init() function.
> > > > >
> > > > > Subsequent patches will flesh-out the functionality of these
> > objects.
> > > > >
> > > > > Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> > > >
> > > > > diff --git a/hw/xen/xen-bus.c b/hw/xen/xen-bus.c
> > > > > new file mode 100644
> > > > > index 0000000000..dede2d914a
> > > > > --- /dev/null
> > > > > +++ b/hw/xen/xen-bus.c
> > > > > @@ -0,0 +1,125 @@
> > > > > +/*
> > > > > + * Copyright (c) Citrix Systems Inc.
> > > > > + * All rights reserved.
> > > > > + */
> > > >
> > > > This doesn't look very compatible with the GPL. In fact it might even
> > > > make it illegal for the QEMU project to distribute this code. :-)
> > > >
> > > > Other files you add throughout the series seem to have the same
> > problem.
> > > >
> > >
> > > I was working on the assumption that a lack of explicit license meant
> > that the overall project license as described in item 2 in LICENSE. Did I
> > misinterpret that text?
> > 
> > It's "All rights reserved." the problem
> 
> Oh, I see. I'm happy to remove that.

That would be better at least. I'm not sure about files that have a
copyright header, but no license statement. Do such files exist yet in
the source tree? To be on the safe side, I'd just stick with the
established practice, which is having a license header in every file.

By the way, in a later patch you remove the existing license header,
which is different from the default license (because parts of the source
file are GPL 2 only). If you can't prove that all such parts (and parts
derived from them) have been removed, this is also a problem.

Kevin
Paul Durrant Nov. 28, 2018, 4:45 p.m. UTC | #7
> -----Original Message-----
> From: Kevin Wolf [mailto:kwolf@redhat.com]
> Sent: 28 November 2018 16:39
> To: Paul Durrant <Paul.Durrant@citrix.com>
> Cc: 'Stefano Stabellini' <sstabellini@kernel.org>; qemu-block@nongnu.org;
> qemu-devel@nongnu.org; xen-devel@lists.xenproject.org; Eduardo Habkost
> <ehabkost@redhat.com>; Michael S. Tsirkin <mst@redhat.com>; Marcel
> Apfelbaum <marcel.apfelbaum@gmail.com>; Anthony Perard
> <anthony.perard@citrix.com>; Paolo Bonzini <pbonzini@redhat.com>; Richard
> Henderson <rth@twiddle.net>
> Subject: Re: [Qemu-block] [PATCH 02/18] xen: introduce new 'XenBus' and
> 'XenDevice' object hierarchy
> 
> Am 28.11.2018 um 17:29 hat Paul Durrant geschrieben:
> > > -----Original Message-----
> > > From: Stefano Stabellini [mailto:sstabellini@kernel.org]
> > > Sent: 28 November 2018 16:28
> > > To: Paul Durrant <Paul.Durrant@citrix.com>
> > > Cc: 'Kevin Wolf' <kwolf@redhat.com>; qemu-block@nongnu.org; qemu-
> > > devel@nongnu.org; xen-devel@lists.xenproject.org; Stefano Stabellini
> > > <sstabellini@kernel.org>; Eduardo Habkost <ehabkost@redhat.com>;
> Michael
> > > S. Tsirkin <mst@redhat.com>; Marcel Apfelbaum
> > > <marcel.apfelbaum@gmail.com>; Anthony Perard
> <anthony.perard@citrix.com>;
> > > Paolo Bonzini <pbonzini@redhat.com>; Richard Henderson
> <rth@twiddle.net>
> > > Subject: RE: [Qemu-block] [PATCH 02/18] xen: introduce new 'XenBus'
> and
> > > 'XenDevice' object hierarchy
> > >
> > > On Wed, 28 Nov 2018, Paul Durrant wrote:
> > > > > -----Original Message-----
> > > > > From: Kevin Wolf [mailto:kwolf@redhat.com]
> > > > > Sent: 28 November 2018 16:19
> > > > > To: Paul Durrant <Paul.Durrant@citrix.com>
> > > > > Cc: qemu-block@nongnu.org; qemu-devel@nongnu.org; xen-
> > > > > devel@lists.xenproject.org; Stefano Stabellini
> > > <sstabellini@kernel.org>;
> > > > > Eduardo Habkost <ehabkost@redhat.com>; Michael S. Tsirkin
> > > > > <mst@redhat.com>; Marcel Apfelbaum <marcel.apfelbaum@gmail.com>;
> > > Anthony
> > > > > Perard <anthony.perard@citrix.com>; Paolo Bonzini
> > > <pbonzini@redhat.com>;
> > > > > Richard Henderson <rth@twiddle.net>
> > > > > Subject: Re: [Qemu-block] [PATCH 02/18] xen: introduce new
> 'XenBus'
> > > and
> > > > > 'XenDevice' object hierarchy
> > > > >
> > > > > Am 21.11.2018 um 16:11 hat Paul Durrant geschrieben:
> > > > > > This patch adds the basic boilerplate for a 'XenBus' object that
> > > will
> > > > > act
> > > > > > as a parent to 'XenDevice' PV backends.
> > > > > > A new 'XenBridge' object is also added to connect XenBus to the
> > > system
> > > > > bus.
> > > > > >
> > > > > > The XenBus object is instantiated by a new xen_bus_init()
> function
> > > > > called
> > > > > > from the same sites as the legacy xen_be_init() function.
> > > > > >
> > > > > > Subsequent patches will flesh-out the functionality of these
> > > objects.
> > > > > >
> > > > > > Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> > > > >
> > > > > > diff --git a/hw/xen/xen-bus.c b/hw/xen/xen-bus.c
> > > > > > new file mode 100644
> > > > > > index 0000000000..dede2d914a
> > > > > > --- /dev/null
> > > > > > +++ b/hw/xen/xen-bus.c
> > > > > > @@ -0,0 +1,125 @@
> > > > > > +/*
> > > > > > + * Copyright (c) Citrix Systems Inc.
> > > > > > + * All rights reserved.
> > > > > > + */
> > > > >
> > > > > This doesn't look very compatible with the GPL. In fact it might
> even
> > > > > make it illegal for the QEMU project to distribute this code. :-)
> > > > >
> > > > > Other files you add throughout the series seem to have the same
> > > problem.
> > > > >
> > > >
> > > > I was working on the assumption that a lack of explicit license
> meant
> > > that the overall project license as described in item 2 in LICENSE.
> Did I
> > > misinterpret that text?
> > >
> > > It's "All rights reserved." the problem
> >
> > Oh, I see. I'm happy to remove that.
> 
> That would be better at least. I'm not sure about files that have a
> copyright header, but no license statement. Do such files exist yet in
> the source tree?

Yes, there's quite a few... e.g. (first ones I tripped over) hw/rdma/rdma_backend.c, hw/virtio/vhost-backend.c, ... 

> To be on the safe side, I'd just stick with the
> established practice, which is having a license header in every file.

Ok... if that is established practice. It really wasn't clear.

> 
> By the way, in a later patch you remove the existing license header,
> which is different from the default license (because parts of the source
> file are GPL 2 only). If you can't prove that all such parts (and parts
> derived from them) have been removed, this is also a problem.
> 

What should I do? I am duplicating xen_disk, and then heavily modifying it. Should I just leave the old boilerplate in place?

  Paul

> Kevin
Paul Durrant Nov. 28, 2018, 4:46 p.m. UTC | #8
> -----Original Message-----
> From: Paul Durrant
> Sent: 28 November 2018 16:46
> To: 'Kevin Wolf' <kwolf@redhat.com>
> Cc: 'Stefano Stabellini' <sstabellini@kernel.org>; qemu-block@nongnu.org;
> qemu-devel@nongnu.org; xen-devel@lists.xenproject.org; Eduardo Habkost
> <ehabkost@redhat.com>; Michael S. Tsirkin <mst@redhat.com>; Marcel
> Apfelbaum <marcel.apfelbaum@gmail.com>; Anthony Perard
> <anthony.perard@citrix.com>; Paolo Bonzini <pbonzini@redhat.com>; Richard
> Henderson <rth@twiddle.net>
> Subject: RE: [Qemu-block] [PATCH 02/18] xen: introduce new 'XenBus' and
> 'XenDevice' object hierarchy
> 
> > -----Original Message-----
> > From: Kevin Wolf [mailto:kwolf@redhat.com]
> > Sent: 28 November 2018 16:39
> > To: Paul Durrant <Paul.Durrant@citrix.com>
> > Cc: 'Stefano Stabellini' <sstabellini@kernel.org>; qemu-
> block@nongnu.org;
> > qemu-devel@nongnu.org; xen-devel@lists.xenproject.org; Eduardo Habkost
> > <ehabkost@redhat.com>; Michael S. Tsirkin <mst@redhat.com>; Marcel
> > Apfelbaum <marcel.apfelbaum@gmail.com>; Anthony Perard
> > <anthony.perard@citrix.com>; Paolo Bonzini <pbonzini@redhat.com>;
> Richard
> > Henderson <rth@twiddle.net>
> > Subject: Re: [Qemu-block] [PATCH 02/18] xen: introduce new 'XenBus' and
> > 'XenDevice' object hierarchy
> >
> > Am 28.11.2018 um 17:29 hat Paul Durrant geschrieben:
> > > > -----Original Message-----
> > > > From: Stefano Stabellini [mailto:sstabellini@kernel.org]
> > > > Sent: 28 November 2018 16:28
> > > > To: Paul Durrant <Paul.Durrant@citrix.com>
> > > > Cc: 'Kevin Wolf' <kwolf@redhat.com>; qemu-block@nongnu.org; qemu-
> > > > devel@nongnu.org; xen-devel@lists.xenproject.org; Stefano Stabellini
> > > > <sstabellini@kernel.org>; Eduardo Habkost <ehabkost@redhat.com>;
> > Michael
> > > > S. Tsirkin <mst@redhat.com>; Marcel Apfelbaum
> > > > <marcel.apfelbaum@gmail.com>; Anthony Perard
> > <anthony.perard@citrix.com>;
> > > > Paolo Bonzini <pbonzini@redhat.com>; Richard Henderson
> > <rth@twiddle.net>
> > > > Subject: RE: [Qemu-block] [PATCH 02/18] xen: introduce new 'XenBus'
> > and
> > > > 'XenDevice' object hierarchy
> > > >
> > > > On Wed, 28 Nov 2018, Paul Durrant wrote:
> > > > > > -----Original Message-----
> > > > > > From: Kevin Wolf [mailto:kwolf@redhat.com]
> > > > > > Sent: 28 November 2018 16:19
> > > > > > To: Paul Durrant <Paul.Durrant@citrix.com>
> > > > > > Cc: qemu-block@nongnu.org; qemu-devel@nongnu.org; xen-
> > > > > > devel@lists.xenproject.org; Stefano Stabellini
> > > > <sstabellini@kernel.org>;
> > > > > > Eduardo Habkost <ehabkost@redhat.com>; Michael S. Tsirkin
> > > > > > <mst@redhat.com>; Marcel Apfelbaum <marcel.apfelbaum@gmail.com>;
> > > > Anthony
> > > > > > Perard <anthony.perard@citrix.com>; Paolo Bonzini
> > > > <pbonzini@redhat.com>;
> > > > > > Richard Henderson <rth@twiddle.net>
> > > > > > Subject: Re: [Qemu-block] [PATCH 02/18] xen: introduce new
> > 'XenBus'
> > > > and
> > > > > > 'XenDevice' object hierarchy
> > > > > >
> > > > > > Am 21.11.2018 um 16:11 hat Paul Durrant geschrieben:
> > > > > > > This patch adds the basic boilerplate for a 'XenBus' object
> that
> > > > will
> > > > > > act
> > > > > > > as a parent to 'XenDevice' PV backends.
> > > > > > > A new 'XenBridge' object is also added to connect XenBus to
> the
> > > > system
> > > > > > bus.
> > > > > > >
> > > > > > > The XenBus object is instantiated by a new xen_bus_init()
> > function
> > > > > > called
> > > > > > > from the same sites as the legacy xen_be_init() function.
> > > > > > >
> > > > > > > Subsequent patches will flesh-out the functionality of these
> > > > objects.
> > > > > > >
> > > > > > > Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> > > > > >
> > > > > > > diff --git a/hw/xen/xen-bus.c b/hw/xen/xen-bus.c
> > > > > > > new file mode 100644
> > > > > > > index 0000000000..dede2d914a
> > > > > > > --- /dev/null
> > > > > > > +++ b/hw/xen/xen-bus.c
> > > > > > > @@ -0,0 +1,125 @@
> > > > > > > +/*
> > > > > > > + * Copyright (c) Citrix Systems Inc.
> > > > > > > + * All rights reserved.
> > > > > > > + */
> > > > > >
> > > > > > This doesn't look very compatible with the GPL. In fact it might
> > even
> > > > > > make it illegal for the QEMU project to distribute this code. :-
> )
> > > > > >
> > > > > > Other files you add throughout the series seem to have the same
> > > > problem.
> > > > > >
> > > > >
> > > > > I was working on the assumption that a lack of explicit license
> > meant
> > > > that the overall project license as described in item 2 in LICENSE.
> > Did I
> > > > misinterpret that text?
> > > >
> > > > It's "All rights reserved." the problem
> > >
> > > Oh, I see. I'm happy to remove that.
> >
> > That would be better at least. I'm not sure about files that have a
> > copyright header, but no license statement. Do such files exist yet in
> > the source tree?
> 
> Yes, there's quite a few... e.g. (first ones I tripped over)
> hw/rdma/rdma_backend.c, hw/virtio/vhost-backend.c, ...

Oh... I see they have a license statement but no boilerplate... is that statement enough?

  Paul

> 
> > To be on the safe side, I'd just stick with the
> > established practice, which is having a license header in every file.
> 
> Ok... if that is established practice. It really wasn't clear.
> 
> >
> > By the way, in a later patch you remove the existing license header,
> > which is different from the default license (because parts of the source
> > file are GPL 2 only). If you can't prove that all such parts (and parts
> > derived from them) have been removed, this is also a problem.
> >
> 
> What should I do? I am duplicating xen_disk, and then heavily modifying
> it. Should I just leave the old boilerplate in place?
> 
>   Paul
> 
> > Kevin
Eric Blake Nov. 28, 2018, 5:01 p.m. UTC | #9
On 11/28/18 10:26 AM, Paul Durrant wrote:

>>> +++ b/hw/xen/xen-bus.c
>>> @@ -0,0 +1,125 @@
>>> +/*
>>> + * Copyright (c) Citrix Systems Inc.
>>> + * All rights reserved.
>>> + */
>>
>> This doesn't look very compatible with the GPL. In fact it might even
>> make it illegal for the QEMU project to distribute this code. :-)
>>
>> Other files you add throughout the series seem to have the same problem.
>>
> 
> I was working on the assumption that a lack of explicit license meant that the overall project license as described in item 2 in LICENSE. Did I misinterpret that text?

No, but you missed the fact that "All rights reserved" is an explicit 
license (or rather, an explicit anti-license that states you are not 
granting rights that the GPL would normally grant), and an implicit 
license does not apply when an explicit (anti-)license is present.

What's more, relying on implicit licenses is prone to misinterpretation, 
so even though the overall project documentation tries to cover what 
will happen, it's much nicer if you DO use an explicit license mention 
in your file so that we don't HAVE to rely on the implicit license.

Yes, the phrase "All rights reserved" exists in several existing files:

$ git grep -il 'all rights reserved' |wc
     138     138    3557

but we should be striving to clean those up, not adding to the mess.
Paul Durrant Nov. 28, 2018, 5:04 p.m. UTC | #10
> -----Original Message-----
> From: Eric Blake [mailto:eblake@redhat.com]
> Sent: 28 November 2018 17:01
> To: Paul Durrant <Paul.Durrant@citrix.com>; 'Kevin Wolf'
> <kwolf@redhat.com>
> Cc: Stefano Stabellini <sstabellini@kernel.org>; Eduardo Habkost
> <ehabkost@redhat.com>; qemu-block@nongnu.org; Michael S. Tsirkin
> <mst@redhat.com>; qemu-devel@nongnu.org; Paolo Bonzini
> <pbonzini@redhat.com>; Anthony Perard <anthony.perard@citrix.com>; xen-
> devel@lists.xenproject.org; Richard Henderson <rth@twiddle.net>
> Subject: Re: [Qemu-devel] [Qemu-block] [PATCH 02/18] xen: introduce new
> 'XenBus' and 'XenDevice' object hierarchy
> 
> On 11/28/18 10:26 AM, Paul Durrant wrote:
> 
> >>> +++ b/hw/xen/xen-bus.c
> >>> @@ -0,0 +1,125 @@
> >>> +/*
> >>> + * Copyright (c) Citrix Systems Inc.
> >>> + * All rights reserved.
> >>> + */
> >>
> >> This doesn't look very compatible with the GPL. In fact it might even
> >> make it illegal for the QEMU project to distribute this code. :-)
> >>
> >> Other files you add throughout the series seem to have the same
> problem.
> >>
> >
> > I was working on the assumption that a lack of explicit license meant
> that the overall project license as described in item 2 in LICENSE. Did I
> misinterpret that text?
> 
> No, but you missed the fact that "All rights reserved" is an explicit
> license (or rather, an explicit anti-license that states you are not
> granting rights that the GPL would normally grant), and an implicit
> license does not apply when an explicit (anti-)license is present.
> 
> What's more, relying on implicit licenses is prone to misinterpretation,
> so even though the overall project documentation tries to cover what
> will happen, it's much nicer if you DO use an explicit license mention
> in your file so that we don't HAVE to rely on the implicit license.
> 
> Yes, the phrase "All rights reserved" exists in several existing files:
> 
> $ git grep -il 'all rights reserved' |wc
>      138     138    3557
> 
> but we should be striving to clean those up, not adding to the mess.

Ok. I'll send a v2 with the "All rights reserved" removed from and a GPL statement added to all the new files.

  Paul

> 
> --
> Eric Blake, Principal Software Engineer
> Red Hat, Inc.           +1-919-301-3266
> Virtualization:  qemu.org | libvirt.org
Anthony PERARD Nov. 28, 2018, 5:10 p.m. UTC | #11
On Wed, Nov 21, 2018 at 03:11:55PM +0000, Paul Durrant wrote:
> diff --git a/hw/xen/xen-bus.c b/hw/xen/xen-bus.c
> new file mode 100644
> index 0000000000..dede2d914a
> --- /dev/null
> +++ b/hw/xen/xen-bus.c
> @@ -0,0 +1,125 @@
> +/*
> + * Copyright (c) Citrix Systems Inc.
> + * All rights reserved.

You probably should include:
  This work is licensed under the terms of the GNU GPL, version 2 or later.
  See the COPYING file in the top-level directory.

As this seems to be a boilerplate used in recent new files, there are
other similair boilerplates.

Also, I think the copyright line should include a year.

> +void xen_bus_init(void)
> +{
> +    DeviceState *dev = qdev_create(NULL, TYPE_XEN_BRIDGE);
> +
> +    qbus_create(TYPE_XEN_BUS, dev, NULL);
> +    qdev_init_nofail(dev);

Will we need a hotplug handler for this bus, like it is done with
TYPE_XENSYSBUS?


The rest looks good,
Thanks,
Paul Durrant Nov. 28, 2018, 5:17 p.m. UTC | #12
> -----Original Message-----
> From: Anthony PERARD [mailto:anthony.perard@citrix.com]
> Sent: 28 November 2018 17:10
> To: Paul Durrant <Paul.Durrant@citrix.com>
> Cc: qemu-block@nongnu.org; qemu-devel@nongnu.org; xen-
> devel@lists.xenproject.org; Stefano Stabellini <sstabellini@kernel.org>;
> Michael S. Tsirkin <mst@redhat.com>; Marcel Apfelbaum
> <marcel.apfelbaum@gmail.com>; Paolo Bonzini <pbonzini@redhat.com>; Richard
> Henderson <rth@twiddle.net>; Eduardo Habkost <ehabkost@redhat.com>
> Subject: Re: [PATCH 02/18] xen: introduce new 'XenBus' and 'XenDevice'
> object hierarchy
> 
> On Wed, Nov 21, 2018 at 03:11:55PM +0000, Paul Durrant wrote:
> > diff --git a/hw/xen/xen-bus.c b/hw/xen/xen-bus.c
> > new file mode 100644
> > index 0000000000..dede2d914a
> > --- /dev/null
> > +++ b/hw/xen/xen-bus.c
> > @@ -0,0 +1,125 @@
> > +/*
> > + * Copyright (c) Citrix Systems Inc.
> > + * All rights reserved.
> 
> You probably should include:
>   This work is licensed under the terms of the GNU GPL, version 2 or
> later.
>   See the COPYING file in the top-level directory.
> 
> As this seems to be a boilerplate used in recent new files, there are
> other similair boilerplates.
> 
> Also, I think the copyright line should include a year.

Ok.

> 
> > +void xen_bus_init(void)
> > +{
> > +    DeviceState *dev = qdev_create(NULL, TYPE_XEN_BRIDGE);
> > +
> > +    qbus_create(TYPE_XEN_BUS, dev, NULL);
> > +    qdev_init_nofail(dev);
> 
> Will we need a hotplug handler for this bus, like it is done with
> TYPE_XENSYSBUS?

I didn't seem to need one even doing 'xl block-attach' after the VM had booted. I'm really not sure what that does.

  Paul

> 
> 
> The rest looks good,
> Thanks,
> 
> --
> Anthony PERARD
Anthony PERARD Nov. 28, 2018, 5:32 p.m. UTC | #13
On Wed, Nov 28, 2018 at 05:17:10PM +0000, Paul Durrant wrote:
> > Will we need a hotplug handler for this bus, like it is done with
> > TYPE_XENSYSBUS?
> 
> I didn't seem to need one even doing 'xl block-attach' after the VM had booted. I'm really not sure what that does.

Indeed, that works fine, and I think I've tested block-detach as well.
Maybe we will need something if we initiate attach of a block device via
QMP instead of xenstore, but we can fix that later.
Kevin Wolf Nov. 29, 2018, 9:04 a.m. UTC | #14
Am 28.11.2018 um 17:46 hat Paul Durrant geschrieben:
> > -----Original Message-----
> > From: Paul Durrant
> > Sent: 28 November 2018 16:46
> > To: 'Kevin Wolf' <kwolf@redhat.com>
> > Cc: 'Stefano Stabellini' <sstabellini@kernel.org>; qemu-block@nongnu.org;
> > qemu-devel@nongnu.org; xen-devel@lists.xenproject.org; Eduardo Habkost
> > <ehabkost@redhat.com>; Michael S. Tsirkin <mst@redhat.com>; Marcel
> > Apfelbaum <marcel.apfelbaum@gmail.com>; Anthony Perard
> > <anthony.perard@citrix.com>; Paolo Bonzini <pbonzini@redhat.com>; Richard
> > Henderson <rth@twiddle.net>
> > Subject: RE: [Qemu-block] [PATCH 02/18] xen: introduce new 'XenBus' and
> > 'XenDevice' object hierarchy
> > 
> > > -----Original Message-----
> > > From: Kevin Wolf [mailto:kwolf@redhat.com]
> > > Sent: 28 November 2018 16:39
> > > To: Paul Durrant <Paul.Durrant@citrix.com>
> > > Cc: 'Stefano Stabellini' <sstabellini@kernel.org>; qemu-
> > block@nongnu.org;
> > > qemu-devel@nongnu.org; xen-devel@lists.xenproject.org; Eduardo Habkost
> > > <ehabkost@redhat.com>; Michael S. Tsirkin <mst@redhat.com>; Marcel
> > > Apfelbaum <marcel.apfelbaum@gmail.com>; Anthony Perard
> > > <anthony.perard@citrix.com>; Paolo Bonzini <pbonzini@redhat.com>;
> > Richard
> > > Henderson <rth@twiddle.net>
> > > Subject: Re: [Qemu-block] [PATCH 02/18] xen: introduce new 'XenBus' and
> > > 'XenDevice' object hierarchy
> > >
> > > Am 28.11.2018 um 17:29 hat Paul Durrant geschrieben:
> > > > > -----Original Message-----
> > > > > From: Stefano Stabellini [mailto:sstabellini@kernel.org]
> > > > > Sent: 28 November 2018 16:28
> > > > > To: Paul Durrant <Paul.Durrant@citrix.com>
> > > > > Cc: 'Kevin Wolf' <kwolf@redhat.com>; qemu-block@nongnu.org; qemu-
> > > > > devel@nongnu.org; xen-devel@lists.xenproject.org; Stefano Stabellini
> > > > > <sstabellini@kernel.org>; Eduardo Habkost <ehabkost@redhat.com>;
> > > Michael
> > > > > S. Tsirkin <mst@redhat.com>; Marcel Apfelbaum
> > > > > <marcel.apfelbaum@gmail.com>; Anthony Perard
> > > <anthony.perard@citrix.com>;
> > > > > Paolo Bonzini <pbonzini@redhat.com>; Richard Henderson
> > > <rth@twiddle.net>
> > > > > Subject: RE: [Qemu-block] [PATCH 02/18] xen: introduce new 'XenBus'
> > > and
> > > > > 'XenDevice' object hierarchy
> > > > >
> > > > > On Wed, 28 Nov 2018, Paul Durrant wrote:
> > > > > > > -----Original Message-----
> > > > > > > From: Kevin Wolf [mailto:kwolf@redhat.com]
> > > > > > > Sent: 28 November 2018 16:19
> > > > > > > To: Paul Durrant <Paul.Durrant@citrix.com>
> > > > > > > Cc: qemu-block@nongnu.org; qemu-devel@nongnu.org; xen-
> > > > > > > devel@lists.xenproject.org; Stefano Stabellini
> > > > > <sstabellini@kernel.org>;
> > > > > > > Eduardo Habkost <ehabkost@redhat.com>; Michael S. Tsirkin
> > > > > > > <mst@redhat.com>; Marcel Apfelbaum <marcel.apfelbaum@gmail.com>;
> > > > > Anthony
> > > > > > > Perard <anthony.perard@citrix.com>; Paolo Bonzini
> > > > > <pbonzini@redhat.com>;
> > > > > > > Richard Henderson <rth@twiddle.net>
> > > > > > > Subject: Re: [Qemu-block] [PATCH 02/18] xen: introduce new
> > > 'XenBus'
> > > > > and
> > > > > > > 'XenDevice' object hierarchy
> > > > > > >
> > > > > > > Am 21.11.2018 um 16:11 hat Paul Durrant geschrieben:
> > > > > > > > This patch adds the basic boilerplate for a 'XenBus' object
> > that
> > > > > will
> > > > > > > act
> > > > > > > > as a parent to 'XenDevice' PV backends.
> > > > > > > > A new 'XenBridge' object is also added to connect XenBus to
> > the
> > > > > system
> > > > > > > bus.
> > > > > > > >
> > > > > > > > The XenBus object is instantiated by a new xen_bus_init()
> > > function
> > > > > > > called
> > > > > > > > from the same sites as the legacy xen_be_init() function.
> > > > > > > >
> > > > > > > > Subsequent patches will flesh-out the functionality of these
> > > > > objects.
> > > > > > > >
> > > > > > > > Signed-off-by: Paul Durrant <paul.durrant@citrix.com>
> > > > > > >
> > > > > > > > diff --git a/hw/xen/xen-bus.c b/hw/xen/xen-bus.c
> > > > > > > > new file mode 100644
> > > > > > > > index 0000000000..dede2d914a
> > > > > > > > --- /dev/null
> > > > > > > > +++ b/hw/xen/xen-bus.c
> > > > > > > > @@ -0,0 +1,125 @@
> > > > > > > > +/*
> > > > > > > > + * Copyright (c) Citrix Systems Inc.
> > > > > > > > + * All rights reserved.
> > > > > > > > + */
> > > > > > >
> > > > > > > This doesn't look very compatible with the GPL. In fact it might
> > > even
> > > > > > > make it illegal for the QEMU project to distribute this code. :-
> > )
> > > > > > >
> > > > > > > Other files you add throughout the series seem to have the same
> > > > > problem.
> > > > > > >
> > > > > >
> > > > > > I was working on the assumption that a lack of explicit license
> > > meant
> > > > > that the overall project license as described in item 2 in LICENSE.
> > > Did I
> > > > > misinterpret that text?
> > > > >
> > > > > It's "All rights reserved." the problem
> > > >
> > > > Oh, I see. I'm happy to remove that.
> > >
> > > That would be better at least. I'm not sure about files that have a
> > > copyright header, but no license statement. Do such files exist yet in
> > > the source tree?
> > 
> > Yes, there's quite a few... e.g. (first ones I tripped over)
> > hw/rdma/rdma_backend.c, hw/virtio/vhost-backend.c, ...
> 
> Oh... I see they have a license statement but no boilerplate... is
> that statement enough?

Yes, this is good enough.

> > > To be on the safe side, I'd just stick with the
> > > established practice, which is having a license header in every file.
> > 
> > Ok... if that is established practice. It really wasn't clear.
> > 
> > >
> > > By the way, in a later patch you remove the existing license header,
> > > which is different from the default license (because parts of the source
> > > file are GPL 2 only). If you can't prove that all such parts (and parts
> > > derived from them) have been removed, this is also a problem.
> > >
> > 
> > What should I do? I am duplicating xen_disk, and then heavily modifying
> > it. Should I just leave the old boilerplate in place?

Yes. Feel free to add your own copyright line right below Gerd's, but
leave the old stuff intact.

Kevin

Patch
diff mbox series

diff --git a/hw/i386/xen/xen-hvm.c b/hw/i386/xen/xen-hvm.c
index 1d637639c7..4497f751d2 100644
--- a/hw/i386/xen/xen-hvm.c
+++ b/hw/i386/xen/xen-hvm.c
@@ -17,6 +17,7 @@ 
 #include "hw/i386/apic-msidef.h"
 #include "hw/xen/xen_common.h"
 #include "hw/xen/xen-legacy-backend.h"
+#include "hw/xen/xen-bus.h"
 #include "qapi/error.h"
 #include "qapi/qapi-commands-misc.h"
 #include "qemu/error-report.h"
@@ -1479,6 +1480,8 @@  void xen_hvm_init(PCMachineState *pcms, MemoryRegion **ram_memory)
     QLIST_INIT(&state->dev_list);
     device_listener_register(&state->device_listener);
 
+    xen_bus_init();
+
     /* Initialize backend core & drivers */
     if (xen_be_init() != 0) {
         error_report("xen backend core setup failed");
diff --git a/hw/xen/Makefile.objs b/hw/xen/Makefile.objs
index 3f64a44051..d9d6d7b4f9 100644
--- a/hw/xen/Makefile.objs
+++ b/hw/xen/Makefile.objs
@@ -1,5 +1,5 @@ 
 # xen backend driver support
-common-obj-$(CONFIG_XEN) += xen-legacy-backend.o xen_devconfig.o xen_pvdev.o xen-common.o
+common-obj-$(CONFIG_XEN) += xen-legacy-backend.o xen_devconfig.o xen_pvdev.o xen-common.o xen-bus.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
diff --git a/hw/xen/trace-events b/hw/xen/trace-events
index c7e7a3b523..0172cd4e26 100644
--- a/hw/xen/trace-events
+++ b/hw/xen/trace-events
@@ -12,3 +12,9 @@  xen_unmap_portio_range(uint32_t id, uint64_t start_addr, uint64_t end_addr) "id:
 xen_map_pcidev(uint32_t id, uint8_t bus, uint8_t dev, uint8_t func) "id: %u bdf: %02x.%02x.%02x"
 xen_unmap_pcidev(uint32_t id, uint8_t bus, uint8_t dev, uint8_t func) "id: %u bdf: %02x.%02x.%02x"
 xen_domid_restrict(int err) "err: %u"
+
+# include/hw/xen/xen-bus.c
+xen_bus_realize(void) ""
+xen_bus_unrealize(void) ""
+xen_device_realize(const char *type) "type: %s"
+xen_device_unrealize(const char *type) "type: %s"
diff --git a/hw/xen/xen-bus.c b/hw/xen/xen-bus.c
new file mode 100644
index 0000000000..dede2d914a
--- /dev/null
+++ b/hw/xen/xen-bus.c
@@ -0,0 +1,125 @@ 
+/*
+ * Copyright (c) Citrix Systems Inc.
+ * All rights reserved.
+ */
+
+#include "qemu/osdep.h"
+#include "hw/hw.h"
+#include "hw/sysbus.h"
+#include "hw/xen/xen-bus.h"
+#include "qapi/error.h"
+#include "trace.h"
+
+static void xen_bus_unrealize(BusState *bus, Error **errp)
+{
+    trace_xen_bus_unrealize();
+}
+
+static void xen_bus_realize(BusState *bus, Error **errp)
+{
+    trace_xen_bus_realize();
+}
+
+static void xen_bus_class_init(ObjectClass *class, void *data)
+{
+    BusClass *bus_class = BUS_CLASS(class);
+
+    bus_class->realize = xen_bus_realize;
+    bus_class->unrealize = xen_bus_unrealize;
+}
+
+static const TypeInfo xen_bus_type_info = {
+    .name = TYPE_XEN_BUS,
+    .parent = TYPE_BUS,
+    .instance_size = sizeof(XenBus),
+    .class_size = sizeof(XenBusClass),
+    .class_init = xen_bus_class_init,
+};
+
+static void xen_device_unrealize(DeviceState *dev, Error **errp)
+{
+    XenDevice *xendev = XEN_DEVICE(dev);
+    XenDeviceClass *xendev_class = XEN_DEVICE_GET_CLASS(xendev);
+    const char *type = object_get_typename(OBJECT(xendev));
+    Error *local_err = NULL;
+
+    trace_xen_device_unrealize(type);
+
+    if (xendev_class->unrealize) {
+        xendev_class->unrealize(xendev, &local_err);
+        if (local_err) {
+            error_propagate(errp, local_err);
+            return;
+        }
+    }
+}
+
+static void xen_device_realize(DeviceState *dev, Error **errp)
+{
+    XenDevice *xendev = XEN_DEVICE(dev);
+    XenDeviceClass *xendev_class = XEN_DEVICE_GET_CLASS(xendev);
+    const char *type = object_get_typename(OBJECT(xendev));
+    Error *local_err = NULL;
+
+    trace_xen_device_realize(type);
+
+    if (xendev_class->realize) {
+        xendev_class->realize(xendev, &local_err);
+        if (local_err) {
+            error_propagate(errp, local_err);
+            goto unrealize;
+        }
+    }
+
+    return;
+
+unrealize:
+    xen_device_unrealize(dev, &error_abort);
+}
+
+static void xen_device_class_init(ObjectClass *class, void *data)
+{
+    DeviceClass *dev_class = DEVICE_CLASS(class);
+
+    dev_class->realize = xen_device_realize;
+    dev_class->unrealize = xen_device_unrealize;
+    dev_class->bus_type = TYPE_XEN_BUS;
+}
+
+static const TypeInfo xen_device_type_info = {
+    .name = TYPE_XEN_DEVICE,
+    .parent = TYPE_DEVICE,
+    .instance_size = sizeof(XenDevice),
+    .abstract = true,
+    .class_size = sizeof(XenDeviceClass),
+    .class_init = xen_device_class_init,
+};
+
+typedef struct XenBridge {
+    SysBusDevice busdev;
+} XenBridge;
+
+#define TYPE_XEN_BRIDGE "xen-bridge"
+
+static const TypeInfo xen_bridge_type_info = {
+    .name = TYPE_XEN_BRIDGE,
+    .parent = TYPE_SYS_BUS_DEVICE,
+    .instance_size = sizeof(XenBridge),
+};
+
+static void xen_register_types(void)
+{
+    type_register_static(&xen_bridge_type_info);
+    type_register_static(&xen_bus_type_info);
+    type_register_static(&xen_device_type_info);
+}
+
+type_init(xen_register_types)
+
+void xen_bus_init(void)
+{
+    DeviceState *dev = qdev_create(NULL, TYPE_XEN_BRIDGE);
+
+    qbus_create(TYPE_XEN_BUS, dev, NULL);
+    qdev_init_nofail(dev);
+}
diff --git a/hw/xenpv/xen_machine_pv.c b/hw/xenpv/xen_machine_pv.c
index 8c86fb7031..608e591bcc 100644
--- a/hw/xenpv/xen_machine_pv.c
+++ b/hw/xenpv/xen_machine_pv.c
@@ -27,6 +27,7 @@ 
 #include "hw/hw.h"
 #include "hw/boards.h"
 #include "hw/xen/xen-legacy-backend.h"
+#include "hw/xen/xen-bus.h"
 #include "xen_domainbuild.h"
 #include "sysemu/block-backend.h"
 
@@ -93,6 +94,8 @@  static void xen_init_pv(MachineState *machine)
         xen_config_dev_nic(nd_table + i);
     }
 
+    xen_bus_init();
+
     /* config cleanup hook */
     atexit(xen_config_cleanup);
 }
diff --git a/include/hw/xen/xen-bus.h b/include/hw/xen/xen-bus.h
new file mode 100644
index 0000000000..41772dc73a
--- /dev/null
+++ b/include/hw/xen/xen-bus.h
@@ -0,0 +1,53 @@ 
+/*
+ * Copyright (c) Citrix Systems Inc.
+ * All rights reserved.
+ */
+
+#ifndef HW_XEN_BUS_H
+#define HW_XEN_BUS_H
+
+#include "hw/sysbus.h"
+
+typedef struct XenDevice {
+    DeviceState qdev;
+} XenDevice;
+
+typedef void (*XenDeviceRealize)(XenDevice *xendev, Error **errp);
+typedef void (*XenDeviceUnrealize)(XenDevice *xendev, Error **errp);
+
+typedef struct XenDeviceClass {
+    /*< private >*/
+    DeviceClass parent_class;
+    /*< public >*/
+    XenDeviceRealize realize;
+    XenDeviceUnrealize unrealize;
+} XenDeviceClass;
+
+#define TYPE_XEN_DEVICE "xen-device"
+#define XEN_DEVICE(obj) \
+     OBJECT_CHECK(XenDevice, (obj), TYPE_XEN_DEVICE)
+#define XEN_DEVICE_CLASS(class) \
+     OBJECT_CLASS_CHECK(XenDeviceClass, (class), TYPE_XEN_DEVICE)
+#define XEN_DEVICE_GET_CLASS(obj) \
+     OBJECT_GET_CLASS(XenDeviceClass, (obj), TYPE_XEN_DEVICE)
+
+typedef struct XenBus {
+    BusState qbus;
+} XenBus;
+
+typedef struct XenBusClass {
+    /*< private >*/
+    BusClass parent_class;
+} XenBusClass;
+
+#define TYPE_XEN_BUS "xen-bus"
+#define XEN_BUS(obj) \
+    OBJECT_CHECK(XenBus, (obj), TYPE_XEN_BUS)
+#define XEN_BUS_CLASS(class) \
+    OBJECT_CLASS_CHECK(XenBusClass, (class), TYPE_XEN_BUS)
+#define XEN_BUS_GET_CLASS(obj) \
+    OBJECT_GET_CLASS(XenBusClass, (obj), TYPE_XEN_BUS)
+
+void xen_bus_init(void);
+
+#endif /* HW_XEN_BUS_H */