* [PATCH] kvm: support to get/set dirty log initial-all-set capability
@ 2020-03-04 2:55 Jay Zhou
2020-03-04 15:48 ` Peter Xu
` (2 more replies)
0 siblings, 3 replies; 7+ messages in thread
From: Jay Zhou @ 2020-03-04 2:55 UTC (permalink / raw)
To: qemu-devel, kvm
Cc: pbonzini, mst, cohuck, peterx, wangxinxin.wang, weidong.huang,
liu.jinsong, jianjay.zhou
Since the new capability KVM_DIRTY_LOG_INITIALLY_SET of
KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 has been introduced in the
kernel, tweak the userspace side to detect and enable this
capability.
Signed-off-by: Jay Zhou <jianjay.zhou@huawei.com>
---
accel/kvm/kvm-all.c | 21 ++++++++++++++-------
| 3 +++
2 files changed, 17 insertions(+), 7 deletions(-)
diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
index 439a4efe52..45ab25be63 100644
--- a/accel/kvm/kvm-all.c
+++ b/accel/kvm/kvm-all.c
@@ -100,7 +100,7 @@ struct KVMState
bool kernel_irqchip_required;
OnOffAuto kernel_irqchip_split;
bool sync_mmu;
- bool manual_dirty_log_protect;
+ uint64_t manual_dirty_log_protect;
/* The man page (and posix) say ioctl numbers are signed int, but
* they're not. Linux, glibc and *BSD all treat ioctl numbers as
* unsigned, and treating them as signed here can break things */
@@ -1882,6 +1882,7 @@ static int kvm_init(MachineState *ms)
int ret;
int type = 0;
const char *kvm_type;
+ uint64_t dirty_log_manual_caps;
s = KVM_STATE(ms->accelerator);
@@ -2007,14 +2008,20 @@ static int kvm_init(MachineState *ms)
s->coalesced_pio = s->coalesced_mmio &&
kvm_check_extension(s, KVM_CAP_COALESCED_PIO);
- s->manual_dirty_log_protect =
+ dirty_log_manual_caps =
kvm_check_extension(s, KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2);
- if (s->manual_dirty_log_protect) {
- ret = kvm_vm_enable_cap(s, KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2, 0, 1);
+ dirty_log_manual_caps &= (KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE |
+ KVM_DIRTY_LOG_INITIALLY_SET);
+ s->manual_dirty_log_protect = dirty_log_manual_caps;
+ if (dirty_log_manual_caps) {
+ ret = kvm_vm_enable_cap(s, KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2, 0,
+ dirty_log_manual_caps);
if (ret) {
- warn_report("Trying to enable KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 "
- "but failed. Falling back to the legacy mode. ");
- s->manual_dirty_log_protect = false;
+ warn_report("Trying to enable capability %"PRIu64" of "
+ "KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 but failed. "
+ "Falling back to the legacy mode. ",
+ dirty_log_manual_caps);
+ s->manual_dirty_log_protect = 0;
}
}
--git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h
index 265099100e..3cb71c2b19 100644
--- a/linux-headers/linux/kvm.h
+++ b/linux-headers/linux/kvm.h
@@ -1628,4 +1628,7 @@ struct kvm_hyperv_eventfd {
#define KVM_HYPERV_CONN_ID_MASK 0x00ffffff
#define KVM_HYPERV_EVENTFD_DEASSIGN (1 << 0)
+#define KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE (1 << 0)
+#define KVM_DIRTY_LOG_INITIALLY_SET (1 << 1)
+
#endif /* __LINUX_KVM_H */
--
2.14.1.windows.1
^ permalink raw reply related [flat|nested] 7+ messages in thread
* Re: [PATCH] kvm: support to get/set dirty log initial-all-set capability
2020-03-04 2:55 [PATCH] kvm: support to get/set dirty log initial-all-set capability Jay Zhou
@ 2020-03-04 15:48 ` Peter Xu
2020-03-16 11:07 ` Cornelia Huck
2020-03-18 10:47 ` Paolo Bonzini
2 siblings, 0 replies; 7+ messages in thread
From: Peter Xu @ 2020-03-04 15:48 UTC (permalink / raw)
To: Jay Zhou
Cc: qemu-devel, kvm, pbonzini, mst, cohuck, wangxinxin.wang,
weidong.huang, liu.jinsong
On Wed, Mar 04, 2020 at 10:55:54AM +0800, Jay Zhou wrote:
> Since the new capability KVM_DIRTY_LOG_INITIALLY_SET of
> KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 has been introduced in the
> kernel, tweak the userspace side to detect and enable this
> capability.
>
> Signed-off-by: Jay Zhou <jianjay.zhou@huawei.com>
> ---
> accel/kvm/kvm-all.c | 21 ++++++++++++++-------
> linux-headers/linux/kvm.h | 3 +++
> 2 files changed, 17 insertions(+), 7 deletions(-)
>
> diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
> index 439a4efe52..45ab25be63 100644
> --- a/accel/kvm/kvm-all.c
> +++ b/accel/kvm/kvm-all.c
> @@ -100,7 +100,7 @@ struct KVMState
> bool kernel_irqchip_required;
> OnOffAuto kernel_irqchip_split;
> bool sync_mmu;
> - bool manual_dirty_log_protect;
> + uint64_t manual_dirty_log_protect;
> /* The man page (and posix) say ioctl numbers are signed int, but
> * they're not. Linux, glibc and *BSD all treat ioctl numbers as
> * unsigned, and treating them as signed here can break things */
> @@ -1882,6 +1882,7 @@ static int kvm_init(MachineState *ms)
> int ret;
> int type = 0;
> const char *kvm_type;
> + uint64_t dirty_log_manual_caps;
>
> s = KVM_STATE(ms->accelerator);
>
> @@ -2007,14 +2008,20 @@ static int kvm_init(MachineState *ms)
> s->coalesced_pio = s->coalesced_mmio &&
> kvm_check_extension(s, KVM_CAP_COALESCED_PIO);
>
> - s->manual_dirty_log_protect =
> + dirty_log_manual_caps =
> kvm_check_extension(s, KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2);
> - if (s->manual_dirty_log_protect) {
> - ret = kvm_vm_enable_cap(s, KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2, 0, 1);
> + dirty_log_manual_caps &= (KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE |
> + KVM_DIRTY_LOG_INITIALLY_SET);
> + s->manual_dirty_log_protect = dirty_log_manual_caps;
> + if (dirty_log_manual_caps) {
> + ret = kvm_vm_enable_cap(s, KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2, 0,
> + dirty_log_manual_caps);
> if (ret) {
> - warn_report("Trying to enable KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 "
> - "but failed. Falling back to the legacy mode. ");
> - s->manual_dirty_log_protect = false;
> + warn_report("Trying to enable capability %"PRIu64" of "
> + "KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 but failed. "
> + "Falling back to the legacy mode. ",
> + dirty_log_manual_caps);
> + s->manual_dirty_log_protect = 0;
> }
> }
>
> diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h
> index 265099100e..3cb71c2b19 100644
> --- a/linux-headers/linux/kvm.h
> +++ b/linux-headers/linux/kvm.h
> @@ -1628,4 +1628,7 @@ struct kvm_hyperv_eventfd {
> #define KVM_HYPERV_CONN_ID_MASK 0x00ffffff
> #define KVM_HYPERV_EVENTFD_DEASSIGN (1 << 0)
>
> +#define KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE (1 << 0)
> +#define KVM_DIRTY_LOG_INITIALLY_SET (1 << 1)
> +
The patch looks ok, though ideally I think we need to wait until the
kernel patch got pushed then we'll be sure these macros won't be
overwrite by other ./scripts/update-linux-headers.sh updates (or
another patch to call the update script to fetch the macros...).
Reviewed-by: Peter Xu <peterx@redhat.com>
Thanks,
--
Peter Xu
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] kvm: support to get/set dirty log initial-all-set capability
2020-03-04 2:55 [PATCH] kvm: support to get/set dirty log initial-all-set capability Jay Zhou
2020-03-04 15:48 ` Peter Xu
@ 2020-03-16 11:07 ` Cornelia Huck
2020-03-18 10:47 ` Paolo Bonzini
2 siblings, 0 replies; 7+ messages in thread
From: Cornelia Huck @ 2020-03-16 11:07 UTC (permalink / raw)
To: Jay Zhou
Cc: qemu-devel, kvm, pbonzini, mst, peterx, wangxinxin.wang,
weidong.huang, liu.jinsong
On Wed, 4 Mar 2020 10:55:54 +0800
Jay Zhou <jianjay.zhou@huawei.com> wrote:
> Since the new capability KVM_DIRTY_LOG_INITIALLY_SET of
> KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 has been introduced in the
> kernel, tweak the userspace side to detect and enable this
> capability.
>
> Signed-off-by: Jay Zhou <jianjay.zhou@huawei.com>
> ---
> accel/kvm/kvm-all.c | 21 ++++++++++++++-------
> linux-headers/linux/kvm.h | 3 +++
> 2 files changed, 17 insertions(+), 7 deletions(-)
<standard message>
Please do any linux-headers updates in a separate patch; that makes it
easy to replace the manual update with a complete headers update.
</standard message>
:)
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] kvm: support to get/set dirty log initial-all-set capability
2020-03-04 2:55 [PATCH] kvm: support to get/set dirty log initial-all-set capability Jay Zhou
2020-03-04 15:48 ` Peter Xu
2020-03-16 11:07 ` Cornelia Huck
@ 2020-03-18 10:47 ` Paolo Bonzini
2020-06-12 3:01 ` Zhoujian (jay)
2 siblings, 1 reply; 7+ messages in thread
From: Paolo Bonzini @ 2020-03-18 10:47 UTC (permalink / raw)
To: Jay Zhou, qemu-devel, kvm
Cc: mst, cohuck, peterx, wangxinxin.wang, weidong.huang, liu.jinsong
On 04/03/20 03:55, Jay Zhou wrote:
> Since the new capability KVM_DIRTY_LOG_INITIALLY_SET of
> KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 has been introduced in the
> kernel, tweak the userspace side to detect and enable this
> capability.
>
> Signed-off-by: Jay Zhou <jianjay.zhou@huawei.com>
> ---
> accel/kvm/kvm-all.c | 21 ++++++++++++++-------
> linux-headers/linux/kvm.h | 3 +++
> 2 files changed, 17 insertions(+), 7 deletions(-)
>
> diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c
> index 439a4efe52..45ab25be63 100644
> --- a/accel/kvm/kvm-all.c
> +++ b/accel/kvm/kvm-all.c
> @@ -100,7 +100,7 @@ struct KVMState
> bool kernel_irqchip_required;
> OnOffAuto kernel_irqchip_split;
> bool sync_mmu;
> - bool manual_dirty_log_protect;
> + uint64_t manual_dirty_log_protect;
> /* The man page (and posix) say ioctl numbers are signed int, but
> * they're not. Linux, glibc and *BSD all treat ioctl numbers as
> * unsigned, and treating them as signed here can break things */
> @@ -1882,6 +1882,7 @@ static int kvm_init(MachineState *ms)
> int ret;
> int type = 0;
> const char *kvm_type;
> + uint64_t dirty_log_manual_caps;
>
> s = KVM_STATE(ms->accelerator);
>
> @@ -2007,14 +2008,20 @@ static int kvm_init(MachineState *ms)
> s->coalesced_pio = s->coalesced_mmio &&
> kvm_check_extension(s, KVM_CAP_COALESCED_PIO);
>
> - s->manual_dirty_log_protect =
> + dirty_log_manual_caps =
> kvm_check_extension(s, KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2);
> - if (s->manual_dirty_log_protect) {
> - ret = kvm_vm_enable_cap(s, KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2, 0, 1);
> + dirty_log_manual_caps &= (KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE |
> + KVM_DIRTY_LOG_INITIALLY_SET);
> + s->manual_dirty_log_protect = dirty_log_manual_caps;
> + if (dirty_log_manual_caps) {
> + ret = kvm_vm_enable_cap(s, KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2, 0,
> + dirty_log_manual_caps);
> if (ret) {
> - warn_report("Trying to enable KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 "
> - "but failed. Falling back to the legacy mode. ");
> - s->manual_dirty_log_protect = false;
> + warn_report("Trying to enable capability %"PRIu64" of "
> + "KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 but failed. "
> + "Falling back to the legacy mode. ",
> + dirty_log_manual_caps);
> + s->manual_dirty_log_protect = 0;
> }
> }
>
> diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h
> index 265099100e..3cb71c2b19 100644
> --- a/linux-headers/linux/kvm.h
> +++ b/linux-headers/linux/kvm.h
> @@ -1628,4 +1628,7 @@ struct kvm_hyperv_eventfd {
> #define KVM_HYPERV_CONN_ID_MASK 0x00ffffff
> #define KVM_HYPERV_EVENTFD_DEASSIGN (1 << 0)
>
> +#define KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE (1 << 0)
> +#define KVM_DIRTY_LOG_INITIALLY_SET (1 << 1)
> +
> #endif /* __LINUX_KVM_H */
>
Queued, thanks.
Paolo
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [PATCH] kvm: support to get/set dirty log initial-all-set capability
2020-03-18 10:47 ` Paolo Bonzini
@ 2020-06-12 3:01 ` Zhoujian (jay)
2020-06-12 9:27 ` Paolo Bonzini
0 siblings, 1 reply; 7+ messages in thread
From: Zhoujian (jay) @ 2020-06-12 3:01 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel, kvm
Cc: mst, cohuck, peterx, Wangxin (Alexander,
Cloud Infrastructure Service Product Dept.), Huangweidong (C),
Liujinsong (Paul)
> -----Original Message-----
> From: Paolo Bonzini [mailto:pbonzini@redhat.com]
> Sent: Wednesday, March 18, 2020 6:48 PM
> To: Zhoujian (jay) <jianjay.zhou@huawei.com>; qemu-devel@nongnu.org;
> kvm@vger.kernel.org
> Cc: mst@redhat.com; cohuck@redhat.com; peterx@redhat.com; wangxin (U)
> <wangxinxin.wang@huawei.com>; Huangweidong (C)
> <weidong.huang@huawei.com>; Liujinsong (Paul) <liu.jinsong@huawei.com>
> Subject: Re: [PATCH] kvm: support to get/set dirty log initial-all-set capability
>
> On 04/03/20 03:55, Jay Zhou wrote:
> > Since the new capability KVM_DIRTY_LOG_INITIALLY_SET of
> > KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 has been introduced in the kernel,
> > tweak the userspace side to detect and enable this capability.
> >
> > Signed-off-by: Jay Zhou <jianjay.zhou@huawei.com>
> > ---
> > accel/kvm/kvm-all.c | 21 ++++++++++++++-------
> > linux-headers/linux/kvm.h | 3 +++
> > 2 files changed, 17 insertions(+), 7 deletions(-)
> >
> > diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index
> > 439a4efe52..45ab25be63 100644
> > --- a/accel/kvm/kvm-all.c
> > +++ b/accel/kvm/kvm-all.c
> > @@ -100,7 +100,7 @@ struct KVMState
> > bool kernel_irqchip_required;
> > OnOffAuto kernel_irqchip_split;
> > bool sync_mmu;
> > - bool manual_dirty_log_protect;
> > + uint64_t manual_dirty_log_protect;
> > /* The man page (and posix) say ioctl numbers are signed int, but
> > * they're not. Linux, glibc and *BSD all treat ioctl numbers as
> > * unsigned, and treating them as signed here can break things */
> > @@ -1882,6 +1882,7 @@ static int kvm_init(MachineState *ms)
> > int ret;
> > int type = 0;
> > const char *kvm_type;
> > + uint64_t dirty_log_manual_caps;
> >
> > s = KVM_STATE(ms->accelerator);
> >
> > @@ -2007,14 +2008,20 @@ static int kvm_init(MachineState *ms)
> > s->coalesced_pio = s->coalesced_mmio &&
> > kvm_check_extension(s,
> KVM_CAP_COALESCED_PIO);
> >
> > - s->manual_dirty_log_protect =
> > + dirty_log_manual_caps =
> > kvm_check_extension(s,
> KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2);
> > - if (s->manual_dirty_log_protect) {
> > - ret = kvm_vm_enable_cap(s,
> KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2, 0, 1);
> > + dirty_log_manual_caps &=
> (KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE |
> > + KVM_DIRTY_LOG_INITIALLY_SET);
> > + s->manual_dirty_log_protect = dirty_log_manual_caps;
> > + if (dirty_log_manual_caps) {
> > + ret = kvm_vm_enable_cap(s,
> KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2, 0,
> > + dirty_log_manual_caps);
> > if (ret) {
> > - warn_report("Trying to enable
> KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 "
> > - "but failed. Falling back to the legacy mode. ");
> > - s->manual_dirty_log_protect = false;
> > + warn_report("Trying to enable capability %"PRIu64" of "
> > + "KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2
> but failed. "
> > + "Falling back to the legacy mode. ",
> > + dirty_log_manual_caps);
> > + s->manual_dirty_log_protect = 0;
> > }
> > }
> >
> > diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h
> > index 265099100e..3cb71c2b19 100644
> > --- a/linux-headers/linux/kvm.h
> > +++ b/linux-headers/linux/kvm.h
> > @@ -1628,4 +1628,7 @@ struct kvm_hyperv_eventfd {
> > #define KVM_HYPERV_CONN_ID_MASK 0x00ffffff
> > #define KVM_HYPERV_EVENTFD_DEASSIGN (1 << 0)
> >
> > +#define KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE (1 << 0)
> > +#define KVM_DIRTY_LOG_INITIALLY_SET (1 << 1)
> > +
> > #endif /* __LINUX_KVM_H */
> >
>
> Queued, thanks.
>
Hi Paolo,
It seems that this patch isn't included in your last pull request...
If there's something else to be done, please let me know.
Regards,
Jay Zhou
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH] kvm: support to get/set dirty log initial-all-set capability
2020-06-12 3:01 ` Zhoujian (jay)
@ 2020-06-12 9:27 ` Paolo Bonzini
2020-06-12 9:35 ` Zhoujian (jay)
0 siblings, 1 reply; 7+ messages in thread
From: Paolo Bonzini @ 2020-06-12 9:27 UTC (permalink / raw)
To: Zhoujian (jay), qemu-devel, kvm
Cc: mst, cohuck, peterx, Wangxin (Alexander,
Cloud Infrastructure Service Product Dept.), Huangweidong (C),
Liujinsong (Paul)
On 12/06/20 05:01, Zhoujian (jay) wrote:
>
>
>> -----Original Message-----
>> From: Paolo Bonzini [mailto:pbonzini@redhat.com]
>> Sent: Wednesday, March 18, 2020 6:48 PM
>> To: Zhoujian (jay) <jianjay.zhou@huawei.com>; qemu-devel@nongnu.org;
>> kvm@vger.kernel.org
>> Cc: mst@redhat.com; cohuck@redhat.com; peterx@redhat.com; wangxin (U)
>> <wangxinxin.wang@huawei.com>; Huangweidong (C)
>> <weidong.huang@huawei.com>; Liujinsong (Paul) <liu.jinsong@huawei.com>
>> Subject: Re: [PATCH] kvm: support to get/set dirty log initial-all-set capability
>>
>> On 04/03/20 03:55, Jay Zhou wrote:
>>> Since the new capability KVM_DIRTY_LOG_INITIALLY_SET of
>>> KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 has been introduced in the kernel,
>>> tweak the userspace side to detect and enable this capability.
>>>
>>> Signed-off-by: Jay Zhou <jianjay.zhou@huawei.com>
>>> ---
>>> accel/kvm/kvm-all.c | 21 ++++++++++++++-------
>>> linux-headers/linux/kvm.h | 3 +++
>>> 2 files changed, 17 insertions(+), 7 deletions(-)
>>>
>>> diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index
>>> 439a4efe52..45ab25be63 100644
>>> --- a/accel/kvm/kvm-all.c
>>> +++ b/accel/kvm/kvm-all.c
>>> @@ -100,7 +100,7 @@ struct KVMState
>>> bool kernel_irqchip_required;
>>> OnOffAuto kernel_irqchip_split;
>>> bool sync_mmu;
>>> - bool manual_dirty_log_protect;
>>> + uint64_t manual_dirty_log_protect;
>>> /* The man page (and posix) say ioctl numbers are signed int, but
>>> * they're not. Linux, glibc and *BSD all treat ioctl numbers as
>>> * unsigned, and treating them as signed here can break things */
>>> @@ -1882,6 +1882,7 @@ static int kvm_init(MachineState *ms)
>>> int ret;
>>> int type = 0;
>>> const char *kvm_type;
>>> + uint64_t dirty_log_manual_caps;
>>>
>>> s = KVM_STATE(ms->accelerator);
>>>
>>> @@ -2007,14 +2008,20 @@ static int kvm_init(MachineState *ms)
>>> s->coalesced_pio = s->coalesced_mmio &&
>>> kvm_check_extension(s,
>> KVM_CAP_COALESCED_PIO);
>>>
>>> - s->manual_dirty_log_protect =
>>> + dirty_log_manual_caps =
>>> kvm_check_extension(s,
>> KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2);
>>> - if (s->manual_dirty_log_protect) {
>>> - ret = kvm_vm_enable_cap(s,
>> KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2, 0, 1);
>>> + dirty_log_manual_caps &=
>> (KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE |
>>> + KVM_DIRTY_LOG_INITIALLY_SET);
>>> + s->manual_dirty_log_protect = dirty_log_manual_caps;
>>> + if (dirty_log_manual_caps) {
>>> + ret = kvm_vm_enable_cap(s,
>> KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2, 0,
>>> + dirty_log_manual_caps);
>>> if (ret) {
>>> - warn_report("Trying to enable
>> KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 "
>>> - "but failed. Falling back to the legacy mode. ");
>>> - s->manual_dirty_log_protect = false;
>>> + warn_report("Trying to enable capability %"PRIu64" of "
>>> + "KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2
>> but failed. "
>>> + "Falling back to the legacy mode. ",
>>> + dirty_log_manual_caps);
>>> + s->manual_dirty_log_protect = 0;
>>> }
>>> }
>>>
>>> diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h
>>> index 265099100e..3cb71c2b19 100644
>>> --- a/linux-headers/linux/kvm.h
>>> +++ b/linux-headers/linux/kvm.h
>>> @@ -1628,4 +1628,7 @@ struct kvm_hyperv_eventfd {
>>> #define KVM_HYPERV_CONN_ID_MASK 0x00ffffff
>>> #define KVM_HYPERV_EVENTFD_DEASSIGN (1 << 0)
>>>
>>> +#define KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE (1 << 0)
>>> +#define KVM_DIRTY_LOG_INITIALLY_SET (1 << 1)
>>> +
>>> #endif /* __LINUX_KVM_H */
>>>
>>
>> Queued, thanks.
>>
>
> Hi Paolo,
>
> It seems that this patch isn't included in your last pull request...
> If there's something else to be done, please let me know.
Sorry, I thought mistakenly that it was a 5.8 feature (so it would have
to wait for the 5.8-rc1 release and header update). It's still queued
though.
Paolo
^ permalink raw reply [flat|nested] 7+ messages in thread
* RE: [PATCH] kvm: support to get/set dirty log initial-all-set capability
2020-06-12 9:27 ` Paolo Bonzini
@ 2020-06-12 9:35 ` Zhoujian (jay)
0 siblings, 0 replies; 7+ messages in thread
From: Zhoujian (jay) @ 2020-06-12 9:35 UTC (permalink / raw)
To: Paolo Bonzini, qemu-devel, kvm
Cc: mst, cohuck, peterx, Wangxin (Alexander,
Cloud Infrastructure Service Product Dept.), Huangweidong (C),
Liujinsong (Paul)
> -----Original Message-----
> From: Paolo Bonzini [mailto:pbonzini@redhat.com]
> Sent: Friday, June 12, 2020 5:28 PM
> To: Zhoujian (jay) <jianjay.zhou@huawei.com>; qemu-devel@nongnu.org;
> kvm@vger.kernel.org
> Cc: mst@redhat.com; cohuck@redhat.com; peterx@redhat.com; Wangxin
> (Alexander, Cloud Infrastructure Service Product Dept.)
> <wangxinxin.wang@huawei.com>; Huangweidong (C)
> <weidong.huang@huawei.com>; Liujinsong (Paul) <liu.jinsong@huawei.com>
> Subject: Re: [PATCH] kvm: support to get/set dirty log initial-all-set capability
>
> On 12/06/20 05:01, Zhoujian (jay) wrote:
> >
> >
> >> -----Original Message-----
> >> From: Paolo Bonzini [mailto:pbonzini@redhat.com]
> >> Sent: Wednesday, March 18, 2020 6:48 PM
> >> To: Zhoujian (jay) <jianjay.zhou@huawei.com>; qemu-devel@nongnu.org;
> >> kvm@vger.kernel.org
> >> Cc: mst@redhat.com; cohuck@redhat.com; peterx@redhat.com; wangxin (U)
> >> <wangxinxin.wang@huawei.com>; Huangweidong (C)
> >> <weidong.huang@huawei.com>; Liujinsong (Paul)
> >> <liu.jinsong@huawei.com>
> >> Subject: Re: [PATCH] kvm: support to get/set dirty log
> >> initial-all-set capability
> >>
> >> On 04/03/20 03:55, Jay Zhou wrote:
> >>> Since the new capability KVM_DIRTY_LOG_INITIALLY_SET of
> >>> KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 has been introduced in the
> kernel,
> >>> tweak the userspace side to detect and enable this capability.
> >>>
> >>> Signed-off-by: Jay Zhou <jianjay.zhou@huawei.com>
> >>> ---
> >>> accel/kvm/kvm-all.c | 21 ++++++++++++++-------
> >>> linux-headers/linux/kvm.h | 3 +++
> >>> 2 files changed, 17 insertions(+), 7 deletions(-)
> >>>
> >>> diff --git a/accel/kvm/kvm-all.c b/accel/kvm/kvm-all.c index
> >>> 439a4efe52..45ab25be63 100644
> >>> --- a/accel/kvm/kvm-all.c
> >>> +++ b/accel/kvm/kvm-all.c
> >>> @@ -100,7 +100,7 @@ struct KVMState
> >>> bool kernel_irqchip_required;
> >>> OnOffAuto kernel_irqchip_split;
> >>> bool sync_mmu;
> >>> - bool manual_dirty_log_protect;
> >>> + uint64_t manual_dirty_log_protect;
> >>> /* The man page (and posix) say ioctl numbers are signed int, but
> >>> * they're not. Linux, glibc and *BSD all treat ioctl numbers as
> >>> * unsigned, and treating them as signed here can break things
> >>> */ @@ -1882,6 +1882,7 @@ static int kvm_init(MachineState *ms)
> >>> int ret;
> >>> int type = 0;
> >>> const char *kvm_type;
> >>> + uint64_t dirty_log_manual_caps;
> >>>
> >>> s = KVM_STATE(ms->accelerator);
> >>>
> >>> @@ -2007,14 +2008,20 @@ static int kvm_init(MachineState *ms)
> >>> s->coalesced_pio = s->coalesced_mmio &&
> >>> kvm_check_extension(s,
> >> KVM_CAP_COALESCED_PIO);
> >>>
> >>> - s->manual_dirty_log_protect =
> >>> + dirty_log_manual_caps =
> >>> kvm_check_extension(s,
> >> KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2);
> >>> - if (s->manual_dirty_log_protect) {
> >>> - ret = kvm_vm_enable_cap(s,
> >> KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2, 0, 1);
> >>> + dirty_log_manual_caps &=
> >> (KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE |
> >>> + KVM_DIRTY_LOG_INITIALLY_SET);
> >>> + s->manual_dirty_log_protect = dirty_log_manual_caps;
> >>> + if (dirty_log_manual_caps) {
> >>> + ret = kvm_vm_enable_cap(s,
> >> KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2, 0,
> >>> + dirty_log_manual_caps);
> >>> if (ret) {
> >>> - warn_report("Trying to enable
> >> KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2 "
> >>> - "but failed. Falling back to the legacy mode.
> ");
> >>> - s->manual_dirty_log_protect = false;
> >>> + warn_report("Trying to enable capability %"PRIu64" of "
> >>> + "KVM_CAP_MANUAL_DIRTY_LOG_PROTECT2
> >> but failed. "
> >>> + "Falling back to the legacy mode. ",
> >>> + dirty_log_manual_caps);
> >>> + s->manual_dirty_log_protect = 0;
> >>> }
> >>> }
> >>>
> >>> diff --git a/linux-headers/linux/kvm.h b/linux-headers/linux/kvm.h
> >>> index 265099100e..3cb71c2b19 100644
> >>> --- a/linux-headers/linux/kvm.h
> >>> +++ b/linux-headers/linux/kvm.h
> >>> @@ -1628,4 +1628,7 @@ struct kvm_hyperv_eventfd {
> >>> #define KVM_HYPERV_CONN_ID_MASK 0x00ffffff
> >>> #define KVM_HYPERV_EVENTFD_DEASSIGN (1 << 0)
> >>>
> >>> +#define KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE (1 << 0)
> >>> +#define KVM_DIRTY_LOG_INITIALLY_SET (1 << 1)
> >>> +
> >>> #endif /* __LINUX_KVM_H */
> >>>
> >>
> >> Queued, thanks.
> >>
> >
> > Hi Paolo,
> >
> > It seems that this patch isn't included in your last pull request...
> > If there's something else to be done, please let me know.
>
> Sorry, I thought mistakenly that it was a 5.8 feature (so it would have to wait for
> the 5.8-rc1 release and header update). It's still queued though.
Okay, never mind, :)
Regards,
Jay Zhou
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2020-06-12 9:35 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-03-04 2:55 [PATCH] kvm: support to get/set dirty log initial-all-set capability Jay Zhou
2020-03-04 15:48 ` Peter Xu
2020-03-16 11:07 ` Cornelia Huck
2020-03-18 10:47 ` Paolo Bonzini
2020-06-12 3:01 ` Zhoujian (jay)
2020-06-12 9:27 ` Paolo Bonzini
2020-06-12 9:35 ` Zhoujian (jay)
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).