qemu-devel.nongnu.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] savevm: Delete stale snapshots in save_snapshot()
@ 2020-12-08  6:53 Tuguoyi
  2020-12-08  6:53 ` [PATCH 1/2] savevm: Remove dead code " Tuguoyi
  2020-12-08  6:53 ` [PATCH 2/2] savevm: Delete snapshots just created in case of error Tuguoyi
  0 siblings, 2 replies; 7+ messages in thread
From: Tuguoyi @ 2020-12-08  6:53 UTC (permalink / raw)
  To: Juan Quintela, Dr. David Alan Gilbert; +Cc: tuguoyi, qemu-devel, Tuguoyi

These two patches just clear dead code and delete stale snapshots
in case of error in save_snapshot()

Tuguoyi (2):
  savevm: Remove dead code in save_snapshot()
  savevm: Delete snapshots just created in case of error

 migration/savevm.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

-- 
2.7.4



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

* [PATCH 1/2] savevm: Remove dead code in save_snapshot()
  2020-12-08  6:53 [PATCH 0/2] savevm: Delete stale snapshots in save_snapshot() Tuguoyi
@ 2020-12-08  6:53 ` Tuguoyi
  2020-12-17 15:27   ` Dr. David Alan Gilbert
  2020-12-08  6:53 ` [PATCH 2/2] savevm: Delete snapshots just created in case of error Tuguoyi
  1 sibling, 1 reply; 7+ messages in thread
From: Tuguoyi @ 2020-12-08  6:53 UTC (permalink / raw)
  To: Juan Quintela, Dr. David Alan Gilbert; +Cc: tuguoyi, qemu-devel, Tuguoyi

The snapshot in each bs is deleted at the beginning, so there is no need
to find the snapshot again.

Signed-off-by: Tuguoyi <tu.guoyi@h3c.com>
---
 migration/savevm.c | 10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/migration/savevm.c b/migration/savevm.c
index 5f937a2..601b514 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -2728,7 +2728,7 @@ int qemu_load_device_state(QEMUFile *f)
 int save_snapshot(const char *name, Error **errp)
 {
     BlockDriverState *bs, *bs1;
-    QEMUSnapshotInfo sn1, *sn = &sn1, old_sn1, *old_sn = &old_sn1;
+    QEMUSnapshotInfo sn1, *sn = &sn1;
     int ret = -1, ret2;
     QEMUFile *f;
     int saved_vm_running;
@@ -2797,13 +2797,7 @@ int save_snapshot(const char *name, Error **errp)
     }
 
     if (name) {
-        ret = bdrv_snapshot_find(bs, old_sn, name);
-        if (ret >= 0) {
-            pstrcpy(sn->name, sizeof(sn->name), old_sn->name);
-            pstrcpy(sn->id_str, sizeof(sn->id_str), old_sn->id_str);
-        } else {
-            pstrcpy(sn->name, sizeof(sn->name), name);
-        }
+        pstrcpy(sn->name, sizeof(sn->name), name);
     } else {
         /* cast below needed for OpenBSD where tv_sec is still 'long' */
         localtime_r((const time_t *)&tv.tv_sec, &tm);
-- 
2.7.4



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

* [PATCH 2/2] savevm: Delete snapshots just created in case of error
  2020-12-08  6:53 [PATCH 0/2] savevm: Delete stale snapshots in save_snapshot() Tuguoyi
  2020-12-08  6:53 ` [PATCH 1/2] savevm: Remove dead code " Tuguoyi
@ 2020-12-08  6:53 ` Tuguoyi
  2020-12-17 15:38   ` Dr. David Alan Gilbert
  1 sibling, 1 reply; 7+ messages in thread
From: Tuguoyi @ 2020-12-08  6:53 UTC (permalink / raw)
  To: Juan Quintela, Dr. David Alan Gilbert; +Cc: tuguoyi, qemu-devel, Tuguoyi

