qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL for-2.2 0/2] Xen tree 2014-11-14
@ 2014-11-14 11:29 Stefano Stabellini
  2014-11-14 11:30 ` [Qemu-devel] [PULL for-2.2 1/2] pc: piix4_pm: init legacy PCI hotplug when running on Xen Stefano Stabellini
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Stefano Stabellini @ 2014-11-14 11:29 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell, xen-devel, Stefano Stabellini

The following changes since commit c52e67924fbdadfa00668248f5c075542943c54c:

  Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging (2014-11-13 15:44:16 +0000)

are available in the git repository at:


  git://xenbits.xen.org/people/sstabellini/qemu-dm.git xen-2014-11-14

for you to fetch changes up to 2f01dfacb56bc7a0d4639adc9dff9aae131e6216:

  xen_disk: fix unmapping of persistent grants (2014-11-14 11:12:38 +0000)

----------------------------------------------------------------
Igor Mammedov (1):
      pc: piix4_pm: init legacy PCI hotplug when running on Xen

Roger Pau Monne (1):
      xen_disk: fix unmapping of persistent grants

 hw/acpi/piix4.c     |    4 +++
 hw/block/xen_disk.c |   72 ++++++++++++++++++++++++++++++++++++++++++++++-----
 hw/i386/pc_piix.c   |   11 --------
 3 files changed, 70 insertions(+), 17 deletions(-)

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PULL for-2.2 1/2] pc: piix4_pm: init legacy PCI hotplug when running on Xen
  2014-11-14 11:29 [Qemu-devel] [PULL for-2.2 0/2] Xen tree 2014-11-14 Stefano Stabellini
@ 2014-11-14 11:30 ` Stefano Stabellini
  2014-11-14 11:30 ` [Qemu-devel] [PULL for-2.2 2/2] xen_disk: fix unmapping of persistent grants Stefano Stabellini
  2014-11-14 13:28 ` [Qemu-devel] [PULL for-2.2 0/2] Xen tree 2014-11-14 Peter Maydell
  2 siblings, 0 replies; 4+ messages in thread
From: Stefano Stabellini @ 2014-11-14 11:30 UTC (permalink / raw)
  To: qemu-devel
  Cc: peter.maydell, Igor Mammedov, xen-devel, Li Liang,
	Stefano Stabellini

From: Igor Mammedov <imammedo@redhat.com>

If user starts QEMU with "-machine pc,accel=xen", then
compat property in xenfv won't work and it would cause error:
"Unsupported bus. Bus doesn't have property 'acpi-pcihp-bsel' set"
when PCI device is added with -device on QEMU CLI.

From: Igor Mammedov <imammedo@redhat.com>

In case of Xen instead of using compat property, just use the fact
that xen doesn't use QEMU's fw_cfg/acpi tables to switch piix4_pm
into legacy PCI hotplug mode when Xen is enabled.

Signed-off-by: Igor Mammedov <imammedo@redhat.com>
Signed-off-by: Li Liang <liang.z.li@intel.com>
Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Acked-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/acpi/piix4.c   |    4 ++++
 hw/i386/pc_piix.c |   11 -----------
 2 files changed, 4 insertions(+), 11 deletions(-)

diff --git a/hw/acpi/piix4.c b/hw/acpi/piix4.c
index 78c0a6d..481a16c 100644
--- a/hw/acpi/piix4.c
+++ b/hw/acpi/piix4.c
@@ -36,6 +36,7 @@
 #include "hw/mem/pc-dimm.h"
 #include "hw/acpi/memory_hotplug.h"
 #include "hw/acpi/acpi_dev_interface.h"
+#include "hw/xen/xen.h"
 
 //#define DEBUG
 
