[Qemu-devel] [PATCH v2 13/15] qmp: Expose manual_dirty_log_protect via "query-kvm"

Peter Xu posted 15 patches 6 years, 5 months ago
Maintainers: Paolo Bonzini <pbonzini@redhat.com>, Eric Blake <eblake@redhat.com>, "Michael S. Tsirkin" <mst@redhat.com>, "Dr. David Alan Gilbert" <dgilbert@redhat.com>, Cornelia Huck <cohuck@redhat.com>, Juan Quintela <quintela@redhat.com>, Richard Henderson <rth@twiddle.net>, Markus Armbruster <armbru@redhat.com>
There is a newer version of this series
[Qemu-devel] [PATCH v2 13/15] qmp: Expose manual_dirty_log_protect via "query-kvm"
Posted by Peter Xu 6 years, 5 months ago
Expose the new capability via "query-kvm" QMP command too so we know
whether that's turned on on the source VM when we want.

Signed-off-by: Peter Xu <peterx@redhat.com>
---
 accel/kvm/kvm-all.c  | 5 +++++
 include/sysemu/kvm.h | 2 ++
 qapi/misc.json       | 6 +++++-
 qmp.c                | 1 +
 4 files changed, 13 insertions(+), 1 deletion(-)

diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 062bf8b5b0..c79d6b51e2 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -169,6 +169,11 @@ int kvm_memcrypt_encrypt_data(uint8_t *ptr, uint64_t len)
     return 1;
 }
 
+bool kvm_manual_dirty_log_protect_enabled(void)
+{
+    return kvm_state && kvm_state->manual_dirty_log_protect;
+}
+
 /* Must be with slots_lock held */
 static KVMSlot *kvm_get_free_slot(KVMMemoryListener *kml)
 {
diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
index a6d1cd190f..30757f1425 100644
--- a/include/sysemu/kvm.h
+++ b/include/sysemu/kvm.h
@@ -547,4 +547,6 @@ int kvm_set_one_reg(CPUState *cs, uint64_t id, void *source);
 int kvm_get_one_reg(CPUState *cs, uint64_t id, void *target);
 struct ppc_radix_page_info *kvm_get_radix_page_info(void);
 int kvm_get_max_memslots(void);
+bool kvm_manual_dirty_log_protect_enabled(void);
+
 #endif
diff --git a/qapi/misc.json b/qapi/misc.json
index 8b3ca4fdd3..ce7a76755a 100644
--- a/qapi/misc.json
+++ b/qapi/misc.json
@@ -253,9 +253,13 @@
 #
 # @present: true if KVM acceleration is built into this executable
 #
+# @manual-dirty-log-protect: true if manual dirty log protect is enabled
+#
 # Since: 0.14.0
 ##
-{ 'struct': 'KvmInfo', 'data': {'enabled': 'bool', 'present': 'bool'} }
+{ 'struct': 'KvmInfo', 'data':
+  {'enabled': 'bool', 'present': 'bool',
+   'manual-dirty-log-protect': 'bool' } }
 
 ##
 # @query-kvm:
diff --git a/qmp.c b/qmp.c
index b92d62cd5f..047bef032e 100644
--- a/qmp.c
+++ b/qmp.c
@@ -73,6 +73,7 @@ KvmInfo *qmp_query_kvm(Error **errp)
 
     info->enabled = kvm_enabled();
     info->present = kvm_available();
+    info->manual_dirty_log_protect = kvm_manual_dirty_log_protect_enabled();
 
     return info;
 }
-- 
2.17.1


Re: [Qemu-devel] [PATCH v2 13/15] qmp: Expose manual_dirty_log_protect via "query-kvm"
Posted by Paolo Bonzini 6 years, 5 months ago
On 20/05/19 05:08, Peter Xu wrote:
> Expose the new capability via "query-kvm" QMP command too so we know
> whether that's turned on on the source VM when we want.
> 
> Signed-off-by: Peter Xu <peterx@redhat.com>

