public inbox for kvm@vger.kernel.org
 help / color / mirror / Atom feed
From: Glauber Costa <glommer@redhat.com>
To: Jan Kiszka <jan.kiszka@web.de>
Cc: Glauber Costa <gcosta@redhat.com>,
	kvm@vger.kernel.org, avi@qumranet.com, aliguori@us.ibm.com
Subject: Re: [PATCH] remove KVM_CAP_USER_MEMORY reference from qemu-kvm.c
Date: Wed, 10 Sep 2008 16:37:09 -0300	[thread overview]
Message-ID: <20080910193709.GD17969@poweredge.glommer> (raw)
In-Reply-To: <48C81EA6.10307@web.de>

On Wed, Sep 10, 2008 at 09:23:18PM +0200, Jan Kiszka wrote:
> Glauber Costa wrote:
> > From: Glauber Costa <glommer@redhat.com>
> > 
> > kvm_cpu_register_physical_memory() is its only user. Remove it.
> > 
> > Signed-off-by: Glauber Costa <glommer@redhat.com>
> > ---
> >  qemu/qemu-kvm.c |   52 +++++++++++++++++++++-------------------------------
> >  1 files changed, 21 insertions(+), 31 deletions(-)
> > 
> > diff --git a/qemu/qemu-kvm.c b/qemu/qemu-kvm.c
> > index 8d366e5..f0ef21e 100644
> > --- a/qemu/qemu-kvm.c
> > +++ b/qemu/qemu-kvm.c
> > @@ -775,42 +775,32 @@ void kvm_cpu_register_physical_memory(target_phys_addr_t start_addr,
> >                                        unsigned long size,
> >                                        unsigned long phys_offset)
> >  {
> > -#ifdef KVM_CAP_USER_MEMORY
> >      int r = 0;
> > -
> > -    r = kvm_check_extension(kvm_context, KVM_CAP_USER_MEMORY);
> > -    if (r) {
> > -        if (!(phys_offset & ~TARGET_PAGE_MASK)) {
> > -                r = kvm_is_allocated_mem(kvm_context, start_addr, size);
> > -            if (r)
> > -                return;
> > -            r = kvm_is_intersecting_mem(kvm_context, start_addr);
> > -            if (r)
> > -                kvm_create_mem_hole(kvm_context, start_addr, size);
> > -            r = kvm_register_userspace_phys_mem(kvm_context, start_addr,
> > -                                                phys_ram_base + phys_offset,
> > -                                                size, 0);
> > -        }
> > -        if (phys_offset & IO_MEM_ROM) {
> > -            phys_offset &= ~IO_MEM_ROM;
> > -            r = kvm_is_intersecting_mem(kvm_context, start_addr);
> > -            if (r)
> > -                kvm_create_mem_hole(kvm_context, start_addr, size);
> > -            r = kvm_register_userspace_phys_mem(kvm_context, start_addr,
> > -                                                phys_ram_base + phys_offset,
> > -                                                size, 0);
> > -        }
> > -        if (r < 0) {
> > -            printf("kvm_cpu_register_physical_memory: failed\n");
> > -            exit(1);
> > -        }
> > -        return;
> > +    if (!(phys_offset & ~TARGET_PAGE_MASK)) {
> > +        r = kvm_is_allocated_mem(kvm_context, start_addr, size);
> > +        if (r)
> > +            return;
> > +        r = kvm_is_intersecting_mem(kvm_context, start_addr);
> > +        if (r)
> > +            kvm_create_mem_hole(kvm_context, start_addr, size);
> > +        r = kvm_register_userspace_phys_mem(kvm_context, start_addr,
> > +                                            phys_ram_base + phys_offset,
> > +                                            size, 0);
> >      }
> > -#endif
> >      if (phys_offset & IO_MEM_ROM) {
> 
> At this chance: Shouldn't this become 'else if'?

fyi: just sent out a new series, this time with numbers and no tabs in qemu ;-)

As a coding style practice, yes. But they are mutually exclusive anyway, so it shouldn't
matter. We could definitely try to make it better, but they way to go is to have only one case
instead of two: look at how close they are to each other! I have a later series that do that,
so I'm just trying to set up the ground here.

> 
> >          phys_offset &= ~IO_MEM_ROM;
> > -        memcpy(phys_ram_base + start_addr, phys_ram_base + phys_offset, size);
> > +        r = kvm_is_intersecting_mem(kvm_context, start_addr);
> > +        if (r)
> > +            kvm_create_mem_hole(kvm_context, start_addr, size);
> > +        r = kvm_register_userspace_phys_mem(kvm_context, start_addr,
> > +                                            phys_ram_base + phys_offset,
> > +                                            size, 0);
> > +    }
> > +    if (r < 0) {
> > +        printf("kvm_cpu_register_physical_memory: failed\n");
> > +        exit(1);
> >      }
> > +    return;
> >  }
> >  
> >  int kvm_setup_guest_memory(void *area, unsigned long size)
> 
> Jan
> 



  reply	other threads:[~2008-09-10 19:40 UTC|newest]