bdrv_all_create_snapshot() can fails with some snapshots created,
so it's better to delete those snapshots before returns to the caller

Signed-off-by: Tuguoyi <tu.guoyi@h3c.com>
---
 migration/savevm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/migration/savevm.c b/migration/savevm.c
index 601b514..4a18c9d 100644
--- a/migration/savevm.c
+++ b/migration/savevm.c
@@ -2833,6 +2833,7 @@ int save_snapshot(const char *name, Error **errp)
     if (ret < 0) {
         error_setg(errp, "Error while creating snapshot on '%s'",
                    bdrv_get_device_or_node_name(bs));
+        bdrv_all_delete_snapshot(sn->name, &bs, NULL);
         goto the_end;
     }
 
-- 
2.7.4



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

* Re: [PATCH 1/2] savevm: Remove dead code in save_snapshot()
  2020-12-08  6:53 ` [PATCH 1/2] savevm: Remove dead code " Tuguoyi
@ 2020-12-17 15:27   ` Dr. David Alan Gilbert
  2020-12-17 16:14     ` Denis V. Lunev
  0 siblings, 1 reply; 7+ messages in thread
From: Dr. David Alan Gilbert @ 2020-12-17 15:27 UTC (permalink / raw)
  To: Tuguoyi, den, berrange; +Cc: tuguoyi, qemu-devel, Juan Quintela

* Tuguoyi (tu.guoyi@h3c.com) wrote:
> The snapshot in each bs is deleted at the beginning, so there is no need
> to find the snapshot again.
> 
> Signed-off-by: Tuguoyi <tu.guoyi@h3c.com>

This looks OK to me, becoming redundant after Denis's 0b46160 - but
I don't know the snapshot code much;

Denis - do you agree this is correct?

Dave

> ---
>  migration/savevm.c | 10 ++--------
>  1 file changed, 2 insertions(+), 8 deletions(-)
> 
> diff --git a/migration/savevm.c b/migration/savevm.c
> index 5f937a2..601b514 100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -2728,7 +2728,7 @@ int qemu_load_device_state(QEMUFile *f)
>  int save_snapshot(const char *name, Error **errp)
>  {
>      BlockDriverState *bs, *bs1;
> -    QEMUSnapshotInfo sn1, *sn = &sn1, old_sn1, *old_sn = &old_sn1;
> +    QEMUSnapshotInfo sn1, *sn = &sn1;
>      int ret = -1, ret2;
>      QEMUFile *f;
>      int saved_vm_running;
> @@ -2797,13 +2797,7 @@ int save_snapshot(const char *name, Error **errp)
>      }
>  
>      if (name) {
> -        ret = bdrv_snapshot_find(bs, old_sn, name);
> -        if (ret >= 0) {
> -            pstrcpy(sn->name, sizeof(sn->name), old_sn->name);
> -            pstrcpy(sn->id_str, sizeof(sn->id_str), old_sn->id_str);
> -        } else {
> -            pstrcpy(sn->name, sizeof(sn->name), name);
> -        }
> +        pstrcpy(sn->name, sizeof(sn->name), name);
>      } else {
>          /* cast below needed for OpenBSD where tv_sec is still 'long' */
>          localtime_r((const time_t *)&tv.tv_sec, &tm);
> -- 
> 2.7.4
> 
-- 
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



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

* Re: [PATCH 2/2] savevm: Delete snapshots just created in case of error
  2020-12-08  6:53 ` [PATCH 2/2] savevm: Delete snapshots just created in case of error Tuguoyi
