qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
From: Paolo Bonzini <pbonzini@redhat.com>
To: Jens Freimann <jfrei@linux.vnet.ibm.com>,
	Christian Borntraeger <borntraeger@de.ibm.com>,
	Alexander Graf <agraf@suse.de>,
	Cornelia Huck <cornelia.huck@de.ibm.com>
Cc: qemu-devel@nongnu.org, Dominik Dingel <dingel@linux.vnet.ibm.com>
Subject: Re: [Qemu-devel] [PATCH 1/6] kvm: encapsulate HAS_DEVICE for vm attrs
Date: Thu, 12 Mar 2015 17:47:03 +0100	[thread overview]
Message-ID: <5501C307.3010602@redhat.com> (raw)
In-Reply-To: <1426164834-38648-2-git-send-email-jfrei@linux.vnet.ibm.com>



On 12/03/2015 13:53, Jens Freimann wrote:
> From: Dominik Dingel <dingel@linux.vnet.ibm.com>
> 
> More and more virtual machine specifics between kvm and qemu will be
> transferred with vm attributes.
> So we encapsulate the common logic in a generic function.
> 
> Additionally we need only to check during initialization if kvm supports
> virtual machine attributes.
> 
> Cc: Paolo Bonzini <pbonzini@redhat.com>
> Suggested-by: Thomas Huth <thuth@linux.vnet.ibm.com>
> Reviewed-by: Thomas Huth <thuth@linux.vnet.ibm.com>
> Signed-off-by: Dominik Dingel <dingel@linux.vnet.ibm.com>
> Signed-off-by: Jens Freimann <jfrei@linux.vnet.ibm.com>
> ---
>  include/sysemu/kvm.h | 12 ++++++++++++
>  kvm-all.c            | 21 +++++++++++++++++++++
>  2 files changed, 33 insertions(+)
> 
> diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
> index 30cb84d..1fcde16 100644
> --- a/include/sysemu/kvm.h
> +++ b/include/sysemu/kvm.h
> @@ -225,6 +225,18 @@ int kvm_vcpu_ioctl(CPUState *cpu, int type, ...);
>  int kvm_device_ioctl(int fd, int type, ...);
>  
>  /**
> + * kvm_vm_check_attr - check for existence of a specific vm attribute
> + * @s: The KVMState pointer
> + * @group: the group
> + * @attr: the attribute of that group to query for
> + *
> + * Returns: 1 if the attribute exists
> + *          0 if the attribute either does not exist or if the vm device
> + *            interface is unavailable
> + */
> +int kvm_vm_check_attr(KVMState *s, uint32_t group, uint64_t attr);
> +
> +/**
>   * kvm_create_device - create a KVM device for the device control API
>   * @KVMState: The KVMState pointer
>   * @type: The KVM device type (see Documentation/virtual/kvm/devices in the
> diff --git a/kvm-all.c b/kvm-all.c
> index 05a79c2..e1ca8e0 100644
> --- a/kvm-all.c
> +++ b/kvm-all.c
> @@ -126,6 +126,7 @@ bool kvm_gsi_routing_allowed;
>  bool kvm_gsi_direct_mapping;
>  bool kvm_allowed;
>  bool kvm_readonly_mem_allowed;
> +bool kvm_vm_attributes_allowed;
>  
>  static const KVMCapabilityInfo kvm_required_capabilites[] = {
>      KVM_CAP_INFO(USER_MEMORY),
> @@ -1598,6 +1599,9 @@ static int kvm_init(MachineState *ms)
>      kvm_resamplefds_allowed =
>          (kvm_check_extension(s, KVM_CAP_IRQFD_RESAMPLE) > 0);
>  
> +    kvm_vm_attributes_allowed =
> +        (kvm_check_extension(s, KVM_CAP_VM_ATTRIBUTES) > 0);
> +
>      ret = kvm_arch_init(s);
>      if (ret < 0) {
>          goto err;
> @@ -1936,6 +1940,23 @@ int kvm_device_ioctl(int fd, int type, ...)
>      return ret;
>  }
>  
> +int kvm_vm_check_attr(KVMState *s, uint32_t group, uint64_t attr)
> +{
> +    int ret;
> +    struct kvm_device_attr attribute = {
> +        .group = group,
> +        .attr = attr,
> +    };
> +
> +    if (!kvm_vm_attributes_allowed) {
> +        return 0;
> +    }
> +
> +    ret = kvm_vm_ioctl(s, KVM_HAS_DEVICE_ATTR, &attribute);
> +    /* kvm returns 0 on success for HAS_DEVICE_ATTR */
> +    return ret ? 0 : 1;
> +}
> +
>  int kvm_has_sync_mmu(void)
>  {
>      return kvm_check_extension(kvm_state, KVM_CAP_SYNC_MMU);
> 

Acked-by: Paolo Bonzini <pbonzini@redhat.com>

  reply	other threads:[~2015-03-12 16:47 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-03-12 12:53 [Qemu-devel] [PATCH 0/6] [PREVIEW] s390x/kvm: fixes and features Jens Freimann
2015-03-12 12:53 ` [Qemu-devel] [PATCH 1/6] kvm: encapsulate HAS_DEVICE for vm attrs Jens Freimann
2015-03-12 16:47   ` Paolo Bonzini [this message]
2015-03-12 12:53 ` [Qemu-devel] [PATCH 2/6] s390x/kvm: make use of generic vm attribute check Jens Freimann
2015-03-12 12:53 ` [Qemu-devel] [PATCH 3/6] s390x: CPACF: Handle key wrap machine options Jens Freimann
2015-03-12 12:53 ` [Qemu-devel] [PATCH 4/6] s390x/virtio-bus: Remove unused function s390_virtio_bus_console() Jens Freimann
2015-03-12 12:53 ` [Qemu-devel] [PATCH 5/6] s390x/ipl: remove dead code Jens Freimann
2015-03-12 12:53 ` [Qemu-devel] [PATCH 6/6] s390x/pci: fix length in sei_nt2 event Jens Freimann
2015-03-12 13:51 ` [Qemu-devel] [PATCH 0/6] [PREVIEW] s390x/kvm: fixes and features Jens Freimann
2015-03-13 10:09 ` Cornelia Huck

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=5501C307.3010602@redhat.com \
    --to=pbonzini@redhat.com \
    --cc=agraf@suse.de \
    --cc=borntraeger@de.ibm.com \
    --cc=cornelia.huck@de.ibm.com \
    --cc=dingel@linux.vnet.ibm.com \
    --cc=jfrei@linux.vnet.ibm.com \
    --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).