Is this useful?  We could I guess make a migration capability in order
to benchmark with the old code, but otherwise I would just make this a
"hidden" optimization just like many others (same for patch 14).

In other words, there are many other capabilities that we could inform
the user about, I don't see what makes manual_dirty_log_protect special.

Paolo

> ---
>  accel/kvm/kvm-all.c  | 5 +++++
>  include/sysemu/kvm.h | 2 ++
>  qapi/misc.json       | 6 +++++-
>  qmp.c                | 1 +
>  4 files changed, 13 insertions(+), 1 deletion(-)
> 
> diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
> index 062bf8b5b0..c79d6b51e2 100644
> --- a/accel/kvm/kvm-all.c
> +++ b/accel/kvm/kvm-all.c
> @@ -169,6 +169,11 @@ int kvm_memcrypt_encrypt_data(uint8_t *ptr, uint64_t len)
>      return 1;
>  }
>  
> +bool kvm_manual_dirty_log_protect_enabled(void)
> +{
> +    return kvm_state && kvm_state->manual_dirty_log_protect;
> +}
> +
>  /* Must be with slots_lock held */
>  static KVMSlot *kvm_get_free_slot(KVMMemoryListener *kml)
>  {
> diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
> index a6d1cd190f..30757f1425 100644
> --- a/include/sysemu/kvm.h
> +++ b/include/sysemu/kvm.h
> @@ -547,4 +547,6 @@ int kvm_set_one_reg(CPUState *cs, uint64_t id, void *source);
>  int kvm_get_one_reg(CPUState *cs, uint64_t id, void *target);
>  struct ppc_radix_page_info *kvm_get_radix_page_info(void);
>  int kvm_get_max_memslots(void);
> +bool kvm_manual_dirty_log_protect_enabled(void);
> +
>  #endif
> diff --git a/qapi/misc.json b/qapi/misc.json
> index 8b3ca4fdd3..ce7a76755a 100644
> --- a/qapi/misc.json
> +++ b/qapi/misc.json
> @@ -253,9 +253,13 @@
>  #
>  # @present: true if KVM acceleration is built into this executable
>  #
> +# @manual-dirty-log-protect: true if manual dirty log protect is enabled
> +#
>  # Since: 0.14.0
>  ##
> -{ 'struct': 'KvmInfo', 'data': {'enabled': 'bool', 'present': 'bool'} }
> +{ 'struct': 'KvmInfo', 'data':
> +  {'enabled': 'bool', 'present': 'bool',
> +   'manual-dirty-log-protect': 'bool' } }
>  
>  ##
>  # @query-kvm:
> diff --git a/qmp.c b/qmp.c
> index b92d62cd5f..047bef032e 100644
> --- a/qmp.c
> +++ b/qmp.c
> @@ -73,6 +73,7 @@ KvmInfo *qmp_query_kvm(Error **errp)
>  
>      info->enabled = kvm_enabled();
>      info->present = kvm_available();
> +    info->manual_dirty_log_protect = kvm_manual_dirty_log_protect_enabled();
>  
>      return info;
>  }
> 


Re: [Qemu-devel] [PATCH v2 13/15] qmp: Expose manual_dirty_log_protect via "query-kvm"
Posted by Dr. David Alan Gilbert 6 years, 5 months ago
* Paolo Bonzini (pbonzini@redhat.com) wrote:
> On 20/05/19 05:08, Peter Xu wrote:
> > Expose the new capability via "query-kvm" QMP command too so we know
> > whether that's turned on on the source VM when we want.
> > 
> > Signed-off-by: Peter Xu <peterx@redhat.com>
> 
> Is this useful?  We could I guess make a migration capability in order
> to benchmark with the old code, but otherwise I would just make this a
> "hidden" optimization just like many others (same for patch 14).
> 
> In other words, there are many other capabilities that we could inform
> the user about, I don't see what makes manual_dirty_log_protect special.

