@@ -1047,6 +1047,7 @@ void do_savevm(Monitor *mon, const QDict *qdict)
QEMUFile *f;
int saved_vm_running;
uint64_t vm_state_size;
+ bool generate_ids = true;
qemu_timeval tv;
struct tm tm;
const char *name = qdict_get_try_str(qdict, "name");
@@ -1088,6 +1089,7 @@ void do_savevm(Monitor *mon, const QDict *qdict)
if (ret >= 0) {
pstrcpy(sn->name, sizeof(sn->name), old_sn->name);
pstrcpy(sn->id_str, sizeof(sn->id_str), old_sn->id_str);
+ generate_ids = false;
} else {
pstrcpy(sn->name, sizeof(sn->name), name);
}
@@ -1123,6 +1125,14 @@ void do_savevm(Monitor *mon, const QDict *qdict)
if (bdrv_can_snapshot(bs1)) {
/* Write VM state size only to the image that contains the state */
sn->vm_state_size = (bs == bs1 ? vm_state_size : 0);
+
+ /* Images may have existing IDs so let the ID be autogenerated if the
+ * user did not specify a name.
+ */
+ if (generate_ids) {
+ sn->id_str[0] = '\0';
+ }
+
ret = bdrv_snapshot_create(bs1, sn);
if (ret < 0) {
monitor_printf(mon, "Error while creating snapshot on '%s'\n",