[libvirt] [PATCH v3] qemu: add the print of page size in cmd domjobinfo

Chao Fan posted 1 patch 6 years, 6 months ago
Patches applied successfully (tree, apply log)
git fetch https://github.com/patchew-project/libvirt tags/patchew/20171009020003.16165-1-fanc.fnst@cn.fujitsu.com
include/libvirt/libvirt-domain.h | 7 +++++++
src/qemu/qemu_domain.c           | 6 ++++++
src/qemu/qemu_migration_cookie.c | 7 +++++++
src/qemu/qemu_monitor.h          | 1 +
src/qemu/qemu_monitor_json.c     | 2 ++
tools/virsh-domain.c             | 8 ++++++++
6 files changed, 31 insertions(+)
[libvirt] [PATCH v3] qemu: add the print of page size in cmd domjobinfo
Posted by Chao Fan 6 years, 6 months ago
The command "info migrate" of qemu outputs the dirty-pages-rate during
migration, but page size is different in different architectures. So
page size should be output to calculate dirty pages in bytes.

Page size is already implemented with commit
030ce1f8612215fcbe9d353dfeaeb2937f8e3f94 in qemu.
Now Implement the counter-part in libvirt.

Signed-off-by: Chao Fan <fanc.fnst@cn.fujitsu.com>
Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
---
v2 -> v3:
  Follow the suggestion of John Ferlan:
  1. Improve a judgment logic when failing to get page size.

v1 -> v2:
  Follow the suggestion of John Ferlan:
  1. Drop the fix for unrelated coding style problem.
  2. Fix typo.
  3. Improve a judgment logic when failing to get page size.
---
 include/libvirt/libvirt-domain.h | 7 +++++++
 src/qemu/qemu_domain.c           | 6 ++++++
 src/qemu/qemu_migration_cookie.c | 7 +++++++
 src/qemu/qemu_monitor.h          | 1 +
 src/qemu/qemu_monitor_json.c     | 2 ++
 tools/virsh-domain.c             | 8 ++++++++
 6 files changed, 31 insertions(+)

diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
index 030a62c43..1f4ddcf66 100644
--- a/include/libvirt/libvirt-domain.h
+++ b/include/libvirt/libvirt-domain.h
@@ -3336,6 +3336,13 @@ typedef enum {
 # define VIR_DOMAIN_JOB_MEMORY_DIRTY_RATE        "memory_dirty_rate"
 
 /**
+ * VIR_DOMAIN_JOB_MEMORY_PAGE_SIZE:
+ *
+ * virDomainGetJobStats field: page size of the memory in this domain
+ */
+# define VIR_DOMAIN_JOB_MEMORY_PAGE_SIZE        "page_size"
+
+/**
  * VIR_DOMAIN_JOB_MEMORY_ITERATION:
  *
  * virDomainGetJobStats field: current iteration over domain's memory
diff --git a/src/qemu/qemu_domain.c b/src/qemu/qemu_domain.c
index e395c4ddf..e95e427e5 100644
--- a/src/qemu/qemu_domain.c
+++ b/src/qemu/qemu_domain.c
@@ -570,6 +570,12 @@ qemuDomainJobInfoToParams(qemuDomainJobInfoPtr jobInfo,
                                 stats->ram_iteration) < 0)
         goto error;
 
+    if (stats->ram_page_size > 0 &&
+        virTypedParamsAddULLong(&par, &npar, &maxpar,
+                                VIR_DOMAIN_JOB_MEMORY_PAGE_SIZE,
+                                stats->ram_page_size) < 0)
+        goto error;
+
     if (virTypedParamsAddULLong(&par, &npar, &maxpar,
                                 VIR_DOMAIN_JOB_DISK_TOTAL,
                                 stats->disk_total +
diff --git a/src/qemu/qemu_migration_cookie.c b/src/qemu/qemu_migration_cookie.c
index eef40a6cd..bc6a8dc55 100644
--- a/src/qemu/qemu_migration_cookie.c
+++ b/src/qemu/qemu_migration_cookie.c
@@ -654,6 +654,10 @@ qemuMigrationCookieStatisticsXMLFormat(virBufferPtr buf,
                       stats->ram_iteration);
 
     virBufferAsprintf(buf, "<%1$s>%2$llu</%1$s>\n",
+                      VIR_DOMAIN_JOB_MEMORY_PAGE_SIZE,
+                      stats->ram_page_size);
+
+    virBufferAsprintf(buf, "<%1$s>%2$llu</%1$s>\n",
                       VIR_DOMAIN_JOB_DISK_TOTAL,
                       stats->disk_total);
     virBufferAsprintf(buf, "<%1$s>%2$llu</%1$s>\n",
@@ -1014,6 +1018,9 @@ qemuMigrationCookieStatisticsXMLParse(xmlXPathContextPtr ctxt)
     virXPathULongLong("string(./" VIR_DOMAIN_JOB_MEMORY_ITERATION "[1])",
                       ctxt, &stats->ram_iteration);
 
+    virXPathULongLong("string(./" VIR_DOMAIN_JOB_MEMORY_PAGE_SIZE "[1])",
+                      ctxt, &stats->ram_page_size);
+
     virXPathULongLong("string(./" VIR_DOMAIN_JOB_DISK_TOTAL "[1])",
                       ctxt, &stats->disk_total);
     virXPathULongLong("string(./" VIR_DOMAIN_JOB_DISK_PROCESSED "[1])",
diff --git a/src/qemu/qemu_monitor.h b/src/qemu/qemu_monitor.h
index 6414d2483..1e3322433 100644
--- a/src/qemu/qemu_monitor.h
+++ b/src/qemu/qemu_monitor.h
@@ -677,6 +677,7 @@ struct _qemuMonitorMigrationStats {
     unsigned long long ram_normal;
     unsigned long long ram_normal_bytes;
     unsigned long long ram_dirty_rate;
+    unsigned long long ram_page_size;
     unsigned long long ram_iteration;
 
     unsigned long long disk_transferred;
diff --git a/src/qemu/qemu_monitor_json.c b/src/qemu/qemu_monitor_json.c
index c63d250d3..70c895a35 100644
--- a/src/qemu/qemu_monitor_json.c
+++ b/src/qemu/qemu_monitor_json.c
@@ -2892,6 +2892,8 @@ qemuMonitorJSONGetMigrationStatsReply(virJSONValuePtr reply,
                                                       &stats->ram_normal_bytes));
         ignore_value(virJSONValueObjectGetNumberUlong(ram, "dirty-pages-rate",
                                                       &stats->ram_dirty_rate));
+        ignore_value(virJSONValueObjectGetNumberUlong(ram, "page-size",
+                                                      &stats->ram_page_size));
         ignore_value(virJSONValueObjectGetNumberUlong(ram, "dirty-sync-count",
                                                       &stats->ram_iteration));
 
diff --git a/tools/virsh-domain.c b/tools/virsh-domain.c
index a3f3b7c7b..a50713d6e 100644
--- a/tools/virsh-domain.c
+++ b/tools/virsh-domain.c
@@ -6021,6 +6021,14 @@ cmdDomjobinfo(vshControl *ctl, const vshCmd *cmd)
         }
 
         if ((rc = virTypedParamsGetULLong(params, nparams,
+                                          VIR_DOMAIN_JOB_MEMORY_PAGE_SIZE,
+                                          &value)) < 0) {
+            goto save_error;
+        } else if (rc) {
+            vshPrint(ctl, "%-17s %-12llu bytes\n", _("Page size:"), value);
+        }
+
+        if ((rc = virTypedParamsGetULLong(params, nparams,
                                           VIR_DOMAIN_JOB_MEMORY_ITERATION,
                                           &value)) < 0) {
             goto save_error;
-- 
2.13.5



--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v3] qemu: add the print of page size in cmd domjobinfo
Posted by Jiri Denemark 6 years, 6 months ago
On Mon, Oct 09, 2017 at 10:00:03 +0800, Chao Fan wrote:
> The command "info migrate" of qemu outputs the dirty-pages-rate during
> migration, but page size is different in different architectures. So
> page size should be output to calculate dirty pages in bytes.
> 
> Page size is already implemented with commit
> 030ce1f8612215fcbe9d353dfeaeb2937f8e3f94 in qemu.
> Now Implement the counter-part in libvirt.
> 
> Signed-off-by: Chao Fan <fanc.fnst@cn.fujitsu.com>
> Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
> ---
> v2 -> v3:
>   Follow the suggestion of John Ferlan:
>   1. Improve a judgment logic when failing to get page size.
> 
> v1 -> v2:
>   Follow the suggestion of John Ferlan:
>   1. Drop the fix for unrelated coding style problem.
>   2. Fix typo.
>   3. Improve a judgment logic when failing to get page size.
> ---
>  include/libvirt/libvirt-domain.h | 7 +++++++
>  src/qemu/qemu_domain.c           | 6 ++++++
>  src/qemu/qemu_migration_cookie.c | 7 +++++++
>  src/qemu/qemu_monitor.h          | 1 +
>  src/qemu/qemu_monitor_json.c     | 2 ++
>  tools/virsh-domain.c             | 8 ++++++++
>  6 files changed, 31 insertions(+)
> 
> diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
> index 030a62c43..1f4ddcf66 100644
> --- a/include/libvirt/libvirt-domain.h
> +++ b/include/libvirt/libvirt-domain.h
> @@ -3336,6 +3336,13 @@ typedef enum {
>  # define VIR_DOMAIN_JOB_MEMORY_DIRTY_RATE        "memory_dirty_rate"
>  
>  /**
> + * VIR_DOMAIN_JOB_MEMORY_PAGE_SIZE:
> + *
> + * virDomainGetJobStats field: page size of the memory in this domain
> + */
> +# define VIR_DOMAIN_JOB_MEMORY_PAGE_SIZE        "page_size"

The parameter should be called "memory_page_size" and its documentation
could be a bit more verbose., for example:

virDomainGetJobStats field: memory page size in bytes, as
VIR_TYPED_PARAM_ULLONG. If present, this parameter can be used to
convert other page based statistics, such as
VIR_DOMAIN_JOB_MEMORY_DIRTY_RATE or VIR_DOMAIN_JOB_COMPRESSION_PAGES
to bytes.

ACK and pushed with this small change.

Thanks,

Jirka

--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v3] qemu: add the print of page size in cmd domjobinfo
Posted by Chao Fan 6 years, 6 months ago
On Thu, Oct 12, 2017 at 05:10:43PM +0200, Jiri Denemark wrote:
>On Mon, Oct 09, 2017 at 10:00:03 +0800, Chao Fan wrote:
>> The command "info migrate" of qemu outputs the dirty-pages-rate during
>> migration, but page size is different in different architectures. So
>> page size should be output to calculate dirty pages in bytes.
>> 
>> Page size is already implemented with commit
>> 030ce1f8612215fcbe9d353dfeaeb2937f8e3f94 in qemu.
>> Now Implement the counter-part in libvirt.
>> 
>> Signed-off-by: Chao Fan <fanc.fnst@cn.fujitsu.com>
>> Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
>> ---
>> v2 -> v3:
>>   Follow the suggestion of John Ferlan:
>>   1. Improve a judgment logic when failing to get page size.
>> 
>> v1 -> v2:
>>   Follow the suggestion of John Ferlan:
>>   1. Drop the fix for unrelated coding style problem.
>>   2. Fix typo.
>>   3. Improve a judgment logic when failing to get page size.
>> ---
>>  include/libvirt/libvirt-domain.h | 7 +++++++
>>  src/qemu/qemu_domain.c           | 6 ++++++
>>  src/qemu/qemu_migration_cookie.c | 7 +++++++
>>  src/qemu/qemu_monitor.h          | 1 +
>>  src/qemu/qemu_monitor_json.c     | 2 ++
>>  tools/virsh-domain.c             | 8 ++++++++
>>  6 files changed, 31 insertions(+)
>> 
>> diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
>> index 030a62c43..1f4ddcf66 100644
>> --- a/include/libvirt/libvirt-domain.h
>> +++ b/include/libvirt/libvirt-domain.h
>> @@ -3336,6 +3336,13 @@ typedef enum {
>>  # define VIR_DOMAIN_JOB_MEMORY_DIRTY_RATE        "memory_dirty_rate"
>>  
>>  /**
>> + * VIR_DOMAIN_JOB_MEMORY_PAGE_SIZE:
>> + *
>> + * virDomainGetJobStats field: page size of the memory in this domain
>> + */
>> +# define VIR_DOMAIN_JOB_MEMORY_PAGE_SIZE        "page_size"
Hi Jirka,

Thanks for your reply.

>
>The parameter should be called "memory_page_size" and its documentation
>could be a bit more verbose., for example:

OK, thanks for your suggestion.
>
>virDomainGetJobStats field: memory page size in bytes, as
>VIR_TYPED_PARAM_ULLONG. If present, this parameter can be used to
>convert other page based statistics, such as
>VIR_DOMAIN_JOB_MEMORY_DIRTY_RATE or VIR_DOMAIN_JOB_COMPRESSION_PAGES
>to bytes.
>
>ACK and pushed with this small change.

The new version is on the way.

Thanks,
Chao Fan
>
>Thanks,
>
>Jirka
>
>


--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list
Re: [libvirt] [PATCH v3] qemu: add the print of page size in cmd domjobinfo
Posted by Chao Fan 6 years, 6 months ago
On Fri, Oct 13, 2017 at 09:13:07AM +0800, Chao Fan wrote:
>On Thu, Oct 12, 2017 at 05:10:43PM +0200, Jiri Denemark wrote:
>>On Mon, Oct 09, 2017 at 10:00:03 +0800, Chao Fan wrote:
>>> The command "info migrate" of qemu outputs the dirty-pages-rate during
>>> migration, but page size is different in different architectures. So
>>> page size should be output to calculate dirty pages in bytes.
>>> 
>>> Page size is already implemented with commit
>>> 030ce1f8612215fcbe9d353dfeaeb2937f8e3f94 in qemu.
>>> Now Implement the counter-part in libvirt.
>>> 
>>> Signed-off-by: Chao Fan <fanc.fnst@cn.fujitsu.com>
>>> Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
>>> ---
>>> v2 -> v3:
>>>   Follow the suggestion of John Ferlan:
>>>   1. Improve a judgment logic when failing to get page size.
>>> 
>>> v1 -> v2:
>>>   Follow the suggestion of John Ferlan:
>>>   1. Drop the fix for unrelated coding style problem.
>>>   2. Fix typo.
>>>   3. Improve a judgment logic when failing to get page size.
>>> ---
>>>  include/libvirt/libvirt-domain.h | 7 +++++++
>>>  src/qemu/qemu_domain.c           | 6 ++++++
>>>  src/qemu/qemu_migration_cookie.c | 7 +++++++
>>>  src/qemu/qemu_monitor.h          | 1 +
>>>  src/qemu/qemu_monitor_json.c     | 2 ++
>>>  tools/virsh-domain.c             | 8 ++++++++
>>>  6 files changed, 31 insertions(+)
>>> 
>>> diff --git a/include/libvirt/libvirt-domain.h b/include/libvirt/libvirt-domain.h
>>> index 030a62c43..1f4ddcf66 100644
>>> --- a/include/libvirt/libvirt-domain.h
>>> +++ b/include/libvirt/libvirt-domain.h
>>> @@ -3336,6 +3336,13 @@ typedef enum {
>>>  # define VIR_DOMAIN_JOB_MEMORY_DIRTY_RATE        "memory_dirty_rate"
>>>  
>>>  /**
>>> + * VIR_DOMAIN_JOB_MEMORY_PAGE_SIZE:
>>> + *
>>> + * virDomainGetJobStats field: page size of the memory in this domain
>>> + */
>>> +# define VIR_DOMAIN_JOB_MEMORY_PAGE_SIZE        "page_size"
>Hi Jirka,
>
>Thanks for your reply.
>
>>
>>The parameter should be called "memory_page_size" and its documentation
>>could be a bit more verbose., for example:
>
>OK, thanks for your suggestion.
>>
>>virDomainGetJobStats field: memory page size in bytes, as
>>VIR_TYPED_PARAM_ULLONG. If present, this parameter can be used to
>>convert other page based statistics, such as
>>VIR_DOMAIN_JOB_MEMORY_DIRTY_RATE or VIR_DOMAIN_JOB_COMPRESSION_PAGES
>>to bytes.
>>
>>ACK and pushed with this small change.
>
>The new version is on the way.
Sorry for misunderstanding, and thanks for your merge.

Thanks,
Chao Fan
>
>Thanks,
>Chao Fan
>>
>>Thanks,
>>
>>Jirka
>>
>>


--
libvir-list mailing list
libvir-list@redhat.com
https://www.redhat.com/mailman/listinfo/libvir-list