libxl: add 2 consoles to stubdoms for save/restore
PATCH 1/3 libxl: add 2 consoles to stubdoms for save/restore
Add two "special" PV consoles to stubdoms that are going to be used to send and receive the qemu-xen save files on save/restore.
Rename the save file on resume so that it doesn't collide with the name of the next save file.
tools/libxl/libxl.c +1 -1
@@ -750,7 +750,7 @@ int libxl_primary_console_exec(libxl_ctx {uint32_t stubdomid =libxl_get_stubdom_id (ctx, domid_vm);if (stubdomid) -return libxl_console_exec (ctx, stubdomid,1 ,LIBXL_CONSTYPE_PV ); +return libxl_console_exec (ctx, stubdomid,3 ,LIBXL_CONSTYPE_PV );else {if (libxl__domain_is_hvm (ctx, domid_vm))return libxl_console_exec (ctx, domid_vm,0 ,LIBXL_CONSTYPE_SERIAL );
tools/libxl/libxl_create.c +5 -1
@@ -250,8 +250,12 @@ static int domain_restore(libxl_ctx *ctx dm_info->saved_state =NULL ;if (info->hvm) { +char buf[100 ]; +snprintf (buf,sizeof (buf),"/var/lib/xen/qemu-save.%d" , domid); ret =asprintf (&dm_info->saved_state, -"/var/lib/xen/qemu-save.%d" , domid); +"/var/lib/xen/qemu-restore.%d" , domid); +if (ret >=0 ) + ret =rename (buf, dm_info->saved_state); ret = (ret <0 ) ?ERROR_FAIL :0 ; }
tools/libxl/libxl_dm.c +23 -10
@@ -430,7 +430,7 @@ static int libxl_create_stubdom(libxl_ct libxl__device_model_starting **starting_r) {libxl__gc gc =LIBXL_INIT_GC (ctx); -int i, num_console =1 , ret; +int i, num_console =3 , ret;libxl_device_console *console;libxl_domain_create_info c_info;libxl_domain_build_info b_info;
@@ -533,15 +533,28 @@ retry_transaction: console[i].devid = i; console[i].consback =LIBXL_CONSBACK_IOEMU ; console[i].domid = domid; -if (!i) { -char *filename; -char *name =libxl__sprintf (&gc,"qemu-dm-%s" ,libxl_domid_to_name (ctx, info->domid)); -libxl_create_logfile (ctx, name, &filename); - console[i].output =libxl__sprintf (&gc,"file:%s" , filename); - console[i].build_state = &state; -free (filename); - }else - console[i].output ="pty" ; +switch (i) { +case 0 : + { +char *filename; +char *name =libxl__sprintf (&gc,"qemu-dm-%s" ,libxl_domid_to_name (ctx, info->domid)); +libxl_create_logfile (ctx, name, &filename); + console[i].output =libxl__sprintf (&gc,"file:%s" , filename); + console[i].build_state = &state; +free (filename); + } +break ; +case 1 : + console[i].output =libxl__sprintf (&gc,"file:/var/lib/xen/qemu-save.%d" , info->domid); +break ; +case 2 : +if (info->saved_state) + console[i].output =libxl__sprintf (&gc,"filerw:%s" , info->saved_state); +break ; +default : + console[i].output ="pty" ; +break ; + } ret =libxl_device_console_add (ctx, domid, &console[i]);if (ret) goto out_free;
Quoted 2 lines · Stefano Stabellini
Rename the save file on resume so that it doesn't collide with the name of the next save file.
What is the underlying issue here? Why does it matter if a save uses the same filename as a previous resume? Or is the issue that you can accidentally resume an image twice?
Ian.
Quoted 7 lines · Ian Campbell
Quoted 2 lines · Stefano Stabellini
Rename the save file on resume so that it doesn't collide with the name of the next save file.
What is the underlying issue here? Why does it matter if a save uses the same filename as a previous resume? Or is the issue that you can accidentally resume an image twice?
The issue is that the console backend is going to open both the resume file and the next save file when it starts, so they cannot have the same name.
Quoted 5 lines · Stefano Stabellini
Quoted 4 lines · Ian Campbell
Quoted 2 lines · Stefano Stabellini
Rename the save file on resume so that it doesn't collide with the name of the next save file.
Quoted 7 lines
Quoted 3 lines
What is the underlying issue here? Why does it matter if a save uses the same filename as a previous resume? Or is the issue that you can accidentally resume an image twice?
The issue is that the console backend is going to open both the resume file and the next save file when it starts, so they cannot have the same name.
Makes sense.
I think it is worth writing this in the checking comment.
Ian.
Quoted 10 lines · Ian Campbell
Quoted 9 lines · Stefano Stabellini
Quoted 7 lines · Ian Campbell
Quoted 2 lines · Stefano Stabellini
Rename the save file on resume so that it doesn't collide with the name of the next save file.
What is the underlying issue here? Why does it matter if a save uses the same filename as a previous resume? Or is the issue that you can accidentally resume an image twice?
Quoted 7 lines
Quoted 3 lines
The issue is that the console backend is going to open both the resume file and the next save file when it starts, so they cannot have the same name.
Makes sense.
I think it is worth writing this in the checking comment.
Add two "special" PV consoles to stubdoms that are going to be used to send and receive the qemu-xen save files on save/restore.
Rename the save file on resume so that it doesn't collide with the name of the next save file (that is opened by the console backend as soon as it starts so it cannot be the same as the resume state file name).
tools/libxl/libxl.c +1 -1
@@ -750,7 +750,7 @@ int libxl_primary_console_exec(libxl_ctx {uint32_t stubdomid =libxl_get_stubdom_id (ctx, domid_vm);if (stubdomid) -return libxl_console_exec (ctx, stubdomid,1 ,LIBXL_CONSTYPE_PV ); +return libxl_console_exec (ctx, stubdomid,3 ,LIBXL_CONSTYPE_PV );else {if (libxl__domain_is_hvm (ctx, domid_vm))return libxl_console_exec (ctx, domid_vm,0 ,LIBXL_CONSTYPE_SERIAL );
tools/libxl/libxl_create.c +5 -1
@@ -250,8 +250,12 @@ static int domain_restore(libxl_ctx *ctx dm_info->saved_state =NULL ;if (info->hvm) { +char buf[100 ]; +snprintf (buf,sizeof (buf),"/var/lib/xen/qemu-save.%d" , domid); ret =asprintf (&dm_info->saved_state, -"/var/lib/xen/qemu-save.%d" , domid); +"/var/lib/xen/qemu-restore.%d" , domid); +if (ret >=0 ) + ret =rename (buf, dm_info->saved_state); ret = (ret <0 ) ?ERROR_FAIL :0 ; }
tools/libxl/libxl_dm.c +23 -10
@@ -430,7 +430,7 @@ static int libxl_create_stubdom(libxl_ct libxl__device_model_starting **starting_r) {libxl__gc gc =LIBXL_INIT_GC (ctx); -int i, num_console =1 , ret; +int i, num_console =3 , ret;libxl_device_console *console;libxl_domain_create_info c_info;libxl_domain_build_info b_info;
@@ -533,15 +533,28 @@ retry_transaction: console[i].devid = i; console[i].consback =LIBXL_CONSBACK_IOEMU ; console[i].domid = domid; -if (!i) { -char *filename; -char *name =libxl__sprintf (&gc,"qemu-dm-%s" ,libxl_domid_to_name (ctx, info->domid)); -libxl_create_logfile (ctx, name, &filename); - console[i].output =libxl__sprintf (&gc,"file:%s" , filename); - console[i].build_state = &state; -free (filename); - }else - console[i].output ="pty" ; +switch (i) { +case 0 : + { +char *filename; +char *name =libxl__sprintf (&gc,"qemu-dm-%s" ,libxl_domid_to_name (ctx, info->domid)); +libxl_create_logfile (ctx, name, &filename); + console[i].output =libxl__sprintf (&gc,"file:%s" , filename); + console[i].build_state = &state; +free (filename); + } +break ; +case 1 : + console[i].output =libxl__sprintf (&gc,"file:/var/lib/xen/qemu-save.%d" , info->domid); +break ; +case 2 : +if (info->saved_state) + console[i].output =libxl__sprintf (&gc,"filerw:%s" , info->saved_state); +break ; +default : + console[i].output ="pty" ; +break ; + } ret =libxl_device_console_add (ctx, domid, &console[i]);if (ret) goto out_free;
_______________________________________________
Xen-devel mailing list
[email protected]
http://lists.xensource.com/xen-devel
Quoted 13 lines · Stefano Stabellini
Add two "special" PV consoles to stubdoms that are going to be used to send and receive the qemu-xen save files on save/restore.
Rename the save file on resume so that it doesn't collide with the name of the next save file.
Signed-off-by Stefano Stabellini <[email protected]>diff -r
59396addc940tools/libxl/libxl.c
tools/libxl/libxl.c int libxl_primary_console_exec(libxl_ctx · line 753
Quoted 5 lines
tools/libxl/libxl.c +1
-1@@ -750,7 +750,7 @@ int libxl_primary_console_exec(libxl_ctx {uint32_t stubdomid =libxl_get_stubdom_id (ctx, domid_vm);if (stubdomid) -return libxl_console_exec (ctx, stubdomid,1 ,LIBXL_CONSTYPE_PV ); +return libxl_console_exec (ctx, stubdomid,3 ,LIBXL_CONSTYPE_PV );
#define STUBDOM_CONSOLE_xxx or an enum to give a symbolic name to each of the 3-4 console numbers.
Quoted 7 lines
tools/libxl/libxl.c +0
-0else {if (libxl__domain_is_hvm (ctx, domid_vm))return libxl_console_exec (ctx, domid_vm,0 ,LIBXL_CONSTYPE_SERIAL );diff -r
59396addc940tools/libxl/libxl_create.c
tools/libxl/libxl_create.c static int domain_restore(libxl_ctx *ctx · line 256
Quoted 8 lines
tools/libxl/libxl_create.c +3
-1@@ -250,8 +250,12 @@ static int domain_restore(libxl_ctx *ctx dm_info->saved_state =NULL ;if (info->hvm) { +char buf[100 ]; +snprintf (buf,sizeof (buf),"/var/lib/xen/qemu-save.%d" , domid); ret =asprintf (&dm_info->saved_state, -"/var/lib/xen/qemu-save.%d" , domid); +"/var/lib/xen/qemu-restore.%d" , domid);
These two strings end up in a couple of places, probably worth either a #define or libxl__domain_dm_{save,restore}_path(...).
char buf[100] is pretty ugly too. Either use the relevant libxl_Xprintf or a number much smaller than 100 since domid is bounded -- i.e. strlen("/var/lib/xen/qemu-save.") + strlen("65536") (+ 1?). 32 seems to be more than sufficient.
[...]
tools/libxl/libxl_create.c static int domain_restore(libxl_ctx *ctx
Quoted 6 lines
tools/libxl/libxl_create.c +6
-0+case 1 : + console[i].output =libxl__sprintf (&gc,"file:/var/lib/xen/qemu-save.%d" , info->domid); +break ; +case 2 : +if (info->saved_state) + console[i].output =libxl__sprintf (&gc,"filerw:%s" , info->saved_state);
These "file:" and "filerw:" prefixed things are interpreted by qemu within the stub domain? Since you need to introduce filerw why not instead introduce something like pvconsole:{0,1,2,3} (or /dev/consoleN etc)?
Ian.
Quoted 10 lines · Ian Campbell
Quoted 9 lines · Stefano Stabellini
Add two "special" PV consoles to stubdoms that are going to be used to send and receive the qemu-xen save files on save/restore.
Rename the save file on resume so that it doesn't collide with the name of the next save file.
Signed-off-by Stefano Stabellini <[email protected]>
Quoted 12 lines
tools/libxl/libxl.c int libxl_primary_console_exec(libxl_ctx · line 753
Quoted 9 lines
diff -r
59396addc940tools/libxl/libxl.ctools/libxl/libxl.c +1
-1@@ -750,7 +750,7 @@ int libxl_primary_console_exec(libxl_ctx {uint32_t stubdomid =libxl_get_stubdom_id (ctx, domid_vm);if (stubdomid) -return libxl_console_exec (ctx, stubdomid,1 ,LIBXL_CONSTYPE_PV ); +return libxl_console_exec (ctx, stubdomid,3 ,LIBXL_CONSTYPE_PV );#define
STUBDOM_CONSOLE_xxxor an enum to give a symbolic name to each of the 3-4 console numbers.
good idea
Quoted 9 lines
Quoted 9 lines
tools/libxl/libxl.c +0
-0else {if (libxl__domain_is_hvm (ctx, domid_vm))return libxl_console_exec (ctx, domid_vm,0 ,LIBXL_CONSTYPE_SERIAL );diff -r
59396addc940tools/libxl/libxl_create.ctools/libxl/libxl_create.c +0
-0@@ -250,8 +250,12 @@ static int domain_restore(libxl_ctx *ctx
Quoted 11 lines
tools/libxl/libxl_create.c static int domain_restore(libxl_ctx *ctx · line 256
Quoted 7 lines
tools/libxl/libxl_create.c +3
-1dm_info->saved_state =NULL ;if (info->hvm) { +char buf[100 ]; +snprintf (buf,sizeof (buf),"/var/lib/xen/qemu-save.%d" , domid); ret =asprintf (&dm_info->saved_state, -"/var/lib/xen/qemu-save.%d" , domid); +"/var/lib/xen/qemu-restore.%d" , domid);These two strings end up in a couple of places, probably worth either a #define or libxl__domain_dm_{save,restore}_path(...).
considering that the restore string comes from libxc I'll go with an #define
Quoted 5 lines
char buf[100] is pretty ugly too. Either use the relevant
libxl_Xprintfor a number much smaller than 100 since domid is bounded -- i.e.strlen("/var/lib/xen/qemu-save.")+strlen("65536")(+ 1?). 32 seems to be more than sufficient.
I am going to remove it and modify libxc to save to a different filename in the first place
Quoted 10 lines
[...]
tools/libxl/libxl_create.c
Quoted 6 lines
tools/libxl/libxl_create.c +6
-0+case 1 : + console[i].output =libxl__sprintf (&gc,"file:/var/lib/xen/qemu-save.%d" , info->domid); +break ; +case 2 : +if (info->saved_state) + console[i].output =libxl__sprintf (&gc,"filerw:%s" , info->saved_state);These "file:" and "filerw:" prefixed things are interpreted by qemu within the stub domain?
No, they are interpreted by the console backend in dom0