@ 2020-12-17 15:38   ` Dr. David Alan Gilbert
  0 siblings, 0 replies; 7+ messages in thread
From: Dr. David Alan Gilbert @ 2020-12-17 15:38 UTC (permalink / raw)
  To: Tuguoyi, berrange; +Cc: tuguoyi, qemu-devel, Juan Quintela

* Tuguoyi (tu.guoyi@h3c.com) wrote:
> bdrv_all_create_snapshot() can fails with some snapshots created,
> so it's better to delete those snapshots before returns to the caller
> 
> Signed-off-by: Tuguoyi <tu.guoyi@h3c.com>

This makes sense to me,


Reviewed-by: Dr. David Alan Gilbert <dgilbert@redhat.com>

> ---
>  migration/savevm.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/migration/savevm.c b/migration/savevm.c
> index 601b514..4a18c9d 100644
> --- a/migration/savevm.c
> +++ b/migration/savevm.c
> @@ -2833,6 +2833,7 @@ int save_snapshot(const char *name, Error **errp)
>      if (ret < 0) {
>          error_setg(errp, "Error while creating snapshot on '%s'",
>                     bdrv_get_device_or_node_name(bs));
> +        bdrv_all_delete_snapshot(sn->name, &bs, NULL);
>          goto the_end;
>      }
>  
> -- 
> 2.7.4
> 
-- 
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



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

* Re: [PATCH 1/2] savevm: Remove dead code in save_snapshot()
  2020-12-17 15:27   ` Dr. David Alan Gilbert
@ 2020-12-17 16:14     ` Denis V. Lunev
  2020-12-17 17:32       ` Dr. David Alan Gilbert
  0 siblings, 1 reply; 7+ messages in thread
From: Denis V. Lunev @ 2020-12-17 16:14 UTC (permalink / raw)
  To: Dr. David Alan Gilbert, Tuguoyi, berrange
  Cc: tuguoyi, qemu-devel, Juan Quintela

On 12/17/20 6:27 PM, Dr. David Alan Gilbert wrote:
> * Tuguoyi (tu.guoyi@h3c.com) wrote:
>> The snapshot in each bs is deleted at the beginning, so there is no need
>> to find the snapshot again.
>>
>> Signed-off-by: Tuguoyi <tu.guoyi@h3c.com>
> This looks OK to me, becoming redundant after Denis's 0b46160 - but
> I don't know the snapshot code much;
>
> Denis - do you agree this is correct?

For me it looks too that the code becomes redundant, thus

Reviewed-by: Denis V. Lunev <den@openvz.org>

