xen-devel.lists.xenproject.org archive mirror
 help / color / mirror / Atom feed
* [PATCH]xl: Add missing start_time entry when create and restore VMs
@ 2010-05-14 11:33 Yang Hongyang
  2010-05-14 15:47 ` Dan Magenheimer
  2010-05-15  2:06 ` [PATCH v2]xl: " Yang Hongyang
  0 siblings, 2 replies; 4+ messages in thread
From: Yang Hongyang @ 2010-05-14 11:33 UTC (permalink / raw)
  To: xen-devel@lists.xensource.com

Add missing start_time entry when create and restore VMs.

Signed-off-by: Yang Hongyang<yanghy@cn.fujitsu.com> 

diff -r baccadfd9418 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c	Fri May 14 08:05:05 2010 +0100
+++ b/tools/libxl/libxl.c	Sat May 15 03:30:13 2010 +0800
@@ -264,30 +264,37 @@
 int libxl_domain_build(struct libxl_ctx *ctx, libxl_domain_build_info *info, uint32_t domid, libxl_domain_build_state *state)
 {
     char **vments = NULL, **localents = NULL;
+    struct timeval start_time;
     int i, ret;
 
     ret = build_pre(ctx, domid, info, state);
     if (ret) goto out;
 
+    gettimeofday(&start_time, NULL);
+
     if (info->hvm) {
         ret = build_hvm(ctx, domid, info, state);
         if (ret) goto out;
 
-        vments = libxl_calloc(ctx, 5, sizeof(char *));
+        vments = libxl_calloc(ctx, 7, sizeof(char *));
         vments[0] = "rtc/timeoffset";
         vments[1] = (info->u.hvm.timeoffset) ? info->u.hvm.timeoffset : "";
         vments[2] = "image/ostype";
         vments[3] = "hvm";
+        vments[4] = "start_time";
+        vments[5] = libxl_sprintf(ctx, "%lu.%d", start_time.tv_sec,(int)start_time.tv_usec/10000);
     } else {
         ret = build_pv(ctx, domid, info, state);
         if (ret) goto out;
 
-        vments = libxl_calloc(ctx, 9, sizeof(char *));
+        vments = libxl_calloc(ctx, 11, sizeof(char *));
         i = 0;
         vments[i++] = "image/ostype";
         vments[i++] = "linux";
         vments[i++] = "image/kernel";
         vments[i++] = (char*) info->kernel;
+        vments[i++] = "start_time";
+        vments[i++] = libxl_sprintf(ctx, "%lu.%d", start_time.tv_sec,(int)start_time.tv_usec/10000);
         if (info->u.pv.ramdisk) {
             vments[i++] = "image/ramdisk";
             vments[i++] = (char*) info->u.pv.ramdisk;
@@ -307,6 +314,7 @@
                          libxl_device_model_info *dm_info)
 {
     char **vments = NULL, **localents = NULL;
+    struct timeval start_time;
     int i, ret, esave, flags;
 
     ret = build_pre(ctx, domid, info, state);
@@ -315,19 +323,25 @@
     ret = restore_common(ctx, domid, info, state, fd);
     if (ret) goto out;
 
+    gettimeofday(&start_time, NULL);
+
     if (info->hvm) {
-        vments = libxl_calloc(ctx, 5, sizeof(char *));
+        vments = libxl_calloc(ctx, 7, sizeof(char *));
         vments[0] = "rtc/timeoffset";
         vments[1] = (info->u.hvm.timeoffset) ? info->u.hvm.timeoffset : "";
         vments[2] = "image/ostype";
         vments[3] = "hvm";
+        vments[4] = "start_time";
+        vments[5] = libxl_sprintf(ctx, "%lu.%d", start_time.tv_sec,(int)start_time.tv_usec/10000);
     } else {
-        vments = libxl_calloc(ctx, 9, sizeof(char *));
+        vments = libxl_calloc(ctx, 11, sizeof(char *));
         i = 0;
         vments[i++] = "image/ostype";
         vments[i++] = "linux";
         vments[i++] = "image/kernel";
         vments[i++] = (char*) info->kernel;
+        vments[i++] = "start_time";
+        vments[i++] = libxl_sprintf(ctx, "%lu.%d", start_time.tv_sec,(int)start_time.tv_usec/10000);
         if (info->u.pv.ramdisk) {
             vments[i++] = "image/ramdisk";
             vments[i++] = (char*) info->u.pv.ramdisk;

-- 
Regards
Yang Hongyang

^ permalink raw reply	[flat|nested] 4+ messages in thread

* RE: [PATCH]xl: Add missing start_time entry when create and restore VMs
  2010-05-14 11:33 [PATCH]xl: Add missing start_time entry when create and restore VMs Yang Hongyang
@ 2010-05-14 15:47 ` Dan Magenheimer
  2010-05-15  1:54   ` Yang Hongyang
  2010-05-15  2:06 ` [PATCH v2]xl: " Yang Hongyang
  1 sibling, 1 reply; 4+ messages in thread
From: Dan Magenheimer @ 2010-05-14 15:47 UTC (permalink / raw)
  To: Yang Hongyang, xen-devel

> + vments[5] = libxl_sprintf(ctx, "%lu.%d", start_time.tv_sec,(int)start_time.tv_usec/10000);
> + vments[i++] = libxl_sprintf(ctx, "%lu.%d",start_time.tv_sec,(int)start_time.tv_usec/10000);

I don't think these work as intended.  For example, if
tv_usec is 10000, I think you want xxx.01 printed, not
xxx.1.  Maybe you want %lu.%02d?

And in any case, is there a reason to limit the precision
to two digits?  Why not %lu.%06d?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH]xl: Add missing start_time entry when create and restore VMs
  2010-05-14 15:47 ` Dan Magenheimer
@ 2010-05-15  1:54   ` Yang Hongyang
  0 siblings, 0 replies; 4+ messages in thread
From: Yang Hongyang @ 2010-05-15  1:54 UTC (permalink / raw)
  To: Dan Magenheimer; +Cc: xen-devel

On 05/14/2010 11:47 PM, Dan Magenheimer wrote:
>> + vments[5] = libxl_sprintf(ctx, "%lu.%d", start_time.tv_sec,(int)start_time.tv_usec/10000);
>> + vments[i++] = libxl_sprintf(ctx, "%lu.%d",start_time.tv_sec,(int)start_time.tv_usec/10000);
> 
> I don't think these work as intended.  For example, if
> tv_usec is 10000, I think you want xxx.01 printed, not
> xxx.1.  Maybe you want %lu.%02d?

Ah sorry, you're right, I'll fix that, Thank you.

> 
> And in any case, is there a reason to limit the precision
> to two digits?  Why not %lu.%06d?
> 

I see no reason too. But the current start_time is limit to
two digits(vms created from 'xm create'). So I limit the
precision to two digits.

> 


-- 
Regards
Yang Hongyang

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH v2]xl: Add missing start_time entry when create and restore VMs
  2010-05-14 11:33 [PATCH]xl: Add missing start_time entry when create and restore VMs Yang Hongyang
  2010-05-14 15:47 ` Dan Magenheimer
@ 2010-05-15  2:06 ` Yang Hongyang
  1 sibling, 0 replies; 4+ messages in thread
From: Yang Hongyang @ 2010-05-15  2:06 UTC (permalink / raw)
  To: xen-devel@lists.xensource.com, Dan Magenheimer

v1->v2:
  when tv_usec is 10000, should print xxx.01, not xxx.1.

=================================================================

Add missing start_time entry when create and restore VMs.

Signed-off-by: Yang Hongyang<yanghy@cn.fujitsu.com> 

diff -r baccadfd9418 tools/libxl/libxl.c
--- a/tools/libxl/libxl.c	Fri May 14 08:05:05 2010 +0100
+++ b/tools/libxl/libxl.c	Sat May 15 18:02:32 2010 +0800
@@ -264,30 +264,37 @@
 int libxl_domain_build(struct libxl_ctx *ctx, libxl_domain_build_info *info, uint32_t domid, libxl_domain_build_state *state)
 {
     char **vments = NULL, **localents = NULL;
+    struct timeval start_time;
     int i, ret;
 
     ret = build_pre(ctx, domid, info, state);
     if (ret) goto out;
 
+    gettimeofday(&start_time, NULL);
+
     if (info->hvm) {
         ret = build_hvm(ctx, domid, info, state);
         if (ret) goto out;
 
-        vments = libxl_calloc(ctx, 5, sizeof(char *));
+        vments = libxl_calloc(ctx, 7, sizeof(char *));
         vments[0] = "rtc/timeoffset";
         vments[1] = (info->u.hvm.timeoffset) ? info->u.hvm.timeoffset : "";
         vments[2] = "image/ostype";
         vments[3] = "hvm";
+        vments[4] = "start_time";
+        vments[5] = libxl_sprintf(ctx, "%lu.%02d", start_time.tv_sec,(int)start_time.tv_usec/10000);
     } else {
         ret = build_pv(ctx, domid, info, state);
         if (ret) goto out;
 
-        vments = libxl_calloc(ctx, 9, sizeof(char *));
+        vments = libxl_calloc(ctx, 11, sizeof(char *));
         i = 0;
         vments[i++] = "image/ostype";
         vments[i++] = "linux";
         vments[i++] = "image/kernel";
         vments[i++] = (char*) info->kernel;
+        vments[i++] = "start_time";
+        vments[i++] = libxl_sprintf(ctx, "%lu.%02d", start_time.tv_sec,(int)start_time.tv_usec/10000);
         if (info->u.pv.ramdisk) {
             vments[i++] = "image/ramdisk";
             vments[i++] = (char*) info->u.pv.ramdisk;
@@ -307,6 +314,7 @@
                          libxl_device_model_info *dm_info)
 {
     char **vments = NULL, **localents = NULL;
+    struct timeval start_time;
     int i, ret, esave, flags;
 
     ret = build_pre(ctx, domid, info, state);
@@ -315,19 +323,25 @@
     ret = restore_common(ctx, domid, info, state, fd);
     if (ret) goto out;
 
+    gettimeofday(&start_time, NULL);
+
     if (info->hvm) {
-        vments = libxl_calloc(ctx, 5, sizeof(char *));
+        vments = libxl_calloc(ctx, 7, sizeof(char *));
         vments[0] = "rtc/timeoffset";
         vments[1] = (info->u.hvm.timeoffset) ? info->u.hvm.timeoffset : "";
         vments[2] = "image/ostype";
         vments[3] = "hvm";
+        vments[4] = "start_time";
+        vments[5] = libxl_sprintf(ctx, "%lu.%02d", start_time.tv_sec,(int)start_time.tv_usec/10000);
     } else {
-        vments = libxl_calloc(ctx, 9, sizeof(char *));
+        vments = libxl_calloc(ctx, 11, sizeof(char *));
         i = 0;
         vments[i++] = "image/ostype";
         vments[i++] = "linux";
         vments[i++] = "image/kernel";
         vments[i++] = (char*) info->kernel;
+        vments[i++] = "start_time";
+        vments[i++] = libxl_sprintf(ctx, "%lu.%02d", start_time.tv_sec,(int)start_time.tv_usec/10000);
         if (info->u.pv.ramdisk) {
             vments[i++] = "image/ramdisk";
             vments[i++] = (char*) info->u.pv.ramdisk;

-- 
Regards
Yang Hongyang

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2010-05-15  2:06 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-05-14 11:33 [PATCH]xl: Add missing start_time entry when create and restore VMs Yang Hongyang
2010-05-14 15:47 ` Dan Magenheimer
2010-05-15  1:54   ` Yang Hongyang
2010-05-15  2:06 ` [PATCH v2]xl: " Yang Hongyang

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).