Thread overview: 33+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-09-08 19:30 [PATCH 0/12] Get rid of kernel memory allocation Glauber Costa
2008-09-08 19:30 ` [PATCH] start removing kernel memory functions Glauber Costa
2008-09-08 19:30   ` [PATCH] remove tests of user memory from vl.c Glauber Costa
2008-09-08 19:30     ` [PATCH] coalesce memory allocation Glauber Costa
2008-09-08 19:30       ` [PATCH] remove KVM_CAP_USER_MEMORY reference from qemu-kvm.c Glauber Costa
2008-09-08 19:30         ` [PATCH] remove KVM_CAP_USER_MEMORY from libkvm.c Glauber Costa
2008-09-08 19:30           ` [PATCH] remove create_kernel_phys_mem Glauber Costa
2008-09-08 19:30             ` [PATCH] get rid of kvm_create_userspace_phys_mem Glauber Costa
2008-09-08 19:30               ` [PATCH] remove user_alloc field from slot representation Glauber Costa
2008-09-08 19:30                 ` [PATCH] merge destroy phys mem functions Glauber Costa
2008-09-08 19:30                   ` [PATCH] rename kvm_register_userspace_phys_mem Glauber Costa
2008-09-08 19:30                     ` [PATCH] remove kernel memory code from hw/pc.c Glauber Costa
2008-09-08 19:30                       ` [PATCH] remove kernel memory allocation code from ipf.c Glauber Costa
2008-09-10 19:23         ` [PATCH] remove KVM_CAP_USER_MEMORY reference from qemu-kvm.c Jan Kiszka
2008-09-10 19:37           ` Glauber Costa [this message]
2008-09-10 19:59             ` Jan Kiszka
2008-09-09 14:25 ` [PATCH 0/12] Get rid of kernel memory allocation Avi Kivity
2008-09-09 14:57   ` Glauber Costa
2008-09-09 15:01     ` Avi Kivity
2008-09-10 19:20 ` [PATCH 0/12] get rid of kernel memory registration Glauber Costa
2008-09-11  8:59   ` Avi Kivity
2008-09-10 19:20 ` [PATCH 01/12] start removing kernel memory functions Glauber Costa
2008-09-10 19:20 ` [PATCH 02/12] remove tests of user memory from vl.c Glauber Costa
2008-09-10 19:20 ` [PATCH 03/12] coalesce memory allocation Glauber Costa
2008-09-10 19:20 ` [PATCH 04/12] remove KVM_CAP_USER_MEMORY reference from qemu-kvm.c Glauber Costa
2008-09-10 19:20 ` [PATCH 05/12] remove KVM_CAP_USER_MEMORY from libkvm.c Glauber Costa
2008-09-10 19:21 ` [PATCH 06/12] remove create_kernel_phys_mem Glauber Costa
2008-09-10 19:21 ` [PATCH 07/12] get rid of kvm_create_userspace_phys_mem Glauber Costa
2008-09-10 19:21 ` [PATCH 08/12] remove user_alloc field from slot representation Glauber Costa
2008-09-10 19:21 ` [PATCH 09/12] merge destroy phys mem functions Glauber Costa
2008-09-10 19:21 ` [PATCH 10/12] rename kvm_register_userspace_phys_mem Glauber Costa
2008-09-10 19:21 ` [PATCH 11/12] remove kernel memory code from hw/pc.c Glauber Costa
2008-09-10 19:21 ` [PATCH 12/12] remove kernel memory allocation code from ipf.c Glauber Costa

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=20080910193709.GD17969@poweredge.glommer \
    --to=glommer@redhat.com \
    --cc=aliguori@us.ibm.com \
    --cc=avi@qumranet.com \
    --cc=gcosta@redhat.com \
    --cc=jan.kiszka@web.de \
    --cc=kvm@vger.kernel.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