qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: "Michael S. Tsirkin" <mst@redhat.com>
To: Igor Mammedov <imammedo@redhat.com>
Cc: Gal Hammer <ghammer@redhat.com>, qemu-devel@nongnu.org
Subject: Re: [Qemu-devel] [PATCH V15 4/5] i386: add a Virtual Machine Generation ID device
Date: Wed, 3 Jun 2015 18:32:00 +0200	[thread overview]
Message-ID: <20150603183107-mutt-send-email-mst@redhat.com> (raw)
In-Reply-To: <20150529134644.67bbfd27@nial.brq.redhat.com>

On Fri, May 29, 2015 at 01:46:44PM +0200, Igor Mammedov wrote:
> On Mon, 27 Apr 2015 14:19:50 +0300
> Gal Hammer <ghammer@redhat.com> wrote:
> 
> > Based on Microsoft's sepecifications (paper can be dowloaded from
> > http://go.microsoft.com/fwlink/?LinkId=260709), add a device
> > description to the SSDT ACPI table and its implementation.
> > 
> > The GUID is set using a global "vmgenid.uuid" parameter.
> > 
> > Signed-off-by: Gal Hammer <ghammer@redhat.com>
> > ---
> >  default-configs/i386-softmmu.mak   |   1 +
> >  default-configs/x86_64-softmmu.mak |   1 +
> >  hw/i386/acpi-build.c               |  41 +++++++++++++
> >  hw/i386/pc.c                       |   8 +++
> >  hw/misc/Makefile.objs              |   1 +
> >  hw/misc/vmgenid.c                  | 116 +++++++++++++++++++++++++++++++++++++
> >  include/hw/i386/pc.h               |   3 +
> >  include/hw/misc/vmgenid.h          |  21 +++++++
> >  8 files changed, 192 insertions(+)
> >  create mode 100644 hw/misc/vmgenid.c
> >  create mode 100644 include/hw/misc/vmgenid.h
> > 
> > diff --git a/default-configs/i386-softmmu.mak b/default-configs/i386-softmmu.mak
> > index 6a74e00..9fc0a3c 100644
> > --- a/default-configs/i386-softmmu.mak
> > +++ b/default-configs/i386-softmmu.mak
> > @@ -45,3 +45,4 @@ CONFIG_MEM_HOTPLUG=y
> >  CONFIG_XIO3130=y
> >  CONFIG_IOH3420=y
> >  CONFIG_I82801B11=y
> > +CONFIG_VMGENID=y
> > diff --git a/default-configs/x86_64-softmmu.mak b/default-configs/x86_64-softmmu.mak
> > index 46b87dd..f66fd3c 100644
> > --- a/default-configs/x86_64-softmmu.mak
> > +++ b/default-configs/x86_64-softmmu.mak
> > @@ -45,3 +45,4 @@ CONFIG_MEM_HOTPLUG=y
> >  CONFIG_XIO3130=y
> >  CONFIG_IOH3420=y
> >  CONFIG_I82801B11=y
> > +CONFIG_VMGENID=y
> > diff --git a/hw/i386/acpi-build.c b/hw/i386/acpi-build.c
> > index e761005..8d1a761 100644
> > --- a/hw/i386/acpi-build.c
> > +++ b/hw/i386/acpi-build.c
> > @@ -42,6 +42,7 @@
> >  #include "hw/acpi/memory_hotplug.h"
> >  #include "sysemu/tpm.h"
> >  #include "hw/acpi/tpm.h"
> > +#include "hw/misc/vmgenid.h"
> >  
> >  /* Supported chipsets: */
> >  #include "hw/acpi/piix4.h"
> > @@ -116,6 +117,7 @@ typedef struct AcpiMiscInfo {
> >      unsigned dsdt_size;
> >      uint16_t pvpanic_port;
> >      uint16_t applesmc_io_base;
> > +    bool vm_generation_id_set;
> >  } AcpiMiscInfo;
> >  
> >  typedef struct AcpiBuildPciBusHotplugState {
> > @@ -242,6 +244,7 @@ static void acpi_get_misc_info(AcpiMiscInfo *info)
> >      info->has_tpm = tpm_find();
> >      info->pvpanic_port = pvpanic_port();
> >      info->applesmc_io_base = applesmc_port();
> > +    info->vm_generation_id_set = vm_generation_id_set();
> >  }
> >  
> >  static void acpi_get_pci_info(PcPciInfo *info)
> > @@ -815,6 +818,44 @@ build_ssdt(GArray *table_data, GArray *linker,
> >          aml_append(ssdt, scope);
> >      }
> >  
> > +    if (misc->vm_generation_id_set) {
> would be better to make it conditional depending on if vmgenid device is present
> 
> > +        scope = aml_scope("\\_SB");
> > +
> > +        dev = aml_device("VMGI");
> 
> [...]
> 
> > +
> > +    vmgenid = qdev_try_create(NULL, VMGENID_DEVICE);
> > +    if (vmgenid) {
> > +        qdev_init_nofail(vmgenid);
> > +        sysbus_mmio_map(SYS_BUS_DEVICE(vmgenid), 0, VMGENID_BASE_ADDRESS);
> > +    }
> it should be possible not to create device if user haven't asked for it,
> my guess is that you are using sysbus device as a convenience for mapping.
> 
> I'd suggest to use plain Device type instead, with it
> vmgenid would be created when management asks for it using CLI:
>   -device vmgenid,uuid=XXXX
> and from mgmt side it would treat device as any other device using the same APIs.
> 
> Mapping device to board is also simple, for example see:
> 
> pc_machine_device_plug_cb()->pc_dimm_plug()->memory_region_add_subregion()
> 
> for PC machine pc_machine_device_plug_cb() callback is called for
> every bus-less device during device_realize() time
>    hw/core/qdev.c:hotplug_handler_plug(hotplug_ctrl, dev, &local_err);
> 
> you just need to add something like:
>   pc_vmgenid_plug()
> 	addr = object_property_get_int(dev, VMGENID_BASE_ADDR_PROP, &local_err);
>         VMGenIdDeviceClass vmgidc = CAST(dev)
> 	memory_region_add_subregion(&system_memory, addr, vmgidc->get_memory_region());
> 
> [...]
> 

Yes, I think it is best not to add devices by default, -device is safer.

> > +
> > +#define VMGENID_BASE_ADDRESS    0xfedf0000
> I'd make it a property, so that every target would be able to set
> its own value when times come and ACPI part would automatically pick it up,
> it also helps with test cases.

I think there's no need for this change as we plan
to modify this code down the road anyway.

> > +#define VMGENID_BASE_ADDR_LEN   16
> > +
> > +#endif

  reply	other threads:[~2015-06-03 16:32 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-04-27 11:19 [Qemu-devel] [PATCH V15 0/5] Virtual Machine Generation ID Gal Hammer
2015-04-27 11:19 ` [Qemu-devel] [PATCH V15 1/5] docs: vm generation id device's description Gal Hammer
2015-04-27 13:42   ` Michael S. Tsirkin
2015-04-27 13:55   ` Michael S. Tsirkin
2015-04-28 14:20     ` Gal Hammer
2015-04-27 14:56   ` Eric Blake
2015-04-28 14:38     ` Gal Hammer
2015-04-27 11:19 ` [Qemu-devel] [PATCH V15 2/5] acpi: add a vm_generation_id_changed method Gal Hammer
2015-04-27 14:57   ` Eric Blake
2015-04-27 11:19 ` [Qemu-devel] [PATCH V15 3/5] aml: implement a 32-bit fixed memory range descriptor Gal Hammer
2015-04-27 11:19 ` [Qemu-devel] [PATCH V15 4/5] i386: add a Virtual Machine Generation ID device Gal Hammer
2015-04-27 13:38   ` Michael S. Tsirkin
2015-04-29 12:46     ` Gal Hammer
2015-04-27 14:59   ` Eric Blake
2015-05-28 10:25   ` Paolo Bonzini
2015-05-28 11:49     ` Michael S. Tsirkin
2015-05-28 11:59     ` Gal Hammer
2015-05-28 12:21       ` Michael S. Tsirkin
2015-05-28 13:00         ` Paolo Bonzini
2015-05-28 13:24           ` Michael S. Tsirkin
2015-05-28 13:35             ` Paolo Bonzini
2015-05-29 11:46   ` Igor Mammedov
2015-06-03 16:32     ` Michael S. Tsirkin [this message]
2015-06-03 16:37   ` Paolo Bonzini
2015-06-08 13:42     ` Gal Hammer
2015-06-08 13:43       ` Paolo Bonzini
2015-06-08 13:52         ` Gal Hammer
2015-06-08 13:55           ` Paolo Bonzini
2015-06-08 13:58             ` Daniel P. Berrange
2015-06-08 14:05               ` Gal Hammer
2015-06-08 15:01               ` Michael S. Tsirkin
2015-06-08 15:17                 ` Paolo Bonzini
2015-06-08 15:22                   ` Michael S. Tsirkin
2015-06-08 15:28                     ` Gal Hammer
2015-06-08 15:32                       ` Michael S. Tsirkin
2015-06-08 15:33                     ` Paolo Bonzini
2015-06-08 15:41                       ` Michael S. Tsirkin
2015-06-08 15:43                         ` Paolo Bonzini
2015-06-08 14:00             ` Gal Hammer
2015-06-08 13:59               ` Paolo Bonzini
2015-04-27 11:19 ` [Qemu-devel] [PATCH V15 5/5] tests: add a unit test for the vmgenid device Gal Hammer
2015-04-27 15:01   ` Eric Blake
2015-04-27 16:17     ` Michael S. Tsirkin

Reply instructions:

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

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

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

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

  git send-email \
    --in-reply-to=20150603183107-mutt-send-email-mst@redhat.com \
    --to=mst@redhat.com \
    --cc=ghammer@redhat.com \
    --cc=imammedo@redhat.com \
    --cc=qemu-devel@nongnu.org \
    /path/to/YOUR_REPLY

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

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