Yes agreed, if your kernel has it then just use it.

Dave

> Paolo
> 
> > ---
> >  accel/kvm/kvm-all.c  | 5 +++++
> >  include/sysemu/kvm.h | 2 ++
> >  qapi/misc.json       | 6 +++++-
> >  qmp.c                | 1 +
> >  4 files changed, 13 insertions(+), 1 deletion(-)
> > 
> > diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
> > index 062bf8b5b0..c79d6b51e2 100644
> > --- a/accel/kvm/kvm-all.c
> > +++ b/accel/kvm/kvm-all.c
> > @@ -169,6 +169,11 @@ int kvm_memcrypt_encrypt_data(uint8_t *ptr, uint64_t len)
> >      return 1;
> >  }
> >  
> > +bool kvm_manual_dirty_log_protect_enabled(void)
> > +{
> > +    return kvm_state && kvm_state->manual_dirty_log_protect;
> > +}
> > +
> >  /* Must be with slots_lock held */
> >  static KVMSlot *kvm_get_free_slot(KVMMemoryListener *kml)
> >  {
> > diff --git a/include/sysemu/kvm.h b/include/sysemu/kvm.h
> > index a6d1cd190f..30757f1425 100644
> > --- a/include/sysemu/kvm.h
> > +++ b/include/sysemu/kvm.h
> > @@ -547,4 +547,6 @@ int kvm_set_one_reg(CPUState *cs, uint64_t id, void *source);
> >  int kvm_get_one_reg(CPUState *cs, uint64_t id, void *target);
> >  struct ppc_radix_page_info *kvm_get_radix_page_info(void);
> >  int kvm_get_max_memslots(void);
> > +bool kvm_manual_dirty_log_protect_enabled(void);
> > +
> >  #endif
> > diff --git a/qapi/misc.json b/qapi/misc.json
> > index 8b3ca4fdd3..ce7a76755a 100644
> > --- a/qapi/misc.json
> > +++ b/qapi/misc.json
> > @@ -253,9 +253,13 @@
> >  #
> >  # @present: true if KVM acceleration is built into this executable
> >  #
> > +# @manual-dirty-log-protect: true if manual dirty log protect is enabled
> > +#
> >  # Since: 0.14.0
> >  ##
> > -{ 'struct': 'KvmInfo', 'data': {'enabled': 'bool', 'present': 'bool'} }
> > +{ 'struct': 'KvmInfo', 'data':
> > +  {'enabled': 'bool', 'present': 'bool',
> > +   'manual-dirty-log-protect': 'bool' } }
> >  
> >  ##
> >  # @query-kvm:
> > diff --git a/qmp.c b/qmp.c
> > index b92d62cd5f..047bef032e 100644
> > --- a/qmp.c
> > +++ b/qmp.c
> > @@ -73,6 +73,7 @@ KvmInfo *qmp_query_kvm(Error **errp)
> >  
> >      info->enabled = kvm_enabled();
> >      info->present = kvm_available();
> > +    info->manual_dirty_log_protect = kvm_manual_dirty_log_protect_enabled();
> >  
> >      return info;
> >  }
> > 
> 
--
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK

Re: [Qemu-devel] [PATCH v2 13/15] qmp: Expose manual_dirty_log_protect via "query-kvm"
Posted by Peter Xu 6 years, 5 months ago
On Mon, May 20, 2019 at 12:44:29PM +0200, Paolo Bonzini wrote:
> On 20/05/19 05:08, Peter Xu wrote:
> > Expose the new capability via "query-kvm" QMP command too so we know
> > whether that's turned on on the source VM when we want.
> > 
> > Signed-off-by: Peter Xu <peterx@redhat.com>
> 
> Is this useful?  We could I guess make a migration capability in order
> to benchmark with the old code, but otherwise I would just make this a
> "hidden" optimization just like many others (same for patch 14).
> 
> In other words, there are many other capabilities that we could inform
> the user about, I don't see what makes manual_dirty_log_protect special.

