qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [Qemu-devel] [PULL 00/12] Xen patch queue 2011-07-05
@ 2011-07-05 16:51 Alexander Graf
  2011-07-05 16:51 ` [Qemu-devel] [PATCH 01/12] xen: Clean up build system Alexander Graf
                   ` (12 more replies)
  0 siblings, 13 replies; 15+ messages in thread
From: Alexander Graf @ 2011-07-05 16:51 UTC (permalink / raw)
  To: qemu-devel@nongnu.org Developers; +Cc: xen-devel@lists.xensource.com Devel

Hi Anthony,

This is my current patch queue for Xen stuff that accumulated over
the past few weeks.

Please pull.

Alex

The following changes since commit 9312805d33e8b106bae356d13a8071fb37d75554:
  Vasily Khoruzhick (1):
        pxa2xx_lcd: add proper rotation support

are available in the git repository at:

  git://repo.or.cz/qemu/agraf.git xen-next

Alexander Graf (2):
      checkpatch: don't error out on },{ lines
      xen_console: fall back to qemu serial device

Jan Kiszka (3):
      xen: Clean up build system
      xen: Clean up map cache API naming
      xen: Fold CONFIG_XEN_MAPCACHE into CONFIG_XEN

Stefano Stabellini (7):
      xen: enable console and disk backend in HVM mode
      xen_console: fix memory leak
      xen: add vkbd support for PV on HVM guests
      xen_disk: cope with missing xenstore "params" node
      qemu_ram_ptr_length: take ram_addr_t as arguments
      xen_disk: treat "aio" as "raw"
      xen_console: support the new extended xenstore protocol

 Makefile.objs         |    4 +-
 Makefile.target       |   14 +--------
 configure             |    2 +-
 cpu-common.h          |    2 +-
 exec.c                |   55 +++++++++++++++++++++---------------
 hw/xen.h              |   10 +------
 hw/xen_common.h       |   12 ++++++++
 hw/xen_console.c      |   25 ++++++++++++-----
 hw/xen_disk.c         |   37 ++++++++++++++++++++-----
 hw/xenfb.c            |   19 ++++++++-----
 scripts/checkpatch.pl |    4 ++-
 trace-events          |    6 ++--
 xen-all.c             |   73 +++++++++++++++++++++++++++++++++++++++++++++++-
 xen-mapcache-stub.c   |   36 ------------------------
 xen-mapcache.c        |   41 +++++++++++++++------------
 xen-mapcache.h        |   14 ++++-----
 16 files changed, 217 insertions(+), 137 deletions(-)
 delete mode 100644 xen-mapcache-stub.c

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

* [Qemu-devel] [PATCH 01/12] xen: Clean up build system
  2011-07-05 16:51 [Qemu-devel] [PULL 00/12] Xen patch queue 2011-07-05 Alexander Graf
@ 2011-07-05 16:51 ` Alexander Graf
  2011-07-05 16:51 ` [Qemu-devel] [PATCH 02/12] xen: Clean up map cache API naming Alexander Graf
                   ` (11 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: Alexander Graf @ 2011-07-05 16:51 UTC (permalink / raw)
  To: qemu-devel@nongnu.org Developers
  Cc: Jan Kiszka, xen-devel@lists.xensource.com Devel

From: Jan Kiszka <jan.kiszka@siemens.com>

Introduce CONFIG_XEN_BACKEND so that this new config solely controls the
target-independent backend build and CONFIG_XEN can focus on per-target
building.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
 Makefile.objs   |    4 ++--
 Makefile.target |   13 +++----------
 configure       |    2 +-
 3 files changed, 6 insertions(+), 13 deletions(-)

diff --git a/Makefile.objs b/Makefile.objs
index cea15e4..1635df6 100644
--- a/Makefile.objs
+++ b/Makefile.objs
@@ -155,8 +155,8 @@ slirp-obj-y += tcp_subr.o tcp_timer.o udp.o bootp.o tftp.o
 common-obj-$(CONFIG_SLIRP) += $(addprefix slirp/, $(slirp-obj-y))
 
 # xen backend driver support
-common-obj-$(CONFIG_XEN) += xen_backend.o xen_devconfig.o
-common-obj-$(CONFIG_XEN) += xen_console.o xenfb.o xen_disk.o xen_nic.o
+common-obj-$(CONFIG_XEN_BACKEND) += xen_backend.o xen_devconfig.o
+common-obj-$(CONFIG_XEN_BACKEND) += xen_console.o xenfb.o xen_disk.o xen_nic.o
 
 ######################################################################
 # libuser
diff --git a/Makefile.target b/Makefile.target
index a53a2ff..c347176 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -3,6 +3,8 @@
 GENERATED_HEADERS = config-target.h
 CONFIG_NO_PCI = $(if $(subst n,,$(CONFIG_PCI)),n,y)
 CONFIG_NO_KVM = $(if $(subst n,,$(CONFIG_KVM)),n,y)
+CONFIG_NO_XEN = $(if $(subst n,,$(CONFIG_XEN)),n,y)
+CONFIG_NO_XEN_MAPCACHE = $(if $(subst n,,$(CONFIG_XEN_MAPCACHE)),n,y)
 
 include ../config-host.mak
 include config-devices.mak
@@ -204,17 +206,8 @@ QEMU_CFLAGS += $(VNC_SASL_CFLAGS)
 QEMU_CFLAGS += $(VNC_JPEG_CFLAGS)
 QEMU_CFLAGS += $(VNC_PNG_CFLAGS)
 
-# xen backend driver support
-obj-i386-$(CONFIG_XEN) += xen_machine_pv.o xen_domainbuild.o
-
-ifeq ($(TARGET_BASE_ARCH), i386)
-  CONFIG_NO_XEN = $(if $(subst n,,$(CONFIG_XEN)),n,y)
-else
-  CONFIG_NO_XEN = y
-endif
 # xen support
-CONFIG_NO_XEN_MAPCACHE = $(if $(subst n,,$(CONFIG_XEN_MAPCACHE)),n,y)
-obj-i386-$(CONFIG_XEN) += xen-all.o
+obj-$(CONFIG_XEN) += xen-all.o xen_machine_pv.o xen_domainbuild.o
 obj-$(CONFIG_NO_XEN) += xen-stub.o
 obj-i386-$(CONFIG_XEN_MAPCACHE) += xen-mapcache.o
 obj-$(CONFIG_NO_XEN_MAPCACHE) += xen-mapcache-stub.o
diff --git a/configure b/configure
index 88159ac..e57efb1 100755
--- a/configure
+++ b/configure
@@ -2850,7 +2850,7 @@ if test "$bluez" = "yes" ; then
   echo "BLUEZ_CFLAGS=$bluez_cflags" >> $config_host_mak
 fi
 if test "$xen" = "yes" ; then
-  echo "CONFIG_XEN=y" >> $config_host_mak
+  echo "CONFIG_XEN_BACKEND=y" >> $config_host_mak
   echo "CONFIG_XEN_CTRL_INTERFACE_VERSION=$xen_ctrl_version" >> $config_host_mak
 fi
 if test "$io_thread" = "yes" ; then
-- 
1.6.0.2

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

* [Qemu-devel] [PATCH 02/12] xen: Clean up map cache API naming
  2011-07-05 16:51 [Qemu-devel] [PULL 00/12] Xen patch queue 2011-07-05 Alexander Graf
  2011-07-05 16:51 ` [Qemu-devel] [PATCH 01/12] xen: Clean up build system Alexander Graf