> Dave
>
>> ---
>>  migration/savevm.c | 10 ++--------
>>  1 file changed, 2 insertions(+), 8 deletions(-)
>>
>> diff --git a/migration/savevm.c b/migration/savevm.c
>> index 5f937a2..601b514 100644
>> --- a/migration/savevm.c
>> +++ b/migration/savevm.c
>> @@ -2728,7 +2728,7 @@ int qemu_load_device_state(QEMUFile *f)
>>  int save_snapshot(const char *name, Error **errp)
>>  {
>>      BlockDriverState *bs, *bs1;
>> -    QEMUSnapshotInfo sn1, *sn = &sn1, old_sn1, *old_sn = &old_sn1;
>> +    QEMUSnapshotInfo sn1, *sn = &sn1;
>>      int ret = -1, ret2;
>>      QEMUFile *f;
>>      int saved_vm_running;
>> @@ -2797,13 +2797,7 @@ int save_snapshot(const char *name, Error **errp)
>>      }
>>  
>>      if (name) {
>> -        ret = bdrv_snapshot_find(bs, old_sn, name);
>> -        if (ret >= 0) {
>> -            pstrcpy(sn->name, sizeof(sn->name), old_sn->name);
>> -            pstrcpy(sn->id_str, sizeof(sn->id_str), old_sn->id_str);
>> -        } else {
>> -            pstrcpy(sn->name, sizeof(sn->name), name);
>> -        }
>> +        pstrcpy(sn->name, sizeof(sn->name), name);
>>      } else {
>>          /* cast below needed for OpenBSD where tv_sec is still 'long' */
>>          localtime_r((const time_t *)&tv.tv_sec, &tm);
>> -- 
>> 2.7.4
>>



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

* Re: [PATCH 1/2] savevm: Remove dead code in save_snapshot()
  2020-12-17 16:14     ` Denis V. Lunev
@ 2020-12-17 17:32       ` Dr. David Alan Gilbert
  0 siblings, 0 replies; 7+ messages in thread
From: Dr. David Alan Gilbert @ 2020-12-17 17:32 UTC (permalink / raw)
  To: Denis V. Lunev; +Cc: qemu-devel, tuguoyi, berrange, Tuguoyi, Juan Quintela

* Denis V. Lunev (den@openvz.org) wrote:
> On 12/17/20 6:27 PM, Dr. David Alan Gilbert wrote:
> > * Tuguoyi (tu.guoyi@h3c.com) wrote:
> >> The snapshot in each bs is deleted at the beginning, so there is no need
> >> to find the snapshot again.
> >>
> >> Signed-off-by: Tuguoyi <tu.guoyi@h3c.com>
> > This looks OK to me, becoming redundant after Denis's 0b46160 - but
> > I don't know the snapshot code much;
> >
> > Denis - do you agree this is correct?
> 
> For me it looks too that the code becomes redundant, thus
> 
> Reviewed-by: Denis V. Lunev <den@openvz.org>

Thanks!
(Both patches) queued

> > Dave
> >
> >> ---
> >>  migration/savevm.c | 10 ++--------
> >>  1 file changed, 2 insertions(+), 8 deletions(-)
> >>
> >> diff --git a/migration/savevm.c b/migration/savevm.c
> >> index 5f937a2..601b514 100644
> >> --- a/migration/savevm.c
> >> +++ b/migration/savevm.c
> >> @@ -2728,7 +2728,7 @@ int qemu_load_device_state(QEMUFile *f)
> >>  int save_snapshot(const char *name, Error **errp)
> >>  {
> >>      BlockDriverState *bs, *bs1;
> >> -    QEMUSnapshotInfo sn1, *sn = &sn1, old_sn1, *old_sn = &old_sn1;
> >> +    QEMUSnapshotInfo sn1, *sn = &sn1;
> >>      int ret = -1, ret2;
> >>      QEMUFile *f;
> >>      int saved_vm_running;
> >> @@ -2797,13 +2797,7 @@ int save_snapshot(const char *name, Error **errp)
> >>      }
> >>  
> >>      if (name) {
> >> -        ret = bdrv_snapshot_find(bs, old_sn, name);
> >> -        if (ret >= 0) {
> >> -            pstrcpy(sn->name, sizeof(sn->name), old_sn->name);
> >> -            pstrcpy(sn->id_str, sizeof(sn->id_str), old_sn->id_str);
> >> -        } else {
> >> -            pstrcpy(sn->name, sizeof(sn->name), name);
> >> -        }
> >> +        pstrcpy(sn->name, sizeof(sn->name), name);
> >>      } else {
> >>          /* cast below needed for OpenBSD where tv_sec is still 'long' */
> >>          localtime_r((const time_t *)&tv.tv_sec, &tm);
> >> -- 
> >> 2.7.4
> >>
> 
-- 
Dr. David Alan Gilbert / dgilbert@redhat.com / Manchester, UK



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

end of thread, other threads:[~2020-12-17 17:43 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-08  6:53 [PATCH 0/2] savevm: Delete stale snapshots in save_snapshot() Tuguoyi
2020-12-08  6:53 ` [PATCH 1/2] savevm: Remove dead code " Tuguoyi
2020-12-17 15:27   ` Dr. David Alan Gilbert
2020-12-17 16:14     ` Denis V. Lunev
2020-12-17 17:32       ` Dr. David Alan Gilbert
2020-12-08  6:53 ` [PATCH 2/2] savevm: Delete snapshots just created in case of error Tuguoyi
2020-12-17 15:38   ` Dr. David Alan Gilbert

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