Yes this is mostly used for me to make sure the new capability is
enabled when comparing with the old code.  I added QMP part too
because otherwise I'll need to justify why I only add HMP...

But I agree with above - let's drop these two QMP/HMP patches.

Thanks,

-- 
Peter Xu

Re: [Qemu-devel] [PATCH v2 13/15] qmp: Expose manual_dirty_log_protect via "query-kvm"
Posted by Eric Blake 6 years, 5 months ago
On 5/19/19 10:08 PM, Peter Xu wrote:
> Expose the new capability via "query-kvm" QMP command too so we know
> whether that's turned on on the source VM when we want.
> 
> Signed-off-by: Peter Xu <peterx@redhat.com>
> ---
>  accel/kvm/kvm-all.c  | 5 +++++
>  include/sysemu/kvm.h | 2 ++
>  qapi/misc.json       | 6 +++++-
>  qmp.c                | 1 +
>  4 files changed, 13 insertions(+), 1 deletion(-)
> 

> +++ b/qapi/misc.json
> @@ -253,9 +253,13 @@
>  #
>  # @present: true if KVM acceleration is built into this executable
>  #
> +# @manual-dirty-log-protect: true if manual dirty log protect is enabled
> +#

If we want this exposed (and Paolo is right that we might not), it needs
'(since 4.1)' designation.

>  # Since: 0.14.0
>  ##
> -{ 'struct': 'KvmInfo', 'data': {'enabled': 'bool', 'present': 'bool'} }
> +{ 'struct': 'KvmInfo', 'data':
> +  {'enabled': 'bool', 'present': 'bool',
> +   'manual-dirty-log-protect': 'bool' } }
>  
>  ##
>  # @query-kvm:
> diff --git a/qmp.c b/qmp.c
> index b92d62cd5f..047bef032e 100644
> --- a/qmp.c
> +++ b/qmp.c
> @@ -73,6 +73,7 @@ KvmInfo *qmp_query_kvm(Error **errp)
>  
>      info->enabled = kvm_enabled();
>      info->present = kvm_available();
> +    info->manual_dirty_log_protect = kvm_manual_dirty_log_protect_enabled();
>  
>      return info;
>  }
> 

-- 
Eric Blake, Principal Software Engineer
Red Hat, Inc.           +1-919-301-3226
Virtualization:  qemu.org | libvirt.org

Re: [Qemu-devel] [PATCH v2 13/15] qmp: Expose manual_dirty_log_protect via "query-kvm"
Posted by Peter Xu 6 years, 5 months ago
On Mon, May 20, 2019 at 11:30:01AM -0500, Eric Blake wrote:
> On 5/19/19 10:08 PM, Peter Xu wrote:
> > Expose the new capability via "query-kvm" QMP command too so we know
> > whether that's turned on on the source VM when we want.
> > 
> > Signed-off-by: Peter Xu <peterx@redhat.com>
> > ---
> >  accel/kvm/kvm-all.c  | 5 +++++
> >  include/sysemu/kvm.h | 2 ++
> >  qapi/misc.json       | 6 +++++-
> >  qmp.c                | 1 +
> >  4 files changed, 13 insertions(+), 1 deletion(-)
> > 
> 
> > +++ b/qapi/misc.json
> > @@ -253,9 +253,13 @@
> >  #
> >  # @present: true if KVM acceleration is built into this executable
> >  #
> > +# @manual-dirty-log-protect: true if manual dirty log protect is enabled
> > +#
> 
> If we want this exposed (and Paolo is right that we might not), it needs
> '(since 4.1)' designation.

Yes I'll drop them.  Still, thanks to review the grammar part (as
always).

-- 
Peter Xu