@ 2011-07-05 16:51 ` Alexander Graf
  2011-07-05 16:51 ` [Qemu-devel] [PATCH 03/12] xen: Fold CONFIG_XEN_MAPCACHE into CONFIG_XEN Alexander Graf
                   ` (10 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: Alexander Graf @ 2011-07-05 16:51 UTC (permalink / raw)
  To: qemu-devel@nongnu.org Developers
  Cc: Jan Kiszka, xen-devel@lists.xensource.com Devel

From: Jan Kiszka <jan.kiszka@siemens.com>

The map cache is a Xen thing, so its API should make this clear.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
 exec.c              |   18 ++++++++++--------
 trace-events        |    6 +++---
 xen-all.c           |    4 ++--
 xen-mapcache-stub.c |   11 ++++++-----
 xen-mapcache.c      |   41 +++++++++++++++++++++++------------------
 xen-mapcache.h      |   14 ++++++--------
 6 files changed, 50 insertions(+), 44 deletions(-)

diff --git a/exec.c b/exec.c
index 4c45299..3addace 100644
--- a/exec.c
+++ b/exec.c
@@ -3020,7 +3020,7 @@ void qemu_ram_free(ram_addr_t addr)
                 munmap(block->host, block->length);
 #else
                 if (xen_mapcache_enabled()) {
-                    qemu_invalidate_entry(block->host);
+                    xen_invalidate_map_cache_entry(block->host);
                 } else {
                     qemu_vfree(block->host);
                 }
@@ -3118,9 +3118,10 @@ void *qemu_get_ram_ptr(ram_addr_t addr)
                  * In that case just map until the end of the page.
                  */
                 if (block->offset == 0) {
-                    return qemu_map_cache(addr, 0, 0);
+                    return xen_map_cache(addr, 0, 0);
                 } else if (block->host == NULL) {
-                    block->host = qemu_map_cache(block->offset, block->length, 1);
+                    block->host =
+                        xen_map_cache(block->offset, block->length, 1);
                 }
             }
             return block->host + (addr - block->offset);
@@ -3148,9 +3149,10 @@ void *qemu_safe_ram_ptr(ram_addr_t addr)
                  * In that case just map until the end of the page.
                  */
                 if (block->offset == 0) {
-                    return qemu_map_cache(addr, 0, 0);
+                    return xen_map_cache(addr, 0, 0);
                 } else if (block->host == NULL) {
-                    block->host = qemu_map_cache(block->offset, block->length, 1);
+                    block->host =
+                        xen_map_cache(block->offset, block->length, 1);
                 }
             }
             return block->host + (addr - block->offset);
@@ -3168,7 +3170,7 @@ void *qemu_safe_ram_ptr(ram_addr_t addr)
 void *qemu_ram_ptr_length(target_phys_addr_t addr, target_phys_addr_t *size)
 {
     if (xen_mapcache_enabled())
-        return qemu_map_cache(addr, *size, 1);
+        return xen_map_cache(addr, *size, 1);
     else {
         RAMBlock *block;
 
@@ -3199,7 +3201,7 @@ int qemu_ram_addr_from_host(void *ptr, ram_addr_t *ram_addr)
     uint8_t *host = ptr;
 
     if (xen_mapcache_enabled()) {
-        *ram_addr = qemu_ram_addr_from_mapcache(ptr);
+        *ram_addr = xen_ram_addr_from_mapcache(ptr);
         return 0;
     }
 
@@ -4114,7 +4116,7 @@ void cpu_physical_memory_unmap(void *buffer, target_phys_addr_t len,
             }
         }
         if (xen_mapcache_enabled()) {
-            qemu_invalidate_entry(buffer);
+            xen_invalidate_map_cache_entry(buffer);
         }
         return;
     }
diff --git a/trace-events b/trace-events
index bebf612..2372385 100644
--- a/trace-events
+++ b/trace-events
@@ -399,9 +399,9 @@ disable xen_ram_alloc(unsigned long ram_addr, unsigned long size) "requested: %#
 disable xen_client_set_memory(uint64_t start_addr, unsigned long size, unsigned long phys_offset, bool log_dirty) "%#"PRIx64" size %#lx, offset %#lx, log_dirty %i"
 
 # xen-mapcache.c
-disable qemu_map_cache(uint64_t phys_addr) "want %#"PRIx64""
-disable qemu_remap_bucket(uint64_t index) "index %#"PRIx64""
-disable qemu_map_cache_return(void* ptr) "%p"
+disable xen_map_cache(uint64_t phys_addr) "want %#"PRIx64""
+disable xen_remap_bucket(uint64_t index) "index %#"PRIx64""
+disable xen_map_cache_return(void* ptr) "%p"
 disable xen_map_block(uint64_t phys_addr, uint64_t size) "%#"PRIx64", size %#"PRIx64""
 disable xen_unmap_block(void* addr, unsigned long size) "%p, size %#lx"
 
diff --git a/xen-all.c b/xen-all.c
index fcb106f..4827d6a 100644
--- a/xen-all.c
+++ b/xen-all.c
@@ -644,7 +644,7 @@ static void handle_ioreq(ioreq_t *req)
         case IOREQ_TYPE_TIMEOFFSET:
             break;
         case IOREQ_TYPE_INVALIDATE:
-            qemu_invalidate_map_cache();
+            xen_invalidate_map_cache();
             break;
         default:
             hw_error("Invalid ioreq type 0x%x\n", req->type);
@@ -852,7 +852,7 @@ int xen_hvm_init(void)
     }
 
     /* Init RAM management */
-    qemu_map_cache_init();
+    xen_map_cache_init();
     xen_ram_init(ram_size);
 
     qemu_add_vm_change_state_handler(xen_vm_change_state_handler, state);
diff --git a/xen-mapcache-stub.c b/xen-mapcache-stub.c
index 90a994d..f037016 100644
--- a/xen-mapcache-stub.c
+++ b/xen-mapcache-stub.c
@@ -13,24 +13,25 @@
 #include "cpu-common.h"
 #include "xen-mapcache.h"
 
-void qemu_map_cache_init(void)
+void xen_map_cache_init(void)
 {
 }
 
-uint8_t *qemu_map_cache(target_phys_addr_t phys_addr, target_phys_addr_t size, uint8_t lock)
+uint8_t *xen_map_cache(target_phys_addr_t phys_addr, target_phys_addr_t size,
+                       uint8_t lock)
 {
     return qemu_get_ram_ptr(phys_addr);
 }
 
-ram_addr_t qemu_ram_addr_from_mapcache(void *ptr)
+ram_addr_t xen_ram_addr_from_mapcache(void *ptr)
 {
     return -1;
 }
 
-void qemu_invalidate_map_cache(void)
+void xen_invalidate_map_cache(void)
 {
 }
 
-void qemu_invalidate_entry(uint8_t *buffer)
+void xen_invalidate_map_cache_entry(uint8_t *buffer)
 {
 }
diff --git a/xen-mapcache.c b/xen-mapcache.c
index fac47cd..007136a 100644
--- a/xen-mapcache.c
+++ b/xen-mapcache.c
@@ -40,6 +40,9 @@
 #endif
 #define MCACHE_BUCKET_SIZE (1UL << MCACHE_BUCKET_SHIFT)
 
+#define mapcache_lock()   ((void)0)
+#define mapcache_unlock() ((void)0)
+
 typedef struct MapCacheEntry {
     target_phys_addr_t paddr_index;
     uint8_t *vaddr_base;
@@ -79,7 +82,7 @@ static inline int test_bits(int nr, int size, const unsigned long *addr)
         return 0;
 }
 
-void qemu_map_cache_init(void)
+void xen_map_cache_init(void)
 {
     unsigned long size;
     struct rlimit rlimit_as;
@@ -106,13 +109,14 @@ void qemu_map_cache_init(void)
 
     size = mapcache->nr_buckets * sizeof (MapCacheEntry);
     size = (size + XC_PAGE_SIZE - 1) & ~(XC_PAGE_SIZE - 1);
-    DPRINTF("qemu_map_cache_init, nr_buckets = %lx size %lu\n", mapcache->nr_buckets, size);
+    DPRINTF("%s, nr_buckets = %lx size %lu\n", __func__,
+            mapcache->nr_buckets, size);
     mapcache->entry = qemu_mallocz(size);
 }
 
-static void qemu_remap_bucket(MapCacheEntry *entry,
-                              target_phys_addr_t size,
-                              target_phys_addr_t address_index)
+static void xen_remap_bucket(MapCacheEntry *entry,
+                             target_phys_addr_t size,
+                             target_phys_addr_t address_index)
 {
     uint8_t *vaddr_base;
     xen_pfn_t *pfns;
@@ -120,7 +124,7 @@ static void qemu_remap_bucket(MapCacheEntry *entry,
     unsigned int i;
     target_phys_addr_t nb_pfn = size >> XC_PAGE_SHIFT;
 
-    trace_qemu_remap_bucket(address_index);
+    trace_xen_remap_bucket(address_index);
 
     pfns = qemu_mallocz(nb_pfn * sizeof (xen_pfn_t));
     err = qemu_mallocz(nb_pfn * sizeof (int));
@@ -164,17 +168,18 @@ static void qemu_remap_bucket(MapCacheEntry *entry,
     qemu_free(err);
 }
 
-uint8_t *qemu_map_cache(target_phys_addr_t phys_addr, target_phys_addr_t size, uint8_t lock)
+uint8_t *xen_map_cache(target_phys_addr_t phys_addr, target_phys_addr_t size,
+                       uint8_t lock)
 {
     MapCacheEntry *entry, *pentry = NULL;
     target_phys_addr_t address_index  = phys_addr >> MCACHE_BUCKET_SHIFT;
     target_phys_addr_t address_offset = phys_addr & (MCACHE_BUCKET_SIZE - 1);
     target_phys_addr_t __size = size;
 
-    trace_qemu_map_cache(phys_addr);
+    trace_xen_map_cache(phys_addr);
 
     if (address_index == mapcache->last_address_index && !lock && !__size) {
-        trace_qemu_map_cache_return(mapcache->last_address_vaddr + address_offset);
+        trace_xen_map_cache_return(mapcache->last_address_vaddr + address_offset);
         return mapcache->last_address_vaddr + address_offset;
     }
 
@@ -198,20 +203,20 @@ uint8_t *qemu_map_cache(target_phys_addr_t phys_addr, target_phys_addr_t size, u
     if (!entry) {
         entry = qemu_mallocz(sizeof (MapCacheEntry));
         pentry->next = entry;
-        qemu_remap_bucket(entry, __size, address_index);
+        xen_remap_bucket(entry, __size, address_index);
     } else if (!entry->lock) {
         if (!entry->vaddr_base || entry->paddr_index != address_index ||
                 entry->size != __size ||
                 !test_bits(address_offset >> XC_PAGE_SHIFT, size >> XC_PAGE_SHIFT,
                     entry->valid_mapping)) {
-            qemu_remap_bucket(entry, __size, address_index);
+            xen_remap_bucket(entry, __size, address_index);
         }
     }
 
     if(!test_bits(address_offset >> XC_PAGE_SHIFT, size >> XC_PAGE_SHIFT,
                 entry->valid_mapping)) {
         mapcache->last_address_index = -1;
-        trace_qemu_map_cache_return(NULL);
+        trace_xen_map_cache_return(NULL);
         return NULL;
     }
 
@@ -226,11 +231,11 @@ uint8_t *qemu_map_cache(target_phys_addr_t phys_addr, target_phys_addr_t size, u
         QTAILQ_INSERT_HEAD(&mapcache->locked_entries, reventry, next);
     }
 
-    trace_qemu_map_cache_return(mapcache->last_address_vaddr + address_offset);
+    trace_xen_map_cache_return(mapcache->last_address_vaddr + address_offset);
     return mapcache->last_address_vaddr + address_offset;
 }
 
-ram_addr_t qemu_ram_addr_from_mapcache(void *ptr)
+ram_addr_t xen_ram_addr_from_mapcache(void *ptr)
 {
     MapCacheEntry *entry = NULL, *pentry = NULL;
     MapCacheRev *reventry;
@@ -247,7 +252,7 @@ ram_addr_t qemu_ram_addr_from_mapcache(void *ptr)
         }
     }
     if (!found) {
-        fprintf(stderr, "qemu_ram_addr_from_mapcache, could not find %p\n", ptr);
+        fprintf(stderr, "%s, could not find %p\n", __func__, ptr);
         QTAILQ_FOREACH(reventry, &mapcache->locked_entries, next) {
             DPRINTF("   "TARGET_FMT_plx" -> %p is present\n", reventry->paddr_index,
                     reventry->vaddr_req);
@@ -269,7 +274,7 @@ ram_addr_t qemu_ram_addr_from_mapcache(void *ptr)
         ((unsigned long) ptr - (unsigned long) entry->vaddr_base);
 }
 
-void qemu_invalidate_entry(uint8_t *buffer)
+void xen_invalidate_map_cache_entry(uint8_t *buffer)
 {
     MapCacheEntry *entry = NULL, *pentry = NULL;
     MapCacheRev *reventry;
@@ -290,7 +295,7 @@ void qemu_invalidate_entry(uint8_t *buffer)
         }
     }
     if (!found) {
-        DPRINTF("qemu_invalidate_entry, could not find %p\n", buffer);
+        DPRINTF("%s, could not find %p\n", __func__, buffer);
         QTAILQ_FOREACH(reventry, &mapcache->locked_entries, next) {
             DPRINTF("   "TARGET_FMT_plx" -> %p is present\n", reventry->paddr_index, reventry->vaddr_req);
         }
@@ -322,7 +327,7 @@ void qemu_invalidate_entry(uint8_t *buffer)
     qemu_free(entry);
 }
 
-void qemu_invalidate_map_cache(void)
+void xen_invalidate_map_cache(void)
 {
     unsigned long i;
     MapCacheRev *reventry;
diff --git a/xen-mapcache.h b/xen-mapcache.h
index 6216cc3..606b8af 100644
--- a/xen-mapcache.h
+++ b/xen-mapcache.h
@@ -9,13 +9,11 @@
 #ifndef XEN_MAPCACHE_H
 #define XEN_MAPCACHE_H
 
-void     qemu_map_cache_init(void);
-uint8_t  *qemu_map_cache(target_phys_addr_t phys_addr, target_phys_addr_t size, uint8_t lock);
-ram_addr_t qemu_ram_addr_from_mapcache(void *ptr);
-void     qemu_invalidate_entry(uint8_t *buffer);
-void     qemu_invalidate_map_cache(void);
-
-#define mapcache_lock()   ((void)0)
-#define mapcache_unlock() ((void)0)
+void xen_map_cache_init(void);
+uint8_t *xen_map_cache(target_phys_addr_t phys_addr, target_phys_addr_t size,
+                       uint8_t lock);
+ram_addr_t xen_ram_addr_from_mapcache(void *ptr);
+void xen_invalidate_map_cache_entry(uint8_t *buffer);
+void xen_invalidate_map_cache(void);
 
 #endif /* !XEN_MAPCACHE_H */
-- 
1.6.0.2

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

* [Qemu-devel] [PATCH 03/12] xen: Fold CONFIG_XEN_MAPCACHE into CONFIG_XEN
  2011-07-05 16:51 [Qemu-devel] [PULL 00/12] Xen patch queue 2011-07-05 Alexander Graf
  2011-07-05 16:51 ` [Qemu-devel] [PATCH 01/12] xen: Clean up build system Alexander Graf
  2011-07-05 16:51 ` [Qemu-devel] [PATCH 02/12] xen: Clean up map cache API naming Alexander Graf
@ 2011-07-05 16:51 ` Alexander Graf
  2011-07-05 16:51 ` [Qemu-devel] [PATCH 04/12] xen: enable console and disk backend in HVM mode Alexander Graf
                   ` (9 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: Alexander Graf @ 2011-07-05 16:51 UTC (permalink / raw)
  To: qemu-devel@nongnu.org Developers
  Cc: Jan Kiszka, xen-devel@lists.xensource.com Devel

From: Jan Kiszka <jan.kiszka@siemens.com>

Xen won't be enabled if there is no backend support available for the
host. And that also means the map cache will work. So drop the separate
config switch and move the required stubs over to xen-stub.c.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
 Makefile.target     |    5 +----
 exec.c              |   16 ++++++++--------
 hw/xen.h            |    9 ---------
 xen-mapcache-stub.c |   37 -------------------------------------
 4 files changed, 9 insertions(+), 58 deletions(-)
 delete mode 100644 xen-mapcache-stub.c

diff --git a/Makefile.target b/Makefile.target
index c347176..c566eb1 100644
--- a/Makefile.target
+++ b/Makefile.target
@@ -4,7 +4,6 @@ GENERATED_HEADERS = config-target.h
 CONFIG_NO_PCI = $(if $(subst n,,$(CONFIG_PCI)),n,y)
 CONFIG_NO_KVM = $(if $(subst n,,$(CONFIG_KVM)),n,y)
 CONFIG_NO_XEN = $(if $(subst n,,$(CONFIG_XEN)),n,y)
-CONFIG_NO_XEN_MAPCACHE = $(if $(subst n,,$(CONFIG_XEN_MAPCACHE)),n,y)
 
 include ../config-host.mak
 include config-devices.mak
@@ -207,10 +206,8 @@ QEMU_CFLAGS += $(VNC_JPEG_CFLAGS)
 QEMU_CFLAGS += $(VNC_PNG_CFLAGS)
 
 # xen support
-obj-$(CONFIG_XEN) += xen-all.o xen_machine_pv.o xen_domainbuild.o
+obj-$(CONFIG_XEN) += xen-all.o xen_machine_pv.o xen_domainbuild.o xen-mapcache.o
 obj-$(CONFIG_NO_XEN) += xen-stub.o
-obj-i386-$(CONFIG_XEN_MAPCACHE) += xen-mapcache.o
-obj-$(CONFIG_NO_XEN_MAPCACHE) += xen-mapcache-stub.o
 
 obj-i386-$(CONFIG_XEN) += xen_platform.o
 
diff --git a/exec.c b/exec.c
index 3addace..5604946 100644
--- a/exec.c
+++ b/exec.c
@@ -2953,7 +2953,7 @@ ram_addr_t qemu_ram_alloc_from_ptr(DeviceState *dev, const char *name,
                 abort();
             }
 #else
-            if (xen_mapcache_enabled()) {
+            if (xen_enabled()) {
                 xen_ram_alloc(new_block->offset, size);
             } else {
                 new_block->host = qemu_vmalloc(size);
@@ -3019,7 +3019,7 @@ void qemu_ram_free(ram_addr_t addr)
 #if defined(TARGET_S390X) && defined(CONFIG_KVM)
                 munmap(block->host, block->length);
 #else
-                if (xen_mapcache_enabled()) {
+                if (xen_enabled()) {
                     xen_invalidate_map_cache_entry(block->host);
                 } else {
                     qemu_vfree(block->host);
@@ -3112,7 +3112,7 @@ void *qemu_get_ram_ptr(ram_addr_t addr)
                 QLIST_REMOVE(block, next);
                 QLIST_INSERT_HEAD(&ram_list.blocks, block, next);
             }
-            if (xen_mapcache_enabled()) {
+            if (xen_enabled()) {
                 /* We need to check if the requested address is in the RAM
                  * because we don't want to map the entire memory in QEMU.
                  * In that case just map until the end of the page.
@@ -3143,7 +3143,7 @@ void *qemu_safe_ram_ptr(ram_addr_t addr)
 
     QLIST_FOREACH(block, &ram_list.blocks, next) {
         if (addr - block->offset < block->length) {
-            if (xen_mapcache_enabled()) {
+            if (xen_enabled()) {
                 /* We need to check if the requested address is in the RAM
                  * because we don't want to map the entire memory in QEMU.
                  * In that case just map until the end of the page.
@@ -3169,9 +3169,9 @@ void *qemu_safe_ram_ptr(ram_addr_t addr)
  * but takes a size argument */
 void *qemu_ram_ptr_length(target_phys_addr_t addr, target_phys_addr_t *size)
 {
-    if (xen_mapcache_enabled())
+    if (xen_enabled()) {
         return xen_map_cache(addr, *size, 1);
-    else {
+    } else {
         RAMBlock *block;
 
         QLIST_FOREACH(block, &ram_list.blocks, next) {
@@ -3200,7 +3200,7 @@ int qemu_ram_addr_from_host(void *ptr, ram_addr_t *ram_addr)
     RAMBlock *block;
     uint8_t *host = ptr;
 
-    if (xen_mapcache_enabled()) {
+    if (xen_enabled()) {
         *ram_addr = xen_ram_addr_from_mapcache(ptr);
         return 0;
     }
@@ -4115,7 +4115,7 @@ void cpu_physical_memory_unmap(void *buffer, target_phys_addr_t len,
                 access_len -= l;
             }
         }
-        if (xen_mapcache_enabled()) {
+        if (xen_enabled()) {
             xen_invalidate_map_cache_entry(buffer);
         }
         return;
diff --git a/hw/xen.h b/hw/xen.h
index d435ca0..95029bb 100644
--- a/hw/xen.h
+++ b/hw/xen.h
@@ -31,15 +31,6 @@ static inline int xen_enabled(void)
 #endif
 }
 
-static inline int xen_mapcache_enabled(void)
-{
-#ifdef CONFIG_XEN_MAPCACHE
-    return xen_enabled();
-#else
-    return 0;
-#endif
-}
-
 int xen_pci_slot_get_pirq(PCIDevice *pci_dev, int irq_num);
 void xen_piix3_set_irq(void *opaque, int irq_num, int level);
 void xen_piix_pci_write_config_client(uint32_t address, uint32_t val, int len);
diff --git a/xen-mapcache-stub.c b/xen-mapcache-stub.c
deleted file mode 100644
index f037016..0000000
--- a/xen-mapcache-stub.c
+++ /dev/null
@@ -1,37 +0,0 @@
-/*
- * Copyright (C) 2011       Citrix Ltd.
- *
- * This work is licensed under the terms of the GNU GPL, version 2.  See
- * the COPYING file in the top-level directory.
- *
- */
-
-#include "config.h"
-
-#include "cpu.h"
-#include "qemu-common.h"
-#include "cpu-common.h"
-#include "xen-mapcache.h"
-
-void xen_map_cache_init(void)
-{
-}
-
-uint8_t *xen_map_cache(target_phys_addr_t phys_addr, target_phys_addr_t size,
-                       uint8_t lock)
-{
-    return qemu_get_ram_ptr(phys_addr);
-}
-
-ram_addr_t xen_ram_addr_from_mapcache(void *ptr)
-{
-    return -1;
-}
-
-void xen_invalidate_map_cache(void)
-{
-}
-
-void xen_invalidate_map_cache_entry(uint8_t *buffer)
-{
-}
-- 
1.6.0.2

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

* [Qemu-devel] [PATCH 04/12] xen: enable console and disk backend in HVM mode
  2011-07-05 16:51 [Qemu-devel] [PULL 00/12] Xen patch queue 2011-07-05 Alexander Graf
                   ` (2 preceding siblings ...)
  2011-07-05 16:51 ` [Qemu-devel] [PATCH 03/12] xen: Fold CONFIG_XEN_MAPCACHE into CONFIG_XEN Alexander Graf
@ 2011-07-05 16:51 ` Alexander Graf
  2011-07-05 16:51 ` [Qemu-devel] [PATCH 05/12] xen_console: fix memory leak Alexander Graf
                   ` (8 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: Alexander Graf @ 2011-07-05 16:51 UTC (permalink / raw)
  To: qemu-devel@nongnu.org Developers
  Cc: xen-devel@lists.xensource.com Devel, Stefano Stabellini

From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

Initialize the Xen console backend and the Xen disk backend even when
running in HVM mode so that PV on HVM drivers can connect to them.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
 xen-all.c |    8 ++++++++
 1 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/xen-all.c b/xen-all.c
index 4827d6a..3d40ab0 100644
--- a/xen-all.c
+++ b/xen-all.c
@@ -862,6 +862,14 @@ int xen_hvm_init(void)
     cpu_register_phys_memory_client(&state->client);
     state->log_for_dirtybit = NULL;
 
+    /* Initialize backend core & drivers */
+    if (xen_be_init() != 0) {
+        fprintf(stderr, "%s: xen backend core setup failed\n", __FUNCTION__);
+        exit(1);
+    }
+    xen_be_register("console", &xen_console_ops);
+    xen_be_register("qdisk", &xen_blkdev_ops);
+
     return 0;
 }
 
-- 
1.6.0.2

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

* [Qemu-devel] [PATCH 05/12] xen_console: fix memory leak
  2011-07-05 16:51 [Qemu-devel] [PULL 00/12] Xen patch queue 2011-07-05 Alexander Graf
                   ` (3 preceding siblings ...)
  2011-07-05 16:51 ` [Qemu-devel] [PATCH 04/12] xen: enable console and disk backend in HVM mode Alexander Graf
@ 2011-07-05 16:51 ` Alexander Graf
  2011-07-05 16:51 ` [Qemu-devel] [PATCH 06/12] xen: add vkbd support for PV on HVM guests Alexander Graf
                   ` (7 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: Alexander Graf @ 2011-07-05 16:51 UTC (permalink / raw)
  To: qemu-devel@nongnu.org Developers
  Cc: xen-devel@lists.xensource.com Devel, Stefano Stabellini

From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

con_init leaks the string "type", fix it.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
 hw/xen_console.c |    8 ++++++--
 1 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/hw/xen_console.c b/hw/xen_console.c
index c6c8163..2d613ee 100644
--- a/hw/xen_console.c
+++ b/hw/xen_console.c
@@ -180,6 +180,7 @@ static int con_init(struct XenDevice *xendev)
 {
     struct XenConsole *con = container_of(xendev, struct XenConsole, xendev);
     char *type, *dom;
+    int ret = 0;
 
     /* setup */
     dom = xs_get_domain_path(xenstore, con->xendev.dom);
@@ -189,7 +190,8 @@ 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);
-	return -1;
+        ret = -1;
+        goto out;
     }
 
     if (!serial_hds[con->xendev.dev])
@@ -198,7 +200,9 @@ static int con_init(struct XenDevice *xendev)
     else
         con->chr = serial_hds[con->xendev.dev];
 
-    return 0;
+out:
+    qemu_free(type);
+    return ret;
 }
 
 static int con_connect(struct XenDevice *xendev)
-- 
1.6.0.2

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

* [Qemu-devel] [PATCH 06/12] xen: add vkbd support for PV on HVM guests
  2011-07-05 16:51 [Qemu-devel] [PULL 00/12] Xen patch queue 2011-07-05 Alexander Graf
                   ` (4 preceding siblings ...)
  2011-07-05 16:51 ` [Qemu-devel] [PATCH 05/12] xen_console: fix memory leak Alexander Graf
@ 2011-07-05 16:51 ` Alexander Graf
  2011-07-05 16:51 ` [Qemu-devel] [PATCH 07/12] xen_disk: cope with missing xenstore "params" node Alexander Graf
                   ` (6 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: Alexander Graf @ 2011-07-05 16:51 UTC (permalink / raw)
  To: qemu-devel@nongnu.org Developers
  Cc: xen-devel@lists.xensource.com Devel, Stefano Stabellini

From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

Register the vkbd backend even when running as device emulator for HVM
guests: it is useful because it doesn't need a frequent timer like usb.

Check whether the XenInput DisplayState has been set in the initialise
state, rather than the input state.
In case the DisplayState hasn't been set and there is no vfb for this
domain, then set the XenInput DisplayState to the default one.

Changed in v2:

- use qemu_free instead of free;

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
 hw/xenfb.c |   19 ++++++++++++-------
 xen-all.c  |    1 +
 2 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/hw/xenfb.c b/hw/xenfb.c
index 1db75fb..0a01ae3 100644
--- a/hw/xenfb.c
+++ b/hw/xenfb.c
@@ -347,13 +347,6 @@ static void xenfb_mouse_event(void *opaque,
 
 static int input_init(struct XenDevice *xendev)
 {
-    struct XenInput *in = container_of(xendev, struct XenInput, c.xendev);
-
-    if (!in->c.ds) {
-        xen_be_printf(xendev, 1, "ds not set (yet)\n");
-	return -1;
-    }
-
     xenstore_write_be_int(xendev, "feature-abs-pointer", 1);
     return 0;
 }
@@ -367,6 +360,18 @@ static int input_connect(struct XenDevice *xendev)
                              &in->abs_pointer_wanted) == -1)
 	in->abs_pointer_wanted = 0;
 
+    if (!in->c.ds) {
+        char *vfb = xenstore_read_str(NULL, "device/vfb");
+        if (vfb == NULL) {
+            /* there is no vfb, run vkbd on its own */
+            in->c.ds = get_displaystate();
+        } else {
+            qemu_free(vfb);
+            xen_be_printf(xendev, 1, "ds not set (yet)\n");
+            return -1;
+        }
+    }
+
     rc = common_bind(&in->c);
     if (rc != 0)
 	return rc;
diff --git a/xen-all.c b/xen-all.c
index 3d40ab0..fb9bcc8 100644
--- a/xen-all.c
+++ b/xen-all.c
@@ -868,6 +868,7 @@ int xen_hvm_init(void)
         exit(1);
     }
     xen_be_register("console", &xen_console_ops);
+    xen_be_register("vkbd", &xen_kbdmouse_ops);
     xen_be_register("qdisk", &xen_blkdev_ops);
 
     return 0;
-- 
1.6.0.2

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

* [Qemu-devel] [PATCH 07/12] xen_disk: cope with missing xenstore "params" node
  2011-07-05 16:51 [Qemu-devel] [PULL 00/12] Xen patch queue 2011-07-05 Alexander Graf
                   ` (5 preceding siblings ...)
  2011-07-05 16:51 ` [Qemu-devel] [PATCH 06/12] xen: add vkbd support for PV on HVM guests Alexander Graf
@ 2011-07-05 16:51 ` Alexander Graf
  2011-07-05 16:51 ` [Qemu-devel] [PATCH 08/12] qemu_ram_ptr_length: take ram_addr_t as arguments Alexander Graf
                   ` (5 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: Alexander Graf @ 2011-07-05 16:51 UTC (permalink / raw)
  To: qemu-devel@nongnu.org Developers
  Cc: xen-devel@lists.xensource.com Devel, Stefano Stabellini

From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

When disk is a cdrom and the drive is empty the "params" node in
xenstore might be missing completely: cope with it instead of
segfaulting.

Updated in v2:

- actually removed the strchr(blkdev->params, ':') that caused the
segfault;

- free all the allocated strings from xenstore before returning;

Updated in v3:

- set blkdev fields to NULL after free'ing them.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
 hw/xen_disk.c |   34 +++++++++++++++++++++++++++-------
 1 files changed, 27 insertions(+), 7 deletions(-)

diff --git a/hw/xen_disk.c b/hw/xen_disk.c
index 0c298af..f14e5a6 100644
--- a/hw/xen_disk.c
+++ b/hw/xen_disk.c
@@ -616,12 +616,14 @@ static int blk_init(struct XenDevice *xendev)
 {
     struct XenBlkDev *blkdev = container_of(xendev, struct XenBlkDev, xendev);
     int index, qflags, have_barriers, info = 0;
-    char *h;
 
     /* read xenstore entries */
     if (blkdev->params == NULL) {
+        char *h = NULL;
         blkdev->params = xenstore_read_be_str(&blkdev->xendev, "params");
-        h = strchr(blkdev->params, ':');
+        if (blkdev->params != NULL) {
+            h = strchr(blkdev->params, ':');
+        }
         if (h != NULL) {
             blkdev->fileproto = blkdev->params;
             blkdev->filename  = h+1;
@@ -649,7 +651,7 @@ static int blk_init(struct XenDevice *xendev)
         blkdev->mode == NULL   ||
         blkdev->type == NULL   ||
         blkdev->dev == NULL) {
-        return -1;
+        goto out_error;
     }
 
     /* read-only ? */
@@ -672,10 +674,15 @@ static int blk_init(struct XenDevice *xendev)
         /* setup via xenbus -> create new block driver instance */
         xen_be_printf(&blkdev->xendev, 2, "create new bdrv (xenbus setup)\n");
         blkdev->bs = bdrv_new(blkdev->dev);
-        if (bdrv_open(blkdev->bs, blkdev->filename, qflags,
-                      bdrv_find_whitelisted_format(blkdev->fileproto)) != 0) {
-            bdrv_delete(blkdev->bs);
-            return -1;
+        if (blkdev->bs) {
+            if (bdrv_open(blkdev->bs, blkdev->filename, qflags,
+                        bdrv_find_whitelisted_format(blkdev->fileproto)) != 0) {
+                bdrv_delete(blkdev->bs);
+                blkdev->bs = NULL;
+            }
+        }
+        if (!blkdev->bs) {
+            goto out_error;
         }
     } else {
         /* setup via qemu cmdline -> already setup for us */
@@ -704,6 +711,19 @@ static int blk_init(struct XenDevice *xendev)
     xenstore_write_be_int(&blkdev->xendev, "sectors",
                           blkdev->file_size / blkdev->file_blk);
     return 0;
+
+out_error:
+    qemu_free(blkdev->params);
+    blkdev->params = NULL;
+    qemu_free(blkdev->mode);
+    blkdev->mode = NULL;
+    qemu_free(blkdev->type);
+    blkdev->type = NULL;
+    qemu_free(blkdev->dev);
+    blkdev->dev = NULL;
+    qemu_free(blkdev->devtype);
+    blkdev->devtype = NULL;
+    return -1;
 }
 
 static int blk_connect(struct XenDevice *xendev)
-- 
1.6.0.2

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

* [Qemu-devel] [PATCH 08/12] qemu_ram_ptr_length: take ram_addr_t as arguments
  2011-07-05 16:51 [Qemu-devel] [PULL 00/12] Xen patch queue 2011-07-05 Alexander Graf
                   ` (6 preceding siblings ...)
  2011-07-05 16:51 ` [Qemu-devel] [PATCH 07/12] xen_disk: cope with missing xenstore "params" node Alexander Graf
@ 2011-07-05 16:51 ` Alexander Graf
  2011-07-06 13:12   ` Vasily Khoruzhick
  2011-07-05 16:51 ` [Qemu-devel] [PATCH 09/12] xen_disk: treat "aio" as "raw" Alexander Graf
                   ` (4 subsequent siblings)
  12 siblings, 1 reply; 15+ messages in thread
From: Alexander Graf @ 2011-07-05 16:51 UTC (permalink / raw)
  To: qemu-devel@nongnu.org Developers
  Cc: xen-devel@lists.xensource.com Devel, Stefano Stabellini

From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

qemu_ram_ptr_length should take ram_addr_t as argument rather than
target_phys_addr_t because is doing comparisons with RAMBlock addresses.

cpu_physical_memory_map should create a ram_addr_t address to pass to
qemu_ram_ptr_length from PhysPageDesc phys_offset.

Remove code after abort() in qemu_ram_ptr_length.

Changes in v2:

- handle 0 size in qemu_ram_ptr_length;

- rename addr1 to raddr;

- initialize raddr to ULONG_MAX.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
 cpu-common.h |    2 +-
 exec.c       |   21 ++++++++++++++-------
 2 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/cpu-common.h b/cpu-common.h
index b027e43..e4fcded 100644
--- a/cpu-common.h
+++ b/cpu-common.h
@@ -65,7 +65,7 @@ void qemu_ram_free_from_ptr(ram_addr_t addr);
 void qemu_ram_remap(ram_addr_t addr, ram_addr_t length);
 /* This should only be used for ram local to a device.  */
 void *qemu_get_ram_ptr(ram_addr_t addr);
-void *qemu_ram_ptr_length(target_phys_addr_t addr, target_phys_addr_t *size);
+void *qemu_ram_ptr_length(ram_addr_t addr, ram_addr_t *size);
 /* Same but slower, to use for migration, where the order of
  * RAMBlocks must not change. */
 void *qemu_safe_ram_ptr(ram_addr_t addr);
diff --git a/exec.c b/exec.c
index 5604946..c0673c2 100644
--- a/exec.c
+++ b/exec.c
@@ -3167,8 +3167,11 @@ void *qemu_safe_ram_ptr(ram_addr_t addr)
 
 /* Return a host pointer to guest's ram. Similar to qemu_get_ram_ptr
  * but takes a size argument */
-void *qemu_ram_ptr_length(target_phys_addr_t addr, target_phys_addr_t *size)
+void *qemu_ram_ptr_length(ram_addr_t addr, ram_addr_t *size)
 {
+    if (*size == 0) {
+        return NULL;
+    }
     if (xen_enabled()) {
         return xen_map_cache(addr, *size, 1);
     } else {
@@ -3184,9 +3187,6 @@ void *qemu_ram_ptr_length(target_phys_addr_t addr, target_phys_addr_t *size)
 
         fprintf(stderr, "Bad ram offset %" PRIx64 "\n", (uint64_t)addr);
         abort();
-
-        *size = 0;
-        return NULL;
     }
 }
 
@@ -4052,7 +4052,9 @@ void *cpu_physical_memory_map(target_phys_addr_t addr,
     target_phys_addr_t page;
     unsigned long pd;
     PhysPageDesc *p;
-    target_phys_addr_t addr1 = addr;
+    ram_addr_t raddr = ULONG_MAX;
+    ram_addr_t rlen;
+    void *ret;
 
     while (len > 0) {
         page = addr & TARGET_PAGE_MASK;
@@ -4080,13 +4082,18 @@ void *cpu_physical_memory_map(target_phys_addr_t addr,
             *plen = l;
             return bounce.buffer;
         }
+        if (!todo) {
+            raddr = (pd & TARGET_PAGE_MASK) + (addr & ~TARGET_PAGE_MASK);
+        }
 
         len -= l;
         addr += l;
         todo += l;
     }
-    *plen = todo;
-    return qemu_ram_ptr_length(addr1, plen);
+    rlen = todo;
+    ret = qemu_ram_ptr_length(raddr, &rlen);
+    *plen = rlen;
+    return ret;
 }
 
 /* Unmaps a memory region previously mapped by cpu_physical_memory_map().
-- 
1.6.0.2

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

* [Qemu-devel] [PATCH 09/12] xen_disk: treat "aio" as "raw"
  2011-07-05 16:51 [Qemu-devel] [PULL 00/12] Xen patch queue 2011-07-05 Alexander Graf
                   ` (7 preceding siblings ...)
  2011-07-05 16:51 ` [Qemu-devel] [PATCH 08/12] qemu_ram_ptr_length: take ram_addr_t as arguments Alexander Graf
@ 2011-07-05 16:51 ` Alexander Graf
  2011-07-05 16:51 ` [Qemu-devel] [PATCH 10/12] checkpatch: don't error out on }, { lines Alexander Graf
                   ` (3 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: Alexander Graf @ 2011-07-05 16:51 UTC (permalink / raw)
  To: qemu-devel@nongnu.org Developers
  Cc: xen-devel@lists.xensource.com Devel, Stefano Stabellini

From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

Sometimes the toolstack uses "aio" without an additional format
identifier, in such cases use "raw".

Updated in v2:

- fix code style.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
 hw/xen_disk.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/hw/xen_disk.c b/hw/xen_disk.c
index f14e5a6..add815f 100644
--- a/hw/xen_disk.c
+++ b/hw/xen_disk.c
@@ -633,6 +633,9 @@ static int blk_init(struct XenDevice *xendev)
             blkdev->filename  = blkdev->params;
         }
     }
+    if (!strcmp("aio", blkdev->fileproto)) {
+        blkdev->fileproto = "raw";
+    }
     if (blkdev->mode == NULL) {
         blkdev->mode = xenstore_read_be_str(&blkdev->xendev, "mode");
     }
-- 
1.6.0.2

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

* [Qemu-devel] [PATCH 10/12] checkpatch: don't error out on }, { lines
  2011-07-05 16:51 [Qemu-devel] [PULL 00/12] Xen patch queue 2011-07-05 Alexander Graf
                   ` (8 preceding siblings ...)
  2011-07-05 16:51 ` [Qemu-devel] [PATCH 09/12] xen_disk: treat "aio" as "raw" Alexander Graf
@ 2011-07-05 16:51 ` Alexander Graf
  2011-07-05 16:51 ` [Qemu-devel] [PATCH 11/12] xen_console: support the new extended xenstore protocol Alexander Graf
                   ` (2 subsequent siblings)
  12 siblings, 0 replies; 15+ messages in thread
From: Alexander Graf @ 2011-07-05 16:51 UTC (permalink / raw)
  To: qemu-devel@nongnu.org Developers; +Cc: xen-devel@lists.xensource.com Devel

When having code like this:

    static PCIDeviceInfo piix_ide_info[] = {
        {
            .qdev.name    = "piix3-ide",
            .qdev.size    = sizeof(PCIIDEState),
            .qdev.no_user = 1,
            .no_hotplug   = 1,
            .init         = pci_piix_ide_initfn,
            .vendor_id    = PCI_VENDOR_ID_INTEL,
            .device_id    = PCI_DEVICE_ID_INTEL_82371SB_1,
            .class_id     = PCI_CLASS_STORAGE_IDE,
        },{
            .qdev.name    = "piix4-ide",
            .qdev.size    = sizeof(PCIIDEState),
            .qdev.no_user = 1,
            .no_hotplug   = 1,
            .init         = pci_piix_ide_initfn,
            .vendor_id    = PCI_VENDOR_ID_INTEL,
            .device_id    = PCI_DEVICE_ID_INTEL_82371AB,
            .class_id     = PCI_CLASS_STORAGE_IDE,
        },{
            /* end of list */
        }
    };

checkpatch currently errors out, claiming that spaces need to follow
commas. However, this particular style of defining structs is pretty
common in qemu code and very readable. So let's declare it as supported
for the above case.

Reported-by: Kevin Wolf <kwolf@redhat.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
 scripts/checkpatch.pl |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/scripts/checkpatch.pl b/scripts/checkpatch.pl
index 075b614..70a2111 100755
--- a/scripts/checkpatch.pl
+++ b/scripts/checkpatch.pl
@@ -2068,8 +2068,10 @@ sub process {
 					}
 
 				# , must have a space on the right.
+                                # not required when having a single },{ on one line
 				} elsif ($op eq ',') {
-					if ($ctx !~ /.x[WEC]/ && $cc !~ /^}/) {
+					if ($ctx !~ /.x[WEC]/ && $cc !~ /^}/ &&
+                                            ($elements[$n] . $elements[$n + 2]) !~ " *}{") {
 						ERROR("space required after that '$op' $at\n" . $hereptr);
 					}
 
-- 
1.6.0.2

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

* [Qemu-devel] [PATCH 11/12] xen_console: support the new extended xenstore protocol
  2011-07-05 16:51 [Qemu-devel] [PULL 00/12] Xen patch queue 2011-07-05 Alexander Graf
                   ` (9 preceding siblings ...)
  2011-07-05 16:51 ` [Qemu-devel] [PATCH 10/12] checkpatch: don't error out on }, { lines Alexander Graf
@ 2011-07-05 16:51 ` Alexander Graf
  2011-07-05 16:51 ` [Qemu-devel] [PATCH 12/12] xen_console: fall back to qemu serial device Alexander Graf
  2011-07-19 15:59 ` [Qemu-devel] [PULL 00/12] Xen patch queue 2011-07-05 Anthony Liguori
  12 siblings, 0 replies; 15+ messages in thread
From: Alexander Graf @ 2011-07-05 16:51 UTC (permalink / raw)
  To: qemu-devel@nongnu.org Developers
  Cc: xen-devel@lists.xensource.com Devel, Stefano Stabellini

From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

Since CS 21994 on xen-unstable.hg and CS
466608f3a32e1f9808acdf832a5843af37e5fcec on qemu-xen-unstable.git, few
changes have been introduced to the PV console xenstore protocol, as
described by the document docs/misc/console.txt under xen-unstable.hg.

>From the Qemu point of view, very few modifications are needed to
correctly support the protocol: read from xenstore the "output" node
that tell us what the output of the PV console is going to be.
In case the output is a tty, write to xenstore the device name.

Changes in v2:

- fix error paths: free malloc'ed strings and close the xenstore
connection before returning;

- remove useless snprintf in xenstore_store_pv_console_info if i == 0.

Changes in v3:

- replace xs_daemon_open/xs_daemon_close with xs_open/xs_close.

Changes in v4:

- add a compatibility implementation of xs_open/xs_close.

Changes in v5:

- fix code style.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
Signed-off-by: Alexander Graf <agraf@suse.de>
---
 hw/xen.h         |    1 +
 hw/xen_common.h  |   12 ++++++++++
 hw/xen_console.c |   16 +++++++++-----
 xen-all.c        |   60 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
 4 files changed, 83 insertions(+), 6 deletions(-)

diff --git a/hw/xen.h b/hw/xen.h
index 95029bb..e432705 100644
--- a/hw/xen.h
+++ b/hw/xen.h
@@ -41,6 +41,7 @@ qemu_irq *xen_interrupt_controller_init(void);
 int xen_init(void);
 int xen_hvm_init(void);
 void xen_vcpu_init(void);
+void xenstore_store_pv_console_info(int i, struct CharDriverState *chr);
 
 #if defined(NEED_CPU_H) && !defined(CONFIG_USER_ONLY)
 void xen_ram_alloc(ram_addr_t ram_addr, ram_addr_t size);
diff --git a/hw/xen_common.h b/hw/xen_common.h
index 2c79af6..0409ac7 100644
--- a/hw/xen_common.h
+++ b/hw/xen_common.h
@@ -85,6 +85,18 @@ static inline int xc_domain_add_to_physmap(int xc_handle, uint32_t domid,
     return xc_memory_op(xc_handle, XENMEM_add_to_physmap, &xatp);
 }
 
+static inline struct xs_handle *xs_open(unsigned long flags)
+{
+    return xs_daemon_open();
+}
+
+static inline void xs_close(struct xs_handle *xsh)
+{
+    if (xsh != NULL) {
+        xs_daemon_close(xsh);
+    }
+}
+
 
 /* Xen 4.1 */
 #else
diff --git a/hw/xen_console.c b/hw/xen_console.c
index 2d613ee..bdb8540 100644
--- a/hw/xen_console.c
+++ b/hw/xen_console.c
@@ -179,8 +179,9 @@ static void xencons_send(struct XenConsole *con)
 static int con_init(struct XenDevice *xendev)
 {
     struct XenConsole *con = container_of(xendev, struct XenConsole, xendev);
-    char *type, *dom;
+    char *type, *dom, label[32];
     int ret = 0;
+    const char *output;
 
     /* setup */
     dom = xs_get_domain_path(xenstore, con->xendev.dom);
@@ -194,11 +195,14 @@ static int con_init(struct XenDevice *xendev)
         goto out;
     }
 
-    if (!serial_hds[con->xendev.dev])
-	xen_be_printf(xendev, 1, "WARNING: serial line %d not configured\n",
-                      con->xendev.dev);
-    else
-        con->chr = serial_hds[con->xendev.dev];
+    output = xenstore_read_str(con->console, "output");
+    /* output is a pty by default */
+    if (output == NULL) {
+        output = "pty";
+    }
+    snprintf(label, sizeof(label), "xencons%d", con->xendev.dev);
+    con->chr = qemu_chr_open(label, output, NULL);
+    xenstore_store_pv_console_info(con->xendev.dev, con->chr);
 
 out:
     qemu_free(type);
diff --git a/xen-all.c b/xen-all.c
index fb9bcc8..8105c83 100644
--- a/xen-all.c
+++ b/xen-all.c
@@ -737,6 +737,66 @@ static void cpu_handle_ioreq(void *opaque)
     }
 }
 
+static int store_dev_info(int domid, CharDriverState *cs, const char *string)
+{
+    struct xs_handle *xs = NULL;
+    char *path = NULL;
+    char *newpath = NULL;
+    char *pts = NULL;
+    int ret = -1;
+
+    /* Only continue if we're talking to a pty. */
+    if (strncmp(cs->filename, "pty:", 4)) {
+        return 0;
+    }
+    pts = cs->filename + 4;
+
+    /* We now have everything we need to set the xenstore entry. */
+    xs = xs_open(0);
+    if (xs == NULL) {
+        fprintf(stderr, "Could not contact XenStore\n");
+        goto out;
+    }
+
+    path = xs_get_domain_path(xs, domid);
+    if (path == NULL) {
+        fprintf(stderr, "xs_get_domain_path() error\n");
+        goto out;
+    }
+    newpath = realloc(path, (strlen(path) + strlen(string) +
+                strlen("/tty") + 1));
+    if (newpath == NULL) {
+        fprintf(stderr, "realloc error\n");
+        goto out;
+    }
+    path = newpath;
+
+    strcat(path, string);
+    strcat(path, "/tty");
+    if (!xs_write(xs, XBT_NULL, path, pts, strlen(pts))) {
+        fprintf(stderr, "xs_write for '%s' fail", string);
+        goto out;
+    }
+    ret = 0;
+
+out:
+    free(path);
+    xs_close(xs);
+
+    return ret;
+}
+
+void xenstore_store_pv_console_info(int i, CharDriverState *chr)
+{
+    if (i == 0) {
+        store_dev_info(xen_domid, chr, "/console");
+    } else {
+        char buf[32];
+        snprintf(buf, sizeof(buf), "/device/console/%d", i);
+        store_dev_info(xen_domid, chr, buf);
+    }
+}
+
 static void xenstore_record_dm_state(XenIOState *s, const char *state)
 {
     char path[50];
-- 
1.6.0.2

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

* [Qemu-devel] [PATCH 12/12] xen_console: fall back to qemu serial device
  2011-07-05 16:51 [Qemu-devel] [PULL 00/12] Xen patch queue 2011-07-05 Alexander Graf
                   ` (10 preceding siblings ...)
  2011-07-05 16:51 ` [Qemu-devel] [PATCH 11/12] xen_console: support the new extended xenstore protocol Alexander Graf
@ 2011-07-05 16:51 ` Alexander Graf
  2011-07-19 15:59 ` [Qemu-devel] [PULL 00/12] Xen patch queue 2011-07-05 Anthony Liguori
  12 siblings, 0 replies; 15+ messages in thread
From: Alexander Graf @ 2011-07-05 16:51 UTC (permalink / raw)
  To: qemu-devel@nongnu.org Developers; +Cc: xen-devel@lists.xensource.com Devel

The new xen_console protocol changed the default xen_console output device
from whatever Qemu chose to whatever xenstore choses and "pty" as fallback.

This is not how Qemu works. It has its own serial redirection semantics. So
it xenstore doesn't contain information on what to do, Qemu is the place to
ask.

Signed-off-by: Alexander Graf <agraf@suse.de>
---
 hw/xen_console.c |   11 +++++++----
 1 files changed, 7 insertions(+), 4 deletions(-)

diff --git a/hw/xen_console.c b/hw/xen_console.c
index bdb8540..8ef104c 100644
--- a/hw/xen_console.c
+++ b/hw/xen_console.c
@@ -196,12 +196,15 @@ static int con_init(struct XenDevice *xendev)
     }
 
     output = xenstore_read_str(con->console, "output");
-    /* output is a pty by default */
+
+    /* no Xen override, use qemu output device */
     if (output == NULL) {
-        output = "pty";
+        con->chr = serial_hds[con->xendev.dev];
+    } else {
+        snprintf(label, sizeof(label), "xencons%d", con->xendev.dev);
+        con->chr = qemu_chr_open(label, output, NULL);
     }
-    snprintf(label, sizeof(label), "xencons%d", con->xendev.dev);
-    con->chr = qemu_chr_open(label, output, NULL);
+
     xenstore_store_pv_console_info(con->xendev.dev, con->chr);
 
 out:
-- 
1.6.0.2

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

* Re: [Qemu-devel] [PATCH 08/12] qemu_ram_ptr_length: take ram_addr_t as arguments
  2011-07-05 16:51 ` [Qemu-devel] [PATCH 08/12] qemu_ram_ptr_length: take ram_addr_t as arguments Alexander Graf
@ 2011-07-06 13:12   ` Vasily Khoruzhick
  0 siblings, 0 replies; 15+ messages in thread
From: Vasily Khoruzhick @ 2011-07-06 13:12 UTC (permalink / raw)
  To: qemu-devel
  Cc: xen-devel@lists.xensource.com Devel, Alexander Graf,
	Stefano Stabellini

On Tuesday 05 July 2011 19:51:09 Alexander Graf wrote:
> From: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> 
> qemu_ram_ptr_length should take ram_addr_t as argument rather than
> target_phys_addr_t because is doing comparisons with RAMBlock addresses.
> 
> cpu_physical_memory_map should create a ram_addr_t address to pass to
> qemu_ram_ptr_length from PhysPageDesc phys_offset.
> 
> Remove code after abort() in qemu_ram_ptr_length.
> 
> Changes in v2:
> 
> - handle 0 size in qemu_ram_ptr_length;
> 
> - rename addr1 to raddr;
> 
> - initialize raddr to ULONG_MAX.
> 
> Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>
> Reviewed-by: Peter Maydell <peter.maydell@linaro.org>
> Signed-off-by: Alexander Graf <agraf@suse.de>

Tested-by: Vasily Khoruzhick <anarsoul@gmail.com>

> ---
>  cpu-common.h |    2 +-
>  exec.c       |   21 ++++++++++++++-------
>  2 files changed, 15 insertions(+), 8 deletions(-)
> 
> diff --git a/cpu-common.h b/cpu-common.h
> index b027e43..e4fcded 100644
> --- a/cpu-common.h
> +++ b/cpu-common.h
> @@ -65,7 +65,7 @@ void qemu_ram_free_from_ptr(ram_addr_t addr);
>  void qemu_ram_remap(ram_addr_t addr, ram_addr_t length);
>  /* This should only be used for ram local to a device.  */
>  void *qemu_get_ram_ptr(ram_addr_t addr);
> -void *qemu_ram_ptr_length(target_phys_addr_t addr, target_phys_addr_t
> *size); +void *qemu_ram_ptr_length(ram_addr_t addr, ram_addr_t *size);
>  /* Same but slower, to use for migration, where the order of
>   * RAMBlocks must not change. */
>  void *qemu_safe_ram_ptr(ram_addr_t addr);
> diff --git a/exec.c b/exec.c
> index 5604946..c0673c2 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -3167,8 +3167,11 @@ void *qemu_safe_ram_ptr(ram_addr_t addr)
> 
>  /* Return a host pointer to guest's ram. Similar to qemu_get_ram_ptr
>   * but takes a size argument */
> -void *qemu_ram_ptr_length(target_phys_addr_t addr, target_phys_addr_t
> *size) +void *qemu_ram_ptr_length(ram_addr_t addr, ram_addr_t *size)
>  {
> +    if (*size == 0) {
> +        return NULL;
> +    }
>      if (xen_enabled()) {
>          return xen_map_cache(addr, *size, 1);
>      } else {
> @@ -3184,9 +3187,6 @@ void *qemu_ram_ptr_length(target_phys_addr_t addr,
> target_phys_addr_t *size)
> 
>          fprintf(stderr, "Bad ram offset %" PRIx64 "\n", (uint64_t)addr);
>          abort();
> -
> -        *size = 0;
> -        return NULL;
>      }
>  }
> 
> @@ -4052,7 +4052,9 @@ void *cpu_physical_memory_map(target_phys_addr_t
> addr, target_phys_addr_t page;
>      unsigned long pd;
>      PhysPageDesc *p;
> -    target_phys_addr_t addr1 = addr;
> +    ram_addr_t raddr = ULONG_MAX;
> +    ram_addr_t rlen;
> +    void *ret;
> 
>      while (len > 0) {
>          page = addr & TARGET_PAGE_MASK;
> @@ -4080,13 +4082,18 @@ void *cpu_physical_memory_map(target_phys_addr_t
> addr, *plen = l;
>              return bounce.buffer;
>          }
> +        if (!todo) {
> +            raddr = (pd & TARGET_PAGE_MASK) + (addr & ~TARGET_PAGE_MASK);
> +        }
> 
>          len -= l;
>          addr += l;
>          todo += l;
>      }
> -    *plen = todo;
> -    return qemu_ram_ptr_length(addr1, plen);
> +    rlen = todo;
> +    ret = qemu_ram_ptr_length(raddr, &rlen);
> +    *plen = rlen;
> +    return ret;
>  }
> 
>  /* Unmaps a memory region previously mapped by cpu_physical_memory_map().

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

* Re: [Qemu-devel] [PULL 00/12] Xen patch queue 2011-07-05
  2011-07-05 16:51 [Qemu-devel] [PULL 00/12] Xen patch queue 2011-07-05 Alexander Graf
                   ` (11 preceding siblings ...)
  2011-07-05 16:51 ` [Qemu-devel] [PATCH 12/12] xen_console: fall back to qemu serial device Alexander Graf
@ 2011-07-19 15:59 ` Anthony Liguori
  12 siblings, 0 replies; 15+ messages in thread
From: Anthony Liguori @ 2011-07-19 15:59 UTC (permalink / raw)
  To: Alexander Graf
  Cc: xen-devel@lists.xensource.com Devel,
	qemu-devel@nongnu.org Developers

On 07/05/2011 11:51 AM, Alexander Graf wrote:
> Hi Anthony,
>
> This is my current patch queue for Xen stuff that accumulated over
> the past few weeks.
>
> Please pull.

Pulled.  Thanks.

Regards,

Anthony Liguori

>
> Alex
>
> The following changes since commit 9312805d33e8b106bae356d13a8071fb37d75554:
>    Vasily Khoruzhick (1):
>          pxa2xx_lcd: add proper rotation support
>
> are available in the git repository at:
>
>    git://repo.or.cz/qemu/agraf.git xen-next
>
> Alexander Graf (2):
>        checkpatch: don't error out on },{ lines
>        xen_console: fall back to qemu serial device
>
> Jan Kiszka (3):
>        xen: Clean up build system
>        xen: Clean up map cache API naming
>        xen: Fold CONFIG_XEN_MAPCACHE into CONFIG_XEN
>
> Stefano Stabellini (7):
>        xen: enable console and disk backend in HVM mode
>        xen_console: fix memory leak
>        xen: add vkbd support for PV on HVM guests
>        xen_disk: cope with missing xenstore "params" node
>        qemu_ram_ptr_length: take ram_addr_t as arguments
>        xen_disk: treat "aio" as "raw"
>        xen_console: support the new extended xenstore protocol
>
>   Makefile.objs         |    4 +-
>   Makefile.target       |   14 +--------
>   configure             |    2 +-
>   cpu-common.h          |    2 +-
>   exec.c                |   55 +++++++++++++++++++++---------------
>   hw/xen.h              |   10 +------
>   hw/xen_common.h       |   12 ++++++++
>   hw/xen_console.c      |   25 ++++++++++++-----
>   hw/xen_disk.c         |   37 ++++++++++++++++++++-----
>   hw/xenfb.c            |   19 ++++++++-----
>   scripts/checkpatch.pl |    4 ++-
>   trace-events          |    6 ++--
>   xen-all.c             |   73 +++++++++++++++++++++++++++++++++++++++++++++++-
>   xen-mapcache-stub.c   |   36 ------------------------
>   xen-mapcache.c        |   41 +++++++++++++++------------
>   xen-mapcache.h        |   14 ++++-----
>   16 files changed, 217 insertions(+), 137 deletions(-)
>   delete mode 100644 xen-mapcache-stub.c
>
>
>

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

end of thread, other threads:[~2011-07-19 15:59 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-07-05 16:51 [Qemu-devel] [PULL 00/12] Xen patch queue 2011-07-05 Alexander Graf
2011-07-05 16:51 ` [Qemu-devel] [PATCH 01/12] xen: Clean up build system Alexander Graf
2011-07-05 16:51 ` [Qemu-devel] [PATCH 02/12] xen: Clean up map cache API naming Alexander Graf
2011-07-05 16:51 ` [Qemu-devel] [PATCH 03/12] xen: Fold CONFIG_XEN_MAPCACHE into CONFIG_XEN Alexander Graf
2011-07-05 16:51 ` [Qemu-devel] [PATCH 04/12] xen: enable console and disk backend in HVM mode Alexander Graf
2011-07-05 16:51 ` [Qemu-devel] [PATCH 05/12] xen_console: fix memory leak Alexander Graf
2011-07-05 16:51 ` [Qemu-devel] [PATCH 06/12] xen: add vkbd support for PV on HVM guests Alexander Graf
2011-07-05 16:51 ` [Qemu-devel] [PATCH 07/12] xen_disk: cope with missing xenstore "params" node Alexander Graf
2011-07-05 16:51 ` [Qemu-devel] [PATCH 08/12] qemu_ram_ptr_length: take ram_addr_t as arguments Alexander Graf
2011-07-06 13:12   ` Vasily Khoruzhick
2011-07-05 16:51 ` [Qemu-devel] [PATCH 09/12] xen_disk: treat "aio" as "raw" Alexander Graf
2011-07-05 16:51 ` [Qemu-devel] [PATCH 10/12] checkpatch: don't error out on }, { lines Alexander Graf
2011-07-05 16:51 ` [Qemu-devel] [PATCH 11/12] xen_console: support the new extended xenstore protocol Alexander Graf
2011-07-05 16:51 ` [Qemu-devel] [PATCH 12/12] xen_console: fall back to qemu serial device Alexander Graf
2011-07-19 15:59 ` [Qemu-devel] [PULL 00/12] Xen patch queue 2011-07-05 Anthony Liguori

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