Re: [Qemu-devel] [PATCH 8/8] vring: remove

2016-02-16 Thread Fam Zheng
On Sun, 02/14 18:17, Paolo Bonzini wrote:
> Signed-off-by: Paolo Bonzini 
> ---
>  hw/virtio/Makefile.objs   |   1 -
>  hw/virtio/dataplane/Makefile.objs |   1 -
>  hw/virtio/dataplane/vring.c   | 548 
> --
>  include/hw/virtio/dataplane/vring-accessors.h |  75 
>  include/hw/virtio/dataplane/vring.h   |  51 ---
>  trace-events  |   3 -
>  6 files changed, 679 deletions(-)
>  delete mode 100644 hw/virtio/dataplane/Makefile.objs
>  delete mode 100644 hw/virtio/dataplane/vring.c
>  delete mode 100644 include/hw/virtio/dataplane/vring-accessors.h
>  delete mode 100644 include/hw/virtio/dataplane/vring.h

Bravo!

Reviewed-by: Fam Zheng 

> 
> diff --git a/hw/virtio/Makefile.objs b/hw/virtio/Makefile.objs
> index 19b224a..3e2b175 100644
> --- a/hw/virtio/Makefile.objs
> +++ b/hw/virtio/Makefile.objs
> @@ -2,7 +2,6 @@ common-obj-y += virtio-rng.o
>  common-obj-$(CONFIG_VIRTIO_PCI) += virtio-pci.o
>  common-obj-y += virtio-bus.o
>  common-obj-y += virtio-mmio.o
> -obj-$(CONFIG_VIRTIO) += dataplane/
>  
>  obj-y += virtio.o virtio-balloon.o 
>  obj-$(CONFIG_LINUX) += vhost.o vhost-backend.o vhost-user.o
> diff --git a/hw/virtio/dataplane/Makefile.objs 
> b/hw/virtio/dataplane/Makefile.objs
> deleted file mode 100644
> index 753a9ca..000
> --- a/hw/virtio/dataplane/Makefile.objs
> +++ /dev/null
> @@ -1 +0,0 @@
> -obj-y += vring.o
> diff --git a/hw/virtio/dataplane/vring.c b/hw/virtio/dataplane/vring.c
> deleted file mode 100644
> index 157e8b8..000
> --- a/hw/virtio/dataplane/vring.c
> +++ /dev/null
> @@ -1,548 +0,0 @@
> -/* Copyright 2012 Red Hat, Inc.
> - * Copyright IBM, Corp. 2012
> - *
> - * Based on Linux 2.6.39 vhost code:
> - * Copyright (C) 2009 Red Hat, Inc.
> - * Copyright (C) 2006 Rusty Russell IBM Corporation
> - *
> - * Author: Michael S. Tsirkin 
> - * Stefan Hajnoczi 
> - *
> - * Inspiration, some code, and most witty comments come from
> - * Documentation/virtual/lguest/lguest.c, by Rusty Russell
> - *
> - * This work is licensed under the terms of the GNU GPL, version 2.
> - */
> -
> -#include "qemu/osdep.h"
> -#include "trace.h"
> -#include "hw/hw.h"
> -#include "exec/memory.h"
> -#include "exec/address-spaces.h"
> -#include "hw/virtio/virtio-access.h"
> -#include "hw/virtio/dataplane/vring.h"
> -#include "hw/virtio/dataplane/vring-accessors.h"
> -#include "qemu/error-report.h"
> -
> -/* vring_map can be coupled with vring_unmap or (if you still have the
> - * value returned in *mr) memory_region_unref.
> - * Returns NULL on failure.
> - * Callers that can handle a partial mapping must supply mapped_len pointer 
> to
> - * get the actual length mapped.
> - * Passing mapped_len == NULL requires either a full mapping or a failure.
> - */
> -static void *vring_map(MemoryRegion **mr, hwaddr phys,
> -   hwaddr len, hwaddr *mapped_len,
> -   bool is_write)
> -{
> -MemoryRegionSection section = memory_region_find(get_system_memory(), 
> phys, len);
> -uint64_t size;
> -
> -if (!section.mr) {
> -goto out;
> -}
> -
> -size = int128_get64(section.size);
> -assert(size);
> -
> -/* Passing mapped_len == NULL requires either a full mapping or a 
> failure. */
> -if (!mapped_len && size < len) {
> -goto out;
> -}
> -
> -if (is_write && section.readonly) {
> -goto out;
> -}
> -if (!memory_region_is_ram(section.mr)) {
> -goto out;
> -}
> -
> -/* Ignore regions with dirty logging, we cannot mark them dirty */
> -if (memory_region_get_dirty_log_mask(section.mr)) {
> -goto out;
> -}
> -
> -if (mapped_len) {
> -*mapped_len = MIN(size, len);
> -}
> -
> -*mr = section.mr;
> -return memory_region_get_ram_ptr(section.mr) + 
> section.offset_within_region;
> -
> -out:
> -memory_region_unref(section.mr);
> -*mr = NULL;
> -return NULL;
> -}
> -
> -static void vring_unmap(void *buffer, bool is_write)
> -{
> -ram_addr_t addr;
> -MemoryRegion *mr;
> -
> -mr = qemu_ram_addr_from_host(buffer, );
> -memory_region_unref(mr);
> -}
> -
> -/* Map the guest's vring to host memory */
> -bool vring_setup(Vring *vring, VirtIODevice *vdev, int n)
> -{
> -struct vring *vr = >vr;
> -hwaddr addr;
> -hwaddr size;
> -void *ptr;
> -
> -vring->broken = false;
> -vr->num = virtio_queue_get_num(vdev, n);
> -
> -addr = virtio_queue_get_desc_addr(vdev, n);
> -size = virtio_queue_get_desc_size(vdev, n);
> -/* Map the descriptor area as read only */
> -ptr = vring_map(>mr_desc, addr, size, NULL, false);
> -if (!ptr) {
> -error_report("Failed to map 0x%" HWADDR_PRIx " byte for vring desc "
> - "at 0x%" HWADDR_PRIx,
> -  size, addr);
> -goto out_err_desc;
> 

[Qemu-devel] [PATCH 8/8] vring: remove

2016-02-14 Thread Paolo Bonzini
Signed-off-by: Paolo Bonzini 
---
 hw/virtio/Makefile.objs   |   1 -
 hw/virtio/dataplane/Makefile.objs |   1 -
 hw/virtio/dataplane/vring.c   | 548 --
 include/hw/virtio/dataplane/vring-accessors.h |  75 
 include/hw/virtio/dataplane/vring.h   |  51 ---
 trace-events  |   3 -
 6 files changed, 679 deletions(-)
 delete mode 100644 hw/virtio/dataplane/Makefile.objs
 delete mode 100644 hw/virtio/dataplane/vring.c
 delete mode 100644 include/hw/virtio/dataplane/vring-accessors.h
 delete mode 100644 include/hw/virtio/dataplane/vring.h

diff --git a/hw/virtio/Makefile.objs b/hw/virtio/Makefile.objs
index 19b224a..3e2b175 100644
--- a/hw/virtio/Makefile.objs
+++ b/hw/virtio/Makefile.objs
@@ -2,7 +2,6 @@ common-obj-y += virtio-rng.o
 common-obj-$(CONFIG_VIRTIO_PCI) += virtio-pci.o
 common-obj-y += virtio-bus.o
 common-obj-y += virtio-mmio.o
-obj-$(CONFIG_VIRTIO) += dataplane/
 
 obj-y += virtio.o virtio-balloon.o 
 obj-$(CONFIG_LINUX) += vhost.o vhost-backend.o vhost-user.o
diff --git a/hw/virtio/dataplane/Makefile.objs 
b/hw/virtio/dataplane/Makefile.objs
deleted file mode 100644
index 753a9ca..000
--- a/hw/virtio/dataplane/Makefile.objs
+++ /dev/null
@@ -1 +0,0 @@
-obj-y += vring.o
diff --git a/hw/virtio/dataplane/vring.c b/hw/virtio/dataplane/vring.c
deleted file mode 100644
index 157e8b8..000
--- a/hw/virtio/dataplane/vring.c
+++ /dev/null
@@ -1,548 +0,0 @@
-/* Copyright 2012 Red Hat, Inc.
- * Copyright IBM, Corp. 2012
- *
- * Based on Linux 2.6.39 vhost code:
- * Copyright (C) 2009 Red Hat, Inc.
- * Copyright (C) 2006 Rusty Russell IBM Corporation
- *
- * Author: Michael S. Tsirkin 
- * Stefan Hajnoczi 
- *
- * Inspiration, some code, and most witty comments come from
- * Documentation/virtual/lguest/lguest.c, by Rusty Russell
- *
- * This work is licensed under the terms of the GNU GPL, version 2.
- */
-
-#include "qemu/osdep.h"
-#include "trace.h"
-#include "hw/hw.h"
-#include "exec/memory.h"
-#include "exec/address-spaces.h"
-#include "hw/virtio/virtio-access.h"
-#include "hw/virtio/dataplane/vring.h"
-#include "hw/virtio/dataplane/vring-accessors.h"
-#include "qemu/error-report.h"
-
-/* vring_map can be coupled with vring_unmap or (if you still have the
- * value returned in *mr) memory_region_unref.
- * Returns NULL on failure.
- * Callers that can handle a partial mapping must supply mapped_len pointer to
- * get the actual length mapped.
- * Passing mapped_len == NULL requires either a full mapping or a failure.
- */
-static void *vring_map(MemoryRegion **mr, hwaddr phys,
-   hwaddr len, hwaddr *mapped_len,
-   bool is_write)
-{
-MemoryRegionSection section = memory_region_find(get_system_memory(), 
phys, len);
-uint64_t size;
-
-if (!section.mr) {
-goto out;
-}
-
-size = int128_get64(section.size);
-assert(size);
-
-/* Passing mapped_len == NULL requires either a full mapping or a failure. 
*/
-if (!mapped_len && size < len) {
-goto out;
-}
-
-if (is_write && section.readonly) {
-goto out;
-}
-if (!memory_region_is_ram(section.mr)) {
-goto out;
-}
-
-/* Ignore regions with dirty logging, we cannot mark them dirty */
-if (memory_region_get_dirty_log_mask(section.mr)) {
-goto out;
-}
-
-if (mapped_len) {
-*mapped_len = MIN(size, len);
-}
-
-*mr = section.mr;
-return memory_region_get_ram_ptr(section.mr) + 
section.offset_within_region;
-
-out:
-memory_region_unref(section.mr);
-*mr = NULL;
-return NULL;
-}
-
-static void vring_unmap(void *buffer, bool is_write)
-{
-ram_addr_t addr;
-MemoryRegion *mr;
-
-mr = qemu_ram_addr_from_host(buffer, );
-memory_region_unref(mr);
-}
-
-/* Map the guest's vring to host memory */
-bool vring_setup(Vring *vring, VirtIODevice *vdev, int n)
-{
-struct vring *vr = >vr;
-hwaddr addr;
-hwaddr size;
-void *ptr;
-
-vring->broken = false;
-vr->num = virtio_queue_get_num(vdev, n);
-
-addr = virtio_queue_get_desc_addr(vdev, n);
-size = virtio_queue_get_desc_size(vdev, n);
-/* Map the descriptor area as read only */
-ptr = vring_map(>mr_desc, addr, size, NULL, false);
-if (!ptr) {
-error_report("Failed to map 0x%" HWADDR_PRIx " byte for vring desc "
- "at 0x%" HWADDR_PRIx,
-  size, addr);
-goto out_err_desc;
-}
-vr->desc = ptr;
-
-addr = virtio_queue_get_avail_addr(vdev, n);
-size = virtio_queue_get_avail_size(vdev, n);
-/* Add the size of the used_event_idx */
-size += sizeof(uint16_t);
-/* Map the driver area as read only */
-ptr = vring_map(>mr_avail, addr, size, NULL, false);
-if (!ptr) {
-error_report("Failed to map 0x%" HWADDR_PRIx " byte for vring