qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Anthony Liguori <anthony@codemonkey.ws>
To: Cam Macdonell <cam@cs.ualberta.ca>
Cc: qemu-devel@nongnu.org, kvm@vger.kernel.org
Subject: Re: [Qemu-devel] [PATCH v8 1/5] Add qemu_ram_alloc_from_ptr function
Date: Tue, 10 Aug 2010 16:28:18 -0500	[thread overview]
Message-ID: <4C61C472.2020806@codemonkey.ws> (raw)
In-Reply-To: <1280189461-1929-2-git-send-email-cam@cs.ualberta.ca>

On 07/26/2010 07:10 PM, Cam Macdonell wrote:
> Provide a function to add an allocated region of memory to the qemu RAM.
>
> This patch is copied from Marcelo's qemu_ram_map() in qemu-kvm and given the
> clearer name qemu_ram_alloc_from_ptr().
>
> Signed-off-by: Cam Macdonell<cam@cs.ualberta.ca>
>    

Applied all.  Thanks.

Regards,

Anthony Liguori

> ---
>   cpu-common.h |    2 ++
>   exec.c       |   43 +++++++++++++++++++++++++++++++++++++++++++
>   2 files changed, 45 insertions(+), 0 deletions(-)
>
> diff --git a/cpu-common.h b/cpu-common.h
> index 71e7933..0426bc8 100644
> --- a/cpu-common.h
> +++ b/cpu-common.h
> @@ -40,6 +40,8 @@ static inline void cpu_register_physical_memory(target_phys_addr_t start_addr,
>   }
>
>   ram_addr_t cpu_get_physical_page_desc(target_phys_addr_t addr);
> +ram_addr_t qemu_ram_alloc_from_ptr(DeviceState *dev, const char *name,
> +                        ram_addr_t size, void *host);
>   ram_addr_t qemu_ram_alloc(DeviceState *dev, const char *name, ram_addr_t size);
>   void qemu_ram_free(ram_addr_t addr);
>   /* This should only be used for ram local to a device.  */
> diff --git a/exec.c b/exec.c
> index 868cd7f..8636316 100644
> --- a/exec.c
> +++ b/exec.c
> @@ -2808,6 +2808,49 @@ static ram_addr_t last_ram_offset(void)
>       return last;
>   }
>
> +ram_addr_t qemu_ram_alloc_from_ptr(DeviceState *dev, const char *name,
> +                        ram_addr_t size, void *host)
> +{
> +    RAMBlock *new_block, *block;
> +
> +    size = TARGET_PAGE_ALIGN(size);
> +    new_block = qemu_mallocz(sizeof(*new_block));
> +
> +    if (dev&&  dev->parent_bus&&  dev->parent_bus->info->get_dev_path) {
> +        char *id = dev->parent_bus->info->get_dev_path(dev);
> +        if (id) {
> +            snprintf(new_block->idstr, sizeof(new_block->idstr), "%s/", id);
> +            qemu_free(id);
> +        }
> +    }
> +    pstrcat(new_block->idstr, sizeof(new_block->idstr), name);
> +
> +    QLIST_FOREACH(block,&ram_list.blocks, next) {
> +        if (!strcmp(block->idstr, new_block->idstr)) {
> +            fprintf(stderr, "RAMBlock \"%s\" already registered, abort!\n",
> +                    new_block->idstr);
> +            abort();
> +        }
> +    }
> +
> +    new_block->host = host;
> +
> +    new_block->offset = find_ram_offset(size);
> +    new_block->length = size;
> +
> +    QLIST_INSERT_HEAD(&ram_list.blocks, new_block, next);
> +
> +    ram_list.phys_dirty = qemu_realloc(ram_list.phys_dirty,
> +                                       last_ram_offset()>>  TARGET_PAGE_BITS);
> +    memset(ram_list.phys_dirty + (new_block->offset>>  TARGET_PAGE_BITS),
> +           0xff, size>>  TARGET_PAGE_BITS);
> +
> +    if (kvm_enabled())
> +        kvm_setup_guest_memory(new_block->host, size);
> +
> +    return new_block->offset;
> +}
> +
>   ram_addr_t qemu_ram_alloc(DeviceState *dev, const char *name, ram_addr_t size)
>   {
>       RAMBlock *new_block, *block;
>    

      parent reply	other threads:[~2010-08-10 21:28 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-27  0:10 [Qemu-devel] [PATCH v8 0/5] Inter-VM Shared Memory Device Cam Macdonell
2010-07-27  0:10 ` [Qemu-devel] [PATCH v8 1/5] Add qemu_ram_alloc_from_ptr function Cam Macdonell
2010-07-27  0:10   ` [Qemu-devel] [PATCH v8 2/5] Device specification for shared memory PCI device Cam Macdonell
2010-07-27  0:10     ` [Qemu-devel] [PATCH v8 3/5] Add function to assign ioeventfd to MMIO Cam Macdonell
2010-07-27  0:11       ` [Qemu-devel] [PATCH v8 4/5] Support marking a device as non-migratable Cam Macdonell
2010-07-27  0:11         ` [Qemu-devel] [PATCH v8 5/5] Inter-VM shared memory PCI device Cam Macdonell
2010-07-27 16:54           ` [Qemu-devel] [PATCH v8 5/5] RESEND: " Cam Macdonell
2010-08-11  8:35             ` Stefan Weil
2010-08-11 15:49               ` Cam Macdonell
2010-08-11 17:07                 ` Paolo Bonzini
2010-08-11 18:22                   ` Stefan Weil
2010-08-10 21:28   ` Anthony Liguori [this message]

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=4C61C472.2020806@codemonkey.ws \
    --to=anthony@codemonkey.ws \
    --cc=cam@cs.ualberta.ca \
    --cc=kvm@vger.kernel.org \
    --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).