Skip to contentSkip to conversation

migration: Truncate state file in xen-save-devices-state

PATCH In review Dov Murik 5 participants 8 messages Sep 21, 2020 – Sep 28, 2020

lore
Share & tools
lore

Dov Murik

author
#0 lore raw

PATCH 1/1 migration: Truncate state file in xen-save-devices-state

When running the xen-save-devices-state QMP command, if the filename already exists it will be truncated before dumping the devices' state into it.

---

Note that I found the above issue while trying to debug xen-load-devices-state which simply fails (prints "Configuration section missing" to stderr) directly after xen-save-devices-state (in the same VM). I wonder if I should file a bug report as-is or investigate some more. Advice welcome.

-Dov

---
 migration/savevm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
migration/savevm.c +2 -1
index 304d98ff78..e1b26672cc 100644
@@ -2803,7 +2803,8 @@ void qmp_xen_save_devices_state(const char *filename, bool has_live, bool live,
     vm_stop(RUN_STATE_SAVE_VM);
     global_state_store_running();
 
-    ioc = qio_channel_file_new_path(filename, O_WRONLY | O_CREAT, 0660, errp);
+    ioc = qio_channel_file_new_path(filename, O_WRONLY | O_CREAT | O_TRUNC,
+                                    0660, errp);
     if (!ioc) {
         goto the_end;
     }
Signature · 1 line
2.20.1
Reviewed-by on v1 1/1
#1 lore raw
Quoted 6 lines · * Dov Murik ([email protected]) wrote:

When running the xen-save-devices-state QMP command, if the filename already exists it will be truncated before dumping the devices' state into it.

---

OK, that looks fine to me, so:

Quoted 6 lines

Note that I found the above issue while trying to debug xen-load-devices-state which simply fails (prints "Configuration section missing" to stderr) directly after xen-save-devices-state (in the same VM). I wonder if I should file a bug report as-is or investigate some more. Advice welcome.

I don't try the xen-* commands normally; I've cc'ing in Stefano and Anthony.

Dave

Quoted 24 lines
(quoted diff) +0 -2
-Dov
 
---
 migration/savevm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
migration/savevm.c +2 -1
index 304d98ff78..e1b26672cc 100644
@@ -2803,7 +2803,8 @@ void qmp_xen_save_devices_state(const char *filename, bool has_live, bool live,
     vm_stop(RUN_STATE_SAVE_VM);
     global_state_store_running();
 
-    ioc = qio_channel_file_new_path(filename, O_WRONLY | O_CREAT, 0660, errp);
+    ioc = qio_channel_file_new_path(filename, O_WRONLY | O_CREAT | O_TRUNC,
+                                    0660, errp);
     if (!ioc) {
         goto the_end;
     }
Signature · 1 line
2.20.1
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
author
#2 lore raw
Quoted 13 lines · Dr. David Alan Gilbert
Quoted 6 lines · * Dov Murik ([email protected]) wrote:

When running the xen-save-devices-state QMP command, if the filename already exists it will be truncated before dumping the devices' state into it.

---

OK, that looks fine to me, so:

Quoted 1 line
Quoted 8 lines
Quoted 5 lines

Note that I found the above issue while trying to debug xen-load-devices-state which simply fails (prints "Configuration section missing" to stderr) directly after xen-save-devices-state (in the same VM). I wonder if I should file a bug report as-is or investigate some more. Advice welcome.

I don't try the xen-* commands normally; I've cc'ing in Stefano and Anthony.

Thanks Dave. Just to be clear, I'm running this without Xen at all; but these commands seem to work OK for dumping/restoring guest's devices state (without RAM) -- if I modify the code to circumvent the mentioned problem.

Dov

Quoted 27 lines

Dave

Quoted 24 lines
(quoted diff) +0 -2
-Dov
 
---
  migration/savevm.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
migration/savevm.c +2 -1
index 304d98ff78..e1b26672cc 100644
@@ -2803,7 +2803,8 @@ void qmp_xen_save_devices_state(const char *filename, bool has_live, bool live,
      vm_stop(RUN_STATE_SAVE_VM);
      global_state_store_running();
 
-    ioc = qio_channel_file_new_path(filename, O_WRONLY | O_CREAT, 0660, errp);
+    ioc = qio_channel_file_new_path(filename, O_WRONLY | O_CREAT | O_TRUNC,
+                                    0660, errp);
      if (!ioc) {
          goto the_end;
      }
Signature · 1 line
2.20.1
#3 lore raw
Quoted 22 lines · * Dov Murik ([email protected]) wrote:
Quoted 19 lines · Dr. David Alan Gilbert
Quoted 6 lines · * Dov Murik ([email protected]) wrote:

When running the xen-save-devices-state QMP command, if the filename already exists it will be truncated before dumping the devices' state into it.

---

OK, that looks fine to me, so:

Quoted 6 lines

Note that I found the above issue while trying to debug xen-load-devices-state which simply fails (prints "Configuration section missing" to stderr) directly after xen-save-devices-state (in the same VM). I wonder if I should file a bug report as-is or investigate some more. Advice welcome.

Quoted 7 lines
Quoted 2 lines

I don't try the xen-* commands normally; I've cc'ing in Stefano and Anthony.

Thanks Dave. Just to be clear, I'm running this without Xen at all; but these commands seem to work OK for dumping/restoring guest's devices state (without RAM) -- if I modify the code to circumvent the mentioned problem.

Yeh, although you can't rely on them not doing something Xen in the future. There are a few other similar ways of doing what you want; eg. if your RAM is 'shared' then you can set the x-ignore-shared migration capability.

Dave

Quoted 29 lines

Dov

Quoted 26 lines

Dave

Quoted 23 lines
(quoted diff) +0 -2
-Dov
 
---
  migration/savevm.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
migration/savevm.c +2 -1
index 304d98ff78..e1b26672cc 100644
@@ -2803,7 +2803,8 @@ void qmp_xen_save_devices_state(const char *filename, bool has_live, bool live,
      vm_stop(RUN_STATE_SAVE_VM);
      global_state_store_running();
-    ioc = qio_channel_file_new_path(filename, O_WRONLY | O_CREAT, 0660, errp);
+    ioc = qio_channel_file_new_path(filename, O_WRONLY | O_CREAT | O_TRUNC,
+                                    0660, errp);
      if (!ioc) {
          goto the_end;
      }
Signature · 1 line
2.20.1
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
#4 lore raw

Adding Paul

Quoted 70 lines · Dr. David Alan Gilbert
Quoted 22 lines · * Dov Murik ([email protected]) wrote:
Quoted 19 lines · Dr. David Alan Gilbert
Quoted 6 lines · * Dov Murik ([email protected]) wrote:

When running the xen-save-devices-state QMP command, if the filename already exists it will be truncated before dumping the devices' state into it.

---

OK, that looks fine to me, so:

Quoted 6 lines

Note that I found the above issue while trying to debug xen-load-devices-state which simply fails (prints "Configuration section missing" to stderr) directly after xen-save-devices-state (in the same VM). I wonder if I should file a bug report as-is or investigate some more. Advice welcome.

Quoted 7 lines
Quoted 2 lines

I don't try the xen-* commands normally; I've cc'ing in Stefano and Anthony.

Thanks Dave. Just to be clear, I'm running this without Xen at all; but these commands seem to work OK for dumping/restoring guest's devices state (without RAM) -- if I modify the code to circumvent the mentioned problem.

Yeh, although you can't rely on them not doing something Xen in the future. There are a few other similar ways of doing what you want; eg. if your RAM is 'shared' then you can set the x-ignore-shared migration capability.

Dave

Quoted 29 lines

Dov

Quoted 26 lines

Dave

Quoted 23 lines
(quoted diff) +0 -2
-Dov
 
---
  migration/savevm.c | 3 ++-
  1 file changed, 2 insertions(+), 1 deletion(-)
migration/savevm.c +2 -1
index 304d98ff78..e1b26672cc 100644
@@ -2803,7 +2803,8 @@ void qmp_xen_save_devices_state(const char *filename, bool has_live, bool live,
      vm_stop(RUN_STATE_SAVE_VM);
      global_state_store_running();
-    ioc = qio_channel_file_new_path(filename, O_WRONLY | O_CREAT, 0660, errp);
+    ioc = qio_channel_file_new_path(filename, O_WRONLY | O_CREAT | O_TRUNC,
+                                    0660, errp);
      if (!ioc) {
          goto the_end;
      }
Signature · 1 line
2.20.1
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
#5 lore raw
In reply to Dr. David Alan Gilbert
Quoted 11 lines · * Dr. David Alan Gilbert ([email protected]) wrote:
Quoted 6 lines · * Dov Murik ([email protected]) wrote:

When running the xen-save-devices-state QMP command, if the filename already exists it will be truncated before dumping the devices' state into it.

---

OK, that looks fine to me, so:

Queued

Quoted 40 lines
Quoted 6 lines

Note that I found the above issue while trying to debug xen-load-devices-state which simply fails (prints "Configuration section missing" to stderr) directly after xen-save-devices-state (in the same VM). I wonder if I should file a bug report as-is or investigate some more. Advice welcome.

I don't try the xen-* commands normally; I've cc'ing in Stefano and Anthony.

Dave

Quoted 24 lines
(quoted diff) +0 -2
-Dov
 
---
 migration/savevm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
migration/savevm.c +2 -1
index 304d98ff78..e1b26672cc 100644
@@ -2803,7 +2803,8 @@ void qmp_xen_save_devices_state(const char *filename, bool has_live, bool live,
     vm_stop(RUN_STATE_SAVE_VM);
     global_state_store_running();
 
-    ioc = qio_channel_file_new_path(filename, O_WRONLY | O_CREAT, 0660, errp);
+    ioc = qio_channel_file_new_path(filename, O_WRONLY | O_CREAT | O_TRUNC,
+                                    0660, errp);
     if (!ioc) {
         goto the_end;
     }
Signature · 1 line
2.20.1
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
Signature · 1 line
Dr. David Alan Gilbert / [email protected] / Manchester, UK
#6 lore raw
In reply to Dr. David Alan Gilbert
Quoted 18 lines · Dr. David Alan Gilbert
Quoted 17 lines · * Dov Murik ([email protected]) wrote:

When running the xen-save-devices-state QMP command, if the filename already exists it will be truncated before dumping the devices' state into it.

---
 migration/savevm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
migration/savevm.c +0 -0
index 304d98ff78..e1b26672cc 100644
@@ -2803,7 +2803,8 @@ void qmp_xen_save_devices_state(const char *filename, bool has_live, bool live,
     vm_stop(RUN_STATE_SAVE_VM);
     global_state_store_running();
 
Quoted 6 lines

migration/savevm.c void qmp_xen_save_devices_state(const char *filename, bool has_live, bool live, · line 2810

Quoted 6 lines
migration/savevm.c +2 -1
-    ioc = qio_channel_file_new_path(filename, O_WRONLY | O_CREAT, 0660, errp);
+    ioc = qio_channel_file_new_path(filename, O_WRONLY | O_CREAT | O_TRUNC,
+                                    0660, errp);
     if (!ioc) {
         goto the_end;
     }

Hi Marek,

Do you know if the above patch is going to work in a linux stubdomain? Can we truncate the "save file" which seems to be stubdomain's console 1?

Cheers,

Signature · 1 line
Anthony PERARD
#7 lore raw
Quoted 28 lines · Anthony PERARD
Quoted 18 lines · Dr. David Alan Gilbert
Quoted 17 lines · * Dov Murik ([email protected]) wrote:

When running the xen-save-devices-state QMP command, if the filename already exists it will be truncated before dumping the devices' state into it.

---
 migration/savevm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
migration/savevm.c +0 -0
index 304d98ff78..e1b26672cc 100644
@@ -2803,7 +2803,8 @@ void qmp_xen_save_devices_state(const char *filename, bool has_live, bool live,
     vm_stop(RUN_STATE_SAVE_VM);
     global_state_store_running();
 
Quoted 6 lines

migration/savevm.c void qmp_xen_save_devices_state(const char *filename, bool has_live, bool live, · line 2810

Quoted 6 lines
migration/savevm.c +2 -1
-    ioc = qio_channel_file_new_path(filename, O_WRONLY | O_CREAT, 0660, errp);
+    ioc = qio_channel_file_new_path(filename, O_WRONLY | O_CREAT | O_TRUNC,
+                                    0660, errp);
     if (!ioc) {
         goto the_end;
     }

Hi Marek,

Quoted 2 lines

Do you know if the above patch is going to work in a linux stubdomain? Can we truncate the "save file" which seems to be stubdomain's console 1?

No, truncate won't work on the stubdomain's console. I mean, the operation won't fail, but the actual file connected to the console on the other end won't get truncated. But I think in case of stubdomain, toolstack should connect the console to an empty file, so it shouldn't be a problem.

Signature · 5 lines
Best Regards,
Marek Marczykowski-Górecki
Invisible Things Lab
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?