@@ -501,6 +502,9 @@ I2CBus *piix4_pm_init(PCIBus *bus, int devfn, uint32_t smb_io_base,
     s->irq = sci_irq;
     s->smi_irq = smi_irq;
     s->kvm_enabled = kvm_enabled;
+    if (xen_enabled()) {
+        s->use_acpi_pci_hotplug = false;
+    }
 
     qdev_init_nofail(dev);
 
diff --git a/hw/i386/pc_piix.c b/hw/i386/pc_piix.c
index b559181..7bb97a4 100644
--- a/hw/i386/pc_piix.c
+++ b/hw/i386/pc_piix.c
@@ -916,17 +916,6 @@ static QEMUMachine xenfv_machine = {
     .max_cpus = HVM_MAX_VCPUS,
     .default_machine_opts = "accel=xen",
     .hot_add_cpu = pc_hot_add_cpu,
-    .compat_props = (GlobalProperty[]) {
-        /* xenfv has no fwcfg and so does not load acpi from QEMU.
-         * as such new acpi features don't work.
-         */
-        {
-            .driver   = "PIIX4_PM",
-            .property = "acpi-pci-hotplug-with-bridge-support",
-            .value    = "off",
-        },
-        { /* end of list */ }
-    },
 };
 #endif
 
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [Qemu-devel] [PULL for-2.2 2/2] xen_disk: fix unmapping of persistent grants
  2014-11-14 11:29 [Qemu-devel] [PULL for-2.2 0/2] Xen tree 2014-11-14 Stefano Stabellini
  2014-11-14 11:30 ` [Qemu-devel] [PULL for-2.2 1/2] pc: piix4_pm: init legacy PCI hotplug when running on Xen Stefano Stabellini
@ 2014-11-14 11:30 ` Stefano Stabellini
  2014-11-14 13:28 ` [Qemu-devel] [PULL for-2.2 0/2] Xen tree 2014-11-14 Peter Maydell
  2 siblings, 0 replies; 4+ messages in thread
From: Stefano Stabellini @ 2014-11-14 11:30 UTC (permalink / raw)
  To: qemu-devel
  Cc: Kevin Wolf, peter.maydell, xen-devel, Stefano Stabellini,
	George Dunlap, Konrad Rzeszutek Wilk, Stefan Hajnoczi,
	Roger Pau Monne

From: Roger Pau Monne <roger.pau@citrix.com>

This patch fixes two issues with persistent grants and the disk PV backend
(Qdisk):

 - Keep track of memory regions where persistent grants have been mapped
   since we need to unmap them as a whole. It is not possible to unmap a
   single grant if it has been batch-mapped. A new check has also been added
   to make sure persistent grants are only used if the whole mapped region
   can be persistently mapped in the batch_maps case.
 - Unmap persistent grants before switching to the closed state, so the
   frontend can also free them.

Signed-off-by: Roger Pau Monné <roger.pau@citrix.com>
Reported-by: George Dunlap <george.dunlap@eu.citrix.com>
Cc: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Cc: Kevin Wolf <kwolf@redhat.com>
Cc: Stefan Hajnoczi <stefanha@redhat.com>
Cc: George Dunlap <george.dunlap@eu.citrix.com>
Cc: Konrad Rzeszutek Wilk <konrad.wilk@oracle.com>
---
 hw/block/xen_disk.c |   72 ++++++++++++++++++++++++++++++++++++++++++++++-----
 1 file changed, 66 insertions(+), 6 deletions(-)

diff --git a/hw/block/xen_disk.c b/hw/block/xen_disk.c
index 231e9a7..21842a0 100644
--- a/hw/block/xen_disk.c
+++ b/hw/block/xen_disk.c
@@ -59,6 +59,13 @@ struct PersistentGrant {
 
 typedef struct PersistentGrant PersistentGrant;
 
+struct PersistentRegion {
+    void *addr;
+    int num;
+};
+
+typedef struct PersistentRegion PersistentRegion;
+
 struct ioreq {
     blkif_request_t     req;
     int16_t             status;
@@ -118,6 +125,7 @@ struct XenBlkDev {
     gboolean            feature_discard;
     gboolean            feature_persistent;
     GTree               *persistent_gnts;
+    GSList              *persistent_regions;
     unsigned int        persistent_gnt_count;
     unsigned int        max_grants;
 
@@ -177,6 +185,23 @@ static void destroy_grant(gpointer pgnt)
     g_free(grant);
 }
 
+static void remove_persistent_region(gpointer data, gpointer dev)
+{
+    PersistentRegion *region = data;
+    struct XenBlkDev *blkdev = dev;
+    XenGnttab gnt = blkdev->xendev.gnttabdev;
+
+    if (xc_gnttab_munmap(gnt, region->addr, region->num) != 0) {
+        xen_be_printf(&blkdev->xendev, 0,
+                      "xc_gnttab_munmap region %p failed: %s\n",
+                      region->addr, strerror(errno));
+    }
+    xen_be_printf(&blkdev->xendev, 3,
+                  "unmapped grant region %p with %d pages\n",
+                  region->addr, region->num);
+    g_free(region);
+}
+
 static struct ioreq *ioreq_start(struct XenBlkDev *blkdev)
 {
     struct ioreq *ioreq = NULL;
@@ -343,6 +368,7 @@ static int ioreq_map(struct ioreq *ioreq)
     void *page[BLKIF_MAX_SEGMENTS_PER_REQUEST];
     int i, j, new_maps = 0;
     PersistentGrant *grant;
+    PersistentRegion *region;
     /* domids and refs variables will contain the information necessary
      * to map the grants that are needed to fulfill this request.
      *
@@ -421,7 +447,22 @@ static int ioreq_map(struct ioreq *ioreq)
             }
         }
     }
-    if (ioreq->blkdev->feature_persistent) {
+    if (ioreq->blkdev->feature_persistent && new_maps != 0 &&
+        (!batch_maps || (ioreq->blkdev->persistent_gnt_count + new_maps <=
+        ioreq->blkdev->max_grants))) {
+        /*
+         * If we are using persistent grants and batch mappings only
+         * add the new maps to the list of persistent grants if the whole
+         * area can be persistently mapped.
+         */
+        if (batch_maps) {
+            region = g_malloc0(sizeof(*region));
+            region->addr = ioreq->pages;
+            region->num = new_maps;
+            ioreq->blkdev->persistent_regions = g_slist_append(
+                                            ioreq->blkdev->persistent_regions,
+                                            region);
+        }
         while ((ioreq->blkdev->persistent_gnt_count < ioreq->blkdev->max_grants)
               && new_maps) {
             /* Go through the list of newly mapped grants and add as many
@@ -447,6 +488,7 @@ static int ioreq_map(struct ioreq *ioreq)
                           grant);
             ioreq->blkdev->persistent_gnt_count++;
         }
+        assert(!batch_maps || new_maps == 0);
     }
     for (i = 0; i < ioreq->v.niov; i++) {
         ioreq->v.iov[i].iov_base += (uintptr_t)page[i];
@@ -971,7 +1013,10 @@ static int blk_connect(struct XenDevice *xendev)
         blkdev->max_grants = max_requests * BLKIF_MAX_SEGMENTS_PER_REQUEST;
         blkdev->persistent_gnts = g_tree_new_full((GCompareDataFunc)int_cmp,
                                              NULL, NULL,
+                                             batch_maps ?
+                                             (GDestroyNotify)g_free :
                                              (GDestroyNotify)destroy_grant);
+        blkdev->persistent_regions = NULL;
         blkdev->persistent_gnt_count = 0;
     }
 
@@ -1000,6 +1045,26 @@ static void blk_disconnect(struct XenDevice *xendev)
         blkdev->cnt_map--;
         blkdev->sring = NULL;
     }
+
+    /*
+     * Unmap persistent grants before switching to the closed state
+     * so the frontend can free them.
+     *
+     * In the !batch_maps case g_tree_destroy will take care of unmapping
+     * the grant, but in the batch_maps case we need to iterate over every
+     * region in persistent_regions and unmap it.
+     */
+    if (blkdev->feature_persistent) {
+        g_tree_destroy(blkdev->persistent_gnts);
+        assert(batch_maps || blkdev->persistent_gnt_count == 0);
+        if (batch_maps) {
+            blkdev->persistent_gnt_count = 0;
+            g_slist_foreach(blkdev->persistent_regions,
+                            (GFunc)remove_persistent_region, blkdev);
+            g_slist_free(blkdev->persistent_regions);
+        }
+        blkdev->feature_persistent = false;
+    }
 }
 
 static int blk_free(struct XenDevice *xendev)
@@ -1011,11 +1076,6 @@ static int blk_free(struct XenDevice *xendev)
         blk_disconnect(xendev);
     }
 
-    /* Free persistent grants */
-    if (blkdev->feature_persistent) {
-        g_tree_destroy(blkdev->persistent_gnts);
-    }
-
     while (!QLIST_EMPTY(&blkdev->freelist)) {
         ioreq = QLIST_FIRST(&blkdev->freelist);
         QLIST_REMOVE(ioreq, list);
-- 
1.7.10.4

^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [Qemu-devel] [PULL for-2.2 0/2] Xen tree 2014-11-14
  2014-11-14 11:29 [Qemu-devel] [PULL for-2.2 0/2] Xen tree 2014-11-14 Stefano Stabellini
  2014-11-14 11:30 ` [Qemu-devel] [PULL for-2.2 1/2] pc: piix4_pm: init legacy PCI hotplug when running on Xen Stefano Stabellini
  2014-11-14 11:30 ` [Qemu-devel] [PULL for-2.2 2/2] xen_disk: fix unmapping of persistent grants Stefano Stabellini
@ 2014-11-14 13:28 ` Peter Maydell
  2 siblings, 0 replies; 4+ messages in thread
From: Peter Maydell @ 2014-11-14 13:28 UTC (permalink / raw)
  To: Stefano Stabellini; +Cc: xen-devel@lists.xensource.com Devel, QEMU Developers

On 14 November 2014 11:29, Stefano Stabellini
<stefano.stabellini@eu.citrix.com> wrote:
> The following changes since commit c52e67924fbdadfa00668248f5c075542943c54c:
>
>   Merge remote-tracking branch 'remotes/bonzini/tags/for-upstream' into staging (2014-11-13 15:44:16 +0000)
>
> are available in the git repository at:
>
>
>   git://xenbits.xen.org/people/sstabellini/qemu-dm.git xen-2014-11-14
>
> for you to fetch changes up to 2f01dfacb56bc7a0d4639adc9dff9aae131e6216:
>
>   xen_disk: fix unmapping of persistent grants (2014-11-14 11:12:38 +0000)
>
> ----------------------------------------------------------------
> Igor Mammedov (1):
>       pc: piix4_pm: init legacy PCI hotplug when running on Xen
>
> Roger Pau Monne (1):
>       xen_disk: fix unmapping of persistent grants
>
>  hw/acpi/piix4.c     |    4 +++
>  hw/block/xen_disk.c |   72 ++++++++++++++++++++++++++++++++++++++++++++++-----
>  hw/i386/pc_piix.c   |   11 --------
>  3 files changed, 70 insertions(+), 17 deletions(-)

Applied, thanks.

-- PMM

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2014-11-14 13:28 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-11-14 11:29 [Qemu-devel] [PULL for-2.2 0/2] Xen tree 2014-11-14 Stefano Stabellini
2014-11-14 11:30 ` [Qemu-devel] [PULL for-2.2 1/2] pc: piix4_pm: init legacy PCI hotplug when running on Xen Stefano Stabellini
2014-11-14 11:30 ` [Qemu-devel] [PULL for-2.2 2/2] xen_disk: fix unmapping of persistent grants Stefano Stabellini
2014-11-14 13:28 ` [Qemu-devel] [PULL for-2.2 0/2] Xen tree 2014-11-14 Peter Maydell

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).