qapi: Correct error message for 'vcpu_dirty_limit' parameter
[qemu/armbru.git] / block / snapshot.c
blob8fd17567773f47af99218d0a7e5fe11cc9f8f411
1 /*
2 * Block layer snapshot related functions
4 * Copyright (c) 2003-2008 Fabrice Bellard
6 * Permission is hereby granted, free of charge, to any person obtaining a copy
7 * of this software and associated documentation files (the "Software"), to deal
8 * in the Software without restriction, including without limitation the rights
9 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10 * copies of the Software, and to permit persons to whom the Software is
11 * furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included in
14 * all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22 * THE SOFTWARE.
25 #include "qemu/osdep.h"
26 #include "block/snapshot.h"
27 #include "block/block_int.h"
28 #include "block/qdict.h"
29 #include "qapi/error.h"
30 #include "qapi/qmp/qdict.h"
31 #include "qapi/qmp/qstring.h"
32 #include "qemu/option.h"
33 #include "sysemu/block-backend.h"
35 QemuOptsList internal_snapshot_opts = {
36 .name = "snapshot",
37 .head = QTAILQ_HEAD_INITIALIZER(internal_snapshot_opts.head),
38 .desc = {
40 .name = SNAPSHOT_OPT_ID,
41 .type = QEMU_OPT_STRING,
42 .help = "snapshot id"
43 },{
44 .name = SNAPSHOT_OPT_NAME,
45 .type = QEMU_OPT_STRING,
46 .help = "snapshot name"
47 },{
48 /* end of list */
53 int bdrv_snapshot_find(BlockDriverState *bs, QEMUSnapshotInfo *sn_info,
54 const char *name)
56 QEMUSnapshotInfo *sn_tab, *sn;
57 int nb_sns, i, ret;
59 GLOBAL_STATE_CODE();
61 ret = -ENOENT;
62 nb_sns = bdrv_snapshot_list(bs, &sn_tab);
63 if (nb_sns < 0) {
64 return ret;
66 for (i = 0; i < nb_sns; i++) {
67 sn = &sn_tab[i];
68 if (!strcmp(sn->name, name)) {
69 *sn_info = *sn;
70 ret = 0;
71 break;
74 g_free(sn_tab);
75 return ret;
78 /**
79 * Look up an internal snapshot by @id and @name.
80 * @bs: block device to search
81 * @id: unique snapshot ID, or NULL
82 * @name: snapshot name, or NULL
83 * @sn_info: location to store information on the snapshot found
84 * @errp: location to store error, will be set only for exception
86 * This function will traverse snapshot list in @bs to search the matching
87 * one, @id and @name are the matching condition:
88 * If both @id and @name are specified, find the first one with id @id and
89 * name @name.
90 * If only @id is specified, find the first one with id @id.
91 * If only @name is specified, find the first one with name @name.
92 * if none is specified, abort().
94 * Returns: true when a snapshot is found and @sn_info will be filled, false
95 * when error or not found. If all operation succeed but no matching one is
96 * found, @errp will NOT be set.
98 bool bdrv_snapshot_find_by_id_and_name(BlockDriverState *bs,
99 const char *id,
100 const char *name,
101 QEMUSnapshotInfo *sn_info,
102 Error **errp)
104 QEMUSnapshotInfo *sn_tab, *sn;
105 int nb_sns, i;
106 bool ret = false;
108 assert(id || name);
109 GLOBAL_STATE_CODE();
111 nb_sns = bdrv_snapshot_list(bs, &sn_tab);
112 if (nb_sns < 0) {
113 error_setg_errno(errp, -nb_sns, "Failed to get a snapshot list");
114 return false;
115 } else if (nb_sns == 0) {
116 return false;
119 if (id && name) {
120 for (i = 0; i < nb_sns; i++) {
121 sn = &sn_tab[i];
122 if (!strcmp(sn->id_str, id) && !strcmp(sn->name, name)) {
123 *sn_info = *sn;
124 ret = true;
125 break;
128 } else if (id) {
129 for (i = 0; i < nb_sns; i++) {
130 sn = &sn_tab[i];
131 if (!strcmp(sn->id_str, id)) {
132 *sn_info = *sn;
133 ret = true;
134 break;
137 } else if (name) {
138 for (i = 0; i < nb_sns; i++) {
139 sn = &sn_tab[i];
140 if (!strcmp(sn->name, name)) {
141 *sn_info = *sn;
142 ret = true;
143 break;
148 g_free(sn_tab);
149 return ret;
153 * Return a pointer to child of given BDS to which we can fall
154 * back if the given BDS does not support snapshots.
155 * Return NULL if there is no BDS to (safely) fall back to.
157 static BdrvChild * GRAPH_RDLOCK
158 bdrv_snapshot_fallback_child(BlockDriverState *bs)
160 BdrvChild *fallback = bdrv_primary_child(bs);
161 BdrvChild *child;
163 GLOBAL_STATE_CODE();
164 assert_bdrv_graph_readable();
166 /* We allow fallback only to primary child */
167 if (!fallback) {
168 return NULL;
172 * Check that there are no other children that would need to be
173 * snapshotted. If there are, it is not safe to fall back to
174 * fallback.
176 QLIST_FOREACH(child, &bs->children, next) {
177 if (child->role & (BDRV_CHILD_DATA | BDRV_CHILD_METADATA |
178 BDRV_CHILD_FILTERED) &&
179 child != fallback)
181 return NULL;
185 return fallback;
188 static BlockDriverState * GRAPH_RDLOCK
189 bdrv_snapshot_fallback(BlockDriverState *bs)
191 GLOBAL_STATE_CODE();
192 return child_bs(bdrv_snapshot_fallback_child(bs));
195 int bdrv_can_snapshot(BlockDriverState *bs)
197 BlockDriver *drv = bs->drv;
199 GLOBAL_STATE_CODE();
201 if (!drv || !bdrv_is_inserted(bs) || !bdrv_is_writable(bs)) {
202 return 0;
205 if (!drv->bdrv_snapshot_create) {
206 BlockDriverState *fallback_bs = bdrv_snapshot_fallback(bs);
207 if (fallback_bs) {
208 return bdrv_can_snapshot(fallback_bs);
210 return 0;
213 return 1;
216 int bdrv_snapshot_create(BlockDriverState *bs,
217 QEMUSnapshotInfo *sn_info)
219 BlockDriver *drv = bs->drv;
220 BlockDriverState *fallback_bs = bdrv_snapshot_fallback(bs);
222 GLOBAL_STATE_CODE();
224 if (!drv) {
225 return -ENOMEDIUM;
227 if (drv->bdrv_snapshot_create) {
228 return drv->bdrv_snapshot_create(bs, sn_info);
230 if (fallback_bs) {
231 return bdrv_snapshot_create(fallback_bs, sn_info);
233 return -ENOTSUP;
236 int bdrv_snapshot_goto(BlockDriverState *bs,
237 const char *snapshot_id,
238 Error **errp)
240 BlockDriver *drv = bs->drv;
241 BdrvChild *fallback;
242 int ret, open_ret;
244 GLOBAL_STATE_CODE();
246 if (!drv) {
247 error_setg(errp, "Block driver is closed");
248 return -ENOMEDIUM;
251 if (!QLIST_EMPTY(&bs->dirty_bitmaps)) {
252 error_setg(errp, "Device has active dirty bitmaps");
253 return -EBUSY;
256 if (drv->bdrv_snapshot_goto) {
257 ret = drv->bdrv_snapshot_goto(bs, snapshot_id);
258 if (ret < 0) {
259 error_setg_errno(errp, -ret, "Failed to load snapshot");
261 return ret;
264 bdrv_graph_rdlock_main_loop();
265 fallback = bdrv_snapshot_fallback_child(bs);
266 bdrv_graph_rdunlock_main_loop();
268 if (fallback) {
269 QDict *options;
270 QDict *file_options;
271 Error *local_err = NULL;
272 BlockDriverState *fallback_bs = fallback->bs;
273 char *subqdict_prefix = g_strdup_printf("%s.", fallback->name);
275 options = qdict_clone_shallow(bs->options);
277 /* Prevent it from getting deleted when detached from bs */
278 bdrv_ref(fallback_bs);
280 qdict_extract_subqdict(options, &file_options, subqdict_prefix);
281 qobject_unref(file_options);
282 g_free(subqdict_prefix);
284 /* Force .bdrv_open() below to re-attach fallback_bs on fallback */
285 qdict_put_str(options, fallback->name,
286 bdrv_get_node_name(fallback_bs));
288 /* Now close bs, apply the snapshot on fallback_bs, and re-open bs */
289 if (drv->bdrv_close) {
290 drv->bdrv_close(bs);
293 /* .bdrv_open() will re-attach it */
294 bdrv_graph_wrlock();
295 bdrv_unref_child(bs, fallback);
296 bdrv_graph_wrunlock();
298 ret = bdrv_snapshot_goto(fallback_bs, snapshot_id, errp);
299 open_ret = drv->bdrv_open(bs, options, bs->open_flags, &local_err);
300 qobject_unref(options);
301 if (open_ret < 0) {
302 bdrv_unref(fallback_bs);
303 bs->drv = NULL;
304 /* A bdrv_snapshot_goto() error takes precedence */
305 error_propagate(errp, local_err);
306 return ret < 0 ? ret : open_ret;
310 * fallback was a primary child. It was closed above and set to NULL,
311 * but the .bdrv_open() call has opened it again, because we set the
312 * respective option (with the qdict_put_str() call above).
313 * Assert that .bdrv_open() has attached the right BDS as primary child.
315 bdrv_graph_rdlock_main_loop();
316 assert(bdrv_primary_bs(bs) == fallback_bs);
317 bdrv_graph_rdunlock_main_loop();
319 bdrv_unref(fallback_bs);
320 return ret;
323 error_setg(errp, "Block driver does not support snapshots");
324 return -ENOTSUP;
328 * Delete an internal snapshot by @snapshot_id and @name.
329 * @bs: block device used in the operation
330 * @snapshot_id: unique snapshot ID, or NULL
331 * @name: snapshot name, or NULL
332 * @errp: location to store error
334 * If both @snapshot_id and @name are specified, delete the first one with
335 * id @snapshot_id and name @name.
336 * If only @snapshot_id is specified, delete the first one with id
337 * @snapshot_id.
338 * If only @name is specified, delete the first one with name @name.
339 * if none is specified, return -EINVAL.
341 * Returns: 0 on success, -errno on failure. If @bs is not inserted, return
342 * -ENOMEDIUM. If @snapshot_id and @name are both NULL, return -EINVAL. If @bs
343 * does not support internal snapshot deletion, return -ENOTSUP. If @bs does
344 * not support parameter @snapshot_id or @name, or one of them is not correctly
345 * specified, return -EINVAL. If @bs can't find one matching @id and @name,
346 * return -ENOENT. If @errp != NULL, it will always be filled with error
347 * message on failure.
349 int bdrv_snapshot_delete(BlockDriverState *bs,
350 const char *snapshot_id,
351 const char *name,
352 Error **errp)
354 BlockDriver *drv = bs->drv;
355 BlockDriverState *fallback_bs = bdrv_snapshot_fallback(bs);
356 int ret;
358 GLOBAL_STATE_CODE();
360 if (!drv) {
361 error_setg(errp, "Device '%s' has no medium",
362 bdrv_get_device_name(bs));
363 return -ENOMEDIUM;
365 if (!snapshot_id && !name) {
366 error_setg(errp, "snapshot_id and name are both NULL");
367 return -EINVAL;
370 /* drain all pending i/o before deleting snapshot */
371 bdrv_drained_begin(bs);
373 if (drv->bdrv_snapshot_delete) {
374 ret = drv->bdrv_snapshot_delete(bs, snapshot_id, name, errp);
375 } else if (fallback_bs) {
376 ret = bdrv_snapshot_delete(fallback_bs, snapshot_id, name, errp);
377 } else {
378 error_setg(errp, "Block format '%s' used by device '%s' "
379 "does not support internal snapshot deletion",
380 drv->format_name, bdrv_get_device_name(bs));
381 ret = -ENOTSUP;
384 bdrv_drained_end(bs);
385 return ret;
388 int bdrv_snapshot_list(BlockDriverState *bs,
389 QEMUSnapshotInfo **psn_info)
391 GLOBAL_STATE_CODE();
392 GRAPH_RDLOCK_GUARD_MAINLOOP();
394 BlockDriver *drv = bs->drv;
395 BlockDriverState *fallback_bs = bdrv_snapshot_fallback(bs);
397 if (!drv) {
398 return -ENOMEDIUM;
400 if (drv->bdrv_snapshot_list) {
401 return drv->bdrv_snapshot_list(bs, psn_info);
403 if (fallback_bs) {
404 return bdrv_snapshot_list(fallback_bs, psn_info);
406 return -ENOTSUP;
410 * Temporarily load an internal snapshot by @snapshot_id and @name.
411 * @bs: block device used in the operation
412 * @snapshot_id: unique snapshot ID, or NULL
413 * @name: snapshot name, or NULL
414 * @errp: location to store error
416 * If both @snapshot_id and @name are specified, load the first one with
417 * id @snapshot_id and name @name.
418 * If only @snapshot_id is specified, load the first one with id
419 * @snapshot_id.
420 * If only @name is specified, load the first one with name @name.
421 * if none is specified, return -EINVAL.
423 * Returns: 0 on success, -errno on fail. If @bs is not inserted, return
424 * -ENOMEDIUM. If @bs is not readonly, return -EINVAL. If @bs did not support
425 * internal snapshot, return -ENOTSUP. If qemu can't find a matching @id and
426 * @name, return -ENOENT. If @errp != NULL, it will always be filled on
427 * failure.
429 int bdrv_snapshot_load_tmp(BlockDriverState *bs,
430 const char *snapshot_id,
431 const char *name,
432 Error **errp)
434 BlockDriver *drv = bs->drv;
436 GLOBAL_STATE_CODE();
437 GRAPH_RDLOCK_GUARD_MAINLOOP();
439 if (!drv) {
440 error_setg(errp, "Device '%s' has no medium",
441 bdrv_get_device_name(bs));
442 return -ENOMEDIUM;
444 if (!snapshot_id && !name) {
445 error_setg(errp, "snapshot_id and name are both NULL");
446 return -EINVAL;
448 if (!bdrv_is_read_only(bs)) {
449 error_setg(errp, "Device is not readonly");
450 return -EINVAL;
452 if (drv->bdrv_snapshot_load_tmp) {
453 return drv->bdrv_snapshot_load_tmp(bs, snapshot_id, name, errp);
455 error_setg(errp, "Block format '%s' used by device '%s' "
456 "does not support temporarily loading internal snapshots",
457 drv->format_name, bdrv_get_device_name(bs));
458 return -ENOTSUP;
461 int bdrv_snapshot_load_tmp_by_id_or_name(BlockDriverState *bs,
462 const char *id_or_name,
463 Error **errp)
465 int ret;
466 Error *local_err = NULL;
468 GLOBAL_STATE_CODE();
470 ret = bdrv_snapshot_load_tmp(bs, id_or_name, NULL, &local_err);
471 if (ret == -ENOENT || ret == -EINVAL) {
472 error_free(local_err);
473 local_err = NULL;
474 ret = bdrv_snapshot_load_tmp(bs, NULL, id_or_name, &local_err);
477 error_propagate(errp, local_err);
479 return ret;
483 static int GRAPH_RDLOCK
484 bdrv_all_get_snapshot_devices(bool has_devices, strList *devices,
485 GList **all_bdrvs, Error **errp)
487 g_autoptr(GList) bdrvs = NULL;
489 if (has_devices) {
490 if (!devices) {
491 error_setg(errp, "At least one device is required for snapshot");
492 return -1;
495 while (devices) {
496 BlockDriverState *bs = bdrv_find_node(devices->value);
497 if (!bs) {
498 error_setg(errp, "No block device node '%s'", devices->value);
499 return -1;
501 bdrvs = g_list_append(bdrvs, bs);
502 devices = devices->next;
504 } else {
505 BlockDriverState *bs;
506 BdrvNextIterator it;
507 for (bs = bdrv_first(&it); bs; bs = bdrv_next(&it)) {
508 bdrvs = g_list_append(bdrvs, bs);
512 *all_bdrvs = g_steal_pointer(&bdrvs);
513 return 0;
517 static bool GRAPH_RDLOCK bdrv_all_snapshots_includes_bs(BlockDriverState *bs)
519 GLOBAL_STATE_CODE();
520 assert_bdrv_graph_readable();
522 if (!bdrv_is_inserted(bs) || bdrv_is_read_only(bs)) {
523 return false;
526 /* Include all nodes that are either in use by a BlockBackend, or that
527 * aren't attached to any node, but owned by the monitor. */
528 return bdrv_has_blk(bs) || QLIST_EMPTY(&bs->parents);
531 /* Group operations. All block drivers are involved. */
533 bool bdrv_all_can_snapshot(bool has_devices, strList *devices,
534 Error **errp)
536 g_autoptr(GList) bdrvs = NULL;
537 GList *iterbdrvs;
539 GLOBAL_STATE_CODE();
540 GRAPH_RDLOCK_GUARD_MAINLOOP();
542 if (bdrv_all_get_snapshot_devices(has_devices, devices, &bdrvs, errp) < 0) {
543 return false;
546 iterbdrvs = bdrvs;
547 while (iterbdrvs) {
548 BlockDriverState *bs = iterbdrvs->data;
549 bool ok = true;
551 if (devices || bdrv_all_snapshots_includes_bs(bs)) {
552 ok = bdrv_can_snapshot(bs);
554 if (!ok) {
555 error_setg(errp, "Device '%s' is writable but does not support "
556 "snapshots", bdrv_get_device_or_node_name(bs));
557 return false;
560 iterbdrvs = iterbdrvs->next;
563 return true;
566 int bdrv_all_delete_snapshot(const char *name,
567 bool has_devices, strList *devices,
568 Error **errp)
570 ERRP_GUARD();
571 g_autoptr(GList) bdrvs = NULL;
572 GList *iterbdrvs;
574 GLOBAL_STATE_CODE();
575 GRAPH_RDLOCK_GUARD_MAINLOOP();
577 if (bdrv_all_get_snapshot_devices(has_devices, devices, &bdrvs, errp) < 0) {
578 return -1;
581 iterbdrvs = bdrvs;
582 while (iterbdrvs) {
583 BlockDriverState *bs = iterbdrvs->data;
584 QEMUSnapshotInfo sn1, *snapshot = &sn1;
585 int ret = 0;
587 if ((devices || bdrv_all_snapshots_includes_bs(bs)) &&
588 bdrv_snapshot_find(bs, snapshot, name) >= 0)
590 ret = bdrv_snapshot_delete(bs, snapshot->id_str,
591 snapshot->name, errp);
593 if (ret < 0) {
594 error_prepend(errp, "Could not delete snapshot '%s' on '%s': ",
595 name, bdrv_get_device_or_node_name(bs));
596 return -1;
599 iterbdrvs = iterbdrvs->next;
602 return 0;
606 int bdrv_all_goto_snapshot(const char *name,
607 bool has_devices, strList *devices,
608 Error **errp)
610 ERRP_GUARD();
611 g_autoptr(GList) bdrvs = NULL;
612 GList *iterbdrvs;
613 int ret;
615 GLOBAL_STATE_CODE();
617 bdrv_graph_rdlock_main_loop();
618 ret = bdrv_all_get_snapshot_devices(has_devices, devices, &bdrvs, errp);
619 bdrv_graph_rdunlock_main_loop();
621 if (ret < 0) {
622 return -1;
625 iterbdrvs = bdrvs;
626 while (iterbdrvs) {
627 BlockDriverState *bs = iterbdrvs->data;
628 bool all_snapshots_includes_bs;
630 bdrv_graph_rdlock_main_loop();
631 all_snapshots_includes_bs = bdrv_all_snapshots_includes_bs(bs);
632 bdrv_graph_rdunlock_main_loop();
634 ret = (devices || all_snapshots_includes_bs) ?
635 bdrv_snapshot_goto(bs, name, errp) : 0;
636 if (ret < 0) {
637 bdrv_graph_rdlock_main_loop();
638 error_prepend(errp, "Could not load snapshot '%s' on '%s': ",
639 name, bdrv_get_device_or_node_name(bs));
640 bdrv_graph_rdunlock_main_loop();
641 return -1;
644 iterbdrvs = iterbdrvs->next;
647 return 0;
650 int bdrv_all_has_snapshot(const char *name,
651 bool has_devices, strList *devices,
652 Error **errp)
654 g_autoptr(GList) bdrvs = NULL;
655 GList *iterbdrvs;
657 GLOBAL_STATE_CODE();
658 GRAPH_RDLOCK_GUARD_MAINLOOP();
660 if (bdrv_all_get_snapshot_devices(has_devices, devices, &bdrvs, errp) < 0) {
661 return -1;
664 iterbdrvs = bdrvs;
665 while (iterbdrvs) {
666 BlockDriverState *bs = iterbdrvs->data;
667 QEMUSnapshotInfo sn;
668 int ret = 0;
670 if (devices || bdrv_all_snapshots_includes_bs(bs)) {
671 ret = bdrv_snapshot_find(bs, &sn, name);
673 if (ret < 0) {
674 if (ret == -ENOENT) {
675 return 0;
676 } else {
677 error_setg_errno(errp, errno,
678 "Could not check snapshot '%s' on '%s'",
679 name, bdrv_get_device_or_node_name(bs));
680 return -1;
684 iterbdrvs = iterbdrvs->next;
687 return 1;
690 int bdrv_all_create_snapshot(QEMUSnapshotInfo *sn,
691 BlockDriverState *vm_state_bs,
692 uint64_t vm_state_size,
693 bool has_devices, strList *devices,
694 Error **errp)
696 g_autoptr(GList) bdrvs = NULL;
697 GList *iterbdrvs;
699 GLOBAL_STATE_CODE();
700 GRAPH_RDLOCK_GUARD_MAINLOOP();
702 if (bdrv_all_get_snapshot_devices(has_devices, devices, &bdrvs, errp) < 0) {
703 return -1;
706 iterbdrvs = bdrvs;
707 while (iterbdrvs) {
708 BlockDriverState *bs = iterbdrvs->data;
709 int ret = 0;
711 if (bs == vm_state_bs) {
712 sn->vm_state_size = vm_state_size;
713 ret = bdrv_snapshot_create(bs, sn);
714 } else if (devices || bdrv_all_snapshots_includes_bs(bs)) {
715 sn->vm_state_size = 0;
716 ret = bdrv_snapshot_create(bs, sn);
718 if (ret < 0) {
719 error_setg(errp, "Could not create snapshot '%s' on '%s'",
720 sn->name, bdrv_get_device_or_node_name(bs));
721 return -1;
724 iterbdrvs = iterbdrvs->next;
727 return 0;
731 BlockDriverState *bdrv_all_find_vmstate_bs(const char *vmstate_bs,
732 bool has_devices, strList *devices,
733 Error **errp)
735 g_autoptr(GList) bdrvs = NULL;
736 GList *iterbdrvs;
738 GLOBAL_STATE_CODE();
739 GRAPH_RDLOCK_GUARD_MAINLOOP();
741 if (bdrv_all_get_snapshot_devices(has_devices, devices, &bdrvs, errp) < 0) {
742 return NULL;
745 iterbdrvs = bdrvs;
746 while (iterbdrvs) {
747 BlockDriverState *bs = iterbdrvs->data;
748 bool found = false;
750 found = (devices || bdrv_all_snapshots_includes_bs(bs)) &&
751 bdrv_can_snapshot(bs);
753 if (vmstate_bs) {
754 if (g_str_equal(vmstate_bs,
755 bdrv_get_node_name(bs))) {
756 if (found) {
757 return bs;
758 } else {
759 error_setg(errp,
760 "vmstate block device '%s' does not support snapshots",
761 vmstate_bs);
762 return NULL;
765 } else if (found) {
766 return bs;
769 iterbdrvs = iterbdrvs->next;
772 if (vmstate_bs) {
773 error_setg(errp,
774 "vmstate block device '%s' does not exist", vmstate_bs);
775 } else {
776 error_setg(errp,
777 "no block device can store vmstate for snapshot");
779 return NULL;